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

496 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) 

31 

32from google.cloud.logging_v2 import gapic_version as package_version 

33 

34from google.api_core.client_options import ClientOptions 

35from google.api_core import exceptions as core_exceptions 

36from google.api_core import gapic_v1 

37from google.api_core import retry_async as retries 

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

39from google.oauth2 import service_account # type: ignore 

40import google.protobuf 

41 

42 

43try: 

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

45except AttributeError: # pragma: NO COVER 

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

47 

48from google.api_core import operation # type: ignore 

49from google.api_core import operation_async # type: ignore 

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

51from google.cloud.logging_v2.types import logging_config 

52from google.longrunning import operations_pb2 # type: ignore 

53from google.protobuf import empty_pb2 # type: ignore 

54from google.protobuf import field_mask_pb2 # type: ignore 

55from google.protobuf import timestamp_pb2 # type: ignore 

56from .transports.base import ConfigServiceV2Transport, DEFAULT_CLIENT_INFO 

57from .transports.grpc_asyncio import ConfigServiceV2GrpcAsyncIOTransport 

58from .client import ConfigServiceV2Client 

59 

60try: 

61 from google.api_core import client_logging # type: ignore 

62 

63 CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER 

64except ImportError: # pragma: NO COVER 

65 CLIENT_LOGGING_SUPPORTED = False 

66 

67_LOGGER = std_logging.getLogger(__name__) 

68 

69 

70class ConfigServiceV2AsyncClient: 

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

72 

73 _client: ConfigServiceV2Client 

74 

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

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

77 DEFAULT_ENDPOINT = ConfigServiceV2Client.DEFAULT_ENDPOINT 

78 DEFAULT_MTLS_ENDPOINT = ConfigServiceV2Client.DEFAULT_MTLS_ENDPOINT 

79 _DEFAULT_ENDPOINT_TEMPLATE = ConfigServiceV2Client._DEFAULT_ENDPOINT_TEMPLATE 

80 _DEFAULT_UNIVERSE = ConfigServiceV2Client._DEFAULT_UNIVERSE 

81 

82 cmek_settings_path = staticmethod(ConfigServiceV2Client.cmek_settings_path) 

83 parse_cmek_settings_path = staticmethod( 

84 ConfigServiceV2Client.parse_cmek_settings_path 

85 ) 

86 link_path = staticmethod(ConfigServiceV2Client.link_path) 

87 parse_link_path = staticmethod(ConfigServiceV2Client.parse_link_path) 

88 log_bucket_path = staticmethod(ConfigServiceV2Client.log_bucket_path) 

89 parse_log_bucket_path = staticmethod(ConfigServiceV2Client.parse_log_bucket_path) 

90 log_exclusion_path = staticmethod(ConfigServiceV2Client.log_exclusion_path) 

91 parse_log_exclusion_path = staticmethod( 

92 ConfigServiceV2Client.parse_log_exclusion_path 

93 ) 

94 log_sink_path = staticmethod(ConfigServiceV2Client.log_sink_path) 

95 parse_log_sink_path = staticmethod(ConfigServiceV2Client.parse_log_sink_path) 

96 log_view_path = staticmethod(ConfigServiceV2Client.log_view_path) 

97 parse_log_view_path = staticmethod(ConfigServiceV2Client.parse_log_view_path) 

98 settings_path = staticmethod(ConfigServiceV2Client.settings_path) 

99 parse_settings_path = staticmethod(ConfigServiceV2Client.parse_settings_path) 

100 common_billing_account_path = staticmethod( 

101 ConfigServiceV2Client.common_billing_account_path 

102 ) 

103 parse_common_billing_account_path = staticmethod( 

104 ConfigServiceV2Client.parse_common_billing_account_path 

105 ) 

106 common_folder_path = staticmethod(ConfigServiceV2Client.common_folder_path) 

107 parse_common_folder_path = staticmethod( 

108 ConfigServiceV2Client.parse_common_folder_path 

109 ) 

110 common_organization_path = staticmethod( 

111 ConfigServiceV2Client.common_organization_path 

112 ) 

113 parse_common_organization_path = staticmethod( 

114 ConfigServiceV2Client.parse_common_organization_path 

115 ) 

116 common_project_path = staticmethod(ConfigServiceV2Client.common_project_path) 

117 parse_common_project_path = staticmethod( 

118 ConfigServiceV2Client.parse_common_project_path 

119 ) 

120 common_location_path = staticmethod(ConfigServiceV2Client.common_location_path) 

121 parse_common_location_path = staticmethod( 

122 ConfigServiceV2Client.parse_common_location_path 

123 ) 

124 

125 @classmethod 

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

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

128 info. 

129 

130 Args: 

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

132 args: Additional arguments to pass to the constructor. 

133 kwargs: Additional arguments to pass to the constructor. 

134 

135 Returns: 

136 ConfigServiceV2AsyncClient: The constructed client. 

137 """ 

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

139 

140 @classmethod 

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

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

143 file. 

144 

145 Args: 

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

147 file. 

148 args: Additional arguments to pass to the constructor. 

149 kwargs: Additional arguments to pass to the constructor. 

150 

151 Returns: 

152 ConfigServiceV2AsyncClient: The constructed client. 

153 """ 

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

155 

156 from_service_account_json = from_service_account_file 

157 

158 @classmethod 

159 def get_mtls_endpoint_and_cert_source( 

160 cls, client_options: Optional[ClientOptions] = None 

161 ): 

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

163 

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

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

166 client cert source is None. 

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

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

169 source is None. 

170 

171 The API endpoint is determined in the following order: 

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

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

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

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

176 use the default API endpoint. 

177 

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

179 

180 Args: 

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

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

183 in this method. 

184 

185 Returns: 

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

187 client cert source to use. 

188 

189 Raises: 

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

191 """ 

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

193 

194 @property 

195 def transport(self) -> ConfigServiceV2Transport: 

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

197 

198 Returns: 

199 ConfigServiceV2Transport: The transport used by the client instance. 

200 """ 

201 return self._client.transport 

202 

203 @property 

204 def api_endpoint(self): 

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

206 

207 Returns: 

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

209 """ 

210 return self._client._api_endpoint 

211 

212 @property 

213 def universe_domain(self) -> str: 

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

215 

216 Returns: 

217 str: The universe domain used 

218 by the client instance. 

219 """ 

220 return self._client._universe_domain 

221 

222 get_transport_class = ConfigServiceV2Client.get_transport_class 

223 

224 def __init__( 

225 self, 

226 *, 

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

228 transport: Optional[ 

229 Union[ 

230 str, ConfigServiceV2Transport, Callable[..., ConfigServiceV2Transport] 

231 ] 

232 ] = "grpc_asyncio", 

233 client_options: Optional[ClientOptions] = None, 

234 client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, 

235 ) -> None: 

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

237 

238 Args: 

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

240 authorization credentials to attach to requests. These 

241 credentials identify the application to the service; if none 

242 are specified, the client will attempt to ascertain the 

243 credentials from the environment. 

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

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

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

247 arguments as used in the ConfigServiceV2Transport constructor. 

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

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

250 Custom options for the client. 

251 

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

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

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

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

256 determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment 

257 variable, which have one of the following values: 

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

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

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

261 the default value). 

262 

263 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable 

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

265 to provide a client certificate for mTLS transport. If 

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

267 present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not 

268 set, no client certificate will be used. 

269 

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

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

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

273 currently not supported for mTLS. 

274 

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

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

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

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

279 your own client library. 

280 

281 Raises: 

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

283 creation failed for any reason. 

284 """ 

285 self._client = ConfigServiceV2Client( 

286 credentials=credentials, 

287 transport=transport, 

288 client_options=client_options, 

289 client_info=client_info, 

290 ) 

291 

292 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

293 std_logging.DEBUG 

294 ): # pragma: NO COVER 

295 _LOGGER.debug( 

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

297 extra={ 

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

299 "universeDomain": getattr( 

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

301 ), 

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

303 "credentialsInfo": getattr( 

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

305 )(), 

306 } 

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

308 else { 

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

310 "credentialsType": None, 

311 }, 

312 ) 

313 

314 async def list_buckets( 

315 self, 

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

317 *, 

318 parent: Optional[str] = None, 

319 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

322 ) -> pagers.ListBucketsAsyncPager: 

323 r"""Lists log buckets. 

324 

325 .. code-block:: python 

326 

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

328 # code template only. 

329 # It will require modifications to work: 

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

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

332 # client as shown in: 

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

334 from google.cloud import logging_v2 

335 

336 async def sample_list_buckets(): 

337 # Create a client 

338 client = logging_v2.ConfigServiceV2AsyncClient() 

339 

340 # Initialize request argument(s) 

341 request = logging_v2.ListBucketsRequest( 

342 parent="parent_value", 

343 ) 

344 

345 # Make the request 

346 page_result = client.list_buckets(request=request) 

347 

348 # Handle the response 

349 async for response in page_result: 

350 print(response) 

351 

352 Args: 

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

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

355 parent (:class:`str`): 

356 Required. The parent resource whose buckets are to be 

357 listed: 

358 

359 :: 

360 

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

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

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

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

365 

366 Note: The locations portion of the resource must be 

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

368 [LOCATION_ID] will return all buckets. 

369 

370 This corresponds to the ``parent`` field 

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

372 should not be set. 

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

374 should be retried. 

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

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

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

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

379 be of type `bytes`. 

380 

381 Returns: 

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

383 The response from ListBuckets. 

384 

385 Iterating over this object will yield 

386 results and resolve additional pages 

387 automatically. 

388 

389 """ 

390 # Create or coerce a protobuf request object. 

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

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

393 flattened_params = [parent] 

394 has_flattened_params = ( 

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

396 ) 

397 if request is not None and has_flattened_params: 

398 raise ValueError( 

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

400 "the individual field arguments should be set." 

401 ) 

402 

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

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

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

406 request = logging_config.ListBucketsRequest(request) 

407 

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

409 # request, apply these. 

410 if parent is not None: 

411 request.parent = parent 

412 

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

414 # and friendly error handling. 

415 rpc = self._client._transport._wrapped_methods[ 

416 self._client._transport.list_buckets 

417 ] 

418 

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

420 # add these here. 

421 metadata = tuple(metadata) + ( 

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

423 ) 

424 

425 # Validate the universe domain. 

426 self._client._validate_universe_domain() 

427 

428 # Send the request. 

429 response = await rpc( 

430 request, 

431 retry=retry, 

432 timeout=timeout, 

433 metadata=metadata, 

434 ) 

435 

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

437 # an `__aiter__` convenience method. 

438 response = pagers.ListBucketsAsyncPager( 

439 method=rpc, 

440 request=request, 

441 response=response, 

442 retry=retry, 

443 timeout=timeout, 

444 metadata=metadata, 

445 ) 

446 

447 # Done; return the response. 

448 return response 

449 

450 async def get_bucket( 

451 self, 

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

453 *, 

454 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

457 ) -> logging_config.LogBucket: 

458 r"""Gets a log bucket. 

459 

460 .. code-block:: python 

461 

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

463 # code template only. 

464 # It will require modifications to work: 

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

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

467 # client as shown in: 

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

469 from google.cloud import logging_v2 

470 

471 async def sample_get_bucket(): 

472 # Create a client 

473 client = logging_v2.ConfigServiceV2AsyncClient() 

474 

475 # Initialize request argument(s) 

476 request = logging_v2.GetBucketRequest( 

477 name="name_value", 

478 ) 

479 

480 # Make the request 

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

482 

483 # Handle the response 

484 print(response) 

485 

486 Args: 

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

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

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

490 should be retried. 

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

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

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

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

495 be of type `bytes`. 

496 

497 Returns: 

498 google.cloud.logging_v2.types.LogBucket: 

499 Describes a repository in which log 

500 entries are stored. 

501 

502 """ 

503 # Create or coerce a protobuf request object. 

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

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

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

507 request = logging_config.GetBucketRequest(request) 

508 

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

510 # and friendly error handling. 

511 rpc = self._client._transport._wrapped_methods[ 

512 self._client._transport.get_bucket 

513 ] 

514 

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

516 # add these here. 

517 metadata = tuple(metadata) + ( 

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

519 ) 

520 

521 # Validate the universe domain. 

522 self._client._validate_universe_domain() 

523 

524 # Send the request. 

525 response = await rpc( 

526 request, 

527 retry=retry, 

528 timeout=timeout, 

529 metadata=metadata, 

530 ) 

531 

532 # Done; return the response. 

533 return response 

534 

535 async def create_bucket_async( 

536 self, 

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

538 *, 

539 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

542 ) -> operation_async.AsyncOperation: 

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

544 to store log entries. 

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

546 cannot be changed. 

547 

548 .. code-block:: python 

549 

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

551 # code template only. 

552 # It will require modifications to work: 

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

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

555 # client as shown in: 

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

557 from google.cloud import logging_v2 

558 

559 async def sample_create_bucket_async(): 

560 # Create a client 

561 client = logging_v2.ConfigServiceV2AsyncClient() 

562 

563 # Initialize request argument(s) 

564 request = logging_v2.CreateBucketRequest( 

565 parent="parent_value", 

566 bucket_id="bucket_id_value", 

567 ) 

568 

569 # Make the request 

570 operation = client.create_bucket_async(request=request) 

571 

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

573 

574 response = (await operation).result() 

575 

576 # Handle the response 

577 print(response) 

578 

579 Args: 

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

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

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

583 should be retried. 

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

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

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

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

588 be of type `bytes`. 

589 

590 Returns: 

591 google.api_core.operation_async.AsyncOperation: 

592 An object representing a long-running operation. 

593 

594 The result type for the operation will be 

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

596 Describes a repository in which log entries are stored. 

597 

598 """ 

599 # Create or coerce a protobuf request object. 

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

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

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

603 request = logging_config.CreateBucketRequest(request) 

604 

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

606 # and friendly error handling. 

607 rpc = self._client._transport._wrapped_methods[ 

608 self._client._transport.create_bucket_async 

609 ] 

610 

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

612 # add these here. 

613 metadata = tuple(metadata) + ( 

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

615 ) 

616 

617 # Validate the universe domain. 

618 self._client._validate_universe_domain() 

619 

620 # Send the request. 

621 response = await rpc( 

622 request, 

623 retry=retry, 

624 timeout=timeout, 

625 metadata=metadata, 

626 ) 

627 

628 # Wrap the response in an operation future. 

629 response = operation_async.from_gapic( 

630 response, 

631 self._client._transport.operations_client, 

632 logging_config.LogBucket, 

633 metadata_type=logging_config.BucketMetadata, 

634 ) 

635 

636 # Done; return the response. 

637 return response 

638 

639 async def update_bucket_async( 

640 self, 

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

642 *, 

643 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

646 ) -> operation_async.AsyncOperation: 

647 r"""Updates a log bucket asynchronously. 

648 

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

650 then ``FAILED_PRECONDITION`` will be returned. 

651 

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

653 changed. 

654 

655 .. code-block:: python 

656 

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

658 # code template only. 

659 # It will require modifications to work: 

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

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

662 # client as shown in: 

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

664 from google.cloud import logging_v2 

665 

666 async def sample_update_bucket_async(): 

667 # Create a client 

668 client = logging_v2.ConfigServiceV2AsyncClient() 

669 

670 # Initialize request argument(s) 

671 request = logging_v2.UpdateBucketRequest( 

672 name="name_value", 

673 ) 

674 

675 # Make the request 

676 operation = client.update_bucket_async(request=request) 

677 

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

679 

680 response = (await operation).result() 

681 

682 # Handle the response 

683 print(response) 

684 

685 Args: 

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

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

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

689 should be retried. 

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

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

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

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

694 be of type `bytes`. 

695 

696 Returns: 

697 google.api_core.operation_async.AsyncOperation: 

698 An object representing a long-running operation. 

699 

700 The result type for the operation will be 

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

702 Describes a repository in which log entries are stored. 

703 

704 """ 

705 # Create or coerce a protobuf request object. 

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

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

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

709 request = logging_config.UpdateBucketRequest(request) 

710 

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

712 # and friendly error handling. 

713 rpc = self._client._transport._wrapped_methods[ 

714 self._client._transport.update_bucket_async 

715 ] 

716 

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

718 # add these here. 

719 metadata = tuple(metadata) + ( 

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

721 ) 

722 

723 # Validate the universe domain. 

724 self._client._validate_universe_domain() 

725 

726 # Send the request. 

727 response = await rpc( 

728 request, 

729 retry=retry, 

730 timeout=timeout, 

731 metadata=metadata, 

732 ) 

733 

734 # Wrap the response in an operation future. 

735 response = operation_async.from_gapic( 

736 response, 

737 self._client._transport.operations_client, 

738 logging_config.LogBucket, 

739 metadata_type=logging_config.BucketMetadata, 

740 ) 

741 

742 # Done; return the response. 

743 return response 

744 

745 async def create_bucket( 

746 self, 

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

748 *, 

749 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

752 ) -> logging_config.LogBucket: 

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

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

755 location cannot be changed. 

756 

757 .. code-block:: python 

758 

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

760 # code template only. 

761 # It will require modifications to work: 

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

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

764 # client as shown in: 

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

766 from google.cloud import logging_v2 

767 

768 async def sample_create_bucket(): 

769 # Create a client 

770 client = logging_v2.ConfigServiceV2AsyncClient() 

771 

772 # Initialize request argument(s) 

773 request = logging_v2.CreateBucketRequest( 

774 parent="parent_value", 

775 bucket_id="bucket_id_value", 

776 ) 

777 

778 # Make the request 

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

780 

781 # Handle the response 

782 print(response) 

783 

784 Args: 

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

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

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

788 should be retried. 

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

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

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

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

793 be of type `bytes`. 

794 

795 Returns: 

796 google.cloud.logging_v2.types.LogBucket: 

797 Describes a repository in which log 

798 entries are stored. 

799 

800 """ 

801 # Create or coerce a protobuf request object. 

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

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

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

805 request = logging_config.CreateBucketRequest(request) 

806 

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

808 # and friendly error handling. 

809 rpc = self._client._transport._wrapped_methods[ 

810 self._client._transport.create_bucket 

811 ] 

812 

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

814 # add these here. 

815 metadata = tuple(metadata) + ( 

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

817 ) 

818 

819 # Validate the universe domain. 

820 self._client._validate_universe_domain() 

821 

822 # Send the request. 

823 response = await rpc( 

824 request, 

825 retry=retry, 

826 timeout=timeout, 

827 metadata=metadata, 

828 ) 

829 

830 # Done; return the response. 

831 return response 

832 

833 async def update_bucket( 

834 self, 

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

836 *, 

837 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

840 ) -> logging_config.LogBucket: 

841 r"""Updates a log bucket. 

842 

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

844 then ``FAILED_PRECONDITION`` will be returned. 

845 

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

847 changed. 

848 

849 .. code-block:: python 

850 

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

852 # code template only. 

853 # It will require modifications to work: 

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

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

856 # client as shown in: 

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

858 from google.cloud import logging_v2 

859 

860 async def sample_update_bucket(): 

861 # Create a client 

862 client = logging_v2.ConfigServiceV2AsyncClient() 

863 

864 # Initialize request argument(s) 

865 request = logging_v2.UpdateBucketRequest( 

866 name="name_value", 

867 ) 

868 

869 # Make the request 

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

871 

872 # Handle the response 

873 print(response) 

874 

875 Args: 

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

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

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

879 should be retried. 

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

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

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

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

884 be of type `bytes`. 

885 

886 Returns: 

887 google.cloud.logging_v2.types.LogBucket: 

888 Describes a repository in which log 

889 entries are stored. 

890 

891 """ 

892 # Create or coerce a protobuf request object. 

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

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

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

896 request = logging_config.UpdateBucketRequest(request) 

897 

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

899 # and friendly error handling. 

900 rpc = self._client._transport._wrapped_methods[ 

901 self._client._transport.update_bucket 

902 ] 

903 

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

905 # add these here. 

906 metadata = tuple(metadata) + ( 

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

908 ) 

909 

910 # Validate the universe domain. 

911 self._client._validate_universe_domain() 

912 

913 # Send the request. 

914 response = await rpc( 

915 request, 

916 retry=retry, 

917 timeout=timeout, 

918 metadata=metadata, 

919 ) 

920 

921 # Done; return the response. 

922 return response 

923 

924 async def delete_bucket( 

925 self, 

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

927 *, 

928 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

931 ) -> None: 

932 r"""Deletes a log bucket. 

933 

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

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

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

937 deleted. 

938 

939 .. code-block:: python 

940 

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

942 # code template only. 

943 # It will require modifications to work: 

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

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

946 # client as shown in: 

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

948 from google.cloud import logging_v2 

949 

950 async def sample_delete_bucket(): 

951 # Create a client 

952 client = logging_v2.ConfigServiceV2AsyncClient() 

953 

954 # Initialize request argument(s) 

955 request = logging_v2.DeleteBucketRequest( 

956 name="name_value", 

957 ) 

958 

959 # Make the request 

960 await client.delete_bucket(request=request) 

961 

962 Args: 

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

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

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

966 should be retried. 

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

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

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

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

971 be of type `bytes`. 

972 """ 

973 # Create or coerce a protobuf request object. 

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

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

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

977 request = logging_config.DeleteBucketRequest(request) 

978 

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

980 # and friendly error handling. 

981 rpc = self._client._transport._wrapped_methods[ 

982 self._client._transport.delete_bucket 

983 ] 

984 

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

986 # add these here. 

987 metadata = tuple(metadata) + ( 

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

989 ) 

990 

991 # Validate the universe domain. 

992 self._client._validate_universe_domain() 

993 

994 # Send the request. 

995 await rpc( 

996 request, 

997 retry=retry, 

998 timeout=timeout, 

999 metadata=metadata, 

1000 ) 

1001 

1002 async def undelete_bucket( 

1003 self, 

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

1005 *, 

1006 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

1009 ) -> None: 

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

1011 deleted can be undeleted within the grace period of 7 

1012 days. 

1013 

1014 .. code-block:: python 

1015 

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

1017 # code template only. 

1018 # It will require modifications to work: 

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

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

1021 # client as shown in: 

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

1023 from google.cloud import logging_v2 

1024 

1025 async def sample_undelete_bucket(): 

1026 # Create a client 

1027 client = logging_v2.ConfigServiceV2AsyncClient() 

1028 

1029 # Initialize request argument(s) 

1030 request = logging_v2.UndeleteBucketRequest( 

1031 name="name_value", 

1032 ) 

1033 

1034 # Make the request 

1035 await client.undelete_bucket(request=request) 

1036 

1037 Args: 

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

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

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

1041 should be retried. 

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

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

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

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

1046 be of type `bytes`. 

1047 """ 

1048 # Create or coerce a protobuf request object. 

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

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

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

1052 request = logging_config.UndeleteBucketRequest(request) 

1053 

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

1055 # and friendly error handling. 

1056 rpc = self._client._transport._wrapped_methods[ 

1057 self._client._transport.undelete_bucket 

1058 ] 

1059 

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

1061 # add these here. 

1062 metadata = tuple(metadata) + ( 

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

1064 ) 

1065 

1066 # Validate the universe domain. 

1067 self._client._validate_universe_domain() 

1068 

1069 # Send the request. 

1070 await rpc( 

1071 request, 

1072 retry=retry, 

1073 timeout=timeout, 

1074 metadata=metadata, 

1075 ) 

1076 

1077 async def list_views( 

1078 self, 

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

1080 *, 

1081 parent: Optional[str] = None, 

1082 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

1085 ) -> pagers.ListViewsAsyncPager: 

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

1087 

1088 .. code-block:: python 

1089 

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

1091 # code template only. 

1092 # It will require modifications to work: 

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

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

1095 # client as shown in: 

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

1097 from google.cloud import logging_v2 

1098 

1099 async def sample_list_views(): 

1100 # Create a client 

1101 client = logging_v2.ConfigServiceV2AsyncClient() 

1102 

1103 # Initialize request argument(s) 

1104 request = logging_v2.ListViewsRequest( 

1105 parent="parent_value", 

1106 ) 

1107 

1108 # Make the request 

1109 page_result = client.list_views(request=request) 

1110 

1111 # Handle the response 

1112 async for response in page_result: 

1113 print(response) 

1114 

1115 Args: 

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

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

1118 parent (:class:`str`): 

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

1120 

1121 :: 

1122 

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

1124 

1125 This corresponds to the ``parent`` field 

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

1127 should not be set. 

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

1129 should be retried. 

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

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

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

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

1134 be of type `bytes`. 

1135 

1136 Returns: 

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

1138 The response from ListViews. 

1139 

1140 Iterating over this object will yield 

1141 results and resolve additional pages 

1142 automatically. 

1143 

1144 """ 

1145 # Create or coerce a protobuf request object. 

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

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

1148 flattened_params = [parent] 

1149 has_flattened_params = ( 

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

1151 ) 

1152 if request is not None and has_flattened_params: 

1153 raise ValueError( 

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

1155 "the individual field arguments should be set." 

1156 ) 

1157 

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

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

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

1161 request = logging_config.ListViewsRequest(request) 

1162 

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

1164 # request, apply these. 

1165 if parent is not None: 

1166 request.parent = parent 

1167 

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

1169 # and friendly error handling. 

1170 rpc = self._client._transport._wrapped_methods[ 

1171 self._client._transport.list_views 

1172 ] 

1173 

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

1175 # add these here. 

1176 metadata = tuple(metadata) + ( 

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

1178 ) 

1179 

1180 # Validate the universe domain. 

1181 self._client._validate_universe_domain() 

1182 

1183 # Send the request. 

1184 response = await rpc( 

1185 request, 

1186 retry=retry, 

1187 timeout=timeout, 

1188 metadata=metadata, 

1189 ) 

1190 

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

1192 # an `__aiter__` convenience method. 

1193 response = pagers.ListViewsAsyncPager( 

1194 method=rpc, 

1195 request=request, 

1196 response=response, 

1197 retry=retry, 

1198 timeout=timeout, 

1199 metadata=metadata, 

1200 ) 

1201 

1202 # Done; return the response. 

1203 return response 

1204 

1205 async def get_view( 

1206 self, 

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

1208 *, 

1209 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

1212 ) -> logging_config.LogView: 

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

1214 

1215 .. code-block:: python 

1216 

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

1218 # code template only. 

1219 # It will require modifications to work: 

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

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

1222 # client as shown in: 

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

1224 from google.cloud import logging_v2 

1225 

1226 async def sample_get_view(): 

1227 # Create a client 

1228 client = logging_v2.ConfigServiceV2AsyncClient() 

1229 

1230 # Initialize request argument(s) 

1231 request = logging_v2.GetViewRequest( 

1232 name="name_value", 

1233 ) 

1234 

1235 # Make the request 

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

1237 

1238 # Handle the response 

1239 print(response) 

1240 

1241 Args: 

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

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

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

1245 should be retried. 

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

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

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

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

1250 be of type `bytes`. 

1251 

1252 Returns: 

1253 google.cloud.logging_v2.types.LogView: 

1254 Describes a view over log entries in 

1255 a bucket. 

1256 

1257 """ 

1258 # Create or coerce a protobuf request object. 

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

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

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

1262 request = logging_config.GetViewRequest(request) 

1263 

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

1265 # and friendly error handling. 

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

1267 

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

1269 # add these here. 

1270 metadata = tuple(metadata) + ( 

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

1272 ) 

1273 

1274 # Validate the universe domain. 

1275 self._client._validate_universe_domain() 

1276 

1277 # Send the request. 

1278 response = await rpc( 

1279 request, 

1280 retry=retry, 

1281 timeout=timeout, 

1282 metadata=metadata, 

1283 ) 

1284 

1285 # Done; return the response. 

1286 return response 

1287 

1288 async def create_view( 

1289 self, 

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

1291 *, 

1292 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

1295 ) -> logging_config.LogView: 

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

1297 bucket may contain a maximum of 30 views. 

1298 

1299 .. code-block:: python 

1300 

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

1302 # code template only. 

1303 # It will require modifications to work: 

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

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

1306 # client as shown in: 

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

1308 from google.cloud import logging_v2 

1309 

1310 async def sample_create_view(): 

1311 # Create a client 

1312 client = logging_v2.ConfigServiceV2AsyncClient() 

1313 

1314 # Initialize request argument(s) 

1315 request = logging_v2.CreateViewRequest( 

1316 parent="parent_value", 

1317 view_id="view_id_value", 

1318 ) 

1319 

1320 # Make the request 

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

1322 

1323 # Handle the response 

1324 print(response) 

1325 

1326 Args: 

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

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

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

1330 should be retried. 

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

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

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

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

1335 be of type `bytes`. 

1336 

1337 Returns: 

1338 google.cloud.logging_v2.types.LogView: 

1339 Describes a view over log entries in 

1340 a bucket. 

1341 

1342 """ 

1343 # Create or coerce a protobuf request object. 

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

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

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

1347 request = logging_config.CreateViewRequest(request) 

1348 

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

1350 # and friendly error handling. 

1351 rpc = self._client._transport._wrapped_methods[ 

1352 self._client._transport.create_view 

1353 ] 

1354 

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

1356 # add these here. 

1357 metadata = tuple(metadata) + ( 

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

1359 ) 

1360 

1361 # Validate the universe domain. 

1362 self._client._validate_universe_domain() 

1363 

1364 # Send the request. 

1365 response = await rpc( 

1366 request, 

1367 retry=retry, 

1368 timeout=timeout, 

1369 metadata=metadata, 

1370 ) 

1371 

1372 # Done; return the response. 

1373 return response 

1374 

1375 async def update_view( 

1376 self, 

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

1378 *, 

1379 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

1382 ) -> logging_config.LogView: 

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

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

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

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

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

1388 

1389 .. code-block:: python 

1390 

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

1392 # code template only. 

1393 # It will require modifications to work: 

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

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

1396 # client as shown in: 

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

1398 from google.cloud import logging_v2 

1399 

1400 async def sample_update_view(): 

1401 # Create a client 

1402 client = logging_v2.ConfigServiceV2AsyncClient() 

1403 

1404 # Initialize request argument(s) 

1405 request = logging_v2.UpdateViewRequest( 

1406 name="name_value", 

1407 ) 

1408 

1409 # Make the request 

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

1411 

1412 # Handle the response 

1413 print(response) 

1414 

1415 Args: 

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

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

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

1419 should be retried. 

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

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

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

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

1424 be of type `bytes`. 

1425 

1426 Returns: 

1427 google.cloud.logging_v2.types.LogView: 

1428 Describes a view over log entries in 

1429 a bucket. 

1430 

1431 """ 

1432 # Create or coerce a protobuf request object. 

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

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

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

1436 request = logging_config.UpdateViewRequest(request) 

1437 

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

1439 # and friendly error handling. 

1440 rpc = self._client._transport._wrapped_methods[ 

1441 self._client._transport.update_view 

1442 ] 

1443 

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

1445 # add these here. 

1446 metadata = tuple(metadata) + ( 

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

1448 ) 

1449 

1450 # Validate the universe domain. 

1451 self._client._validate_universe_domain() 

1452 

1453 # Send the request. 

1454 response = await rpc( 

1455 request, 

1456 retry=retry, 

1457 timeout=timeout, 

1458 metadata=metadata, 

1459 ) 

1460 

1461 # Done; return the response. 

1462 return response 

1463 

1464 async def delete_view( 

1465 self, 

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

1467 *, 

1468 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

1471 ) -> None: 

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

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

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

1475 minutes. 

1476 

1477 .. code-block:: python 

1478 

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

1480 # code template only. 

1481 # It will require modifications to work: 

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

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

1484 # client as shown in: 

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

1486 from google.cloud import logging_v2 

1487 

1488 async def sample_delete_view(): 

1489 # Create a client 

1490 client = logging_v2.ConfigServiceV2AsyncClient() 

1491 

1492 # Initialize request argument(s) 

1493 request = logging_v2.DeleteViewRequest( 

1494 name="name_value", 

1495 ) 

1496 

1497 # Make the request 

1498 await client.delete_view(request=request) 

1499 

1500 Args: 

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

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

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

1504 should be retried. 

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

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

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

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

1509 be of type `bytes`. 

1510 """ 

1511 # Create or coerce a protobuf request object. 

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

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

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

1515 request = logging_config.DeleteViewRequest(request) 

1516 

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

1518 # and friendly error handling. 

1519 rpc = self._client._transport._wrapped_methods[ 

1520 self._client._transport.delete_view 

1521 ] 

1522 

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

1524 # add these here. 

1525 metadata = tuple(metadata) + ( 

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

1527 ) 

1528 

1529 # Validate the universe domain. 

1530 self._client._validate_universe_domain() 

1531 

1532 # Send the request. 

1533 await rpc( 

1534 request, 

1535 retry=retry, 

1536 timeout=timeout, 

1537 metadata=metadata, 

1538 ) 

1539 

1540 async def list_sinks( 

1541 self, 

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

1543 *, 

1544 parent: Optional[str] = None, 

1545 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

1548 ) -> pagers.ListSinksAsyncPager: 

1549 r"""Lists sinks. 

1550 

1551 .. code-block:: python 

1552 

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

1554 # code template only. 

1555 # It will require modifications to work: 

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

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

1558 # client as shown in: 

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

1560 from google.cloud import logging_v2 

1561 

1562 async def sample_list_sinks(): 

1563 # Create a client 

1564 client = logging_v2.ConfigServiceV2AsyncClient() 

1565 

1566 # Initialize request argument(s) 

1567 request = logging_v2.ListSinksRequest( 

1568 parent="parent_value", 

1569 ) 

1570 

1571 # Make the request 

1572 page_result = client.list_sinks(request=request) 

1573 

1574 # Handle the response 

1575 async for response in page_result: 

1576 print(response) 

1577 

1578 Args: 

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

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

1581 parent (:class:`str`): 

1582 Required. The parent resource whose sinks are to be 

1583 listed: 

1584 

1585 :: 

1586 

1587 "projects/[PROJECT_ID]" 

1588 "organizations/[ORGANIZATION_ID]" 

1589 "billingAccounts/[BILLING_ACCOUNT_ID]" 

1590 "folders/[FOLDER_ID]" 

1591 

1592 This corresponds to the ``parent`` field 

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

1594 should not be set. 

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

1596 should be retried. 

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

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

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

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

1601 be of type `bytes`. 

1602 

1603 Returns: 

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

1605 Result returned from ListSinks. 

1606 

1607 Iterating over this object will yield results and 

1608 resolve additional pages automatically. 

1609 

1610 """ 

1611 # Create or coerce a protobuf request object. 

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

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

1614 flattened_params = [parent] 

1615 has_flattened_params = ( 

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

1617 ) 

1618 if request is not None and has_flattened_params: 

1619 raise ValueError( 

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

1621 "the individual field arguments should be set." 

1622 ) 

1623 

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

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

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

1627 request = logging_config.ListSinksRequest(request) 

1628 

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

1630 # request, apply these. 

1631 if parent is not None: 

1632 request.parent = parent 

1633 

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

1635 # and friendly error handling. 

1636 rpc = self._client._transport._wrapped_methods[ 

1637 self._client._transport.list_sinks 

1638 ] 

1639 

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

1641 # add these here. 

1642 metadata = tuple(metadata) + ( 

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

1644 ) 

1645 

1646 # Validate the universe domain. 

1647 self._client._validate_universe_domain() 

1648 

1649 # Send the request. 

1650 response = await rpc( 

1651 request, 

1652 retry=retry, 

1653 timeout=timeout, 

1654 metadata=metadata, 

1655 ) 

1656 

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

1658 # an `__aiter__` convenience method. 

1659 response = pagers.ListSinksAsyncPager( 

1660 method=rpc, 

1661 request=request, 

1662 response=response, 

1663 retry=retry, 

1664 timeout=timeout, 

1665 metadata=metadata, 

1666 ) 

1667 

1668 # Done; return the response. 

1669 return response 

1670 

1671 async def get_sink( 

1672 self, 

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

1674 *, 

1675 sink_name: Optional[str] = None, 

1676 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

1679 ) -> logging_config.LogSink: 

1680 r"""Gets a sink. 

1681 

1682 .. code-block:: python 

1683 

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

1685 # code template only. 

1686 # It will require modifications to work: 

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

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

1689 # client as shown in: 

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

1691 from google.cloud import logging_v2 

1692 

1693 async def sample_get_sink(): 

1694 # Create a client 

1695 client = logging_v2.ConfigServiceV2AsyncClient() 

1696 

1697 # Initialize request argument(s) 

1698 request = logging_v2.GetSinkRequest( 

1699 sink_name="sink_name_value", 

1700 ) 

1701 

1702 # Make the request 

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

1704 

1705 # Handle the response 

1706 print(response) 

1707 

1708 Args: 

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

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

1711 sink_name (:class:`str`): 

1712 Required. The resource name of the sink: 

1713 

1714 :: 

1715 

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

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

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

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

1720 

1721 For example: 

1722 

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

1724 

1725 This corresponds to the ``sink_name`` field 

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

1727 should not be set. 

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

1729 should be retried. 

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

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

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

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

1734 be of type `bytes`. 

1735 

1736 Returns: 

1737 google.cloud.logging_v2.types.LogSink: 

1738 Describes a sink used to export log 

1739 entries to one of the following 

1740 destinations in any project: a Cloud 

1741 Storage bucket, a BigQuery dataset, a 

1742 Pub/Sub topic or a Cloud Logging log 

1743 bucket. A logs filter controls which log 

1744 entries are exported. The sink must be 

1745 created within a project, organization, 

1746 billing account, or folder. 

1747 

1748 """ 

1749 # Create or coerce a protobuf request object. 

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

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

1752 flattened_params = [sink_name] 

1753 has_flattened_params = ( 

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

1755 ) 

1756 if request is not None and has_flattened_params: 

1757 raise ValueError( 

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

1759 "the individual field arguments should be set." 

1760 ) 

1761 

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

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

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

1765 request = logging_config.GetSinkRequest(request) 

1766 

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

1768 # request, apply these. 

1769 if sink_name is not None: 

1770 request.sink_name = sink_name 

1771 

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

1773 # and friendly error handling. 

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

1775 

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

1777 # add these here. 

1778 metadata = tuple(metadata) + ( 

1779 gapic_v1.routing_header.to_grpc_metadata( 

1780 (("sink_name", request.sink_name),) 

1781 ), 

1782 ) 

1783 

1784 # Validate the universe domain. 

1785 self._client._validate_universe_domain() 

1786 

1787 # Send the request. 

1788 response = await rpc( 

1789 request, 

1790 retry=retry, 

1791 timeout=timeout, 

1792 metadata=metadata, 

1793 ) 

1794 

1795 # Done; return the response. 

1796 return response 

1797 

1798 async def create_sink( 

1799 self, 

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

1801 *, 

1802 parent: Optional[str] = None, 

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

1804 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

1807 ) -> logging_config.LogSink: 

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

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

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

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

1812 entries only from the resource owning the sink. 

1813 

1814 .. code-block:: python 

1815 

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

1817 # code template only. 

1818 # It will require modifications to work: 

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

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

1821 # client as shown in: 

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

1823 from google.cloud import logging_v2 

1824 

1825 async def sample_create_sink(): 

1826 # Create a client 

1827 client = logging_v2.ConfigServiceV2AsyncClient() 

1828 

1829 # Initialize request argument(s) 

1830 sink = logging_v2.LogSink() 

1831 sink.name = "name_value" 

1832 sink.destination = "destination_value" 

1833 

1834 request = logging_v2.CreateSinkRequest( 

1835 parent="parent_value", 

1836 sink=sink, 

1837 ) 

1838 

1839 # Make the request 

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

1841 

1842 # Handle the response 

1843 print(response) 

1844 

1845 Args: 

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

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

1848 parent (:class:`str`): 

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

1850 

1851 :: 

1852 

1853 "projects/[PROJECT_ID]" 

1854 "organizations/[ORGANIZATION_ID]" 

1855 "billingAccounts/[BILLING_ACCOUNT_ID]" 

1856 "folders/[FOLDER_ID]" 

1857 

1858 For examples: 

1859 

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

1861 

1862 This corresponds to the ``parent`` field 

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

1864 should not be set. 

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

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

1867 sink identifier that is not already in use. 

1868 

1869 This corresponds to the ``sink`` field 

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

1871 should not be set. 

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

1873 should be retried. 

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

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

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

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

1878 be of type `bytes`. 

1879 

1880 Returns: 

1881 google.cloud.logging_v2.types.LogSink: 

1882 Describes a sink used to export log 

1883 entries to one of the following 

1884 destinations in any project: a Cloud 

1885 Storage bucket, a BigQuery dataset, a 

1886 Pub/Sub topic or a Cloud Logging log 

1887 bucket. A logs filter controls which log 

1888 entries are exported. The sink must be 

1889 created within a project, organization, 

1890 billing account, or folder. 

1891 

1892 """ 

1893 # Create or coerce a protobuf request object. 

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

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

1896 flattened_params = [parent, sink] 

1897 has_flattened_params = ( 

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

1899 ) 

1900 if request is not None and has_flattened_params: 

1901 raise ValueError( 

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

1903 "the individual field arguments should be set." 

1904 ) 

1905 

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

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

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

1909 request = logging_config.CreateSinkRequest(request) 

1910 

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

1912 # request, apply these. 

1913 if parent is not None: 

1914 request.parent = parent 

1915 if sink is not None: 

1916 request.sink = sink 

1917 

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

1919 # and friendly error handling. 

1920 rpc = self._client._transport._wrapped_methods[ 

1921 self._client._transport.create_sink 

1922 ] 

1923 

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

1925 # add these here. 

1926 metadata = tuple(metadata) + ( 

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

1928 ) 

1929 

1930 # Validate the universe domain. 

1931 self._client._validate_universe_domain() 

1932 

1933 # Send the request. 

1934 response = await rpc( 

1935 request, 

1936 retry=retry, 

1937 timeout=timeout, 

1938 metadata=metadata, 

1939 ) 

1940 

1941 # Done; return the response. 

1942 return response 

1943 

1944 async def update_sink( 

1945 self, 

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

1947 *, 

1948 sink_name: Optional[str] = None, 

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

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

1951 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

1954 ) -> logging_config.LogSink: 

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

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

1957 and ``filter``. 

1958 

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

1960 the ``unique_writer_identity`` field. 

1961 

1962 .. code-block:: python 

1963 

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

1965 # code template only. 

1966 # It will require modifications to work: 

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

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

1969 # client as shown in: 

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

1971 from google.cloud import logging_v2 

1972 

1973 async def sample_update_sink(): 

1974 # Create a client 

1975 client = logging_v2.ConfigServiceV2AsyncClient() 

1976 

1977 # Initialize request argument(s) 

1978 sink = logging_v2.LogSink() 

1979 sink.name = "name_value" 

1980 sink.destination = "destination_value" 

1981 

1982 request = logging_v2.UpdateSinkRequest( 

1983 sink_name="sink_name_value", 

1984 sink=sink, 

1985 ) 

1986 

1987 # Make the request 

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

1989 

1990 # Handle the response 

1991 print(response) 

1992 

1993 Args: 

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

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

1996 sink_name (:class:`str`): 

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

1998 including the parent resource and the sink identifier: 

1999 

2000 :: 

2001 

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

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

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

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

2006 

2007 For example: 

2008 

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

2010 

2011 This corresponds to the ``sink_name`` field 

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

2013 should not be set. 

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

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

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

2017 

2018 This corresponds to the ``sink`` field 

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

2020 should not be set. 

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

2022 Optional. Field mask that specifies the fields in 

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

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

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

2026 

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

2028 the following mask for backwards compatibility purposes: 

2029 

2030 ``destination,filter,includeChildren`` 

2031 

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

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

2034 

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

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

2037 

2038 For example: ``updateMask=filter`` 

2039 

2040 This corresponds to the ``update_mask`` field 

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

2042 should not be set. 

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

2044 should be retried. 

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

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

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

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

2049 be of type `bytes`. 

2050 

2051 Returns: 

2052 google.cloud.logging_v2.types.LogSink: 

2053 Describes a sink used to export log 

2054 entries to one of the following 

2055 destinations in any project: a Cloud 

2056 Storage bucket, a BigQuery dataset, a 

2057 Pub/Sub topic or a Cloud Logging log 

2058 bucket. A logs filter controls which log 

2059 entries are exported. The sink must be 

2060 created within a project, organization, 

2061 billing account, or folder. 

2062 

2063 """ 

2064 # Create or coerce a protobuf request object. 

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

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

2067 flattened_params = [sink_name, sink, update_mask] 

2068 has_flattened_params = ( 

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

2070 ) 

2071 if request is not None and has_flattened_params: 

2072 raise ValueError( 

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

2074 "the individual field arguments should be set." 

2075 ) 

2076 

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

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

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

2080 request = logging_config.UpdateSinkRequest(request) 

2081 

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

2083 # request, apply these. 

2084 if sink_name is not None: 

2085 request.sink_name = sink_name 

2086 if sink is not None: 

2087 request.sink = sink 

2088 if update_mask is not None: 

2089 request.update_mask = update_mask 

2090 

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

2092 # and friendly error handling. 

2093 rpc = self._client._transport._wrapped_methods[ 

2094 self._client._transport.update_sink 

2095 ] 

2096 

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

2098 # add these here. 

2099 metadata = tuple(metadata) + ( 

2100 gapic_v1.routing_header.to_grpc_metadata( 

2101 (("sink_name", request.sink_name),) 

2102 ), 

2103 ) 

2104 

2105 # Validate the universe domain. 

2106 self._client._validate_universe_domain() 

2107 

2108 # Send the request. 

2109 response = await rpc( 

2110 request, 

2111 retry=retry, 

2112 timeout=timeout, 

2113 metadata=metadata, 

2114 ) 

2115 

2116 # Done; return the response. 

2117 return response 

2118 

2119 async def delete_sink( 

2120 self, 

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

2122 *, 

2123 sink_name: Optional[str] = None, 

2124 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

2127 ) -> None: 

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

2129 then that service account is also deleted. 

2130 

2131 .. code-block:: python 

2132 

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

2134 # code template only. 

2135 # It will require modifications to work: 

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

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

2138 # client as shown in: 

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

2140 from google.cloud import logging_v2 

2141 

2142 async def sample_delete_sink(): 

2143 # Create a client 

2144 client = logging_v2.ConfigServiceV2AsyncClient() 

2145 

2146 # Initialize request argument(s) 

2147 request = logging_v2.DeleteSinkRequest( 

2148 sink_name="sink_name_value", 

2149 ) 

2150 

2151 # Make the request 

2152 await client.delete_sink(request=request) 

2153 

2154 Args: 

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

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

2157 sink_name (:class:`str`): 

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

2159 including the parent resource and the sink identifier: 

2160 

2161 :: 

2162 

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

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

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

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

2167 

2168 For example: 

2169 

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

2171 

2172 This corresponds to the ``sink_name`` field 

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

2174 should not be set. 

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

2176 should be retried. 

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

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

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

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

2181 be of type `bytes`. 

2182 """ 

2183 # Create or coerce a protobuf request object. 

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

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

2186 flattened_params = [sink_name] 

2187 has_flattened_params = ( 

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

2189 ) 

2190 if request is not None and has_flattened_params: 

2191 raise ValueError( 

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

2193 "the individual field arguments should be set." 

2194 ) 

2195 

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

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

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

2199 request = logging_config.DeleteSinkRequest(request) 

2200 

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

2202 # request, apply these. 

2203 if sink_name is not None: 

2204 request.sink_name = sink_name 

2205 

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

2207 # and friendly error handling. 

2208 rpc = self._client._transport._wrapped_methods[ 

2209 self._client._transport.delete_sink 

2210 ] 

2211 

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

2213 # add these here. 

2214 metadata = tuple(metadata) + ( 

2215 gapic_v1.routing_header.to_grpc_metadata( 

2216 (("sink_name", request.sink_name),) 

2217 ), 

2218 ) 

2219 

2220 # Validate the universe domain. 

2221 self._client._validate_universe_domain() 

2222 

2223 # Send the request. 

2224 await rpc( 

2225 request, 

2226 retry=retry, 

2227 timeout=timeout, 

2228 metadata=metadata, 

2229 ) 

2230 

2231 async def create_link( 

2232 self, 

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

2234 *, 

2235 parent: Optional[str] = None, 

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

2237 link_id: Optional[str] = None, 

2238 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

2241 ) -> operation_async.AsyncOperation: 

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

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

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

2245 only contain one link. 

2246 

2247 .. code-block:: python 

2248 

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

2250 # code template only. 

2251 # It will require modifications to work: 

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

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

2254 # client as shown in: 

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

2256 from google.cloud import logging_v2 

2257 

2258 async def sample_create_link(): 

2259 # Create a client 

2260 client = logging_v2.ConfigServiceV2AsyncClient() 

2261 

2262 # Initialize request argument(s) 

2263 request = logging_v2.CreateLinkRequest( 

2264 parent="parent_value", 

2265 link_id="link_id_value", 

2266 ) 

2267 

2268 # Make the request 

2269 operation = client.create_link(request=request) 

2270 

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

2272 

2273 response = (await operation).result() 

2274 

2275 # Handle the response 

2276 print(response) 

2277 

2278 Args: 

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

2280 The request object. The parameters to CreateLink. 

2281 parent (:class:`str`): 

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

2283 a link for. 

2284 

2285 :: 

2286 

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

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

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

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

2291 

2292 This corresponds to the ``parent`` field 

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

2294 should not be set. 

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

2296 Required. The new link. 

2297 This corresponds to the ``link`` field 

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

2299 should not be set. 

2300 link_id (:class:`str`): 

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

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

2303 have alphanumeric characters and underscores within it. 

2304 

2305 This corresponds to the ``link_id`` field 

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

2307 should not be set. 

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

2309 should be retried. 

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

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

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

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

2314 be of type `bytes`. 

2315 

2316 Returns: 

2317 google.api_core.operation_async.AsyncOperation: 

2318 An object representing a long-running operation. 

2319 

2320 The result type for the operation will be 

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

2322 link connected to an analytics enabled bucket. 

2323 

2324 """ 

2325 # Create or coerce a protobuf request object. 

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

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

2328 flattened_params = [parent, link, link_id] 

2329 has_flattened_params = ( 

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

2331 ) 

2332 if request is not None and has_flattened_params: 

2333 raise ValueError( 

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

2335 "the individual field arguments should be set." 

2336 ) 

2337 

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

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

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

2341 request = logging_config.CreateLinkRequest(request) 

2342 

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

2344 # request, apply these. 

2345 if parent is not None: 

2346 request.parent = parent 

2347 if link is not None: 

2348 request.link = link 

2349 if link_id is not None: 

2350 request.link_id = link_id 

2351 

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

2353 # and friendly error handling. 

2354 rpc = self._client._transport._wrapped_methods[ 

2355 self._client._transport.create_link 

2356 ] 

2357 

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

2359 # add these here. 

2360 metadata = tuple(metadata) + ( 

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

2362 ) 

2363 

2364 # Validate the universe domain. 

2365 self._client._validate_universe_domain() 

2366 

2367 # Send the request. 

2368 response = await rpc( 

2369 request, 

2370 retry=retry, 

2371 timeout=timeout, 

2372 metadata=metadata, 

2373 ) 

2374 

2375 # Wrap the response in an operation future. 

2376 response = operation_async.from_gapic( 

2377 response, 

2378 self._client._transport.operations_client, 

2379 logging_config.Link, 

2380 metadata_type=logging_config.LinkMetadata, 

2381 ) 

2382 

2383 # Done; return the response. 

2384 return response 

2385 

2386 async def delete_link( 

2387 self, 

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

2389 *, 

2390 name: Optional[str] = None, 

2391 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

2394 ) -> operation_async.AsyncOperation: 

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

2396 corresponding BigQuery linked dataset. 

2397 

2398 .. code-block:: python 

2399 

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

2401 # code template only. 

2402 # It will require modifications to work: 

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

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

2405 # client as shown in: 

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

2407 from google.cloud import logging_v2 

2408 

2409 async def sample_delete_link(): 

2410 # Create a client 

2411 client = logging_v2.ConfigServiceV2AsyncClient() 

2412 

2413 # Initialize request argument(s) 

2414 request = logging_v2.DeleteLinkRequest( 

2415 name="name_value", 

2416 ) 

2417 

2418 # Make the request 

2419 operation = client.delete_link(request=request) 

2420 

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

2422 

2423 response = (await operation).result() 

2424 

2425 # Handle the response 

2426 print(response) 

2427 

2428 Args: 

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

2430 The request object. The parameters to DeleteLink. 

2431 name (:class:`str`): 

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

2433 

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

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

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

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

2438 

2439 This corresponds to the ``name`` field 

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

2441 should not be set. 

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

2443 should be retried. 

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

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

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

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

2448 be of type `bytes`. 

2449 

2450 Returns: 

2451 google.api_core.operation_async.AsyncOperation: 

2452 An object representing a long-running operation. 

2453 

2454 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 

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

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

2457 method. For instance: 

2458 

2459 service Foo { 

2460 rpc Bar(google.protobuf.Empty) returns 

2461 (google.protobuf.Empty); 

2462 

2463 } 

2464 

2465 """ 

2466 # Create or coerce a protobuf request object. 

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

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

2469 flattened_params = [name] 

2470 has_flattened_params = ( 

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

2472 ) 

2473 if request is not None and has_flattened_params: 

2474 raise ValueError( 

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

2476 "the individual field arguments should be set." 

2477 ) 

2478 

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

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

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

2482 request = logging_config.DeleteLinkRequest(request) 

2483 

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

2485 # request, apply these. 

2486 if name is not None: 

2487 request.name = name 

2488 

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

2490 # and friendly error handling. 

2491 rpc = self._client._transport._wrapped_methods[ 

2492 self._client._transport.delete_link 

2493 ] 

2494 

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

2496 # add these here. 

2497 metadata = tuple(metadata) + ( 

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

2499 ) 

2500 

2501 # Validate the universe domain. 

2502 self._client._validate_universe_domain() 

2503 

2504 # Send the request. 

2505 response = await rpc( 

2506 request, 

2507 retry=retry, 

2508 timeout=timeout, 

2509 metadata=metadata, 

2510 ) 

2511 

2512 # Wrap the response in an operation future. 

2513 response = operation_async.from_gapic( 

2514 response, 

2515 self._client._transport.operations_client, 

2516 empty_pb2.Empty, 

2517 metadata_type=logging_config.LinkMetadata, 

2518 ) 

2519 

2520 # Done; return the response. 

2521 return response 

2522 

2523 async def list_links( 

2524 self, 

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

2526 *, 

2527 parent: Optional[str] = None, 

2528 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

2531 ) -> pagers.ListLinksAsyncPager: 

2532 r"""Lists links. 

2533 

2534 .. code-block:: python 

2535 

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

2537 # code template only. 

2538 # It will require modifications to work: 

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

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

2541 # client as shown in: 

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

2543 from google.cloud import logging_v2 

2544 

2545 async def sample_list_links(): 

2546 # Create a client 

2547 client = logging_v2.ConfigServiceV2AsyncClient() 

2548 

2549 # Initialize request argument(s) 

2550 request = logging_v2.ListLinksRequest( 

2551 parent="parent_value", 

2552 ) 

2553 

2554 # Make the request 

2555 page_result = client.list_links(request=request) 

2556 

2557 # Handle the response 

2558 async for response in page_result: 

2559 print(response) 

2560 

2561 Args: 

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

2563 The request object. The parameters to ListLinks. 

2564 parent (:class:`str`): 

2565 Required. The parent resource whose links are to be 

2566 listed: 

2567 

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

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

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

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

2572 

2573 This corresponds to the ``parent`` field 

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

2575 should not be set. 

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

2577 should be retried. 

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

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

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

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

2582 be of type `bytes`. 

2583 

2584 Returns: 

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

2586 The response from ListLinks. 

2587 

2588 Iterating over this object will yield 

2589 results and resolve additional pages 

2590 automatically. 

2591 

2592 """ 

2593 # Create or coerce a protobuf request object. 

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

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

2596 flattened_params = [parent] 

2597 has_flattened_params = ( 

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

2599 ) 

2600 if request is not None and has_flattened_params: 

2601 raise ValueError( 

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

2603 "the individual field arguments should be set." 

2604 ) 

2605 

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

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

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

2609 request = logging_config.ListLinksRequest(request) 

2610 

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

2612 # request, apply these. 

2613 if parent is not None: 

2614 request.parent = parent 

2615 

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

2617 # and friendly error handling. 

2618 rpc = self._client._transport._wrapped_methods[ 

2619 self._client._transport.list_links 

2620 ] 

2621 

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

2623 # add these here. 

2624 metadata = tuple(metadata) + ( 

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

2626 ) 

2627 

2628 # Validate the universe domain. 

2629 self._client._validate_universe_domain() 

2630 

2631 # Send the request. 

2632 response = await rpc( 

2633 request, 

2634 retry=retry, 

2635 timeout=timeout, 

2636 metadata=metadata, 

2637 ) 

2638 

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

2640 # an `__aiter__` convenience method. 

2641 response = pagers.ListLinksAsyncPager( 

2642 method=rpc, 

2643 request=request, 

2644 response=response, 

2645 retry=retry, 

2646 timeout=timeout, 

2647 metadata=metadata, 

2648 ) 

2649 

2650 # Done; return the response. 

2651 return response 

2652 

2653 async def get_link( 

2654 self, 

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

2656 *, 

2657 name: Optional[str] = None, 

2658 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

2661 ) -> logging_config.Link: 

2662 r"""Gets a link. 

2663 

2664 .. code-block:: python 

2665 

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

2667 # code template only. 

2668 # It will require modifications to work: 

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

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

2671 # client as shown in: 

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

2673 from google.cloud import logging_v2 

2674 

2675 async def sample_get_link(): 

2676 # Create a client 

2677 client = logging_v2.ConfigServiceV2AsyncClient() 

2678 

2679 # Initialize request argument(s) 

2680 request = logging_v2.GetLinkRequest( 

2681 name="name_value", 

2682 ) 

2683 

2684 # Make the request 

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

2686 

2687 # Handle the response 

2688 print(response) 

2689 

2690 Args: 

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

2692 The request object. The parameters to GetLink. 

2693 name (:class:`str`): 

2694 Required. The resource name of the link: 

2695 

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

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

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

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

2700 

2701 This corresponds to the ``name`` field 

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

2703 should not be set. 

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

2705 should be retried. 

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

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

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

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

2710 be of type `bytes`. 

2711 

2712 Returns: 

2713 google.cloud.logging_v2.types.Link: 

2714 Describes a link connected to an 

2715 analytics enabled bucket. 

2716 

2717 """ 

2718 # Create or coerce a protobuf request object. 

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

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

2721 flattened_params = [name] 

2722 has_flattened_params = ( 

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

2724 ) 

2725 if request is not None and has_flattened_params: 

2726 raise ValueError( 

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

2728 "the individual field arguments should be set." 

2729 ) 

2730 

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

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

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

2734 request = logging_config.GetLinkRequest(request) 

2735 

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

2737 # request, apply these. 

2738 if name is not None: 

2739 request.name = name 

2740 

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

2742 # and friendly error handling. 

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

2744 

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

2746 # add these here. 

2747 metadata = tuple(metadata) + ( 

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

2749 ) 

2750 

2751 # Validate the universe domain. 

2752 self._client._validate_universe_domain() 

2753 

2754 # Send the request. 

2755 response = await rpc( 

2756 request, 

2757 retry=retry, 

2758 timeout=timeout, 

2759 metadata=metadata, 

2760 ) 

2761 

2762 # Done; return the response. 

2763 return response 

2764 

2765 async def list_exclusions( 

2766 self, 

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

2768 *, 

2769 parent: Optional[str] = None, 

2770 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

2773 ) -> pagers.ListExclusionsAsyncPager: 

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

2775 resource. 

2776 

2777 .. code-block:: python 

2778 

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

2780 # code template only. 

2781 # It will require modifications to work: 

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

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

2784 # client as shown in: 

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

2786 from google.cloud import logging_v2 

2787 

2788 async def sample_list_exclusions(): 

2789 # Create a client 

2790 client = logging_v2.ConfigServiceV2AsyncClient() 

2791 

2792 # Initialize request argument(s) 

2793 request = logging_v2.ListExclusionsRequest( 

2794 parent="parent_value", 

2795 ) 

2796 

2797 # Make the request 

2798 page_result = client.list_exclusions(request=request) 

2799 

2800 # Handle the response 

2801 async for response in page_result: 

2802 print(response) 

2803 

2804 Args: 

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

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

2807 parent (:class:`str`): 

2808 Required. The parent resource whose exclusions are to be 

2809 listed. 

2810 

2811 :: 

2812 

2813 "projects/[PROJECT_ID]" 

2814 "organizations/[ORGANIZATION_ID]" 

2815 "billingAccounts/[BILLING_ACCOUNT_ID]" 

2816 "folders/[FOLDER_ID]" 

2817 

2818 This corresponds to the ``parent`` field 

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

2820 should not be set. 

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

2822 should be retried. 

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

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

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

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

2827 be of type `bytes`. 

2828 

2829 Returns: 

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

2831 Result returned from ListExclusions. 

2832 

2833 Iterating over this object will yield results and 

2834 resolve additional pages automatically. 

2835 

2836 """ 

2837 # Create or coerce a protobuf request object. 

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

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

2840 flattened_params = [parent] 

2841 has_flattened_params = ( 

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

2843 ) 

2844 if request is not None and has_flattened_params: 

2845 raise ValueError( 

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

2847 "the individual field arguments should be set." 

2848 ) 

2849 

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

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

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

2853 request = logging_config.ListExclusionsRequest(request) 

2854 

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

2856 # request, apply these. 

2857 if parent is not None: 

2858 request.parent = parent 

2859 

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

2861 # and friendly error handling. 

2862 rpc = self._client._transport._wrapped_methods[ 

2863 self._client._transport.list_exclusions 

2864 ] 

2865 

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

2867 # add these here. 

2868 metadata = tuple(metadata) + ( 

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

2870 ) 

2871 

2872 # Validate the universe domain. 

2873 self._client._validate_universe_domain() 

2874 

2875 # Send the request. 

2876 response = await rpc( 

2877 request, 

2878 retry=retry, 

2879 timeout=timeout, 

2880 metadata=metadata, 

2881 ) 

2882 

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

2884 # an `__aiter__` convenience method. 

2885 response = pagers.ListExclusionsAsyncPager( 

2886 method=rpc, 

2887 request=request, 

2888 response=response, 

2889 retry=retry, 

2890 timeout=timeout, 

2891 metadata=metadata, 

2892 ) 

2893 

2894 # Done; return the response. 

2895 return response 

2896 

2897 async def get_exclusion( 

2898 self, 

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

2900 *, 

2901 name: Optional[str] = None, 

2902 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

2905 ) -> logging_config.LogExclusion: 

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

2907 

2908 .. code-block:: python 

2909 

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

2911 # code template only. 

2912 # It will require modifications to work: 

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

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

2915 # client as shown in: 

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

2917 from google.cloud import logging_v2 

2918 

2919 async def sample_get_exclusion(): 

2920 # Create a client 

2921 client = logging_v2.ConfigServiceV2AsyncClient() 

2922 

2923 # Initialize request argument(s) 

2924 request = logging_v2.GetExclusionRequest( 

2925 name="name_value", 

2926 ) 

2927 

2928 # Make the request 

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

2930 

2931 # Handle the response 

2932 print(response) 

2933 

2934 Args: 

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

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

2937 name (:class:`str`): 

2938 Required. The resource name of an existing exclusion: 

2939 

2940 :: 

2941 

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

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

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

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

2946 

2947 For example: 

2948 

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

2950 

2951 This corresponds to the ``name`` field 

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

2953 should not be set. 

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

2955 should be retried. 

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

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

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

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

2960 be of type `bytes`. 

2961 

2962 Returns: 

2963 google.cloud.logging_v2.types.LogExclusion: 

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

2965 your Google Cloud resource receives a large volume of 

2966 log entries, you can use exclusions to reduce your 

2967 chargeable logs. Note that exclusions on 

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

2969 to child resources. Note also that you cannot modify 

2970 the \_Required sink or exclude logs from it. 

2971 

2972 """ 

2973 # Create or coerce a protobuf request object. 

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

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

2976 flattened_params = [name] 

2977 has_flattened_params = ( 

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

2979 ) 

2980 if request is not None and has_flattened_params: 

2981 raise ValueError( 

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

2983 "the individual field arguments should be set." 

2984 ) 

2985 

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

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

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

2989 request = logging_config.GetExclusionRequest(request) 

2990 

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

2992 # request, apply these. 

2993 if name is not None: 

2994 request.name = name 

2995 

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

2997 # and friendly error handling. 

2998 rpc = self._client._transport._wrapped_methods[ 

2999 self._client._transport.get_exclusion 

3000 ] 

3001 

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

3003 # add these here. 

3004 metadata = tuple(metadata) + ( 

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

3006 ) 

3007 

3008 # Validate the universe domain. 

3009 self._client._validate_universe_domain() 

3010 

3011 # Send the request. 

3012 response = await rpc( 

3013 request, 

3014 retry=retry, 

3015 timeout=timeout, 

3016 metadata=metadata, 

3017 ) 

3018 

3019 # Done; return the response. 

3020 return response 

3021 

3022 async def create_exclusion( 

3023 self, 

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

3025 *, 

3026 parent: Optional[str] = None, 

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

3028 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

3031 ) -> logging_config.LogExclusion: 

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

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

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

3035 

3036 .. code-block:: python 

3037 

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

3039 # code template only. 

3040 # It will require modifications to work: 

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

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

3043 # client as shown in: 

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

3045 from google.cloud import logging_v2 

3046 

3047 async def sample_create_exclusion(): 

3048 # Create a client 

3049 client = logging_v2.ConfigServiceV2AsyncClient() 

3050 

3051 # Initialize request argument(s) 

3052 exclusion = logging_v2.LogExclusion() 

3053 exclusion.name = "name_value" 

3054 exclusion.filter = "filter_value" 

3055 

3056 request = logging_v2.CreateExclusionRequest( 

3057 parent="parent_value", 

3058 exclusion=exclusion, 

3059 ) 

3060 

3061 # Make the request 

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

3063 

3064 # Handle the response 

3065 print(response) 

3066 

3067 Args: 

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

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

3070 parent (:class:`str`): 

3071 Required. The parent resource in which to create the 

3072 exclusion: 

3073 

3074 :: 

3075 

3076 "projects/[PROJECT_ID]" 

3077 "organizations/[ORGANIZATION_ID]" 

3078 "billingAccounts/[BILLING_ACCOUNT_ID]" 

3079 "folders/[FOLDER_ID]" 

3080 

3081 For examples: 

3082 

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

3084 ``"organizations/123456789"`` 

3085 

3086 This corresponds to the ``parent`` field 

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

3088 should not be set. 

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

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

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

3092 resource. 

3093 

3094 This corresponds to the ``exclusion`` field 

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

3096 should not be set. 

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

3098 should be retried. 

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

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

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

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

3103 be of type `bytes`. 

3104 

3105 Returns: 

3106 google.cloud.logging_v2.types.LogExclusion: 

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

3108 your Google Cloud resource receives a large volume of 

3109 log entries, you can use exclusions to reduce your 

3110 chargeable logs. Note that exclusions on 

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

3112 to child resources. Note also that you cannot modify 

3113 the \_Required sink or exclude logs from it. 

3114 

3115 """ 

3116 # Create or coerce a protobuf request object. 

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

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

3119 flattened_params = [parent, exclusion] 

3120 has_flattened_params = ( 

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

3122 ) 

3123 if request is not None and has_flattened_params: 

3124 raise ValueError( 

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

3126 "the individual field arguments should be set." 

3127 ) 

3128 

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

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

3131 if not isinstance(request, logging_config.CreateExclusionRequest): 

3132 request = logging_config.CreateExclusionRequest(request) 

3133 

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

3135 # request, apply these. 

3136 if parent is not None: 

3137 request.parent = parent 

3138 if exclusion is not None: 

3139 request.exclusion = exclusion 

3140 

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

3142 # and friendly error handling. 

3143 rpc = self._client._transport._wrapped_methods[ 

3144 self._client._transport.create_exclusion 

3145 ] 

3146 

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

3148 # add these here. 

3149 metadata = tuple(metadata) + ( 

3150 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), 

3151 ) 

3152 

3153 # Validate the universe domain. 

3154 self._client._validate_universe_domain() 

3155 

3156 # Send the request. 

3157 response = await rpc( 

3158 request, 

3159 retry=retry, 

3160 timeout=timeout, 

3161 metadata=metadata, 

3162 ) 

3163 

3164 # Done; return the response. 

3165 return response 

3166 

3167 async def update_exclusion( 

3168 self, 

3169 request: Optional[Union[logging_config.UpdateExclusionRequest, dict]] = None, 

3170 *, 

3171 name: Optional[str] = None, 

3172 exclusion: Optional[logging_config.LogExclusion] = None, 

3173 update_mask: Optional[field_mask_pb2.FieldMask] = None, 

3174 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3175 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

3176 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

3177 ) -> logging_config.LogExclusion: 

3178 r"""Changes one or more properties of an existing exclusion in the 

3179 \_Default sink. 

3180 

3181 .. code-block:: python 

3182 

3183 # This snippet has been automatically generated and should be regarded as a 

3184 # code template only. 

3185 # It will require modifications to work: 

3186 # - It may require correct/in-range values for request initialization. 

3187 # - It may require specifying regional endpoints when creating the service 

3188 # client as shown in: 

3189 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

3190 from google.cloud import logging_v2 

3191 

3192 async def sample_update_exclusion(): 

3193 # Create a client 

3194 client = logging_v2.ConfigServiceV2AsyncClient() 

3195 

3196 # Initialize request argument(s) 

3197 exclusion = logging_v2.LogExclusion() 

3198 exclusion.name = "name_value" 

3199 exclusion.filter = "filter_value" 

3200 

3201 request = logging_v2.UpdateExclusionRequest( 

3202 name="name_value", 

3203 exclusion=exclusion, 

3204 ) 

3205 

3206 # Make the request 

3207 response = await client.update_exclusion(request=request) 

3208 

3209 # Handle the response 

3210 print(response) 

3211 

3212 Args: 

3213 request (Optional[Union[google.cloud.logging_v2.types.UpdateExclusionRequest, dict]]): 

3214 The request object. The parameters to ``UpdateExclusion``. 

3215 name (:class:`str`): 

3216 Required. The resource name of the exclusion to update: 

3217 

3218 :: 

3219 

3220 "projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" 

3221 "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" 

3222 "billingAccounts/[BILLING_ACCOUNT_ID]/exclusions/[EXCLUSION_ID]" 

3223 "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]" 

3224 

3225 For example: 

3226 

3227 ``"projects/my-project/exclusions/my-exclusion"`` 

3228 

3229 This corresponds to the ``name`` field 

3230 on the ``request`` instance; if ``request`` is provided, this 

3231 should not be set. 

3232 exclusion (:class:`google.cloud.logging_v2.types.LogExclusion`): 

3233 Required. New values for the existing exclusion. Only 

3234 the fields specified in ``update_mask`` are relevant. 

3235 

3236 This corresponds to the ``exclusion`` field 

3237 on the ``request`` instance; if ``request`` is provided, this 

3238 should not be set. 

3239 update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): 

3240 Required. A non-empty list of fields to change in the 

3241 existing exclusion. New values for the fields are taken 

3242 from the corresponding fields in the 

3243 [LogExclusion][google.logging.v2.LogExclusion] included 

3244 in this request. Fields not mentioned in ``update_mask`` 

3245 are not changed and are ignored in the request. 

3246 

3247 For example, to change the filter and description of an 

3248 exclusion, specify an ``update_mask`` of 

3249 ``"filter,description"``. 

3250 

3251 This corresponds to the ``update_mask`` field 

3252 on the ``request`` instance; if ``request`` is provided, this 

3253 should not be set. 

3254 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

3255 should be retried. 

3256 timeout (float): The timeout for this request. 

3257 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

3258 sent along with the request as metadata. Normally, each value must be of type `str`, 

3259 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

3260 be of type `bytes`. 

3261 

3262 Returns: 

3263 google.cloud.logging_v2.types.LogExclusion: 

3264 Specifies a set of log entries that are filtered out by a sink. If 

3265 your Google Cloud resource receives a large volume of 

3266 log entries, you can use exclusions to reduce your 

3267 chargeable logs. Note that exclusions on 

3268 organization-level and folder-level sinks don't apply 

3269 to child resources. Note also that you cannot modify 

3270 the \_Required sink or exclude logs from it. 

3271 

3272 """ 

3273 # Create or coerce a protobuf request object. 

3274 # - Quick check: If we got a request object, we should *not* have 

3275 # gotten any keyword arguments that map to the request. 

3276 flattened_params = [name, exclusion, update_mask] 

3277 has_flattened_params = ( 

3278 len([param for param in flattened_params if param is not None]) > 0 

3279 ) 

3280 if request is not None and has_flattened_params: 

3281 raise ValueError( 

3282 "If the `request` argument is set, then none of " 

3283 "the individual field arguments should be set." 

3284 ) 

3285 

3286 # - Use the request object if provided (there's no risk of modifying the input as 

3287 # there are no flattened fields), or create one. 

3288 if not isinstance(request, logging_config.UpdateExclusionRequest): 

3289 request = logging_config.UpdateExclusionRequest(request) 

3290 

3291 # If we have keyword arguments corresponding to fields on the 

3292 # request, apply these. 

3293 if name is not None: 

3294 request.name = name 

3295 if exclusion is not None: 

3296 request.exclusion = exclusion 

3297 if update_mask is not None: 

3298 request.update_mask = update_mask 

3299 

3300 # Wrap the RPC method; this adds retry and timeout information, 

3301 # and friendly error handling. 

3302 rpc = self._client._transport._wrapped_methods[ 

3303 self._client._transport.update_exclusion 

3304 ] 

3305 

3306 # Certain fields should be provided within the metadata header; 

3307 # add these here. 

3308 metadata = tuple(metadata) + ( 

3309 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

3310 ) 

3311 

3312 # Validate the universe domain. 

3313 self._client._validate_universe_domain() 

3314 

3315 # Send the request. 

3316 response = await rpc( 

3317 request, 

3318 retry=retry, 

3319 timeout=timeout, 

3320 metadata=metadata, 

3321 ) 

3322 

3323 # Done; return the response. 

3324 return response 

3325 

3326 async def delete_exclusion( 

3327 self, 

3328 request: Optional[Union[logging_config.DeleteExclusionRequest, dict]] = None, 

3329 *, 

3330 name: Optional[str] = None, 

3331 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3332 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

3333 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

3334 ) -> None: 

3335 r"""Deletes an exclusion in the \_Default sink. 

3336 

3337 .. code-block:: python 

3338 

3339 # This snippet has been automatically generated and should be regarded as a 

3340 # code template only. 

3341 # It will require modifications to work: 

3342 # - It may require correct/in-range values for request initialization. 

3343 # - It may require specifying regional endpoints when creating the service 

3344 # client as shown in: 

3345 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

3346 from google.cloud import logging_v2 

3347 

3348 async def sample_delete_exclusion(): 

3349 # Create a client 

3350 client = logging_v2.ConfigServiceV2AsyncClient() 

3351 

3352 # Initialize request argument(s) 

3353 request = logging_v2.DeleteExclusionRequest( 

3354 name="name_value", 

3355 ) 

3356 

3357 # Make the request 

3358 await client.delete_exclusion(request=request) 

3359 

3360 Args: 

3361 request (Optional[Union[google.cloud.logging_v2.types.DeleteExclusionRequest, dict]]): 

3362 The request object. The parameters to ``DeleteExclusion``. 

3363 name (:class:`str`): 

3364 Required. The resource name of an existing exclusion to 

3365 delete: 

3366 

3367 :: 

3368 

3369 "projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" 

3370 "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" 

3371 "billingAccounts/[BILLING_ACCOUNT_ID]/exclusions/[EXCLUSION_ID]" 

3372 "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]" 

3373 

3374 For example: 

3375 

3376 ``"projects/my-project/exclusions/my-exclusion"`` 

3377 

3378 This corresponds to the ``name`` field 

3379 on the ``request`` instance; if ``request`` is provided, this 

3380 should not be set. 

3381 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

3382 should be retried. 

3383 timeout (float): The timeout for this request. 

3384 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

3385 sent along with the request as metadata. Normally, each value must be of type `str`, 

3386 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

3387 be of type `bytes`. 

3388 """ 

3389 # Create or coerce a protobuf request object. 

3390 # - Quick check: If we got a request object, we should *not* have 

3391 # gotten any keyword arguments that map to the request. 

3392 flattened_params = [name] 

3393 has_flattened_params = ( 

3394 len([param for param in flattened_params if param is not None]) > 0 

3395 ) 

3396 if request is not None and has_flattened_params: 

3397 raise ValueError( 

3398 "If the `request` argument is set, then none of " 

3399 "the individual field arguments should be set." 

3400 ) 

3401 

3402 # - Use the request object if provided (there's no risk of modifying the input as 

3403 # there are no flattened fields), or create one. 

3404 if not isinstance(request, logging_config.DeleteExclusionRequest): 

3405 request = logging_config.DeleteExclusionRequest(request) 

3406 

3407 # If we have keyword arguments corresponding to fields on the 

3408 # request, apply these. 

3409 if name is not None: 

3410 request.name = name 

3411 

3412 # Wrap the RPC method; this adds retry and timeout information, 

3413 # and friendly error handling. 

3414 rpc = self._client._transport._wrapped_methods[ 

3415 self._client._transport.delete_exclusion 

3416 ] 

3417 

3418 # Certain fields should be provided within the metadata header; 

3419 # add these here. 

3420 metadata = tuple(metadata) + ( 

3421 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

3422 ) 

3423 

3424 # Validate the universe domain. 

3425 self._client._validate_universe_domain() 

3426 

3427 # Send the request. 

3428 await rpc( 

3429 request, 

3430 retry=retry, 

3431 timeout=timeout, 

3432 metadata=metadata, 

3433 ) 

3434 

3435 async def get_cmek_settings( 

3436 self, 

3437 request: Optional[Union[logging_config.GetCmekSettingsRequest, dict]] = None, 

3438 *, 

3439 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3440 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

3441 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

3442 ) -> logging_config.CmekSettings: 

3443 r"""Gets the Logging CMEK settings for the given resource. 

3444 

3445 Note: CMEK for the Log Router can be configured for Google Cloud 

3446 projects, folders, organizations and billing accounts. Once 

3447 configured for an organization, it applies to all projects and 

3448 folders in the Google Cloud organization. 

3449 

3450 See `Enabling CMEK for Log 

3451 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__ 

3452 for more information. 

3453 

3454 .. code-block:: python 

3455 

3456 # This snippet has been automatically generated and should be regarded as a 

3457 # code template only. 

3458 # It will require modifications to work: 

3459 # - It may require correct/in-range values for request initialization. 

3460 # - It may require specifying regional endpoints when creating the service 

3461 # client as shown in: 

3462 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

3463 from google.cloud import logging_v2 

3464 

3465 async def sample_get_cmek_settings(): 

3466 # Create a client 

3467 client = logging_v2.ConfigServiceV2AsyncClient() 

3468 

3469 # Initialize request argument(s) 

3470 request = logging_v2.GetCmekSettingsRequest( 

3471 name="name_value", 

3472 ) 

3473 

3474 # Make the request 

3475 response = await client.get_cmek_settings(request=request) 

3476 

3477 # Handle the response 

3478 print(response) 

3479 

3480 Args: 

3481 request (Optional[Union[google.cloud.logging_v2.types.GetCmekSettingsRequest, dict]]): 

3482 The request object. The parameters to 

3483 [GetCmekSettings][google.logging.v2.ConfigServiceV2.GetCmekSettings]. 

3484 

3485 See `Enabling CMEK for Log 

3486 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__ 

3487 for more information. 

3488 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

3489 should be retried. 

3490 timeout (float): The timeout for this request. 

3491 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

3492 sent along with the request as metadata. Normally, each value must be of type `str`, 

3493 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

3494 be of type `bytes`. 

3495 

3496 Returns: 

3497 google.cloud.logging_v2.types.CmekSettings: 

3498 Describes the customer-managed encryption key (CMEK) settings associated with 

3499 a project, folder, organization, billing account, or 

3500 flexible resource. 

3501 

3502 Note: CMEK for the Log Router can currently only be 

3503 configured for Google Cloud organizations. Once 

3504 configured, it applies to all projects and folders in 

3505 the Google Cloud organization. 

3506 

3507 See [Enabling CMEK for Log 

3508 Router](\ https://cloud.google.com/logging/docs/routing/managed-encryption) 

3509 for more information. 

3510 

3511 """ 

3512 # Create or coerce a protobuf request object. 

3513 # - Use the request object if provided (there's no risk of modifying the input as 

3514 # there are no flattened fields), or create one. 

3515 if not isinstance(request, logging_config.GetCmekSettingsRequest): 

3516 request = logging_config.GetCmekSettingsRequest(request) 

3517 

3518 # Wrap the RPC method; this adds retry and timeout information, 

3519 # and friendly error handling. 

3520 rpc = self._client._transport._wrapped_methods[ 

3521 self._client._transport.get_cmek_settings 

3522 ] 

3523 

3524 # Certain fields should be provided within the metadata header; 

3525 # add these here. 

3526 metadata = tuple(metadata) + ( 

3527 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

3528 ) 

3529 

3530 # Validate the universe domain. 

3531 self._client._validate_universe_domain() 

3532 

3533 # Send the request. 

3534 response = await rpc( 

3535 request, 

3536 retry=retry, 

3537 timeout=timeout, 

3538 metadata=metadata, 

3539 ) 

3540 

3541 # Done; return the response. 

3542 return response 

3543 

3544 async def update_cmek_settings( 

3545 self, 

3546 request: Optional[Union[logging_config.UpdateCmekSettingsRequest, dict]] = None, 

3547 *, 

3548 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3549 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

3550 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

3551 ) -> logging_config.CmekSettings: 

3552 r"""Updates the Log Router CMEK settings for the given resource. 

3553 

3554 Note: CMEK for the Log Router can currently only be configured 

3555 for Google Cloud organizations. Once configured, it applies to 

3556 all projects and folders in the Google Cloud organization. 

3557 

3558 [UpdateCmekSettings][google.logging.v2.ConfigServiceV2.UpdateCmekSettings] 

3559 will fail if 1) ``kms_key_name`` is invalid, or 2) the 

3560 associated service account does not have the required 

3561 ``roles/cloudkms.cryptoKeyEncrypterDecrypter`` role assigned for 

3562 the key, or 3) access to the key is disabled. 

3563 

3564 See `Enabling CMEK for Log 

3565 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__ 

3566 for more information. 

3567 

3568 .. code-block:: python 

3569 

3570 # This snippet has been automatically generated and should be regarded as a 

3571 # code template only. 

3572 # It will require modifications to work: 

3573 # - It may require correct/in-range values for request initialization. 

3574 # - It may require specifying regional endpoints when creating the service 

3575 # client as shown in: 

3576 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

3577 from google.cloud import logging_v2 

3578 

3579 async def sample_update_cmek_settings(): 

3580 # Create a client 

3581 client = logging_v2.ConfigServiceV2AsyncClient() 

3582 

3583 # Initialize request argument(s) 

3584 request = logging_v2.UpdateCmekSettingsRequest( 

3585 name="name_value", 

3586 ) 

3587 

3588 # Make the request 

3589 response = await client.update_cmek_settings(request=request) 

3590 

3591 # Handle the response 

3592 print(response) 

3593 

3594 Args: 

3595 request (Optional[Union[google.cloud.logging_v2.types.UpdateCmekSettingsRequest, dict]]): 

3596 The request object. The parameters to 

3597 [UpdateCmekSettings][google.logging.v2.ConfigServiceV2.UpdateCmekSettings]. 

3598 

3599 See `Enabling CMEK for Log 

3600 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__ 

3601 for more information. 

3602 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

3603 should be retried. 

3604 timeout (float): The timeout for this request. 

3605 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

3606 sent along with the request as metadata. Normally, each value must be of type `str`, 

3607 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

3608 be of type `bytes`. 

3609 

3610 Returns: 

3611 google.cloud.logging_v2.types.CmekSettings: 

3612 Describes the customer-managed encryption key (CMEK) settings associated with 

3613 a project, folder, organization, billing account, or 

3614 flexible resource. 

3615 

3616 Note: CMEK for the Log Router can currently only be 

3617 configured for Google Cloud organizations. Once 

3618 configured, it applies to all projects and folders in 

3619 the Google Cloud organization. 

3620 

3621 See [Enabling CMEK for Log 

3622 Router](\ https://cloud.google.com/logging/docs/routing/managed-encryption) 

3623 for more information. 

3624 

3625 """ 

3626 # Create or coerce a protobuf request object. 

3627 # - Use the request object if provided (there's no risk of modifying the input as 

3628 # there are no flattened fields), or create one. 

3629 if not isinstance(request, logging_config.UpdateCmekSettingsRequest): 

3630 request = logging_config.UpdateCmekSettingsRequest(request) 

3631 

3632 # Wrap the RPC method; this adds retry and timeout information, 

3633 # and friendly error handling. 

3634 rpc = self._client._transport._wrapped_methods[ 

3635 self._client._transport.update_cmek_settings 

3636 ] 

3637 

3638 # Certain fields should be provided within the metadata header; 

3639 # add these here. 

3640 metadata = tuple(metadata) + ( 

3641 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

3642 ) 

3643 

3644 # Validate the universe domain. 

3645 self._client._validate_universe_domain() 

3646 

3647 # Send the request. 

3648 response = await rpc( 

3649 request, 

3650 retry=retry, 

3651 timeout=timeout, 

3652 metadata=metadata, 

3653 ) 

3654 

3655 # Done; return the response. 

3656 return response 

3657 

3658 async def get_settings( 

3659 self, 

3660 request: Optional[Union[logging_config.GetSettingsRequest, dict]] = None, 

3661 *, 

3662 name: Optional[str] = None, 

3663 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3664 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

3665 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

3666 ) -> logging_config.Settings: 

3667 r"""Gets the Log Router settings for the given resource. 

3668 

3669 Note: Settings for the Log Router can be get for Google Cloud 

3670 projects, folders, organizations and billing accounts. Currently 

3671 it can only be configured for organizations. Once configured for 

3672 an organization, it applies to all projects and folders in the 

3673 Google Cloud organization. 

3674 

3675 See `Enabling CMEK for Log 

3676 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__ 

3677 for more information. 

3678 

3679 .. code-block:: python 

3680 

3681 # This snippet has been automatically generated and should be regarded as a 

3682 # code template only. 

3683 # It will require modifications to work: 

3684 # - It may require correct/in-range values for request initialization. 

3685 # - It may require specifying regional endpoints when creating the service 

3686 # client as shown in: 

3687 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

3688 from google.cloud import logging_v2 

3689 

3690 async def sample_get_settings(): 

3691 # Create a client 

3692 client = logging_v2.ConfigServiceV2AsyncClient() 

3693 

3694 # Initialize request argument(s) 

3695 request = logging_v2.GetSettingsRequest( 

3696 name="name_value", 

3697 ) 

3698 

3699 # Make the request 

3700 response = await client.get_settings(request=request) 

3701 

3702 # Handle the response 

3703 print(response) 

3704 

3705 Args: 

3706 request (Optional[Union[google.cloud.logging_v2.types.GetSettingsRequest, dict]]): 

3707 The request object. The parameters to 

3708 [GetSettings][google.logging.v2.ConfigServiceV2.GetSettings]. 

3709 

3710 See `Enabling CMEK for Log 

3711 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__ 

3712 for more information. 

3713 name (:class:`str`): 

3714 Required. The resource for which to retrieve settings. 

3715 

3716 :: 

3717 

3718 "projects/[PROJECT_ID]/settings" 

3719 "organizations/[ORGANIZATION_ID]/settings" 

3720 "billingAccounts/[BILLING_ACCOUNT_ID]/settings" 

3721 "folders/[FOLDER_ID]/settings" 

3722 

3723 For example: 

3724 

3725 ``"organizations/12345/settings"`` 

3726 

3727 Note: Settings for the Log Router can be get for Google 

3728 Cloud projects, folders, organizations and billing 

3729 accounts. Currently it can only be configured for 

3730 organizations. Once configured for an organization, it 

3731 applies to all projects and folders in the Google Cloud 

3732 organization. 

3733 

3734 This corresponds to the ``name`` field 

3735 on the ``request`` instance; if ``request`` is provided, this 

3736 should not be set. 

3737 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

3738 should be retried. 

3739 timeout (float): The timeout for this request. 

3740 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

3741 sent along with the request as metadata. Normally, each value must be of type `str`, 

3742 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

3743 be of type `bytes`. 

3744 

3745 Returns: 

3746 google.cloud.logging_v2.types.Settings: 

3747 Describes the settings associated 

3748 with a project, folder, organization, 

3749 billing account, or flexible resource. 

3750 

3751 """ 

3752 # Create or coerce a protobuf request object. 

3753 # - Quick check: If we got a request object, we should *not* have 

3754 # gotten any keyword arguments that map to the request. 

3755 flattened_params = [name] 

3756 has_flattened_params = ( 

3757 len([param for param in flattened_params if param is not None]) > 0 

3758 ) 

3759 if request is not None and has_flattened_params: 

3760 raise ValueError( 

3761 "If the `request` argument is set, then none of " 

3762 "the individual field arguments should be set." 

3763 ) 

3764 

3765 # - Use the request object if provided (there's no risk of modifying the input as 

3766 # there are no flattened fields), or create one. 

3767 if not isinstance(request, logging_config.GetSettingsRequest): 

3768 request = logging_config.GetSettingsRequest(request) 

3769 

3770 # If we have keyword arguments corresponding to fields on the 

3771 # request, apply these. 

3772 if name is not None: 

3773 request.name = name 

3774 

3775 # Wrap the RPC method; this adds retry and timeout information, 

3776 # and friendly error handling. 

3777 rpc = self._client._transport._wrapped_methods[ 

3778 self._client._transport.get_settings 

3779 ] 

3780 

3781 # Certain fields should be provided within the metadata header; 

3782 # add these here. 

3783 metadata = tuple(metadata) + ( 

3784 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

3785 ) 

3786 

3787 # Validate the universe domain. 

3788 self._client._validate_universe_domain() 

3789 

3790 # Send the request. 

3791 response = await rpc( 

3792 request, 

3793 retry=retry, 

3794 timeout=timeout, 

3795 metadata=metadata, 

3796 ) 

3797 

3798 # Done; return the response. 

3799 return response 

3800 

3801 async def update_settings( 

3802 self, 

3803 request: Optional[Union[logging_config.UpdateSettingsRequest, dict]] = None, 

3804 *, 

3805 settings: Optional[logging_config.Settings] = None, 

3806 update_mask: Optional[field_mask_pb2.FieldMask] = None, 

3807 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3808 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

3809 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

3810 ) -> logging_config.Settings: 

3811 r"""Updates the Log Router settings for the given resource. 

3812 

3813 Note: Settings for the Log Router can currently only be 

3814 configured for Google Cloud organizations. Once configured, it 

3815 applies to all projects and folders in the Google Cloud 

3816 organization. 

3817 

3818 [UpdateSettings][google.logging.v2.ConfigServiceV2.UpdateSettings] 

3819 will fail if 1) ``kms_key_name`` is invalid, or 2) the 

3820 associated service account does not have the required 

3821 ``roles/cloudkms.cryptoKeyEncrypterDecrypter`` role assigned for 

3822 the key, or 3) access to the key is disabled. 4) ``location_id`` 

3823 is not supported by Logging. 5) ``location_id`` violate 

3824 OrgPolicy. 

3825 

3826 See `Enabling CMEK for Log 

3827 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__ 

3828 for more information. 

3829 

3830 .. code-block:: python 

3831 

3832 # This snippet has been automatically generated and should be regarded as a 

3833 # code template only. 

3834 # It will require modifications to work: 

3835 # - It may require correct/in-range values for request initialization. 

3836 # - It may require specifying regional endpoints when creating the service 

3837 # client as shown in: 

3838 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

3839 from google.cloud import logging_v2 

3840 

3841 async def sample_update_settings(): 

3842 # Create a client 

3843 client = logging_v2.ConfigServiceV2AsyncClient() 

3844 

3845 # Initialize request argument(s) 

3846 request = logging_v2.UpdateSettingsRequest( 

3847 name="name_value", 

3848 ) 

3849 

3850 # Make the request 

3851 response = await client.update_settings(request=request) 

3852 

3853 # Handle the response 

3854 print(response) 

3855 

3856 Args: 

3857 request (Optional[Union[google.cloud.logging_v2.types.UpdateSettingsRequest, dict]]): 

3858 The request object. The parameters to 

3859 [UpdateSettings][google.logging.v2.ConfigServiceV2.UpdateSettings]. 

3860 

3861 See `Enabling CMEK for Log 

3862 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__ 

3863 for more information. 

3864 settings (:class:`google.cloud.logging_v2.types.Settings`): 

3865 Required. The settings to update. 

3866 

3867 See `Enabling CMEK for Log 

3868 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__ 

3869 for more information. 

3870 

3871 This corresponds to the ``settings`` field 

3872 on the ``request`` instance; if ``request`` is provided, this 

3873 should not be set. 

3874 update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): 

3875 Optional. Field mask identifying which fields from 

3876 ``settings`` should be updated. A field will be 

3877 overwritten if and only if it is in the update mask. 

3878 Output only fields cannot be updated. 

3879 

3880 See [FieldMask][google.protobuf.FieldMask] for more 

3881 information. 

3882 

3883 For example: ``"updateMask=kmsKeyName"`` 

3884 

3885 This corresponds to the ``update_mask`` field 

3886 on the ``request`` instance; if ``request`` is provided, this 

3887 should not be set. 

3888 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

3889 should be retried. 

3890 timeout (float): The timeout for this request. 

3891 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

3892 sent along with the request as metadata. Normally, each value must be of type `str`, 

3893 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

3894 be of type `bytes`. 

3895 

3896 Returns: 

3897 google.cloud.logging_v2.types.Settings: 

3898 Describes the settings associated 

3899 with a project, folder, organization, 

3900 billing account, or flexible resource. 

3901 

3902 """ 

3903 # Create or coerce a protobuf request object. 

3904 # - Quick check: If we got a request object, we should *not* have 

3905 # gotten any keyword arguments that map to the request. 

3906 flattened_params = [settings, update_mask] 

3907 has_flattened_params = ( 

3908 len([param for param in flattened_params if param is not None]) > 0 

3909 ) 

3910 if request is not None and has_flattened_params: 

3911 raise ValueError( 

3912 "If the `request` argument is set, then none of " 

3913 "the individual field arguments should be set." 

3914 ) 

3915 

3916 # - Use the request object if provided (there's no risk of modifying the input as 

3917 # there are no flattened fields), or create one. 

3918 if not isinstance(request, logging_config.UpdateSettingsRequest): 

3919 request = logging_config.UpdateSettingsRequest(request) 

3920 

3921 # If we have keyword arguments corresponding to fields on the 

3922 # request, apply these. 

3923 if settings is not None: 

3924 request.settings = settings 

3925 if update_mask is not None: 

3926 request.update_mask = update_mask 

3927 

3928 # Wrap the RPC method; this adds retry and timeout information, 

3929 # and friendly error handling. 

3930 rpc = self._client._transport._wrapped_methods[ 

3931 self._client._transport.update_settings 

3932 ] 

3933 

3934 # Certain fields should be provided within the metadata header; 

3935 # add these here. 

3936 metadata = tuple(metadata) + ( 

3937 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

3938 ) 

3939 

3940 # Validate the universe domain. 

3941 self._client._validate_universe_domain() 

3942 

3943 # Send the request. 

3944 response = await rpc( 

3945 request, 

3946 retry=retry, 

3947 timeout=timeout, 

3948 metadata=metadata, 

3949 ) 

3950 

3951 # Done; return the response. 

3952 return response 

3953 

3954 async def copy_log_entries( 

3955 self, 

3956 request: Optional[Union[logging_config.CopyLogEntriesRequest, dict]] = None, 

3957 *, 

3958 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3959 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

3960 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

3961 ) -> operation_async.AsyncOperation: 

3962 r"""Copies a set of log entries from a log bucket to a 

3963 Cloud Storage bucket. 

3964 

3965 .. code-block:: python 

3966 

3967 # This snippet has been automatically generated and should be regarded as a 

3968 # code template only. 

3969 # It will require modifications to work: 

3970 # - It may require correct/in-range values for request initialization. 

3971 # - It may require specifying regional endpoints when creating the service 

3972 # client as shown in: 

3973 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

3974 from google.cloud import logging_v2 

3975 

3976 async def sample_copy_log_entries(): 

3977 # Create a client 

3978 client = logging_v2.ConfigServiceV2AsyncClient() 

3979 

3980 # Initialize request argument(s) 

3981 request = logging_v2.CopyLogEntriesRequest( 

3982 name="name_value", 

3983 destination="destination_value", 

3984 ) 

3985 

3986 # Make the request 

3987 operation = client.copy_log_entries(request=request) 

3988 

3989 print("Waiting for operation to complete...") 

3990 

3991 response = (await operation).result() 

3992 

3993 # Handle the response 

3994 print(response) 

3995 

3996 Args: 

3997 request (Optional[Union[google.cloud.logging_v2.types.CopyLogEntriesRequest, dict]]): 

3998 The request object. The parameters to CopyLogEntries. 

3999 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

4000 should be retried. 

4001 timeout (float): The timeout for this request. 

4002 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

4003 sent along with the request as metadata. Normally, each value must be of type `str`, 

4004 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

4005 be of type `bytes`. 

4006 

4007 Returns: 

4008 google.api_core.operation_async.AsyncOperation: 

4009 An object representing a long-running operation. 

4010 

4011 The result type for the operation will be 

4012 :class:`google.cloud.logging_v2.types.CopyLogEntriesResponse` 

4013 Response type for CopyLogEntries long running 

4014 operations. 

4015 

4016 """ 

4017 # Create or coerce a protobuf request object. 

4018 # - Use the request object if provided (there's no risk of modifying the input as 

4019 # there are no flattened fields), or create one. 

4020 if not isinstance(request, logging_config.CopyLogEntriesRequest): 

4021 request = logging_config.CopyLogEntriesRequest(request) 

4022 

4023 # Wrap the RPC method; this adds retry and timeout information, 

4024 # and friendly error handling. 

4025 rpc = self._client._transport._wrapped_methods[ 

4026 self._client._transport.copy_log_entries 

4027 ] 

4028 

4029 # Validate the universe domain. 

4030 self._client._validate_universe_domain() 

4031 

4032 # Send the request. 

4033 response = await rpc( 

4034 request, 

4035 retry=retry, 

4036 timeout=timeout, 

4037 metadata=metadata, 

4038 ) 

4039 

4040 # Wrap the response in an operation future. 

4041 response = operation_async.from_gapic( 

4042 response, 

4043 self._client._transport.operations_client, 

4044 logging_config.CopyLogEntriesResponse, 

4045 metadata_type=logging_config.CopyLogEntriesMetadata, 

4046 ) 

4047 

4048 # Done; return the response. 

4049 return response 

4050 

4051 async def list_operations( 

4052 self, 

4053 request: Optional[operations_pb2.ListOperationsRequest] = None, 

4054 *, 

4055 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

4056 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

4057 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

4058 ) -> operations_pb2.ListOperationsResponse: 

4059 r"""Lists operations that match the specified filter in the request. 

4060 

4061 Args: 

4062 request (:class:`~.operations_pb2.ListOperationsRequest`): 

4063 The request object. Request message for 

4064 `ListOperations` method. 

4065 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, 

4066 if any, should be retried. 

4067 timeout (float): The timeout for this request. 

4068 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

4069 sent along with the request as metadata. Normally, each value must be of type `str`, 

4070 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

4071 be of type `bytes`. 

4072 Returns: 

4073 ~.operations_pb2.ListOperationsResponse: 

4074 Response message for ``ListOperations`` method. 

4075 """ 

4076 # Create or coerce a protobuf request object. 

4077 # The request isn't a proto-plus wrapped type, 

4078 # so it must be constructed via keyword expansion. 

4079 if isinstance(request, dict): 

4080 request = operations_pb2.ListOperationsRequest(**request) 

4081 

4082 # Wrap the RPC method; this adds retry and timeout information, 

4083 # and friendly error handling. 

4084 rpc = self.transport._wrapped_methods[self._client._transport.list_operations] 

4085 

4086 # Certain fields should be provided within the metadata header; 

4087 # add these here. 

4088 metadata = tuple(metadata) + ( 

4089 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

4090 ) 

4091 

4092 # Validate the universe domain. 

4093 self._client._validate_universe_domain() 

4094 

4095 # Send the request. 

4096 response = await rpc( 

4097 request, 

4098 retry=retry, 

4099 timeout=timeout, 

4100 metadata=metadata, 

4101 ) 

4102 

4103 # Done; return the response. 

4104 return response 

4105 

4106 async def get_operation( 

4107 self, 

4108 request: Optional[operations_pb2.GetOperationRequest] = None, 

4109 *, 

4110 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

4111 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

4112 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

4113 ) -> operations_pb2.Operation: 

4114 r"""Gets the latest state of a long-running operation. 

4115 

4116 Args: 

4117 request (:class:`~.operations_pb2.GetOperationRequest`): 

4118 The request object. Request message for 

4119 `GetOperation` method. 

4120 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, 

4121 if any, should be retried. 

4122 timeout (float): The timeout for this request. 

4123 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

4124 sent along with the request as metadata. Normally, each value must be of type `str`, 

4125 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

4126 be of type `bytes`. 

4127 Returns: 

4128 ~.operations_pb2.Operation: 

4129 An ``Operation`` object. 

4130 """ 

4131 # Create or coerce a protobuf request object. 

4132 # The request isn't a proto-plus wrapped type, 

4133 # so it must be constructed via keyword expansion. 

4134 if isinstance(request, dict): 

4135 request = operations_pb2.GetOperationRequest(**request) 

4136 

4137 # Wrap the RPC method; this adds retry and timeout information, 

4138 # and friendly error handling. 

4139 rpc = self.transport._wrapped_methods[self._client._transport.get_operation] 

4140 

4141 # Certain fields should be provided within the metadata header; 

4142 # add these here. 

4143 metadata = tuple(metadata) + ( 

4144 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

4145 ) 

4146 

4147 # Validate the universe domain. 

4148 self._client._validate_universe_domain() 

4149 

4150 # Send the request. 

4151 response = await rpc( 

4152 request, 

4153 retry=retry, 

4154 timeout=timeout, 

4155 metadata=metadata, 

4156 ) 

4157 

4158 # Done; return the response. 

4159 return response 

4160 

4161 async def cancel_operation( 

4162 self, 

4163 request: Optional[operations_pb2.CancelOperationRequest] = None, 

4164 *, 

4165 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

4166 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

4167 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

4168 ) -> None: 

4169 r"""Starts asynchronous cancellation on a long-running operation. 

4170 

4171 The server makes a best effort to cancel the operation, but success 

4172 is not guaranteed. If the server doesn't support this method, it returns 

4173 `google.rpc.Code.UNIMPLEMENTED`. 

4174 

4175 Args: 

4176 request (:class:`~.operations_pb2.CancelOperationRequest`): 

4177 The request object. Request message for 

4178 `CancelOperation` method. 

4179 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, 

4180 if any, should be retried. 

4181 timeout (float): The timeout for this request. 

4182 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

4183 sent along with the request as metadata. Normally, each value must be of type `str`, 

4184 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

4185 be of type `bytes`. 

4186 Returns: 

4187 None 

4188 """ 

4189 # Create or coerce a protobuf request object. 

4190 # The request isn't a proto-plus wrapped type, 

4191 # so it must be constructed via keyword expansion. 

4192 if isinstance(request, dict): 

4193 request = operations_pb2.CancelOperationRequest(**request) 

4194 

4195 # Wrap the RPC method; this adds retry and timeout information, 

4196 # and friendly error handling. 

4197 rpc = self.transport._wrapped_methods[self._client._transport.cancel_operation] 

4198 

4199 # Certain fields should be provided within the metadata header; 

4200 # add these here. 

4201 metadata = tuple(metadata) + ( 

4202 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

4203 ) 

4204 

4205 # Validate the universe domain. 

4206 self._client._validate_universe_domain() 

4207 

4208 # Send the request. 

4209 await rpc( 

4210 request, 

4211 retry=retry, 

4212 timeout=timeout, 

4213 metadata=metadata, 

4214 ) 

4215 

4216 async def __aenter__(self) -> "ConfigServiceV2AsyncClient": 

4217 return self 

4218 

4219 async def __aexit__(self, exc_type, exc, tb): 

4220 await self.transport.close() 

4221 

4222 

4223DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( 

4224 gapic_version=package_version.__version__ 

4225) 

4226 

4227if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER 

4228 DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__ 

4229 

4230 

4231__all__ = ("ConfigServiceV2AsyncClient",)