1313# See the License for the specific language governing permissions and
1414# limitations under the License.
1515#
16+ import inspect
1617import warnings
1718from typing import Awaitable , Callable , Dict , Optional , Sequence , Tuple , Union
1819
@@ -233,6 +234,9 @@ def __init__(
233234 )
234235
235236 # Wrap messages. This must be done after self._grpc_channel exists
237+ self ._wrap_with_kind = (
238+ "kind" in inspect .signature (gapic_v1 .method_async .wrap_method ).parameters
239+ )
236240 self ._prep_wrapped_messages (client_info )
237241
238242 @property
@@ -585,7 +589,7 @@ def test_iam_permissions(
585589 def _prep_wrapped_messages (self , client_info ):
586590 """Precompute the wrapped methods, overriding the base class method to use async wrappers."""
587591 self ._wrapped_methods = {
588- self .create_topic : gapic_v1 . method_async . wrap_method (
592+ self .create_topic : self . _wrap_method (
589593 self .create_topic ,
590594 default_retry = retries .AsyncRetry (
591595 initial = 0.1 ,
@@ -599,7 +603,7 @@ def _prep_wrapped_messages(self, client_info):
599603 default_timeout = 60.0 ,
600604 client_info = client_info ,
601605 ),
602- self .update_topic : gapic_v1 . method_async . wrap_method (
606+ self .update_topic : self . _wrap_method (
603607 self .update_topic ,
604608 default_retry = retries .AsyncRetry (
605609 initial = 0.1 ,
@@ -613,7 +617,7 @@ def _prep_wrapped_messages(self, client_info):
613617 default_timeout = 60.0 ,
614618 client_info = client_info ,
615619 ),
616- self .publish : gapic_v1 . method_async . wrap_method (
620+ self .publish : self . _wrap_method (
617621 self .publish ,
618622 default_retry = retries .AsyncRetry (
619623 initial = 0.1 ,
@@ -633,7 +637,7 @@ def _prep_wrapped_messages(self, client_info):
633637 default_timeout = 60.0 ,
634638 client_info = client_info ,
635639 ),
636- self .get_topic : gapic_v1 . method_async . wrap_method (
640+ self .get_topic : self . _wrap_method (
637641 self .get_topic ,
638642 default_retry = retries .AsyncRetry (
639643 initial = 0.1 ,
@@ -649,7 +653,7 @@ def _prep_wrapped_messages(self, client_info):
649653 default_timeout = 60.0 ,
650654 client_info = client_info ,
651655 ),
652- self .list_topics : gapic_v1 . method_async . wrap_method (
656+ self .list_topics : self . _wrap_method (
653657 self .list_topics ,
654658 default_retry = retries .AsyncRetry (
655659 initial = 0.1 ,
@@ -665,7 +669,7 @@ def _prep_wrapped_messages(self, client_info):
665669 default_timeout = 60.0 ,
666670 client_info = client_info ,
667671 ),
668- self .list_topic_subscriptions : gapic_v1 . method_async . wrap_method (
672+ self .list_topic_subscriptions : self . _wrap_method (
669673 self .list_topic_subscriptions ,
670674 default_retry = retries .AsyncRetry (
671675 initial = 0.1 ,
@@ -681,7 +685,7 @@ def _prep_wrapped_messages(self, client_info):
681685 default_timeout = 60.0 ,
682686 client_info = client_info ,
683687 ),
684- self .list_topic_snapshots : gapic_v1 . method_async . wrap_method (
688+ self .list_topic_snapshots : self . _wrap_method (
685689 self .list_topic_snapshots ,
686690 default_retry = retries .AsyncRetry (
687691 initial = 0.1 ,
@@ -697,7 +701,7 @@ def _prep_wrapped_messages(self, client_info):
697701 default_timeout = 60.0 ,
698702 client_info = client_info ,
699703 ),
700- self .delete_topic : gapic_v1 . method_async . wrap_method (
704+ self .delete_topic : self . _wrap_method (
701705 self .delete_topic ,
702706 default_retry = retries .AsyncRetry (
703707 initial = 0.1 ,
@@ -711,7 +715,7 @@ def _prep_wrapped_messages(self, client_info):
711715 default_timeout = 60.0 ,
712716 client_info = client_info ,
713717 ),
714- self .detach_subscription : gapic_v1 . method_async . wrap_method (
718+ self .detach_subscription : self . _wrap_method (
715719 self .detach_subscription ,
716720 default_retry = retries .AsyncRetry (
717721 initial = 0.1 ,
@@ -725,10 +729,34 @@ def _prep_wrapped_messages(self, client_info):
725729 default_timeout = 60.0 ,
726730 client_info = client_info ,
727731 ),
732+ self .get_iam_policy : self ._wrap_method (
733+ self .get_iam_policy ,
734+ default_timeout = None ,
735+ client_info = client_info ,
736+ ),
737+ self .set_iam_policy : self ._wrap_method (
738+ self .set_iam_policy ,
739+ default_timeout = None ,
740+ client_info = client_info ,
741+ ),
742+ self .test_iam_permissions : self ._wrap_method (
743+ self .test_iam_permissions ,
744+ default_timeout = None ,
745+ client_info = client_info ,
746+ ),
728747 }
729748
749+ def _wrap_method (self , func , * args , ** kwargs ):
750+ if self ._wrap_with_kind : # pragma: NO COVER
751+ kwargs ["kind" ] = self .kind
752+ return gapic_v1 .method_async .wrap_method (func , * args , ** kwargs )
753+
730754 def close (self ):
731755 return self .grpc_channel .close ()
732756
757+ @property
758+ def kind (self ) -> str :
759+ return "grpc_asyncio"
760+
733761
734762__all__ = ("PublisherGrpcAsyncIOTransport" ,)
0 commit comments