Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/google/cloud/logging_v2/services/logging_service_v2/transports/grpc_asyncio.py: 47%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

121 statements  

1# -*- coding: utf-8 -*- 

2# Copyright 2025 Google LLC 

3# 

4# Licensed under the Apache License, Version 2.0 (the "License"); 

5# you may not use this file except in compliance with the License. 

6# You may obtain a copy of the License at 

7# 

8# http://www.apache.org/licenses/LICENSE-2.0 

9# 

10# Unless required by applicable law or agreed to in writing, software 

11# distributed under the License is distributed on an "AS IS" BASIS, 

12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

13# See the License for the specific language governing permissions and 

14# limitations under the License. 

15# 

16import inspect 

17import json 

18import pickle 

19import logging as std_logging 

20import warnings 

21from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union 

22 

23from google.api_core import gapic_v1 

24from google.api_core import grpc_helpers_async 

25from google.api_core import exceptions as core_exceptions 

26from google.api_core import retry_async as retries 

27from google.auth import credentials as ga_credentials # type: ignore 

28from google.auth.transport.grpc import SslCredentials # type: ignore 

29from google.protobuf.json_format import MessageToJson 

30import google.protobuf.message 

31 

32import grpc # type: ignore 

33import proto # type: ignore 

34from grpc.experimental import aio # type: ignore 

35 

36from google.cloud.logging_v2.types import logging 

37from google.longrunning import operations_pb2 # type: ignore 

38from google.protobuf import empty_pb2 # type: ignore 

39from .base import LoggingServiceV2Transport, DEFAULT_CLIENT_INFO 

40from .grpc import LoggingServiceV2GrpcTransport 

41 

42try: 

43 from google.api_core import client_logging # type: ignore 

44 

45 CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER 

46except ImportError: # pragma: NO COVER 

47 CLIENT_LOGGING_SUPPORTED = False 

48 

49_LOGGER = std_logging.getLogger(__name__) 

50 

51 

52class _LoggingClientAIOInterceptor( 

53 grpc.aio.UnaryUnaryClientInterceptor 

54): # pragma: NO COVER 

55 async def intercept_unary_unary(self, continuation, client_call_details, request): 

56 logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

57 std_logging.DEBUG 

58 ) 

59 if logging_enabled: # pragma: NO COVER 

60 request_metadata = client_call_details.metadata 

61 if isinstance(request, proto.Message): 

62 request_payload = type(request).to_json(request) 

63 elif isinstance(request, google.protobuf.message.Message): 

64 request_payload = MessageToJson(request) 

65 else: 

66 request_payload = f"{type(request).__name__}: {pickle.dumps(request)}" 

67 

68 request_metadata = { 

69 key: value.decode("utf-8") if isinstance(value, bytes) else value 

70 for key, value in request_metadata 

71 } 

72 grpc_request = { 

73 "payload": request_payload, 

74 "requestMethod": "grpc", 

75 "metadata": dict(request_metadata), 

76 } 

77 _LOGGER.debug( 

78 f"Sending request for {client_call_details.method}", 

79 extra={ 

80 "serviceName": "google.logging.v2.LoggingServiceV2", 

81 "rpcName": str(client_call_details.method), 

82 "request": grpc_request, 

83 "metadata": grpc_request["metadata"], 

84 }, 

85 ) 

86 response = await continuation(client_call_details, request) 

87 if logging_enabled: # pragma: NO COVER 

88 response_metadata = await response.trailing_metadata() 

89 # Convert gRPC metadata `<class 'grpc.aio._metadata.Metadata'>` to list of tuples 

90 metadata = ( 

91 dict([(k, str(v)) for k, v in response_metadata]) 

92 if response_metadata 

93 else None 

94 ) 

95 result = await response 

96 if isinstance(result, proto.Message): 

97 response_payload = type(result).to_json(result) 

98 elif isinstance(result, google.protobuf.message.Message): 

99 response_payload = MessageToJson(result) 

100 else: 

101 response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" 

102 grpc_response = { 

103 "payload": response_payload, 

104 "metadata": metadata, 

105 "status": "OK", 

106 } 

107 _LOGGER.debug( 

108 f"Received response to rpc {client_call_details.method}.", 

109 extra={ 

110 "serviceName": "google.logging.v2.LoggingServiceV2", 

111 "rpcName": str(client_call_details.method), 

112 "response": grpc_response, 

113 "metadata": grpc_response["metadata"], 

114 }, 

115 ) 

116 return response 

117 

118 

119class LoggingServiceV2GrpcAsyncIOTransport(LoggingServiceV2Transport): 

120 """gRPC AsyncIO backend transport for LoggingServiceV2. 

121 

122 Service for ingesting and querying logs. 

123 

124 This class defines the same methods as the primary client, so the 

125 primary client can load the underlying transport implementation 

126 and call it. 

127 

128 It sends protocol buffers over the wire using gRPC (which is built on 

129 top of HTTP/2); the ``grpcio`` package must be installed. 

130 """ 

131 

132 _grpc_channel: aio.Channel 

133 _stubs: Dict[str, Callable] = {} 

134 

135 @classmethod 

136 def create_channel( 

137 cls, 

138 host: str = "logging.googleapis.com", 

139 credentials: Optional[ga_credentials.Credentials] = None, 

140 credentials_file: Optional[str] = None, 

141 scopes: Optional[Sequence[str]] = None, 

142 quota_project_id: Optional[str] = None, 

143 **kwargs, 

144 ) -> aio.Channel: 

145 """Create and return a gRPC AsyncIO channel object. 

146 Args: 

147 host (Optional[str]): The host for the channel to use. 

148 credentials (Optional[~.Credentials]): The 

149 authorization credentials to attach to requests. These 

150 credentials identify this application to the service. If 

151 none are specified, the client will attempt to ascertain 

152 the credentials from the environment. 

153 credentials_file (Optional[str]): Deprecated. A file with credentials that can 

154 be loaded with :func:`google.auth.load_credentials_from_file`. This argument will be 

155 removed in the next major version of this library. 

156 scopes (Optional[Sequence[str]]): A optional list of scopes needed for this 

157 service. These are only used when credentials are not specified and 

158 are passed to :func:`google.auth.default`. 

159 quota_project_id (Optional[str]): An optional project to use for billing 

160 and quota. 

161 kwargs (Optional[dict]): Keyword arguments, which are passed to the 

162 channel creation. 

163 Returns: 

164 aio.Channel: A gRPC AsyncIO channel object. 

165 """ 

166 

167 return grpc_helpers_async.create_channel( 

168 host, 

169 credentials=credentials, 

170 credentials_file=credentials_file, 

171 quota_project_id=quota_project_id, 

172 default_scopes=cls.AUTH_SCOPES, 

173 scopes=scopes, 

174 default_host=cls.DEFAULT_HOST, 

175 **kwargs, 

176 ) 

177 

178 def __init__( 

179 self, 

180 *, 

181 host: str = "logging.googleapis.com", 

182 credentials: Optional[ga_credentials.Credentials] = None, 

183 credentials_file: Optional[str] = None, 

184 scopes: Optional[Sequence[str]] = None, 

185 channel: Optional[Union[aio.Channel, Callable[..., aio.Channel]]] = None, 

186 api_mtls_endpoint: Optional[str] = None, 

187 client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, 

188 ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, 

189 client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, 

190 quota_project_id: Optional[str] = None, 

191 client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, 

192 always_use_jwt_access: Optional[bool] = False, 

193 api_audience: Optional[str] = None, 

194 ) -> None: 

195 """Instantiate the transport. 

196 

197 Args: 

198 host (Optional[str]): 

199 The hostname to connect to (default: 'logging.googleapis.com'). 

200 credentials (Optional[google.auth.credentials.Credentials]): The 

201 authorization credentials to attach to requests. These 

202 credentials identify the application to the service; if none 

203 are specified, the client will attempt to ascertain the 

204 credentials from the environment. 

205 This argument is ignored if a ``channel`` instance is provided. 

206 credentials_file (Optional[str]): Deprecated. A file with credentials that can 

207 be loaded with :func:`google.auth.load_credentials_from_file`. 

208 This argument is ignored if a ``channel`` instance is provided. 

209 This argument will be removed in the next major version of this library. 

210 scopes (Optional[Sequence[str]]): A optional list of scopes needed for this 

211 service. These are only used when credentials are not specified and 

212 are passed to :func:`google.auth.default`. 

213 channel (Optional[Union[aio.Channel, Callable[..., aio.Channel]]]): 

214 A ``Channel`` instance through which to make calls, or a Callable 

215 that constructs and returns one. If set to None, ``self.create_channel`` 

216 is used to create the channel. If a Callable is given, it will be called 

217 with the same arguments as used in ``self.create_channel``. 

218 api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. 

219 If provided, it overrides the ``host`` argument and tries to create 

220 a mutual TLS channel with client SSL credentials from 

221 ``client_cert_source`` or application default SSL credentials. 

222 client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): 

223 Deprecated. A callback to provide client SSL certificate bytes and 

224 private key bytes, both in PEM format. It is ignored if 

225 ``api_mtls_endpoint`` is None. 

226 ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials 

227 for the grpc channel. It is ignored if a ``channel`` instance is provided. 

228 client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): 

229 A callback to provide client certificate bytes and private key bytes, 

230 both in PEM format. It is used to configure a mutual TLS channel. It is 

231 ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided. 

232 quota_project_id (Optional[str]): An optional project to use for billing 

233 and quota. 

234 client_info (google.api_core.gapic_v1.client_info.ClientInfo): 

235 The client info used to send a user-agent string along with 

236 API requests. If ``None``, then default info will be used. 

237 Generally, you only need to set this if you're developing 

238 your own client library. 

239 always_use_jwt_access (Optional[bool]): Whether self signed JWT should 

240 be used for service account credentials. 

241 

242 Raises: 

243 google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport 

244 creation failed for any reason. 

245 google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` 

246 and ``credentials_file`` are passed. 

247 """ 

248 self._grpc_channel = None 

249 self._ssl_channel_credentials = ssl_channel_credentials 

250 self._stubs: Dict[str, Callable] = {} 

251 

252 if api_mtls_endpoint: 

253 warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) 

254 if client_cert_source: 

255 warnings.warn("client_cert_source is deprecated", DeprecationWarning) 

256 

257 if isinstance(channel, aio.Channel): 

258 # Ignore credentials if a channel was passed. 

259 credentials = None 

260 self._ignore_credentials = True 

261 # If a channel was explicitly provided, set it. 

262 self._grpc_channel = channel 

263 self._ssl_channel_credentials = None 

264 else: 

265 if api_mtls_endpoint: 

266 host = api_mtls_endpoint 

267 

268 # Create SSL credentials with client_cert_source or application 

269 # default SSL credentials. 

270 if client_cert_source: 

271 cert, key = client_cert_source() 

272 self._ssl_channel_credentials = grpc.ssl_channel_credentials( 

273 certificate_chain=cert, private_key=key 

274 ) 

275 else: 

276 self._ssl_channel_credentials = SslCredentials().ssl_credentials 

277 

278 else: 

279 if client_cert_source_for_mtls and not ssl_channel_credentials: 

280 cert, key = client_cert_source_for_mtls() 

281 self._ssl_channel_credentials = grpc.ssl_channel_credentials( 

282 certificate_chain=cert, private_key=key 

283 ) 

284 

285 # The base transport sets the host, credentials and scopes 

286 super().__init__( 

287 host=host, 

288 credentials=credentials, 

289 credentials_file=credentials_file, 

290 scopes=scopes, 

291 quota_project_id=quota_project_id, 

292 client_info=client_info, 

293 always_use_jwt_access=always_use_jwt_access, 

294 api_audience=api_audience, 

295 ) 

296 

297 if not self._grpc_channel: 

298 # initialize with the provided callable or the default channel 

299 channel_init = channel or type(self).create_channel 

300 self._grpc_channel = channel_init( 

301 self._host, 

302 # use the credentials which are saved 

303 credentials=self._credentials, 

304 # Set ``credentials_file`` to ``None`` here as 

305 # the credentials that we saved earlier should be used. 

306 credentials_file=None, 

307 scopes=self._scopes, 

308 ssl_credentials=self._ssl_channel_credentials, 

309 quota_project_id=quota_project_id, 

310 options=[ 

311 ("grpc.max_send_message_length", -1), 

312 ("grpc.max_receive_message_length", -1), 

313 ], 

314 ) 

315 

316 self._interceptor = _LoggingClientAIOInterceptor() 

317 self._grpc_channel._unary_unary_interceptors.append(self._interceptor) 

318 self._logged_channel = self._grpc_channel 

319 self._wrap_with_kind = ( 

320 "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters 

321 ) 

322 # Wrap messages. This must be done after self._logged_channel exists 

323 self._prep_wrapped_messages(client_info) 

324 

325 @property 

326 def grpc_channel(self) -> aio.Channel: 

327 """Create the channel designed to connect to this service. 

328 

329 This property caches on the instance; repeated calls return 

330 the same channel. 

331 """ 

332 # Return the channel from cache. 

333 return self._grpc_channel 

334 

335 @property 

336 def delete_log( 

337 self, 

338 ) -> Callable[[logging.DeleteLogRequest], Awaitable[empty_pb2.Empty]]: 

339 r"""Return a callable for the delete log method over gRPC. 

340 

341 Deletes all the log entries in a log for the \_Default Log 

342 Bucket. The log reappears if it receives new entries. Log 

343 entries written shortly before the delete operation might not be 

344 deleted. Entries received after the delete operation with a 

345 timestamp before the operation will be deleted. 

346 

347 Returns: 

348 Callable[[~.DeleteLogRequest], 

349 Awaitable[~.Empty]]: 

350 A function that, when called, will call the underlying RPC 

351 on the server. 

352 """ 

353 # Generate a "stub function" on-the-fly which will actually make 

354 # the request. 

355 # gRPC handles serialization and deserialization, so we just need 

356 # to pass in the functions for each. 

357 if "delete_log" not in self._stubs: 

358 self._stubs["delete_log"] = self._logged_channel.unary_unary( 

359 "/google.logging.v2.LoggingServiceV2/DeleteLog", 

360 request_serializer=logging.DeleteLogRequest.serialize, 

361 response_deserializer=empty_pb2.Empty.FromString, 

362 ) 

363 return self._stubs["delete_log"] 

364 

365 @property 

366 def write_log_entries( 

367 self, 

368 ) -> Callable[ 

369 [logging.WriteLogEntriesRequest], Awaitable[logging.WriteLogEntriesResponse] 

370 ]: 

371 r"""Return a callable for the write log entries method over gRPC. 

372 

373 Writes log entries to Logging. This API method is the 

374 only way to send log entries to Logging. This method is 

375 used, directly or indirectly, by the Logging agent 

376 (fluentd) and all logging libraries configured to use 

377 Logging. A single request may contain log entries for a 

378 maximum of 1000 different resources (projects, 

379 organizations, billing accounts or folders) 

380 

381 Returns: 

382 Callable[[~.WriteLogEntriesRequest], 

383 Awaitable[~.WriteLogEntriesResponse]]: 

384 A function that, when called, will call the underlying RPC 

385 on the server. 

386 """ 

387 # Generate a "stub function" on-the-fly which will actually make 

388 # the request. 

389 # gRPC handles serialization and deserialization, so we just need 

390 # to pass in the functions for each. 

391 if "write_log_entries" not in self._stubs: 

392 self._stubs["write_log_entries"] = self._logged_channel.unary_unary( 

393 "/google.logging.v2.LoggingServiceV2/WriteLogEntries", 

394 request_serializer=logging.WriteLogEntriesRequest.serialize, 

395 response_deserializer=logging.WriteLogEntriesResponse.deserialize, 

396 ) 

397 return self._stubs["write_log_entries"] 

398 

399 @property 

400 def list_log_entries( 

401 self, 

402 ) -> Callable[ 

403 [logging.ListLogEntriesRequest], Awaitable[logging.ListLogEntriesResponse] 

404 ]: 

405 r"""Return a callable for the list log entries method over gRPC. 

406 

407 Lists log entries. Use this method to retrieve log entries that 

408 originated from a project/folder/organization/billing account. 

409 For ways to export log entries, see `Exporting 

410 Logs <https://cloud.google.com/logging/docs/export>`__. 

411 

412 Returns: 

413 Callable[[~.ListLogEntriesRequest], 

414 Awaitable[~.ListLogEntriesResponse]]: 

415 A function that, when called, will call the underlying RPC 

416 on the server. 

417 """ 

418 # Generate a "stub function" on-the-fly which will actually make 

419 # the request. 

420 # gRPC handles serialization and deserialization, so we just need 

421 # to pass in the functions for each. 

422 if "list_log_entries" not in self._stubs: 

423 self._stubs["list_log_entries"] = self._logged_channel.unary_unary( 

424 "/google.logging.v2.LoggingServiceV2/ListLogEntries", 

425 request_serializer=logging.ListLogEntriesRequest.serialize, 

426 response_deserializer=logging.ListLogEntriesResponse.deserialize, 

427 ) 

428 return self._stubs["list_log_entries"] 

429 

430 @property 

431 def list_monitored_resource_descriptors( 

432 self, 

433 ) -> Callable[ 

434 [logging.ListMonitoredResourceDescriptorsRequest], 

435 Awaitable[logging.ListMonitoredResourceDescriptorsResponse], 

436 ]: 

437 r"""Return a callable for the list monitored resource 

438 descriptors method over gRPC. 

439 

440 Lists the descriptors for monitored resource types 

441 used by Logging. 

442 

443 Returns: 

444 Callable[[~.ListMonitoredResourceDescriptorsRequest], 

445 Awaitable[~.ListMonitoredResourceDescriptorsResponse]]: 

446 A function that, when called, will call the underlying RPC 

447 on the server. 

448 """ 

449 # Generate a "stub function" on-the-fly which will actually make 

450 # the request. 

451 # gRPC handles serialization and deserialization, so we just need 

452 # to pass in the functions for each. 

453 if "list_monitored_resource_descriptors" not in self._stubs: 

454 self._stubs[ 

455 "list_monitored_resource_descriptors" 

456 ] = self._logged_channel.unary_unary( 

457 "/google.logging.v2.LoggingServiceV2/ListMonitoredResourceDescriptors", 

458 request_serializer=logging.ListMonitoredResourceDescriptorsRequest.serialize, 

459 response_deserializer=logging.ListMonitoredResourceDescriptorsResponse.deserialize, 

460 ) 

461 return self._stubs["list_monitored_resource_descriptors"] 

462 

463 @property 

464 def list_logs( 

465 self, 

466 ) -> Callable[[logging.ListLogsRequest], Awaitable[logging.ListLogsResponse]]: 

467 r"""Return a callable for the list logs method over gRPC. 

468 

469 Lists the logs in projects, organizations, folders, 

470 or billing accounts. Only logs that have entries are 

471 listed. 

472 

473 Returns: 

474 Callable[[~.ListLogsRequest], 

475 Awaitable[~.ListLogsResponse]]: 

476 A function that, when called, will call the underlying RPC 

477 on the server. 

478 """ 

479 # Generate a "stub function" on-the-fly which will actually make 

480 # the request. 

481 # gRPC handles serialization and deserialization, so we just need 

482 # to pass in the functions for each. 

483 if "list_logs" not in self._stubs: 

484 self._stubs["list_logs"] = self._logged_channel.unary_unary( 

485 "/google.logging.v2.LoggingServiceV2/ListLogs", 

486 request_serializer=logging.ListLogsRequest.serialize, 

487 response_deserializer=logging.ListLogsResponse.deserialize, 

488 ) 

489 return self._stubs["list_logs"] 

490 

491 @property 

492 def tail_log_entries( 

493 self, 

494 ) -> Callable[ 

495 [logging.TailLogEntriesRequest], Awaitable[logging.TailLogEntriesResponse] 

496 ]: 

497 r"""Return a callable for the tail log entries method over gRPC. 

498 

499 Streaming read of log entries as they are ingested. 

500 Until the stream is terminated, it will continue reading 

501 logs. 

502 

503 Returns: 

504 Callable[[~.TailLogEntriesRequest], 

505 Awaitable[~.TailLogEntriesResponse]]: 

506 A function that, when called, will call the underlying RPC 

507 on the server. 

508 """ 

509 # Generate a "stub function" on-the-fly which will actually make 

510 # the request. 

511 # gRPC handles serialization and deserialization, so we just need 

512 # to pass in the functions for each. 

513 if "tail_log_entries" not in self._stubs: 

514 self._stubs["tail_log_entries"] = self._logged_channel.stream_stream( 

515 "/google.logging.v2.LoggingServiceV2/TailLogEntries", 

516 request_serializer=logging.TailLogEntriesRequest.serialize, 

517 response_deserializer=logging.TailLogEntriesResponse.deserialize, 

518 ) 

519 return self._stubs["tail_log_entries"] 

520 

521 def _prep_wrapped_messages(self, client_info): 

522 """Precompute the wrapped methods, overriding the base class method to use async wrappers.""" 

523 self._wrapped_methods = { 

524 self.delete_log: self._wrap_method( 

525 self.delete_log, 

526 default_retry=retries.AsyncRetry( 

527 initial=0.1, 

528 maximum=60.0, 

529 multiplier=1.3, 

530 predicate=retries.if_exception_type( 

531 core_exceptions.DeadlineExceeded, 

532 core_exceptions.InternalServerError, 

533 core_exceptions.ServiceUnavailable, 

534 ), 

535 deadline=60.0, 

536 ), 

537 default_timeout=60.0, 

538 client_info=client_info, 

539 ), 

540 self.write_log_entries: self._wrap_method( 

541 self.write_log_entries, 

542 default_retry=retries.AsyncRetry( 

543 initial=0.1, 

544 maximum=60.0, 

545 multiplier=1.3, 

546 predicate=retries.if_exception_type( 

547 core_exceptions.DeadlineExceeded, 

548 core_exceptions.InternalServerError, 

549 core_exceptions.ServiceUnavailable, 

550 ), 

551 deadline=60.0, 

552 ), 

553 default_timeout=60.0, 

554 client_info=client_info, 

555 ), 

556 self.list_log_entries: self._wrap_method( 

557 self.list_log_entries, 

558 default_retry=retries.AsyncRetry( 

559 initial=0.1, 

560 maximum=60.0, 

561 multiplier=1.3, 

562 predicate=retries.if_exception_type( 

563 core_exceptions.DeadlineExceeded, 

564 core_exceptions.InternalServerError, 

565 core_exceptions.ServiceUnavailable, 

566 ), 

567 deadline=60.0, 

568 ), 

569 default_timeout=60.0, 

570 client_info=client_info, 

571 ), 

572 self.list_monitored_resource_descriptors: self._wrap_method( 

573 self.list_monitored_resource_descriptors, 

574 default_retry=retries.AsyncRetry( 

575 initial=0.1, 

576 maximum=60.0, 

577 multiplier=1.3, 

578 predicate=retries.if_exception_type( 

579 core_exceptions.DeadlineExceeded, 

580 core_exceptions.InternalServerError, 

581 core_exceptions.ServiceUnavailable, 

582 ), 

583 deadline=60.0, 

584 ), 

585 default_timeout=60.0, 

586 client_info=client_info, 

587 ), 

588 self.list_logs: self._wrap_method( 

589 self.list_logs, 

590 default_retry=retries.AsyncRetry( 

591 initial=0.1, 

592 maximum=60.0, 

593 multiplier=1.3, 

594 predicate=retries.if_exception_type( 

595 core_exceptions.DeadlineExceeded, 

596 core_exceptions.InternalServerError, 

597 core_exceptions.ServiceUnavailable, 

598 ), 

599 deadline=60.0, 

600 ), 

601 default_timeout=60.0, 

602 client_info=client_info, 

603 ), 

604 self.tail_log_entries: self._wrap_method( 

605 self.tail_log_entries, 

606 default_retry=retries.AsyncRetry( 

607 initial=0.1, 

608 maximum=60.0, 

609 multiplier=1.3, 

610 predicate=retries.if_exception_type( 

611 core_exceptions.DeadlineExceeded, 

612 core_exceptions.InternalServerError, 

613 core_exceptions.ServiceUnavailable, 

614 ), 

615 deadline=3600.0, 

616 ), 

617 default_timeout=3600.0, 

618 client_info=client_info, 

619 ), 

620 self.cancel_operation: self._wrap_method( 

621 self.cancel_operation, 

622 default_timeout=None, 

623 client_info=client_info, 

624 ), 

625 self.get_operation: self._wrap_method( 

626 self.get_operation, 

627 default_timeout=None, 

628 client_info=client_info, 

629 ), 

630 self.list_operations: self._wrap_method( 

631 self.list_operations, 

632 default_timeout=None, 

633 client_info=client_info, 

634 ), 

635 } 

636 

637 def _wrap_method(self, func, *args, **kwargs): 

638 if self._wrap_with_kind: # pragma: NO COVER 

639 kwargs["kind"] = self.kind 

640 return gapic_v1.method_async.wrap_method(func, *args, **kwargs) 

641 

642 def close(self): 

643 return self._logged_channel.close() 

644 

645 @property 

646 def kind(self) -> str: 

647 return "grpc_asyncio" 

648 

649 @property 

650 def cancel_operation( 

651 self, 

652 ) -> Callable[[operations_pb2.CancelOperationRequest], None]: 

653 r"""Return a callable for the cancel_operation method over gRPC.""" 

654 # Generate a "stub function" on-the-fly which will actually make 

655 # the request. 

656 # gRPC handles serialization and deserialization, so we just need 

657 # to pass in the functions for each. 

658 if "cancel_operation" not in self._stubs: 

659 self._stubs["cancel_operation"] = self._logged_channel.unary_unary( 

660 "/google.longrunning.Operations/CancelOperation", 

661 request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, 

662 response_deserializer=None, 

663 ) 

664 return self._stubs["cancel_operation"] 

665 

666 @property 

667 def get_operation( 

668 self, 

669 ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]: 

670 r"""Return a callable for the get_operation method over gRPC.""" 

671 # Generate a "stub function" on-the-fly which will actually make 

672 # the request. 

673 # gRPC handles serialization and deserialization, so we just need 

674 # to pass in the functions for each. 

675 if "get_operation" not in self._stubs: 

676 self._stubs["get_operation"] = self._logged_channel.unary_unary( 

677 "/google.longrunning.Operations/GetOperation", 

678 request_serializer=operations_pb2.GetOperationRequest.SerializeToString, 

679 response_deserializer=operations_pb2.Operation.FromString, 

680 ) 

681 return self._stubs["get_operation"] 

682 

683 @property 

684 def list_operations( 

685 self, 

686 ) -> Callable[ 

687 [operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse 

688 ]: 

689 r"""Return a callable for the list_operations method over gRPC.""" 

690 # Generate a "stub function" on-the-fly which will actually make 

691 # the request. 

692 # gRPC handles serialization and deserialization, so we just need 

693 # to pass in the functions for each. 

694 if "list_operations" not in self._stubs: 

695 self._stubs["list_operations"] = self._logged_channel.unary_unary( 

696 "/google.longrunning.Operations/ListOperations", 

697 request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, 

698 response_deserializer=operations_pb2.ListOperationsResponse.FromString, 

699 ) 

700 return self._stubs["list_operations"] 

701 

702 

703__all__ = ("LoggingServiceV2GrpcAsyncIOTransport",)