3232from google .protobuf import duration_pb2 as duration # type: ignore
3333from google .protobuf import timestamp_pb2 as timestamp # type: ignore
3434
35- from .transports .base import IAMCredentialsTransport
35+ from .transports .base import IAMCredentialsTransport , DEFAULT_CLIENT_INFO
3636from .transports .grpc_asyncio import IAMCredentialsGrpcAsyncIOTransport
3737from .client import IAMCredentialsClient
3838
@@ -55,9 +55,52 @@ class IAMCredentialsAsyncClient:
5555 DEFAULT_ENDPOINT = IAMCredentialsClient .DEFAULT_ENDPOINT
5656 DEFAULT_MTLS_ENDPOINT = IAMCredentialsClient .DEFAULT_MTLS_ENDPOINT
5757
58+ service_account_path = staticmethod (IAMCredentialsClient .service_account_path )
59+ parse_service_account_path = staticmethod (
60+ IAMCredentialsClient .parse_service_account_path
61+ )
62+
63+ common_billing_account_path = staticmethod (
64+ IAMCredentialsClient .common_billing_account_path
65+ )
66+ parse_common_billing_account_path = staticmethod (
67+ IAMCredentialsClient .parse_common_billing_account_path
68+ )
69+
70+ common_folder_path = staticmethod (IAMCredentialsClient .common_folder_path )
71+ parse_common_folder_path = staticmethod (
72+ IAMCredentialsClient .parse_common_folder_path
73+ )
74+
75+ common_organization_path = staticmethod (
76+ IAMCredentialsClient .common_organization_path
77+ )
78+ parse_common_organization_path = staticmethod (
79+ IAMCredentialsClient .parse_common_organization_path
80+ )
81+
82+ common_project_path = staticmethod (IAMCredentialsClient .common_project_path )
83+ parse_common_project_path = staticmethod (
84+ IAMCredentialsClient .parse_common_project_path
85+ )
86+
87+ common_location_path = staticmethod (IAMCredentialsClient .common_location_path )
88+ parse_common_location_path = staticmethod (
89+ IAMCredentialsClient .parse_common_location_path
90+ )
91+
5892 from_service_account_file = IAMCredentialsClient .from_service_account_file
5993 from_service_account_json = from_service_account_file
6094
95+ @property
96+ def transport (self ) -> IAMCredentialsTransport :
97+ """Return the transport used by the client instance.
98+
99+ Returns:
100+ IAMCredentialsTransport: The transport used by the client instance.
101+ """
102+ return self ._client .transport
103+
61104 get_transport_class = functools .partial (
62105 type (IAMCredentialsClient ).get_transport_class , type (IAMCredentialsClient )
63106 )
@@ -68,6 +111,7 @@ def __init__(
68111 credentials : credentials .Credentials = None ,
69112 transport : Union [str , IAMCredentialsTransport ] = "grpc_asyncio" ,
70113 client_options : ClientOptions = None ,
114+ client_info : gapic_v1 .client_info .ClientInfo = DEFAULT_CLIENT_INFO ,
71115 ) -> None :
72116 """Instantiate the iam credentials client.
73117
@@ -83,24 +127,30 @@ def __init__(
83127 client_options (ClientOptions): Custom options for the client. It
84128 won't take effect if a ``transport`` instance is provided.
85129 (1) The ``api_endpoint`` property can be used to override the
86- default endpoint provided by the client. GOOGLE_API_USE_MTLS
130+ default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
87131 environment variable can also be used to override the endpoint:
88132 "always" (always use the default mTLS endpoint), "never" (always
89- use the default regular endpoint, this is the default value for
90- the environment variable) and "auto" (auto switch to the default
91- mTLS endpoint if client SSL credentials is present). However,
92- the ``api_endpoint`` property takes precedence if provided.
93- (2) The ``client_cert_source`` property is used to provide client
94- SSL credentials for mutual TLS transport. If not provided, the
95- default SSL credentials will be used if present.
133+ use the default regular endpoint) and "auto" (auto switch to the
134+ default mTLS endpoint if client certificate is present, this is
135+ the default value). However, the ``api_endpoint`` property takes
136+ precedence if provided.
137+ (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
138+ is "true", then the ``client_cert_source`` property can be used
139+ to provide client certificate for mutual TLS transport. If
140+ not provided, the default SSL client certificate will be used if
141+ present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
142+ set, no client certificate will be used.
96143
97144 Raises:
98145 google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
99146 creation failed for any reason.
100147 """
101148
102149 self ._client = IAMCredentialsClient (
103- credentials = credentials , transport = transport , client_options = client_options ,
150+ credentials = credentials ,
151+ transport = transport ,
152+ client_options = client_options ,
153+ client_info = client_info ,
104154 )
105155
106156 async def generate_access_token (
@@ -182,7 +232,8 @@ async def generate_access_token(
182232 # Create or coerce a protobuf request object.
183233 # Sanity check: If we got a request object, we should *not* have
184234 # gotten any keyword arguments that map to the request.
185- if request is not None and any ([name , delegates , scope , lifetime ]):
235+ has_flattened_params = any ([name , delegates , scope , lifetime ])
236+ if request is not None and has_flattened_params :
186237 raise ValueError (
187238 "If the `request` argument is set, then none of "
188239 "the individual field arguments should be set."
@@ -195,13 +246,14 @@ async def generate_access_token(
195246
196247 if name is not None :
197248 request .name = name
198- if delegates is not None :
199- request .delegates = delegates
200- if scope is not None :
201- request .scope = scope
202249 if lifetime is not None :
203250 request .lifetime = lifetime
204251
252+ if delegates :
253+ request .delegates .extend (delegates )
254+ if scope :
255+ request .scope .extend (scope )
256+
205257 # Wrap the RPC method; this adds retry and timeout information,
206258 # and friendly error handling.
207259 rpc = gapic_v1 .method_async .wrap_method (
@@ -215,7 +267,7 @@ async def generate_access_token(
215267 ),
216268 ),
217269 default_timeout = 60.0 ,
218- client_info = _client_info ,
270+ client_info = DEFAULT_CLIENT_INFO ,
219271 )
220272
221273 # Certain fields should be provided within the metadata header;
@@ -303,7 +355,8 @@ async def generate_id_token(
303355 # Create or coerce a protobuf request object.
304356 # Sanity check: If we got a request object, we should *not* have
305357 # gotten any keyword arguments that map to the request.
306- if request is not None and any ([name , delegates , audience , include_email ]):
358+ has_flattened_params = any ([name , delegates , audience , include_email ])
359+ if request is not None and has_flattened_params :
307360 raise ValueError (
308361 "If the `request` argument is set, then none of "
309362 "the individual field arguments should be set."
@@ -316,13 +369,14 @@ async def generate_id_token(
316369
317370 if name is not None :
318371 request .name = name
319- if delegates is not None :
320- request .delegates = delegates
321372 if audience is not None :
322373 request .audience = audience
323374 if include_email is not None :
324375 request .include_email = include_email
325376
377+ if delegates :
378+ request .delegates .extend (delegates )
379+
326380 # Wrap the RPC method; this adds retry and timeout information,
327381 # and friendly error handling.
328382 rpc = gapic_v1 .method_async .wrap_method (
@@ -336,7 +390,7 @@ async def generate_id_token(
336390 ),
337391 ),
338392 default_timeout = 60.0 ,
339- client_info = _client_info ,
393+ client_info = DEFAULT_CLIENT_INFO ,
340394 )
341395
342396 # Certain fields should be provided within the metadata header;
@@ -414,7 +468,8 @@ async def sign_blob(
414468 # Create or coerce a protobuf request object.
415469 # Sanity check: If we got a request object, we should *not* have
416470 # gotten any keyword arguments that map to the request.
417- if request is not None and any ([name , delegates , payload ]):
471+ has_flattened_params = any ([name , delegates , payload ])
472+ if request is not None and has_flattened_params :
418473 raise ValueError (
419474 "If the `request` argument is set, then none of "
420475 "the individual field arguments should be set."
@@ -427,11 +482,12 @@ async def sign_blob(
427482
428483 if name is not None :
429484 request .name = name
430- if delegates is not None :
431- request .delegates = delegates
432485 if payload is not None :
433486 request .payload = payload
434487
488+ if delegates :
489+ request .delegates .extend (delegates )
490+
435491 # Wrap the RPC method; this adds retry and timeout information,
436492 # and friendly error handling.
437493 rpc = gapic_v1 .method_async .wrap_method (
@@ -445,7 +501,7 @@ async def sign_blob(
445501 ),
446502 ),
447503 default_timeout = 60.0 ,
448- client_info = _client_info ,
504+ client_info = DEFAULT_CLIENT_INFO ,
449505 )
450506
451507 # Certain fields should be provided within the metadata header;
@@ -525,7 +581,8 @@ async def sign_jwt(
525581 # Create or coerce a protobuf request object.
526582 # Sanity check: If we got a request object, we should *not* have
527583 # gotten any keyword arguments that map to the request.
528- if request is not None and any ([name , delegates , payload ]):
584+ has_flattened_params = any ([name , delegates , payload ])
585+ if request is not None and has_flattened_params :
529586 raise ValueError (
530587 "If the `request` argument is set, then none of "
531588 "the individual field arguments should be set."
@@ -538,11 +595,12 @@ async def sign_jwt(
538595
539596 if name is not None :
540597 request .name = name
541- if delegates is not None :
542- request .delegates = delegates
543598 if payload is not None :
544599 request .payload = payload
545600
601+ if delegates :
602+ request .delegates .extend (delegates )
603+
546604 # Wrap the RPC method; this adds retry and timeout information,
547605 # and friendly error handling.
548606 rpc = gapic_v1 .method_async .wrap_method (
@@ -556,7 +614,7 @@ async def sign_jwt(
556614 ),
557615 ),
558616 default_timeout = 60.0 ,
559- client_info = _client_info ,
617+ client_info = DEFAULT_CLIENT_INFO ,
560618 )
561619
562620 # Certain fields should be provided within the metadata header;
@@ -573,11 +631,11 @@ async def sign_jwt(
573631
574632
575633try :
576- _client_info = gapic_v1 .client_info .ClientInfo (
634+ DEFAULT_CLIENT_INFO = gapic_v1 .client_info .ClientInfo (
577635 gapic_version = pkg_resources .get_distribution ("google-cloud-iam" ,).version ,
578636 )
579637except pkg_resources .DistributionNotFound :
580- _client_info = gapic_v1 .client_info .ClientInfo ()
638+ DEFAULT_CLIENT_INFO = gapic_v1 .client_info .ClientInfo ()
581639
582640
583641__all__ = ("IAMCredentialsAsyncClient" ,)
0 commit comments