Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/google/cloud/logging_v2/services/config_service_v2/async_client.py: 23%

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

497 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 logging as std_logging 

17from collections import OrderedDict 

18import re 

19from typing import ( 

20 Dict, 

21 Callable, 

22 Mapping, 

23 MutableMapping, 

24 MutableSequence, 

25 Optional, 

26 Sequence, 

27 Tuple, 

28 Type, 

29 Union, 

30) 

31import uuid 

32 

33from google.cloud.logging_v2 import gapic_version as package_version 

34 

35from google.api_core.client_options import ClientOptions 

36from google.api_core import exceptions as core_exceptions 

37from google.api_core import gapic_v1 

38from google.api_core import retry_async as retries 

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

40from google.oauth2 import service_account # type: ignore 

41import google.protobuf 

42 

43 

44try: 

45 OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault, None] 

46except AttributeError: # pragma: NO COVER 

47 OptionalRetry = Union[retries.AsyncRetry, object, None] # type: ignore 

48 

49from google.api_core import operation # type: ignore 

50from google.api_core import operation_async # type: ignore 

51from google.cloud.logging_v2.services.config_service_v2 import pagers 

52from google.cloud.logging_v2.types import logging_config 

53from google.longrunning import operations_pb2 # type: ignore 

54from google.protobuf import empty_pb2 # type: ignore 

55from google.protobuf import field_mask_pb2 # type: ignore 

56from google.protobuf import timestamp_pb2 # type: ignore 

57from .transports.base import ConfigServiceV2Transport, DEFAULT_CLIENT_INFO 

58from .transports.grpc_asyncio import ConfigServiceV2GrpcAsyncIOTransport 

59from .client import ConfigServiceV2Client 

60 

61try: 

62 from google.api_core import client_logging # type: ignore 

63 

64 CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER 

65except ImportError: # pragma: NO COVER 

66 CLIENT_LOGGING_SUPPORTED = False 

67 

68_LOGGER = std_logging.getLogger(__name__) 

69 

70 

71class ConfigServiceV2AsyncClient: 

72 """Service for configuring sinks used to route log entries.""" 

73 

74 _client: ConfigServiceV2Client 

75 

76 # Copy defaults from the synchronous client for use here. 

77 # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead. 

78 DEFAULT_ENDPOINT = ConfigServiceV2Client.DEFAULT_ENDPOINT 

79 DEFAULT_MTLS_ENDPOINT = ConfigServiceV2Client.DEFAULT_MTLS_ENDPOINT 

80 _DEFAULT_ENDPOINT_TEMPLATE = ConfigServiceV2Client._DEFAULT_ENDPOINT_TEMPLATE 

81 _DEFAULT_UNIVERSE = ConfigServiceV2Client._DEFAULT_UNIVERSE 

82 

83 cmek_settings_path = staticmethod(ConfigServiceV2Client.cmek_settings_path) 

84 parse_cmek_settings_path = staticmethod( 

85 ConfigServiceV2Client.parse_cmek_settings_path 

86 ) 

87 link_path = staticmethod(ConfigServiceV2Client.link_path) 

88 parse_link_path = staticmethod(ConfigServiceV2Client.parse_link_path) 

89 log_bucket_path = staticmethod(ConfigServiceV2Client.log_bucket_path) 

90 parse_log_bucket_path = staticmethod(ConfigServiceV2Client.parse_log_bucket_path) 

91 log_exclusion_path = staticmethod(ConfigServiceV2Client.log_exclusion_path) 

92 parse_log_exclusion_path = staticmethod( 

93 ConfigServiceV2Client.parse_log_exclusion_path 

94 ) 

95 log_sink_path = staticmethod(ConfigServiceV2Client.log_sink_path) 

96 parse_log_sink_path = staticmethod(ConfigServiceV2Client.parse_log_sink_path) 

97 log_view_path = staticmethod(ConfigServiceV2Client.log_view_path) 

98 parse_log_view_path = staticmethod(ConfigServiceV2Client.parse_log_view_path) 

99 settings_path = staticmethod(ConfigServiceV2Client.settings_path) 

100 parse_settings_path = staticmethod(ConfigServiceV2Client.parse_settings_path) 

101 common_billing_account_path = staticmethod( 

102 ConfigServiceV2Client.common_billing_account_path 

103 ) 

104 parse_common_billing_account_path = staticmethod( 

105 ConfigServiceV2Client.parse_common_billing_account_path 

106 ) 

107 common_folder_path = staticmethod(ConfigServiceV2Client.common_folder_path) 

108 parse_common_folder_path = staticmethod( 

109 ConfigServiceV2Client.parse_common_folder_path 

110 ) 

111 common_organization_path = staticmethod( 

112 ConfigServiceV2Client.common_organization_path 

113 ) 

114 parse_common_organization_path = staticmethod( 

115 ConfigServiceV2Client.parse_common_organization_path 

116 ) 

117 common_project_path = staticmethod(ConfigServiceV2Client.common_project_path) 

118 parse_common_project_path = staticmethod( 

119 ConfigServiceV2Client.parse_common_project_path 

120 ) 

121 common_location_path = staticmethod(ConfigServiceV2Client.common_location_path) 

122 parse_common_location_path = staticmethod( 

123 ConfigServiceV2Client.parse_common_location_path 

124 ) 

125 

126 @classmethod 

127 def from_service_account_info(cls, info: dict, *args, **kwargs): 

128 """Creates an instance of this client using the provided credentials 

129 info. 

130 

131 Args: 

132 info (dict): The service account private key info. 

133 args: Additional arguments to pass to the constructor. 

134 kwargs: Additional arguments to pass to the constructor. 

135 

136 Returns: 

137 ConfigServiceV2AsyncClient: The constructed client. 

138 """ 

139 return ConfigServiceV2Client.from_service_account_info.__func__(ConfigServiceV2AsyncClient, info, *args, **kwargs) # type: ignore 

140 

141 @classmethod 

142 def from_service_account_file(cls, filename: str, *args, **kwargs): 

143 """Creates an instance of this client using the provided credentials 

144 file. 

145 

146 Args: 

147 filename (str): The path to the service account private key json 

148 file. 

149 args: Additional arguments to pass to the constructor. 

150 kwargs: Additional arguments to pass to the constructor. 

151 

152 Returns: 

153 ConfigServiceV2AsyncClient: The constructed client. 

154 """ 

155 return ConfigServiceV2Client.from_service_account_file.__func__(ConfigServiceV2AsyncClient, filename, *args, **kwargs) # type: ignore 

156 

157 from_service_account_json = from_service_account_file 

158 

159 @classmethod 

160 def get_mtls_endpoint_and_cert_source( 

161 cls, client_options: Optional[ClientOptions] = None 

162 ): 

163 """Return the API endpoint and client cert source for mutual TLS. 

164 

165 The client cert source is determined in the following order: 

166 (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the 

167 client cert source is None. 

168 (2) if `client_options.client_cert_source` is provided, use the provided one; if the 

169 default client cert source exists, use the default one; otherwise the client cert 

170 source is None. 

171 

172 The API endpoint is determined in the following order: 

173 (1) if `client_options.api_endpoint` if provided, use the provided one. 

174 (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the 

175 default mTLS endpoint; if the environment variable is "never", use the default API 

176 endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise 

177 use the default API endpoint. 

178 

179 More details can be found at https://google.aip.dev/auth/4114. 

180 

181 Args: 

182 client_options (google.api_core.client_options.ClientOptions): Custom options for the 

183 client. Only the `api_endpoint` and `client_cert_source` properties may be used 

184 in this method. 

185 

186 Returns: 

187 Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the 

188 client cert source to use. 

189 

190 Raises: 

191 google.auth.exceptions.MutualTLSChannelError: If any errors happen. 

192 """ 

193 return ConfigServiceV2Client.get_mtls_endpoint_and_cert_source(client_options) # type: ignore 

194 

195 @property 

196 def transport(self) -> ConfigServiceV2Transport: 

197 """Returns the transport used by the client instance. 

198 

199 Returns: 

200 ConfigServiceV2Transport: The transport used by the client instance. 

201 """ 

202 return self._client.transport 

203 

204 @property 

205 def api_endpoint(self): 

206 """Return the API endpoint used by the client instance. 

207 

208 Returns: 

209 str: The API endpoint used by the client instance. 

210 """ 

211 return self._client._api_endpoint 

212 

213 @property 

214 def universe_domain(self) -> str: 

215 """Return the universe domain used by the client instance. 

216 

217 Returns: 

218 str: The universe domain used 

219 by the client instance. 

220 """ 

221 return self._client._universe_domain 

222 

223 get_transport_class = ConfigServiceV2Client.get_transport_class 

224 

225 def __init__( 

226 self, 

227 *, 

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

229 transport: Optional[ 

230 Union[ 

231 str, ConfigServiceV2Transport, Callable[..., ConfigServiceV2Transport] 

232 ] 

233 ] = "grpc_asyncio", 

234 client_options: Optional[ClientOptions] = None, 

235 client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, 

236 ) -> None: 

237 """Instantiates the config service v2 async client. 

238 

239 Args: 

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

241 authorization credentials to attach to requests. These 

242 credentials identify the application to the service; if none 

243 are specified, the client will attempt to ascertain the 

244 credentials from the environment. 

245 transport (Optional[Union[str,ConfigServiceV2Transport,Callable[..., ConfigServiceV2Transport]]]): 

246 The transport to use, or a Callable that constructs and returns a new transport to use. 

247 If a Callable is given, it will be called with the same set of initialization 

248 arguments as used in the ConfigServiceV2Transport constructor. 

249 If set to None, a transport is chosen automatically. 

250 client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): 

251 Custom options for the client. 

252 

253 1. The ``api_endpoint`` property can be used to override the 

254 default endpoint provided by the client when ``transport`` is 

255 not explicitly provided. Only if this property is not set and 

256 ``transport`` was not explicitly provided, the endpoint is 

257 determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment 

258 variable, which have one of the following values: 

259 "always" (always use the default mTLS endpoint), "never" (always 

260 use the default regular endpoint) and "auto" (auto-switch to the 

261 default mTLS endpoint if client certificate is present; this is 

262 the default value). 

263 

264 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable 

265 is "true", then the ``client_cert_source`` property can be used 

266 to provide a client certificate for mTLS transport. If 

267 not provided, the default SSL client certificate will be used if 

268 present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not 

269 set, no client certificate will be used. 

270 

271 3. The ``universe_domain`` property can be used to override the 

272 default "googleapis.com" universe. Note that ``api_endpoint`` 

273 property still takes precedence; and ``universe_domain`` is 

274 currently not supported for mTLS. 

275 

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

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

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

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

280 your own client library. 

281 

282 Raises: 

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

284 creation failed for any reason. 

285 """ 

286 self._client = ConfigServiceV2Client( 

287 credentials=credentials, 

288 transport=transport, 

289 client_options=client_options, 

290 client_info=client_info, 

291 ) 

292 

293 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

294 std_logging.DEBUG 

295 ): # pragma: NO COVER 

296 _LOGGER.debug( 

297 "Created client `google.logging_v2.ConfigServiceV2AsyncClient`.", 

298 extra={ 

299 "serviceName": "google.logging.v2.ConfigServiceV2", 

300 "universeDomain": getattr( 

301 self._client._transport._credentials, "universe_domain", "" 

302 ), 

303 "credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}", 

304 "credentialsInfo": getattr( 

305 self.transport._credentials, "get_cred_info", lambda: None 

306 )(), 

307 } 

308 if hasattr(self._client._transport, "_credentials") 

309 else { 

310 "serviceName": "google.logging.v2.ConfigServiceV2", 

311 "credentialsType": None, 

312 }, 

313 ) 

314 

315 async def list_buckets( 

316 self, 

317 request: Optional[Union[logging_config.ListBucketsRequest, dict]] = None, 

318 *, 

319 parent: Optional[str] = None, 

320 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

321 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

322 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

323 ) -> pagers.ListBucketsAsyncPager: 

324 r"""Lists log buckets. 

325 

326 .. code-block:: python 

327 

328 # This snippet has been automatically generated and should be regarded as a 

329 # code template only. 

330 # It will require modifications to work: 

331 # - It may require correct/in-range values for request initialization. 

332 # - It may require specifying regional endpoints when creating the service 

333 # client as shown in: 

334 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

335 from google.cloud import logging_v2 

336 

337 async def sample_list_buckets(): 

338 # Create a client 

339 client = logging_v2.ConfigServiceV2AsyncClient() 

340 

341 # Initialize request argument(s) 

342 request = logging_v2.ListBucketsRequest( 

343 parent="parent_value", 

344 ) 

345 

346 # Make the request 

347 page_result = client.list_buckets(request=request) 

348 

349 # Handle the response 

350 async for response in page_result: 

351 print(response) 

352 

353 Args: 

354 request (Optional[Union[google.cloud.logging_v2.types.ListBucketsRequest, dict]]): 

355 The request object. The parameters to ``ListBuckets``. 

356 parent (:class:`str`): 

357 Required. The parent resource whose buckets are to be 

358 listed: 

359 

360 :: 

361 

362 "projects/[PROJECT_ID]/locations/[LOCATION_ID]" 

363 "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]" 

364 "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]" 

365 "folders/[FOLDER_ID]/locations/[LOCATION_ID]" 

366 

367 Note: The locations portion of the resource must be 

368 specified, but supplying the character ``-`` in place of 

369 [LOCATION_ID] will return all buckets. 

370 

371 This corresponds to the ``parent`` field 

372 on the ``request`` instance; if ``request`` is provided, this 

373 should not be set. 

374 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

375 should be retried. 

376 timeout (float): The timeout for this request. 

377 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

378 sent along with the request as metadata. Normally, each value must be of type `str`, 

379 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

380 be of type `bytes`. 

381 

382 Returns: 

383 google.cloud.logging_v2.services.config_service_v2.pagers.ListBucketsAsyncPager: 

384 The response from ListBuckets. 

385 

386 Iterating over this object will yield 

387 results and resolve additional pages 

388 automatically. 

389 

390 """ 

391 # Create or coerce a protobuf request object. 

392 # - Quick check: If we got a request object, we should *not* have 

393 # gotten any keyword arguments that map to the request. 

394 flattened_params = [parent] 

395 has_flattened_params = ( 

396 len([param for param in flattened_params if param is not None]) > 0 

397 ) 

398 if request is not None and has_flattened_params: 

399 raise ValueError( 

400 "If the `request` argument is set, then none of " 

401 "the individual field arguments should be set." 

402 ) 

403 

404 # - Use the request object if provided (there's no risk of modifying the input as 

405 # there are no flattened fields), or create one. 

406 if not isinstance(request, logging_config.ListBucketsRequest): 

407 request = logging_config.ListBucketsRequest(request) 

408 

409 # If we have keyword arguments corresponding to fields on the 

410 # request, apply these. 

411 if parent is not None: 

412 request.parent = parent 

413 

414 # Wrap the RPC method; this adds retry and timeout information, 

415 # and friendly error handling. 

416 rpc = self._client._transport._wrapped_methods[ 

417 self._client._transport.list_buckets 

418 ] 

419 

420 # Certain fields should be provided within the metadata header; 

421 # add these here. 

422 metadata = tuple(metadata) + ( 

423 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), 

424 ) 

425 

426 # Validate the universe domain. 

427 self._client._validate_universe_domain() 

428 

429 # Send the request. 

430 response = await rpc( 

431 request, 

432 retry=retry, 

433 timeout=timeout, 

434 metadata=metadata, 

435 ) 

436 

437 # This method is paged; wrap the response in a pager, which provides 

438 # an `__aiter__` convenience method. 

439 response = pagers.ListBucketsAsyncPager( 

440 method=rpc, 

441 request=request, 

442 response=response, 

443 retry=retry, 

444 timeout=timeout, 

445 metadata=metadata, 

446 ) 

447 

448 # Done; return the response. 

449 return response 

450 

451 async def get_bucket( 

452 self, 

453 request: Optional[Union[logging_config.GetBucketRequest, dict]] = None, 

454 *, 

455 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

456 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

457 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

458 ) -> logging_config.LogBucket: 

459 r"""Gets a log bucket. 

460 

461 .. code-block:: python 

462 

463 # This snippet has been automatically generated and should be regarded as a 

464 # code template only. 

465 # It will require modifications to work: 

466 # - It may require correct/in-range values for request initialization. 

467 # - It may require specifying regional endpoints when creating the service 

468 # client as shown in: 

469 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

470 from google.cloud import logging_v2 

471 

472 async def sample_get_bucket(): 

473 # Create a client 

474 client = logging_v2.ConfigServiceV2AsyncClient() 

475 

476 # Initialize request argument(s) 

477 request = logging_v2.GetBucketRequest( 

478 name="name_value", 

479 ) 

480 

481 # Make the request 

482 response = await client.get_bucket(request=request) 

483 

484 # Handle the response 

485 print(response) 

486 

487 Args: 

488 request (Optional[Union[google.cloud.logging_v2.types.GetBucketRequest, dict]]): 

489 The request object. The parameters to ``GetBucket``. 

490 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

491 should be retried. 

492 timeout (float): The timeout for this request. 

493 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

494 sent along with the request as metadata. Normally, each value must be of type `str`, 

495 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

496 be of type `bytes`. 

497 

498 Returns: 

499 google.cloud.logging_v2.types.LogBucket: 

500 Describes a repository in which log 

501 entries are stored. 

502 

503 """ 

504 # Create or coerce a protobuf request object. 

505 # - Use the request object if provided (there's no risk of modifying the input as 

506 # there are no flattened fields), or create one. 

507 if not isinstance(request, logging_config.GetBucketRequest): 

508 request = logging_config.GetBucketRequest(request) 

509 

510 # Wrap the RPC method; this adds retry and timeout information, 

511 # and friendly error handling. 

512 rpc = self._client._transport._wrapped_methods[ 

513 self._client._transport.get_bucket 

514 ] 

515 

516 # Certain fields should be provided within the metadata header; 

517 # add these here. 

518 metadata = tuple(metadata) + ( 

519 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

520 ) 

521 

522 # Validate the universe domain. 

523 self._client._validate_universe_domain() 

524 

525 # Send the request. 

526 response = await rpc( 

527 request, 

528 retry=retry, 

529 timeout=timeout, 

530 metadata=metadata, 

531 ) 

532 

533 # Done; return the response. 

534 return response 

535 

536 async def create_bucket_async( 

537 self, 

538 request: Optional[Union[logging_config.CreateBucketRequest, dict]] = None, 

539 *, 

540 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

541 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

542 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

543 ) -> operation_async.AsyncOperation: 

544 r"""Creates a log bucket asynchronously that can be used 

545 to store log entries. 

546 After a bucket has been created, the bucket's location 

547 cannot be changed. 

548 

549 .. code-block:: python 

550 

551 # This snippet has been automatically generated and should be regarded as a 

552 # code template only. 

553 # It will require modifications to work: 

554 # - It may require correct/in-range values for request initialization. 

555 # - It may require specifying regional endpoints when creating the service 

556 # client as shown in: 

557 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

558 from google.cloud import logging_v2 

559 

560 async def sample_create_bucket_async(): 

561 # Create a client 

562 client = logging_v2.ConfigServiceV2AsyncClient() 

563 

564 # Initialize request argument(s) 

565 request = logging_v2.CreateBucketRequest( 

566 parent="parent_value", 

567 bucket_id="bucket_id_value", 

568 ) 

569 

570 # Make the request 

571 operation = client.create_bucket_async(request=request) 

572 

573 print("Waiting for operation to complete...") 

574 

575 response = (await operation).result() 

576 

577 # Handle the response 

578 print(response) 

579 

580 Args: 

581 request (Optional[Union[google.cloud.logging_v2.types.CreateBucketRequest, dict]]): 

582 The request object. The parameters to ``CreateBucket``. 

583 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

584 should be retried. 

585 timeout (float): The timeout for this request. 

586 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

587 sent along with the request as metadata. Normally, each value must be of type `str`, 

588 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

589 be of type `bytes`. 

590 

591 Returns: 

592 google.api_core.operation_async.AsyncOperation: 

593 An object representing a long-running operation. 

594 

595 The result type for the operation will be 

596 :class:`google.cloud.logging_v2.types.LogBucket` 

597 Describes a repository in which log entries are stored. 

598 

599 """ 

600 # Create or coerce a protobuf request object. 

601 # - Use the request object if provided (there's no risk of modifying the input as 

602 # there are no flattened fields), or create one. 

603 if not isinstance(request, logging_config.CreateBucketRequest): 

604 request = logging_config.CreateBucketRequest(request) 

605 

606 # Wrap the RPC method; this adds retry and timeout information, 

607 # and friendly error handling. 

608 rpc = self._client._transport._wrapped_methods[ 

609 self._client._transport.create_bucket_async 

610 ] 

611 

612 # Certain fields should be provided within the metadata header; 

613 # add these here. 

614 metadata = tuple(metadata) + ( 

615 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), 

616 ) 

617 

618 # Validate the universe domain. 

619 self._client._validate_universe_domain() 

620 

621 # Send the request. 

622 response = await rpc( 

623 request, 

624 retry=retry, 

625 timeout=timeout, 

626 metadata=metadata, 

627 ) 

628 

629 # Wrap the response in an operation future. 

630 response = operation_async.from_gapic( 

631 response, 

632 self._client._transport.operations_client, 

633 logging_config.LogBucket, 

634 metadata_type=logging_config.BucketMetadata, 

635 ) 

636 

637 # Done; return the response. 

638 return response 

639 

640 async def update_bucket_async( 

641 self, 

642 request: Optional[Union[logging_config.UpdateBucketRequest, dict]] = None, 

643 *, 

644 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

645 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

646 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

647 ) -> operation_async.AsyncOperation: 

648 r"""Updates a log bucket asynchronously. 

649 

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

651 then ``FAILED_PRECONDITION`` will be returned. 

652 

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

654 changed. 

655 

656 .. code-block:: python 

657 

658 # This snippet has been automatically generated and should be regarded as a 

659 # code template only. 

660 # It will require modifications to work: 

661 # - It may require correct/in-range values for request initialization. 

662 # - It may require specifying regional endpoints when creating the service 

663 # client as shown in: 

664 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

665 from google.cloud import logging_v2 

666 

667 async def sample_update_bucket_async(): 

668 # Create a client 

669 client = logging_v2.ConfigServiceV2AsyncClient() 

670 

671 # Initialize request argument(s) 

672 request = logging_v2.UpdateBucketRequest( 

673 name="name_value", 

674 ) 

675 

676 # Make the request 

677 operation = client.update_bucket_async(request=request) 

678 

679 print("Waiting for operation to complete...") 

680 

681 response = (await operation).result() 

682 

683 # Handle the response 

684 print(response) 

685 

686 Args: 

687 request (Optional[Union[google.cloud.logging_v2.types.UpdateBucketRequest, dict]]): 

688 The request object. The parameters to ``UpdateBucket``. 

689 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

690 should be retried. 

691 timeout (float): The timeout for this request. 

692 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

693 sent along with the request as metadata. Normally, each value must be of type `str`, 

694 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

695 be of type `bytes`. 

696 

697 Returns: 

698 google.api_core.operation_async.AsyncOperation: 

699 An object representing a long-running operation. 

700 

701 The result type for the operation will be 

702 :class:`google.cloud.logging_v2.types.LogBucket` 

703 Describes a repository in which log entries are stored. 

704 

705 """ 

706 # Create or coerce a protobuf request object. 

707 # - Use the request object if provided (there's no risk of modifying the input as 

708 # there are no flattened fields), or create one. 

709 if not isinstance(request, logging_config.UpdateBucketRequest): 

710 request = logging_config.UpdateBucketRequest(request) 

711 

712 # Wrap the RPC method; this adds retry and timeout information, 

713 # and friendly error handling. 

714 rpc = self._client._transport._wrapped_methods[ 

715 self._client._transport.update_bucket_async 

716 ] 

717 

718 # Certain fields should be provided within the metadata header; 

719 # add these here. 

720 metadata = tuple(metadata) + ( 

721 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

722 ) 

723 

724 # Validate the universe domain. 

725 self._client._validate_universe_domain() 

726 

727 # Send the request. 

728 response = await rpc( 

729 request, 

730 retry=retry, 

731 timeout=timeout, 

732 metadata=metadata, 

733 ) 

734 

735 # Wrap the response in an operation future. 

736 response = operation_async.from_gapic( 

737 response, 

738 self._client._transport.operations_client, 

739 logging_config.LogBucket, 

740 metadata_type=logging_config.BucketMetadata, 

741 ) 

742 

743 # Done; return the response. 

744 return response 

745 

746 async def create_bucket( 

747 self, 

748 request: Optional[Union[logging_config.CreateBucketRequest, dict]] = None, 

749 *, 

750 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

751 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

752 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

753 ) -> logging_config.LogBucket: 

754 r"""Creates a log bucket that can be used to store log 

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

756 location cannot be changed. 

757 

758 .. code-block:: python 

759 

760 # This snippet has been automatically generated and should be regarded as a 

761 # code template only. 

762 # It will require modifications to work: 

763 # - It may require correct/in-range values for request initialization. 

764 # - It may require specifying regional endpoints when creating the service 

765 # client as shown in: 

766 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

767 from google.cloud import logging_v2 

768 

769 async def sample_create_bucket(): 

770 # Create a client 

771 client = logging_v2.ConfigServiceV2AsyncClient() 

772 

773 # Initialize request argument(s) 

774 request = logging_v2.CreateBucketRequest( 

775 parent="parent_value", 

776 bucket_id="bucket_id_value", 

777 ) 

778 

779 # Make the request 

780 response = await client.create_bucket(request=request) 

781 

782 # Handle the response 

783 print(response) 

784 

785 Args: 

786 request (Optional[Union[google.cloud.logging_v2.types.CreateBucketRequest, dict]]): 

787 The request object. The parameters to ``CreateBucket``. 

788 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

789 should be retried. 

790 timeout (float): The timeout for this request. 

791 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

792 sent along with the request as metadata. Normally, each value must be of type `str`, 

793 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

794 be of type `bytes`. 

795 

796 Returns: 

797 google.cloud.logging_v2.types.LogBucket: 

798 Describes a repository in which log 

799 entries are stored. 

800 

801 """ 

802 # Create or coerce a protobuf request object. 

803 # - Use the request object if provided (there's no risk of modifying the input as 

804 # there are no flattened fields), or create one. 

805 if not isinstance(request, logging_config.CreateBucketRequest): 

806 request = logging_config.CreateBucketRequest(request) 

807 

808 # Wrap the RPC method; this adds retry and timeout information, 

809 # and friendly error handling. 

810 rpc = self._client._transport._wrapped_methods[ 

811 self._client._transport.create_bucket 

812 ] 

813 

814 # Certain fields should be provided within the metadata header; 

815 # add these here. 

816 metadata = tuple(metadata) + ( 

817 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), 

818 ) 

819 

820 # Validate the universe domain. 

821 self._client._validate_universe_domain() 

822 

823 # Send the request. 

824 response = await rpc( 

825 request, 

826 retry=retry, 

827 timeout=timeout, 

828 metadata=metadata, 

829 ) 

830 

831 # Done; return the response. 

832 return response 

833 

834 async def update_bucket( 

835 self, 

836 request: Optional[Union[logging_config.UpdateBucketRequest, dict]] = None, 

837 *, 

838 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

839 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

840 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

841 ) -> logging_config.LogBucket: 

842 r"""Updates a log bucket. 

843 

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

845 then ``FAILED_PRECONDITION`` will be returned. 

846 

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

848 changed. 

849 

850 .. code-block:: python 

851 

852 # This snippet has been automatically generated and should be regarded as a 

853 # code template only. 

854 # It will require modifications to work: 

855 # - It may require correct/in-range values for request initialization. 

856 # - It may require specifying regional endpoints when creating the service 

857 # client as shown in: 

858 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

859 from google.cloud import logging_v2 

860 

861 async def sample_update_bucket(): 

862 # Create a client 

863 client = logging_v2.ConfigServiceV2AsyncClient() 

864 

865 # Initialize request argument(s) 

866 request = logging_v2.UpdateBucketRequest( 

867 name="name_value", 

868 ) 

869 

870 # Make the request 

871 response = await client.update_bucket(request=request) 

872 

873 # Handle the response 

874 print(response) 

875 

876 Args: 

877 request (Optional[Union[google.cloud.logging_v2.types.UpdateBucketRequest, dict]]): 

878 The request object. The parameters to ``UpdateBucket``. 

879 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

880 should be retried. 

881 timeout (float): The timeout for this request. 

882 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

883 sent along with the request as metadata. Normally, each value must be of type `str`, 

884 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

885 be of type `bytes`. 

886 

887 Returns: 

888 google.cloud.logging_v2.types.LogBucket: 

889 Describes a repository in which log 

890 entries are stored. 

891 

892 """ 

893 # Create or coerce a protobuf request object. 

894 # - Use the request object if provided (there's no risk of modifying the input as 

895 # there are no flattened fields), or create one. 

896 if not isinstance(request, logging_config.UpdateBucketRequest): 

897 request = logging_config.UpdateBucketRequest(request) 

898 

899 # Wrap the RPC method; this adds retry and timeout information, 

900 # and friendly error handling. 

901 rpc = self._client._transport._wrapped_methods[ 

902 self._client._transport.update_bucket 

903 ] 

904 

905 # Certain fields should be provided within the metadata header; 

906 # add these here. 

907 metadata = tuple(metadata) + ( 

908 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

909 ) 

910 

911 # Validate the universe domain. 

912 self._client._validate_universe_domain() 

913 

914 # Send the request. 

915 response = await rpc( 

916 request, 

917 retry=retry, 

918 timeout=timeout, 

919 metadata=metadata, 

920 ) 

921 

922 # Done; return the response. 

923 return response 

924 

925 async def delete_bucket( 

926 self, 

927 request: Optional[Union[logging_config.DeleteBucketRequest, dict]] = None, 

928 *, 

929 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

930 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

931 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

932 ) -> None: 

933 r"""Deletes a log bucket. 

934 

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

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

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

938 deleted. 

939 

940 .. code-block:: python 

941 

942 # This snippet has been automatically generated and should be regarded as a 

943 # code template only. 

944 # It will require modifications to work: 

945 # - It may require correct/in-range values for request initialization. 

946 # - It may require specifying regional endpoints when creating the service 

947 # client as shown in: 

948 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

949 from google.cloud import logging_v2 

950 

951 async def sample_delete_bucket(): 

952 # Create a client 

953 client = logging_v2.ConfigServiceV2AsyncClient() 

954 

955 # Initialize request argument(s) 

956 request = logging_v2.DeleteBucketRequest( 

957 name="name_value", 

958 ) 

959 

960 # Make the request 

961 await client.delete_bucket(request=request) 

962 

963 Args: 

964 request (Optional[Union[google.cloud.logging_v2.types.DeleteBucketRequest, dict]]): 

965 The request object. The parameters to ``DeleteBucket``. 

966 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

967 should be retried. 

968 timeout (float): The timeout for this request. 

969 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

970 sent along with the request as metadata. Normally, each value must be of type `str`, 

971 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

972 be of type `bytes`. 

973 """ 

974 # Create or coerce a protobuf request object. 

975 # - Use the request object if provided (there's no risk of modifying the input as 

976 # there are no flattened fields), or create one. 

977 if not isinstance(request, logging_config.DeleteBucketRequest): 

978 request = logging_config.DeleteBucketRequest(request) 

979 

980 # Wrap the RPC method; this adds retry and timeout information, 

981 # and friendly error handling. 

982 rpc = self._client._transport._wrapped_methods[ 

983 self._client._transport.delete_bucket 

984 ] 

985 

986 # Certain fields should be provided within the metadata header; 

987 # add these here. 

988 metadata = tuple(metadata) + ( 

989 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

990 ) 

991 

992 # Validate the universe domain. 

993 self._client._validate_universe_domain() 

994 

995 # Send the request. 

996 await rpc( 

997 request, 

998 retry=retry, 

999 timeout=timeout, 

1000 metadata=metadata, 

1001 ) 

1002 

1003 async def undelete_bucket( 

1004 self, 

1005 request: Optional[Union[logging_config.UndeleteBucketRequest, dict]] = None, 

1006 *, 

1007 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1008 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

1009 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

1010 ) -> None: 

1011 r"""Undeletes a log bucket. A bucket that has been 

1012 deleted can be undeleted within the grace period of 7 

1013 days. 

1014 

1015 .. code-block:: python 

1016 

1017 # This snippet has been automatically generated and should be regarded as a 

1018 # code template only. 

1019 # It will require modifications to work: 

1020 # - It may require correct/in-range values for request initialization. 

1021 # - It may require specifying regional endpoints when creating the service 

1022 # client as shown in: 

1023 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

1024 from google.cloud import logging_v2 

1025 

1026 async def sample_undelete_bucket(): 

1027 # Create a client 

1028 client = logging_v2.ConfigServiceV2AsyncClient() 

1029 

1030 # Initialize request argument(s) 

1031 request = logging_v2.UndeleteBucketRequest( 

1032 name="name_value", 

1033 ) 

1034 

1035 # Make the request 

1036 await client.undelete_bucket(request=request) 

1037 

1038 Args: 

1039 request (Optional[Union[google.cloud.logging_v2.types.UndeleteBucketRequest, dict]]): 

1040 The request object. The parameters to ``UndeleteBucket``. 

1041 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

1042 should be retried. 

1043 timeout (float): The timeout for this request. 

1044 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

1045 sent along with the request as metadata. Normally, each value must be of type `str`, 

1046 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

1047 be of type `bytes`. 

1048 """ 

1049 # Create or coerce a protobuf request object. 

1050 # - Use the request object if provided (there's no risk of modifying the input as 

1051 # there are no flattened fields), or create one. 

1052 if not isinstance(request, logging_config.UndeleteBucketRequest): 

1053 request = logging_config.UndeleteBucketRequest(request) 

1054 

1055 # Wrap the RPC method; this adds retry and timeout information, 

1056 # and friendly error handling. 

1057 rpc = self._client._transport._wrapped_methods[ 

1058 self._client._transport.undelete_bucket 

1059 ] 

1060 

1061 # Certain fields should be provided within the metadata header; 

1062 # add these here. 

1063 metadata = tuple(metadata) + ( 

1064 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

1065 ) 

1066 

1067 # Validate the universe domain. 

1068 self._client._validate_universe_domain() 

1069 

1070 # Send the request. 

1071 await rpc( 

1072 request, 

1073 retry=retry, 

1074 timeout=timeout, 

1075 metadata=metadata, 

1076 ) 

1077 

1078 async def list_views( 

1079 self, 

1080 request: Optional[Union[logging_config.ListViewsRequest, dict]] = None, 

1081 *, 

1082 parent: Optional[str] = None, 

1083 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1084 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

1085 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

1086 ) -> pagers.ListViewsAsyncPager: 

1087 r"""Lists views on a log bucket. 

1088 

1089 .. code-block:: python 

1090 

1091 # This snippet has been automatically generated and should be regarded as a 

1092 # code template only. 

1093 # It will require modifications to work: 

1094 # - It may require correct/in-range values for request initialization. 

1095 # - It may require specifying regional endpoints when creating the service 

1096 # client as shown in: 

1097 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

1098 from google.cloud import logging_v2 

1099 

1100 async def sample_list_views(): 

1101 # Create a client 

1102 client = logging_v2.ConfigServiceV2AsyncClient() 

1103 

1104 # Initialize request argument(s) 

1105 request = logging_v2.ListViewsRequest( 

1106 parent="parent_value", 

1107 ) 

1108 

1109 # Make the request 

1110 page_result = client.list_views(request=request) 

1111 

1112 # Handle the response 

1113 async for response in page_result: 

1114 print(response) 

1115 

1116 Args: 

1117 request (Optional[Union[google.cloud.logging_v2.types.ListViewsRequest, dict]]): 

1118 The request object. The parameters to ``ListViews``. 

1119 parent (:class:`str`): 

1120 Required. The bucket whose views are to be listed: 

1121 

1122 :: 

1123 

1124 "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" 

1125 

1126 This corresponds to the ``parent`` field 

1127 on the ``request`` instance; if ``request`` is provided, this 

1128 should not be set. 

1129 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

1130 should be retried. 

1131 timeout (float): The timeout for this request. 

1132 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

1133 sent along with the request as metadata. Normally, each value must be of type `str`, 

1134 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

1135 be of type `bytes`. 

1136 

1137 Returns: 

1138 google.cloud.logging_v2.services.config_service_v2.pagers.ListViewsAsyncPager: 

1139 The response from ListViews. 

1140 

1141 Iterating over this object will yield 

1142 results and resolve additional pages 

1143 automatically. 

1144 

1145 """ 

1146 # Create or coerce a protobuf request object. 

1147 # - Quick check: If we got a request object, we should *not* have 

1148 # gotten any keyword arguments that map to the request. 

1149 flattened_params = [parent] 

1150 has_flattened_params = ( 

1151 len([param for param in flattened_params if param is not None]) > 0 

1152 ) 

1153 if request is not None and has_flattened_params: 

1154 raise ValueError( 

1155 "If the `request` argument is set, then none of " 

1156 "the individual field arguments should be set." 

1157 ) 

1158 

1159 # - Use the request object if provided (there's no risk of modifying the input as 

1160 # there are no flattened fields), or create one. 

1161 if not isinstance(request, logging_config.ListViewsRequest): 

1162 request = logging_config.ListViewsRequest(request) 

1163 

1164 # If we have keyword arguments corresponding to fields on the 

1165 # request, apply these. 

1166 if parent is not None: 

1167 request.parent = parent 

1168 

1169 # Wrap the RPC method; this adds retry and timeout information, 

1170 # and friendly error handling. 

1171 rpc = self._client._transport._wrapped_methods[ 

1172 self._client._transport.list_views 

1173 ] 

1174 

1175 # Certain fields should be provided within the metadata header; 

1176 # add these here. 

1177 metadata = tuple(metadata) + ( 

1178 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), 

1179 ) 

1180 

1181 # Validate the universe domain. 

1182 self._client._validate_universe_domain() 

1183 

1184 # Send the request. 

1185 response = await rpc( 

1186 request, 

1187 retry=retry, 

1188 timeout=timeout, 

1189 metadata=metadata, 

1190 ) 

1191 

1192 # This method is paged; wrap the response in a pager, which provides 

1193 # an `__aiter__` convenience method. 

1194 response = pagers.ListViewsAsyncPager( 

1195 method=rpc, 

1196 request=request, 

1197 response=response, 

1198 retry=retry, 

1199 timeout=timeout, 

1200 metadata=metadata, 

1201 ) 

1202 

1203 # Done; return the response. 

1204 return response 

1205 

1206 async def get_view( 

1207 self, 

1208 request: Optional[Union[logging_config.GetViewRequest, dict]] = None, 

1209 *, 

1210 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1211 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

1212 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

1213 ) -> logging_config.LogView: 

1214 r"""Gets a view on a log bucket.. 

1215 

1216 .. code-block:: python 

1217 

1218 # This snippet has been automatically generated and should be regarded as a 

1219 # code template only. 

1220 # It will require modifications to work: 

1221 # - It may require correct/in-range values for request initialization. 

1222 # - It may require specifying regional endpoints when creating the service 

1223 # client as shown in: 

1224 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

1225 from google.cloud import logging_v2 

1226 

1227 async def sample_get_view(): 

1228 # Create a client 

1229 client = logging_v2.ConfigServiceV2AsyncClient() 

1230 

1231 # Initialize request argument(s) 

1232 request = logging_v2.GetViewRequest( 

1233 name="name_value", 

1234 ) 

1235 

1236 # Make the request 

1237 response = await client.get_view(request=request) 

1238 

1239 # Handle the response 

1240 print(response) 

1241 

1242 Args: 

1243 request (Optional[Union[google.cloud.logging_v2.types.GetViewRequest, dict]]): 

1244 The request object. The parameters to ``GetView``. 

1245 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

1246 should be retried. 

1247 timeout (float): The timeout for this request. 

1248 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

1249 sent along with the request as metadata. Normally, each value must be of type `str`, 

1250 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

1251 be of type `bytes`. 

1252 

1253 Returns: 

1254 google.cloud.logging_v2.types.LogView: 

1255 Describes a view over log entries in 

1256 a bucket. 

1257 

1258 """ 

1259 # Create or coerce a protobuf request object. 

1260 # - Use the request object if provided (there's no risk of modifying the input as 

1261 # there are no flattened fields), or create one. 

1262 if not isinstance(request, logging_config.GetViewRequest): 

1263 request = logging_config.GetViewRequest(request) 

1264 

1265 # Wrap the RPC method; this adds retry and timeout information, 

1266 # and friendly error handling. 

1267 rpc = self._client._transport._wrapped_methods[self._client._transport.get_view] 

1268 

1269 # Certain fields should be provided within the metadata header; 

1270 # add these here. 

1271 metadata = tuple(metadata) + ( 

1272 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

1273 ) 

1274 

1275 # Validate the universe domain. 

1276 self._client._validate_universe_domain() 

1277 

1278 # Send the request. 

1279 response = await rpc( 

1280 request, 

1281 retry=retry, 

1282 timeout=timeout, 

1283 metadata=metadata, 

1284 ) 

1285 

1286 # Done; return the response. 

1287 return response 

1288 

1289 async def create_view( 

1290 self, 

1291 request: Optional[Union[logging_config.CreateViewRequest, dict]] = None, 

1292 *, 

1293 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1294 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

1295 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

1296 ) -> logging_config.LogView: 

1297 r"""Creates a view over log entries in a log bucket. A 

1298 bucket may contain a maximum of 30 views. 

1299 

1300 .. code-block:: python 

1301 

1302 # This snippet has been automatically generated and should be regarded as a 

1303 # code template only. 

1304 # It will require modifications to work: 

1305 # - It may require correct/in-range values for request initialization. 

1306 # - It may require specifying regional endpoints when creating the service 

1307 # client as shown in: 

1308 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

1309 from google.cloud import logging_v2 

1310 

1311 async def sample_create_view(): 

1312 # Create a client 

1313 client = logging_v2.ConfigServiceV2AsyncClient() 

1314 

1315 # Initialize request argument(s) 

1316 request = logging_v2.CreateViewRequest( 

1317 parent="parent_value", 

1318 view_id="view_id_value", 

1319 ) 

1320 

1321 # Make the request 

1322 response = await client.create_view(request=request) 

1323 

1324 # Handle the response 

1325 print(response) 

1326 

1327 Args: 

1328 request (Optional[Union[google.cloud.logging_v2.types.CreateViewRequest, dict]]): 

1329 The request object. The parameters to ``CreateView``. 

1330 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

1331 should be retried. 

1332 timeout (float): The timeout for this request. 

1333 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

1334 sent along with the request as metadata. Normally, each value must be of type `str`, 

1335 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

1336 be of type `bytes`. 

1337 

1338 Returns: 

1339 google.cloud.logging_v2.types.LogView: 

1340 Describes a view over log entries in 

1341 a bucket. 

1342 

1343 """ 

1344 # Create or coerce a protobuf request object. 

1345 # - Use the request object if provided (there's no risk of modifying the input as 

1346 # there are no flattened fields), or create one. 

1347 if not isinstance(request, logging_config.CreateViewRequest): 

1348 request = logging_config.CreateViewRequest(request) 

1349 

1350 # Wrap the RPC method; this adds retry and timeout information, 

1351 # and friendly error handling. 

1352 rpc = self._client._transport._wrapped_methods[ 

1353 self._client._transport.create_view 

1354 ] 

1355 

1356 # Certain fields should be provided within the metadata header; 

1357 # add these here. 

1358 metadata = tuple(metadata) + ( 

1359 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), 

1360 ) 

1361 

1362 # Validate the universe domain. 

1363 self._client._validate_universe_domain() 

1364 

1365 # Send the request. 

1366 response = await rpc( 

1367 request, 

1368 retry=retry, 

1369 timeout=timeout, 

1370 metadata=metadata, 

1371 ) 

1372 

1373 # Done; return the response. 

1374 return response 

1375 

1376 async def update_view( 

1377 self, 

1378 request: Optional[Union[logging_config.UpdateViewRequest, dict]] = None, 

1379 *, 

1380 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1381 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

1382 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

1383 ) -> logging_config.LogView: 

1384 r"""Updates a view on a log bucket. This method replaces the 

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

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

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

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

1389 

1390 .. code-block:: python 

1391 

1392 # This snippet has been automatically generated and should be regarded as a 

1393 # code template only. 

1394 # It will require modifications to work: 

1395 # - It may require correct/in-range values for request initialization. 

1396 # - It may require specifying regional endpoints when creating the service 

1397 # client as shown in: 

1398 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

1399 from google.cloud import logging_v2 

1400 

1401 async def sample_update_view(): 

1402 # Create a client 

1403 client = logging_v2.ConfigServiceV2AsyncClient() 

1404 

1405 # Initialize request argument(s) 

1406 request = logging_v2.UpdateViewRequest( 

1407 name="name_value", 

1408 ) 

1409 

1410 # Make the request 

1411 response = await client.update_view(request=request) 

1412 

1413 # Handle the response 

1414 print(response) 

1415 

1416 Args: 

1417 request (Optional[Union[google.cloud.logging_v2.types.UpdateViewRequest, dict]]): 

1418 The request object. The parameters to ``UpdateView``. 

1419 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

1420 should be retried. 

1421 timeout (float): The timeout for this request. 

1422 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

1423 sent along with the request as metadata. Normally, each value must be of type `str`, 

1424 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

1425 be of type `bytes`. 

1426 

1427 Returns: 

1428 google.cloud.logging_v2.types.LogView: 

1429 Describes a view over log entries in 

1430 a bucket. 

1431 

1432 """ 

1433 # Create or coerce a protobuf request object. 

1434 # - Use the request object if provided (there's no risk of modifying the input as 

1435 # there are no flattened fields), or create one. 

1436 if not isinstance(request, logging_config.UpdateViewRequest): 

1437 request = logging_config.UpdateViewRequest(request) 

1438 

1439 # Wrap the RPC method; this adds retry and timeout information, 

1440 # and friendly error handling. 

1441 rpc = self._client._transport._wrapped_methods[ 

1442 self._client._transport.update_view 

1443 ] 

1444 

1445 # Certain fields should be provided within the metadata header; 

1446 # add these here. 

1447 metadata = tuple(metadata) + ( 

1448 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

1449 ) 

1450 

1451 # Validate the universe domain. 

1452 self._client._validate_universe_domain() 

1453 

1454 # Send the request. 

1455 response = await rpc( 

1456 request, 

1457 retry=retry, 

1458 timeout=timeout, 

1459 metadata=metadata, 

1460 ) 

1461 

1462 # Done; return the response. 

1463 return response 

1464 

1465 async def delete_view( 

1466 self, 

1467 request: Optional[Union[logging_config.DeleteViewRequest, dict]] = None, 

1468 *, 

1469 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1470 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

1471 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

1472 ) -> None: 

1473 r"""Deletes a view on a log bucket. If an ``UNAVAILABLE`` error is 

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

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

1476 minutes. 

1477 

1478 .. code-block:: python 

1479 

1480 # This snippet has been automatically generated and should be regarded as a 

1481 # code template only. 

1482 # It will require modifications to work: 

1483 # - It may require correct/in-range values for request initialization. 

1484 # - It may require specifying regional endpoints when creating the service 

1485 # client as shown in: 

1486 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

1487 from google.cloud import logging_v2 

1488 

1489 async def sample_delete_view(): 

1490 # Create a client 

1491 client = logging_v2.ConfigServiceV2AsyncClient() 

1492 

1493 # Initialize request argument(s) 

1494 request = logging_v2.DeleteViewRequest( 

1495 name="name_value", 

1496 ) 

1497 

1498 # Make the request 

1499 await client.delete_view(request=request) 

1500 

1501 Args: 

1502 request (Optional[Union[google.cloud.logging_v2.types.DeleteViewRequest, dict]]): 

1503 The request object. The parameters to ``DeleteView``. 

1504 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

1505 should be retried. 

1506 timeout (float): The timeout for this request. 

1507 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

1508 sent along with the request as metadata. Normally, each value must be of type `str`, 

1509 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

1510 be of type `bytes`. 

1511 """ 

1512 # Create or coerce a protobuf request object. 

1513 # - Use the request object if provided (there's no risk of modifying the input as 

1514 # there are no flattened fields), or create one. 

1515 if not isinstance(request, logging_config.DeleteViewRequest): 

1516 request = logging_config.DeleteViewRequest(request) 

1517 

1518 # Wrap the RPC method; this adds retry and timeout information, 

1519 # and friendly error handling. 

1520 rpc = self._client._transport._wrapped_methods[ 

1521 self._client._transport.delete_view 

1522 ] 

1523 

1524 # Certain fields should be provided within the metadata header; 

1525 # add these here. 

1526 metadata = tuple(metadata) + ( 

1527 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

1528 ) 

1529 

1530 # Validate the universe domain. 

1531 self._client._validate_universe_domain() 

1532 

1533 # Send the request. 

1534 await rpc( 

1535 request, 

1536 retry=retry, 

1537 timeout=timeout, 

1538 metadata=metadata, 

1539 ) 

1540 

1541 async def list_sinks( 

1542 self, 

1543 request: Optional[Union[logging_config.ListSinksRequest, dict]] = None, 

1544 *, 

1545 parent: Optional[str] = None, 

1546 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1547 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

1548 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

1549 ) -> pagers.ListSinksAsyncPager: 

1550 r"""Lists sinks. 

1551 

1552 .. code-block:: python 

1553 

1554 # This snippet has been automatically generated and should be regarded as a 

1555 # code template only. 

1556 # It will require modifications to work: 

1557 # - It may require correct/in-range values for request initialization. 

1558 # - It may require specifying regional endpoints when creating the service 

1559 # client as shown in: 

1560 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

1561 from google.cloud import logging_v2 

1562 

1563 async def sample_list_sinks(): 

1564 # Create a client 

1565 client = logging_v2.ConfigServiceV2AsyncClient() 

1566 

1567 # Initialize request argument(s) 

1568 request = logging_v2.ListSinksRequest( 

1569 parent="parent_value", 

1570 ) 

1571 

1572 # Make the request 

1573 page_result = client.list_sinks(request=request) 

1574 

1575 # Handle the response 

1576 async for response in page_result: 

1577 print(response) 

1578 

1579 Args: 

1580 request (Optional[Union[google.cloud.logging_v2.types.ListSinksRequest, dict]]): 

1581 The request object. The parameters to ``ListSinks``. 

1582 parent (:class:`str`): 

1583 Required. The parent resource whose sinks are to be 

1584 listed: 

1585 

1586 :: 

1587 

1588 "projects/[PROJECT_ID]" 

1589 "organizations/[ORGANIZATION_ID]" 

1590 "billingAccounts/[BILLING_ACCOUNT_ID]" 

1591 "folders/[FOLDER_ID]" 

1592 

1593 This corresponds to the ``parent`` field 

1594 on the ``request`` instance; if ``request`` is provided, this 

1595 should not be set. 

1596 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

1597 should be retried. 

1598 timeout (float): The timeout for this request. 

1599 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

1600 sent along with the request as metadata. Normally, each value must be of type `str`, 

1601 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

1602 be of type `bytes`. 

1603 

1604 Returns: 

1605 google.cloud.logging_v2.services.config_service_v2.pagers.ListSinksAsyncPager: 

1606 Result returned from ListSinks. 

1607 

1608 Iterating over this object will yield results and 

1609 resolve additional pages automatically. 

1610 

1611 """ 

1612 # Create or coerce a protobuf request object. 

1613 # - Quick check: If we got a request object, we should *not* have 

1614 # gotten any keyword arguments that map to the request. 

1615 flattened_params = [parent] 

1616 has_flattened_params = ( 

1617 len([param for param in flattened_params if param is not None]) > 0 

1618 ) 

1619 if request is not None and has_flattened_params: 

1620 raise ValueError( 

1621 "If the `request` argument is set, then none of " 

1622 "the individual field arguments should be set." 

1623 ) 

1624 

1625 # - Use the request object if provided (there's no risk of modifying the input as 

1626 # there are no flattened fields), or create one. 

1627 if not isinstance(request, logging_config.ListSinksRequest): 

1628 request = logging_config.ListSinksRequest(request) 

1629 

1630 # If we have keyword arguments corresponding to fields on the 

1631 # request, apply these. 

1632 if parent is not None: 

1633 request.parent = parent 

1634 

1635 # Wrap the RPC method; this adds retry and timeout information, 

1636 # and friendly error handling. 

1637 rpc = self._client._transport._wrapped_methods[ 

1638 self._client._transport.list_sinks 

1639 ] 

1640 

1641 # Certain fields should be provided within the metadata header; 

1642 # add these here. 

1643 metadata = tuple(metadata) + ( 

1644 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), 

1645 ) 

1646 

1647 # Validate the universe domain. 

1648 self._client._validate_universe_domain() 

1649 

1650 # Send the request. 

1651 response = await rpc( 

1652 request, 

1653 retry=retry, 

1654 timeout=timeout, 

1655 metadata=metadata, 

1656 ) 

1657 

1658 # This method is paged; wrap the response in a pager, which provides 

1659 # an `__aiter__` convenience method. 

1660 response = pagers.ListSinksAsyncPager( 

1661 method=rpc, 

1662 request=request, 

1663 response=response, 

1664 retry=retry, 

1665 timeout=timeout, 

1666 metadata=metadata, 

1667 ) 

1668 

1669 # Done; return the response. 

1670 return response 

1671 

1672 async def get_sink( 

1673 self, 

1674 request: Optional[Union[logging_config.GetSinkRequest, dict]] = None, 

1675 *, 

1676 sink_name: Optional[str] = None, 

1677 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1678 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

1679 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

1680 ) -> logging_config.LogSink: 

1681 r"""Gets a sink. 

1682 

1683 .. code-block:: python 

1684 

1685 # This snippet has been automatically generated and should be regarded as a 

1686 # code template only. 

1687 # It will require modifications to work: 

1688 # - It may require correct/in-range values for request initialization. 

1689 # - It may require specifying regional endpoints when creating the service 

1690 # client as shown in: 

1691 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

1692 from google.cloud import logging_v2 

1693 

1694 async def sample_get_sink(): 

1695 # Create a client 

1696 client = logging_v2.ConfigServiceV2AsyncClient() 

1697 

1698 # Initialize request argument(s) 

1699 request = logging_v2.GetSinkRequest( 

1700 sink_name="sink_name_value", 

1701 ) 

1702 

1703 # Make the request 

1704 response = await client.get_sink(request=request) 

1705 

1706 # Handle the response 

1707 print(response) 

1708 

1709 Args: 

1710 request (Optional[Union[google.cloud.logging_v2.types.GetSinkRequest, dict]]): 

1711 The request object. The parameters to ``GetSink``. 

1712 sink_name (:class:`str`): 

1713 Required. The resource name of the sink: 

1714 

1715 :: 

1716 

1717 "projects/[PROJECT_ID]/sinks/[SINK_ID]" 

1718 "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" 

1719 "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" 

1720 "folders/[FOLDER_ID]/sinks/[SINK_ID]" 

1721 

1722 For example: 

1723 

1724 ``"projects/my-project/sinks/my-sink"`` 

1725 

1726 This corresponds to the ``sink_name`` field 

1727 on the ``request`` instance; if ``request`` is provided, this 

1728 should not be set. 

1729 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

1730 should be retried. 

1731 timeout (float): The timeout for this request. 

1732 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

1733 sent along with the request as metadata. Normally, each value must be of type `str`, 

1734 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

1735 be of type `bytes`. 

1736 

1737 Returns: 

1738 google.cloud.logging_v2.types.LogSink: 

1739 Describes a sink used to export log 

1740 entries to one of the following 

1741 destinations in any project: a Cloud 

1742 Storage bucket, a BigQuery dataset, a 

1743 Pub/Sub topic or a Cloud Logging log 

1744 bucket. A logs filter controls which log 

1745 entries are exported. The sink must be 

1746 created within a project, organization, 

1747 billing account, or folder. 

1748 

1749 """ 

1750 # Create or coerce a protobuf request object. 

1751 # - Quick check: If we got a request object, we should *not* have 

1752 # gotten any keyword arguments that map to the request. 

1753 flattened_params = [sink_name] 

1754 has_flattened_params = ( 

1755 len([param for param in flattened_params if param is not None]) > 0 

1756 ) 

1757 if request is not None and has_flattened_params: 

1758 raise ValueError( 

1759 "If the `request` argument is set, then none of " 

1760 "the individual field arguments should be set." 

1761 ) 

1762 

1763 # - Use the request object if provided (there's no risk of modifying the input as 

1764 # there are no flattened fields), or create one. 

1765 if not isinstance(request, logging_config.GetSinkRequest): 

1766 request = logging_config.GetSinkRequest(request) 

1767 

1768 # If we have keyword arguments corresponding to fields on the 

1769 # request, apply these. 

1770 if sink_name is not None: 

1771 request.sink_name = sink_name 

1772 

1773 # Wrap the RPC method; this adds retry and timeout information, 

1774 # and friendly error handling. 

1775 rpc = self._client._transport._wrapped_methods[self._client._transport.get_sink] 

1776 

1777 # Certain fields should be provided within the metadata header; 

1778 # add these here. 

1779 metadata = tuple(metadata) + ( 

1780 gapic_v1.routing_header.to_grpc_metadata( 

1781 (("sink_name", request.sink_name),) 

1782 ), 

1783 ) 

1784 

1785 # Validate the universe domain. 

1786 self._client._validate_universe_domain() 

1787 

1788 # Send the request. 

1789 response = await rpc( 

1790 request, 

1791 retry=retry, 

1792 timeout=timeout, 

1793 metadata=metadata, 

1794 ) 

1795 

1796 # Done; return the response. 

1797 return response 

1798 

1799 async def create_sink( 

1800 self, 

1801 request: Optional[Union[logging_config.CreateSinkRequest, dict]] = None, 

1802 *, 

1803 parent: Optional[str] = None, 

1804 sink: Optional[logging_config.LogSink] = None, 

1805 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1806 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

1807 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

1808 ) -> logging_config.LogSink: 

1809 r"""Creates a sink that exports specified log entries to a 

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

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

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

1813 entries only from the resource owning the sink. 

1814 

1815 .. code-block:: python 

1816 

1817 # This snippet has been automatically generated and should be regarded as a 

1818 # code template only. 

1819 # It will require modifications to work: 

1820 # - It may require correct/in-range values for request initialization. 

1821 # - It may require specifying regional endpoints when creating the service 

1822 # client as shown in: 

1823 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

1824 from google.cloud import logging_v2 

1825 

1826 async def sample_create_sink(): 

1827 # Create a client 

1828 client = logging_v2.ConfigServiceV2AsyncClient() 

1829 

1830 # Initialize request argument(s) 

1831 sink = logging_v2.LogSink() 

1832 sink.name = "name_value" 

1833 sink.destination = "destination_value" 

1834 

1835 request = logging_v2.CreateSinkRequest( 

1836 parent="parent_value", 

1837 sink=sink, 

1838 ) 

1839 

1840 # Make the request 

1841 response = await client.create_sink(request=request) 

1842 

1843 # Handle the response 

1844 print(response) 

1845 

1846 Args: 

1847 request (Optional[Union[google.cloud.logging_v2.types.CreateSinkRequest, dict]]): 

1848 The request object. The parameters to ``CreateSink``. 

1849 parent (:class:`str`): 

1850 Required. The resource in which to create the sink: 

1851 

1852 :: 

1853 

1854 "projects/[PROJECT_ID]" 

1855 "organizations/[ORGANIZATION_ID]" 

1856 "billingAccounts/[BILLING_ACCOUNT_ID]" 

1857 "folders/[FOLDER_ID]" 

1858 

1859 For examples: 

1860 

1861 ``"projects/my-project"`` ``"organizations/123456789"`` 

1862 

1863 This corresponds to the ``parent`` field 

1864 on the ``request`` instance; if ``request`` is provided, this 

1865 should not be set. 

1866 sink (:class:`google.cloud.logging_v2.types.LogSink`): 

1867 Required. The new sink, whose ``name`` parameter is a 

1868 sink identifier that is not already in use. 

1869 

1870 This corresponds to the ``sink`` field 

1871 on the ``request`` instance; if ``request`` is provided, this 

1872 should not be set. 

1873 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

1874 should be retried. 

1875 timeout (float): The timeout for this request. 

1876 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

1877 sent along with the request as metadata. Normally, each value must be of type `str`, 

1878 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

1879 be of type `bytes`. 

1880 

1881 Returns: 

1882 google.cloud.logging_v2.types.LogSink: 

1883 Describes a sink used to export log 

1884 entries to one of the following 

1885 destinations in any project: a Cloud 

1886 Storage bucket, a BigQuery dataset, a 

1887 Pub/Sub topic or a Cloud Logging log 

1888 bucket. A logs filter controls which log 

1889 entries are exported. The sink must be 

1890 created within a project, organization, 

1891 billing account, or folder. 

1892 

1893 """ 

1894 # Create or coerce a protobuf request object. 

1895 # - Quick check: If we got a request object, we should *not* have 

1896 # gotten any keyword arguments that map to the request. 

1897 flattened_params = [parent, sink] 

1898 has_flattened_params = ( 

1899 len([param for param in flattened_params if param is not None]) > 0 

1900 ) 

1901 if request is not None and has_flattened_params: 

1902 raise ValueError( 

1903 "If the `request` argument is set, then none of " 

1904 "the individual field arguments should be set." 

1905 ) 

1906 

1907 # - Use the request object if provided (there's no risk of modifying the input as 

1908 # there are no flattened fields), or create one. 

1909 if not isinstance(request, logging_config.CreateSinkRequest): 

1910 request = logging_config.CreateSinkRequest(request) 

1911 

1912 # If we have keyword arguments corresponding to fields on the 

1913 # request, apply these. 

1914 if parent is not None: 

1915 request.parent = parent 

1916 if sink is not None: 

1917 request.sink = sink 

1918 

1919 # Wrap the RPC method; this adds retry and timeout information, 

1920 # and friendly error handling. 

1921 rpc = self._client._transport._wrapped_methods[ 

1922 self._client._transport.create_sink 

1923 ] 

1924 

1925 # Certain fields should be provided within the metadata header; 

1926 # add these here. 

1927 metadata = tuple(metadata) + ( 

1928 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), 

1929 ) 

1930 

1931 # Validate the universe domain. 

1932 self._client._validate_universe_domain() 

1933 

1934 # Send the request. 

1935 response = await rpc( 

1936 request, 

1937 retry=retry, 

1938 timeout=timeout, 

1939 metadata=metadata, 

1940 ) 

1941 

1942 # Done; return the response. 

1943 return response 

1944 

1945 async def update_sink( 

1946 self, 

1947 request: Optional[Union[logging_config.UpdateSinkRequest, dict]] = None, 

1948 *, 

1949 sink_name: Optional[str] = None, 

1950 sink: Optional[logging_config.LogSink] = None, 

1951 update_mask: Optional[field_mask_pb2.FieldMask] = None, 

1952 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1953 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

1954 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

1955 ) -> logging_config.LogSink: 

1956 r"""Updates a sink. This method replaces the following fields in the 

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

1958 and ``filter``. 

1959 

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

1961 the ``unique_writer_identity`` field. 

1962 

1963 .. code-block:: python 

1964 

1965 # This snippet has been automatically generated and should be regarded as a 

1966 # code template only. 

1967 # It will require modifications to work: 

1968 # - It may require correct/in-range values for request initialization. 

1969 # - It may require specifying regional endpoints when creating the service 

1970 # client as shown in: 

1971 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

1972 from google.cloud import logging_v2 

1973 

1974 async def sample_update_sink(): 

1975 # Create a client 

1976 client = logging_v2.ConfigServiceV2AsyncClient() 

1977 

1978 # Initialize request argument(s) 

1979 sink = logging_v2.LogSink() 

1980 sink.name = "name_value" 

1981 sink.destination = "destination_value" 

1982 

1983 request = logging_v2.UpdateSinkRequest( 

1984 sink_name="sink_name_value", 

1985 sink=sink, 

1986 ) 

1987 

1988 # Make the request 

1989 response = await client.update_sink(request=request) 

1990 

1991 # Handle the response 

1992 print(response) 

1993 

1994 Args: 

1995 request (Optional[Union[google.cloud.logging_v2.types.UpdateSinkRequest, dict]]): 

1996 The request object. The parameters to ``UpdateSink``. 

1997 sink_name (:class:`str`): 

1998 Required. The full resource name of the sink to update, 

1999 including the parent resource and the sink identifier: 

2000 

2001 :: 

2002 

2003 "projects/[PROJECT_ID]/sinks/[SINK_ID]" 

2004 "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" 

2005 "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" 

2006 "folders/[FOLDER_ID]/sinks/[SINK_ID]" 

2007 

2008 For example: 

2009 

2010 ``"projects/my-project/sinks/my-sink"`` 

2011 

2012 This corresponds to the ``sink_name`` field 

2013 on the ``request`` instance; if ``request`` is provided, this 

2014 should not be set. 

2015 sink (:class:`google.cloud.logging_v2.types.LogSink`): 

2016 Required. The updated sink, whose name is the same 

2017 identifier that appears as part of ``sink_name``. 

2018 

2019 This corresponds to the ``sink`` field 

2020 on the ``request`` instance; if ``request`` is provided, this 

2021 should not be set. 

2022 update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): 

2023 Optional. Field mask that specifies the fields in 

2024 ``sink`` that need an update. A sink field will be 

2025 overwritten if, and only if, it is in the update mask. 

2026 ``name`` and output only fields cannot be updated. 

2027 

2028 An empty ``updateMask`` is temporarily treated as using 

2029 the following mask for backwards compatibility purposes: 

2030 

2031 ``destination,filter,includeChildren`` 

2032 

2033 At some point in the future, behavior will be removed 

2034 and specifying an empty ``updateMask`` will be an error. 

2035 

2036 For a detailed ``FieldMask`` definition, see 

2037 https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMask 

2038 

2039 For example: ``updateMask=filter`` 

2040 

2041 This corresponds to the ``update_mask`` field 

2042 on the ``request`` instance; if ``request`` is provided, this 

2043 should not be set. 

2044 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

2045 should be retried. 

2046 timeout (float): The timeout for this request. 

2047 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

2048 sent along with the request as metadata. Normally, each value must be of type `str`, 

2049 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

2050 be of type `bytes`. 

2051 

2052 Returns: 

2053 google.cloud.logging_v2.types.LogSink: 

2054 Describes a sink used to export log 

2055 entries to one of the following 

2056 destinations in any project: a Cloud 

2057 Storage bucket, a BigQuery dataset, a 

2058 Pub/Sub topic or a Cloud Logging log 

2059 bucket. A logs filter controls which log 

2060 entries are exported. The sink must be 

2061 created within a project, organization, 

2062 billing account, or folder. 

2063 

2064 """ 

2065 # Create or coerce a protobuf request object. 

2066 # - Quick check: If we got a request object, we should *not* have 

2067 # gotten any keyword arguments that map to the request. 

2068 flattened_params = [sink_name, sink, update_mask] 

2069 has_flattened_params = ( 

2070 len([param for param in flattened_params if param is not None]) > 0 

2071 ) 

2072 if request is not None and has_flattened_params: 

2073 raise ValueError( 

2074 "If the `request` argument is set, then none of " 

2075 "the individual field arguments should be set." 

2076 ) 

2077 

2078 # - Use the request object if provided (there's no risk of modifying the input as 

2079 # there are no flattened fields), or create one. 

2080 if not isinstance(request, logging_config.UpdateSinkRequest): 

2081 request = logging_config.UpdateSinkRequest(request) 

2082 

2083 # If we have keyword arguments corresponding to fields on the 

2084 # request, apply these. 

2085 if sink_name is not None: 

2086 request.sink_name = sink_name 

2087 if sink is not None: 

2088 request.sink = sink 

2089 if update_mask is not None: 

2090 request.update_mask = update_mask 

2091 

2092 # Wrap the RPC method; this adds retry and timeout information, 

2093 # and friendly error handling. 

2094 rpc = self._client._transport._wrapped_methods[ 

2095 self._client._transport.update_sink 

2096 ] 

2097 

2098 # Certain fields should be provided within the metadata header; 

2099 # add these here. 

2100 metadata = tuple(metadata) + ( 

2101 gapic_v1.routing_header.to_grpc_metadata( 

2102 (("sink_name", request.sink_name),) 

2103 ), 

2104 ) 

2105 

2106 # Validate the universe domain. 

2107 self._client._validate_universe_domain() 

2108 

2109 # Send the request. 

2110 response = await rpc( 

2111 request, 

2112 retry=retry, 

2113 timeout=timeout, 

2114 metadata=metadata, 

2115 ) 

2116 

2117 # Done; return the response. 

2118 return response 

2119 

2120 async def delete_sink( 

2121 self, 

2122 request: Optional[Union[logging_config.DeleteSinkRequest, dict]] = None, 

2123 *, 

2124 sink_name: Optional[str] = None, 

2125 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

2126 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

2127 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

2128 ) -> None: 

2129 r"""Deletes a sink. If the sink has a unique ``writer_identity``, 

2130 then that service account is also deleted. 

2131 

2132 .. code-block:: python 

2133 

2134 # This snippet has been automatically generated and should be regarded as a 

2135 # code template only. 

2136 # It will require modifications to work: 

2137 # - It may require correct/in-range values for request initialization. 

2138 # - It may require specifying regional endpoints when creating the service 

2139 # client as shown in: 

2140 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

2141 from google.cloud import logging_v2 

2142 

2143 async def sample_delete_sink(): 

2144 # Create a client 

2145 client = logging_v2.ConfigServiceV2AsyncClient() 

2146 

2147 # Initialize request argument(s) 

2148 request = logging_v2.DeleteSinkRequest( 

2149 sink_name="sink_name_value", 

2150 ) 

2151 

2152 # Make the request 

2153 await client.delete_sink(request=request) 

2154 

2155 Args: 

2156 request (Optional[Union[google.cloud.logging_v2.types.DeleteSinkRequest, dict]]): 

2157 The request object. The parameters to ``DeleteSink``. 

2158 sink_name (:class:`str`): 

2159 Required. The full resource name of the sink to delete, 

2160 including the parent resource and the sink identifier: 

2161 

2162 :: 

2163 

2164 "projects/[PROJECT_ID]/sinks/[SINK_ID]" 

2165 "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" 

2166 "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" 

2167 "folders/[FOLDER_ID]/sinks/[SINK_ID]" 

2168 

2169 For example: 

2170 

2171 ``"projects/my-project/sinks/my-sink"`` 

2172 

2173 This corresponds to the ``sink_name`` field 

2174 on the ``request`` instance; if ``request`` is provided, this 

2175 should not be set. 

2176 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

2177 should be retried. 

2178 timeout (float): The timeout for this request. 

2179 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

2180 sent along with the request as metadata. Normally, each value must be of type `str`, 

2181 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

2182 be of type `bytes`. 

2183 """ 

2184 # Create or coerce a protobuf request object. 

2185 # - Quick check: If we got a request object, we should *not* have 

2186 # gotten any keyword arguments that map to the request. 

2187 flattened_params = [sink_name] 

2188 has_flattened_params = ( 

2189 len([param for param in flattened_params if param is not None]) > 0 

2190 ) 

2191 if request is not None and has_flattened_params: 

2192 raise ValueError( 

2193 "If the `request` argument is set, then none of " 

2194 "the individual field arguments should be set." 

2195 ) 

2196 

2197 # - Use the request object if provided (there's no risk of modifying the input as 

2198 # there are no flattened fields), or create one. 

2199 if not isinstance(request, logging_config.DeleteSinkRequest): 

2200 request = logging_config.DeleteSinkRequest(request) 

2201 

2202 # If we have keyword arguments corresponding to fields on the 

2203 # request, apply these. 

2204 if sink_name is not None: 

2205 request.sink_name = sink_name 

2206 

2207 # Wrap the RPC method; this adds retry and timeout information, 

2208 # and friendly error handling. 

2209 rpc = self._client._transport._wrapped_methods[ 

2210 self._client._transport.delete_sink 

2211 ] 

2212 

2213 # Certain fields should be provided within the metadata header; 

2214 # add these here. 

2215 metadata = tuple(metadata) + ( 

2216 gapic_v1.routing_header.to_grpc_metadata( 

2217 (("sink_name", request.sink_name),) 

2218 ), 

2219 ) 

2220 

2221 # Validate the universe domain. 

2222 self._client._validate_universe_domain() 

2223 

2224 # Send the request. 

2225 await rpc( 

2226 request, 

2227 retry=retry, 

2228 timeout=timeout, 

2229 metadata=metadata, 

2230 ) 

2231 

2232 async def create_link( 

2233 self, 

2234 request: Optional[Union[logging_config.CreateLinkRequest, dict]] = None, 

2235 *, 

2236 parent: Optional[str] = None, 

2237 link: Optional[logging_config.Link] = None, 

2238 link_id: Optional[str] = None, 

2239 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

2240 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

2241 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

2242 ) -> operation_async.AsyncOperation: 

2243 r"""Asynchronously creates a linked dataset in BigQuery 

2244 which makes it possible to use BigQuery to read the logs 

2245 stored in the log bucket. A log bucket may currently 

2246 only contain one link. 

2247 

2248 .. code-block:: python 

2249 

2250 # This snippet has been automatically generated and should be regarded as a 

2251 # code template only. 

2252 # It will require modifications to work: 

2253 # - It may require correct/in-range values for request initialization. 

2254 # - It may require specifying regional endpoints when creating the service 

2255 # client as shown in: 

2256 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

2257 from google.cloud import logging_v2 

2258 

2259 async def sample_create_link(): 

2260 # Create a client 

2261 client = logging_v2.ConfigServiceV2AsyncClient() 

2262 

2263 # Initialize request argument(s) 

2264 request = logging_v2.CreateLinkRequest( 

2265 parent="parent_value", 

2266 link_id="link_id_value", 

2267 ) 

2268 

2269 # Make the request 

2270 operation = client.create_link(request=request) 

2271 

2272 print("Waiting for operation to complete...") 

2273 

2274 response = (await operation).result() 

2275 

2276 # Handle the response 

2277 print(response) 

2278 

2279 Args: 

2280 request (Optional[Union[google.cloud.logging_v2.types.CreateLinkRequest, dict]]): 

2281 The request object. The parameters to CreateLink. 

2282 parent (:class:`str`): 

2283 Required. The full resource name of the bucket to create 

2284 a link for. 

2285 

2286 :: 

2287 

2288 "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" 

2289 "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" 

2290 "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" 

2291 "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" 

2292 

2293 This corresponds to the ``parent`` field 

2294 on the ``request`` instance; if ``request`` is provided, this 

2295 should not be set. 

2296 link (:class:`google.cloud.logging_v2.types.Link`): 

2297 Required. The new link. 

2298 This corresponds to the ``link`` field 

2299 on the ``request`` instance; if ``request`` is provided, this 

2300 should not be set. 

2301 link_id (:class:`str`): 

2302 Required. The ID to use for the link. The link_id can 

2303 have up to 100 characters. A valid link_id must only 

2304 have alphanumeric characters and underscores within it. 

2305 

2306 This corresponds to the ``link_id`` field 

2307 on the ``request`` instance; if ``request`` is provided, this 

2308 should not be set. 

2309 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

2310 should be retried. 

2311 timeout (float): The timeout for this request. 

2312 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

2313 sent along with the request as metadata. Normally, each value must be of type `str`, 

2314 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

2315 be of type `bytes`. 

2316 

2317 Returns: 

2318 google.api_core.operation_async.AsyncOperation: 

2319 An object representing a long-running operation. 

2320 

2321 The result type for the operation will be 

2322 :class:`google.cloud.logging_v2.types.Link` Describes a 

2323 link connected to an analytics enabled bucket. 

2324 

2325 """ 

2326 # Create or coerce a protobuf request object. 

2327 # - Quick check: If we got a request object, we should *not* have 

2328 # gotten any keyword arguments that map to the request. 

2329 flattened_params = [parent, link, link_id] 

2330 has_flattened_params = ( 

2331 len([param for param in flattened_params if param is not None]) > 0 

2332 ) 

2333 if request is not None and has_flattened_params: 

2334 raise ValueError( 

2335 "If the `request` argument is set, then none of " 

2336 "the individual field arguments should be set." 

2337 ) 

2338 

2339 # - Use the request object if provided (there's no risk of modifying the input as 

2340 # there are no flattened fields), or create one. 

2341 if not isinstance(request, logging_config.CreateLinkRequest): 

2342 request = logging_config.CreateLinkRequest(request) 

2343 

2344 # If we have keyword arguments corresponding to fields on the 

2345 # request, apply these. 

2346 if parent is not None: 

2347 request.parent = parent 

2348 if link is not None: 

2349 request.link = link 

2350 if link_id is not None: 

2351 request.link_id = link_id 

2352 

2353 # Wrap the RPC method; this adds retry and timeout information, 

2354 # and friendly error handling. 

2355 rpc = self._client._transport._wrapped_methods[ 

2356 self._client._transport.create_link 

2357 ] 

2358 

2359 # Certain fields should be provided within the metadata header; 

2360 # add these here. 

2361 metadata = tuple(metadata) + ( 

2362 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), 

2363 ) 

2364 

2365 # Validate the universe domain. 

2366 self._client._validate_universe_domain() 

2367 

2368 # Send the request. 

2369 response = await rpc( 

2370 request, 

2371 retry=retry, 

2372 timeout=timeout, 

2373 metadata=metadata, 

2374 ) 

2375 

2376 # Wrap the response in an operation future. 

2377 response = operation_async.from_gapic( 

2378 response, 

2379 self._client._transport.operations_client, 

2380 logging_config.Link, 

2381 metadata_type=logging_config.LinkMetadata, 

2382 ) 

2383 

2384 # Done; return the response. 

2385 return response 

2386 

2387 async def delete_link( 

2388 self, 

2389 request: Optional[Union[logging_config.DeleteLinkRequest, dict]] = None, 

2390 *, 

2391 name: Optional[str] = None, 

2392 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

2393 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

2394 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

2395 ) -> operation_async.AsyncOperation: 

2396 r"""Deletes a link. This will also delete the 

2397 corresponding BigQuery linked dataset. 

2398 

2399 .. code-block:: python 

2400 

2401 # This snippet has been automatically generated and should be regarded as a 

2402 # code template only. 

2403 # It will require modifications to work: 

2404 # - It may require correct/in-range values for request initialization. 

2405 # - It may require specifying regional endpoints when creating the service 

2406 # client as shown in: 

2407 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

2408 from google.cloud import logging_v2 

2409 

2410 async def sample_delete_link(): 

2411 # Create a client 

2412 client = logging_v2.ConfigServiceV2AsyncClient() 

2413 

2414 # Initialize request argument(s) 

2415 request = logging_v2.DeleteLinkRequest( 

2416 name="name_value", 

2417 ) 

2418 

2419 # Make the request 

2420 operation = client.delete_link(request=request) 

2421 

2422 print("Waiting for operation to complete...") 

2423 

2424 response = (await operation).result() 

2425 

2426 # Handle the response 

2427 print(response) 

2428 

2429 Args: 

2430 request (Optional[Union[google.cloud.logging_v2.types.DeleteLinkRequest, dict]]): 

2431 The request object. The parameters to DeleteLink. 

2432 name (:class:`str`): 

2433 Required. The full resource name of the link to delete. 

2434 

2435 "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID]" 

2436 "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID]" 

2437 "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID]" 

2438 "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID]" 

2439 

2440 This corresponds to the ``name`` field 

2441 on the ``request`` instance; if ``request`` is provided, this 

2442 should not be set. 

2443 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

2444 should be retried. 

2445 timeout (float): The timeout for this request. 

2446 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

2447 sent along with the request as metadata. Normally, each value must be of type `str`, 

2448 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

2449 be of type `bytes`. 

2450 

2451 Returns: 

2452 google.api_core.operation_async.AsyncOperation: 

2453 An object representing a long-running operation. 

2454 

2455 The result type for the operation will be :class:`google.protobuf.empty_pb2.Empty` A generic empty message that you can re-use to avoid defining duplicated 

2456 empty messages in your APIs. A typical example is to 

2457 use it as the request or the response type of an API 

2458 method. For instance: 

2459 

2460 service Foo { 

2461 rpc Bar(google.protobuf.Empty) returns 

2462 (google.protobuf.Empty); 

2463 

2464 } 

2465 

2466 """ 

2467 # Create or coerce a protobuf request object. 

2468 # - Quick check: If we got a request object, we should *not* have 

2469 # gotten any keyword arguments that map to the request. 

2470 flattened_params = [name] 

2471 has_flattened_params = ( 

2472 len([param for param in flattened_params if param is not None]) > 0 

2473 ) 

2474 if request is not None and has_flattened_params: 

2475 raise ValueError( 

2476 "If the `request` argument is set, then none of " 

2477 "the individual field arguments should be set." 

2478 ) 

2479 

2480 # - Use the request object if provided (there's no risk of modifying the input as 

2481 # there are no flattened fields), or create one. 

2482 if not isinstance(request, logging_config.DeleteLinkRequest): 

2483 request = logging_config.DeleteLinkRequest(request) 

2484 

2485 # If we have keyword arguments corresponding to fields on the 

2486 # request, apply these. 

2487 if name is not None: 

2488 request.name = name 

2489 

2490 # Wrap the RPC method; this adds retry and timeout information, 

2491 # and friendly error handling. 

2492 rpc = self._client._transport._wrapped_methods[ 

2493 self._client._transport.delete_link 

2494 ] 

2495 

2496 # Certain fields should be provided within the metadata header; 

2497 # add these here. 

2498 metadata = tuple(metadata) + ( 

2499 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

2500 ) 

2501 

2502 # Validate the universe domain. 

2503 self._client._validate_universe_domain() 

2504 

2505 # Send the request. 

2506 response = await rpc( 

2507 request, 

2508 retry=retry, 

2509 timeout=timeout, 

2510 metadata=metadata, 

2511 ) 

2512 

2513 # Wrap the response in an operation future. 

2514 response = operation_async.from_gapic( 

2515 response, 

2516 self._client._transport.operations_client, 

2517 empty_pb2.Empty, 

2518 metadata_type=logging_config.LinkMetadata, 

2519 ) 

2520 

2521 # Done; return the response. 

2522 return response 

2523 

2524 async def list_links( 

2525 self, 

2526 request: Optional[Union[logging_config.ListLinksRequest, dict]] = None, 

2527 *, 

2528 parent: Optional[str] = None, 

2529 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

2530 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

2531 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

2532 ) -> pagers.ListLinksAsyncPager: 

2533 r"""Lists links. 

2534 

2535 .. code-block:: python 

2536 

2537 # This snippet has been automatically generated and should be regarded as a 

2538 # code template only. 

2539 # It will require modifications to work: 

2540 # - It may require correct/in-range values for request initialization. 

2541 # - It may require specifying regional endpoints when creating the service 

2542 # client as shown in: 

2543 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

2544 from google.cloud import logging_v2 

2545 

2546 async def sample_list_links(): 

2547 # Create a client 

2548 client = logging_v2.ConfigServiceV2AsyncClient() 

2549 

2550 # Initialize request argument(s) 

2551 request = logging_v2.ListLinksRequest( 

2552 parent="parent_value", 

2553 ) 

2554 

2555 # Make the request 

2556 page_result = client.list_links(request=request) 

2557 

2558 # Handle the response 

2559 async for response in page_result: 

2560 print(response) 

2561 

2562 Args: 

2563 request (Optional[Union[google.cloud.logging_v2.types.ListLinksRequest, dict]]): 

2564 The request object. The parameters to ListLinks. 

2565 parent (:class:`str`): 

2566 Required. The parent resource whose links are to be 

2567 listed: 

2568 

2569 "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/" 

2570 "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/" 

2571 "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/" 

2572 "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/ 

2573 

2574 This corresponds to the ``parent`` field 

2575 on the ``request`` instance; if ``request`` is provided, this 

2576 should not be set. 

2577 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

2578 should be retried. 

2579 timeout (float): The timeout for this request. 

2580 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

2581 sent along with the request as metadata. Normally, each value must be of type `str`, 

2582 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

2583 be of type `bytes`. 

2584 

2585 Returns: 

2586 google.cloud.logging_v2.services.config_service_v2.pagers.ListLinksAsyncPager: 

2587 The response from ListLinks. 

2588 

2589 Iterating over this object will yield 

2590 results and resolve additional pages 

2591 automatically. 

2592 

2593 """ 

2594 # Create or coerce a protobuf request object. 

2595 # - Quick check: If we got a request object, we should *not* have 

2596 # gotten any keyword arguments that map to the request. 

2597 flattened_params = [parent] 

2598 has_flattened_params = ( 

2599 len([param for param in flattened_params if param is not None]) > 0 

2600 ) 

2601 if request is not None and has_flattened_params: 

2602 raise ValueError( 

2603 "If the `request` argument is set, then none of " 

2604 "the individual field arguments should be set." 

2605 ) 

2606 

2607 # - Use the request object if provided (there's no risk of modifying the input as 

2608 # there are no flattened fields), or create one. 

2609 if not isinstance(request, logging_config.ListLinksRequest): 

2610 request = logging_config.ListLinksRequest(request) 

2611 

2612 # If we have keyword arguments corresponding to fields on the 

2613 # request, apply these. 

2614 if parent is not None: 

2615 request.parent = parent 

2616 

2617 # Wrap the RPC method; this adds retry and timeout information, 

2618 # and friendly error handling. 

2619 rpc = self._client._transport._wrapped_methods[ 

2620 self._client._transport.list_links 

2621 ] 

2622 

2623 # Certain fields should be provided within the metadata header; 

2624 # add these here. 

2625 metadata = tuple(metadata) + ( 

2626 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), 

2627 ) 

2628 

2629 # Validate the universe domain. 

2630 self._client._validate_universe_domain() 

2631 

2632 # Send the request. 

2633 response = await rpc( 

2634 request, 

2635 retry=retry, 

2636 timeout=timeout, 

2637 metadata=metadata, 

2638 ) 

2639 

2640 # This method is paged; wrap the response in a pager, which provides 

2641 # an `__aiter__` convenience method. 

2642 response = pagers.ListLinksAsyncPager( 

2643 method=rpc, 

2644 request=request, 

2645 response=response, 

2646 retry=retry, 

2647 timeout=timeout, 

2648 metadata=metadata, 

2649 ) 

2650 

2651 # Done; return the response. 

2652 return response 

2653 

2654 async def get_link( 

2655 self, 

2656 request: Optional[Union[logging_config.GetLinkRequest, dict]] = None, 

2657 *, 

2658 name: Optional[str] = None, 

2659 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

2660 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

2661 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

2662 ) -> logging_config.Link: 

2663 r"""Gets a link. 

2664 

2665 .. code-block:: python 

2666 

2667 # This snippet has been automatically generated and should be regarded as a 

2668 # code template only. 

2669 # It will require modifications to work: 

2670 # - It may require correct/in-range values for request initialization. 

2671 # - It may require specifying regional endpoints when creating the service 

2672 # client as shown in: 

2673 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

2674 from google.cloud import logging_v2 

2675 

2676 async def sample_get_link(): 

2677 # Create a client 

2678 client = logging_v2.ConfigServiceV2AsyncClient() 

2679 

2680 # Initialize request argument(s) 

2681 request = logging_v2.GetLinkRequest( 

2682 name="name_value", 

2683 ) 

2684 

2685 # Make the request 

2686 response = await client.get_link(request=request) 

2687 

2688 # Handle the response 

2689 print(response) 

2690 

2691 Args: 

2692 request (Optional[Union[google.cloud.logging_v2.types.GetLinkRequest, dict]]): 

2693 The request object. The parameters to GetLink. 

2694 name (:class:`str`): 

2695 Required. The resource name of the link: 

2696 

2697 "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID]" 

2698 "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID]" 

2699 "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID]" 

2700 "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID] 

2701 

2702 This corresponds to the ``name`` field 

2703 on the ``request`` instance; if ``request`` is provided, this 

2704 should not be set. 

2705 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

2706 should be retried. 

2707 timeout (float): The timeout for this request. 

2708 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

2709 sent along with the request as metadata. Normally, each value must be of type `str`, 

2710 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

2711 be of type `bytes`. 

2712 

2713 Returns: 

2714 google.cloud.logging_v2.types.Link: 

2715 Describes a link connected to an 

2716 analytics enabled bucket. 

2717 

2718 """ 

2719 # Create or coerce a protobuf request object. 

2720 # - Quick check: If we got a request object, we should *not* have 

2721 # gotten any keyword arguments that map to the request. 

2722 flattened_params = [name] 

2723 has_flattened_params = ( 

2724 len([param for param in flattened_params if param is not None]) > 0 

2725 ) 

2726 if request is not None and has_flattened_params: 

2727 raise ValueError( 

2728 "If the `request` argument is set, then none of " 

2729 "the individual field arguments should be set." 

2730 ) 

2731 

2732 # - Use the request object if provided (there's no risk of modifying the input as 

2733 # there are no flattened fields), or create one. 

2734 if not isinstance(request, logging_config.GetLinkRequest): 

2735 request = logging_config.GetLinkRequest(request) 

2736 

2737 # If we have keyword arguments corresponding to fields on the 

2738 # request, apply these. 

2739 if name is not None: 

2740 request.name = name 

2741 

2742 # Wrap the RPC method; this adds retry and timeout information, 

2743 # and friendly error handling. 

2744 rpc = self._client._transport._wrapped_methods[self._client._transport.get_link] 

2745 

2746 # Certain fields should be provided within the metadata header; 

2747 # add these here. 

2748 metadata = tuple(metadata) + ( 

2749 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

2750 ) 

2751 

2752 # Validate the universe domain. 

2753 self._client._validate_universe_domain() 

2754 

2755 # Send the request. 

2756 response = await rpc( 

2757 request, 

2758 retry=retry, 

2759 timeout=timeout, 

2760 metadata=metadata, 

2761 ) 

2762 

2763 # Done; return the response. 

2764 return response 

2765 

2766 async def list_exclusions( 

2767 self, 

2768 request: Optional[Union[logging_config.ListExclusionsRequest, dict]] = None, 

2769 *, 

2770 parent: Optional[str] = None, 

2771 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

2772 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

2773 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

2774 ) -> pagers.ListExclusionsAsyncPager: 

2775 r"""Lists all the exclusions on the \_Default sink in a parent 

2776 resource. 

2777 

2778 .. code-block:: python 

2779 

2780 # This snippet has been automatically generated and should be regarded as a 

2781 # code template only. 

2782 # It will require modifications to work: 

2783 # - It may require correct/in-range values for request initialization. 

2784 # - It may require specifying regional endpoints when creating the service 

2785 # client as shown in: 

2786 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

2787 from google.cloud import logging_v2 

2788 

2789 async def sample_list_exclusions(): 

2790 # Create a client 

2791 client = logging_v2.ConfigServiceV2AsyncClient() 

2792 

2793 # Initialize request argument(s) 

2794 request = logging_v2.ListExclusionsRequest( 

2795 parent="parent_value", 

2796 ) 

2797 

2798 # Make the request 

2799 page_result = client.list_exclusions(request=request) 

2800 

2801 # Handle the response 

2802 async for response in page_result: 

2803 print(response) 

2804 

2805 Args: 

2806 request (Optional[Union[google.cloud.logging_v2.types.ListExclusionsRequest, dict]]): 

2807 The request object. The parameters to ``ListExclusions``. 

2808 parent (:class:`str`): 

2809 Required. The parent resource whose exclusions are to be 

2810 listed. 

2811 

2812 :: 

2813 

2814 "projects/[PROJECT_ID]" 

2815 "organizations/[ORGANIZATION_ID]" 

2816 "billingAccounts/[BILLING_ACCOUNT_ID]" 

2817 "folders/[FOLDER_ID]" 

2818 

2819 This corresponds to the ``parent`` field 

2820 on the ``request`` instance; if ``request`` is provided, this 

2821 should not be set. 

2822 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

2823 should be retried. 

2824 timeout (float): The timeout for this request. 

2825 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

2826 sent along with the request as metadata. Normally, each value must be of type `str`, 

2827 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

2828 be of type `bytes`. 

2829 

2830 Returns: 

2831 google.cloud.logging_v2.services.config_service_v2.pagers.ListExclusionsAsyncPager: 

2832 Result returned from ListExclusions. 

2833 

2834 Iterating over this object will yield results and 

2835 resolve additional pages automatically. 

2836 

2837 """ 

2838 # Create or coerce a protobuf request object. 

2839 # - Quick check: If we got a request object, we should *not* have 

2840 # gotten any keyword arguments that map to the request. 

2841 flattened_params = [parent] 

2842 has_flattened_params = ( 

2843 len([param for param in flattened_params if param is not None]) > 0 

2844 ) 

2845 if request is not None and has_flattened_params: 

2846 raise ValueError( 

2847 "If the `request` argument is set, then none of " 

2848 "the individual field arguments should be set." 

2849 ) 

2850 

2851 # - Use the request object if provided (there's no risk of modifying the input as 

2852 # there are no flattened fields), or create one. 

2853 if not isinstance(request, logging_config.ListExclusionsRequest): 

2854 request = logging_config.ListExclusionsRequest(request) 

2855 

2856 # If we have keyword arguments corresponding to fields on the 

2857 # request, apply these. 

2858 if parent is not None: 

2859 request.parent = parent 

2860 

2861 # Wrap the RPC method; this adds retry and timeout information, 

2862 # and friendly error handling. 

2863 rpc = self._client._transport._wrapped_methods[ 

2864 self._client._transport.list_exclusions 

2865 ] 

2866 

2867 # Certain fields should be provided within the metadata header; 

2868 # add these here. 

2869 metadata = tuple(metadata) + ( 

2870 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), 

2871 ) 

2872 

2873 # Validate the universe domain. 

2874 self._client._validate_universe_domain() 

2875 

2876 # Send the request. 

2877 response = await rpc( 

2878 request, 

2879 retry=retry, 

2880 timeout=timeout, 

2881 metadata=metadata, 

2882 ) 

2883 

2884 # This method is paged; wrap the response in a pager, which provides 

2885 # an `__aiter__` convenience method. 

2886 response = pagers.ListExclusionsAsyncPager( 

2887 method=rpc, 

2888 request=request, 

2889 response=response, 

2890 retry=retry, 

2891 timeout=timeout, 

2892 metadata=metadata, 

2893 ) 

2894 

2895 # Done; return the response. 

2896 return response 

2897 

2898 async def get_exclusion( 

2899 self, 

2900 request: Optional[Union[logging_config.GetExclusionRequest, dict]] = None, 

2901 *, 

2902 name: Optional[str] = None, 

2903 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

2904 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

2905 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

2906 ) -> logging_config.LogExclusion: 

2907 r"""Gets the description of an exclusion in the \_Default sink. 

2908 

2909 .. code-block:: python 

2910 

2911 # This snippet has been automatically generated and should be regarded as a 

2912 # code template only. 

2913 # It will require modifications to work: 

2914 # - It may require correct/in-range values for request initialization. 

2915 # - It may require specifying regional endpoints when creating the service 

2916 # client as shown in: 

2917 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

2918 from google.cloud import logging_v2 

2919 

2920 async def sample_get_exclusion(): 

2921 # Create a client 

2922 client = logging_v2.ConfigServiceV2AsyncClient() 

2923 

2924 # Initialize request argument(s) 

2925 request = logging_v2.GetExclusionRequest( 

2926 name="name_value", 

2927 ) 

2928 

2929 # Make the request 

2930 response = await client.get_exclusion(request=request) 

2931 

2932 # Handle the response 

2933 print(response) 

2934 

2935 Args: 

2936 request (Optional[Union[google.cloud.logging_v2.types.GetExclusionRequest, dict]]): 

2937 The request object. The parameters to ``GetExclusion``. 

2938 name (:class:`str`): 

2939 Required. The resource name of an existing exclusion: 

2940 

2941 :: 

2942 

2943 "projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" 

2944 "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" 

2945 "billingAccounts/[BILLING_ACCOUNT_ID]/exclusions/[EXCLUSION_ID]" 

2946 "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]" 

2947 

2948 For example: 

2949 

2950 ``"projects/my-project/exclusions/my-exclusion"`` 

2951 

2952 This corresponds to the ``name`` field 

2953 on the ``request`` instance; if ``request`` is provided, this 

2954 should not be set. 

2955 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

2956 should be retried. 

2957 timeout (float): The timeout for this request. 

2958 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

2959 sent along with the request as metadata. Normally, each value must be of type `str`, 

2960 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

2961 be of type `bytes`. 

2962 

2963 Returns: 

2964 google.cloud.logging_v2.types.LogExclusion: 

2965 Specifies a set of log entries that are filtered out by a sink. If 

2966 your Google Cloud resource receives a large volume of 

2967 log entries, you can use exclusions to reduce your 

2968 chargeable logs. Note that exclusions on 

2969 organization-level and folder-level sinks don't apply 

2970 to child resources. Note also that you cannot modify 

2971 the Required sink or exclude logs from it. 

2972 

2973 """ 

2974 # Create or coerce a protobuf request object. 

2975 # - Quick check: If we got a request object, we should *not* have 

2976 # gotten any keyword arguments that map to the request. 

2977 flattened_params = [name] 

2978 has_flattened_params = ( 

2979 len([param for param in flattened_params if param is not None]) > 0 

2980 ) 

2981 if request is not None and has_flattened_params: 

2982 raise ValueError( 

2983 "If the `request` argument is set, then none of " 

2984 "the individual field arguments should be set." 

2985 ) 

2986 

2987 # - Use the request object if provided (there's no risk of modifying the input as 

2988 # there are no flattened fields), or create one. 

2989 if not isinstance(request, logging_config.GetExclusionRequest): 

2990 request = logging_config.GetExclusionRequest(request) 

2991 

2992 # If we have keyword arguments corresponding to fields on the 

2993 # request, apply these. 

2994 if name is not None: 

2995 request.name = name 

2996 

2997 # Wrap the RPC method; this adds retry and timeout information, 

2998 # and friendly error handling. 

2999 rpc = self._client._transport._wrapped_methods[ 

3000 self._client._transport.get_exclusion 

3001 ] 

3002 

3003 # Certain fields should be provided within the metadata header; 

3004 # add these here. 

3005 metadata = tuple(metadata) + ( 

3006 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

3007 ) 

3008 

3009 # Validate the universe domain. 

3010 self._client._validate_universe_domain() 

3011 

3012 # Send the request. 

3013 response = await rpc( 

3014 request, 

3015 retry=retry, 

3016 timeout=timeout, 

3017 metadata=metadata, 

3018 ) 

3019 

3020 # Done; return the response. 

3021 return response 

3022 

3023 async def create_exclusion( 

3024 self, 

3025 request: Optional[Union[logging_config.CreateExclusionRequest, dict]] = None, 

3026 *, 

3027 parent: Optional[str] = None, 

3028 exclusion: Optional[logging_config.LogExclusion] = None, 

3029 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3030 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

3031 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

3032 ) -> logging_config.LogExclusion: 

3033 r"""Creates a new exclusion in the \_Default sink in a specified 

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

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

3036 

3037 .. code-block:: python 

3038 

3039 # This snippet has been automatically generated and should be regarded as a 

3040 # code template only. 

3041 # It will require modifications to work: 

3042 # - It may require correct/in-range values for request initialization. 

3043 # - It may require specifying regional endpoints when creating the service 

3044 # client as shown in: 

3045 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

3046 from google.cloud import logging_v2 

3047 

3048 async def sample_create_exclusion(): 

3049 # Create a client 

3050 client = logging_v2.ConfigServiceV2AsyncClient() 

3051 

3052 # Initialize request argument(s) 

3053 exclusion = logging_v2.LogExclusion() 

3054 exclusion.name = "name_value" 

3055 exclusion.filter = "filter_value" 

3056 

3057 request = logging_v2.CreateExclusionRequest( 

3058 parent="parent_value", 

3059 exclusion=exclusion, 

3060 ) 

3061 

3062 # Make the request 

3063 response = await client.create_exclusion(request=request) 

3064 

3065 # Handle the response 

3066 print(response) 

3067 

3068 Args: 

3069 request (Optional[Union[google.cloud.logging_v2.types.CreateExclusionRequest, dict]]): 

3070 The request object. The parameters to ``CreateExclusion``. 

3071 parent (:class:`str`): 

3072 Required. The parent resource in which to create the 

3073 exclusion: 

3074 

3075 :: 

3076 

3077 "projects/[PROJECT_ID]" 

3078 "organizations/[ORGANIZATION_ID]" 

3079 "billingAccounts/[BILLING_ACCOUNT_ID]" 

3080 "folders/[FOLDER_ID]" 

3081 

3082 For examples: 

3083 

3084 ``"projects/my-logging-project"`` 

3085 ``"organizations/123456789"`` 

3086 

3087 This corresponds to the ``parent`` field 

3088 on the ``request`` instance; if ``request`` is provided, this 

3089 should not be set. 

3090 exclusion (:class:`google.cloud.logging_v2.types.LogExclusion`): 

3091 Required. The new exclusion, whose ``name`` parameter is 

3092 an exclusion name that is not already used in the parent 

3093 resource. 

3094 

3095 This corresponds to the ``exclusion`` field 

3096 on the ``request`` instance; if ``request`` is provided, this 

3097 should not be set. 

3098 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

3099 should be retried. 

3100 timeout (float): The timeout for this request. 

3101 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

3102 sent along with the request as metadata. Normally, each value must be of type `str`, 

3103 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

3104 be of type `bytes`. 

3105 

3106 Returns: 

3107 google.cloud.logging_v2.types.LogExclusion: 

3108 Specifies a set of log entries that are filtered out by a sink. If 

3109 your Google Cloud resource receives a large volume of 

3110 log entries, you can use exclusions to reduce your 

3111 chargeable logs. Note that exclusions on 

3112 organization-level and folder-level sinks don't apply 

3113 to child resources. Note also that you cannot modify 

3114 the Required sink or exclude logs from it. 

3115 

3116 """ 

3117 # Create or coerce a protobuf request object. 

3118 # - Quick check: If we got a request object, we should *not* have 

3119 # gotten any keyword arguments that map to the request. 

3120 flattened_params = [parent, exclusion] 

3121 has_flattened_params = ( 

3122 len([param for param in flattened_params if param is not None]) > 0 

3123 ) 

3124 if request is not None and has_flattened_params: 

3125 raise ValueError( 

3126 "If the `request` argument is set, then none of " 

3127 "the individual field arguments should be set." 

3128 ) 

3129 

3130 # - Use the request object if provided (there's no risk of modifying the input as 

3131 # there are no flattened fields), or create one. 

3132 if not isinstance(request, logging_config.CreateExclusionRequest): 

3133 request = logging_config.CreateExclusionRequest(request) 

3134 

3135 # If we have keyword arguments corresponding to fields on the 

3136 # request, apply these. 

3137 if parent is not None: 

3138 request.parent = parent 

3139 if exclusion is not None: 

3140 request.exclusion = exclusion 

3141 

3142 # Wrap the RPC method; this adds retry and timeout information, 

3143 # and friendly error handling. 

3144 rpc = self._client._transport._wrapped_methods[ 

3145 self._client._transport.create_exclusion 

3146 ] 

3147 

3148 # Certain fields should be provided within the metadata header; 

3149 # add these here. 

3150 metadata = tuple(metadata) + ( 

3151 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), 

3152 ) 

3153 

3154 # Validate the universe domain. 

3155 self._client._validate_universe_domain() 

3156 

3157 # Send the request. 

3158 response = await rpc( 

3159 request, 

3160 retry=retry, 

3161 timeout=timeout, 

3162 metadata=metadata, 

3163 ) 

3164 

3165 # Done; return the response. 

3166 return response 

3167 

3168 async def update_exclusion( 

3169 self, 

3170 request: Optional[Union[logging_config.UpdateExclusionRequest, dict]] = None, 

3171 *, 

3172 name: Optional[str] = None, 

3173 exclusion: Optional[logging_config.LogExclusion] = None, 

3174 update_mask: Optional[field_mask_pb2.FieldMask] = None, 

3175 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3176 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

3177 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

3178 ) -> logging_config.LogExclusion: 

3179 r"""Changes one or more properties of an existing exclusion in the 

3180 \_Default sink. 

3181 

3182 .. code-block:: python 

3183 

3184 # This snippet has been automatically generated and should be regarded as a 

3185 # code template only. 

3186 # It will require modifications to work: 

3187 # - It may require correct/in-range values for request initialization. 

3188 # - It may require specifying regional endpoints when creating the service 

3189 # client as shown in: 

3190 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

3191 from google.cloud import logging_v2 

3192 

3193 async def sample_update_exclusion(): 

3194 # Create a client 

3195 client = logging_v2.ConfigServiceV2AsyncClient() 

3196 

3197 # Initialize request argument(s) 

3198 exclusion = logging_v2.LogExclusion() 

3199 exclusion.name = "name_value" 

3200 exclusion.filter = "filter_value" 

3201 

3202 request = logging_v2.UpdateExclusionRequest( 

3203 name="name_value", 

3204 exclusion=exclusion, 

3205 ) 

3206 

3207 # Make the request 

3208 response = await client.update_exclusion(request=request) 

3209 

3210 # Handle the response 

3211 print(response) 

3212 

3213 Args: 

3214 request (Optional[Union[google.cloud.logging_v2.types.UpdateExclusionRequest, dict]]): 

3215 The request object. The parameters to ``UpdateExclusion``. 

3216 name (:class:`str`): 

3217 Required. The resource name of the exclusion to update: 

3218 

3219 :: 

3220 

3221 "projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" 

3222 "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" 

3223 "billingAccounts/[BILLING_ACCOUNT_ID]/exclusions/[EXCLUSION_ID]" 

3224 "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]" 

3225 

3226 For example: 

3227 

3228 ``"projects/my-project/exclusions/my-exclusion"`` 

3229 

3230 This corresponds to the ``name`` field 

3231 on the ``request`` instance; if ``request`` is provided, this 

3232 should not be set. 

3233 exclusion (:class:`google.cloud.logging_v2.types.LogExclusion`): 

3234 Required. New values for the existing exclusion. Only 

3235 the fields specified in ``update_mask`` are relevant. 

3236 

3237 This corresponds to the ``exclusion`` field 

3238 on the ``request`` instance; if ``request`` is provided, this 

3239 should not be set. 

3240 update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): 

3241 Required. A non-empty list of fields to change in the 

3242 existing exclusion. New values for the fields are taken 

3243 from the corresponding fields in the 

3244 [LogExclusion][google.logging.v2.LogExclusion] included 

3245 in this request. Fields not mentioned in ``update_mask`` 

3246 are not changed and are ignored in the request. 

3247 

3248 For example, to change the filter and description of an 

3249 exclusion, specify an ``update_mask`` of 

3250 ``"filter,description"``. 

3251 

3252 This corresponds to the ``update_mask`` field 

3253 on the ``request`` instance; if ``request`` is provided, this 

3254 should not be set. 

3255 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

3256 should be retried. 

3257 timeout (float): The timeout for this request. 

3258 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

3259 sent along with the request as metadata. Normally, each value must be of type `str`, 

3260 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

3261 be of type `bytes`. 

3262 

3263 Returns: 

3264 google.cloud.logging_v2.types.LogExclusion: 

3265 Specifies a set of log entries that are filtered out by a sink. If 

3266 your Google Cloud resource receives a large volume of 

3267 log entries, you can use exclusions to reduce your 

3268 chargeable logs. Note that exclusions on 

3269 organization-level and folder-level sinks don't apply 

3270 to child resources. Note also that you cannot modify 

3271 the Required sink or exclude logs from it. 

3272 

3273 """ 

3274 # Create or coerce a protobuf request object. 

3275 # - Quick check: If we got a request object, we should *not* have 

3276 # gotten any keyword arguments that map to the request. 

3277 flattened_params = [name, exclusion, update_mask] 

3278 has_flattened_params = ( 

3279 len([param for param in flattened_params if param is not None]) > 0 

3280 ) 

3281 if request is not None and has_flattened_params: 

3282 raise ValueError( 

3283 "If the `request` argument is set, then none of " 

3284 "the individual field arguments should be set." 

3285 ) 

3286 

3287 # - Use the request object if provided (there's no risk of modifying the input as 

3288 # there are no flattened fields), or create one. 

3289 if not isinstance(request, logging_config.UpdateExclusionRequest): 

3290 request = logging_config.UpdateExclusionRequest(request) 

3291 

3292 # If we have keyword arguments corresponding to fields on the 

3293 # request, apply these. 

3294 if name is not None: 

3295 request.name = name 

3296 if exclusion is not None: 

3297 request.exclusion = exclusion 

3298 if update_mask is not None: 

3299 request.update_mask = update_mask 

3300 

3301 # Wrap the RPC method; this adds retry and timeout information, 

3302 # and friendly error handling. 

3303 rpc = self._client._transport._wrapped_methods[ 

3304 self._client._transport.update_exclusion 

3305 ] 

3306 

3307 # Certain fields should be provided within the metadata header; 

3308 # add these here. 

3309 metadata = tuple(metadata) + ( 

3310 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

3311 ) 

3312 

3313 # Validate the universe domain. 

3314 self._client._validate_universe_domain() 

3315 

3316 # Send the request. 

3317 response = await rpc( 

3318 request, 

3319 retry=retry, 

3320 timeout=timeout, 

3321 metadata=metadata, 

3322 ) 

3323 

3324 # Done; return the response. 

3325 return response 

3326 

3327 async def delete_exclusion( 

3328 self, 

3329 request: Optional[Union[logging_config.DeleteExclusionRequest, dict]] = None, 

3330 *, 

3331 name: Optional[str] = None, 

3332 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3333 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

3334 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

3335 ) -> None: 

3336 r"""Deletes an exclusion in the \_Default sink. 

3337 

3338 .. code-block:: python 

3339 

3340 # This snippet has been automatically generated and should be regarded as a 

3341 # code template only. 

3342 # It will require modifications to work: 

3343 # - It may require correct/in-range values for request initialization. 

3344 # - It may require specifying regional endpoints when creating the service 

3345 # client as shown in: 

3346 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

3347 from google.cloud import logging_v2 

3348 

3349 async def sample_delete_exclusion(): 

3350 # Create a client 

3351 client = logging_v2.ConfigServiceV2AsyncClient() 

3352 

3353 # Initialize request argument(s) 

3354 request = logging_v2.DeleteExclusionRequest( 

3355 name="name_value", 

3356 ) 

3357 

3358 # Make the request 

3359 await client.delete_exclusion(request=request) 

3360 

3361 Args: 

3362 request (Optional[Union[google.cloud.logging_v2.types.DeleteExclusionRequest, dict]]): 

3363 The request object. The parameters to ``DeleteExclusion``. 

3364 name (:class:`str`): 

3365 Required. The resource name of an existing exclusion to 

3366 delete: 

3367 

3368 :: 

3369 

3370 "projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" 

3371 "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" 

3372 "billingAccounts/[BILLING_ACCOUNT_ID]/exclusions/[EXCLUSION_ID]" 

3373 "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]" 

3374 

3375 For example: 

3376 

3377 ``"projects/my-project/exclusions/my-exclusion"`` 

3378 

3379 This corresponds to the ``name`` field 

3380 on the ``request`` instance; if ``request`` is provided, this 

3381 should not be set. 

3382 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

3383 should be retried. 

3384 timeout (float): The timeout for this request. 

3385 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

3386 sent along with the request as metadata. Normally, each value must be of type `str`, 

3387 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

3388 be of type `bytes`. 

3389 """ 

3390 # Create or coerce a protobuf request object. 

3391 # - Quick check: If we got a request object, we should *not* have 

3392 # gotten any keyword arguments that map to the request. 

3393 flattened_params = [name] 

3394 has_flattened_params = ( 

3395 len([param for param in flattened_params if param is not None]) > 0 

3396 ) 

3397 if request is not None and has_flattened_params: 

3398 raise ValueError( 

3399 "If the `request` argument is set, then none of " 

3400 "the individual field arguments should be set." 

3401 ) 

3402 

3403 # - Use the request object if provided (there's no risk of modifying the input as 

3404 # there are no flattened fields), or create one. 

3405 if not isinstance(request, logging_config.DeleteExclusionRequest): 

3406 request = logging_config.DeleteExclusionRequest(request) 

3407 

3408 # If we have keyword arguments corresponding to fields on the 

3409 # request, apply these. 

3410 if name is not None: 

3411 request.name = name 

3412 

3413 # Wrap the RPC method; this adds retry and timeout information, 

3414 # and friendly error handling. 

3415 rpc = self._client._transport._wrapped_methods[ 

3416 self._client._transport.delete_exclusion 

3417 ] 

3418 

3419 # Certain fields should be provided within the metadata header; 

3420 # add these here. 

3421 metadata = tuple(metadata) + ( 

3422 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

3423 ) 

3424 

3425 # Validate the universe domain. 

3426 self._client._validate_universe_domain() 

3427 

3428 # Send the request. 

3429 await rpc( 

3430 request, 

3431 retry=retry, 

3432 timeout=timeout, 

3433 metadata=metadata, 

3434 ) 

3435 

3436 async def get_cmek_settings( 

3437 self, 

3438 request: Optional[Union[logging_config.GetCmekSettingsRequest, dict]] = None, 

3439 *, 

3440 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3441 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

3442 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

3443 ) -> logging_config.CmekSettings: 

3444 r"""Gets the Logging CMEK settings for the given resource. 

3445 

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

3447 projects, folders, organizations and billing accounts. Once 

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

3449 folders in the Google Cloud organization. 

3450 

3451 See `Enabling CMEK for Log 

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

3453 for more information. 

3454 

3455 .. code-block:: python 

3456 

3457 # This snippet has been automatically generated and should be regarded as a 

3458 # code template only. 

3459 # It will require modifications to work: 

3460 # - It may require correct/in-range values for request initialization. 

3461 # - It may require specifying regional endpoints when creating the service 

3462 # client as shown in: 

3463 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

3464 from google.cloud import logging_v2 

3465 

3466 async def sample_get_cmek_settings(): 

3467 # Create a client 

3468 client = logging_v2.ConfigServiceV2AsyncClient() 

3469 

3470 # Initialize request argument(s) 

3471 request = logging_v2.GetCmekSettingsRequest( 

3472 name="name_value", 

3473 ) 

3474 

3475 # Make the request 

3476 response = await client.get_cmek_settings(request=request) 

3477 

3478 # Handle the response 

3479 print(response) 

3480 

3481 Args: 

3482 request (Optional[Union[google.cloud.logging_v2.types.GetCmekSettingsRequest, dict]]): 

3483 The request object. The parameters to 

3484 [GetCmekSettings][google.logging.v2.ConfigServiceV2.GetCmekSettings]. 

3485 

3486 See `Enabling CMEK for Log 

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

3488 for more information. 

3489 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

3490 should be retried. 

3491 timeout (float): The timeout for this request. 

3492 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

3493 sent along with the request as metadata. Normally, each value must be of type `str`, 

3494 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

3495 be of type `bytes`. 

3496 

3497 Returns: 

3498 google.cloud.logging_v2.types.CmekSettings: 

3499 Describes the customer-managed encryption key (CMEK) settings associated with 

3500 a project, folder, organization, billing account, or 

3501 flexible resource. 

3502 

3503 Note: CMEK for the Log Router can currently only be 

3504 configured for Google Cloud organizations. Once 

3505 configured, it applies to all projects and folders in 

3506 the Google Cloud organization. 

3507 

3508 See [Enabling CMEK for Log 

3509 Router](https://cloud.google.com/logging/docs/routing/managed-encryption) 

3510 for more information. 

3511 

3512 """ 

3513 # Create or coerce a protobuf request object. 

3514 # - Use the request object if provided (there's no risk of modifying the input as 

3515 # there are no flattened fields), or create one. 

3516 if not isinstance(request, logging_config.GetCmekSettingsRequest): 

3517 request = logging_config.GetCmekSettingsRequest(request) 

3518 

3519 # Wrap the RPC method; this adds retry and timeout information, 

3520 # and friendly error handling. 

3521 rpc = self._client._transport._wrapped_methods[ 

3522 self._client._transport.get_cmek_settings 

3523 ] 

3524 

3525 # Certain fields should be provided within the metadata header; 

3526 # add these here. 

3527 metadata = tuple(metadata) + ( 

3528 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

3529 ) 

3530 

3531 # Validate the universe domain. 

3532 self._client._validate_universe_domain() 

3533 

3534 # Send the request. 

3535 response = await rpc( 

3536 request, 

3537 retry=retry, 

3538 timeout=timeout, 

3539 metadata=metadata, 

3540 ) 

3541 

3542 # Done; return the response. 

3543 return response 

3544 

3545 async def update_cmek_settings( 

3546 self, 

3547 request: Optional[Union[logging_config.UpdateCmekSettingsRequest, dict]] = None, 

3548 *, 

3549 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3550 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

3551 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

3552 ) -> logging_config.CmekSettings: 

3553 r"""Updates the Log Router CMEK settings for the given resource. 

3554 

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

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

3557 all projects and folders in the Google Cloud organization. 

3558 

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

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

3561 associated service account does not have the required 

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

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

3564 

3565 See `Enabling CMEK for Log 

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

3567 for more information. 

3568 

3569 .. code-block:: python 

3570 

3571 # This snippet has been automatically generated and should be regarded as a 

3572 # code template only. 

3573 # It will require modifications to work: 

3574 # - It may require correct/in-range values for request initialization. 

3575 # - It may require specifying regional endpoints when creating the service 

3576 # client as shown in: 

3577 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

3578 from google.cloud import logging_v2 

3579 

3580 async def sample_update_cmek_settings(): 

3581 # Create a client 

3582 client = logging_v2.ConfigServiceV2AsyncClient() 

3583 

3584 # Initialize request argument(s) 

3585 request = logging_v2.UpdateCmekSettingsRequest( 

3586 name="name_value", 

3587 ) 

3588 

3589 # Make the request 

3590 response = await client.update_cmek_settings(request=request) 

3591 

3592 # Handle the response 

3593 print(response) 

3594 

3595 Args: 

3596 request (Optional[Union[google.cloud.logging_v2.types.UpdateCmekSettingsRequest, dict]]): 

3597 The request object. The parameters to 

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

3599 

3600 See `Enabling CMEK for Log 

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

3602 for more information. 

3603 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

3604 should be retried. 

3605 timeout (float): The timeout for this request. 

3606 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

3607 sent along with the request as metadata. Normally, each value must be of type `str`, 

3608 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

3609 be of type `bytes`. 

3610 

3611 Returns: 

3612 google.cloud.logging_v2.types.CmekSettings: 

3613 Describes the customer-managed encryption key (CMEK) settings associated with 

3614 a project, folder, organization, billing account, or 

3615 flexible resource. 

3616 

3617 Note: CMEK for the Log Router can currently only be 

3618 configured for Google Cloud organizations. Once 

3619 configured, it applies to all projects and folders in 

3620 the Google Cloud organization. 

3621 

3622 See [Enabling CMEK for Log 

3623 Router](https://cloud.google.com/logging/docs/routing/managed-encryption) 

3624 for more information. 

3625 

3626 """ 

3627 # Create or coerce a protobuf request object. 

3628 # - Use the request object if provided (there's no risk of modifying the input as 

3629 # there are no flattened fields), or create one. 

3630 if not isinstance(request, logging_config.UpdateCmekSettingsRequest): 

3631 request = logging_config.UpdateCmekSettingsRequest(request) 

3632 

3633 # Wrap the RPC method; this adds retry and timeout information, 

3634 # and friendly error handling. 

3635 rpc = self._client._transport._wrapped_methods[ 

3636 self._client._transport.update_cmek_settings 

3637 ] 

3638 

3639 # Certain fields should be provided within the metadata header; 

3640 # add these here. 

3641 metadata = tuple(metadata) + ( 

3642 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

3643 ) 

3644 

3645 # Validate the universe domain. 

3646 self._client._validate_universe_domain() 

3647 

3648 # Send the request. 

3649 response = await rpc( 

3650 request, 

3651 retry=retry, 

3652 timeout=timeout, 

3653 metadata=metadata, 

3654 ) 

3655 

3656 # Done; return the response. 

3657 return response 

3658 

3659 async def get_settings( 

3660 self, 

3661 request: Optional[Union[logging_config.GetSettingsRequest, dict]] = None, 

3662 *, 

3663 name: Optional[str] = None, 

3664 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3665 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

3666 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

3667 ) -> logging_config.Settings: 

3668 r"""Gets the Log Router settings for the given resource. 

3669 

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

3671 projects, folders, organizations and billing accounts. Currently 

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

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

3674 Google Cloud organization. 

3675 

3676 See `Enabling CMEK for Log 

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

3678 for more information. 

3679 

3680 .. code-block:: python 

3681 

3682 # This snippet has been automatically generated and should be regarded as a 

3683 # code template only. 

3684 # It will require modifications to work: 

3685 # - It may require correct/in-range values for request initialization. 

3686 # - It may require specifying regional endpoints when creating the service 

3687 # client as shown in: 

3688 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

3689 from google.cloud import logging_v2 

3690 

3691 async def sample_get_settings(): 

3692 # Create a client 

3693 client = logging_v2.ConfigServiceV2AsyncClient() 

3694 

3695 # Initialize request argument(s) 

3696 request = logging_v2.GetSettingsRequest( 

3697 name="name_value", 

3698 ) 

3699 

3700 # Make the request 

3701 response = await client.get_settings(request=request) 

3702 

3703 # Handle the response 

3704 print(response) 

3705 

3706 Args: 

3707 request (Optional[Union[google.cloud.logging_v2.types.GetSettingsRequest, dict]]): 

3708 The request object. The parameters to 

3709 [GetSettings][google.logging.v2.ConfigServiceV2.GetSettings]. 

3710 

3711 See `Enabling CMEK for Log 

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

3713 for more information. 

3714 name (:class:`str`): 

3715 Required. The resource for which to retrieve settings. 

3716 

3717 :: 

3718 

3719 "projects/[PROJECT_ID]/settings" 

3720 "organizations/[ORGANIZATION_ID]/settings" 

3721 "billingAccounts/[BILLING_ACCOUNT_ID]/settings" 

3722 "folders/[FOLDER_ID]/settings" 

3723 

3724 For example: 

3725 

3726 ``"organizations/12345/settings"`` 

3727 

3728 Note: Settings for the Log Router can be get for Google 

3729 Cloud projects, folders, organizations and billing 

3730 accounts. Currently it can only be configured for 

3731 organizations. Once configured for an organization, it 

3732 applies to all projects and folders in the Google Cloud 

3733 organization. 

3734 

3735 This corresponds to the ``name`` field 

3736 on the ``request`` instance; if ``request`` is provided, this 

3737 should not be set. 

3738 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

3739 should be retried. 

3740 timeout (float): The timeout for this request. 

3741 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

3742 sent along with the request as metadata. Normally, each value must be of type `str`, 

3743 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

3744 be of type `bytes`. 

3745 

3746 Returns: 

3747 google.cloud.logging_v2.types.Settings: 

3748 Describes the settings associated 

3749 with a project, folder, organization, 

3750 billing account, or flexible resource. 

3751 

3752 """ 

3753 # Create or coerce a protobuf request object. 

3754 # - Quick check: If we got a request object, we should *not* have 

3755 # gotten any keyword arguments that map to the request. 

3756 flattened_params = [name] 

3757 has_flattened_params = ( 

3758 len([param for param in flattened_params if param is not None]) > 0 

3759 ) 

3760 if request is not None and has_flattened_params: 

3761 raise ValueError( 

3762 "If the `request` argument is set, then none of " 

3763 "the individual field arguments should be set." 

3764 ) 

3765 

3766 # - Use the request object if provided (there's no risk of modifying the input as 

3767 # there are no flattened fields), or create one. 

3768 if not isinstance(request, logging_config.GetSettingsRequest): 

3769 request = logging_config.GetSettingsRequest(request) 

3770 

3771 # If we have keyword arguments corresponding to fields on the 

3772 # request, apply these. 

3773 if name is not None: 

3774 request.name = name 

3775 

3776 # Wrap the RPC method; this adds retry and timeout information, 

3777 # and friendly error handling. 

3778 rpc = self._client._transport._wrapped_methods[ 

3779 self._client._transport.get_settings 

3780 ] 

3781 

3782 # Certain fields should be provided within the metadata header; 

3783 # add these here. 

3784 metadata = tuple(metadata) + ( 

3785 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

3786 ) 

3787 

3788 # Validate the universe domain. 

3789 self._client._validate_universe_domain() 

3790 

3791 # Send the request. 

3792 response = await rpc( 

3793 request, 

3794 retry=retry, 

3795 timeout=timeout, 

3796 metadata=metadata, 

3797 ) 

3798 

3799 # Done; return the response. 

3800 return response 

3801 

3802 async def update_settings( 

3803 self, 

3804 request: Optional[Union[logging_config.UpdateSettingsRequest, dict]] = None, 

3805 *, 

3806 settings: Optional[logging_config.Settings] = None, 

3807 update_mask: Optional[field_mask_pb2.FieldMask] = None, 

3808 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3809 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

3810 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

3811 ) -> logging_config.Settings: 

3812 r"""Updates the Log Router settings for the given resource. 

3813 

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

3815 configured for Google Cloud organizations. Once configured, it 

3816 applies to all projects and folders in the Google Cloud 

3817 organization. 

3818 

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

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

3821 associated service account does not have the required 

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

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

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

3825 OrgPolicy. 

3826 

3827 See `Enabling CMEK for Log 

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

3829 for more information. 

3830 

3831 .. code-block:: python 

3832 

3833 # This snippet has been automatically generated and should be regarded as a 

3834 # code template only. 

3835 # It will require modifications to work: 

3836 # - It may require correct/in-range values for request initialization. 

3837 # - It may require specifying regional endpoints when creating the service 

3838 # client as shown in: 

3839 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

3840 from google.cloud import logging_v2 

3841 

3842 async def sample_update_settings(): 

3843 # Create a client 

3844 client = logging_v2.ConfigServiceV2AsyncClient() 

3845 

3846 # Initialize request argument(s) 

3847 request = logging_v2.UpdateSettingsRequest( 

3848 name="name_value", 

3849 ) 

3850 

3851 # Make the request 

3852 response = await client.update_settings(request=request) 

3853 

3854 # Handle the response 

3855 print(response) 

3856 

3857 Args: 

3858 request (Optional[Union[google.cloud.logging_v2.types.UpdateSettingsRequest, dict]]): 

3859 The request object. The parameters to 

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

3861 

3862 See `Enabling CMEK for Log 

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

3864 for more information. 

3865 settings (:class:`google.cloud.logging_v2.types.Settings`): 

3866 Required. The settings to update. 

3867 

3868 See `Enabling CMEK for Log 

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

3870 for more information. 

3871 

3872 This corresponds to the ``settings`` field 

3873 on the ``request`` instance; if ``request`` is provided, this 

3874 should not be set. 

3875 update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): 

3876 Optional. Field mask identifying which fields from 

3877 ``settings`` should be updated. A field will be 

3878 overwritten if and only if it is in the update mask. 

3879 Output only fields cannot be updated. 

3880 

3881 See [FieldMask][google.protobuf.FieldMask] for more 

3882 information. 

3883 

3884 For example: ``"updateMask=kmsKeyName"`` 

3885 

3886 This corresponds to the ``update_mask`` field 

3887 on the ``request`` instance; if ``request`` is provided, this 

3888 should not be set. 

3889 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

3890 should be retried. 

3891 timeout (float): The timeout for this request. 

3892 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

3893 sent along with the request as metadata. Normally, each value must be of type `str`, 

3894 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

3895 be of type `bytes`. 

3896 

3897 Returns: 

3898 google.cloud.logging_v2.types.Settings: 

3899 Describes the settings associated 

3900 with a project, folder, organization, 

3901 billing account, or flexible resource. 

3902 

3903 """ 

3904 # Create or coerce a protobuf request object. 

3905 # - Quick check: If we got a request object, we should *not* have 

3906 # gotten any keyword arguments that map to the request. 

3907 flattened_params = [settings, update_mask] 

3908 has_flattened_params = ( 

3909 len([param for param in flattened_params if param is not None]) > 0 

3910 ) 

3911 if request is not None and has_flattened_params: 

3912 raise ValueError( 

3913 "If the `request` argument is set, then none of " 

3914 "the individual field arguments should be set." 

3915 ) 

3916 

3917 # - Use the request object if provided (there's no risk of modifying the input as 

3918 # there are no flattened fields), or create one. 

3919 if not isinstance(request, logging_config.UpdateSettingsRequest): 

3920 request = logging_config.UpdateSettingsRequest(request) 

3921 

3922 # If we have keyword arguments corresponding to fields on the 

3923 # request, apply these. 

3924 if settings is not None: 

3925 request.settings = settings 

3926 if update_mask is not None: 

3927 request.update_mask = update_mask 

3928 

3929 # Wrap the RPC method; this adds retry and timeout information, 

3930 # and friendly error handling. 

3931 rpc = self._client._transport._wrapped_methods[ 

3932 self._client._transport.update_settings 

3933 ] 

3934 

3935 # Certain fields should be provided within the metadata header; 

3936 # add these here. 

3937 metadata = tuple(metadata) + ( 

3938 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

3939 ) 

3940 

3941 # Validate the universe domain. 

3942 self._client._validate_universe_domain() 

3943 

3944 # Send the request. 

3945 response = await rpc( 

3946 request, 

3947 retry=retry, 

3948 timeout=timeout, 

3949 metadata=metadata, 

3950 ) 

3951 

3952 # Done; return the response. 

3953 return response 

3954 

3955 async def copy_log_entries( 

3956 self, 

3957 request: Optional[Union[logging_config.CopyLogEntriesRequest, dict]] = None, 

3958 *, 

3959 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3960 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

3961 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

3962 ) -> operation_async.AsyncOperation: 

3963 r"""Copies a set of log entries from a log bucket to a 

3964 Cloud Storage bucket. 

3965 

3966 .. code-block:: python 

3967 

3968 # This snippet has been automatically generated and should be regarded as a 

3969 # code template only. 

3970 # It will require modifications to work: 

3971 # - It may require correct/in-range values for request initialization. 

3972 # - It may require specifying regional endpoints when creating the service 

3973 # client as shown in: 

3974 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

3975 from google.cloud import logging_v2 

3976 

3977 async def sample_copy_log_entries(): 

3978 # Create a client 

3979 client = logging_v2.ConfigServiceV2AsyncClient() 

3980 

3981 # Initialize request argument(s) 

3982 request = logging_v2.CopyLogEntriesRequest( 

3983 name="name_value", 

3984 destination="destination_value", 

3985 ) 

3986 

3987 # Make the request 

3988 operation = client.copy_log_entries(request=request) 

3989 

3990 print("Waiting for operation to complete...") 

3991 

3992 response = (await operation).result() 

3993 

3994 # Handle the response 

3995 print(response) 

3996 

3997 Args: 

3998 request (Optional[Union[google.cloud.logging_v2.types.CopyLogEntriesRequest, dict]]): 

3999 The request object. The parameters to CopyLogEntries. 

4000 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

4001 should be retried. 

4002 timeout (float): The timeout for this request. 

4003 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

4004 sent along with the request as metadata. Normally, each value must be of type `str`, 

4005 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

4006 be of type `bytes`. 

4007 

4008 Returns: 

4009 google.api_core.operation_async.AsyncOperation: 

4010 An object representing a long-running operation. 

4011 

4012 The result type for the operation will be 

4013 :class:`google.cloud.logging_v2.types.CopyLogEntriesResponse` 

4014 Response type for CopyLogEntries long running 

4015 operations. 

4016 

4017 """ 

4018 # Create or coerce a protobuf request object. 

4019 # - Use the request object if provided (there's no risk of modifying the input as 

4020 # there are no flattened fields), or create one. 

4021 if not isinstance(request, logging_config.CopyLogEntriesRequest): 

4022 request = logging_config.CopyLogEntriesRequest(request) 

4023 

4024 # Wrap the RPC method; this adds retry and timeout information, 

4025 # and friendly error handling. 

4026 rpc = self._client._transport._wrapped_methods[ 

4027 self._client._transport.copy_log_entries 

4028 ] 

4029 

4030 # Validate the universe domain. 

4031 self._client._validate_universe_domain() 

4032 

4033 # Send the request. 

4034 response = await rpc( 

4035 request, 

4036 retry=retry, 

4037 timeout=timeout, 

4038 metadata=metadata, 

4039 ) 

4040 

4041 # Wrap the response in an operation future. 

4042 response = operation_async.from_gapic( 

4043 response, 

4044 self._client._transport.operations_client, 

4045 logging_config.CopyLogEntriesResponse, 

4046 metadata_type=logging_config.CopyLogEntriesMetadata, 

4047 ) 

4048 

4049 # Done; return the response. 

4050 return response 

4051 

4052 async def list_operations( 

4053 self, 

4054 request: Optional[operations_pb2.ListOperationsRequest] = None, 

4055 *, 

4056 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

4057 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

4058 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

4059 ) -> operations_pb2.ListOperationsResponse: 

4060 r"""Lists operations that match the specified filter in the request. 

4061 

4062 Args: 

4063 request (:class:`~.operations_pb2.ListOperationsRequest`): 

4064 The request object. Request message for 

4065 `ListOperations` method. 

4066 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, 

4067 if any, should be retried. 

4068 timeout (float): The timeout for this request. 

4069 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

4070 sent along with the request as metadata. Normally, each value must be of type `str`, 

4071 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

4072 be of type `bytes`. 

4073 Returns: 

4074 ~.operations_pb2.ListOperationsResponse: 

4075 Response message for ``ListOperations`` method. 

4076 """ 

4077 # Create or coerce a protobuf request object. 

4078 # The request isn't a proto-plus wrapped type, 

4079 # so it must be constructed via keyword expansion. 

4080 if isinstance(request, dict): 

4081 request = operations_pb2.ListOperationsRequest(**request) 

4082 

4083 # Wrap the RPC method; this adds retry and timeout information, 

4084 # and friendly error handling. 

4085 rpc = self.transport._wrapped_methods[self._client._transport.list_operations] 

4086 

4087 # Certain fields should be provided within the metadata header; 

4088 # add these here. 

4089 metadata = tuple(metadata) + ( 

4090 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

4091 ) 

4092 

4093 # Validate the universe domain. 

4094 self._client._validate_universe_domain() 

4095 

4096 # Send the request. 

4097 response = await rpc( 

4098 request, 

4099 retry=retry, 

4100 timeout=timeout, 

4101 metadata=metadata, 

4102 ) 

4103 

4104 # Done; return the response. 

4105 return response 

4106 

4107 async def get_operation( 

4108 self, 

4109 request: Optional[operations_pb2.GetOperationRequest] = None, 

4110 *, 

4111 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

4112 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

4113 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

4114 ) -> operations_pb2.Operation: 

4115 r"""Gets the latest state of a long-running operation. 

4116 

4117 Args: 

4118 request (:class:`~.operations_pb2.GetOperationRequest`): 

4119 The request object. Request message for 

4120 `GetOperation` method. 

4121 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, 

4122 if any, should be retried. 

4123 timeout (float): The timeout for this request. 

4124 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

4125 sent along with the request as metadata. Normally, each value must be of type `str`, 

4126 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

4127 be of type `bytes`. 

4128 Returns: 

4129 ~.operations_pb2.Operation: 

4130 An ``Operation`` object. 

4131 """ 

4132 # Create or coerce a protobuf request object. 

4133 # The request isn't a proto-plus wrapped type, 

4134 # so it must be constructed via keyword expansion. 

4135 if isinstance(request, dict): 

4136 request = operations_pb2.GetOperationRequest(**request) 

4137 

4138 # Wrap the RPC method; this adds retry and timeout information, 

4139 # and friendly error handling. 

4140 rpc = self.transport._wrapped_methods[self._client._transport.get_operation] 

4141 

4142 # Certain fields should be provided within the metadata header; 

4143 # add these here. 

4144 metadata = tuple(metadata) + ( 

4145 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

4146 ) 

4147 

4148 # Validate the universe domain. 

4149 self._client._validate_universe_domain() 

4150 

4151 # Send the request. 

4152 response = await rpc( 

4153 request, 

4154 retry=retry, 

4155 timeout=timeout, 

4156 metadata=metadata, 

4157 ) 

4158 

4159 # Done; return the response. 

4160 return response 

4161 

4162 async def cancel_operation( 

4163 self, 

4164 request: Optional[operations_pb2.CancelOperationRequest] = None, 

4165 *, 

4166 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

4167 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

4168 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

4169 ) -> None: 

4170 r"""Starts asynchronous cancellation on a long-running operation. 

4171 

4172 The server makes a best effort to cancel the operation, but success 

4173 is not guaranteed. If the server doesn't support this method, it returns 

4174 `google.rpc.Code.UNIMPLEMENTED`. 

4175 

4176 Args: 

4177 request (:class:`~.operations_pb2.CancelOperationRequest`): 

4178 The request object. Request message for 

4179 `CancelOperation` method. 

4180 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, 

4181 if any, should be retried. 

4182 timeout (float): The timeout for this request. 

4183 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

4184 sent along with the request as metadata. Normally, each value must be of type `str`, 

4185 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

4186 be of type `bytes`. 

4187 Returns: 

4188 None 

4189 """ 

4190 # Create or coerce a protobuf request object. 

4191 # The request isn't a proto-plus wrapped type, 

4192 # so it must be constructed via keyword expansion. 

4193 if isinstance(request, dict): 

4194 request = operations_pb2.CancelOperationRequest(**request) 

4195 

4196 # Wrap the RPC method; this adds retry and timeout information, 

4197 # and friendly error handling. 

4198 rpc = self.transport._wrapped_methods[self._client._transport.cancel_operation] 

4199 

4200 # Certain fields should be provided within the metadata header; 

4201 # add these here. 

4202 metadata = tuple(metadata) + ( 

4203 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

4204 ) 

4205 

4206 # Validate the universe domain. 

4207 self._client._validate_universe_domain() 

4208 

4209 # Send the request. 

4210 await rpc( 

4211 request, 

4212 retry=retry, 

4213 timeout=timeout, 

4214 metadata=metadata, 

4215 ) 

4216 

4217 async def __aenter__(self) -> "ConfigServiceV2AsyncClient": 

4218 return self 

4219 

4220 async def __aexit__(self, exc_type, exc, tb): 

4221 await self.transport.close() 

4222 

4223 

4224DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( 

4225 gapic_version=package_version.__version__ 

4226) 

4227 

4228if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER 

4229 DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__ 

4230 

4231 

4232__all__ = ("ConfigServiceV2AsyncClient",)