Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/google/cloud/logging_v2/services/config_service_v2/transports/grpc_asyncio.py: 42%

187 statements  

« prev     ^ index     » next       coverage.py v7.2.2, created at 2023-03-26 07:30 +0000

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

2# Copyright 2022 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 warnings 

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

18 

19from google.api_core import gapic_v1 

20from google.api_core import grpc_helpers_async 

21from google.api_core import operations_v1 

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

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

24 

25import grpc # type: ignore 

26from grpc.experimental import aio # type: ignore 

27 

28from google.cloud.logging_v2.types import logging_config 

29from google.longrunning import operations_pb2 # type: ignore 

30from google.protobuf import empty_pb2 # type: ignore 

31from .base import ConfigServiceV2Transport, DEFAULT_CLIENT_INFO 

32from .grpc import ConfigServiceV2GrpcTransport 

33 

34 

35class ConfigServiceV2GrpcAsyncIOTransport(ConfigServiceV2Transport): 

36 """gRPC AsyncIO backend transport for ConfigServiceV2. 

37 

38 Service for configuring sinks used to route log entries. 

39 

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

41 primary client can load the underlying transport implementation 

42 and call it. 

43 

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

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

46 """ 

47 

48 _grpc_channel: aio.Channel 

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

50 

51 @classmethod 

52 def create_channel( 

53 cls, 

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

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

56 credentials_file: Optional[str] = None, 

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

58 quota_project_id: Optional[str] = None, 

59 **kwargs, 

60 ) -> aio.Channel: 

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

62 Args: 

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

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

65 authorization credentials to attach to requests. These 

66 credentials identify this application to the service. If 

67 none are specified, the client will attempt to ascertain 

68 the credentials from the environment. 

69 credentials_file (Optional[str]): A file with credentials that can 

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

71 This argument is ignored if ``channel`` is provided. 

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

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

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

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

76 and quota. 

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

78 channel creation. 

79 Returns: 

80 aio.Channel: A gRPC AsyncIO channel object. 

81 """ 

82 

83 return grpc_helpers_async.create_channel( 

84 host, 

85 credentials=credentials, 

86 credentials_file=credentials_file, 

87 quota_project_id=quota_project_id, 

88 default_scopes=cls.AUTH_SCOPES, 

89 scopes=scopes, 

90 default_host=cls.DEFAULT_HOST, 

91 **kwargs, 

92 ) 

93 

94 def __init__( 

95 self, 

96 *, 

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

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

99 credentials_file: Optional[str] = None, 

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

101 channel: Optional[aio.Channel] = None, 

102 api_mtls_endpoint: Optional[str] = None, 

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

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

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

106 quota_project_id: Optional[str] = None, 

107 client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, 

108 always_use_jwt_access: Optional[bool] = False, 

109 api_audience: Optional[str] = None, 

110 ) -> None: 

111 """Instantiate the transport. 

112 

113 Args: 

114 host (Optional[str]): 

115 The hostname to connect to. 

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

117 authorization credentials to attach to requests. These 

118 credentials identify the application to the service; if none 

119 are specified, the client will attempt to ascertain the 

120 credentials from the environment. 

121 This argument is ignored if ``channel`` is provided. 

122 credentials_file (Optional[str]): A file with credentials that can 

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

124 This argument is ignored if ``channel`` is provided. 

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

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

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

128 channel (Optional[aio.Channel]): A ``Channel`` instance through 

129 which to make calls. 

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

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

132 a mutual TLS channel with client SSL credentials from 

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

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

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

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

137 ``api_mtls_endpoint`` is None. 

138 ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials 

139 for the grpc channel. It is ignored if ``channel`` is provided. 

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

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

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

143 ignored if ``channel`` or ``ssl_channel_credentials`` is provided. 

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

145 and quota. 

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

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

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

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

150 your own client library. 

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

152 be used for service account credentials. 

153 

154 Raises: 

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

156 creation failed for any reason. 

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

158 and ``credentials_file`` are passed. 

159 """ 

160 self._grpc_channel = None 

161 self._ssl_channel_credentials = ssl_channel_credentials 

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

163 self._operations_client: Optional[operations_v1.OperationsAsyncClient] = None 

164 

165 if api_mtls_endpoint: 

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

167 if client_cert_source: 

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

169 

170 if channel: 

171 # Ignore credentials if a channel was passed. 

172 credentials = False 

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

174 self._grpc_channel = channel 

175 self._ssl_channel_credentials = None 

176 else: 

177 if api_mtls_endpoint: 

178 host = api_mtls_endpoint 

179 

180 # Create SSL credentials with client_cert_source or application 

181 # default SSL credentials. 

182 if client_cert_source: 

183 cert, key = client_cert_source() 

184 self._ssl_channel_credentials = grpc.ssl_channel_credentials( 

185 certificate_chain=cert, private_key=key 

186 ) 

187 else: 

188 self._ssl_channel_credentials = SslCredentials().ssl_credentials 

189 

190 else: 

191 if client_cert_source_for_mtls and not ssl_channel_credentials: 

192 cert, key = client_cert_source_for_mtls() 

193 self._ssl_channel_credentials = grpc.ssl_channel_credentials( 

194 certificate_chain=cert, private_key=key 

195 ) 

196 

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

198 super().__init__( 

199 host=host, 

200 credentials=credentials, 

201 credentials_file=credentials_file, 

202 scopes=scopes, 

203 quota_project_id=quota_project_id, 

204 client_info=client_info, 

205 always_use_jwt_access=always_use_jwt_access, 

206 api_audience=api_audience, 

207 ) 

208 

209 if not self._grpc_channel: 

210 self._grpc_channel = type(self).create_channel( 

211 self._host, 

212 # use the credentials which are saved 

213 credentials=self._credentials, 

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

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

216 credentials_file=None, 

217 scopes=self._scopes, 

218 ssl_credentials=self._ssl_channel_credentials, 

219 quota_project_id=quota_project_id, 

220 options=[ 

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

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

223 ], 

224 ) 

225 

226 # Wrap messages. This must be done after self._grpc_channel exists 

227 self._prep_wrapped_messages(client_info) 

228 

229 @property 

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

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

232 

233 This property caches on the instance; repeated calls return 

234 the same channel. 

235 """ 

236 # Return the channel from cache. 

237 return self._grpc_channel 

238 

239 @property 

240 def operations_client(self) -> operations_v1.OperationsAsyncClient: 

241 """Create the client designed to process long-running operations. 

242 

243 This property caches on the instance; repeated calls return the same 

244 client. 

245 """ 

246 # Quick check: Only create a new client if we do not already have one. 

247 if self._operations_client is None: 

248 self._operations_client = operations_v1.OperationsAsyncClient( 

249 self.grpc_channel 

250 ) 

251 

252 # Return the client from cache. 

253 return self._operations_client 

254 

255 @property 

256 def list_buckets( 

257 self, 

258 ) -> Callable[ 

259 [logging_config.ListBucketsRequest], 

260 Awaitable[logging_config.ListBucketsResponse], 

261 ]: 

262 r"""Return a callable for the list buckets method over gRPC. 

263 

264 Lists log buckets. 

265 

266 Returns: 

267 Callable[[~.ListBucketsRequest], 

268 Awaitable[~.ListBucketsResponse]]: 

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

270 on the server. 

271 """ 

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

273 # the request. 

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

275 # to pass in the functions for each. 

276 if "list_buckets" not in self._stubs: 

277 self._stubs["list_buckets"] = self.grpc_channel.unary_unary( 

278 "/google.logging.v2.ConfigServiceV2/ListBuckets", 

279 request_serializer=logging_config.ListBucketsRequest.serialize, 

280 response_deserializer=logging_config.ListBucketsResponse.deserialize, 

281 ) 

282 return self._stubs["list_buckets"] 

283 

284 @property 

285 def get_bucket( 

286 self, 

287 ) -> Callable[ 

288 [logging_config.GetBucketRequest], Awaitable[logging_config.LogBucket] 

289 ]: 

290 r"""Return a callable for the get bucket method over gRPC. 

291 

292 Gets a log bucket. 

293 

294 Returns: 

295 Callable[[~.GetBucketRequest], 

296 Awaitable[~.LogBucket]]: 

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

298 on the server. 

299 """ 

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

301 # the request. 

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

303 # to pass in the functions for each. 

304 if "get_bucket" not in self._stubs: 

305 self._stubs["get_bucket"] = self.grpc_channel.unary_unary( 

306 "/google.logging.v2.ConfigServiceV2/GetBucket", 

307 request_serializer=logging_config.GetBucketRequest.serialize, 

308 response_deserializer=logging_config.LogBucket.deserialize, 

309 ) 

310 return self._stubs["get_bucket"] 

311 

312 @property 

313 def create_bucket( 

314 self, 

315 ) -> Callable[ 

316 [logging_config.CreateBucketRequest], Awaitable[logging_config.LogBucket] 

317 ]: 

318 r"""Return a callable for the create bucket method over gRPC. 

319 

320 Creates a log bucket that can be used to store log 

321 entries. After a bucket has been created, the bucket's 

322 location cannot be changed. 

323 

324 Returns: 

325 Callable[[~.CreateBucketRequest], 

326 Awaitable[~.LogBucket]]: 

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

328 on the server. 

329 """ 

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

331 # the request. 

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

333 # to pass in the functions for each. 

334 if "create_bucket" not in self._stubs: 

335 self._stubs["create_bucket"] = self.grpc_channel.unary_unary( 

336 "/google.logging.v2.ConfigServiceV2/CreateBucket", 

337 request_serializer=logging_config.CreateBucketRequest.serialize, 

338 response_deserializer=logging_config.LogBucket.deserialize, 

339 ) 

340 return self._stubs["create_bucket"] 

341 

342 @property 

343 def update_bucket( 

344 self, 

345 ) -> Callable[ 

346 [logging_config.UpdateBucketRequest], Awaitable[logging_config.LogBucket] 

347 ]: 

348 r"""Return a callable for the update bucket method over gRPC. 

349 

350 Updates a log bucket. This method replaces the following fields 

351 in the existing bucket with values from the new bucket: 

352 ``retention_period`` 

353 

354 If the retention period is decreased and the bucket is locked, 

355 ``FAILED_PRECONDITION`` will be returned. 

356 

357 If the bucket has a ``lifecycle_state`` of ``DELETE_REQUESTED``, 

358 then ``FAILED_PRECONDITION`` will be returned. 

359 

360 After a bucket has been created, the bucket's location cannot be 

361 changed. 

362 

363 Returns: 

364 Callable[[~.UpdateBucketRequest], 

365 Awaitable[~.LogBucket]]: 

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

367 on the server. 

368 """ 

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

370 # the request. 

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

372 # to pass in the functions for each. 

373 if "update_bucket" not in self._stubs: 

374 self._stubs["update_bucket"] = self.grpc_channel.unary_unary( 

375 "/google.logging.v2.ConfigServiceV2/UpdateBucket", 

376 request_serializer=logging_config.UpdateBucketRequest.serialize, 

377 response_deserializer=logging_config.LogBucket.deserialize, 

378 ) 

379 return self._stubs["update_bucket"] 

380 

381 @property 

382 def delete_bucket( 

383 self, 

384 ) -> Callable[[logging_config.DeleteBucketRequest], Awaitable[empty_pb2.Empty]]: 

385 r"""Return a callable for the delete bucket method over gRPC. 

386 

387 Deletes a log bucket. 

388 

389 Changes the bucket's ``lifecycle_state`` to the 

390 ``DELETE_REQUESTED`` state. After 7 days, the bucket will be 

391 purged and all log entries in the bucket will be permanently 

392 deleted. 

393 

394 Returns: 

395 Callable[[~.DeleteBucketRequest], 

396 Awaitable[~.Empty]]: 

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

398 on the server. 

399 """ 

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

401 # the request. 

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

403 # to pass in the functions for each. 

404 if "delete_bucket" not in self._stubs: 

405 self._stubs["delete_bucket"] = self.grpc_channel.unary_unary( 

406 "/google.logging.v2.ConfigServiceV2/DeleteBucket", 

407 request_serializer=logging_config.DeleteBucketRequest.serialize, 

408 response_deserializer=empty_pb2.Empty.FromString, 

409 ) 

410 return self._stubs["delete_bucket"] 

411 

412 @property 

413 def undelete_bucket( 

414 self, 

415 ) -> Callable[[logging_config.UndeleteBucketRequest], Awaitable[empty_pb2.Empty]]: 

416 r"""Return a callable for the undelete bucket method over gRPC. 

417 

418 Undeletes a log bucket. A bucket that has been 

419 deleted can be undeleted within the grace period of 7 

420 days. 

421 

422 Returns: 

423 Callable[[~.UndeleteBucketRequest], 

424 Awaitable[~.Empty]]: 

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

426 on the server. 

427 """ 

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

429 # the request. 

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

431 # to pass in the functions for each. 

432 if "undelete_bucket" not in self._stubs: 

433 self._stubs["undelete_bucket"] = self.grpc_channel.unary_unary( 

434 "/google.logging.v2.ConfigServiceV2/UndeleteBucket", 

435 request_serializer=logging_config.UndeleteBucketRequest.serialize, 

436 response_deserializer=empty_pb2.Empty.FromString, 

437 ) 

438 return self._stubs["undelete_bucket"] 

439 

440 @property 

441 def list_views( 

442 self, 

443 ) -> Callable[ 

444 [logging_config.ListViewsRequest], Awaitable[logging_config.ListViewsResponse] 

445 ]: 

446 r"""Return a callable for the list views method over gRPC. 

447 

448 Lists views on a log bucket. 

449 

450 Returns: 

451 Callable[[~.ListViewsRequest], 

452 Awaitable[~.ListViewsResponse]]: 

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

454 on the server. 

455 """ 

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

457 # the request. 

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

459 # to pass in the functions for each. 

460 if "list_views" not in self._stubs: 

461 self._stubs["list_views"] = self.grpc_channel.unary_unary( 

462 "/google.logging.v2.ConfigServiceV2/ListViews", 

463 request_serializer=logging_config.ListViewsRequest.serialize, 

464 response_deserializer=logging_config.ListViewsResponse.deserialize, 

465 ) 

466 return self._stubs["list_views"] 

467 

468 @property 

469 def get_view( 

470 self, 

471 ) -> Callable[[logging_config.GetViewRequest], Awaitable[logging_config.LogView]]: 

472 r"""Return a callable for the get view method over gRPC. 

473 

474 Gets a view on a log bucket.. 

475 

476 Returns: 

477 Callable[[~.GetViewRequest], 

478 Awaitable[~.LogView]]: 

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

480 on the server. 

481 """ 

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

483 # the request. 

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

485 # to pass in the functions for each. 

486 if "get_view" not in self._stubs: 

487 self._stubs["get_view"] = self.grpc_channel.unary_unary( 

488 "/google.logging.v2.ConfigServiceV2/GetView", 

489 request_serializer=logging_config.GetViewRequest.serialize, 

490 response_deserializer=logging_config.LogView.deserialize, 

491 ) 

492 return self._stubs["get_view"] 

493 

494 @property 

495 def create_view( 

496 self, 

497 ) -> Callable[ 

498 [logging_config.CreateViewRequest], Awaitable[logging_config.LogView] 

499 ]: 

500 r"""Return a callable for the create view method over gRPC. 

501 

502 Creates a view over log entries in a log bucket. A 

503 bucket may contain a maximum of 30 views. 

504 

505 Returns: 

506 Callable[[~.CreateViewRequest], 

507 Awaitable[~.LogView]]: 

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

509 on the server. 

510 """ 

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

512 # the request. 

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

514 # to pass in the functions for each. 

515 if "create_view" not in self._stubs: 

516 self._stubs["create_view"] = self.grpc_channel.unary_unary( 

517 "/google.logging.v2.ConfigServiceV2/CreateView", 

518 request_serializer=logging_config.CreateViewRequest.serialize, 

519 response_deserializer=logging_config.LogView.deserialize, 

520 ) 

521 return self._stubs["create_view"] 

522 

523 @property 

524 def update_view( 

525 self, 

526 ) -> Callable[ 

527 [logging_config.UpdateViewRequest], Awaitable[logging_config.LogView] 

528 ]: 

529 r"""Return a callable for the update view method over gRPC. 

530 

531 Updates a view on a log bucket. This method replaces the 

532 following fields in the existing view with values from the new 

533 view: ``filter``. If an ``UNAVAILABLE`` error is returned, this 

534 indicates that system is not in a state where it can update the 

535 view. If this occurs, please try again in a few minutes. 

536 

537 Returns: 

538 Callable[[~.UpdateViewRequest], 

539 Awaitable[~.LogView]]: 

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

541 on the server. 

542 """ 

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

544 # the request. 

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

546 # to pass in the functions for each. 

547 if "update_view" not in self._stubs: 

548 self._stubs["update_view"] = self.grpc_channel.unary_unary( 

549 "/google.logging.v2.ConfigServiceV2/UpdateView", 

550 request_serializer=logging_config.UpdateViewRequest.serialize, 

551 response_deserializer=logging_config.LogView.deserialize, 

552 ) 

553 return self._stubs["update_view"] 

554 

555 @property 

556 def delete_view( 

557 self, 

558 ) -> Callable[[logging_config.DeleteViewRequest], Awaitable[empty_pb2.Empty]]: 

559 r"""Return a callable for the delete view method over gRPC. 

560 

561 Deletes a view on a log bucket. If an ``UNAVAILABLE`` error is 

562 returned, this indicates that system is not in a state where it 

563 can delete the view. If this occurs, please try again in a few 

564 minutes. 

565 

566 Returns: 

567 Callable[[~.DeleteViewRequest], 

568 Awaitable[~.Empty]]: 

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

570 on the server. 

571 """ 

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

573 # the request. 

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

575 # to pass in the functions for each. 

576 if "delete_view" not in self._stubs: 

577 self._stubs["delete_view"] = self.grpc_channel.unary_unary( 

578 "/google.logging.v2.ConfigServiceV2/DeleteView", 

579 request_serializer=logging_config.DeleteViewRequest.serialize, 

580 response_deserializer=empty_pb2.Empty.FromString, 

581 ) 

582 return self._stubs["delete_view"] 

583 

584 @property 

585 def list_sinks( 

586 self, 

587 ) -> Callable[ 

588 [logging_config.ListSinksRequest], Awaitable[logging_config.ListSinksResponse] 

589 ]: 

590 r"""Return a callable for the list sinks method over gRPC. 

591 

592 Lists sinks. 

593 

594 Returns: 

595 Callable[[~.ListSinksRequest], 

596 Awaitable[~.ListSinksResponse]]: 

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

598 on the server. 

599 """ 

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

601 # the request. 

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

603 # to pass in the functions for each. 

604 if "list_sinks" not in self._stubs: 

605 self._stubs["list_sinks"] = self.grpc_channel.unary_unary( 

606 "/google.logging.v2.ConfigServiceV2/ListSinks", 

607 request_serializer=logging_config.ListSinksRequest.serialize, 

608 response_deserializer=logging_config.ListSinksResponse.deserialize, 

609 ) 

610 return self._stubs["list_sinks"] 

611 

612 @property 

613 def get_sink( 

614 self, 

615 ) -> Callable[[logging_config.GetSinkRequest], Awaitable[logging_config.LogSink]]: 

616 r"""Return a callable for the get sink method over gRPC. 

617 

618 Gets a sink. 

619 

620 Returns: 

621 Callable[[~.GetSinkRequest], 

622 Awaitable[~.LogSink]]: 

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

624 on the server. 

625 """ 

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

627 # the request. 

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

629 # to pass in the functions for each. 

630 if "get_sink" not in self._stubs: 

631 self._stubs["get_sink"] = self.grpc_channel.unary_unary( 

632 "/google.logging.v2.ConfigServiceV2/GetSink", 

633 request_serializer=logging_config.GetSinkRequest.serialize, 

634 response_deserializer=logging_config.LogSink.deserialize, 

635 ) 

636 return self._stubs["get_sink"] 

637 

638 @property 

639 def create_sink( 

640 self, 

641 ) -> Callable[ 

642 [logging_config.CreateSinkRequest], Awaitable[logging_config.LogSink] 

643 ]: 

644 r"""Return a callable for the create sink method over gRPC. 

645 

646 Creates a sink that exports specified log entries to a 

647 destination. The export of newly-ingested log entries begins 

648 immediately, unless the sink's ``writer_identity`` is not 

649 permitted to write to the destination. A sink can export log 

650 entries only from the resource owning the sink. 

651 

652 Returns: 

653 Callable[[~.CreateSinkRequest], 

654 Awaitable[~.LogSink]]: 

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

656 on the server. 

657 """ 

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

659 # the request. 

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

661 # to pass in the functions for each. 

662 if "create_sink" not in self._stubs: 

663 self._stubs["create_sink"] = self.grpc_channel.unary_unary( 

664 "/google.logging.v2.ConfigServiceV2/CreateSink", 

665 request_serializer=logging_config.CreateSinkRequest.serialize, 

666 response_deserializer=logging_config.LogSink.deserialize, 

667 ) 

668 return self._stubs["create_sink"] 

669 

670 @property 

671 def update_sink( 

672 self, 

673 ) -> Callable[ 

674 [logging_config.UpdateSinkRequest], Awaitable[logging_config.LogSink] 

675 ]: 

676 r"""Return a callable for the update sink method over gRPC. 

677 

678 Updates a sink. This method replaces the following fields in the 

679 existing sink with values from the new sink: ``destination``, 

680 and ``filter``. 

681 

682 The updated sink might also have a new ``writer_identity``; see 

683 the ``unique_writer_identity`` field. 

684 

685 Returns: 

686 Callable[[~.UpdateSinkRequest], 

687 Awaitable[~.LogSink]]: 

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

689 on the server. 

690 """ 

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

692 # the request. 

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

694 # to pass in the functions for each. 

695 if "update_sink" not in self._stubs: 

696 self._stubs["update_sink"] = self.grpc_channel.unary_unary( 

697 "/google.logging.v2.ConfigServiceV2/UpdateSink", 

698 request_serializer=logging_config.UpdateSinkRequest.serialize, 

699 response_deserializer=logging_config.LogSink.deserialize, 

700 ) 

701 return self._stubs["update_sink"] 

702 

703 @property 

704 def delete_sink( 

705 self, 

706 ) -> Callable[[logging_config.DeleteSinkRequest], Awaitable[empty_pb2.Empty]]: 

707 r"""Return a callable for the delete sink method over gRPC. 

708 

709 Deletes a sink. If the sink has a unique ``writer_identity``, 

710 then that service account is also deleted. 

711 

712 Returns: 

713 Callable[[~.DeleteSinkRequest], 

714 Awaitable[~.Empty]]: 

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

716 on the server. 

717 """ 

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

719 # the request. 

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

721 # to pass in the functions for each. 

722 if "delete_sink" not in self._stubs: 

723 self._stubs["delete_sink"] = self.grpc_channel.unary_unary( 

724 "/google.logging.v2.ConfigServiceV2/DeleteSink", 

725 request_serializer=logging_config.DeleteSinkRequest.serialize, 

726 response_deserializer=empty_pb2.Empty.FromString, 

727 ) 

728 return self._stubs["delete_sink"] 

729 

730 @property 

731 def list_exclusions( 

732 self, 

733 ) -> Callable[ 

734 [logging_config.ListExclusionsRequest], 

735 Awaitable[logging_config.ListExclusionsResponse], 

736 ]: 

737 r"""Return a callable for the list exclusions method over gRPC. 

738 

739 Lists all the exclusions on the \_Default sink in a parent 

740 resource. 

741 

742 Returns: 

743 Callable[[~.ListExclusionsRequest], 

744 Awaitable[~.ListExclusionsResponse]]: 

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

746 on the server. 

747 """ 

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

749 # the request. 

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

751 # to pass in the functions for each. 

752 if "list_exclusions" not in self._stubs: 

753 self._stubs["list_exclusions"] = self.grpc_channel.unary_unary( 

754 "/google.logging.v2.ConfigServiceV2/ListExclusions", 

755 request_serializer=logging_config.ListExclusionsRequest.serialize, 

756 response_deserializer=logging_config.ListExclusionsResponse.deserialize, 

757 ) 

758 return self._stubs["list_exclusions"] 

759 

760 @property 

761 def get_exclusion( 

762 self, 

763 ) -> Callable[ 

764 [logging_config.GetExclusionRequest], Awaitable[logging_config.LogExclusion] 

765 ]: 

766 r"""Return a callable for the get exclusion method over gRPC. 

767 

768 Gets the description of an exclusion in the \_Default sink. 

769 

770 Returns: 

771 Callable[[~.GetExclusionRequest], 

772 Awaitable[~.LogExclusion]]: 

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

774 on the server. 

775 """ 

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

777 # the request. 

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

779 # to pass in the functions for each. 

780 if "get_exclusion" not in self._stubs: 

781 self._stubs["get_exclusion"] = self.grpc_channel.unary_unary( 

782 "/google.logging.v2.ConfigServiceV2/GetExclusion", 

783 request_serializer=logging_config.GetExclusionRequest.serialize, 

784 response_deserializer=logging_config.LogExclusion.deserialize, 

785 ) 

786 return self._stubs["get_exclusion"] 

787 

788 @property 

789 def create_exclusion( 

790 self, 

791 ) -> Callable[ 

792 [logging_config.CreateExclusionRequest], Awaitable[logging_config.LogExclusion] 

793 ]: 

794 r"""Return a callable for the create exclusion method over gRPC. 

795 

796 Creates a new exclusion in the \_Default sink in a specified 

797 parent resource. Only log entries belonging to that resource can 

798 be excluded. You can have up to 10 exclusions in a resource. 

799 

800 Returns: 

801 Callable[[~.CreateExclusionRequest], 

802 Awaitable[~.LogExclusion]]: 

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

804 on the server. 

805 """ 

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

807 # the request. 

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

809 # to pass in the functions for each. 

810 if "create_exclusion" not in self._stubs: 

811 self._stubs["create_exclusion"] = self.grpc_channel.unary_unary( 

812 "/google.logging.v2.ConfigServiceV2/CreateExclusion", 

813 request_serializer=logging_config.CreateExclusionRequest.serialize, 

814 response_deserializer=logging_config.LogExclusion.deserialize, 

815 ) 

816 return self._stubs["create_exclusion"] 

817 

818 @property 

819 def update_exclusion( 

820 self, 

821 ) -> Callable[ 

822 [logging_config.UpdateExclusionRequest], Awaitable[logging_config.LogExclusion] 

823 ]: 

824 r"""Return a callable for the update exclusion method over gRPC. 

825 

826 Changes one or more properties of an existing exclusion in the 

827 \_Default sink. 

828 

829 Returns: 

830 Callable[[~.UpdateExclusionRequest], 

831 Awaitable[~.LogExclusion]]: 

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

833 on the server. 

834 """ 

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

836 # the request. 

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

838 # to pass in the functions for each. 

839 if "update_exclusion" not in self._stubs: 

840 self._stubs["update_exclusion"] = self.grpc_channel.unary_unary( 

841 "/google.logging.v2.ConfigServiceV2/UpdateExclusion", 

842 request_serializer=logging_config.UpdateExclusionRequest.serialize, 

843 response_deserializer=logging_config.LogExclusion.deserialize, 

844 ) 

845 return self._stubs["update_exclusion"] 

846 

847 @property 

848 def delete_exclusion( 

849 self, 

850 ) -> Callable[[logging_config.DeleteExclusionRequest], Awaitable[empty_pb2.Empty]]: 

851 r"""Return a callable for the delete exclusion method over gRPC. 

852 

853 Deletes an exclusion in the \_Default sink. 

854 

855 Returns: 

856 Callable[[~.DeleteExclusionRequest], 

857 Awaitable[~.Empty]]: 

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

859 on the server. 

860 """ 

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

862 # the request. 

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

864 # to pass in the functions for each. 

865 if "delete_exclusion" not in self._stubs: 

866 self._stubs["delete_exclusion"] = self.grpc_channel.unary_unary( 

867 "/google.logging.v2.ConfigServiceV2/DeleteExclusion", 

868 request_serializer=logging_config.DeleteExclusionRequest.serialize, 

869 response_deserializer=empty_pb2.Empty.FromString, 

870 ) 

871 return self._stubs["delete_exclusion"] 

872 

873 @property 

874 def get_cmek_settings( 

875 self, 

876 ) -> Callable[ 

877 [logging_config.GetCmekSettingsRequest], Awaitable[logging_config.CmekSettings] 

878 ]: 

879 r"""Return a callable for the get cmek settings method over gRPC. 

880 

881 Gets the Logging CMEK settings for the given resource. 

882 

883 Note: CMEK for the Log Router can be configured for Google Cloud 

884 projects, folders, organizations and billing accounts. Once 

885 configured for an organization, it applies to all projects and 

886 folders in the Google Cloud organization. 

887 

888 See `Enabling CMEK for Log 

889 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__ 

890 for more information. 

891 

892 Returns: 

893 Callable[[~.GetCmekSettingsRequest], 

894 Awaitable[~.CmekSettings]]: 

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

896 on the server. 

897 """ 

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

899 # the request. 

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

901 # to pass in the functions for each. 

902 if "get_cmek_settings" not in self._stubs: 

903 self._stubs["get_cmek_settings"] = self.grpc_channel.unary_unary( 

904 "/google.logging.v2.ConfigServiceV2/GetCmekSettings", 

905 request_serializer=logging_config.GetCmekSettingsRequest.serialize, 

906 response_deserializer=logging_config.CmekSettings.deserialize, 

907 ) 

908 return self._stubs["get_cmek_settings"] 

909 

910 @property 

911 def update_cmek_settings( 

912 self, 

913 ) -> Callable[ 

914 [logging_config.UpdateCmekSettingsRequest], 

915 Awaitable[logging_config.CmekSettings], 

916 ]: 

917 r"""Return a callable for the update cmek settings method over gRPC. 

918 

919 Updates the Log Router CMEK settings for the given resource. 

920 

921 Note: CMEK for the Log Router can currently only be configured 

922 for Google Cloud organizations. Once configured, it applies to 

923 all projects and folders in the Google Cloud organization. 

924 

925 [UpdateCmekSettings][google.logging.v2.ConfigServiceV2.UpdateCmekSettings] 

926 will fail if 1) ``kms_key_name`` is invalid, or 2) the 

927 associated service account does not have the required 

928 ``roles/cloudkms.cryptoKeyEncrypterDecrypter`` role assigned for 

929 the key, or 3) access to the key is disabled. 

930 

931 See `Enabling CMEK for Log 

932 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__ 

933 for more information. 

934 

935 Returns: 

936 Callable[[~.UpdateCmekSettingsRequest], 

937 Awaitable[~.CmekSettings]]: 

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

939 on the server. 

940 """ 

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

942 # the request. 

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

944 # to pass in the functions for each. 

945 if "update_cmek_settings" not in self._stubs: 

946 self._stubs["update_cmek_settings"] = self.grpc_channel.unary_unary( 

947 "/google.logging.v2.ConfigServiceV2/UpdateCmekSettings", 

948 request_serializer=logging_config.UpdateCmekSettingsRequest.serialize, 

949 response_deserializer=logging_config.CmekSettings.deserialize, 

950 ) 

951 return self._stubs["update_cmek_settings"] 

952 

953 @property 

954 def get_settings( 

955 self, 

956 ) -> Callable[ 

957 [logging_config.GetSettingsRequest], Awaitable[logging_config.Settings] 

958 ]: 

959 r"""Return a callable for the get settings method over gRPC. 

960 

961 Gets the Log Router settings for the given resource. 

962 

963 Note: Settings for the Log Router can be get for Google Cloud 

964 projects, folders, organizations and billing accounts. Currently 

965 it can only be configured for organizations. Once configured for 

966 an organization, it applies to all projects and folders in the 

967 Google Cloud organization. 

968 

969 See `Enabling CMEK for Log 

970 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__ 

971 for more information. 

972 

973 Returns: 

974 Callable[[~.GetSettingsRequest], 

975 Awaitable[~.Settings]]: 

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

977 on the server. 

978 """ 

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

980 # the request. 

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

982 # to pass in the functions for each. 

983 if "get_settings" not in self._stubs: 

984 self._stubs["get_settings"] = self.grpc_channel.unary_unary( 

985 "/google.logging.v2.ConfigServiceV2/GetSettings", 

986 request_serializer=logging_config.GetSettingsRequest.serialize, 

987 response_deserializer=logging_config.Settings.deserialize, 

988 ) 

989 return self._stubs["get_settings"] 

990 

991 @property 

992 def update_settings( 

993 self, 

994 ) -> Callable[ 

995 [logging_config.UpdateSettingsRequest], Awaitable[logging_config.Settings] 

996 ]: 

997 r"""Return a callable for the update settings method over gRPC. 

998 

999 Updates the Log Router settings for the given resource. 

1000 

1001 Note: Settings for the Log Router can currently only be 

1002 configured for Google Cloud organizations. Once configured, it 

1003 applies to all projects and folders in the Google Cloud 

1004 organization. 

1005 

1006 [UpdateSettings][google.logging.v2.ConfigServiceV2.UpdateSettings] 

1007 will fail if 1) ``kms_key_name`` is invalid, or 2) the 

1008 associated service account does not have the required 

1009 ``roles/cloudkms.cryptoKeyEncrypterDecrypter`` role assigned for 

1010 the key, or 3) access to the key is disabled. 4) ``location_id`` 

1011 is not supported by Logging. 5) ``location_id`` violate 

1012 OrgPolicy. 

1013 

1014 See `Enabling CMEK for Log 

1015 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__ 

1016 for more information. 

1017 

1018 Returns: 

1019 Callable[[~.UpdateSettingsRequest], 

1020 Awaitable[~.Settings]]: 

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

1022 on the server. 

1023 """ 

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

1025 # the request. 

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

1027 # to pass in the functions for each. 

1028 if "update_settings" not in self._stubs: 

1029 self._stubs["update_settings"] = self.grpc_channel.unary_unary( 

1030 "/google.logging.v2.ConfigServiceV2/UpdateSettings", 

1031 request_serializer=logging_config.UpdateSettingsRequest.serialize, 

1032 response_deserializer=logging_config.Settings.deserialize, 

1033 ) 

1034 return self._stubs["update_settings"] 

1035 

1036 @property 

1037 def copy_log_entries( 

1038 self, 

1039 ) -> Callable[ 

1040 [logging_config.CopyLogEntriesRequest], Awaitable[operations_pb2.Operation] 

1041 ]: 

1042 r"""Return a callable for the copy log entries method over gRPC. 

1043 

1044 Copies a set of log entries from a log bucket to a 

1045 Cloud Storage bucket. 

1046 

1047 Returns: 

1048 Callable[[~.CopyLogEntriesRequest], 

1049 Awaitable[~.Operation]]: 

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

1051 on the server. 

1052 """ 

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

1054 # the request. 

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

1056 # to pass in the functions for each. 

1057 if "copy_log_entries" not in self._stubs: 

1058 self._stubs["copy_log_entries"] = self.grpc_channel.unary_unary( 

1059 "/google.logging.v2.ConfigServiceV2/CopyLogEntries", 

1060 request_serializer=logging_config.CopyLogEntriesRequest.serialize, 

1061 response_deserializer=operations_pb2.Operation.FromString, 

1062 ) 

1063 return self._stubs["copy_log_entries"] 

1064 

1065 def close(self): 

1066 return self.grpc_channel.close() 

1067 

1068 

1069__all__ = ("ConfigServiceV2GrpcAsyncIOTransport",)