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

553 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2023-12-08 06:45 +0000

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

2# Copyright 2023 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# 

16from collections import OrderedDict 

17import os 

18import re 

19from typing import ( 

20 Dict, 

21 Mapping, 

22 MutableMapping, 

23 MutableSequence, 

24 Optional, 

25 Sequence, 

26 Tuple, 

27 Type, 

28 Union, 

29 cast, 

30) 

31 

32from google.cloud.logging_v2 import gapic_version as package_version 

33 

34from google.api_core import client_options as client_options_lib 

35from google.api_core import exceptions as core_exceptions 

36from google.api_core import gapic_v1 

37from google.api_core import retry as retries 

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

39from google.auth.transport import mtls # type: ignore 

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

41from google.auth.exceptions import MutualTLSChannelError # type: ignore 

42from google.oauth2 import service_account # type: ignore 

43 

44try: 

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

46except AttributeError: # pragma: NO COVER 

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

48 

49from google.api_core import operation # type: ignore 

50from google.api_core import operation_async # type: ignore 

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

52from google.cloud.logging_v2.types import logging_config 

53from google.longrunning import operations_pb2 # type: ignore 

54from google.protobuf import empty_pb2 # type: ignore 

55from google.protobuf import field_mask_pb2 # type: ignore 

56from google.protobuf import timestamp_pb2 # type: ignore 

57from .transports.base import ConfigServiceV2Transport, DEFAULT_CLIENT_INFO 

58from .transports.grpc import ConfigServiceV2GrpcTransport 

59from .transports.grpc_asyncio import ConfigServiceV2GrpcAsyncIOTransport 

60 

61 

62class ConfigServiceV2ClientMeta(type): 

63 """Metaclass for the ConfigServiceV2 client. 

64 

65 This provides class-level methods for building and retrieving 

66 support objects (e.g. transport) without polluting the client instance 

67 objects. 

68 """ 

69 

70 _transport_registry = ( 

71 OrderedDict() 

72 ) # type: Dict[str, Type[ConfigServiceV2Transport]] 

73 _transport_registry["grpc"] = ConfigServiceV2GrpcTransport 

74 _transport_registry["grpc_asyncio"] = ConfigServiceV2GrpcAsyncIOTransport 

75 

76 def get_transport_class( 

77 cls, 

78 label: Optional[str] = None, 

79 ) -> Type[ConfigServiceV2Transport]: 

80 """Returns an appropriate transport class. 

81 

82 Args: 

83 label: The name of the desired transport. If none is 

84 provided, then the first transport in the registry is used. 

85 

86 Returns: 

87 The transport class to use. 

88 """ 

89 # If a specific transport is requested, return that one. 

90 if label: 

91 return cls._transport_registry[label] 

92 

93 # No transport is requested; return the default (that is, the first one 

94 # in the dictionary). 

95 return next(iter(cls._transport_registry.values())) 

96 

97 

98class ConfigServiceV2Client(metaclass=ConfigServiceV2ClientMeta): 

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

100 

101 @staticmethod 

102 def _get_default_mtls_endpoint(api_endpoint): 

103 """Converts api endpoint to mTLS endpoint. 

104 

105 Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to 

106 "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively. 

107 Args: 

108 api_endpoint (Optional[str]): the api endpoint to convert. 

109 Returns: 

110 str: converted mTLS api endpoint. 

111 """ 

112 if not api_endpoint: 

113 return api_endpoint 

114 

115 mtls_endpoint_re = re.compile( 

116 r"(?P<name>[^.]+)(?P<mtls>\.mtls)?(?P<sandbox>\.sandbox)?(?P<googledomain>\.googleapis\.com)?" 

117 ) 

118 

119 m = mtls_endpoint_re.match(api_endpoint) 

120 name, mtls, sandbox, googledomain = m.groups() 

121 if mtls or not googledomain: 

122 return api_endpoint 

123 

124 if sandbox: 

125 return api_endpoint.replace( 

126 "sandbox.googleapis.com", "mtls.sandbox.googleapis.com" 

127 ) 

128 

129 return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com") 

130 

131 DEFAULT_ENDPOINT = "logging.googleapis.com" 

132 DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore 

133 DEFAULT_ENDPOINT 

134 ) 

135 

136 @classmethod 

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

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

139 info. 

140 

141 Args: 

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

143 args: Additional arguments to pass to the constructor. 

144 kwargs: Additional arguments to pass to the constructor. 

145 

146 Returns: 

147 ConfigServiceV2Client: The constructed client. 

148 """ 

149 credentials = service_account.Credentials.from_service_account_info(info) 

150 kwargs["credentials"] = credentials 

151 return cls(*args, **kwargs) 

152 

153 @classmethod 

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

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

156 file. 

157 

158 Args: 

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

160 file. 

161 args: Additional arguments to pass to the constructor. 

162 kwargs: Additional arguments to pass to the constructor. 

163 

164 Returns: 

165 ConfigServiceV2Client: The constructed client. 

166 """ 

167 credentials = service_account.Credentials.from_service_account_file(filename) 

168 kwargs["credentials"] = credentials 

169 return cls(*args, **kwargs) 

170 

171 from_service_account_json = from_service_account_file 

172 

173 @property 

174 def transport(self) -> ConfigServiceV2Transport: 

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

176 

177 Returns: 

178 ConfigServiceV2Transport: The transport used by the client 

179 instance. 

180 """ 

181 return self._transport 

182 

183 @staticmethod 

184 def cmek_settings_path( 

185 project: str, 

186 ) -> str: 

187 """Returns a fully-qualified cmek_settings string.""" 

188 return "projects/{project}/cmekSettings".format( 

189 project=project, 

190 ) 

191 

192 @staticmethod 

193 def parse_cmek_settings_path(path: str) -> Dict[str, str]: 

194 """Parses a cmek_settings path into its component segments.""" 

195 m = re.match(r"^projects/(?P<project>.+?)/cmekSettings$", path) 

196 return m.groupdict() if m else {} 

197 

198 @staticmethod 

199 def link_path( 

200 project: str, 

201 location: str, 

202 bucket: str, 

203 link: str, 

204 ) -> str: 

205 """Returns a fully-qualified link string.""" 

206 return "projects/{project}/locations/{location}/buckets/{bucket}/links/{link}".format( 

207 project=project, 

208 location=location, 

209 bucket=bucket, 

210 link=link, 

211 ) 

212 

213 @staticmethod 

214 def parse_link_path(path: str) -> Dict[str, str]: 

215 """Parses a link path into its component segments.""" 

216 m = re.match( 

217 r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/buckets/(?P<bucket>.+?)/links/(?P<link>.+?)$", 

218 path, 

219 ) 

220 return m.groupdict() if m else {} 

221 

222 @staticmethod 

223 def log_bucket_path( 

224 project: str, 

225 location: str, 

226 bucket: str, 

227 ) -> str: 

228 """Returns a fully-qualified log_bucket string.""" 

229 return "projects/{project}/locations/{location}/buckets/{bucket}".format( 

230 project=project, 

231 location=location, 

232 bucket=bucket, 

233 ) 

234 

235 @staticmethod 

236 def parse_log_bucket_path(path: str) -> Dict[str, str]: 

237 """Parses a log_bucket path into its component segments.""" 

238 m = re.match( 

239 r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/buckets/(?P<bucket>.+?)$", 

240 path, 

241 ) 

242 return m.groupdict() if m else {} 

243 

244 @staticmethod 

245 def log_exclusion_path( 

246 project: str, 

247 exclusion: str, 

248 ) -> str: 

249 """Returns a fully-qualified log_exclusion string.""" 

250 return "projects/{project}/exclusions/{exclusion}".format( 

251 project=project, 

252 exclusion=exclusion, 

253 ) 

254 

255 @staticmethod 

256 def parse_log_exclusion_path(path: str) -> Dict[str, str]: 

257 """Parses a log_exclusion path into its component segments.""" 

258 m = re.match(r"^projects/(?P<project>.+?)/exclusions/(?P<exclusion>.+?)$", path) 

259 return m.groupdict() if m else {} 

260 

261 @staticmethod 

262 def log_sink_path( 

263 project: str, 

264 sink: str, 

265 ) -> str: 

266 """Returns a fully-qualified log_sink string.""" 

267 return "projects/{project}/sinks/{sink}".format( 

268 project=project, 

269 sink=sink, 

270 ) 

271 

272 @staticmethod 

273 def parse_log_sink_path(path: str) -> Dict[str, str]: 

274 """Parses a log_sink path into its component segments.""" 

275 m = re.match(r"^projects/(?P<project>.+?)/sinks/(?P<sink>.+?)$", path) 

276 return m.groupdict() if m else {} 

277 

278 @staticmethod 

279 def log_view_path( 

280 project: str, 

281 location: str, 

282 bucket: str, 

283 view: str, 

284 ) -> str: 

285 """Returns a fully-qualified log_view string.""" 

286 return "projects/{project}/locations/{location}/buckets/{bucket}/views/{view}".format( 

287 project=project, 

288 location=location, 

289 bucket=bucket, 

290 view=view, 

291 ) 

292 

293 @staticmethod 

294 def parse_log_view_path(path: str) -> Dict[str, str]: 

295 """Parses a log_view path into its component segments.""" 

296 m = re.match( 

297 r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/buckets/(?P<bucket>.+?)/views/(?P<view>.+?)$", 

298 path, 

299 ) 

300 return m.groupdict() if m else {} 

301 

302 @staticmethod 

303 def settings_path( 

304 project: str, 

305 ) -> str: 

306 """Returns a fully-qualified settings string.""" 

307 return "projects/{project}/settings".format( 

308 project=project, 

309 ) 

310 

311 @staticmethod 

312 def parse_settings_path(path: str) -> Dict[str, str]: 

313 """Parses a settings path into its component segments.""" 

314 m = re.match(r"^projects/(?P<project>.+?)/settings$", path) 

315 return m.groupdict() if m else {} 

316 

317 @staticmethod 

318 def common_billing_account_path( 

319 billing_account: str, 

320 ) -> str: 

321 """Returns a fully-qualified billing_account string.""" 

322 return "billingAccounts/{billing_account}".format( 

323 billing_account=billing_account, 

324 ) 

325 

326 @staticmethod 

327 def parse_common_billing_account_path(path: str) -> Dict[str, str]: 

328 """Parse a billing_account path into its component segments.""" 

329 m = re.match(r"^billingAccounts/(?P<billing_account>.+?)$", path) 

330 return m.groupdict() if m else {} 

331 

332 @staticmethod 

333 def common_folder_path( 

334 folder: str, 

335 ) -> str: 

336 """Returns a fully-qualified folder string.""" 

337 return "folders/{folder}".format( 

338 folder=folder, 

339 ) 

340 

341 @staticmethod 

342 def parse_common_folder_path(path: str) -> Dict[str, str]: 

343 """Parse a folder path into its component segments.""" 

344 m = re.match(r"^folders/(?P<folder>.+?)$", path) 

345 return m.groupdict() if m else {} 

346 

347 @staticmethod 

348 def common_organization_path( 

349 organization: str, 

350 ) -> str: 

351 """Returns a fully-qualified organization string.""" 

352 return "organizations/{organization}".format( 

353 organization=organization, 

354 ) 

355 

356 @staticmethod 

357 def parse_common_organization_path(path: str) -> Dict[str, str]: 

358 """Parse a organization path into its component segments.""" 

359 m = re.match(r"^organizations/(?P<organization>.+?)$", path) 

360 return m.groupdict() if m else {} 

361 

362 @staticmethod 

363 def common_project_path( 

364 project: str, 

365 ) -> str: 

366 """Returns a fully-qualified project string.""" 

367 return "projects/{project}".format( 

368 project=project, 

369 ) 

370 

371 @staticmethod 

372 def parse_common_project_path(path: str) -> Dict[str, str]: 

373 """Parse a project path into its component segments.""" 

374 m = re.match(r"^projects/(?P<project>.+?)$", path) 

375 return m.groupdict() if m else {} 

376 

377 @staticmethod 

378 def common_location_path( 

379 project: str, 

380 location: str, 

381 ) -> str: 

382 """Returns a fully-qualified location string.""" 

383 return "projects/{project}/locations/{location}".format( 

384 project=project, 

385 location=location, 

386 ) 

387 

388 @staticmethod 

389 def parse_common_location_path(path: str) -> Dict[str, str]: 

390 """Parse a location path into its component segments.""" 

391 m = re.match(r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)$", path) 

392 return m.groupdict() if m else {} 

393 

394 @classmethod 

395 def get_mtls_endpoint_and_cert_source( 

396 cls, client_options: Optional[client_options_lib.ClientOptions] = None 

397 ): 

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

399 

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

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

402 client cert source is None. 

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

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

405 source is None. 

406 

407 The API endpoint is determined in the following order: 

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

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

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

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

412 use the default API endpoint. 

413 

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

415 

416 Args: 

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

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

419 in this method. 

420 

421 Returns: 

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

423 client cert source to use. 

424 

425 Raises: 

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

427 """ 

428 if client_options is None: 

429 client_options = client_options_lib.ClientOptions() 

430 use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") 

431 use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") 

432 if use_client_cert not in ("true", "false"): 

433 raise ValueError( 

434 "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" 

435 ) 

436 if use_mtls_endpoint not in ("auto", "never", "always"): 

437 raise MutualTLSChannelError( 

438 "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" 

439 ) 

440 

441 # Figure out the client cert source to use. 

442 client_cert_source = None 

443 if use_client_cert == "true": 

444 if client_options.client_cert_source: 

445 client_cert_source = client_options.client_cert_source 

446 elif mtls.has_default_client_cert_source(): 

447 client_cert_source = mtls.default_client_cert_source() 

448 

449 # Figure out which api endpoint to use. 

450 if client_options.api_endpoint is not None: 

451 api_endpoint = client_options.api_endpoint 

452 elif use_mtls_endpoint == "always" or ( 

453 use_mtls_endpoint == "auto" and client_cert_source 

454 ): 

455 api_endpoint = cls.DEFAULT_MTLS_ENDPOINT 

456 else: 

457 api_endpoint = cls.DEFAULT_ENDPOINT 

458 

459 return api_endpoint, client_cert_source 

460 

461 def __init__( 

462 self, 

463 *, 

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

465 transport: Optional[Union[str, ConfigServiceV2Transport]] = None, 

466 client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, 

467 client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, 

468 ) -> None: 

469 """Instantiates the config service v2 client. 

470 

471 Args: 

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

473 authorization credentials to attach to requests. These 

474 credentials identify the application to the service; if none 

475 are specified, the client will attempt to ascertain the 

476 credentials from the environment. 

477 transport (Union[str, ConfigServiceV2Transport]): The 

478 transport to use. If set to None, a transport is chosen 

479 automatically. 

480 client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): Custom options for the 

481 client. It won't take effect if a ``transport`` instance is provided. 

482 (1) The ``api_endpoint`` property can be used to override the 

483 default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT 

484 environment variable can also be used to override the endpoint: 

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

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

487 default mTLS endpoint if client certificate is present, this is 

488 the default value). However, the ``api_endpoint`` property takes 

489 precedence if provided. 

490 (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable 

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

492 to provide client certificate for mutual TLS transport. If 

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

494 present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not 

495 set, no client certificate will be used. 

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

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

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

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

500 your own client library. 

501 

502 Raises: 

503 google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport 

504 creation failed for any reason. 

505 """ 

506 if isinstance(client_options, dict): 

507 client_options = client_options_lib.from_dict(client_options) 

508 if client_options is None: 

509 client_options = client_options_lib.ClientOptions() 

510 client_options = cast(client_options_lib.ClientOptions, client_options) 

511 

512 api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( 

513 client_options 

514 ) 

515 

516 api_key_value = getattr(client_options, "api_key", None) 

517 if api_key_value and credentials: 

518 raise ValueError( 

519 "client_options.api_key and credentials are mutually exclusive" 

520 ) 

521 

522 # Save or instantiate the transport. 

523 # Ordinarily, we provide the transport, but allowing a custom transport 

524 # instance provides an extensibility point for unusual situations. 

525 if isinstance(transport, ConfigServiceV2Transport): 

526 # transport is a ConfigServiceV2Transport instance. 

527 if credentials or client_options.credentials_file or api_key_value: 

528 raise ValueError( 

529 "When providing a transport instance, " 

530 "provide its credentials directly." 

531 ) 

532 if client_options.scopes: 

533 raise ValueError( 

534 "When providing a transport instance, provide its scopes " 

535 "directly." 

536 ) 

537 self._transport = transport 

538 else: 

539 import google.auth._default # type: ignore 

540 

541 if api_key_value and hasattr( 

542 google.auth._default, "get_api_key_credentials" 

543 ): 

544 credentials = google.auth._default.get_api_key_credentials( 

545 api_key_value 

546 ) 

547 

548 Transport = type(self).get_transport_class(transport) 

549 self._transport = Transport( 

550 credentials=credentials, 

551 credentials_file=client_options.credentials_file, 

552 host=api_endpoint, 

553 scopes=client_options.scopes, 

554 client_cert_source_for_mtls=client_cert_source_func, 

555 quota_project_id=client_options.quota_project_id, 

556 client_info=client_info, 

557 always_use_jwt_access=True, 

558 api_audience=client_options.api_audience, 

559 ) 

560 

561 def list_buckets( 

562 self, 

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

564 *, 

565 parent: Optional[str] = None, 

566 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

568 metadata: Sequence[Tuple[str, str]] = (), 

569 ) -> pagers.ListBucketsPager: 

570 r"""Lists log buckets. 

571 

572 .. code-block:: python 

573 

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

575 # code template only. 

576 # It will require modifications to work: 

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

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

579 # client as shown in: 

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

581 from google.cloud import logging_v2 

582 

583 def sample_list_buckets(): 

584 # Create a client 

585 client = logging_v2.ConfigServiceV2Client() 

586 

587 # Initialize request argument(s) 

588 request = logging_v2.ListBucketsRequest( 

589 parent="parent_value", 

590 ) 

591 

592 # Make the request 

593 page_result = client.list_buckets(request=request) 

594 

595 # Handle the response 

596 for response in page_result: 

597 print(response) 

598 

599 Args: 

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

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

602 parent (str): 

603 Required. The parent resource whose buckets are to be 

604 listed: 

605 

606 :: 

607 

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

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

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

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

612 

613 Note: The locations portion of the resource must be 

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

615 [LOCATION_ID] will return all buckets. 

616 

617 This corresponds to the ``parent`` field 

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

619 should not be set. 

620 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

621 should be retried. 

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

623 metadata (Sequence[Tuple[str, str]]): Strings which should be 

624 sent along with the request as metadata. 

625 

626 Returns: 

627 google.cloud.logging_v2.services.config_service_v2.pagers.ListBucketsPager: 

628 The response from ListBuckets. 

629 

630 Iterating over this object will yield 

631 results and resolve additional pages 

632 automatically. 

633 

634 """ 

635 # Create or coerce a protobuf request object. 

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

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

638 has_flattened_params = any([parent]) 

639 if request is not None and has_flattened_params: 

640 raise ValueError( 

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

642 "the individual field arguments should be set." 

643 ) 

644 

645 # Minor optimization to avoid making a copy if the user passes 

646 # in a logging_config.ListBucketsRequest. 

647 # There's no risk of modifying the input as we've already verified 

648 # there are no flattened fields. 

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

650 request = logging_config.ListBucketsRequest(request) 

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

652 # request, apply these. 

653 if parent is not None: 

654 request.parent = parent 

655 

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

657 # and friendly error handling. 

658 rpc = self._transport._wrapped_methods[self._transport.list_buckets] 

659 

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

661 # add these here. 

662 metadata = tuple(metadata) + ( 

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

664 ) 

665 

666 # Send the request. 

667 response = rpc( 

668 request, 

669 retry=retry, 

670 timeout=timeout, 

671 metadata=metadata, 

672 ) 

673 

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

675 # an `__iter__` convenience method. 

676 response = pagers.ListBucketsPager( 

677 method=rpc, 

678 request=request, 

679 response=response, 

680 metadata=metadata, 

681 ) 

682 

683 # Done; return the response. 

684 return response 

685 

686 def get_bucket( 

687 self, 

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

689 *, 

690 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

692 metadata: Sequence[Tuple[str, str]] = (), 

693 ) -> logging_config.LogBucket: 

694 r"""Gets a log bucket. 

695 

696 .. code-block:: python 

697 

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

699 # code template only. 

700 # It will require modifications to work: 

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

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

703 # client as shown in: 

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

705 from google.cloud import logging_v2 

706 

707 def sample_get_bucket(): 

708 # Create a client 

709 client = logging_v2.ConfigServiceV2Client() 

710 

711 # Initialize request argument(s) 

712 request = logging_v2.GetBucketRequest( 

713 name="name_value", 

714 ) 

715 

716 # Make the request 

717 response = client.get_bucket(request=request) 

718 

719 # Handle the response 

720 print(response) 

721 

722 Args: 

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

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

725 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

726 should be retried. 

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

728 metadata (Sequence[Tuple[str, str]]): Strings which should be 

729 sent along with the request as metadata. 

730 

731 Returns: 

732 google.cloud.logging_v2.types.LogBucket: 

733 Describes a repository in which log 

734 entries are stored. 

735 

736 """ 

737 # Create or coerce a protobuf request object. 

738 # Minor optimization to avoid making a copy if the user passes 

739 # in a logging_config.GetBucketRequest. 

740 # There's no risk of modifying the input as we've already verified 

741 # there are no flattened fields. 

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

743 request = logging_config.GetBucketRequest(request) 

744 

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

746 # and friendly error handling. 

747 rpc = self._transport._wrapped_methods[self._transport.get_bucket] 

748 

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

750 # add these here. 

751 metadata = tuple(metadata) + ( 

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

753 ) 

754 

755 # Send the request. 

756 response = rpc( 

757 request, 

758 retry=retry, 

759 timeout=timeout, 

760 metadata=metadata, 

761 ) 

762 

763 # Done; return the response. 

764 return response 

765 

766 def create_bucket_async( 

767 self, 

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

769 *, 

770 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

772 metadata: Sequence[Tuple[str, str]] = (), 

773 ) -> operation.Operation: 

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

775 to store log entries. 

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

777 cannot be changed. 

778 

779 .. code-block:: python 

780 

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

782 # code template only. 

783 # It will require modifications to work: 

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

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

786 # client as shown in: 

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

788 from google.cloud import logging_v2 

789 

790 def sample_create_bucket_async(): 

791 # Create a client 

792 client = logging_v2.ConfigServiceV2Client() 

793 

794 # Initialize request argument(s) 

795 request = logging_v2.CreateBucketRequest( 

796 parent="parent_value", 

797 bucket_id="bucket_id_value", 

798 ) 

799 

800 # Make the request 

801 operation = client.create_bucket_async(request=request) 

802 

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

804 

805 response = operation.result() 

806 

807 # Handle the response 

808 print(response) 

809 

810 Args: 

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

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

813 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

814 should be retried. 

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

816 metadata (Sequence[Tuple[str, str]]): Strings which should be 

817 sent along with the request as metadata. 

818 

819 Returns: 

820 google.api_core.operation.Operation: 

821 An object representing a long-running operation. 

822 

823 The result type for the operation will be 

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

825 Describes a repository in which log entries are stored. 

826 

827 """ 

828 # Create or coerce a protobuf request object. 

829 # Minor optimization to avoid making a copy if the user passes 

830 # in a logging_config.CreateBucketRequest. 

831 # There's no risk of modifying the input as we've already verified 

832 # there are no flattened fields. 

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

834 request = logging_config.CreateBucketRequest(request) 

835 

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

837 # and friendly error handling. 

838 rpc = self._transport._wrapped_methods[self._transport.create_bucket_async] 

839 

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

841 # add these here. 

842 metadata = tuple(metadata) + ( 

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

844 ) 

845 

846 # Send the request. 

847 response = rpc( 

848 request, 

849 retry=retry, 

850 timeout=timeout, 

851 metadata=metadata, 

852 ) 

853 

854 # Wrap the response in an operation future. 

855 response = operation.from_gapic( 

856 response, 

857 self._transport.operations_client, 

858 logging_config.LogBucket, 

859 metadata_type=logging_config.BucketMetadata, 

860 ) 

861 

862 # Done; return the response. 

863 return response 

864 

865 def update_bucket_async( 

866 self, 

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

868 *, 

869 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

871 metadata: Sequence[Tuple[str, str]] = (), 

872 ) -> operation.Operation: 

873 r"""Updates a log bucket asynchronously. 

874 

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

876 then ``FAILED_PRECONDITION`` will be returned. 

877 

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

879 changed. 

880 

881 .. code-block:: python 

882 

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

884 # code template only. 

885 # It will require modifications to work: 

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

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

888 # client as shown in: 

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

890 from google.cloud import logging_v2 

891 

892 def sample_update_bucket_async(): 

893 # Create a client 

894 client = logging_v2.ConfigServiceV2Client() 

895 

896 # Initialize request argument(s) 

897 request = logging_v2.UpdateBucketRequest( 

898 name="name_value", 

899 ) 

900 

901 # Make the request 

902 operation = client.update_bucket_async(request=request) 

903 

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

905 

906 response = operation.result() 

907 

908 # Handle the response 

909 print(response) 

910 

911 Args: 

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

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

914 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

915 should be retried. 

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

917 metadata (Sequence[Tuple[str, str]]): Strings which should be 

918 sent along with the request as metadata. 

919 

920 Returns: 

921 google.api_core.operation.Operation: 

922 An object representing a long-running operation. 

923 

924 The result type for the operation will be 

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

926 Describes a repository in which log entries are stored. 

927 

928 """ 

929 # Create or coerce a protobuf request object. 

930 # Minor optimization to avoid making a copy if the user passes 

931 # in a logging_config.UpdateBucketRequest. 

932 # There's no risk of modifying the input as we've already verified 

933 # there are no flattened fields. 

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

935 request = logging_config.UpdateBucketRequest(request) 

936 

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

938 # and friendly error handling. 

939 rpc = self._transport._wrapped_methods[self._transport.update_bucket_async] 

940 

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

942 # add these here. 

943 metadata = tuple(metadata) + ( 

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

945 ) 

946 

947 # Send the request. 

948 response = rpc( 

949 request, 

950 retry=retry, 

951 timeout=timeout, 

952 metadata=metadata, 

953 ) 

954 

955 # Wrap the response in an operation future. 

956 response = operation.from_gapic( 

957 response, 

958 self._transport.operations_client, 

959 logging_config.LogBucket, 

960 metadata_type=logging_config.BucketMetadata, 

961 ) 

962 

963 # Done; return the response. 

964 return response 

965 

966 def create_bucket( 

967 self, 

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

969 *, 

970 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

972 metadata: Sequence[Tuple[str, str]] = (), 

973 ) -> logging_config.LogBucket: 

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

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

976 location cannot be changed. 

977 

978 .. code-block:: python 

979 

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

981 # code template only. 

982 # It will require modifications to work: 

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

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

985 # client as shown in: 

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

987 from google.cloud import logging_v2 

988 

989 def sample_create_bucket(): 

990 # Create a client 

991 client = logging_v2.ConfigServiceV2Client() 

992 

993 # Initialize request argument(s) 

994 request = logging_v2.CreateBucketRequest( 

995 parent="parent_value", 

996 bucket_id="bucket_id_value", 

997 ) 

998 

999 # Make the request 

1000 response = client.create_bucket(request=request) 

1001 

1002 # Handle the response 

1003 print(response) 

1004 

1005 Args: 

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

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

1008 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

1009 should be retried. 

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

1011 metadata (Sequence[Tuple[str, str]]): Strings which should be 

1012 sent along with the request as metadata. 

1013 

1014 Returns: 

1015 google.cloud.logging_v2.types.LogBucket: 

1016 Describes a repository in which log 

1017 entries are stored. 

1018 

1019 """ 

1020 # Create or coerce a protobuf request object. 

1021 # Minor optimization to avoid making a copy if the user passes 

1022 # in a logging_config.CreateBucketRequest. 

1023 # There's no risk of modifying the input as we've already verified 

1024 # there are no flattened fields. 

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

1026 request = logging_config.CreateBucketRequest(request) 

1027 

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

1029 # and friendly error handling. 

1030 rpc = self._transport._wrapped_methods[self._transport.create_bucket] 

1031 

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

1033 # add these here. 

1034 metadata = tuple(metadata) + ( 

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

1036 ) 

1037 

1038 # Send the request. 

1039 response = rpc( 

1040 request, 

1041 retry=retry, 

1042 timeout=timeout, 

1043 metadata=metadata, 

1044 ) 

1045 

1046 # Done; return the response. 

1047 return response 

1048 

1049 def update_bucket( 

1050 self, 

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

1052 *, 

1053 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

1055 metadata: Sequence[Tuple[str, str]] = (), 

1056 ) -> logging_config.LogBucket: 

1057 r"""Updates a log bucket. 

1058 

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

1060 then ``FAILED_PRECONDITION`` will be returned. 

1061 

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

1063 changed. 

1064 

1065 .. code-block:: python 

1066 

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

1068 # code template only. 

1069 # It will require modifications to work: 

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

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

1072 # client as shown in: 

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

1074 from google.cloud import logging_v2 

1075 

1076 def sample_update_bucket(): 

1077 # Create a client 

1078 client = logging_v2.ConfigServiceV2Client() 

1079 

1080 # Initialize request argument(s) 

1081 request = logging_v2.UpdateBucketRequest( 

1082 name="name_value", 

1083 ) 

1084 

1085 # Make the request 

1086 response = client.update_bucket(request=request) 

1087 

1088 # Handle the response 

1089 print(response) 

1090 

1091 Args: 

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

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

1094 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

1095 should be retried. 

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

1097 metadata (Sequence[Tuple[str, str]]): Strings which should be 

1098 sent along with the request as metadata. 

1099 

1100 Returns: 

1101 google.cloud.logging_v2.types.LogBucket: 

1102 Describes a repository in which log 

1103 entries are stored. 

1104 

1105 """ 

1106 # Create or coerce a protobuf request object. 

1107 # Minor optimization to avoid making a copy if the user passes 

1108 # in a logging_config.UpdateBucketRequest. 

1109 # There's no risk of modifying the input as we've already verified 

1110 # there are no flattened fields. 

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

1112 request = logging_config.UpdateBucketRequest(request) 

1113 

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

1115 # and friendly error handling. 

1116 rpc = self._transport._wrapped_methods[self._transport.update_bucket] 

1117 

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

1119 # add these here. 

1120 metadata = tuple(metadata) + ( 

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

1122 ) 

1123 

1124 # Send the request. 

1125 response = rpc( 

1126 request, 

1127 retry=retry, 

1128 timeout=timeout, 

1129 metadata=metadata, 

1130 ) 

1131 

1132 # Done; return the response. 

1133 return response 

1134 

1135 def delete_bucket( 

1136 self, 

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

1138 *, 

1139 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

1141 metadata: Sequence[Tuple[str, str]] = (), 

1142 ) -> None: 

1143 r"""Deletes a log bucket. 

1144 

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

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

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

1148 deleted. 

1149 

1150 .. code-block:: python 

1151 

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

1153 # code template only. 

1154 # It will require modifications to work: 

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

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

1157 # client as shown in: 

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

1159 from google.cloud import logging_v2 

1160 

1161 def sample_delete_bucket(): 

1162 # Create a client 

1163 client = logging_v2.ConfigServiceV2Client() 

1164 

1165 # Initialize request argument(s) 

1166 request = logging_v2.DeleteBucketRequest( 

1167 name="name_value", 

1168 ) 

1169 

1170 # Make the request 

1171 client.delete_bucket(request=request) 

1172 

1173 Args: 

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

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

1176 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

1177 should be retried. 

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

1179 metadata (Sequence[Tuple[str, str]]): Strings which should be 

1180 sent along with the request as metadata. 

1181 """ 

1182 # Create or coerce a protobuf request object. 

1183 # Minor optimization to avoid making a copy if the user passes 

1184 # in a logging_config.DeleteBucketRequest. 

1185 # There's no risk of modifying the input as we've already verified 

1186 # there are no flattened fields. 

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

1188 request = logging_config.DeleteBucketRequest(request) 

1189 

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

1191 # and friendly error handling. 

1192 rpc = self._transport._wrapped_methods[self._transport.delete_bucket] 

1193 

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

1195 # add these here. 

1196 metadata = tuple(metadata) + ( 

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

1198 ) 

1199 

1200 # Send the request. 

1201 rpc( 

1202 request, 

1203 retry=retry, 

1204 timeout=timeout, 

1205 metadata=metadata, 

1206 ) 

1207 

1208 def undelete_bucket( 

1209 self, 

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

1211 *, 

1212 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

1214 metadata: Sequence[Tuple[str, str]] = (), 

1215 ) -> None: 

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

1217 deleted can be undeleted within the grace period of 7 

1218 days. 

1219 

1220 .. code-block:: python 

1221 

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

1223 # code template only. 

1224 # It will require modifications to work: 

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

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

1227 # client as shown in: 

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

1229 from google.cloud import logging_v2 

1230 

1231 def sample_undelete_bucket(): 

1232 # Create a client 

1233 client = logging_v2.ConfigServiceV2Client() 

1234 

1235 # Initialize request argument(s) 

1236 request = logging_v2.UndeleteBucketRequest( 

1237 name="name_value", 

1238 ) 

1239 

1240 # Make the request 

1241 client.undelete_bucket(request=request) 

1242 

1243 Args: 

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

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

1246 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

1247 should be retried. 

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

1249 metadata (Sequence[Tuple[str, str]]): Strings which should be 

1250 sent along with the request as metadata. 

1251 """ 

1252 # Create or coerce a protobuf request object. 

1253 # Minor optimization to avoid making a copy if the user passes 

1254 # in a logging_config.UndeleteBucketRequest. 

1255 # There's no risk of modifying the input as we've already verified 

1256 # there are no flattened fields. 

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

1258 request = logging_config.UndeleteBucketRequest(request) 

1259 

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

1261 # and friendly error handling. 

1262 rpc = self._transport._wrapped_methods[self._transport.undelete_bucket] 

1263 

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

1265 # add these here. 

1266 metadata = tuple(metadata) + ( 

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

1268 ) 

1269 

1270 # Send the request. 

1271 rpc( 

1272 request, 

1273 retry=retry, 

1274 timeout=timeout, 

1275 metadata=metadata, 

1276 ) 

1277 

1278 def list_views( 

1279 self, 

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

1281 *, 

1282 parent: Optional[str] = None, 

1283 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

1285 metadata: Sequence[Tuple[str, str]] = (), 

1286 ) -> pagers.ListViewsPager: 

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

1288 

1289 .. code-block:: python 

1290 

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

1292 # code template only. 

1293 # It will require modifications to work: 

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

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

1296 # client as shown in: 

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

1298 from google.cloud import logging_v2 

1299 

1300 def sample_list_views(): 

1301 # Create a client 

1302 client = logging_v2.ConfigServiceV2Client() 

1303 

1304 # Initialize request argument(s) 

1305 request = logging_v2.ListViewsRequest( 

1306 parent="parent_value", 

1307 ) 

1308 

1309 # Make the request 

1310 page_result = client.list_views(request=request) 

1311 

1312 # Handle the response 

1313 for response in page_result: 

1314 print(response) 

1315 

1316 Args: 

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

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

1319 parent (str): 

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

1321 

1322 :: 

1323 

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

1325 

1326 This corresponds to the ``parent`` field 

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

1328 should not be set. 

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

1330 should be retried. 

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

1332 metadata (Sequence[Tuple[str, str]]): Strings which should be 

1333 sent along with the request as metadata. 

1334 

1335 Returns: 

1336 google.cloud.logging_v2.services.config_service_v2.pagers.ListViewsPager: 

1337 The response from ListViews. 

1338 

1339 Iterating over this object will yield 

1340 results and resolve additional pages 

1341 automatically. 

1342 

1343 """ 

1344 # Create or coerce a protobuf request object. 

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

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

1347 has_flattened_params = any([parent]) 

1348 if request is not None and has_flattened_params: 

1349 raise ValueError( 

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

1351 "the individual field arguments should be set." 

1352 ) 

1353 

1354 # Minor optimization to avoid making a copy if the user passes 

1355 # in a logging_config.ListViewsRequest. 

1356 # There's no risk of modifying the input as we've already verified 

1357 # there are no flattened fields. 

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

1359 request = logging_config.ListViewsRequest(request) 

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

1361 # request, apply these. 

1362 if parent is not None: 

1363 request.parent = parent 

1364 

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

1366 # and friendly error handling. 

1367 rpc = self._transport._wrapped_methods[self._transport.list_views] 

1368 

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

1370 # add these here. 

1371 metadata = tuple(metadata) + ( 

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

1373 ) 

1374 

1375 # Send the request. 

1376 response = rpc( 

1377 request, 

1378 retry=retry, 

1379 timeout=timeout, 

1380 metadata=metadata, 

1381 ) 

1382 

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

1384 # an `__iter__` convenience method. 

1385 response = pagers.ListViewsPager( 

1386 method=rpc, 

1387 request=request, 

1388 response=response, 

1389 metadata=metadata, 

1390 ) 

1391 

1392 # Done; return the response. 

1393 return response 

1394 

1395 def get_view( 

1396 self, 

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

1398 *, 

1399 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

1401 metadata: Sequence[Tuple[str, str]] = (), 

1402 ) -> logging_config.LogView: 

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

1404 

1405 .. code-block:: python 

1406 

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

1408 # code template only. 

1409 # It will require modifications to work: 

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

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

1412 # client as shown in: 

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

1414 from google.cloud import logging_v2 

1415 

1416 def sample_get_view(): 

1417 # Create a client 

1418 client = logging_v2.ConfigServiceV2Client() 

1419 

1420 # Initialize request argument(s) 

1421 request = logging_v2.GetViewRequest( 

1422 name="name_value", 

1423 ) 

1424 

1425 # Make the request 

1426 response = client.get_view(request=request) 

1427 

1428 # Handle the response 

1429 print(response) 

1430 

1431 Args: 

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

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

1434 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

1435 should be retried. 

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

1437 metadata (Sequence[Tuple[str, str]]): Strings which should be 

1438 sent along with the request as metadata. 

1439 

1440 Returns: 

1441 google.cloud.logging_v2.types.LogView: 

1442 Describes a view over log entries in 

1443 a bucket. 

1444 

1445 """ 

1446 # Create or coerce a protobuf request object. 

1447 # Minor optimization to avoid making a copy if the user passes 

1448 # in a logging_config.GetViewRequest. 

1449 # There's no risk of modifying the input as we've already verified 

1450 # there are no flattened fields. 

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

1452 request = logging_config.GetViewRequest(request) 

1453 

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

1455 # and friendly error handling. 

1456 rpc = self._transport._wrapped_methods[self._transport.get_view] 

1457 

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

1459 # add these here. 

1460 metadata = tuple(metadata) + ( 

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

1462 ) 

1463 

1464 # Send the request. 

1465 response = rpc( 

1466 request, 

1467 retry=retry, 

1468 timeout=timeout, 

1469 metadata=metadata, 

1470 ) 

1471 

1472 # Done; return the response. 

1473 return response 

1474 

1475 def create_view( 

1476 self, 

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

1478 *, 

1479 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

1481 metadata: Sequence[Tuple[str, str]] = (), 

1482 ) -> logging_config.LogView: 

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

1484 bucket may contain a maximum of 30 views. 

1485 

1486 .. code-block:: python 

1487 

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

1489 # code template only. 

1490 # It will require modifications to work: 

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

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

1493 # client as shown in: 

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

1495 from google.cloud import logging_v2 

1496 

1497 def sample_create_view(): 

1498 # Create a client 

1499 client = logging_v2.ConfigServiceV2Client() 

1500 

1501 # Initialize request argument(s) 

1502 request = logging_v2.CreateViewRequest( 

1503 parent="parent_value", 

1504 view_id="view_id_value", 

1505 ) 

1506 

1507 # Make the request 

1508 response = client.create_view(request=request) 

1509 

1510 # Handle the response 

1511 print(response) 

1512 

1513 Args: 

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

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

1516 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

1517 should be retried. 

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

1519 metadata (Sequence[Tuple[str, str]]): Strings which should be 

1520 sent along with the request as metadata. 

1521 

1522 Returns: 

1523 google.cloud.logging_v2.types.LogView: 

1524 Describes a view over log entries in 

1525 a bucket. 

1526 

1527 """ 

1528 # Create or coerce a protobuf request object. 

1529 # Minor optimization to avoid making a copy if the user passes 

1530 # in a logging_config.CreateViewRequest. 

1531 # There's no risk of modifying the input as we've already verified 

1532 # there are no flattened fields. 

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

1534 request = logging_config.CreateViewRequest(request) 

1535 

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

1537 # and friendly error handling. 

1538 rpc = self._transport._wrapped_methods[self._transport.create_view] 

1539 

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

1541 # add these here. 

1542 metadata = tuple(metadata) + ( 

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

1544 ) 

1545 

1546 # Send the request. 

1547 response = rpc( 

1548 request, 

1549 retry=retry, 

1550 timeout=timeout, 

1551 metadata=metadata, 

1552 ) 

1553 

1554 # Done; return the response. 

1555 return response 

1556 

1557 def update_view( 

1558 self, 

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

1560 *, 

1561 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

1563 metadata: Sequence[Tuple[str, str]] = (), 

1564 ) -> logging_config.LogView: 

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

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

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

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

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

1570 

1571 .. code-block:: python 

1572 

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

1574 # code template only. 

1575 # It will require modifications to work: 

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

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

1578 # client as shown in: 

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

1580 from google.cloud import logging_v2 

1581 

1582 def sample_update_view(): 

1583 # Create a client 

1584 client = logging_v2.ConfigServiceV2Client() 

1585 

1586 # Initialize request argument(s) 

1587 request = logging_v2.UpdateViewRequest( 

1588 name="name_value", 

1589 ) 

1590 

1591 # Make the request 

1592 response = client.update_view(request=request) 

1593 

1594 # Handle the response 

1595 print(response) 

1596 

1597 Args: 

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

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

1600 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

1601 should be retried. 

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

1603 metadata (Sequence[Tuple[str, str]]): Strings which should be 

1604 sent along with the request as metadata. 

1605 

1606 Returns: 

1607 google.cloud.logging_v2.types.LogView: 

1608 Describes a view over log entries in 

1609 a bucket. 

1610 

1611 """ 

1612 # Create or coerce a protobuf request object. 

1613 # Minor optimization to avoid making a copy if the user passes 

1614 # in a logging_config.UpdateViewRequest. 

1615 # There's no risk of modifying the input as we've already verified 

1616 # there are no flattened fields. 

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

1618 request = logging_config.UpdateViewRequest(request) 

1619 

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

1621 # and friendly error handling. 

1622 rpc = self._transport._wrapped_methods[self._transport.update_view] 

1623 

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

1625 # add these here. 

1626 metadata = tuple(metadata) + ( 

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

1628 ) 

1629 

1630 # Send the request. 

1631 response = rpc( 

1632 request, 

1633 retry=retry, 

1634 timeout=timeout, 

1635 metadata=metadata, 

1636 ) 

1637 

1638 # Done; return the response. 

1639 return response 

1640 

1641 def delete_view( 

1642 self, 

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

1644 *, 

1645 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

1647 metadata: Sequence[Tuple[str, str]] = (), 

1648 ) -> None: 

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

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

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

1652 minutes. 

1653 

1654 .. code-block:: python 

1655 

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

1657 # code template only. 

1658 # It will require modifications to work: 

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

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

1661 # client as shown in: 

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

1663 from google.cloud import logging_v2 

1664 

1665 def sample_delete_view(): 

1666 # Create a client 

1667 client = logging_v2.ConfigServiceV2Client() 

1668 

1669 # Initialize request argument(s) 

1670 request = logging_v2.DeleteViewRequest( 

1671 name="name_value", 

1672 ) 

1673 

1674 # Make the request 

1675 client.delete_view(request=request) 

1676 

1677 Args: 

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

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

1680 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

1681 should be retried. 

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

1683 metadata (Sequence[Tuple[str, str]]): Strings which should be 

1684 sent along with the request as metadata. 

1685 """ 

1686 # Create or coerce a protobuf request object. 

1687 # Minor optimization to avoid making a copy if the user passes 

1688 # in a logging_config.DeleteViewRequest. 

1689 # There's no risk of modifying the input as we've already verified 

1690 # there are no flattened fields. 

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

1692 request = logging_config.DeleteViewRequest(request) 

1693 

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

1695 # and friendly error handling. 

1696 rpc = self._transport._wrapped_methods[self._transport.delete_view] 

1697 

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

1699 # add these here. 

1700 metadata = tuple(metadata) + ( 

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

1702 ) 

1703 

1704 # Send the request. 

1705 rpc( 

1706 request, 

1707 retry=retry, 

1708 timeout=timeout, 

1709 metadata=metadata, 

1710 ) 

1711 

1712 def list_sinks( 

1713 self, 

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

1715 *, 

1716 parent: Optional[str] = None, 

1717 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

1719 metadata: Sequence[Tuple[str, str]] = (), 

1720 ) -> pagers.ListSinksPager: 

1721 r"""Lists sinks. 

1722 

1723 .. code-block:: python 

1724 

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

1726 # code template only. 

1727 # It will require modifications to work: 

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

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

1730 # client as shown in: 

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

1732 from google.cloud import logging_v2 

1733 

1734 def sample_list_sinks(): 

1735 # Create a client 

1736 client = logging_v2.ConfigServiceV2Client() 

1737 

1738 # Initialize request argument(s) 

1739 request = logging_v2.ListSinksRequest( 

1740 parent="parent_value", 

1741 ) 

1742 

1743 # Make the request 

1744 page_result = client.list_sinks(request=request) 

1745 

1746 # Handle the response 

1747 for response in page_result: 

1748 print(response) 

1749 

1750 Args: 

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

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

1753 parent (str): 

1754 Required. The parent resource whose sinks are to be 

1755 listed: 

1756 

1757 :: 

1758 

1759 "projects/[PROJECT_ID]" 

1760 "organizations/[ORGANIZATION_ID]" 

1761 "billingAccounts/[BILLING_ACCOUNT_ID]" 

1762 "folders/[FOLDER_ID]" 

1763 

1764 This corresponds to the ``parent`` field 

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

1766 should not be set. 

1767 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

1768 should be retried. 

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

1770 metadata (Sequence[Tuple[str, str]]): Strings which should be 

1771 sent along with the request as metadata. 

1772 

1773 Returns: 

1774 google.cloud.logging_v2.services.config_service_v2.pagers.ListSinksPager: 

1775 Result returned from ListSinks. 

1776 

1777 Iterating over this object will yield results and 

1778 resolve additional pages automatically. 

1779 

1780 """ 

1781 # Create or coerce a protobuf request object. 

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

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

1784 has_flattened_params = any([parent]) 

1785 if request is not None and has_flattened_params: 

1786 raise ValueError( 

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

1788 "the individual field arguments should be set." 

1789 ) 

1790 

1791 # Minor optimization to avoid making a copy if the user passes 

1792 # in a logging_config.ListSinksRequest. 

1793 # There's no risk of modifying the input as we've already verified 

1794 # there are no flattened fields. 

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

1796 request = logging_config.ListSinksRequest(request) 

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

1798 # request, apply these. 

1799 if parent is not None: 

1800 request.parent = parent 

1801 

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

1803 # and friendly error handling. 

1804 rpc = self._transport._wrapped_methods[self._transport.list_sinks] 

1805 

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

1807 # add these here. 

1808 metadata = tuple(metadata) + ( 

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

1810 ) 

1811 

1812 # Send the request. 

1813 response = rpc( 

1814 request, 

1815 retry=retry, 

1816 timeout=timeout, 

1817 metadata=metadata, 

1818 ) 

1819 

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

1821 # an `__iter__` convenience method. 

1822 response = pagers.ListSinksPager( 

1823 method=rpc, 

1824 request=request, 

1825 response=response, 

1826 metadata=metadata, 

1827 ) 

1828 

1829 # Done; return the response. 

1830 return response 

1831 

1832 def get_sink( 

1833 self, 

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

1835 *, 

1836 sink_name: Optional[str] = None, 

1837 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

1839 metadata: Sequence[Tuple[str, str]] = (), 

1840 ) -> logging_config.LogSink: 

1841 r"""Gets a sink. 

1842 

1843 .. code-block:: python 

1844 

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

1846 # code template only. 

1847 # It will require modifications to work: 

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

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

1850 # client as shown in: 

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

1852 from google.cloud import logging_v2 

1853 

1854 def sample_get_sink(): 

1855 # Create a client 

1856 client = logging_v2.ConfigServiceV2Client() 

1857 

1858 # Initialize request argument(s) 

1859 request = logging_v2.GetSinkRequest( 

1860 sink_name="sink_name_value", 

1861 ) 

1862 

1863 # Make the request 

1864 response = client.get_sink(request=request) 

1865 

1866 # Handle the response 

1867 print(response) 

1868 

1869 Args: 

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

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

1872 sink_name (str): 

1873 Required. The resource name of the sink: 

1874 

1875 :: 

1876 

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

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

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

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

1881 

1882 For example: 

1883 

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

1885 

1886 This corresponds to the ``sink_name`` field 

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

1888 should not be set. 

1889 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

1890 should be retried. 

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

1892 metadata (Sequence[Tuple[str, str]]): Strings which should be 

1893 sent along with the request as metadata. 

1894 

1895 Returns: 

1896 google.cloud.logging_v2.types.LogSink: 

1897 Describes a sink used to export log 

1898 entries to one of the following 

1899 destinations in any project: a Cloud 

1900 Storage bucket, a BigQuery dataset, a 

1901 Pub/Sub topic or a Cloud Logging log 

1902 bucket. A logs filter controls which log 

1903 entries are exported. The sink must be 

1904 created within a project, organization, 

1905 billing account, or folder. 

1906 

1907 """ 

1908 # Create or coerce a protobuf request object. 

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

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

1911 has_flattened_params = any([sink_name]) 

1912 if request is not None and has_flattened_params: 

1913 raise ValueError( 

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

1915 "the individual field arguments should be set." 

1916 ) 

1917 

1918 # Minor optimization to avoid making a copy if the user passes 

1919 # in a logging_config.GetSinkRequest. 

1920 # There's no risk of modifying the input as we've already verified 

1921 # there are no flattened fields. 

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

1923 request = logging_config.GetSinkRequest(request) 

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

1925 # request, apply these. 

1926 if sink_name is not None: 

1927 request.sink_name = sink_name 

1928 

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

1930 # and friendly error handling. 

1931 rpc = self._transport._wrapped_methods[self._transport.get_sink] 

1932 

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

1934 # add these here. 

1935 metadata = tuple(metadata) + ( 

1936 gapic_v1.routing_header.to_grpc_metadata( 

1937 (("sink_name", request.sink_name),) 

1938 ), 

1939 ) 

1940 

1941 # Send the request. 

1942 response = rpc( 

1943 request, 

1944 retry=retry, 

1945 timeout=timeout, 

1946 metadata=metadata, 

1947 ) 

1948 

1949 # Done; return the response. 

1950 return response 

1951 

1952 def create_sink( 

1953 self, 

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

1955 *, 

1956 parent: Optional[str] = None, 

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

1958 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

1960 metadata: Sequence[Tuple[str, str]] = (), 

1961 ) -> logging_config.LogSink: 

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

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

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

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

1966 entries only from the resource owning the sink. 

1967 

1968 .. code-block:: python 

1969 

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

1971 # code template only. 

1972 # It will require modifications to work: 

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

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

1975 # client as shown in: 

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

1977 from google.cloud import logging_v2 

1978 

1979 def sample_create_sink(): 

1980 # Create a client 

1981 client = logging_v2.ConfigServiceV2Client() 

1982 

1983 # Initialize request argument(s) 

1984 sink = logging_v2.LogSink() 

1985 sink.name = "name_value" 

1986 sink.destination = "destination_value" 

1987 

1988 request = logging_v2.CreateSinkRequest( 

1989 parent="parent_value", 

1990 sink=sink, 

1991 ) 

1992 

1993 # Make the request 

1994 response = client.create_sink(request=request) 

1995 

1996 # Handle the response 

1997 print(response) 

1998 

1999 Args: 

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

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

2002 parent (str): 

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

2004 

2005 :: 

2006 

2007 "projects/[PROJECT_ID]" 

2008 "organizations/[ORGANIZATION_ID]" 

2009 "billingAccounts/[BILLING_ACCOUNT_ID]" 

2010 "folders/[FOLDER_ID]" 

2011 

2012 For examples: 

2013 

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

2015 

2016 This corresponds to the ``parent`` field 

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

2018 should not be set. 

2019 sink (google.cloud.logging_v2.types.LogSink): 

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

2021 sink identifier that is not already in use. 

2022 

2023 This corresponds to the ``sink`` field 

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

2025 should not be set. 

2026 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

2027 should be retried. 

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

2029 metadata (Sequence[Tuple[str, str]]): Strings which should be 

2030 sent along with the request as metadata. 

2031 

2032 Returns: 

2033 google.cloud.logging_v2.types.LogSink: 

2034 Describes a sink used to export log 

2035 entries to one of the following 

2036 destinations in any project: a Cloud 

2037 Storage bucket, a BigQuery dataset, a 

2038 Pub/Sub topic or a Cloud Logging log 

2039 bucket. A logs filter controls which log 

2040 entries are exported. The sink must be 

2041 created within a project, organization, 

2042 billing account, or folder. 

2043 

2044 """ 

2045 # Create or coerce a protobuf request object. 

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

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

2048 has_flattened_params = any([parent, sink]) 

2049 if request is not None and has_flattened_params: 

2050 raise ValueError( 

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

2052 "the individual field arguments should be set." 

2053 ) 

2054 

2055 # Minor optimization to avoid making a copy if the user passes 

2056 # in a logging_config.CreateSinkRequest. 

2057 # There's no risk of modifying the input as we've already verified 

2058 # there are no flattened fields. 

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

2060 request = logging_config.CreateSinkRequest(request) 

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

2062 # request, apply these. 

2063 if parent is not None: 

2064 request.parent = parent 

2065 if sink is not None: 

2066 request.sink = sink 

2067 

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

2069 # and friendly error handling. 

2070 rpc = self._transport._wrapped_methods[self._transport.create_sink] 

2071 

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

2073 # add these here. 

2074 metadata = tuple(metadata) + ( 

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

2076 ) 

2077 

2078 # Send the request. 

2079 response = rpc( 

2080 request, 

2081 retry=retry, 

2082 timeout=timeout, 

2083 metadata=metadata, 

2084 ) 

2085 

2086 # Done; return the response. 

2087 return response 

2088 

2089 def update_sink( 

2090 self, 

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

2092 *, 

2093 sink_name: Optional[str] = None, 

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

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

2096 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

2098 metadata: Sequence[Tuple[str, str]] = (), 

2099 ) -> logging_config.LogSink: 

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

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

2102 and ``filter``. 

2103 

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

2105 the ``unique_writer_identity`` field. 

2106 

2107 .. code-block:: python 

2108 

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

2110 # code template only. 

2111 # It will require modifications to work: 

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

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

2114 # client as shown in: 

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

2116 from google.cloud import logging_v2 

2117 

2118 def sample_update_sink(): 

2119 # Create a client 

2120 client = logging_v2.ConfigServiceV2Client() 

2121 

2122 # Initialize request argument(s) 

2123 sink = logging_v2.LogSink() 

2124 sink.name = "name_value" 

2125 sink.destination = "destination_value" 

2126 

2127 request = logging_v2.UpdateSinkRequest( 

2128 sink_name="sink_name_value", 

2129 sink=sink, 

2130 ) 

2131 

2132 # Make the request 

2133 response = client.update_sink(request=request) 

2134 

2135 # Handle the response 

2136 print(response) 

2137 

2138 Args: 

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

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

2141 sink_name (str): 

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

2143 including the parent resource and the sink identifier: 

2144 

2145 :: 

2146 

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

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

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

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

2151 

2152 For example: 

2153 

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

2155 

2156 This corresponds to the ``sink_name`` field 

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

2158 should not be set. 

2159 sink (google.cloud.logging_v2.types.LogSink): 

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

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

2162 

2163 This corresponds to the ``sink`` field 

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

2165 should not be set. 

2166 update_mask (google.protobuf.field_mask_pb2.FieldMask): 

2167 Optional. Field mask that specifies the fields in 

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

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

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

2171 

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

2173 the following mask for backwards compatibility purposes: 

2174 

2175 ``destination,filter,includeChildren`` 

2176 

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

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

2179 

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

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

2182 

2183 For example: ``updateMask=filter`` 

2184 

2185 This corresponds to the ``update_mask`` field 

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

2187 should not be set. 

2188 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

2189 should be retried. 

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

2191 metadata (Sequence[Tuple[str, str]]): Strings which should be 

2192 sent along with the request as metadata. 

2193 

2194 Returns: 

2195 google.cloud.logging_v2.types.LogSink: 

2196 Describes a sink used to export log 

2197 entries to one of the following 

2198 destinations in any project: a Cloud 

2199 Storage bucket, a BigQuery dataset, a 

2200 Pub/Sub topic or a Cloud Logging log 

2201 bucket. A logs filter controls which log 

2202 entries are exported. The sink must be 

2203 created within a project, organization, 

2204 billing account, or folder. 

2205 

2206 """ 

2207 # Create or coerce a protobuf request object. 

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

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

2210 has_flattened_params = any([sink_name, sink, update_mask]) 

2211 if request is not None and has_flattened_params: 

2212 raise ValueError( 

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

2214 "the individual field arguments should be set." 

2215 ) 

2216 

2217 # Minor optimization to avoid making a copy if the user passes 

2218 # in a logging_config.UpdateSinkRequest. 

2219 # There's no risk of modifying the input as we've already verified 

2220 # there are no flattened fields. 

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

2222 request = logging_config.UpdateSinkRequest(request) 

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

2224 # request, apply these. 

2225 if sink_name is not None: 

2226 request.sink_name = sink_name 

2227 if sink is not None: 

2228 request.sink = sink 

2229 if update_mask is not None: 

2230 request.update_mask = update_mask 

2231 

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

2233 # and friendly error handling. 

2234 rpc = self._transport._wrapped_methods[self._transport.update_sink] 

2235 

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

2237 # add these here. 

2238 metadata = tuple(metadata) + ( 

2239 gapic_v1.routing_header.to_grpc_metadata( 

2240 (("sink_name", request.sink_name),) 

2241 ), 

2242 ) 

2243 

2244 # Send the request. 

2245 response = rpc( 

2246 request, 

2247 retry=retry, 

2248 timeout=timeout, 

2249 metadata=metadata, 

2250 ) 

2251 

2252 # Done; return the response. 

2253 return response 

2254 

2255 def delete_sink( 

2256 self, 

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

2258 *, 

2259 sink_name: Optional[str] = None, 

2260 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

2262 metadata: Sequence[Tuple[str, str]] = (), 

2263 ) -> None: 

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

2265 then that service account is also deleted. 

2266 

2267 .. code-block:: python 

2268 

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

2270 # code template only. 

2271 # It will require modifications to work: 

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

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

2274 # client as shown in: 

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

2276 from google.cloud import logging_v2 

2277 

2278 def sample_delete_sink(): 

2279 # Create a client 

2280 client = logging_v2.ConfigServiceV2Client() 

2281 

2282 # Initialize request argument(s) 

2283 request = logging_v2.DeleteSinkRequest( 

2284 sink_name="sink_name_value", 

2285 ) 

2286 

2287 # Make the request 

2288 client.delete_sink(request=request) 

2289 

2290 Args: 

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

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

2293 sink_name (str): 

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

2295 including the parent resource and the sink identifier: 

2296 

2297 :: 

2298 

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

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

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

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

2303 

2304 For example: 

2305 

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

2307 

2308 This corresponds to the ``sink_name`` field 

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

2310 should not be set. 

2311 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

2312 should be retried. 

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

2314 metadata (Sequence[Tuple[str, str]]): Strings which should be 

2315 sent along with the request as metadata. 

2316 """ 

2317 # Create or coerce a protobuf request object. 

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

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

2320 has_flattened_params = any([sink_name]) 

2321 if request is not None and has_flattened_params: 

2322 raise ValueError( 

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

2324 "the individual field arguments should be set." 

2325 ) 

2326 

2327 # Minor optimization to avoid making a copy if the user passes 

2328 # in a logging_config.DeleteSinkRequest. 

2329 # There's no risk of modifying the input as we've already verified 

2330 # there are no flattened fields. 

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

2332 request = logging_config.DeleteSinkRequest(request) 

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

2334 # request, apply these. 

2335 if sink_name is not None: 

2336 request.sink_name = sink_name 

2337 

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

2339 # and friendly error handling. 

2340 rpc = self._transport._wrapped_methods[self._transport.delete_sink] 

2341 

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

2343 # add these here. 

2344 metadata = tuple(metadata) + ( 

2345 gapic_v1.routing_header.to_grpc_metadata( 

2346 (("sink_name", request.sink_name),) 

2347 ), 

2348 ) 

2349 

2350 # Send the request. 

2351 rpc( 

2352 request, 

2353 retry=retry, 

2354 timeout=timeout, 

2355 metadata=metadata, 

2356 ) 

2357 

2358 def create_link( 

2359 self, 

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

2361 *, 

2362 parent: Optional[str] = None, 

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

2364 link_id: Optional[str] = None, 

2365 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

2367 metadata: Sequence[Tuple[str, str]] = (), 

2368 ) -> operation.Operation: 

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

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

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

2372 only contain one link. 

2373 

2374 .. code-block:: python 

2375 

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

2377 # code template only. 

2378 # It will require modifications to work: 

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

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

2381 # client as shown in: 

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

2383 from google.cloud import logging_v2 

2384 

2385 def sample_create_link(): 

2386 # Create a client 

2387 client = logging_v2.ConfigServiceV2Client() 

2388 

2389 # Initialize request argument(s) 

2390 request = logging_v2.CreateLinkRequest( 

2391 parent="parent_value", 

2392 link_id="link_id_value", 

2393 ) 

2394 

2395 # Make the request 

2396 operation = client.create_link(request=request) 

2397 

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

2399 

2400 response = operation.result() 

2401 

2402 # Handle the response 

2403 print(response) 

2404 

2405 Args: 

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

2407 The request object. The parameters to CreateLink. 

2408 parent (str): 

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

2410 a link for. 

2411 

2412 :: 

2413 

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

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

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

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

2418 

2419 This corresponds to the ``parent`` field 

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

2421 should not be set. 

2422 link (google.cloud.logging_v2.types.Link): 

2423 Required. The new link. 

2424 This corresponds to the ``link`` field 

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

2426 should not be set. 

2427 link_id (str): 

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

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

2430 have alphanumeric characters and underscores within it. 

2431 

2432 This corresponds to the ``link_id`` field 

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

2434 should not be set. 

2435 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

2436 should be retried. 

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

2438 metadata (Sequence[Tuple[str, str]]): Strings which should be 

2439 sent along with the request as metadata. 

2440 

2441 Returns: 

2442 google.api_core.operation.Operation: 

2443 An object representing a long-running operation. 

2444 

2445 The result type for the operation will be 

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

2447 link connected to an analytics enabled bucket. 

2448 

2449 """ 

2450 # Create or coerce a protobuf request object. 

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

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

2453 has_flattened_params = any([parent, link, link_id]) 

2454 if request is not None and has_flattened_params: 

2455 raise ValueError( 

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

2457 "the individual field arguments should be set." 

2458 ) 

2459 

2460 # Minor optimization to avoid making a copy if the user passes 

2461 # in a logging_config.CreateLinkRequest. 

2462 # There's no risk of modifying the input as we've already verified 

2463 # there are no flattened fields. 

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

2465 request = logging_config.CreateLinkRequest(request) 

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

2467 # request, apply these. 

2468 if parent is not None: 

2469 request.parent = parent 

2470 if link is not None: 

2471 request.link = link 

2472 if link_id is not None: 

2473 request.link_id = link_id 

2474 

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

2476 # and friendly error handling. 

2477 rpc = self._transport._wrapped_methods[self._transport.create_link] 

2478 

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

2480 # add these here. 

2481 metadata = tuple(metadata) + ( 

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

2483 ) 

2484 

2485 # Send the request. 

2486 response = rpc( 

2487 request, 

2488 retry=retry, 

2489 timeout=timeout, 

2490 metadata=metadata, 

2491 ) 

2492 

2493 # Wrap the response in an operation future. 

2494 response = operation.from_gapic( 

2495 response, 

2496 self._transport.operations_client, 

2497 logging_config.Link, 

2498 metadata_type=logging_config.LinkMetadata, 

2499 ) 

2500 

2501 # Done; return the response. 

2502 return response 

2503 

2504 def delete_link( 

2505 self, 

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

2507 *, 

2508 name: Optional[str] = None, 

2509 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

2511 metadata: Sequence[Tuple[str, str]] = (), 

2512 ) -> operation.Operation: 

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

2514 corresponding BigQuery linked dataset. 

2515 

2516 .. code-block:: python 

2517 

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

2519 # code template only. 

2520 # It will require modifications to work: 

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

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

2523 # client as shown in: 

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

2525 from google.cloud import logging_v2 

2526 

2527 def sample_delete_link(): 

2528 # Create a client 

2529 client = logging_v2.ConfigServiceV2Client() 

2530 

2531 # Initialize request argument(s) 

2532 request = logging_v2.DeleteLinkRequest( 

2533 name="name_value", 

2534 ) 

2535 

2536 # Make the request 

2537 operation = client.delete_link(request=request) 

2538 

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

2540 

2541 response = operation.result() 

2542 

2543 # Handle the response 

2544 print(response) 

2545 

2546 Args: 

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

2548 The request object. The parameters to DeleteLink. 

2549 name (str): 

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

2551 

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

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

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

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

2556 

2557 This corresponds to the ``name`` field 

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

2559 should not be set. 

2560 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

2561 should be retried. 

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

2563 metadata (Sequence[Tuple[str, str]]): Strings which should be 

2564 sent along with the request as metadata. 

2565 

2566 Returns: 

2567 google.api_core.operation.Operation: 

2568 An object representing a long-running operation. 

2569 

2570 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 

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

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

2573 method. For instance: 

2574 

2575 service Foo { 

2576 rpc Bar(google.protobuf.Empty) returns 

2577 (google.protobuf.Empty); 

2578 

2579 } 

2580 

2581 """ 

2582 # Create or coerce a protobuf request object. 

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

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

2585 has_flattened_params = any([name]) 

2586 if request is not None and has_flattened_params: 

2587 raise ValueError( 

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

2589 "the individual field arguments should be set." 

2590 ) 

2591 

2592 # Minor optimization to avoid making a copy if the user passes 

2593 # in a logging_config.DeleteLinkRequest. 

2594 # There's no risk of modifying the input as we've already verified 

2595 # there are no flattened fields. 

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

2597 request = logging_config.DeleteLinkRequest(request) 

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

2599 # request, apply these. 

2600 if name is not None: 

2601 request.name = name 

2602 

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

2604 # and friendly error handling. 

2605 rpc = self._transport._wrapped_methods[self._transport.delete_link] 

2606 

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

2608 # add these here. 

2609 metadata = tuple(metadata) + ( 

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

2611 ) 

2612 

2613 # Send the request. 

2614 response = rpc( 

2615 request, 

2616 retry=retry, 

2617 timeout=timeout, 

2618 metadata=metadata, 

2619 ) 

2620 

2621 # Wrap the response in an operation future. 

2622 response = operation.from_gapic( 

2623 response, 

2624 self._transport.operations_client, 

2625 empty_pb2.Empty, 

2626 metadata_type=logging_config.LinkMetadata, 

2627 ) 

2628 

2629 # Done; return the response. 

2630 return response 

2631 

2632 def list_links( 

2633 self, 

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

2635 *, 

2636 parent: Optional[str] = None, 

2637 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

2639 metadata: Sequence[Tuple[str, str]] = (), 

2640 ) -> pagers.ListLinksPager: 

2641 r"""Lists links. 

2642 

2643 .. code-block:: python 

2644 

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

2646 # code template only. 

2647 # It will require modifications to work: 

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

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

2650 # client as shown in: 

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

2652 from google.cloud import logging_v2 

2653 

2654 def sample_list_links(): 

2655 # Create a client 

2656 client = logging_v2.ConfigServiceV2Client() 

2657 

2658 # Initialize request argument(s) 

2659 request = logging_v2.ListLinksRequest( 

2660 parent="parent_value", 

2661 ) 

2662 

2663 # Make the request 

2664 page_result = client.list_links(request=request) 

2665 

2666 # Handle the response 

2667 for response in page_result: 

2668 print(response) 

2669 

2670 Args: 

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

2672 The request object. The parameters to ListLinks. 

2673 parent (str): 

2674 Required. The parent resource whose links are to be 

2675 listed: 

2676 

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

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

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

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

2681 

2682 This corresponds to the ``parent`` field 

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

2684 should not be set. 

2685 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

2686 should be retried. 

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

2688 metadata (Sequence[Tuple[str, str]]): Strings which should be 

2689 sent along with the request as metadata. 

2690 

2691 Returns: 

2692 google.cloud.logging_v2.services.config_service_v2.pagers.ListLinksPager: 

2693 The response from ListLinks. 

2694 

2695 Iterating over this object will yield 

2696 results and resolve additional pages 

2697 automatically. 

2698 

2699 """ 

2700 # Create or coerce a protobuf request object. 

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

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

2703 has_flattened_params = any([parent]) 

2704 if request is not None and has_flattened_params: 

2705 raise ValueError( 

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

2707 "the individual field arguments should be set." 

2708 ) 

2709 

2710 # Minor optimization to avoid making a copy if the user passes 

2711 # in a logging_config.ListLinksRequest. 

2712 # There's no risk of modifying the input as we've already verified 

2713 # there are no flattened fields. 

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

2715 request = logging_config.ListLinksRequest(request) 

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

2717 # request, apply these. 

2718 if parent is not None: 

2719 request.parent = parent 

2720 

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

2722 # and friendly error handling. 

2723 rpc = self._transport._wrapped_methods[self._transport.list_links] 

2724 

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

2726 # add these here. 

2727 metadata = tuple(metadata) + ( 

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

2729 ) 

2730 

2731 # Send the request. 

2732 response = rpc( 

2733 request, 

2734 retry=retry, 

2735 timeout=timeout, 

2736 metadata=metadata, 

2737 ) 

2738 

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

2740 # an `__iter__` convenience method. 

2741 response = pagers.ListLinksPager( 

2742 method=rpc, 

2743 request=request, 

2744 response=response, 

2745 metadata=metadata, 

2746 ) 

2747 

2748 # Done; return the response. 

2749 return response 

2750 

2751 def get_link( 

2752 self, 

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

2754 *, 

2755 name: Optional[str] = None, 

2756 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

2758 metadata: Sequence[Tuple[str, str]] = (), 

2759 ) -> logging_config.Link: 

2760 r"""Gets a link. 

2761 

2762 .. code-block:: python 

2763 

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

2765 # code template only. 

2766 # It will require modifications to work: 

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

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

2769 # client as shown in: 

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

2771 from google.cloud import logging_v2 

2772 

2773 def sample_get_link(): 

2774 # Create a client 

2775 client = logging_v2.ConfigServiceV2Client() 

2776 

2777 # Initialize request argument(s) 

2778 request = logging_v2.GetLinkRequest( 

2779 name="name_value", 

2780 ) 

2781 

2782 # Make the request 

2783 response = client.get_link(request=request) 

2784 

2785 # Handle the response 

2786 print(response) 

2787 

2788 Args: 

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

2790 The request object. The parameters to GetLink. 

2791 name (str): 

2792 Required. The resource name of the link: 

2793 

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

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

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

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

2798 

2799 This corresponds to the ``name`` field 

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

2801 should not be set. 

2802 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

2803 should be retried. 

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

2805 metadata (Sequence[Tuple[str, str]]): Strings which should be 

2806 sent along with the request as metadata. 

2807 

2808 Returns: 

2809 google.cloud.logging_v2.types.Link: 

2810 Describes a link connected to an 

2811 analytics enabled bucket. 

2812 

2813 """ 

2814 # Create or coerce a protobuf request object. 

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

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

2817 has_flattened_params = any([name]) 

2818 if request is not None and has_flattened_params: 

2819 raise ValueError( 

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

2821 "the individual field arguments should be set." 

2822 ) 

2823 

2824 # Minor optimization to avoid making a copy if the user passes 

2825 # in a logging_config.GetLinkRequest. 

2826 # There's no risk of modifying the input as we've already verified 

2827 # there are no flattened fields. 

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

2829 request = logging_config.GetLinkRequest(request) 

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

2831 # request, apply these. 

2832 if name is not None: 

2833 request.name = name 

2834 

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

2836 # and friendly error handling. 

2837 rpc = self._transport._wrapped_methods[self._transport.get_link] 

2838 

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

2840 # add these here. 

2841 metadata = tuple(metadata) + ( 

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

2843 ) 

2844 

2845 # Send the request. 

2846 response = rpc( 

2847 request, 

2848 retry=retry, 

2849 timeout=timeout, 

2850 metadata=metadata, 

2851 ) 

2852 

2853 # Done; return the response. 

2854 return response 

2855 

2856 def list_exclusions( 

2857 self, 

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

2859 *, 

2860 parent: Optional[str] = None, 

2861 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

2863 metadata: Sequence[Tuple[str, str]] = (), 

2864 ) -> pagers.ListExclusionsPager: 

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

2866 resource. 

2867 

2868 .. code-block:: python 

2869 

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

2871 # code template only. 

2872 # It will require modifications to work: 

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

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

2875 # client as shown in: 

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

2877 from google.cloud import logging_v2 

2878 

2879 def sample_list_exclusions(): 

2880 # Create a client 

2881 client = logging_v2.ConfigServiceV2Client() 

2882 

2883 # Initialize request argument(s) 

2884 request = logging_v2.ListExclusionsRequest( 

2885 parent="parent_value", 

2886 ) 

2887 

2888 # Make the request 

2889 page_result = client.list_exclusions(request=request) 

2890 

2891 # Handle the response 

2892 for response in page_result: 

2893 print(response) 

2894 

2895 Args: 

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

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

2898 parent (str): 

2899 Required. The parent resource whose exclusions are to be 

2900 listed. 

2901 

2902 :: 

2903 

2904 "projects/[PROJECT_ID]" 

2905 "organizations/[ORGANIZATION_ID]" 

2906 "billingAccounts/[BILLING_ACCOUNT_ID]" 

2907 "folders/[FOLDER_ID]" 

2908 

2909 This corresponds to the ``parent`` field 

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

2911 should not be set. 

2912 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

2913 should be retried. 

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

2915 metadata (Sequence[Tuple[str, str]]): Strings which should be 

2916 sent along with the request as metadata. 

2917 

2918 Returns: 

2919 google.cloud.logging_v2.services.config_service_v2.pagers.ListExclusionsPager: 

2920 Result returned from ListExclusions. 

2921 

2922 Iterating over this object will yield results and 

2923 resolve additional pages automatically. 

2924 

2925 """ 

2926 # Create or coerce a protobuf request object. 

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

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

2929 has_flattened_params = any([parent]) 

2930 if request is not None and has_flattened_params: 

2931 raise ValueError( 

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

2933 "the individual field arguments should be set." 

2934 ) 

2935 

2936 # Minor optimization to avoid making a copy if the user passes 

2937 # in a logging_config.ListExclusionsRequest. 

2938 # There's no risk of modifying the input as we've already verified 

2939 # there are no flattened fields. 

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

2941 request = logging_config.ListExclusionsRequest(request) 

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

2943 # request, apply these. 

2944 if parent is not None: 

2945 request.parent = parent 

2946 

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

2948 # and friendly error handling. 

2949 rpc = self._transport._wrapped_methods[self._transport.list_exclusions] 

2950 

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

2952 # add these here. 

2953 metadata = tuple(metadata) + ( 

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

2955 ) 

2956 

2957 # Send the request. 

2958 response = rpc( 

2959 request, 

2960 retry=retry, 

2961 timeout=timeout, 

2962 metadata=metadata, 

2963 ) 

2964 

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

2966 # an `__iter__` convenience method. 

2967 response = pagers.ListExclusionsPager( 

2968 method=rpc, 

2969 request=request, 

2970 response=response, 

2971 metadata=metadata, 

2972 ) 

2973 

2974 # Done; return the response. 

2975 return response 

2976 

2977 def get_exclusion( 

2978 self, 

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

2980 *, 

2981 name: Optional[str] = None, 

2982 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

2984 metadata: Sequence[Tuple[str, str]] = (), 

2985 ) -> logging_config.LogExclusion: 

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

2987 

2988 .. code-block:: python 

2989 

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

2991 # code template only. 

2992 # It will require modifications to work: 

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

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

2995 # client as shown in: 

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

2997 from google.cloud import logging_v2 

2998 

2999 def sample_get_exclusion(): 

3000 # Create a client 

3001 client = logging_v2.ConfigServiceV2Client() 

3002 

3003 # Initialize request argument(s) 

3004 request = logging_v2.GetExclusionRequest( 

3005 name="name_value", 

3006 ) 

3007 

3008 # Make the request 

3009 response = client.get_exclusion(request=request) 

3010 

3011 # Handle the response 

3012 print(response) 

3013 

3014 Args: 

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

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

3017 name (str): 

3018 Required. The resource name of an existing exclusion: 

3019 

3020 :: 

3021 

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

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

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

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

3026 

3027 For example: 

3028 

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

3030 

3031 This corresponds to the ``name`` field 

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

3033 should not be set. 

3034 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

3035 should be retried. 

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

3037 metadata (Sequence[Tuple[str, str]]): Strings which should be 

3038 sent along with the request as metadata. 

3039 

3040 Returns: 

3041 google.cloud.logging_v2.types.LogExclusion: 

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

3043 your Google Cloud resource receives a large volume of 

3044 log entries, you can use exclusions to reduce your 

3045 chargeable logs. Note that exclusions on 

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

3047 to child resources. Note also that you cannot modify 

3048 the \_Required sink or exclude logs from it. 

3049 

3050 """ 

3051 # Create or coerce a protobuf request object. 

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

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

3054 has_flattened_params = any([name]) 

3055 if request is not None and has_flattened_params: 

3056 raise ValueError( 

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

3058 "the individual field arguments should be set." 

3059 ) 

3060 

3061 # Minor optimization to avoid making a copy if the user passes 

3062 # in a logging_config.GetExclusionRequest. 

3063 # There's no risk of modifying the input as we've already verified 

3064 # there are no flattened fields. 

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

3066 request = logging_config.GetExclusionRequest(request) 

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

3068 # request, apply these. 

3069 if name is not None: 

3070 request.name = name 

3071 

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

3073 # and friendly error handling. 

3074 rpc = self._transport._wrapped_methods[self._transport.get_exclusion] 

3075 

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

3077 # add these here. 

3078 metadata = tuple(metadata) + ( 

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

3080 ) 

3081 

3082 # Send the request. 

3083 response = rpc( 

3084 request, 

3085 retry=retry, 

3086 timeout=timeout, 

3087 metadata=metadata, 

3088 ) 

3089 

3090 # Done; return the response. 

3091 return response 

3092 

3093 def create_exclusion( 

3094 self, 

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

3096 *, 

3097 parent: Optional[str] = None, 

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

3099 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

3101 metadata: Sequence[Tuple[str, str]] = (), 

3102 ) -> logging_config.LogExclusion: 

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

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

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

3106 

3107 .. code-block:: python 

3108 

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

3110 # code template only. 

3111 # It will require modifications to work: 

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

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

3114 # client as shown in: 

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

3116 from google.cloud import logging_v2 

3117 

3118 def sample_create_exclusion(): 

3119 # Create a client 

3120 client = logging_v2.ConfigServiceV2Client() 

3121 

3122 # Initialize request argument(s) 

3123 exclusion = logging_v2.LogExclusion() 

3124 exclusion.name = "name_value" 

3125 exclusion.filter = "filter_value" 

3126 

3127 request = logging_v2.CreateExclusionRequest( 

3128 parent="parent_value", 

3129 exclusion=exclusion, 

3130 ) 

3131 

3132 # Make the request 

3133 response = client.create_exclusion(request=request) 

3134 

3135 # Handle the response 

3136 print(response) 

3137 

3138 Args: 

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

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

3141 parent (str): 

3142 Required. The parent resource in which to create the 

3143 exclusion: 

3144 

3145 :: 

3146 

3147 "projects/[PROJECT_ID]" 

3148 "organizations/[ORGANIZATION_ID]" 

3149 "billingAccounts/[BILLING_ACCOUNT_ID]" 

3150 "folders/[FOLDER_ID]" 

3151 

3152 For examples: 

3153 

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

3155 ``"organizations/123456789"`` 

3156 

3157 This corresponds to the ``parent`` field 

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

3159 should not be set. 

3160 exclusion (google.cloud.logging_v2.types.LogExclusion): 

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

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

3163 resource. 

3164 

3165 This corresponds to the ``exclusion`` field 

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

3167 should not be set. 

3168 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

3169 should be retried. 

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

3171 metadata (Sequence[Tuple[str, str]]): Strings which should be 

3172 sent along with the request as metadata. 

3173 

3174 Returns: 

3175 google.cloud.logging_v2.types.LogExclusion: 

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

3177 your Google Cloud resource receives a large volume of 

3178 log entries, you can use exclusions to reduce your 

3179 chargeable logs. Note that exclusions on 

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

3181 to child resources. Note also that you cannot modify 

3182 the \_Required sink or exclude logs from it. 

3183 

3184 """ 

3185 # Create or coerce a protobuf request object. 

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

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

3188 has_flattened_params = any([parent, exclusion]) 

3189 if request is not None and has_flattened_params: 

3190 raise ValueError( 

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

3192 "the individual field arguments should be set." 

3193 ) 

3194 

3195 # Minor optimization to avoid making a copy if the user passes 

3196 # in a logging_config.CreateExclusionRequest. 

3197 # There's no risk of modifying the input as we've already verified 

3198 # there are no flattened fields. 

3199 if not isinstance(request, logging_config.CreateExclusionRequest): 

3200 request = logging_config.CreateExclusionRequest(request) 

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

3202 # request, apply these. 

3203 if parent is not None: 

3204 request.parent = parent 

3205 if exclusion is not None: 

3206 request.exclusion = exclusion 

3207 

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

3209 # and friendly error handling. 

3210 rpc = self._transport._wrapped_methods[self._transport.create_exclusion] 

3211 

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

3213 # add these here. 

3214 metadata = tuple(metadata) + ( 

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

3216 ) 

3217 

3218 # Send the request. 

3219 response = rpc( 

3220 request, 

3221 retry=retry, 

3222 timeout=timeout, 

3223 metadata=metadata, 

3224 ) 

3225 

3226 # Done; return the response. 

3227 return response 

3228 

3229 def update_exclusion( 

3230 self, 

3231 request: Optional[Union[logging_config.UpdateExclusionRequest, dict]] = None, 

3232 *, 

3233 name: Optional[str] = None, 

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

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

3236 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

3238 metadata: Sequence[Tuple[str, str]] = (), 

3239 ) -> logging_config.LogExclusion: 

3240 r"""Changes one or more properties of an existing exclusion in the 

3241 \_Default sink. 

3242 

3243 .. code-block:: python 

3244 

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

3246 # code template only. 

3247 # It will require modifications to work: 

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

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

3250 # client as shown in: 

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

3252 from google.cloud import logging_v2 

3253 

3254 def sample_update_exclusion(): 

3255 # Create a client 

3256 client = logging_v2.ConfigServiceV2Client() 

3257 

3258 # Initialize request argument(s) 

3259 exclusion = logging_v2.LogExclusion() 

3260 exclusion.name = "name_value" 

3261 exclusion.filter = "filter_value" 

3262 

3263 request = logging_v2.UpdateExclusionRequest( 

3264 name="name_value", 

3265 exclusion=exclusion, 

3266 ) 

3267 

3268 # Make the request 

3269 response = client.update_exclusion(request=request) 

3270 

3271 # Handle the response 

3272 print(response) 

3273 

3274 Args: 

3275 request (Union[google.cloud.logging_v2.types.UpdateExclusionRequest, dict]): 

3276 The request object. The parameters to ``UpdateExclusion``. 

3277 name (str): 

3278 Required. The resource name of the exclusion to update: 

3279 

3280 :: 

3281 

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

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

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

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

3286 

3287 For example: 

3288 

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

3290 

3291 This corresponds to the ``name`` field 

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

3293 should not be set. 

3294 exclusion (google.cloud.logging_v2.types.LogExclusion): 

3295 Required. New values for the existing exclusion. Only 

3296 the fields specified in ``update_mask`` are relevant. 

3297 

3298 This corresponds to the ``exclusion`` field 

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

3300 should not be set. 

3301 update_mask (google.protobuf.field_mask_pb2.FieldMask): 

3302 Required. A non-empty list of fields to change in the 

3303 existing exclusion. New values for the fields are taken 

3304 from the corresponding fields in the 

3305 [LogExclusion][google.logging.v2.LogExclusion] included 

3306 in this request. Fields not mentioned in ``update_mask`` 

3307 are not changed and are ignored in the request. 

3308 

3309 For example, to change the filter and description of an 

3310 exclusion, specify an ``update_mask`` of 

3311 ``"filter,description"``. 

3312 

3313 This corresponds to the ``update_mask`` field 

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

3315 should not be set. 

3316 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

3317 should be retried. 

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

3319 metadata (Sequence[Tuple[str, str]]): Strings which should be 

3320 sent along with the request as metadata. 

3321 

3322 Returns: 

3323 google.cloud.logging_v2.types.LogExclusion: 

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

3325 your Google Cloud resource receives a large volume of 

3326 log entries, you can use exclusions to reduce your 

3327 chargeable logs. Note that exclusions on 

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

3329 to child resources. Note also that you cannot modify 

3330 the \_Required sink or exclude logs from it. 

3331 

3332 """ 

3333 # Create or coerce a protobuf request object. 

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

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

3336 has_flattened_params = any([name, exclusion, update_mask]) 

3337 if request is not None and has_flattened_params: 

3338 raise ValueError( 

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

3340 "the individual field arguments should be set." 

3341 ) 

3342 

3343 # Minor optimization to avoid making a copy if the user passes 

3344 # in a logging_config.UpdateExclusionRequest. 

3345 # There's no risk of modifying the input as we've already verified 

3346 # there are no flattened fields. 

3347 if not isinstance(request, logging_config.UpdateExclusionRequest): 

3348 request = logging_config.UpdateExclusionRequest(request) 

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

3350 # request, apply these. 

3351 if name is not None: 

3352 request.name = name 

3353 if exclusion is not None: 

3354 request.exclusion = exclusion 

3355 if update_mask is not None: 

3356 request.update_mask = update_mask 

3357 

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

3359 # and friendly error handling. 

3360 rpc = self._transport._wrapped_methods[self._transport.update_exclusion] 

3361 

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

3363 # add these here. 

3364 metadata = tuple(metadata) + ( 

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

3366 ) 

3367 

3368 # Send the request. 

3369 response = rpc( 

3370 request, 

3371 retry=retry, 

3372 timeout=timeout, 

3373 metadata=metadata, 

3374 ) 

3375 

3376 # Done; return the response. 

3377 return response 

3378 

3379 def delete_exclusion( 

3380 self, 

3381 request: Optional[Union[logging_config.DeleteExclusionRequest, dict]] = None, 

3382 *, 

3383 name: Optional[str] = None, 

3384 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

3386 metadata: Sequence[Tuple[str, str]] = (), 

3387 ) -> None: 

3388 r"""Deletes an exclusion in the \_Default sink. 

3389 

3390 .. code-block:: python 

3391 

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

3393 # code template only. 

3394 # It will require modifications to work: 

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

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

3397 # client as shown in: 

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

3399 from google.cloud import logging_v2 

3400 

3401 def sample_delete_exclusion(): 

3402 # Create a client 

3403 client = logging_v2.ConfigServiceV2Client() 

3404 

3405 # Initialize request argument(s) 

3406 request = logging_v2.DeleteExclusionRequest( 

3407 name="name_value", 

3408 ) 

3409 

3410 # Make the request 

3411 client.delete_exclusion(request=request) 

3412 

3413 Args: 

3414 request (Union[google.cloud.logging_v2.types.DeleteExclusionRequest, dict]): 

3415 The request object. The parameters to ``DeleteExclusion``. 

3416 name (str): 

3417 Required. The resource name of an existing exclusion to 

3418 delete: 

3419 

3420 :: 

3421 

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

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

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

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

3426 

3427 For example: 

3428 

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

3430 

3431 This corresponds to the ``name`` field 

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

3433 should not be set. 

3434 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

3435 should be retried. 

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

3437 metadata (Sequence[Tuple[str, str]]): Strings which should be 

3438 sent along with the request as metadata. 

3439 """ 

3440 # Create or coerce a protobuf request object. 

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

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

3443 has_flattened_params = any([name]) 

3444 if request is not None and has_flattened_params: 

3445 raise ValueError( 

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

3447 "the individual field arguments should be set." 

3448 ) 

3449 

3450 # Minor optimization to avoid making a copy if the user passes 

3451 # in a logging_config.DeleteExclusionRequest. 

3452 # There's no risk of modifying the input as we've already verified 

3453 # there are no flattened fields. 

3454 if not isinstance(request, logging_config.DeleteExclusionRequest): 

3455 request = logging_config.DeleteExclusionRequest(request) 

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

3457 # request, apply these. 

3458 if name is not None: 

3459 request.name = name 

3460 

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

3462 # and friendly error handling. 

3463 rpc = self._transport._wrapped_methods[self._transport.delete_exclusion] 

3464 

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

3466 # add these here. 

3467 metadata = tuple(metadata) + ( 

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

3469 ) 

3470 

3471 # Send the request. 

3472 rpc( 

3473 request, 

3474 retry=retry, 

3475 timeout=timeout, 

3476 metadata=metadata, 

3477 ) 

3478 

3479 def get_cmek_settings( 

3480 self, 

3481 request: Optional[Union[logging_config.GetCmekSettingsRequest, dict]] = None, 

3482 *, 

3483 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

3485 metadata: Sequence[Tuple[str, str]] = (), 

3486 ) -> logging_config.CmekSettings: 

3487 r"""Gets the Logging CMEK settings for the given resource. 

3488 

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

3490 projects, folders, organizations and billing accounts. Once 

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

3492 folders in the Google Cloud organization. 

3493 

3494 See `Enabling CMEK for Log 

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

3496 for more information. 

3497 

3498 .. code-block:: python 

3499 

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

3501 # code template only. 

3502 # It will require modifications to work: 

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

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

3505 # client as shown in: 

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

3507 from google.cloud import logging_v2 

3508 

3509 def sample_get_cmek_settings(): 

3510 # Create a client 

3511 client = logging_v2.ConfigServiceV2Client() 

3512 

3513 # Initialize request argument(s) 

3514 request = logging_v2.GetCmekSettingsRequest( 

3515 name="name_value", 

3516 ) 

3517 

3518 # Make the request 

3519 response = client.get_cmek_settings(request=request) 

3520 

3521 # Handle the response 

3522 print(response) 

3523 

3524 Args: 

3525 request (Union[google.cloud.logging_v2.types.GetCmekSettingsRequest, dict]): 

3526 The request object. The parameters to 

3527 [GetCmekSettings][google.logging.v2.ConfigServiceV2.GetCmekSettings]. 

3528 

3529 See `Enabling CMEK for Log 

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

3531 for more information. 

3532 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

3533 should be retried. 

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

3535 metadata (Sequence[Tuple[str, str]]): Strings which should be 

3536 sent along with the request as metadata. 

3537 

3538 Returns: 

3539 google.cloud.logging_v2.types.CmekSettings: 

3540 Describes the customer-managed encryption key (CMEK) settings associated with 

3541 a project, folder, organization, billing account, or 

3542 flexible resource. 

3543 

3544 Note: CMEK for the Log Router can currently only be 

3545 configured for Google Cloud organizations. Once 

3546 configured, it applies to all projects and folders in 

3547 the Google Cloud organization. 

3548 

3549 See [Enabling CMEK for Log 

3550 Router](\ https://cloud.google.com/logging/docs/routing/managed-encryption) 

3551 for more information. 

3552 

3553 """ 

3554 # Create or coerce a protobuf request object. 

3555 # Minor optimization to avoid making a copy if the user passes 

3556 # in a logging_config.GetCmekSettingsRequest. 

3557 # There's no risk of modifying the input as we've already verified 

3558 # there are no flattened fields. 

3559 if not isinstance(request, logging_config.GetCmekSettingsRequest): 

3560 request = logging_config.GetCmekSettingsRequest(request) 

3561 

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

3563 # and friendly error handling. 

3564 rpc = self._transport._wrapped_methods[self._transport.get_cmek_settings] 

3565 

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

3567 # add these here. 

3568 metadata = tuple(metadata) + ( 

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

3570 ) 

3571 

3572 # Send the request. 

3573 response = rpc( 

3574 request, 

3575 retry=retry, 

3576 timeout=timeout, 

3577 metadata=metadata, 

3578 ) 

3579 

3580 # Done; return the response. 

3581 return response 

3582 

3583 def update_cmek_settings( 

3584 self, 

3585 request: Optional[Union[logging_config.UpdateCmekSettingsRequest, dict]] = None, 

3586 *, 

3587 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

3589 metadata: Sequence[Tuple[str, str]] = (), 

3590 ) -> logging_config.CmekSettings: 

3591 r"""Updates the Log Router CMEK settings for the given resource. 

3592 

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

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

3595 all projects and folders in the Google Cloud organization. 

3596 

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

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

3599 associated service account does not have the required 

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

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

3602 

3603 See `Enabling CMEK for Log 

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

3605 for more information. 

3606 

3607 .. code-block:: python 

3608 

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

3610 # code template only. 

3611 # It will require modifications to work: 

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

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

3614 # client as shown in: 

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

3616 from google.cloud import logging_v2 

3617 

3618 def sample_update_cmek_settings(): 

3619 # Create a client 

3620 client = logging_v2.ConfigServiceV2Client() 

3621 

3622 # Initialize request argument(s) 

3623 request = logging_v2.UpdateCmekSettingsRequest( 

3624 name="name_value", 

3625 ) 

3626 

3627 # Make the request 

3628 response = client.update_cmek_settings(request=request) 

3629 

3630 # Handle the response 

3631 print(response) 

3632 

3633 Args: 

3634 request (Union[google.cloud.logging_v2.types.UpdateCmekSettingsRequest, dict]): 

3635 The request object. The parameters to 

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

3637 

3638 See `Enabling CMEK for Log 

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

3640 for more information. 

3641 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

3642 should be retried. 

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

3644 metadata (Sequence[Tuple[str, str]]): Strings which should be 

3645 sent along with the request as metadata. 

3646 

3647 Returns: 

3648 google.cloud.logging_v2.types.CmekSettings: 

3649 Describes the customer-managed encryption key (CMEK) settings associated with 

3650 a project, folder, organization, billing account, or 

3651 flexible resource. 

3652 

3653 Note: CMEK for the Log Router can currently only be 

3654 configured for Google Cloud organizations. Once 

3655 configured, it applies to all projects and folders in 

3656 the Google Cloud organization. 

3657 

3658 See [Enabling CMEK for Log 

3659 Router](\ https://cloud.google.com/logging/docs/routing/managed-encryption) 

3660 for more information. 

3661 

3662 """ 

3663 # Create or coerce a protobuf request object. 

3664 # Minor optimization to avoid making a copy if the user passes 

3665 # in a logging_config.UpdateCmekSettingsRequest. 

3666 # There's no risk of modifying the input as we've already verified 

3667 # there are no flattened fields. 

3668 if not isinstance(request, logging_config.UpdateCmekSettingsRequest): 

3669 request = logging_config.UpdateCmekSettingsRequest(request) 

3670 

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

3672 # and friendly error handling. 

3673 rpc = self._transport._wrapped_methods[self._transport.update_cmek_settings] 

3674 

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

3676 # add these here. 

3677 metadata = tuple(metadata) + ( 

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

3679 ) 

3680 

3681 # Send the request. 

3682 response = rpc( 

3683 request, 

3684 retry=retry, 

3685 timeout=timeout, 

3686 metadata=metadata, 

3687 ) 

3688 

3689 # Done; return the response. 

3690 return response 

3691 

3692 def get_settings( 

3693 self, 

3694 request: Optional[Union[logging_config.GetSettingsRequest, dict]] = None, 

3695 *, 

3696 name: Optional[str] = None, 

3697 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

3699 metadata: Sequence[Tuple[str, str]] = (), 

3700 ) -> logging_config.Settings: 

3701 r"""Gets the Log Router settings for the given resource. 

3702 

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

3704 projects, folders, organizations and billing accounts. Currently 

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

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

3707 Google Cloud organization. 

3708 

3709 See `Enabling CMEK for Log 

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

3711 for more information. 

3712 

3713 .. code-block:: python 

3714 

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

3716 # code template only. 

3717 # It will require modifications to work: 

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

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

3720 # client as shown in: 

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

3722 from google.cloud import logging_v2 

3723 

3724 def sample_get_settings(): 

3725 # Create a client 

3726 client = logging_v2.ConfigServiceV2Client() 

3727 

3728 # Initialize request argument(s) 

3729 request = logging_v2.GetSettingsRequest( 

3730 name="name_value", 

3731 ) 

3732 

3733 # Make the request 

3734 response = client.get_settings(request=request) 

3735 

3736 # Handle the response 

3737 print(response) 

3738 

3739 Args: 

3740 request (Union[google.cloud.logging_v2.types.GetSettingsRequest, dict]): 

3741 The request object. The parameters to 

3742 [GetSettings][google.logging.v2.ConfigServiceV2.GetSettings]. 

3743 

3744 See `Enabling CMEK for Log 

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

3746 for more information. 

3747 name (str): 

3748 Required. The resource for which to retrieve settings. 

3749 

3750 :: 

3751 

3752 "projects/[PROJECT_ID]/settings" 

3753 "organizations/[ORGANIZATION_ID]/settings" 

3754 "billingAccounts/[BILLING_ACCOUNT_ID]/settings" 

3755 "folders/[FOLDER_ID]/settings" 

3756 

3757 For example: 

3758 

3759 ``"organizations/12345/settings"`` 

3760 

3761 Note: Settings for the Log Router can be get for Google 

3762 Cloud projects, folders, organizations and billing 

3763 accounts. Currently it can only be configured for 

3764 organizations. Once configured for an organization, it 

3765 applies to all projects and folders in the Google Cloud 

3766 organization. 

3767 

3768 This corresponds to the ``name`` field 

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

3770 should not be set. 

3771 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

3772 should be retried. 

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

3774 metadata (Sequence[Tuple[str, str]]): Strings which should be 

3775 sent along with the request as metadata. 

3776 

3777 Returns: 

3778 google.cloud.logging_v2.types.Settings: 

3779 Describes the settings associated 

3780 with a project, folder, organization, 

3781 billing account, or flexible resource. 

3782 

3783 """ 

3784 # Create or coerce a protobuf request object. 

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

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

3787 has_flattened_params = any([name]) 

3788 if request is not None and has_flattened_params: 

3789 raise ValueError( 

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

3791 "the individual field arguments should be set." 

3792 ) 

3793 

3794 # Minor optimization to avoid making a copy if the user passes 

3795 # in a logging_config.GetSettingsRequest. 

3796 # There's no risk of modifying the input as we've already verified 

3797 # there are no flattened fields. 

3798 if not isinstance(request, logging_config.GetSettingsRequest): 

3799 request = logging_config.GetSettingsRequest(request) 

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

3801 # request, apply these. 

3802 if name is not None: 

3803 request.name = name 

3804 

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

3806 # and friendly error handling. 

3807 rpc = self._transport._wrapped_methods[self._transport.get_settings] 

3808 

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

3810 # add these here. 

3811 metadata = tuple(metadata) + ( 

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

3813 ) 

3814 

3815 # Send the request. 

3816 response = rpc( 

3817 request, 

3818 retry=retry, 

3819 timeout=timeout, 

3820 metadata=metadata, 

3821 ) 

3822 

3823 # Done; return the response. 

3824 return response 

3825 

3826 def update_settings( 

3827 self, 

3828 request: Optional[Union[logging_config.UpdateSettingsRequest, dict]] = None, 

3829 *, 

3830 settings: Optional[logging_config.Settings] = None, 

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

3832 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

3834 metadata: Sequence[Tuple[str, str]] = (), 

3835 ) -> logging_config.Settings: 

3836 r"""Updates the Log Router settings for the given resource. 

3837 

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

3839 configured for Google Cloud organizations. Once configured, it 

3840 applies to all projects and folders in the Google Cloud 

3841 organization. 

3842 

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

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

3845 associated service account does not have the required 

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

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

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

3849 OrgPolicy. 

3850 

3851 See `Enabling CMEK for Log 

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

3853 for more information. 

3854 

3855 .. code-block:: python 

3856 

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

3858 # code template only. 

3859 # It will require modifications to work: 

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

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

3862 # client as shown in: 

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

3864 from google.cloud import logging_v2 

3865 

3866 def sample_update_settings(): 

3867 # Create a client 

3868 client = logging_v2.ConfigServiceV2Client() 

3869 

3870 # Initialize request argument(s) 

3871 request = logging_v2.UpdateSettingsRequest( 

3872 name="name_value", 

3873 ) 

3874 

3875 # Make the request 

3876 response = client.update_settings(request=request) 

3877 

3878 # Handle the response 

3879 print(response) 

3880 

3881 Args: 

3882 request (Union[google.cloud.logging_v2.types.UpdateSettingsRequest, dict]): 

3883 The request object. The parameters to 

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

3885 

3886 See `Enabling CMEK for Log 

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

3888 for more information. 

3889 settings (google.cloud.logging_v2.types.Settings): 

3890 Required. The settings to update. 

3891 

3892 See `Enabling CMEK for Log 

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

3894 for more information. 

3895 

3896 This corresponds to the ``settings`` field 

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

3898 should not be set. 

3899 update_mask (google.protobuf.field_mask_pb2.FieldMask): 

3900 Optional. Field mask identifying which fields from 

3901 ``settings`` should be updated. A field will be 

3902 overwritten if and only if it is in the update mask. 

3903 Output only fields cannot be updated. 

3904 

3905 See [FieldMask][google.protobuf.FieldMask] for more 

3906 information. 

3907 

3908 For example: ``"updateMask=kmsKeyName"`` 

3909 

3910 This corresponds to the ``update_mask`` field 

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

3912 should not be set. 

3913 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

3914 should be retried. 

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

3916 metadata (Sequence[Tuple[str, str]]): Strings which should be 

3917 sent along with the request as metadata. 

3918 

3919 Returns: 

3920 google.cloud.logging_v2.types.Settings: 

3921 Describes the settings associated 

3922 with a project, folder, organization, 

3923 billing account, or flexible resource. 

3924 

3925 """ 

3926 # Create or coerce a protobuf request object. 

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

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

3929 has_flattened_params = any([settings, update_mask]) 

3930 if request is not None and has_flattened_params: 

3931 raise ValueError( 

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

3933 "the individual field arguments should be set." 

3934 ) 

3935 

3936 # Minor optimization to avoid making a copy if the user passes 

3937 # in a logging_config.UpdateSettingsRequest. 

3938 # There's no risk of modifying the input as we've already verified 

3939 # there are no flattened fields. 

3940 if not isinstance(request, logging_config.UpdateSettingsRequest): 

3941 request = logging_config.UpdateSettingsRequest(request) 

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

3943 # request, apply these. 

3944 if settings is not None: 

3945 request.settings = settings 

3946 if update_mask is not None: 

3947 request.update_mask = update_mask 

3948 

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

3950 # and friendly error handling. 

3951 rpc = self._transport._wrapped_methods[self._transport.update_settings] 

3952 

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

3954 # add these here. 

3955 metadata = tuple(metadata) + ( 

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

3957 ) 

3958 

3959 # Send the request. 

3960 response = rpc( 

3961 request, 

3962 retry=retry, 

3963 timeout=timeout, 

3964 metadata=metadata, 

3965 ) 

3966 

3967 # Done; return the response. 

3968 return response 

3969 

3970 def copy_log_entries( 

3971 self, 

3972 request: Optional[Union[logging_config.CopyLogEntriesRequest, dict]] = None, 

3973 *, 

3974 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

3976 metadata: Sequence[Tuple[str, str]] = (), 

3977 ) -> operation.Operation: 

3978 r"""Copies a set of log entries from a log bucket to a 

3979 Cloud Storage bucket. 

3980 

3981 .. code-block:: python 

3982 

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

3984 # code template only. 

3985 # It will require modifications to work: 

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

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

3988 # client as shown in: 

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

3990 from google.cloud import logging_v2 

3991 

3992 def sample_copy_log_entries(): 

3993 # Create a client 

3994 client = logging_v2.ConfigServiceV2Client() 

3995 

3996 # Initialize request argument(s) 

3997 request = logging_v2.CopyLogEntriesRequest( 

3998 name="name_value", 

3999 destination="destination_value", 

4000 ) 

4001 

4002 # Make the request 

4003 operation = client.copy_log_entries(request=request) 

4004 

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

4006 

4007 response = operation.result() 

4008 

4009 # Handle the response 

4010 print(response) 

4011 

4012 Args: 

4013 request (Union[google.cloud.logging_v2.types.CopyLogEntriesRequest, dict]): 

4014 The request object. The parameters to CopyLogEntries. 

4015 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

4016 should be retried. 

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

4018 metadata (Sequence[Tuple[str, str]]): Strings which should be 

4019 sent along with the request as metadata. 

4020 

4021 Returns: 

4022 google.api_core.operation.Operation: 

4023 An object representing a long-running operation. 

4024 

4025 The result type for the operation will be 

4026 :class:`google.cloud.logging_v2.types.CopyLogEntriesResponse` 

4027 Response type for CopyLogEntries long running 

4028 operations. 

4029 

4030 """ 

4031 # Create or coerce a protobuf request object. 

4032 # Minor optimization to avoid making a copy if the user passes 

4033 # in a logging_config.CopyLogEntriesRequest. 

4034 # There's no risk of modifying the input as we've already verified 

4035 # there are no flattened fields. 

4036 if not isinstance(request, logging_config.CopyLogEntriesRequest): 

4037 request = logging_config.CopyLogEntriesRequest(request) 

4038 

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

4040 # and friendly error handling. 

4041 rpc = self._transport._wrapped_methods[self._transport.copy_log_entries] 

4042 

4043 # Send the request. 

4044 response = rpc( 

4045 request, 

4046 retry=retry, 

4047 timeout=timeout, 

4048 metadata=metadata, 

4049 ) 

4050 

4051 # Wrap the response in an operation future. 

4052 response = operation.from_gapic( 

4053 response, 

4054 self._transport.operations_client, 

4055 logging_config.CopyLogEntriesResponse, 

4056 metadata_type=logging_config.CopyLogEntriesMetadata, 

4057 ) 

4058 

4059 # Done; return the response. 

4060 return response 

4061 

4062 def __enter__(self) -> "ConfigServiceV2Client": 

4063 return self 

4064 

4065 def __exit__(self, type, value, traceback): 

4066 """Releases underlying transport's resources. 

4067 

4068 .. warning:: 

4069 ONLY use as a context manager if the transport is NOT shared 

4070 with other clients! Exiting the with block will CLOSE the transport 

4071 and may cause errors in other clients! 

4072 """ 

4073 self.transport.close() 

4074 

4075 def list_operations( 

4076 self, 

4077 request: Optional[operations_pb2.ListOperationsRequest] = None, 

4078 *, 

4079 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

4081 metadata: Sequence[Tuple[str, str]] = (), 

4082 ) -> operations_pb2.ListOperationsResponse: 

4083 r"""Lists operations that match the specified filter in the request. 

4084 

4085 Args: 

4086 request (:class:`~.operations_pb2.ListOperationsRequest`): 

4087 The request object. Request message for 

4088 `ListOperations` method. 

4089 retry (google.api_core.retry.Retry): Designation of what errors, 

4090 if any, should be retried. 

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

4092 metadata (Sequence[Tuple[str, str]]): Strings which should be 

4093 sent along with the request as metadata. 

4094 Returns: 

4095 ~.operations_pb2.ListOperationsResponse: 

4096 Response message for ``ListOperations`` method. 

4097 """ 

4098 # Create or coerce a protobuf request object. 

4099 # The request isn't a proto-plus wrapped type, 

4100 # so it must be constructed via keyword expansion. 

4101 if isinstance(request, dict): 

4102 request = operations_pb2.ListOperationsRequest(**request) 

4103 

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

4105 # and friendly error handling. 

4106 rpc = gapic_v1.method.wrap_method( 

4107 self._transport.list_operations, 

4108 default_timeout=None, 

4109 client_info=DEFAULT_CLIENT_INFO, 

4110 ) 

4111 

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

4113 # add these here. 

4114 metadata = tuple(metadata) + ( 

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

4116 ) 

4117 

4118 # Send the request. 

4119 response = rpc( 

4120 request, 

4121 retry=retry, 

4122 timeout=timeout, 

4123 metadata=metadata, 

4124 ) 

4125 

4126 # Done; return the response. 

4127 return response 

4128 

4129 def get_operation( 

4130 self, 

4131 request: Optional[operations_pb2.GetOperationRequest] = None, 

4132 *, 

4133 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

4135 metadata: Sequence[Tuple[str, str]] = (), 

4136 ) -> operations_pb2.Operation: 

4137 r"""Gets the latest state of a long-running operation. 

4138 

4139 Args: 

4140 request (:class:`~.operations_pb2.GetOperationRequest`): 

4141 The request object. Request message for 

4142 `GetOperation` method. 

4143 retry (google.api_core.retry.Retry): Designation of what errors, 

4144 if any, should be retried. 

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

4146 metadata (Sequence[Tuple[str, str]]): Strings which should be 

4147 sent along with the request as metadata. 

4148 Returns: 

4149 ~.operations_pb2.Operation: 

4150 An ``Operation`` object. 

4151 """ 

4152 # Create or coerce a protobuf request object. 

4153 # The request isn't a proto-plus wrapped type, 

4154 # so it must be constructed via keyword expansion. 

4155 if isinstance(request, dict): 

4156 request = operations_pb2.GetOperationRequest(**request) 

4157 

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

4159 # and friendly error handling. 

4160 rpc = gapic_v1.method.wrap_method( 

4161 self._transport.get_operation, 

4162 default_timeout=None, 

4163 client_info=DEFAULT_CLIENT_INFO, 

4164 ) 

4165 

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

4167 # add these here. 

4168 metadata = tuple(metadata) + ( 

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

4170 ) 

4171 

4172 # Send the request. 

4173 response = rpc( 

4174 request, 

4175 retry=retry, 

4176 timeout=timeout, 

4177 metadata=metadata, 

4178 ) 

4179 

4180 # Done; return the response. 

4181 return response 

4182 

4183 def cancel_operation( 

4184 self, 

4185 request: Optional[operations_pb2.CancelOperationRequest] = None, 

4186 *, 

4187 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

4189 metadata: Sequence[Tuple[str, str]] = (), 

4190 ) -> None: 

4191 r"""Starts asynchronous cancellation on a long-running operation. 

4192 

4193 The server makes a best effort to cancel the operation, but success 

4194 is not guaranteed. If the server doesn't support this method, it returns 

4195 `google.rpc.Code.UNIMPLEMENTED`. 

4196 

4197 Args: 

4198 request (:class:`~.operations_pb2.CancelOperationRequest`): 

4199 The request object. Request message for 

4200 `CancelOperation` method. 

4201 retry (google.api_core.retry.Retry): Designation of what errors, 

4202 if any, should be retried. 

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

4204 metadata (Sequence[Tuple[str, str]]): Strings which should be 

4205 sent along with the request as metadata. 

4206 Returns: 

4207 None 

4208 """ 

4209 # Create or coerce a protobuf request object. 

4210 # The request isn't a proto-plus wrapped type, 

4211 # so it must be constructed via keyword expansion. 

4212 if isinstance(request, dict): 

4213 request = operations_pb2.CancelOperationRequest(**request) 

4214 

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

4216 # and friendly error handling. 

4217 rpc = gapic_v1.method.wrap_method( 

4218 self._transport.cancel_operation, 

4219 default_timeout=None, 

4220 client_info=DEFAULT_CLIENT_INFO, 

4221 ) 

4222 

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

4224 # add these here. 

4225 metadata = tuple(metadata) + ( 

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

4227 ) 

4228 

4229 # Send the request. 

4230 rpc( 

4231 request, 

4232 retry=retry, 

4233 timeout=timeout, 

4234 metadata=metadata, 

4235 ) 

4236 

4237 

4238DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( 

4239 gapic_version=package_version.__version__ 

4240) 

4241 

4242 

4243__all__ = ("ConfigServiceV2Client",)