diff --git a/gapic/templates/%namespace/%name_%version/%sub/services/%service/_shared_macros.j2 b/gapic/templates/%namespace/%name_%version/%sub/services/%service/_shared_macros.j2 index f588391bd..6aeae0cc9 100644 --- a/gapic/templates/%namespace/%name_%version/%sub/services/%service/_shared_macros.j2 +++ b/gapic/templates/%namespace/%name_%version/%sub/services/%service/_shared_macros.j2 @@ -389,7 +389,20 @@ class {{ async_method_name_prefix }}{{ service.name }}RestInterceptor: """ return response + {% if not method.server_streaming %} + {{ async_prefix }}def post_{{ method.name|snake_case }}_with_metadata(self, response: {{method.output.ident}}, {{ client_method_metadata_argument() }}) -> Tuple[{{method.output.ident}}, {{ client_method_metadata_type() }}]: + {% else %} + {{ async_prefix }}def post_{{ method.name|snake_case }}_with_metadata(self, response: rest_streaming{{ async_suffix }}.{{ async_method_name_prefix }}ResponseIterator, {{ client_method_metadata_argument() }}) -> Tuple[rest_streaming{{ async_suffix }}.{{ async_method_name_prefix }}ResponseIterator, {{ client_method_metadata_type() }}]: {% endif %} + """Post-rpc interceptor for {{ method.name|snake_case }} + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the {{ service.name }} server but before + it is returned to user code. + """ + return response, metadata + + {% endif %}{# not method.void #} {% endfor %} {% for name, signature in api.mixin_api_signatures.items() %} diff --git a/gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/rest.py.j2 b/gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/rest.py.j2 index 3ba65b993..63adba192 100644 --- a/gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/rest.py.j2 +++ b/gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/rest.py.j2 @@ -256,6 +256,8 @@ class {{service.name}}RestTransport(_Base{{ service.name }}RestTransport): {% endif %}{# method.lro #} {#- TODO(https://github.com/googleapis/gapic-generator-python/issues/2274): Add debug log before intercepting a request #} resp = self._interceptor.post_{{ method.name|snake_case }}(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_{{ method.name|snake_case }}_with_metadata(resp, response_metadata) {# TODO(https://github.com/googleapis/gapic-generator-python/issues/2279): Add logging support for rest streaming. #} {% if not method.server_streaming %} if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER diff --git a/gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/rest_asyncio.py.j2 b/gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/rest_asyncio.py.j2 index 99658a0b1..79d54e4f2 100644 --- a/gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/rest_asyncio.py.j2 +++ b/gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/rest_asyncio.py.j2 @@ -217,6 +217,8 @@ class Async{{service.name}}RestTransport(_Base{{ service.name }}RestTransport): json_format.Parse(content, pb_resp, ignore_unknown_fields=True) {% endif %}{# if method.server_streaming #} resp = await self._interceptor.post_{{ method.name|snake_case }}(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = await self._interceptor.post_{{ method.name|snake_case }}_with_metadata(resp, response_metadata) {# TODO(https://github.com/googleapis/gapic-generator-python/issues/2279): Add logging support for rest streaming. #} {% if not method.server_streaming %} if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER diff --git a/gapic/templates/tests/unit/gapic/%name_%version/%sub/test_macros.j2 b/gapic/templates/tests/unit/gapic/%name_%version/%sub/test_macros.j2 index bd8547f63..33b76774c 100644 --- a/gapic/templates/tests/unit/gapic/%name_%version/%sub/test_macros.j2 +++ b/gapic/templates/tests/unit/gapic/%name_%version/%sub/test_macros.j2 @@ -2218,11 +2218,13 @@ def test_initialize_client_w_{{transport_name}}(): {% endif %} {% if not method.void %} mock.patch.object(transports.{{async_method_prefix}}{{ service.name }}RestInterceptor, "post_{{method.name|snake_case}}") as post, \ + mock.patch.object(transports.{{async_method_prefix}}{{ service.name }}RestInterceptor, "post_{{method.name|snake_case}}_with_metadata") as post_with_metadata, \ {% endif %} mock.patch.object(transports.{{async_method_prefix}}{{ service.name }}RestInterceptor, "pre_{{ method.name|snake_case }}") as pre: pre.assert_not_called() {% if not method.void %} post.assert_not_called() + post_with_metadata.assert_not_called() {% endif %} {% if method.input.ident.is_proto_plus_type %} pb_message = {{ method.input.ident }}.pb({{ method.input.ident }}()) @@ -2265,6 +2267,7 @@ def test_initialize_client_w_{{transport_name}}(): pre.return_value = request, metadata {% if not method.void %} post.return_value = {{ method.output.ident }}() + post_with_metadata.return_value = {{ method.output.ident }}(), metadata {% endif %} {{await_prefix}}client.{{ method_name }}(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) @@ -2272,6 +2275,7 @@ def test_initialize_client_w_{{transport_name}}(): pre.assert_called_once() {% if not method.void %} post.assert_called_once() + post_with_metadata.assert_called_once() {% endif %} {% endif %}{# end 'grpc' in transport #} {% endmacro%}{# inteceptor_class_test #} diff --git a/tests/integration/goldens/asset/google/cloud/asset_v1/services/asset_service/transports/rest.py b/tests/integration/goldens/asset/google/cloud/asset_v1/services/asset_service/transports/rest.py index 053297f16..1e1f07f89 100755 --- a/tests/integration/goldens/asset/google/cloud/asset_v1/services/asset_service/transports/rest.py +++ b/tests/integration/goldens/asset/google/cloud/asset_v1/services/asset_service/transports/rest.py @@ -274,6 +274,15 @@ def post_analyze_iam_policy(self, response: asset_service.AnalyzeIamPolicyRespon """ return response + def post_analyze_iam_policy_with_metadata(self, response: asset_service.AnalyzeIamPolicyResponse, metadata: Sequence[Tuple[str, str]]) -> Tuple[asset_service.AnalyzeIamPolicyResponse, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for analyze_iam_policy + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the AssetService server but before + it is returned to user code. + """ + return response, metadata + def pre_analyze_iam_policy_longrunning(self, request: asset_service.AnalyzeIamPolicyLongrunningRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[asset_service.AnalyzeIamPolicyLongrunningRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for analyze_iam_policy_longrunning @@ -291,6 +300,15 @@ def post_analyze_iam_policy_longrunning(self, response: operations_pb2.Operation """ return response + def post_analyze_iam_policy_longrunning_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, str]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for analyze_iam_policy_longrunning + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the AssetService server but before + it is returned to user code. + """ + return response, metadata + def pre_analyze_move(self, request: asset_service.AnalyzeMoveRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[asset_service.AnalyzeMoveRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for analyze_move @@ -308,6 +326,15 @@ def post_analyze_move(self, response: asset_service.AnalyzeMoveResponse) -> asse """ return response + def post_analyze_move_with_metadata(self, response: asset_service.AnalyzeMoveResponse, metadata: Sequence[Tuple[str, str]]) -> Tuple[asset_service.AnalyzeMoveResponse, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for analyze_move + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the AssetService server but before + it is returned to user code. + """ + return response, metadata + def pre_analyze_org_policies(self, request: asset_service.AnalyzeOrgPoliciesRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[asset_service.AnalyzeOrgPoliciesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for analyze_org_policies @@ -325,6 +352,15 @@ def post_analyze_org_policies(self, response: asset_service.AnalyzeOrgPoliciesRe """ return response + def post_analyze_org_policies_with_metadata(self, response: asset_service.AnalyzeOrgPoliciesResponse, metadata: Sequence[Tuple[str, str]]) -> Tuple[asset_service.AnalyzeOrgPoliciesResponse, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for analyze_org_policies + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the AssetService server but before + it is returned to user code. + """ + return response, metadata + def pre_analyze_org_policy_governed_assets(self, request: asset_service.AnalyzeOrgPolicyGovernedAssetsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[asset_service.AnalyzeOrgPolicyGovernedAssetsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for analyze_org_policy_governed_assets @@ -342,6 +378,15 @@ def post_analyze_org_policy_governed_assets(self, response: asset_service.Analyz """ return response + def post_analyze_org_policy_governed_assets_with_metadata(self, response: asset_service.AnalyzeOrgPolicyGovernedAssetsResponse, metadata: Sequence[Tuple[str, str]]) -> Tuple[asset_service.AnalyzeOrgPolicyGovernedAssetsResponse, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for analyze_org_policy_governed_assets + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the AssetService server but before + it is returned to user code. + """ + return response, metadata + def pre_analyze_org_policy_governed_containers(self, request: asset_service.AnalyzeOrgPolicyGovernedContainersRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[asset_service.AnalyzeOrgPolicyGovernedContainersRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for analyze_org_policy_governed_containers @@ -359,6 +404,15 @@ def post_analyze_org_policy_governed_containers(self, response: asset_service.An """ return response + def post_analyze_org_policy_governed_containers_with_metadata(self, response: asset_service.AnalyzeOrgPolicyGovernedContainersResponse, metadata: Sequence[Tuple[str, str]]) -> Tuple[asset_service.AnalyzeOrgPolicyGovernedContainersResponse, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for analyze_org_policy_governed_containers + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the AssetService server but before + it is returned to user code. + """ + return response, metadata + def pre_batch_get_assets_history(self, request: asset_service.BatchGetAssetsHistoryRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[asset_service.BatchGetAssetsHistoryRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for batch_get_assets_history @@ -376,6 +430,15 @@ def post_batch_get_assets_history(self, response: asset_service.BatchGetAssetsHi """ return response + def post_batch_get_assets_history_with_metadata(self, response: asset_service.BatchGetAssetsHistoryResponse, metadata: Sequence[Tuple[str, str]]) -> Tuple[asset_service.BatchGetAssetsHistoryResponse, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for batch_get_assets_history + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the AssetService server but before + it is returned to user code. + """ + return response, metadata + def pre_batch_get_effective_iam_policies(self, request: asset_service.BatchGetEffectiveIamPoliciesRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[asset_service.BatchGetEffectiveIamPoliciesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for batch_get_effective_iam_policies @@ -393,6 +456,15 @@ def post_batch_get_effective_iam_policies(self, response: asset_service.BatchGet """ return response + def post_batch_get_effective_iam_policies_with_metadata(self, response: asset_service.BatchGetEffectiveIamPoliciesResponse, metadata: Sequence[Tuple[str, str]]) -> Tuple[asset_service.BatchGetEffectiveIamPoliciesResponse, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for batch_get_effective_iam_policies + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the AssetService server but before + it is returned to user code. + """ + return response, metadata + def pre_create_feed(self, request: asset_service.CreateFeedRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[asset_service.CreateFeedRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_feed @@ -410,6 +482,15 @@ def post_create_feed(self, response: asset_service.Feed) -> asset_service.Feed: """ return response + def post_create_feed_with_metadata(self, response: asset_service.Feed, metadata: Sequence[Tuple[str, str]]) -> Tuple[asset_service.Feed, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for create_feed + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the AssetService server but before + it is returned to user code. + """ + return response, metadata + def pre_create_saved_query(self, request: asset_service.CreateSavedQueryRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[asset_service.CreateSavedQueryRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_saved_query @@ -427,6 +508,15 @@ def post_create_saved_query(self, response: asset_service.SavedQuery) -> asset_s """ return response + def post_create_saved_query_with_metadata(self, response: asset_service.SavedQuery, metadata: Sequence[Tuple[str, str]]) -> Tuple[asset_service.SavedQuery, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for create_saved_query + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the AssetService server but before + it is returned to user code. + """ + return response, metadata + def pre_delete_feed(self, request: asset_service.DeleteFeedRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[asset_service.DeleteFeedRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_feed @@ -460,6 +550,15 @@ def post_export_assets(self, response: operations_pb2.Operation) -> operations_p """ return response + def post_export_assets_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, str]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for export_assets + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the AssetService server but before + it is returned to user code. + """ + return response, metadata + def pre_get_feed(self, request: asset_service.GetFeedRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[asset_service.GetFeedRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_feed @@ -477,6 +576,15 @@ def post_get_feed(self, response: asset_service.Feed) -> asset_service.Feed: """ return response + def post_get_feed_with_metadata(self, response: asset_service.Feed, metadata: Sequence[Tuple[str, str]]) -> Tuple[asset_service.Feed, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for get_feed + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the AssetService server but before + it is returned to user code. + """ + return response, metadata + def pre_get_saved_query(self, request: asset_service.GetSavedQueryRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[asset_service.GetSavedQueryRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_saved_query @@ -494,6 +602,15 @@ def post_get_saved_query(self, response: asset_service.SavedQuery) -> asset_serv """ return response + def post_get_saved_query_with_metadata(self, response: asset_service.SavedQuery, metadata: Sequence[Tuple[str, str]]) -> Tuple[asset_service.SavedQuery, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for get_saved_query + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the AssetService server but before + it is returned to user code. + """ + return response, metadata + def pre_list_assets(self, request: asset_service.ListAssetsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[asset_service.ListAssetsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_assets @@ -511,6 +628,15 @@ def post_list_assets(self, response: asset_service.ListAssetsResponse) -> asset_ """ return response + def post_list_assets_with_metadata(self, response: asset_service.ListAssetsResponse, metadata: Sequence[Tuple[str, str]]) -> Tuple[asset_service.ListAssetsResponse, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for list_assets + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the AssetService server but before + it is returned to user code. + """ + return response, metadata + def pre_list_feeds(self, request: asset_service.ListFeedsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[asset_service.ListFeedsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_feeds @@ -528,6 +654,15 @@ def post_list_feeds(self, response: asset_service.ListFeedsResponse) -> asset_se """ return response + def post_list_feeds_with_metadata(self, response: asset_service.ListFeedsResponse, metadata: Sequence[Tuple[str, str]]) -> Tuple[asset_service.ListFeedsResponse, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for list_feeds + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the AssetService server but before + it is returned to user code. + """ + return response, metadata + def pre_list_saved_queries(self, request: asset_service.ListSavedQueriesRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[asset_service.ListSavedQueriesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_saved_queries @@ -545,6 +680,15 @@ def post_list_saved_queries(self, response: asset_service.ListSavedQueriesRespon """ return response + def post_list_saved_queries_with_metadata(self, response: asset_service.ListSavedQueriesResponse, metadata: Sequence[Tuple[str, str]]) -> Tuple[asset_service.ListSavedQueriesResponse, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for list_saved_queries + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the AssetService server but before + it is returned to user code. + """ + return response, metadata + def pre_query_assets(self, request: asset_service.QueryAssetsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[asset_service.QueryAssetsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for query_assets @@ -562,6 +706,15 @@ def post_query_assets(self, response: asset_service.QueryAssetsResponse) -> asse """ return response + def post_query_assets_with_metadata(self, response: asset_service.QueryAssetsResponse, metadata: Sequence[Tuple[str, str]]) -> Tuple[asset_service.QueryAssetsResponse, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for query_assets + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the AssetService server but before + it is returned to user code. + """ + return response, metadata + def pre_search_all_iam_policies(self, request: asset_service.SearchAllIamPoliciesRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[asset_service.SearchAllIamPoliciesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for search_all_iam_policies @@ -579,6 +732,15 @@ def post_search_all_iam_policies(self, response: asset_service.SearchAllIamPolic """ return response + def post_search_all_iam_policies_with_metadata(self, response: asset_service.SearchAllIamPoliciesResponse, metadata: Sequence[Tuple[str, str]]) -> Tuple[asset_service.SearchAllIamPoliciesResponse, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for search_all_iam_policies + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the AssetService server but before + it is returned to user code. + """ + return response, metadata + def pre_search_all_resources(self, request: asset_service.SearchAllResourcesRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[asset_service.SearchAllResourcesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for search_all_resources @@ -596,6 +758,15 @@ def post_search_all_resources(self, response: asset_service.SearchAllResourcesRe """ return response + def post_search_all_resources_with_metadata(self, response: asset_service.SearchAllResourcesResponse, metadata: Sequence[Tuple[str, str]]) -> Tuple[asset_service.SearchAllResourcesResponse, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for search_all_resources + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the AssetService server but before + it is returned to user code. + """ + return response, metadata + def pre_update_feed(self, request: asset_service.UpdateFeedRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[asset_service.UpdateFeedRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_feed @@ -613,6 +784,15 @@ def post_update_feed(self, response: asset_service.Feed) -> asset_service.Feed: """ return response + def post_update_feed_with_metadata(self, response: asset_service.Feed, metadata: Sequence[Tuple[str, str]]) -> Tuple[asset_service.Feed, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for update_feed + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the AssetService server but before + it is returned to user code. + """ + return response, metadata + def pre_update_saved_query(self, request: asset_service.UpdateSavedQueryRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[asset_service.UpdateSavedQueryRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_saved_query @@ -630,6 +810,15 @@ def post_update_saved_query(self, response: asset_service.SavedQuery) -> asset_s """ return response + def post_update_saved_query_with_metadata(self, response: asset_service.SavedQuery, metadata: Sequence[Tuple[str, str]]) -> Tuple[asset_service.SavedQuery, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for update_saved_query + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the AssetService server but before + it is returned to user code. + """ + return response, metadata + def pre_get_operation( self, request: operations_pb2.GetOperationRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]] ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: @@ -871,6 +1060,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_analyze_iam_policy(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_analyze_iam_policy_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = asset_service.AnalyzeIamPolicyResponse.to_json(response) @@ -994,6 +1185,8 @@ def __call__(self, json_format.Parse(response.content, resp, ignore_unknown_fields=True) resp = self._interceptor.post_analyze_iam_policy_longrunning(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_analyze_iam_policy_longrunning_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = json_format.MessageToJson(resp) @@ -1114,6 +1307,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_analyze_move(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_analyze_move_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = asset_service.AnalyzeMoveResponse.to_json(response) @@ -1234,6 +1429,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_analyze_org_policies(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_analyze_org_policies_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = asset_service.AnalyzeOrgPoliciesResponse.to_json(response) @@ -1355,6 +1552,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_analyze_org_policy_governed_assets(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_analyze_org_policy_governed_assets_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = asset_service.AnalyzeOrgPolicyGovernedAssetsResponse.to_json(response) @@ -1476,6 +1675,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_analyze_org_policy_governed_containers(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_analyze_org_policy_governed_containers_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = asset_service.AnalyzeOrgPolicyGovernedContainersResponse.to_json(response) @@ -1593,6 +1794,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_batch_get_assets_history(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_batch_get_assets_history_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = asset_service.BatchGetAssetsHistoryResponse.to_json(response) @@ -1714,6 +1917,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_batch_get_effective_iam_policies(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_batch_get_effective_iam_policies_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = asset_service.BatchGetEffectiveIamPoliciesResponse.to_json(response) @@ -1842,6 +2047,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_create_feed(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_feed_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = asset_service.Feed.to_json(response) @@ -1964,6 +2171,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_create_saved_query(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_saved_query_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = asset_service.SavedQuery.to_json(response) @@ -2255,6 +2464,8 @@ def __call__(self, json_format.Parse(response.content, resp, ignore_unknown_fields=True) resp = self._interceptor.post_export_assets(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_export_assets_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = json_format.MessageToJson(resp) @@ -2380,6 +2591,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_get_feed(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_feed_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = asset_service.Feed.to_json(response) @@ -2499,6 +2712,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_get_saved_query(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_saved_query_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = asset_service.SavedQuery.to_json(response) @@ -2616,6 +2831,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_list_assets(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_assets_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = asset_service.ListAssetsResponse.to_json(response) @@ -2733,6 +2950,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_list_feeds(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_feeds_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = asset_service.ListFeedsResponse.to_json(response) @@ -2850,6 +3069,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_list_saved_queries(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_saved_queries_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = asset_service.ListSavedQueriesResponse.to_json(response) @@ -2970,6 +3191,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_query_assets(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_query_assets_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = asset_service.QueryAssetsResponse.to_json(response) @@ -3087,6 +3310,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_search_all_iam_policies(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_search_all_iam_policies_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = asset_service.SearchAllIamPoliciesResponse.to_json(response) @@ -3204,6 +3429,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_search_all_resources(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_search_all_resources_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = asset_service.SearchAllResourcesResponse.to_json(response) @@ -3332,6 +3559,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_update_feed(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_update_feed_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = asset_service.Feed.to_json(response) @@ -3454,6 +3683,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_update_saved_query(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_update_saved_query_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = asset_service.SavedQuery.to_json(response) diff --git a/tests/integration/goldens/asset/tests/unit/gapic/asset_v1/test_asset_service.py b/tests/integration/goldens/asset/tests/unit/gapic/asset_v1/test_asset_service.py index 61e40a62e..b27b49cd3 100755 --- a/tests/integration/goldens/asset/tests/unit/gapic/asset_v1/test_asset_service.py +++ b/tests/integration/goldens/asset/tests/unit/gapic/asset_v1/test_asset_service.py @@ -14196,9 +14196,11 @@ def test_export_assets_rest_interceptors(null_interceptor): mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(operation.Operation, "_set_result_from_operation"), \ mock.patch.object(transports.AssetServiceRestInterceptor, "post_export_assets") as post, \ + mock.patch.object(transports.AssetServiceRestInterceptor, "post_export_assets_with_metadata") as post_with_metadata, \ mock.patch.object(transports.AssetServiceRestInterceptor, "pre_export_assets") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = asset_service.ExportAssetsRequest.pb(asset_service.ExportAssetsRequest()) transcode.return_value = { "method": "post", @@ -14220,11 +14222,13 @@ def test_export_assets_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata client.export_assets(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_list_assets_rest_bad_request(request_type=asset_service.ListAssetsRequest): @@ -14298,9 +14302,11 @@ def test_list_assets_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.AssetServiceRestInterceptor, "post_list_assets") as post, \ + mock.patch.object(transports.AssetServiceRestInterceptor, "post_list_assets_with_metadata") as post_with_metadata, \ mock.patch.object(transports.AssetServiceRestInterceptor, "pre_list_assets") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = asset_service.ListAssetsRequest.pb(asset_service.ListAssetsRequest()) transcode.return_value = { "method": "post", @@ -14322,11 +14328,13 @@ def test_list_assets_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = asset_service.ListAssetsResponse() + post_with_metadata.return_value = asset_service.ListAssetsResponse(), metadata client.list_assets(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_batch_get_assets_history_rest_bad_request(request_type=asset_service.BatchGetAssetsHistoryRequest): @@ -14398,9 +14406,11 @@ def test_batch_get_assets_history_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.AssetServiceRestInterceptor, "post_batch_get_assets_history") as post, \ + mock.patch.object(transports.AssetServiceRestInterceptor, "post_batch_get_assets_history_with_metadata") as post_with_metadata, \ mock.patch.object(transports.AssetServiceRestInterceptor, "pre_batch_get_assets_history") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = asset_service.BatchGetAssetsHistoryRequest.pb(asset_service.BatchGetAssetsHistoryRequest()) transcode.return_value = { "method": "post", @@ -14422,11 +14432,13 @@ def test_batch_get_assets_history_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = asset_service.BatchGetAssetsHistoryResponse() + post_with_metadata.return_value = asset_service.BatchGetAssetsHistoryResponse(), metadata client.batch_get_assets_history(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_create_feed_rest_bad_request(request_type=asset_service.CreateFeedRequest): @@ -14508,9 +14520,11 @@ def test_create_feed_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.AssetServiceRestInterceptor, "post_create_feed") as post, \ + mock.patch.object(transports.AssetServiceRestInterceptor, "post_create_feed_with_metadata") as post_with_metadata, \ mock.patch.object(transports.AssetServiceRestInterceptor, "pre_create_feed") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = asset_service.CreateFeedRequest.pb(asset_service.CreateFeedRequest()) transcode.return_value = { "method": "post", @@ -14532,11 +14546,13 @@ def test_create_feed_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = asset_service.Feed() + post_with_metadata.return_value = asset_service.Feed(), metadata client.create_feed(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_get_feed_rest_bad_request(request_type=asset_service.GetFeedRequest): @@ -14618,9 +14634,11 @@ def test_get_feed_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.AssetServiceRestInterceptor, "post_get_feed") as post, \ + mock.patch.object(transports.AssetServiceRestInterceptor, "post_get_feed_with_metadata") as post_with_metadata, \ mock.patch.object(transports.AssetServiceRestInterceptor, "pre_get_feed") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = asset_service.GetFeedRequest.pb(asset_service.GetFeedRequest()) transcode.return_value = { "method": "post", @@ -14642,11 +14660,13 @@ def test_get_feed_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = asset_service.Feed() + post_with_metadata.return_value = asset_service.Feed(), metadata client.get_feed(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_list_feeds_rest_bad_request(request_type=asset_service.ListFeedsRequest): @@ -14718,9 +14738,11 @@ def test_list_feeds_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.AssetServiceRestInterceptor, "post_list_feeds") as post, \ + mock.patch.object(transports.AssetServiceRestInterceptor, "post_list_feeds_with_metadata") as post_with_metadata, \ mock.patch.object(transports.AssetServiceRestInterceptor, "pre_list_feeds") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = asset_service.ListFeedsRequest.pb(asset_service.ListFeedsRequest()) transcode.return_value = { "method": "post", @@ -14742,11 +14764,13 @@ def test_list_feeds_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = asset_service.ListFeedsResponse() + post_with_metadata.return_value = asset_service.ListFeedsResponse(), metadata client.list_feeds(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_update_feed_rest_bad_request(request_type=asset_service.UpdateFeedRequest): @@ -14828,9 +14852,11 @@ def test_update_feed_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.AssetServiceRestInterceptor, "post_update_feed") as post, \ + mock.patch.object(transports.AssetServiceRestInterceptor, "post_update_feed_with_metadata") as post_with_metadata, \ mock.patch.object(transports.AssetServiceRestInterceptor, "pre_update_feed") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = asset_service.UpdateFeedRequest.pb(asset_service.UpdateFeedRequest()) transcode.return_value = { "method": "post", @@ -14852,11 +14878,13 @@ def test_update_feed_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = asset_service.Feed() + post_with_metadata.return_value = asset_service.Feed(), metadata client.update_feed(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_delete_feed_rest_bad_request(request_type=asset_service.DeleteFeedRequest): @@ -15020,9 +15048,11 @@ def test_search_all_resources_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.AssetServiceRestInterceptor, "post_search_all_resources") as post, \ + mock.patch.object(transports.AssetServiceRestInterceptor, "post_search_all_resources_with_metadata") as post_with_metadata, \ mock.patch.object(transports.AssetServiceRestInterceptor, "pre_search_all_resources") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = asset_service.SearchAllResourcesRequest.pb(asset_service.SearchAllResourcesRequest()) transcode.return_value = { "method": "post", @@ -15044,11 +15074,13 @@ def test_search_all_resources_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = asset_service.SearchAllResourcesResponse() + post_with_metadata.return_value = asset_service.SearchAllResourcesResponse(), metadata client.search_all_resources(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_search_all_iam_policies_rest_bad_request(request_type=asset_service.SearchAllIamPoliciesRequest): @@ -15122,9 +15154,11 @@ def test_search_all_iam_policies_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.AssetServiceRestInterceptor, "post_search_all_iam_policies") as post, \ + mock.patch.object(transports.AssetServiceRestInterceptor, "post_search_all_iam_policies_with_metadata") as post_with_metadata, \ mock.patch.object(transports.AssetServiceRestInterceptor, "pre_search_all_iam_policies") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = asset_service.SearchAllIamPoliciesRequest.pb(asset_service.SearchAllIamPoliciesRequest()) transcode.return_value = { "method": "post", @@ -15146,11 +15180,13 @@ def test_search_all_iam_policies_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = asset_service.SearchAllIamPoliciesResponse() + post_with_metadata.return_value = asset_service.SearchAllIamPoliciesResponse(), metadata client.search_all_iam_policies(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_analyze_iam_policy_rest_bad_request(request_type=asset_service.AnalyzeIamPolicyRequest): @@ -15224,9 +15260,11 @@ def test_analyze_iam_policy_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.AssetServiceRestInterceptor, "post_analyze_iam_policy") as post, \ + mock.patch.object(transports.AssetServiceRestInterceptor, "post_analyze_iam_policy_with_metadata") as post_with_metadata, \ mock.patch.object(transports.AssetServiceRestInterceptor, "pre_analyze_iam_policy") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = asset_service.AnalyzeIamPolicyRequest.pb(asset_service.AnalyzeIamPolicyRequest()) transcode.return_value = { "method": "post", @@ -15248,11 +15286,13 @@ def test_analyze_iam_policy_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = asset_service.AnalyzeIamPolicyResponse() + post_with_metadata.return_value = asset_service.AnalyzeIamPolicyResponse(), metadata client.analyze_iam_policy(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_analyze_iam_policy_longrunning_rest_bad_request(request_type=asset_service.AnalyzeIamPolicyLongrunningRequest): @@ -15321,9 +15361,11 @@ def test_analyze_iam_policy_longrunning_rest_interceptors(null_interceptor): mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(operation.Operation, "_set_result_from_operation"), \ mock.patch.object(transports.AssetServiceRestInterceptor, "post_analyze_iam_policy_longrunning") as post, \ + mock.patch.object(transports.AssetServiceRestInterceptor, "post_analyze_iam_policy_longrunning_with_metadata") as post_with_metadata, \ mock.patch.object(transports.AssetServiceRestInterceptor, "pre_analyze_iam_policy_longrunning") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = asset_service.AnalyzeIamPolicyLongrunningRequest.pb(asset_service.AnalyzeIamPolicyLongrunningRequest()) transcode.return_value = { "method": "post", @@ -15345,11 +15387,13 @@ def test_analyze_iam_policy_longrunning_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata client.analyze_iam_policy_longrunning(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_analyze_move_rest_bad_request(request_type=asset_service.AnalyzeMoveRequest): @@ -15421,9 +15465,11 @@ def test_analyze_move_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.AssetServiceRestInterceptor, "post_analyze_move") as post, \ + mock.patch.object(transports.AssetServiceRestInterceptor, "post_analyze_move_with_metadata") as post_with_metadata, \ mock.patch.object(transports.AssetServiceRestInterceptor, "pre_analyze_move") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = asset_service.AnalyzeMoveRequest.pb(asset_service.AnalyzeMoveRequest()) transcode.return_value = { "method": "post", @@ -15445,11 +15491,13 @@ def test_analyze_move_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = asset_service.AnalyzeMoveResponse() + post_with_metadata.return_value = asset_service.AnalyzeMoveResponse(), metadata client.analyze_move(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_query_assets_rest_bad_request(request_type=asset_service.QueryAssetsRequest): @@ -15525,9 +15573,11 @@ def test_query_assets_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.AssetServiceRestInterceptor, "post_query_assets") as post, \ + mock.patch.object(transports.AssetServiceRestInterceptor, "post_query_assets_with_metadata") as post_with_metadata, \ mock.patch.object(transports.AssetServiceRestInterceptor, "pre_query_assets") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = asset_service.QueryAssetsRequest.pb(asset_service.QueryAssetsRequest()) transcode.return_value = { "method": "post", @@ -15549,11 +15599,13 @@ def test_query_assets_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = asset_service.QueryAssetsResponse() + post_with_metadata.return_value = asset_service.QueryAssetsResponse(), metadata client.query_assets(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_create_saved_query_rest_bad_request(request_type=asset_service.CreateSavedQueryRequest): @@ -15697,9 +15749,11 @@ def test_create_saved_query_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.AssetServiceRestInterceptor, "post_create_saved_query") as post, \ + mock.patch.object(transports.AssetServiceRestInterceptor, "post_create_saved_query_with_metadata") as post_with_metadata, \ mock.patch.object(transports.AssetServiceRestInterceptor, "pre_create_saved_query") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = asset_service.CreateSavedQueryRequest.pb(asset_service.CreateSavedQueryRequest()) transcode.return_value = { "method": "post", @@ -15721,11 +15775,13 @@ def test_create_saved_query_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = asset_service.SavedQuery() + post_with_metadata.return_value = asset_service.SavedQuery(), metadata client.create_saved_query(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_get_saved_query_rest_bad_request(request_type=asset_service.GetSavedQueryRequest): @@ -15805,9 +15861,11 @@ def test_get_saved_query_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.AssetServiceRestInterceptor, "post_get_saved_query") as post, \ + mock.patch.object(transports.AssetServiceRestInterceptor, "post_get_saved_query_with_metadata") as post_with_metadata, \ mock.patch.object(transports.AssetServiceRestInterceptor, "pre_get_saved_query") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = asset_service.GetSavedQueryRequest.pb(asset_service.GetSavedQueryRequest()) transcode.return_value = { "method": "post", @@ -15829,11 +15887,13 @@ def test_get_saved_query_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = asset_service.SavedQuery() + post_with_metadata.return_value = asset_service.SavedQuery(), metadata client.get_saved_query(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_list_saved_queries_rest_bad_request(request_type=asset_service.ListSavedQueriesRequest): @@ -15907,9 +15967,11 @@ def test_list_saved_queries_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.AssetServiceRestInterceptor, "post_list_saved_queries") as post, \ + mock.patch.object(transports.AssetServiceRestInterceptor, "post_list_saved_queries_with_metadata") as post_with_metadata, \ mock.patch.object(transports.AssetServiceRestInterceptor, "pre_list_saved_queries") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = asset_service.ListSavedQueriesRequest.pb(asset_service.ListSavedQueriesRequest()) transcode.return_value = { "method": "post", @@ -15931,11 +15993,13 @@ def test_list_saved_queries_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = asset_service.ListSavedQueriesResponse() + post_with_metadata.return_value = asset_service.ListSavedQueriesResponse(), metadata client.list_saved_queries(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_update_saved_query_rest_bad_request(request_type=asset_service.UpdateSavedQueryRequest): @@ -16079,9 +16143,11 @@ def test_update_saved_query_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.AssetServiceRestInterceptor, "post_update_saved_query") as post, \ + mock.patch.object(transports.AssetServiceRestInterceptor, "post_update_saved_query_with_metadata") as post_with_metadata, \ mock.patch.object(transports.AssetServiceRestInterceptor, "pre_update_saved_query") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = asset_service.UpdateSavedQueryRequest.pb(asset_service.UpdateSavedQueryRequest()) transcode.return_value = { "method": "post", @@ -16103,11 +16169,13 @@ def test_update_saved_query_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = asset_service.SavedQuery() + post_with_metadata.return_value = asset_service.SavedQuery(), metadata client.update_saved_query(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_delete_saved_query_rest_bad_request(request_type=asset_service.DeleteSavedQueryRequest): @@ -16269,9 +16337,11 @@ def test_batch_get_effective_iam_policies_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.AssetServiceRestInterceptor, "post_batch_get_effective_iam_policies") as post, \ + mock.patch.object(transports.AssetServiceRestInterceptor, "post_batch_get_effective_iam_policies_with_metadata") as post_with_metadata, \ mock.patch.object(transports.AssetServiceRestInterceptor, "pre_batch_get_effective_iam_policies") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = asset_service.BatchGetEffectiveIamPoliciesRequest.pb(asset_service.BatchGetEffectiveIamPoliciesRequest()) transcode.return_value = { "method": "post", @@ -16293,11 +16363,13 @@ def test_batch_get_effective_iam_policies_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = asset_service.BatchGetEffectiveIamPoliciesResponse() + post_with_metadata.return_value = asset_service.BatchGetEffectiveIamPoliciesResponse(), metadata client.batch_get_effective_iam_policies(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_analyze_org_policies_rest_bad_request(request_type=asset_service.AnalyzeOrgPoliciesRequest): @@ -16371,9 +16443,11 @@ def test_analyze_org_policies_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.AssetServiceRestInterceptor, "post_analyze_org_policies") as post, \ + mock.patch.object(transports.AssetServiceRestInterceptor, "post_analyze_org_policies_with_metadata") as post_with_metadata, \ mock.patch.object(transports.AssetServiceRestInterceptor, "pre_analyze_org_policies") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = asset_service.AnalyzeOrgPoliciesRequest.pb(asset_service.AnalyzeOrgPoliciesRequest()) transcode.return_value = { "method": "post", @@ -16395,11 +16469,13 @@ def test_analyze_org_policies_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = asset_service.AnalyzeOrgPoliciesResponse() + post_with_metadata.return_value = asset_service.AnalyzeOrgPoliciesResponse(), metadata client.analyze_org_policies(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_analyze_org_policy_governed_containers_rest_bad_request(request_type=asset_service.AnalyzeOrgPolicyGovernedContainersRequest): @@ -16473,9 +16549,11 @@ def test_analyze_org_policy_governed_containers_rest_interceptors(null_intercept with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.AssetServiceRestInterceptor, "post_analyze_org_policy_governed_containers") as post, \ + mock.patch.object(transports.AssetServiceRestInterceptor, "post_analyze_org_policy_governed_containers_with_metadata") as post_with_metadata, \ mock.patch.object(transports.AssetServiceRestInterceptor, "pre_analyze_org_policy_governed_containers") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = asset_service.AnalyzeOrgPolicyGovernedContainersRequest.pb(asset_service.AnalyzeOrgPolicyGovernedContainersRequest()) transcode.return_value = { "method": "post", @@ -16497,11 +16575,13 @@ def test_analyze_org_policy_governed_containers_rest_interceptors(null_intercept ] pre.return_value = request, metadata post.return_value = asset_service.AnalyzeOrgPolicyGovernedContainersResponse() + post_with_metadata.return_value = asset_service.AnalyzeOrgPolicyGovernedContainersResponse(), metadata client.analyze_org_policy_governed_containers(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_analyze_org_policy_governed_assets_rest_bad_request(request_type=asset_service.AnalyzeOrgPolicyGovernedAssetsRequest): @@ -16575,9 +16655,11 @@ def test_analyze_org_policy_governed_assets_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.AssetServiceRestInterceptor, "post_analyze_org_policy_governed_assets") as post, \ + mock.patch.object(transports.AssetServiceRestInterceptor, "post_analyze_org_policy_governed_assets_with_metadata") as post_with_metadata, \ mock.patch.object(transports.AssetServiceRestInterceptor, "pre_analyze_org_policy_governed_assets") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = asset_service.AnalyzeOrgPolicyGovernedAssetsRequest.pb(asset_service.AnalyzeOrgPolicyGovernedAssetsRequest()) transcode.return_value = { "method": "post", @@ -16599,11 +16681,13 @@ def test_analyze_org_policy_governed_assets_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = asset_service.AnalyzeOrgPolicyGovernedAssetsResponse() + post_with_metadata.return_value = asset_service.AnalyzeOrgPolicyGovernedAssetsResponse(), metadata client.analyze_org_policy_governed_assets(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_get_operation_rest_bad_request(request_type=operations_pb2.GetOperationRequest): diff --git a/tests/integration/goldens/credentials/google/iam/credentials_v1/services/iam_credentials/transports/rest.py b/tests/integration/goldens/credentials/google/iam/credentials_v1/services/iam_credentials/transports/rest.py index 9cf97b875..0f0648995 100755 --- a/tests/integration/goldens/credentials/google/iam/credentials_v1/services/iam_credentials/transports/rest.py +++ b/tests/integration/goldens/credentials/google/iam/credentials_v1/services/iam_credentials/transports/rest.py @@ -127,6 +127,15 @@ def post_generate_access_token(self, response: common.GenerateAccessTokenRespons """ return response + def post_generate_access_token_with_metadata(self, response: common.GenerateAccessTokenResponse, metadata: Sequence[Tuple[str, str]]) -> Tuple[common.GenerateAccessTokenResponse, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for generate_access_token + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the IAMCredentials server but before + it is returned to user code. + """ + return response, metadata + def pre_generate_id_token(self, request: common.GenerateIdTokenRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[common.GenerateIdTokenRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for generate_id_token @@ -144,6 +153,15 @@ def post_generate_id_token(self, response: common.GenerateIdTokenResponse) -> co """ return response + def post_generate_id_token_with_metadata(self, response: common.GenerateIdTokenResponse, metadata: Sequence[Tuple[str, str]]) -> Tuple[common.GenerateIdTokenResponse, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for generate_id_token + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the IAMCredentials server but before + it is returned to user code. + """ + return response, metadata + def pre_sign_blob(self, request: common.SignBlobRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[common.SignBlobRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for sign_blob @@ -161,6 +179,15 @@ def post_sign_blob(self, response: common.SignBlobResponse) -> common.SignBlobRe """ return response + def post_sign_blob_with_metadata(self, response: common.SignBlobResponse, metadata: Sequence[Tuple[str, str]]) -> Tuple[common.SignBlobResponse, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for sign_blob + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the IAMCredentials server but before + it is returned to user code. + """ + return response, metadata + def pre_sign_jwt(self, request: common.SignJwtRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[common.SignJwtRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for sign_jwt @@ -178,6 +205,15 @@ def post_sign_jwt(self, response: common.SignJwtResponse) -> common.SignJwtRespo """ return response + def post_sign_jwt_with_metadata(self, response: common.SignJwtResponse, metadata: Sequence[Tuple[str, str]]) -> Tuple[common.SignJwtResponse, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for sign_jwt + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the IAMCredentials server but before + it is returned to user code. + """ + return response, metadata + @dataclasses.dataclass class IAMCredentialsRestStub: @@ -375,6 +411,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_generate_access_token(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_generate_access_token_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = common.GenerateAccessTokenResponse.to_json(response) @@ -495,6 +533,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_generate_id_token(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_generate_id_token_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = common.GenerateIdTokenResponse.to_json(response) @@ -615,6 +655,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_sign_blob(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_sign_blob_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = common.SignBlobResponse.to_json(response) @@ -735,6 +777,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_sign_jwt(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_sign_jwt_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = common.SignJwtResponse.to_json(response) diff --git a/tests/integration/goldens/credentials/tests/unit/gapic/credentials_v1/test_iam_credentials.py b/tests/integration/goldens/credentials/tests/unit/gapic/credentials_v1/test_iam_credentials.py index 715989b7c..d31e01c82 100755 --- a/tests/integration/goldens/credentials/tests/unit/gapic/credentials_v1/test_iam_credentials.py +++ b/tests/integration/goldens/credentials/tests/unit/gapic/credentials_v1/test_iam_credentials.py @@ -3162,9 +3162,11 @@ def test_generate_access_token_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.IAMCredentialsRestInterceptor, "post_generate_access_token") as post, \ + mock.patch.object(transports.IAMCredentialsRestInterceptor, "post_generate_access_token_with_metadata") as post_with_metadata, \ mock.patch.object(transports.IAMCredentialsRestInterceptor, "pre_generate_access_token") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = common.GenerateAccessTokenRequest.pb(common.GenerateAccessTokenRequest()) transcode.return_value = { "method": "post", @@ -3186,11 +3188,13 @@ def test_generate_access_token_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = common.GenerateAccessTokenResponse() + post_with_metadata.return_value = common.GenerateAccessTokenResponse(), metadata client.generate_access_token(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_generate_id_token_rest_bad_request(request_type=common.GenerateIdTokenRequest): @@ -3264,9 +3268,11 @@ def test_generate_id_token_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.IAMCredentialsRestInterceptor, "post_generate_id_token") as post, \ + mock.patch.object(transports.IAMCredentialsRestInterceptor, "post_generate_id_token_with_metadata") as post_with_metadata, \ mock.patch.object(transports.IAMCredentialsRestInterceptor, "pre_generate_id_token") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = common.GenerateIdTokenRequest.pb(common.GenerateIdTokenRequest()) transcode.return_value = { "method": "post", @@ -3288,11 +3294,13 @@ def test_generate_id_token_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = common.GenerateIdTokenResponse() + post_with_metadata.return_value = common.GenerateIdTokenResponse(), metadata client.generate_id_token(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_sign_blob_rest_bad_request(request_type=common.SignBlobRequest): @@ -3368,9 +3376,11 @@ def test_sign_blob_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.IAMCredentialsRestInterceptor, "post_sign_blob") as post, \ + mock.patch.object(transports.IAMCredentialsRestInterceptor, "post_sign_blob_with_metadata") as post_with_metadata, \ mock.patch.object(transports.IAMCredentialsRestInterceptor, "pre_sign_blob") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = common.SignBlobRequest.pb(common.SignBlobRequest()) transcode.return_value = { "method": "post", @@ -3392,11 +3402,13 @@ def test_sign_blob_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = common.SignBlobResponse() + post_with_metadata.return_value = common.SignBlobResponse(), metadata client.sign_blob(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_sign_jwt_rest_bad_request(request_type=common.SignJwtRequest): @@ -3472,9 +3484,11 @@ def test_sign_jwt_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.IAMCredentialsRestInterceptor, "post_sign_jwt") as post, \ + mock.patch.object(transports.IAMCredentialsRestInterceptor, "post_sign_jwt_with_metadata") as post_with_metadata, \ mock.patch.object(transports.IAMCredentialsRestInterceptor, "pre_sign_jwt") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = common.SignJwtRequest.pb(common.SignJwtRequest()) transcode.return_value = { "method": "post", @@ -3496,11 +3510,13 @@ def test_sign_jwt_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = common.SignJwtResponse() + post_with_metadata.return_value = common.SignJwtResponse(), metadata client.sign_jwt(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_initialize_client_w_rest(): client = IAMCredentialsClient( diff --git a/tests/integration/goldens/eventarc/google/cloud/eventarc_v1/services/eventarc/transports/rest.py b/tests/integration/goldens/eventarc/google/cloud/eventarc_v1/services/eventarc/transports/rest.py index 583ee4301..2b5d2d5cf 100755 --- a/tests/integration/goldens/eventarc/google/cloud/eventarc_v1/services/eventarc/transports/rest.py +++ b/tests/integration/goldens/eventarc/google/cloud/eventarc_v1/services/eventarc/transports/rest.py @@ -250,6 +250,15 @@ def post_create_channel(self, response: operations_pb2.Operation) -> operations_ """ return response + def post_create_channel_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, str]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for create_channel + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the Eventarc server but before + it is returned to user code. + """ + return response, metadata + def pre_create_channel_connection(self, request: eventarc.CreateChannelConnectionRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[eventarc.CreateChannelConnectionRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_channel_connection @@ -267,6 +276,15 @@ def post_create_channel_connection(self, response: operations_pb2.Operation) -> """ return response + def post_create_channel_connection_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, str]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for create_channel_connection + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the Eventarc server but before + it is returned to user code. + """ + return response, metadata + def pre_create_trigger(self, request: eventarc.CreateTriggerRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[eventarc.CreateTriggerRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_trigger @@ -284,6 +302,15 @@ def post_create_trigger(self, response: operations_pb2.Operation) -> operations_ """ return response + def post_create_trigger_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, str]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for create_trigger + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the Eventarc server but before + it is returned to user code. + """ + return response, metadata + def pre_delete_channel(self, request: eventarc.DeleteChannelRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[eventarc.DeleteChannelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_channel @@ -301,6 +328,15 @@ def post_delete_channel(self, response: operations_pb2.Operation) -> operations_ """ return response + def post_delete_channel_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, str]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for delete_channel + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the Eventarc server but before + it is returned to user code. + """ + return response, metadata + def pre_delete_channel_connection(self, request: eventarc.DeleteChannelConnectionRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[eventarc.DeleteChannelConnectionRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_channel_connection @@ -318,6 +354,15 @@ def post_delete_channel_connection(self, response: operations_pb2.Operation) -> """ return response + def post_delete_channel_connection_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, str]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for delete_channel_connection + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the Eventarc server but before + it is returned to user code. + """ + return response, metadata + def pre_delete_trigger(self, request: eventarc.DeleteTriggerRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[eventarc.DeleteTriggerRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_trigger @@ -335,6 +380,15 @@ def post_delete_trigger(self, response: operations_pb2.Operation) -> operations_ """ return response + def post_delete_trigger_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, str]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for delete_trigger + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the Eventarc server but before + it is returned to user code. + """ + return response, metadata + def pre_get_channel(self, request: eventarc.GetChannelRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[eventarc.GetChannelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_channel @@ -352,6 +406,15 @@ def post_get_channel(self, response: channel.Channel) -> channel.Channel: """ return response + def post_get_channel_with_metadata(self, response: channel.Channel, metadata: Sequence[Tuple[str, str]]) -> Tuple[channel.Channel, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for get_channel + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the Eventarc server but before + it is returned to user code. + """ + return response, metadata + def pre_get_channel_connection(self, request: eventarc.GetChannelConnectionRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[eventarc.GetChannelConnectionRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_channel_connection @@ -369,6 +432,15 @@ def post_get_channel_connection(self, response: channel_connection.ChannelConnec """ return response + def post_get_channel_connection_with_metadata(self, response: channel_connection.ChannelConnection, metadata: Sequence[Tuple[str, str]]) -> Tuple[channel_connection.ChannelConnection, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for get_channel_connection + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the Eventarc server but before + it is returned to user code. + """ + return response, metadata + def pre_get_google_channel_config(self, request: eventarc.GetGoogleChannelConfigRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[eventarc.GetGoogleChannelConfigRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_google_channel_config @@ -386,6 +458,15 @@ def post_get_google_channel_config(self, response: google_channel_config.GoogleC """ return response + def post_get_google_channel_config_with_metadata(self, response: google_channel_config.GoogleChannelConfig, metadata: Sequence[Tuple[str, str]]) -> Tuple[google_channel_config.GoogleChannelConfig, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for get_google_channel_config + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the Eventarc server but before + it is returned to user code. + """ + return response, metadata + def pre_get_provider(self, request: eventarc.GetProviderRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[eventarc.GetProviderRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_provider @@ -403,6 +484,15 @@ def post_get_provider(self, response: discovery.Provider) -> discovery.Provider: """ return response + def post_get_provider_with_metadata(self, response: discovery.Provider, metadata: Sequence[Tuple[str, str]]) -> Tuple[discovery.Provider, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for get_provider + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the Eventarc server but before + it is returned to user code. + """ + return response, metadata + def pre_get_trigger(self, request: eventarc.GetTriggerRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[eventarc.GetTriggerRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_trigger @@ -420,6 +510,15 @@ def post_get_trigger(self, response: trigger.Trigger) -> trigger.Trigger: """ return response + def post_get_trigger_with_metadata(self, response: trigger.Trigger, metadata: Sequence[Tuple[str, str]]) -> Tuple[trigger.Trigger, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for get_trigger + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the Eventarc server but before + it is returned to user code. + """ + return response, metadata + def pre_list_channel_connections(self, request: eventarc.ListChannelConnectionsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[eventarc.ListChannelConnectionsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_channel_connections @@ -437,6 +536,15 @@ def post_list_channel_connections(self, response: eventarc.ListChannelConnection """ return response + def post_list_channel_connections_with_metadata(self, response: eventarc.ListChannelConnectionsResponse, metadata: Sequence[Tuple[str, str]]) -> Tuple[eventarc.ListChannelConnectionsResponse, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for list_channel_connections + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the Eventarc server but before + it is returned to user code. + """ + return response, metadata + def pre_list_channels(self, request: eventarc.ListChannelsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[eventarc.ListChannelsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_channels @@ -454,6 +562,15 @@ def post_list_channels(self, response: eventarc.ListChannelsResponse) -> eventar """ return response + def post_list_channels_with_metadata(self, response: eventarc.ListChannelsResponse, metadata: Sequence[Tuple[str, str]]) -> Tuple[eventarc.ListChannelsResponse, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for list_channels + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the Eventarc server but before + it is returned to user code. + """ + return response, metadata + def pre_list_providers(self, request: eventarc.ListProvidersRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[eventarc.ListProvidersRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_providers @@ -471,6 +588,15 @@ def post_list_providers(self, response: eventarc.ListProvidersResponse) -> event """ return response + def post_list_providers_with_metadata(self, response: eventarc.ListProvidersResponse, metadata: Sequence[Tuple[str, str]]) -> Tuple[eventarc.ListProvidersResponse, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for list_providers + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the Eventarc server but before + it is returned to user code. + """ + return response, metadata + def pre_list_triggers(self, request: eventarc.ListTriggersRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[eventarc.ListTriggersRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_triggers @@ -488,6 +614,15 @@ def post_list_triggers(self, response: eventarc.ListTriggersResponse) -> eventar """ return response + def post_list_triggers_with_metadata(self, response: eventarc.ListTriggersResponse, metadata: Sequence[Tuple[str, str]]) -> Tuple[eventarc.ListTriggersResponse, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for list_triggers + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the Eventarc server but before + it is returned to user code. + """ + return response, metadata + def pre_update_channel(self, request: eventarc.UpdateChannelRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[eventarc.UpdateChannelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_channel @@ -505,6 +640,15 @@ def post_update_channel(self, response: operations_pb2.Operation) -> operations_ """ return response + def post_update_channel_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, str]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for update_channel + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the Eventarc server but before + it is returned to user code. + """ + return response, metadata + def pre_update_google_channel_config(self, request: eventarc.UpdateGoogleChannelConfigRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[eventarc.UpdateGoogleChannelConfigRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_google_channel_config @@ -522,6 +666,15 @@ def post_update_google_channel_config(self, response: gce_google_channel_config. """ return response + def post_update_google_channel_config_with_metadata(self, response: gce_google_channel_config.GoogleChannelConfig, metadata: Sequence[Tuple[str, str]]) -> Tuple[gce_google_channel_config.GoogleChannelConfig, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for update_google_channel_config + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the Eventarc server but before + it is returned to user code. + """ + return response, metadata + def pre_update_trigger(self, request: eventarc.UpdateTriggerRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[eventarc.UpdateTriggerRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_trigger @@ -539,6 +692,15 @@ def post_update_trigger(self, response: operations_pb2.Operation) -> operations_ """ return response + def post_update_trigger_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, str]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, str]]]: + """Post-rpc interceptor for update_trigger + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the Eventarc server but before + it is returned to user code. + """ + return response, metadata + def pre_get_location( self, request: locations_pb2.GetLocationRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]] ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: @@ -971,6 +1133,8 @@ def __call__(self, json_format.Parse(response.content, resp, ignore_unknown_fields=True) resp = self._interceptor.post_create_channel(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_channel_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = json_format.MessageToJson(resp) @@ -1093,6 +1257,8 @@ def __call__(self, json_format.Parse(response.content, resp, ignore_unknown_fields=True) resp = self._interceptor.post_create_channel_connection(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_channel_connection_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = json_format.MessageToJson(resp) @@ -1215,6 +1381,8 @@ def __call__(self, json_format.Parse(response.content, resp, ignore_unknown_fields=True) resp = self._interceptor.post_create_trigger(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_trigger_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = json_format.MessageToJson(resp) @@ -1334,6 +1502,8 @@ def __call__(self, json_format.Parse(response.content, resp, ignore_unknown_fields=True) resp = self._interceptor.post_delete_channel(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_delete_channel_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = json_format.MessageToJson(resp) @@ -1453,6 +1623,8 @@ def __call__(self, json_format.Parse(response.content, resp, ignore_unknown_fields=True) resp = self._interceptor.post_delete_channel_connection(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_delete_channel_connection_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = json_format.MessageToJson(resp) @@ -1572,6 +1744,8 @@ def __call__(self, json_format.Parse(response.content, resp, ignore_unknown_fields=True) resp = self._interceptor.post_delete_trigger(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_delete_trigger_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = json_format.MessageToJson(resp) @@ -1698,6 +1872,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_get_channel(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_channel_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = channel.Channel.to_json(response) @@ -1823,6 +1999,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_get_channel_connection(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_channel_connection_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = channel_connection.ChannelConnection.to_json(response) @@ -1949,6 +2127,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_get_google_channel_config(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_google_channel_config_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = google_channel_config.GoogleChannelConfig.to_json(response) @@ -2069,6 +2249,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_get_provider(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_provider_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = discovery.Provider.to_json(response) @@ -2189,6 +2371,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_get_trigger(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_trigger_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = trigger.Trigger.to_json(response) @@ -2309,6 +2493,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_list_channel_connections(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_channel_connections_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = eventarc.ListChannelConnectionsResponse.to_json(response) @@ -2427,6 +2613,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_list_channels(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_channels_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = eventarc.ListChannelsResponse.to_json(response) @@ -2545,6 +2733,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_list_providers(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_providers_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = eventarc.ListProvidersResponse.to_json(response) @@ -2663,6 +2853,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_list_triggers(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_triggers_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = eventarc.ListTriggersResponse.to_json(response) @@ -2785,6 +2977,8 @@ def __call__(self, json_format.Parse(response.content, resp, ignore_unknown_fields=True) resp = self._interceptor.post_update_channel(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_update_channel_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = json_format.MessageToJson(resp) @@ -2915,6 +3109,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_update_google_channel_config(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_update_google_channel_config_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = gce_google_channel_config.GoogleChannelConfig.to_json(response) @@ -3037,6 +3233,8 @@ def __call__(self, json_format.Parse(response.content, resp, ignore_unknown_fields=True) resp = self._interceptor.post_update_trigger(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_update_trigger_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = json_format.MessageToJson(resp) diff --git a/tests/integration/goldens/eventarc/tests/unit/gapic/eventarc_v1/test_eventarc.py b/tests/integration/goldens/eventarc/tests/unit/gapic/eventarc_v1/test_eventarc.py index 42bc23df8..6473ef989 100755 --- a/tests/integration/goldens/eventarc/tests/unit/gapic/eventarc_v1/test_eventarc.py +++ b/tests/integration/goldens/eventarc/tests/unit/gapic/eventarc_v1/test_eventarc.py @@ -11842,9 +11842,11 @@ def test_get_trigger_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.EventarcRestInterceptor, "post_get_trigger") as post, \ + mock.patch.object(transports.EventarcRestInterceptor, "post_get_trigger_with_metadata") as post_with_metadata, \ mock.patch.object(transports.EventarcRestInterceptor, "pre_get_trigger") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = eventarc.GetTriggerRequest.pb(eventarc.GetTriggerRequest()) transcode.return_value = { "method": "post", @@ -11866,11 +11868,13 @@ def test_get_trigger_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = trigger.Trigger() + post_with_metadata.return_value = trigger.Trigger(), metadata client.get_trigger(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_list_triggers_rest_bad_request(request_type=eventarc.ListTriggersRequest): @@ -11946,9 +11950,11 @@ def test_list_triggers_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.EventarcRestInterceptor, "post_list_triggers") as post, \ + mock.patch.object(transports.EventarcRestInterceptor, "post_list_triggers_with_metadata") as post_with_metadata, \ mock.patch.object(transports.EventarcRestInterceptor, "pre_list_triggers") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = eventarc.ListTriggersRequest.pb(eventarc.ListTriggersRequest()) transcode.return_value = { "method": "post", @@ -11970,11 +11976,13 @@ def test_list_triggers_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = eventarc.ListTriggersResponse() + post_with_metadata.return_value = eventarc.ListTriggersResponse(), metadata client.list_triggers(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_create_trigger_rest_bad_request(request_type=eventarc.CreateTriggerRequest): @@ -12107,9 +12115,11 @@ def test_create_trigger_rest_interceptors(null_interceptor): mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(operation.Operation, "_set_result_from_operation"), \ mock.patch.object(transports.EventarcRestInterceptor, "post_create_trigger") as post, \ + mock.patch.object(transports.EventarcRestInterceptor, "post_create_trigger_with_metadata") as post_with_metadata, \ mock.patch.object(transports.EventarcRestInterceptor, "pre_create_trigger") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = eventarc.CreateTriggerRequest.pb(eventarc.CreateTriggerRequest()) transcode.return_value = { "method": "post", @@ -12131,11 +12141,13 @@ def test_create_trigger_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata client.create_trigger(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_update_trigger_rest_bad_request(request_type=eventarc.UpdateTriggerRequest): @@ -12268,9 +12280,11 @@ def test_update_trigger_rest_interceptors(null_interceptor): mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(operation.Operation, "_set_result_from_operation"), \ mock.patch.object(transports.EventarcRestInterceptor, "post_update_trigger") as post, \ + mock.patch.object(transports.EventarcRestInterceptor, "post_update_trigger_with_metadata") as post_with_metadata, \ mock.patch.object(transports.EventarcRestInterceptor, "pre_update_trigger") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = eventarc.UpdateTriggerRequest.pb(eventarc.UpdateTriggerRequest()) transcode.return_value = { "method": "post", @@ -12292,11 +12306,13 @@ def test_update_trigger_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata client.update_trigger(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_delete_trigger_rest_bad_request(request_type=eventarc.DeleteTriggerRequest): @@ -12365,9 +12381,11 @@ def test_delete_trigger_rest_interceptors(null_interceptor): mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(operation.Operation, "_set_result_from_operation"), \ mock.patch.object(transports.EventarcRestInterceptor, "post_delete_trigger") as post, \ + mock.patch.object(transports.EventarcRestInterceptor, "post_delete_trigger_with_metadata") as post_with_metadata, \ mock.patch.object(transports.EventarcRestInterceptor, "pre_delete_trigger") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = eventarc.DeleteTriggerRequest.pb(eventarc.DeleteTriggerRequest()) transcode.return_value = { "method": "post", @@ -12389,11 +12407,13 @@ def test_delete_trigger_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata client.delete_trigger(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_get_channel_rest_bad_request(request_type=eventarc.GetChannelRequest): @@ -12478,9 +12498,11 @@ def test_get_channel_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.EventarcRestInterceptor, "post_get_channel") as post, \ + mock.patch.object(transports.EventarcRestInterceptor, "post_get_channel_with_metadata") as post_with_metadata, \ mock.patch.object(transports.EventarcRestInterceptor, "pre_get_channel") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = eventarc.GetChannelRequest.pb(eventarc.GetChannelRequest()) transcode.return_value = { "method": "post", @@ -12502,11 +12524,13 @@ def test_get_channel_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = channel.Channel() + post_with_metadata.return_value = channel.Channel(), metadata client.get_channel(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_list_channels_rest_bad_request(request_type=eventarc.ListChannelsRequest): @@ -12582,9 +12606,11 @@ def test_list_channels_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.EventarcRestInterceptor, "post_list_channels") as post, \ + mock.patch.object(transports.EventarcRestInterceptor, "post_list_channels_with_metadata") as post_with_metadata, \ mock.patch.object(transports.EventarcRestInterceptor, "pre_list_channels") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = eventarc.ListChannelsRequest.pb(eventarc.ListChannelsRequest()) transcode.return_value = { "method": "post", @@ -12606,11 +12632,13 @@ def test_list_channels_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = eventarc.ListChannelsResponse() + post_with_metadata.return_value = eventarc.ListChannelsResponse(), metadata client.list_channels(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_create_channel_rest_bad_request(request_type=eventarc.CreateChannelRequest): @@ -12743,9 +12771,11 @@ def test_create_channel_rest_interceptors(null_interceptor): mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(operation.Operation, "_set_result_from_operation"), \ mock.patch.object(transports.EventarcRestInterceptor, "post_create_channel") as post, \ + mock.patch.object(transports.EventarcRestInterceptor, "post_create_channel_with_metadata") as post_with_metadata, \ mock.patch.object(transports.EventarcRestInterceptor, "pre_create_channel") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = eventarc.CreateChannelRequest.pb(eventarc.CreateChannelRequest()) transcode.return_value = { "method": "post", @@ -12767,11 +12797,13 @@ def test_create_channel_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata client.create_channel(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_update_channel_rest_bad_request(request_type=eventarc.UpdateChannelRequest): @@ -12904,9 +12936,11 @@ def test_update_channel_rest_interceptors(null_interceptor): mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(operation.Operation, "_set_result_from_operation"), \ mock.patch.object(transports.EventarcRestInterceptor, "post_update_channel") as post, \ + mock.patch.object(transports.EventarcRestInterceptor, "post_update_channel_with_metadata") as post_with_metadata, \ mock.patch.object(transports.EventarcRestInterceptor, "pre_update_channel") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = eventarc.UpdateChannelRequest.pb(eventarc.UpdateChannelRequest()) transcode.return_value = { "method": "post", @@ -12928,11 +12962,13 @@ def test_update_channel_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata client.update_channel(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_delete_channel_rest_bad_request(request_type=eventarc.DeleteChannelRequest): @@ -13001,9 +13037,11 @@ def test_delete_channel_rest_interceptors(null_interceptor): mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(operation.Operation, "_set_result_from_operation"), \ mock.patch.object(transports.EventarcRestInterceptor, "post_delete_channel") as post, \ + mock.patch.object(transports.EventarcRestInterceptor, "post_delete_channel_with_metadata") as post_with_metadata, \ mock.patch.object(transports.EventarcRestInterceptor, "pre_delete_channel") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = eventarc.DeleteChannelRequest.pb(eventarc.DeleteChannelRequest()) transcode.return_value = { "method": "post", @@ -13025,11 +13063,13 @@ def test_delete_channel_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata client.delete_channel(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_get_provider_rest_bad_request(request_type=eventarc.GetProviderRequest): @@ -13105,9 +13145,11 @@ def test_get_provider_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.EventarcRestInterceptor, "post_get_provider") as post, \ + mock.patch.object(transports.EventarcRestInterceptor, "post_get_provider_with_metadata") as post_with_metadata, \ mock.patch.object(transports.EventarcRestInterceptor, "pre_get_provider") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = eventarc.GetProviderRequest.pb(eventarc.GetProviderRequest()) transcode.return_value = { "method": "post", @@ -13129,11 +13171,13 @@ def test_get_provider_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = discovery.Provider() + post_with_metadata.return_value = discovery.Provider(), metadata client.get_provider(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_list_providers_rest_bad_request(request_type=eventarc.ListProvidersRequest): @@ -13209,9 +13253,11 @@ def test_list_providers_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.EventarcRestInterceptor, "post_list_providers") as post, \ + mock.patch.object(transports.EventarcRestInterceptor, "post_list_providers_with_metadata") as post_with_metadata, \ mock.patch.object(transports.EventarcRestInterceptor, "pre_list_providers") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = eventarc.ListProvidersRequest.pb(eventarc.ListProvidersRequest()) transcode.return_value = { "method": "post", @@ -13233,11 +13279,13 @@ def test_list_providers_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = eventarc.ListProvidersResponse() + post_with_metadata.return_value = eventarc.ListProvidersResponse(), metadata client.list_providers(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_get_channel_connection_rest_bad_request(request_type=eventarc.GetChannelConnectionRequest): @@ -13317,9 +13365,11 @@ def test_get_channel_connection_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.EventarcRestInterceptor, "post_get_channel_connection") as post, \ + mock.patch.object(transports.EventarcRestInterceptor, "post_get_channel_connection_with_metadata") as post_with_metadata, \ mock.patch.object(transports.EventarcRestInterceptor, "pre_get_channel_connection") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = eventarc.GetChannelConnectionRequest.pb(eventarc.GetChannelConnectionRequest()) transcode.return_value = { "method": "post", @@ -13341,11 +13391,13 @@ def test_get_channel_connection_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = channel_connection.ChannelConnection() + post_with_metadata.return_value = channel_connection.ChannelConnection(), metadata client.get_channel_connection(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_list_channel_connections_rest_bad_request(request_type=eventarc.ListChannelConnectionsRequest): @@ -13421,9 +13473,11 @@ def test_list_channel_connections_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.EventarcRestInterceptor, "post_list_channel_connections") as post, \ + mock.patch.object(transports.EventarcRestInterceptor, "post_list_channel_connections_with_metadata") as post_with_metadata, \ mock.patch.object(transports.EventarcRestInterceptor, "pre_list_channel_connections") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = eventarc.ListChannelConnectionsRequest.pb(eventarc.ListChannelConnectionsRequest()) transcode.return_value = { "method": "post", @@ -13445,11 +13499,13 @@ def test_list_channel_connections_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = eventarc.ListChannelConnectionsResponse() + post_with_metadata.return_value = eventarc.ListChannelConnectionsResponse(), metadata client.list_channel_connections(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_create_channel_connection_rest_bad_request(request_type=eventarc.CreateChannelConnectionRequest): @@ -13582,9 +13638,11 @@ def test_create_channel_connection_rest_interceptors(null_interceptor): mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(operation.Operation, "_set_result_from_operation"), \ mock.patch.object(transports.EventarcRestInterceptor, "post_create_channel_connection") as post, \ + mock.patch.object(transports.EventarcRestInterceptor, "post_create_channel_connection_with_metadata") as post_with_metadata, \ mock.patch.object(transports.EventarcRestInterceptor, "pre_create_channel_connection") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = eventarc.CreateChannelConnectionRequest.pb(eventarc.CreateChannelConnectionRequest()) transcode.return_value = { "method": "post", @@ -13606,11 +13664,13 @@ def test_create_channel_connection_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata client.create_channel_connection(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_delete_channel_connection_rest_bad_request(request_type=eventarc.DeleteChannelConnectionRequest): @@ -13679,9 +13739,11 @@ def test_delete_channel_connection_rest_interceptors(null_interceptor): mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(operation.Operation, "_set_result_from_operation"), \ mock.patch.object(transports.EventarcRestInterceptor, "post_delete_channel_connection") as post, \ + mock.patch.object(transports.EventarcRestInterceptor, "post_delete_channel_connection_with_metadata") as post_with_metadata, \ mock.patch.object(transports.EventarcRestInterceptor, "pre_delete_channel_connection") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = eventarc.DeleteChannelConnectionRequest.pb(eventarc.DeleteChannelConnectionRequest()) transcode.return_value = { "method": "post", @@ -13703,11 +13765,13 @@ def test_delete_channel_connection_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata client.delete_channel_connection(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_get_google_channel_config_rest_bad_request(request_type=eventarc.GetGoogleChannelConfigRequest): @@ -13783,9 +13847,11 @@ def test_get_google_channel_config_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.EventarcRestInterceptor, "post_get_google_channel_config") as post, \ + mock.patch.object(transports.EventarcRestInterceptor, "post_get_google_channel_config_with_metadata") as post_with_metadata, \ mock.patch.object(transports.EventarcRestInterceptor, "pre_get_google_channel_config") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = eventarc.GetGoogleChannelConfigRequest.pb(eventarc.GetGoogleChannelConfigRequest()) transcode.return_value = { "method": "post", @@ -13807,11 +13873,13 @@ def test_get_google_channel_config_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = google_channel_config.GoogleChannelConfig() + post_with_metadata.return_value = google_channel_config.GoogleChannelConfig(), metadata client.get_google_channel_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_update_google_channel_config_rest_bad_request(request_type=eventarc.UpdateGoogleChannelConfigRequest): @@ -13951,9 +14019,11 @@ def test_update_google_channel_config_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.EventarcRestInterceptor, "post_update_google_channel_config") as post, \ + mock.patch.object(transports.EventarcRestInterceptor, "post_update_google_channel_config_with_metadata") as post_with_metadata, \ mock.patch.object(transports.EventarcRestInterceptor, "pre_update_google_channel_config") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = eventarc.UpdateGoogleChannelConfigRequest.pb(eventarc.UpdateGoogleChannelConfigRequest()) transcode.return_value = { "method": "post", @@ -13975,11 +14045,13 @@ def test_update_google_channel_config_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = gce_google_channel_config.GoogleChannelConfig() + post_with_metadata.return_value = gce_google_channel_config.GoogleChannelConfig(), metadata client.update_google_channel_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationRequest): diff --git a/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/rest.py b/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/rest.py index 0d6c45081..95146980f 100755 --- a/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/rest.py +++ b/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/rest.py @@ -186,6 +186,15 @@ def post_create_instance(self, response: operations_pb2.Operation) -> operations """ return response + def post_create_instance_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for create_instance + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the CloudRedis server but before + it is returned to user code. + """ + return response, metadata + def pre_delete_instance(self, request: cloud_redis.DeleteInstanceRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[cloud_redis.DeleteInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_instance @@ -203,6 +212,15 @@ def post_delete_instance(self, response: operations_pb2.Operation) -> operations """ return response + def post_delete_instance_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for delete_instance + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the CloudRedis server but before + it is returned to user code. + """ + return response, metadata + def pre_export_instance(self, request: cloud_redis.ExportInstanceRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[cloud_redis.ExportInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for export_instance @@ -220,6 +238,15 @@ def post_export_instance(self, response: operations_pb2.Operation) -> operations """ return response + def post_export_instance_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for export_instance + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the CloudRedis server but before + it is returned to user code. + """ + return response, metadata + def pre_failover_instance(self, request: cloud_redis.FailoverInstanceRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[cloud_redis.FailoverInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for failover_instance @@ -237,6 +264,15 @@ def post_failover_instance(self, response: operations_pb2.Operation) -> operatio """ return response + def post_failover_instance_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for failover_instance + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the CloudRedis server but before + it is returned to user code. + """ + return response, metadata + def pre_get_instance(self, request: cloud_redis.GetInstanceRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[cloud_redis.GetInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_instance @@ -254,6 +290,15 @@ def post_get_instance(self, response: cloud_redis.Instance) -> cloud_redis.Insta """ return response + def post_get_instance_with_metadata(self, response: cloud_redis.Instance, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[cloud_redis.Instance, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_instance + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the CloudRedis server but before + it is returned to user code. + """ + return response, metadata + def pre_get_instance_auth_string(self, request: cloud_redis.GetInstanceAuthStringRequest, 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 @@ -271,6 +316,15 @@ def post_get_instance_auth_string(self, response: cloud_redis.InstanceAuthString """ return response + def post_get_instance_auth_string_with_metadata(self, response: cloud_redis.InstanceAuthString, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[cloud_redis.InstanceAuthString, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_instance_auth_string + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the CloudRedis server but before + it is returned to user code. + """ + return response, metadata + def pre_import_instance(self, request: cloud_redis.ImportInstanceRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[cloud_redis.ImportInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for import_instance @@ -288,6 +342,15 @@ def post_import_instance(self, response: operations_pb2.Operation) -> operations """ return response + def post_import_instance_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for import_instance + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the CloudRedis server but before + it is returned to user code. + """ + return response, metadata + def pre_list_instances(self, request: cloud_redis.ListInstancesRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[cloud_redis.ListInstancesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_instances @@ -305,6 +368,15 @@ def post_list_instances(self, response: cloud_redis.ListInstancesResponse) -> cl """ return response + def post_list_instances_with_metadata(self, response: cloud_redis.ListInstancesResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[cloud_redis.ListInstancesResponse, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for list_instances + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the CloudRedis server but before + it is returned to user code. + """ + return response, metadata + def pre_reschedule_maintenance(self, request: cloud_redis.RescheduleMaintenanceRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[cloud_redis.RescheduleMaintenanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for reschedule_maintenance @@ -322,6 +394,15 @@ def post_reschedule_maintenance(self, response: operations_pb2.Operation) -> ope """ return response + def post_reschedule_maintenance_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for reschedule_maintenance + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the CloudRedis server but before + it is returned to user code. + """ + return response, metadata + def pre_update_instance(self, request: cloud_redis.UpdateInstanceRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[cloud_redis.UpdateInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_instance @@ -339,6 +420,15 @@ def post_update_instance(self, response: operations_pb2.Operation) -> operations """ return response + def post_update_instance_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for update_instance + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the CloudRedis server but before + it is returned to user code. + """ + return response, metadata + def pre_upgrade_instance(self, request: cloud_redis.UpgradeInstanceRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[cloud_redis.UpgradeInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for upgrade_instance @@ -356,6 +446,15 @@ def post_upgrade_instance(self, response: operations_pb2.Operation) -> operation """ return response + def post_upgrade_instance_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for upgrade_instance + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the CloudRedis server but before + it is returned to user code. + """ + return response, metadata + def pre_get_location( self, request: locations_pb2.GetLocationRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]] ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: @@ -770,6 +869,8 @@ def __call__(self, json_format.Parse(response.content, resp, ignore_unknown_fields=True) resp = self._interceptor.post_create_instance(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_instance_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = json_format.MessageToJson(resp) @@ -889,6 +990,8 @@ def __call__(self, json_format.Parse(response.content, resp, ignore_unknown_fields=True) resp = self._interceptor.post_delete_instance(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_delete_instance_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = json_format.MessageToJson(resp) @@ -1011,6 +1114,8 @@ def __call__(self, json_format.Parse(response.content, resp, ignore_unknown_fields=True) resp = self._interceptor.post_export_instance(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_export_instance_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = json_format.MessageToJson(resp) @@ -1133,6 +1238,8 @@ def __call__(self, json_format.Parse(response.content, resp, ignore_unknown_fields=True) resp = self._interceptor.post_failover_instance(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_failover_instance_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = json_format.MessageToJson(resp) @@ -1251,6 +1358,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_get_instance(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_instance_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = cloud_redis.Instance.to_json(response) @@ -1369,6 +1478,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_get_instance_auth_string(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_instance_auth_string_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = cloud_redis.InstanceAuthString.to_json(response) @@ -1491,6 +1602,8 @@ def __call__(self, json_format.Parse(response.content, resp, ignore_unknown_fields=True) resp = self._interceptor.post_import_instance(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_import_instance_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = json_format.MessageToJson(resp) @@ -1611,6 +1724,8 @@ def __call__(self, json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) resp = self._interceptor.post_list_instances(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_instances_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = cloud_redis.ListInstancesResponse.to_json(response) @@ -1733,6 +1848,8 @@ def __call__(self, json_format.Parse(response.content, resp, ignore_unknown_fields=True) resp = self._interceptor.post_reschedule_maintenance(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_reschedule_maintenance_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = json_format.MessageToJson(resp) @@ -1855,6 +1972,8 @@ def __call__(self, json_format.Parse(response.content, resp, ignore_unknown_fields=True) resp = self._interceptor.post_update_instance(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_update_instance_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = json_format.MessageToJson(resp) @@ -1977,6 +2096,8 @@ def __call__(self, json_format.Parse(response.content, resp, ignore_unknown_fields=True) resp = self._interceptor.post_upgrade_instance(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_upgrade_instance_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = json_format.MessageToJson(resp) diff --git a/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/rest_asyncio.py b/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/rest_asyncio.py index 9ce8542f7..b4b2f1b40 100755 --- a/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/rest_asyncio.py +++ b/tests/integration/goldens/redis/google/cloud/redis_v1/services/cloud_redis/transports/rest_asyncio.py @@ -199,6 +199,15 @@ async def post_create_instance(self, response: operations_pb2.Operation) -> oper """ return response + async def post_create_instance_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for create_instance + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the CloudRedis server but before + it is returned to user code. + """ + return response, metadata + async def pre_delete_instance(self, request: cloud_redis.DeleteInstanceRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[cloud_redis.DeleteInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_instance @@ -216,6 +225,15 @@ async def post_delete_instance(self, response: operations_pb2.Operation) -> oper """ return response + async def post_delete_instance_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for delete_instance + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the CloudRedis server but before + it is returned to user code. + """ + return response, metadata + async def pre_export_instance(self, request: cloud_redis.ExportInstanceRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[cloud_redis.ExportInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for export_instance @@ -233,6 +251,15 @@ async def post_export_instance(self, response: operations_pb2.Operation) -> oper """ return response + async def post_export_instance_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for export_instance + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the CloudRedis server but before + it is returned to user code. + """ + return response, metadata + async def pre_failover_instance(self, request: cloud_redis.FailoverInstanceRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[cloud_redis.FailoverInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for failover_instance @@ -250,6 +277,15 @@ async def post_failover_instance(self, response: operations_pb2.Operation) -> op """ return response + async def post_failover_instance_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for failover_instance + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the CloudRedis server but before + it is returned to user code. + """ + return response, metadata + async def pre_get_instance(self, request: cloud_redis.GetInstanceRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[cloud_redis.GetInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_instance @@ -267,6 +303,15 @@ async def post_get_instance(self, response: cloud_redis.Instance) -> cloud_redis """ return response + async def post_get_instance_with_metadata(self, response: cloud_redis.Instance, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[cloud_redis.Instance, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_instance + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the CloudRedis server but before + it is returned to user code. + """ + return response, metadata + async def pre_get_instance_auth_string(self, request: cloud_redis.GetInstanceAuthStringRequest, 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 @@ -284,6 +329,15 @@ async def post_get_instance_auth_string(self, response: cloud_redis.InstanceAuth """ return response + async def post_get_instance_auth_string_with_metadata(self, response: cloud_redis.InstanceAuthString, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[cloud_redis.InstanceAuthString, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_instance_auth_string + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the CloudRedis server but before + it is returned to user code. + """ + return response, metadata + async def pre_import_instance(self, request: cloud_redis.ImportInstanceRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[cloud_redis.ImportInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for import_instance @@ -301,6 +355,15 @@ async def post_import_instance(self, response: operations_pb2.Operation) -> oper """ return response + async def post_import_instance_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for import_instance + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the CloudRedis server but before + it is returned to user code. + """ + return response, metadata + async def pre_list_instances(self, request: cloud_redis.ListInstancesRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[cloud_redis.ListInstancesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_instances @@ -318,6 +381,15 @@ async def post_list_instances(self, response: cloud_redis.ListInstancesResponse) """ return response + async def post_list_instances_with_metadata(self, response: cloud_redis.ListInstancesResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[cloud_redis.ListInstancesResponse, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for list_instances + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the CloudRedis server but before + it is returned to user code. + """ + return response, metadata + async def pre_reschedule_maintenance(self, request: cloud_redis.RescheduleMaintenanceRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[cloud_redis.RescheduleMaintenanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for reschedule_maintenance @@ -335,6 +407,15 @@ async def post_reschedule_maintenance(self, response: operations_pb2.Operation) """ return response + async def post_reschedule_maintenance_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for reschedule_maintenance + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the CloudRedis server but before + it is returned to user code. + """ + return response, metadata + async def pre_update_instance(self, request: cloud_redis.UpdateInstanceRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[cloud_redis.UpdateInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_instance @@ -352,6 +433,15 @@ async def post_update_instance(self, response: operations_pb2.Operation) -> oper """ return response + async def post_update_instance_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for update_instance + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the CloudRedis server but before + it is returned to user code. + """ + return response, metadata + async def pre_upgrade_instance(self, request: cloud_redis.UpgradeInstanceRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[cloud_redis.UpgradeInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for upgrade_instance @@ -369,6 +459,15 @@ async def post_upgrade_instance(self, response: operations_pb2.Operation) -> ope """ return response + async def post_upgrade_instance_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for upgrade_instance + + Override in a subclass to either manipulate or read, either the response + or metadata after it is returned by the CloudRedis server but before + it is returned to user code. + """ + return response, metadata + async def pre_get_location( self, request: locations_pb2.GetLocationRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]] ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: @@ -806,6 +905,8 @@ async def __call__(self, content = await response.read() json_format.Parse(content, pb_resp, ignore_unknown_fields=True) resp = await self._interceptor.post_create_instance(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = await self._interceptor.post_create_instance_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = json_format.MessageToJson(resp) @@ -931,6 +1032,8 @@ async def __call__(self, content = await response.read() json_format.Parse(content, pb_resp, ignore_unknown_fields=True) resp = await self._interceptor.post_delete_instance(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = await self._interceptor.post_delete_instance_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = json_format.MessageToJson(resp) @@ -1059,6 +1162,8 @@ async def __call__(self, content = await response.read() json_format.Parse(content, pb_resp, ignore_unknown_fields=True) resp = await self._interceptor.post_export_instance(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = await self._interceptor.post_export_instance_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = json_format.MessageToJson(resp) @@ -1187,6 +1292,8 @@ async def __call__(self, content = await response.read() json_format.Parse(content, pb_resp, ignore_unknown_fields=True) resp = await self._interceptor.post_failover_instance(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = await self._interceptor.post_failover_instance_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = json_format.MessageToJson(resp) @@ -1309,6 +1416,8 @@ async def __call__(self, content = await response.read() json_format.Parse(content, pb_resp, ignore_unknown_fields=True) resp = await self._interceptor.post_get_instance(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = await self._interceptor.post_get_instance_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = cloud_redis.Instance.to_json(response) @@ -1431,6 +1540,8 @@ async def __call__(self, content = await response.read() json_format.Parse(content, pb_resp, ignore_unknown_fields=True) resp = await self._interceptor.post_get_instance_auth_string(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = await self._interceptor.post_get_instance_auth_string_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = cloud_redis.InstanceAuthString.to_json(response) @@ -1559,6 +1670,8 @@ async def __call__(self, content = await response.read() json_format.Parse(content, pb_resp, ignore_unknown_fields=True) resp = await self._interceptor.post_import_instance(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = await self._interceptor.post_import_instance_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = json_format.MessageToJson(resp) @@ -1683,6 +1796,8 @@ async def __call__(self, content = await response.read() json_format.Parse(content, pb_resp, ignore_unknown_fields=True) resp = await self._interceptor.post_list_instances(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = await self._interceptor.post_list_instances_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = cloud_redis.ListInstancesResponse.to_json(response) @@ -1811,6 +1926,8 @@ async def __call__(self, content = await response.read() json_format.Parse(content, pb_resp, ignore_unknown_fields=True) resp = await self._interceptor.post_reschedule_maintenance(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = await self._interceptor.post_reschedule_maintenance_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = json_format.MessageToJson(resp) @@ -1939,6 +2056,8 @@ async def __call__(self, content = await response.read() json_format.Parse(content, pb_resp, ignore_unknown_fields=True) resp = await self._interceptor.post_update_instance(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = await self._interceptor.post_update_instance_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = json_format.MessageToJson(resp) @@ -2067,6 +2186,8 @@ async def __call__(self, content = await response.read() json_format.Parse(content, pb_resp, ignore_unknown_fields=True) resp = await self._interceptor.post_upgrade_instance(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = await self._interceptor.post_upgrade_instance_with_metadata(resp, response_metadata) if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER try: response_payload = json_format.MessageToJson(resp) diff --git a/tests/integration/goldens/redis/tests/unit/gapic/redis_v1/test_cloud_redis.py b/tests/integration/goldens/redis/tests/unit/gapic/redis_v1/test_cloud_redis.py index d46839b7a..fef9b1805 100755 --- a/tests/integration/goldens/redis/tests/unit/gapic/redis_v1/test_cloud_redis.py +++ b/tests/integration/goldens/redis/tests/unit/gapic/redis_v1/test_cloud_redis.py @@ -7287,9 +7287,11 @@ def test_list_instances_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.CloudRedisRestInterceptor, "post_list_instances") as post, \ + mock.patch.object(transports.CloudRedisRestInterceptor, "post_list_instances_with_metadata") as post_with_metadata, \ mock.patch.object(transports.CloudRedisRestInterceptor, "pre_list_instances") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = cloud_redis.ListInstancesRequest.pb(cloud_redis.ListInstancesRequest()) transcode.return_value = { "method": "post", @@ -7311,11 +7313,13 @@ def test_list_instances_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = cloud_redis.ListInstancesResponse() + post_with_metadata.return_value = cloud_redis.ListInstancesResponse(), metadata client.list_instances(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_get_instance_rest_bad_request(request_type=cloud_redis.GetInstanceRequest): @@ -7441,9 +7445,11 @@ def test_get_instance_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.CloudRedisRestInterceptor, "post_get_instance") as post, \ + mock.patch.object(transports.CloudRedisRestInterceptor, "post_get_instance_with_metadata") as post_with_metadata, \ mock.patch.object(transports.CloudRedisRestInterceptor, "pre_get_instance") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = cloud_redis.GetInstanceRequest.pb(cloud_redis.GetInstanceRequest()) transcode.return_value = { "method": "post", @@ -7465,11 +7471,13 @@ def test_get_instance_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = cloud_redis.Instance() + post_with_metadata.return_value = cloud_redis.Instance(), metadata client.get_instance(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_get_instance_auth_string_rest_bad_request(request_type=cloud_redis.GetInstanceAuthStringRequest): @@ -7543,9 +7551,11 @@ def test_get_instance_auth_string_rest_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.CloudRedisRestInterceptor, "post_get_instance_auth_string") as post, \ + mock.patch.object(transports.CloudRedisRestInterceptor, "post_get_instance_auth_string_with_metadata") as post_with_metadata, \ mock.patch.object(transports.CloudRedisRestInterceptor, "pre_get_instance_auth_string") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = cloud_redis.GetInstanceAuthStringRequest.pb(cloud_redis.GetInstanceAuthStringRequest()) transcode.return_value = { "method": "post", @@ -7567,11 +7577,13 @@ def test_get_instance_auth_string_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = cloud_redis.InstanceAuthString() + post_with_metadata.return_value = cloud_redis.InstanceAuthString(), metadata client.get_instance_auth_string(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_create_instance_rest_bad_request(request_type=cloud_redis.CreateInstanceRequest): @@ -7704,9 +7716,11 @@ def test_create_instance_rest_interceptors(null_interceptor): mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(operation.Operation, "_set_result_from_operation"), \ mock.patch.object(transports.CloudRedisRestInterceptor, "post_create_instance") as post, \ + mock.patch.object(transports.CloudRedisRestInterceptor, "post_create_instance_with_metadata") as post_with_metadata, \ mock.patch.object(transports.CloudRedisRestInterceptor, "pre_create_instance") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = cloud_redis.CreateInstanceRequest.pb(cloud_redis.CreateInstanceRequest()) transcode.return_value = { "method": "post", @@ -7728,11 +7742,13 @@ def test_create_instance_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata client.create_instance(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_update_instance_rest_bad_request(request_type=cloud_redis.UpdateInstanceRequest): @@ -7865,9 +7881,11 @@ def test_update_instance_rest_interceptors(null_interceptor): mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(operation.Operation, "_set_result_from_operation"), \ mock.patch.object(transports.CloudRedisRestInterceptor, "post_update_instance") as post, \ + mock.patch.object(transports.CloudRedisRestInterceptor, "post_update_instance_with_metadata") as post_with_metadata, \ mock.patch.object(transports.CloudRedisRestInterceptor, "pre_update_instance") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = cloud_redis.UpdateInstanceRequest.pb(cloud_redis.UpdateInstanceRequest()) transcode.return_value = { "method": "post", @@ -7889,11 +7907,13 @@ def test_update_instance_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata client.update_instance(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_upgrade_instance_rest_bad_request(request_type=cloud_redis.UpgradeInstanceRequest): @@ -7962,9 +7982,11 @@ def test_upgrade_instance_rest_interceptors(null_interceptor): mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(operation.Operation, "_set_result_from_operation"), \ mock.patch.object(transports.CloudRedisRestInterceptor, "post_upgrade_instance") as post, \ + mock.patch.object(transports.CloudRedisRestInterceptor, "post_upgrade_instance_with_metadata") as post_with_metadata, \ mock.patch.object(transports.CloudRedisRestInterceptor, "pre_upgrade_instance") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = cloud_redis.UpgradeInstanceRequest.pb(cloud_redis.UpgradeInstanceRequest()) transcode.return_value = { "method": "post", @@ -7986,11 +8008,13 @@ def test_upgrade_instance_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata client.upgrade_instance(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_import_instance_rest_bad_request(request_type=cloud_redis.ImportInstanceRequest): @@ -8059,9 +8083,11 @@ def test_import_instance_rest_interceptors(null_interceptor): mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(operation.Operation, "_set_result_from_operation"), \ mock.patch.object(transports.CloudRedisRestInterceptor, "post_import_instance") as post, \ + mock.patch.object(transports.CloudRedisRestInterceptor, "post_import_instance_with_metadata") as post_with_metadata, \ mock.patch.object(transports.CloudRedisRestInterceptor, "pre_import_instance") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = cloud_redis.ImportInstanceRequest.pb(cloud_redis.ImportInstanceRequest()) transcode.return_value = { "method": "post", @@ -8083,11 +8109,13 @@ def test_import_instance_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata client.import_instance(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_export_instance_rest_bad_request(request_type=cloud_redis.ExportInstanceRequest): @@ -8156,9 +8184,11 @@ def test_export_instance_rest_interceptors(null_interceptor): mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(operation.Operation, "_set_result_from_operation"), \ mock.patch.object(transports.CloudRedisRestInterceptor, "post_export_instance") as post, \ + mock.patch.object(transports.CloudRedisRestInterceptor, "post_export_instance_with_metadata") as post_with_metadata, \ mock.patch.object(transports.CloudRedisRestInterceptor, "pre_export_instance") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = cloud_redis.ExportInstanceRequest.pb(cloud_redis.ExportInstanceRequest()) transcode.return_value = { "method": "post", @@ -8180,11 +8210,13 @@ def test_export_instance_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata client.export_instance(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_failover_instance_rest_bad_request(request_type=cloud_redis.FailoverInstanceRequest): @@ -8253,9 +8285,11 @@ def test_failover_instance_rest_interceptors(null_interceptor): mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(operation.Operation, "_set_result_from_operation"), \ mock.patch.object(transports.CloudRedisRestInterceptor, "post_failover_instance") as post, \ + mock.patch.object(transports.CloudRedisRestInterceptor, "post_failover_instance_with_metadata") as post_with_metadata, \ mock.patch.object(transports.CloudRedisRestInterceptor, "pre_failover_instance") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = cloud_redis.FailoverInstanceRequest.pb(cloud_redis.FailoverInstanceRequest()) transcode.return_value = { "method": "post", @@ -8277,11 +8311,13 @@ def test_failover_instance_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata client.failover_instance(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_delete_instance_rest_bad_request(request_type=cloud_redis.DeleteInstanceRequest): @@ -8350,9 +8386,11 @@ def test_delete_instance_rest_interceptors(null_interceptor): mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(operation.Operation, "_set_result_from_operation"), \ mock.patch.object(transports.CloudRedisRestInterceptor, "post_delete_instance") as post, \ + mock.patch.object(transports.CloudRedisRestInterceptor, "post_delete_instance_with_metadata") as post_with_metadata, \ mock.patch.object(transports.CloudRedisRestInterceptor, "pre_delete_instance") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = cloud_redis.DeleteInstanceRequest.pb(cloud_redis.DeleteInstanceRequest()) transcode.return_value = { "method": "post", @@ -8374,11 +8412,13 @@ def test_delete_instance_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata client.delete_instance(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_reschedule_maintenance_rest_bad_request(request_type=cloud_redis.RescheduleMaintenanceRequest): @@ -8447,9 +8487,11 @@ def test_reschedule_maintenance_rest_interceptors(null_interceptor): mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(operation.Operation, "_set_result_from_operation"), \ mock.patch.object(transports.CloudRedisRestInterceptor, "post_reschedule_maintenance") as post, \ + mock.patch.object(transports.CloudRedisRestInterceptor, "post_reschedule_maintenance_with_metadata") as post_with_metadata, \ mock.patch.object(transports.CloudRedisRestInterceptor, "pre_reschedule_maintenance") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = cloud_redis.RescheduleMaintenanceRequest.pb(cloud_redis.RescheduleMaintenanceRequest()) transcode.return_value = { "method": "post", @@ -8471,11 +8513,13 @@ def test_reschedule_maintenance_rest_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata client.reschedule_maintenance(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() def test_get_location_rest_bad_request(request_type=locations_pb2.GetLocationRequest): @@ -9204,9 +9248,11 @@ async def test_list_instances_rest_asyncio_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "post_list_instances") as post, \ + mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "post_list_instances_with_metadata") as post_with_metadata, \ mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "pre_list_instances") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = cloud_redis.ListInstancesRequest.pb(cloud_redis.ListInstancesRequest()) transcode.return_value = { "method": "post", @@ -9228,11 +9274,13 @@ async def test_list_instances_rest_asyncio_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = cloud_redis.ListInstancesResponse() + post_with_metadata.return_value = cloud_redis.ListInstancesResponse(), metadata await client.list_instances(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() @pytest.mark.asyncio async def test_get_instance_rest_asyncio_bad_request(request_type=cloud_redis.GetInstanceRequest): @@ -9365,9 +9413,11 @@ async def test_get_instance_rest_asyncio_interceptors(null_interceptor): with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "post_get_instance") as post, \ + mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "post_get_instance_with_metadata") as post_with_metadata, \ mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "pre_get_instance") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = cloud_redis.GetInstanceRequest.pb(cloud_redis.GetInstanceRequest()) transcode.return_value = { "method": "post", @@ -9389,11 +9439,13 @@ async def test_get_instance_rest_asyncio_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = cloud_redis.Instance() + post_with_metadata.return_value = cloud_redis.Instance(), metadata await client.get_instance(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() @pytest.mark.asyncio async def test_get_instance_auth_string_rest_asyncio_bad_request(request_type=cloud_redis.GetInstanceAuthStringRequest): @@ -9474,9 +9526,11 @@ async def test_get_instance_auth_string_rest_asyncio_interceptors(null_intercept with mock.patch.object(type(client.transport._session), "request") as req, \ mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "post_get_instance_auth_string") as post, \ + mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "post_get_instance_auth_string_with_metadata") as post_with_metadata, \ mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "pre_get_instance_auth_string") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = cloud_redis.GetInstanceAuthStringRequest.pb(cloud_redis.GetInstanceAuthStringRequest()) transcode.return_value = { "method": "post", @@ -9498,11 +9552,13 @@ async def test_get_instance_auth_string_rest_asyncio_interceptors(null_intercept ] pre.return_value = request, metadata post.return_value = cloud_redis.InstanceAuthString() + post_with_metadata.return_value = cloud_redis.InstanceAuthString(), metadata await client.get_instance_auth_string(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() @pytest.mark.asyncio async def test_create_instance_rest_asyncio_bad_request(request_type=cloud_redis.CreateInstanceRequest): @@ -9642,9 +9698,11 @@ async def test_create_instance_rest_asyncio_interceptors(null_interceptor): mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(operation.Operation, "_set_result_from_operation"), \ mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "post_create_instance") as post, \ + mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "post_create_instance_with_metadata") as post_with_metadata, \ mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "pre_create_instance") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = cloud_redis.CreateInstanceRequest.pb(cloud_redis.CreateInstanceRequest()) transcode.return_value = { "method": "post", @@ -9666,11 +9724,13 @@ async def test_create_instance_rest_asyncio_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata await client.create_instance(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() @pytest.mark.asyncio async def test_update_instance_rest_asyncio_bad_request(request_type=cloud_redis.UpdateInstanceRequest): @@ -9810,9 +9870,11 @@ async def test_update_instance_rest_asyncio_interceptors(null_interceptor): mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(operation.Operation, "_set_result_from_operation"), \ mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "post_update_instance") as post, \ + mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "post_update_instance_with_metadata") as post_with_metadata, \ mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "pre_update_instance") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = cloud_redis.UpdateInstanceRequest.pb(cloud_redis.UpdateInstanceRequest()) transcode.return_value = { "method": "post", @@ -9834,11 +9896,13 @@ async def test_update_instance_rest_asyncio_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata await client.update_instance(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() @pytest.mark.asyncio async def test_upgrade_instance_rest_asyncio_bad_request(request_type=cloud_redis.UpgradeInstanceRequest): @@ -9914,9 +9978,11 @@ async def test_upgrade_instance_rest_asyncio_interceptors(null_interceptor): mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(operation.Operation, "_set_result_from_operation"), \ mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "post_upgrade_instance") as post, \ + mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "post_upgrade_instance_with_metadata") as post_with_metadata, \ mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "pre_upgrade_instance") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = cloud_redis.UpgradeInstanceRequest.pb(cloud_redis.UpgradeInstanceRequest()) transcode.return_value = { "method": "post", @@ -9938,11 +10004,13 @@ async def test_upgrade_instance_rest_asyncio_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata await client.upgrade_instance(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() @pytest.mark.asyncio async def test_import_instance_rest_asyncio_bad_request(request_type=cloud_redis.ImportInstanceRequest): @@ -10018,9 +10086,11 @@ async def test_import_instance_rest_asyncio_interceptors(null_interceptor): mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(operation.Operation, "_set_result_from_operation"), \ mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "post_import_instance") as post, \ + mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "post_import_instance_with_metadata") as post_with_metadata, \ mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "pre_import_instance") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = cloud_redis.ImportInstanceRequest.pb(cloud_redis.ImportInstanceRequest()) transcode.return_value = { "method": "post", @@ -10042,11 +10112,13 @@ async def test_import_instance_rest_asyncio_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata await client.import_instance(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() @pytest.mark.asyncio async def test_export_instance_rest_asyncio_bad_request(request_type=cloud_redis.ExportInstanceRequest): @@ -10122,9 +10194,11 @@ async def test_export_instance_rest_asyncio_interceptors(null_interceptor): mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(operation.Operation, "_set_result_from_operation"), \ mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "post_export_instance") as post, \ + mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "post_export_instance_with_metadata") as post_with_metadata, \ mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "pre_export_instance") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = cloud_redis.ExportInstanceRequest.pb(cloud_redis.ExportInstanceRequest()) transcode.return_value = { "method": "post", @@ -10146,11 +10220,13 @@ async def test_export_instance_rest_asyncio_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata await client.export_instance(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() @pytest.mark.asyncio async def test_failover_instance_rest_asyncio_bad_request(request_type=cloud_redis.FailoverInstanceRequest): @@ -10226,9 +10302,11 @@ async def test_failover_instance_rest_asyncio_interceptors(null_interceptor): mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(operation.Operation, "_set_result_from_operation"), \ mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "post_failover_instance") as post, \ + mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "post_failover_instance_with_metadata") as post_with_metadata, \ mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "pre_failover_instance") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = cloud_redis.FailoverInstanceRequest.pb(cloud_redis.FailoverInstanceRequest()) transcode.return_value = { "method": "post", @@ -10250,11 +10328,13 @@ async def test_failover_instance_rest_asyncio_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata await client.failover_instance(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() @pytest.mark.asyncio async def test_delete_instance_rest_asyncio_bad_request(request_type=cloud_redis.DeleteInstanceRequest): @@ -10330,9 +10410,11 @@ async def test_delete_instance_rest_asyncio_interceptors(null_interceptor): mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(operation.Operation, "_set_result_from_operation"), \ mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "post_delete_instance") as post, \ + mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "post_delete_instance_with_metadata") as post_with_metadata, \ mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "pre_delete_instance") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = cloud_redis.DeleteInstanceRequest.pb(cloud_redis.DeleteInstanceRequest()) transcode.return_value = { "method": "post", @@ -10354,11 +10436,13 @@ async def test_delete_instance_rest_asyncio_interceptors(null_interceptor): ] pre.return_value = request, metadata post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata await client.delete_instance(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() @pytest.mark.asyncio async def test_reschedule_maintenance_rest_asyncio_bad_request(request_type=cloud_redis.RescheduleMaintenanceRequest): @@ -10434,9 +10518,11 @@ async def test_reschedule_maintenance_rest_asyncio_interceptors(null_interceptor mock.patch.object(path_template, "transcode") as transcode, \ mock.patch.object(operation.Operation, "_set_result_from_operation"), \ mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "post_reschedule_maintenance") as post, \ + mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "post_reschedule_maintenance_with_metadata") as post_with_metadata, \ mock.patch.object(transports.AsyncCloudRedisRestInterceptor, "pre_reschedule_maintenance") as pre: pre.assert_not_called() post.assert_not_called() + post_with_metadata.assert_not_called() pb_message = cloud_redis.RescheduleMaintenanceRequest.pb(cloud_redis.RescheduleMaintenanceRequest()) transcode.return_value = { "method": "post", @@ -10458,11 +10544,13 @@ async def test_reschedule_maintenance_rest_asyncio_interceptors(null_interceptor ] pre.return_value = request, metadata post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata await client.reschedule_maintenance(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) pre.assert_called_once() post.assert_called_once() + post_with_metadata.assert_called_once() @pytest.mark.asyncio async def test_get_location_rest_asyncio_bad_request(request_type=locations_pb2.GetLocationRequest):