4545except AttributeError : # pragma: NO COVER
4646 OptionalRetry = Union [retries .AsyncRetry , object , None ] # type: ignore
4747
48- from google .api_core import operation # type: ignore
49- from google .api_core import operation_async # type: ignore
50- from google .iam .v1 import iam_policy_pb2 # type: ignore
51- from google .iam .v1 import policy_pb2 # type: ignore
48+ import google .api_core . operation as operation # type: ignore
49+ import google .api_core . operation_async as operation_async # type: ignore
50+ import google .iam .v1 . iam_policy_pb2 as iam_policy_pb2 # type: ignore
51+ import google .iam .v1 . policy_pb2 as policy_pb2 # type: ignore
5252from google .longrunning import operations_pb2 # type: ignore
53- from google .protobuf import duration_pb2 # type: ignore
54- from google .protobuf import empty_pb2 # type: ignore
55- from google .protobuf import field_mask_pb2 # type: ignore
56- from google .protobuf import timestamp_pb2 # type: ignore
53+ import google .longrunning .operations_pb2 as operations_pb2 # type: ignore
54+ import google .protobuf .duration_pb2 as duration_pb2 # type: ignore
55+ import google .protobuf .empty_pb2 as empty_pb2 # type: ignore
56+ import google .protobuf .field_mask_pb2 as field_mask_pb2 # type: ignore
57+ import google .protobuf .timestamp_pb2 as timestamp_pb2 # type: ignore
5758
5859from google .cloud .spanner_admin_database_v1 .services .database_admin import pagers
5960from google .cloud .spanner_admin_database_v1 .types import common , spanner_database_admin
@@ -160,7 +161,10 @@ def from_service_account_info(cls, info: dict, *args, **kwargs):
160161 Returns:
161162 DatabaseAdminAsyncClient: The constructed client.
162163 """
163- return DatabaseAdminClient .from_service_account_info .__func__ (DatabaseAdminAsyncClient , info , * args , ** kwargs ) # type: ignore
164+ sa_info_func = (
165+ DatabaseAdminClient .from_service_account_info .__func__ # type: ignore
166+ )
167+ return sa_info_func (DatabaseAdminAsyncClient , info , * args , ** kwargs )
164168
165169 @classmethod
166170 def from_service_account_file (cls , filename : str , * args , ** kwargs ):
@@ -176,7 +180,10 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
176180 Returns:
177181 DatabaseAdminAsyncClient: The constructed client.
178182 """
179- return DatabaseAdminClient .from_service_account_file .__func__ (DatabaseAdminAsyncClient , filename , * args , ** kwargs ) # type: ignore
183+ sa_file_func = (
184+ DatabaseAdminClient .from_service_account_file .__func__ # type: ignore
185+ )
186+ return sa_file_func (DatabaseAdminAsyncClient , filename , * args , ** kwargs )
180187
181188 from_service_account_json = from_service_account_file
182189
@@ -226,7 +233,7 @@ def transport(self) -> DatabaseAdminTransport:
226233 return self ._client .transport
227234
228235 @property
229- def api_endpoint (self ):
236+ def api_endpoint (self ) -> str :
230237 """Return the API endpoint used by the client instance.
231238
232239 Returns:
@@ -1327,7 +1334,7 @@ async def set_iam_policy(
13271334 # client as shown in:
13281335 # https://googleapis.dev/python/google-api-core/latest/client_options.html
13291336 from google.cloud import spanner_admin_database_v1
1330- from google.iam.v1 import iam_policy_pb2 # type: ignore
1337+ import google.iam.v1.iam_policy_pb2 as iam_policy_pb2 # type: ignore
13311338
13321339 async def sample_set_iam_policy():
13331340 # Create a client
@@ -1474,7 +1481,7 @@ async def get_iam_policy(
14741481 # client as shown in:
14751482 # https://googleapis.dev/python/google-api-core/latest/client_options.html
14761483 from google.cloud import spanner_admin_database_v1
1477- from google.iam.v1 import iam_policy_pb2 # type: ignore
1484+ import google.iam.v1.iam_policy_pb2 as iam_policy_pb2 # type: ignore
14781485
14791486 async def sample_get_iam_policy():
14801487 # Create a client
@@ -1622,7 +1629,7 @@ async def test_iam_permissions(
16221629 # client as shown in:
16231630 # https://googleapis.dev/python/google-api-core/latest/client_options.html
16241631 from google.cloud import spanner_admin_database_v1
1625- from google.iam.v1 import iam_policy_pb2 # type: ignore
1632+ import google.iam.v1.iam_policy_pb2 as iam_policy_pb2 # type: ignore
16261633
16271634 async def sample_test_iam_permissions():
16281635 # Create a client
@@ -3980,7 +3987,7 @@ async def sample_internal_update_graph_operation():
39803987
39813988 async def list_operations (
39823989 self ,
3983- request : Optional [operations_pb2 .ListOperationsRequest ] = None ,
3990+ request : Optional [Union [ operations_pb2 .ListOperationsRequest , dict ] ] = None ,
39843991 * ,
39853992 retry : OptionalRetry = gapic_v1 .method .DEFAULT ,
39863993 timeout : Union [float , object ] = gapic_v1 .method .DEFAULT ,
@@ -4006,8 +4013,12 @@ async def list_operations(
40064013 # Create or coerce a protobuf request object.
40074014 # The request isn't a proto-plus wrapped type,
40084015 # so it must be constructed via keyword expansion.
4009- if isinstance (request , dict ):
4010- request = operations_pb2 .ListOperationsRequest (** request )
4016+ if request is None :
4017+ request_pb = operations_pb2 .ListOperationsRequest ()
4018+ elif isinstance (request , dict ):
4019+ request_pb = operations_pb2 .ListOperationsRequest (** request )
4020+ else :
4021+ request_pb = request
40114022
40124023 # Wrap the RPC method; this adds retry and timeout information,
40134024 # and friendly error handling.
@@ -4016,15 +4027,15 @@ async def list_operations(
40164027 # Certain fields should be provided within the metadata header;
40174028 # add these here.
40184029 metadata = tuple (metadata ) + (
4019- gapic_v1 .routing_header .to_grpc_metadata ((("name" , request .name ),)),
4030+ gapic_v1 .routing_header .to_grpc_metadata ((("name" , request_pb .name ),)),
40204031 )
40214032
40224033 # Validate the universe domain.
40234034 self ._client ._validate_universe_domain ()
40244035
40254036 # Send the request.
40264037 response = await rpc (
4027- request ,
4038+ request_pb ,
40284039 retry = retry ,
40294040 timeout = timeout ,
40304041 metadata = metadata ,
@@ -4035,7 +4046,7 @@ async def list_operations(
40354046
40364047 async def get_operation (
40374048 self ,
4038- request : Optional [operations_pb2 .GetOperationRequest ] = None ,
4049+ request : Optional [Union [ operations_pb2 .GetOperationRequest , dict ] ] = None ,
40394050 * ,
40404051 retry : OptionalRetry = gapic_v1 .method .DEFAULT ,
40414052 timeout : Union [float , object ] = gapic_v1 .method .DEFAULT ,
@@ -4061,8 +4072,12 @@ async def get_operation(
40614072 # Create or coerce a protobuf request object.
40624073 # The request isn't a proto-plus wrapped type,
40634074 # so it must be constructed via keyword expansion.
4064- if isinstance (request , dict ):
4065- request = operations_pb2 .GetOperationRequest (** request )
4075+ if request is None :
4076+ request_pb = operations_pb2 .GetOperationRequest ()
4077+ elif isinstance (request , dict ):
4078+ request_pb = operations_pb2 .GetOperationRequest (** request )
4079+ else :
4080+ request_pb = request
40664081
40674082 # Wrap the RPC method; this adds retry and timeout information,
40684083 # and friendly error handling.
@@ -4071,15 +4086,15 @@ async def get_operation(
40714086 # Certain fields should be provided within the metadata header;
40724087 # add these here.
40734088 metadata = tuple (metadata ) + (
4074- gapic_v1 .routing_header .to_grpc_metadata ((("name" , request .name ),)),
4089+ gapic_v1 .routing_header .to_grpc_metadata ((("name" , request_pb .name ),)),
40754090 )
40764091
40774092 # Validate the universe domain.
40784093 self ._client ._validate_universe_domain ()
40794094
40804095 # Send the request.
40814096 response = await rpc (
4082- request ,
4097+ request_pb ,
40834098 retry = retry ,
40844099 timeout = timeout ,
40854100 metadata = metadata ,
@@ -4090,7 +4105,7 @@ async def get_operation(
40904105
40914106 async def delete_operation (
40924107 self ,
4093- request : Optional [operations_pb2 .DeleteOperationRequest ] = None ,
4108+ request : Optional [Union [ operations_pb2 .DeleteOperationRequest , dict ] ] = None ,
40944109 * ,
40954110 retry : OptionalRetry = gapic_v1 .method .DEFAULT ,
40964111 timeout : Union [float , object ] = gapic_v1 .method .DEFAULT ,
@@ -4120,8 +4135,12 @@ async def delete_operation(
41204135 # Create or coerce a protobuf request object.
41214136 # The request isn't a proto-plus wrapped type,
41224137 # so it must be constructed via keyword expansion.
4123- if isinstance (request , dict ):
4124- request = operations_pb2 .DeleteOperationRequest (** request )
4138+ if request is None :
4139+ request_pb = operations_pb2 .DeleteOperationRequest ()
4140+ elif isinstance (request , dict ):
4141+ request_pb = operations_pb2 .DeleteOperationRequest (** request )
4142+ else :
4143+ request_pb = request
41254144
41264145 # Wrap the RPC method; this adds retry and timeout information,
41274146 # and friendly error handling.
@@ -4130,23 +4149,23 @@ async def delete_operation(
41304149 # Certain fields should be provided within the metadata header;
41314150 # add these here.
41324151 metadata = tuple (metadata ) + (
4133- gapic_v1 .routing_header .to_grpc_metadata ((("name" , request .name ),)),
4152+ gapic_v1 .routing_header .to_grpc_metadata ((("name" , request_pb .name ),)),
41344153 )
41354154
41364155 # Validate the universe domain.
41374156 self ._client ._validate_universe_domain ()
41384157
41394158 # Send the request.
41404159 await rpc (
4141- request ,
4160+ request_pb ,
41424161 retry = retry ,
41434162 timeout = timeout ,
41444163 metadata = metadata ,
41454164 )
41464165
41474166 async def cancel_operation (
41484167 self ,
4149- request : Optional [operations_pb2 .CancelOperationRequest ] = None ,
4168+ request : Optional [Union [ operations_pb2 .CancelOperationRequest , dict ] ] = None ,
41504169 * ,
41514170 retry : OptionalRetry = gapic_v1 .method .DEFAULT ,
41524171 timeout : Union [float , object ] = gapic_v1 .method .DEFAULT ,
@@ -4175,8 +4194,12 @@ async def cancel_operation(
41754194 # Create or coerce a protobuf request object.
41764195 # The request isn't a proto-plus wrapped type,
41774196 # so it must be constructed via keyword expansion.
4178- if isinstance (request , dict ):
4179- request = operations_pb2 .CancelOperationRequest (** request )
4197+ if request is None :
4198+ request_pb = operations_pb2 .CancelOperationRequest ()
4199+ elif isinstance (request , dict ):
4200+ request_pb = operations_pb2 .CancelOperationRequest (** request )
4201+ else :
4202+ request_pb = request
41804203
41814204 # Wrap the RPC method; this adds retry and timeout information,
41824205 # and friendly error handling.
@@ -4185,15 +4208,15 @@ async def cancel_operation(
41854208 # Certain fields should be provided within the metadata header;
41864209 # add these here.
41874210 metadata = tuple (metadata ) + (
4188- gapic_v1 .routing_header .to_grpc_metadata ((("name" , request .name ),)),
4211+ gapic_v1 .routing_header .to_grpc_metadata ((("name" , request_pb .name ),)),
41894212 )
41904213
41914214 # Validate the universe domain.
41924215 self ._client ._validate_universe_domain ()
41934216
41944217 # Send the request.
41954218 await rpc (
4196- request ,
4219+ request_pb ,
41974220 retry = retry ,
41984221 timeout = timeout ,
41994222 metadata = metadata ,
0 commit comments