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

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

694 statements  

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

2# Copyright 2025 Google LLC 

3# 

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

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

6# You may obtain a copy of the License at 

7# 

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

9# 

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

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

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

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

14# limitations under the License. 

15# 

16from collections import OrderedDict 

17from http import HTTPStatus 

18import json 

19import logging as std_logging 

20import os 

21import re 

22from typing import ( 

23 Dict, 

24 Callable, 

25 Mapping, 

26 MutableMapping, 

27 MutableSequence, 

28 Optional, 

29 Sequence, 

30 Tuple, 

31 Type, 

32 Union, 

33 cast, 

34) 

35import warnings 

36 

37from google.cloud.logging_v2 import gapic_version as package_version 

38 

39from google.api_core import client_options as client_options_lib 

40from google.api_core import exceptions as core_exceptions 

41from google.api_core import gapic_v1 

42from google.api_core import retry as retries 

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

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

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

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

47from google.oauth2 import service_account # type: ignore 

48import google.protobuf 

49 

50try: 

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

52except AttributeError: # pragma: NO COVER 

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

54 

55try: 

56 from google.api_core import client_logging # type: ignore 

57 

58 CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER 

59except ImportError: # pragma: NO COVER 

60 CLIENT_LOGGING_SUPPORTED = False 

61 

62_LOGGER = std_logging.getLogger(__name__) 

63 

64from google.api_core import operation # type: ignore 

65from google.api_core import operation_async # type: ignore 

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

67from google.cloud.logging_v2.types import logging_config 

68from google.longrunning import operations_pb2 # type: ignore 

69from google.protobuf import empty_pb2 # type: ignore 

70from google.protobuf import field_mask_pb2 # type: ignore 

71from google.protobuf import timestamp_pb2 # type: ignore 

72from .transports.base import ConfigServiceV2Transport, DEFAULT_CLIENT_INFO 

73from .transports.grpc import ConfigServiceV2GrpcTransport 

74from .transports.grpc_asyncio import ConfigServiceV2GrpcAsyncIOTransport 

75 

76 

77class ConfigServiceV2ClientMeta(type): 

78 """Metaclass for the ConfigServiceV2 client. 

79 

80 This provides class-level methods for building and retrieving 

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

82 objects. 

83 """ 

84 

85 _transport_registry = ( 

86 OrderedDict() 

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

88 _transport_registry["grpc"] = ConfigServiceV2GrpcTransport 

89 _transport_registry["grpc_asyncio"] = ConfigServiceV2GrpcAsyncIOTransport 

90 

91 def get_transport_class( 

92 cls, 

93 label: Optional[str] = None, 

94 ) -> Type[ConfigServiceV2Transport]: 

95 """Returns an appropriate transport class. 

96 

97 Args: 

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

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

100 

101 Returns: 

102 The transport class to use. 

103 """ 

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

105 if label: 

106 return cls._transport_registry[label] 

107 

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

109 # in the dictionary). 

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

111 

112 

113class ConfigServiceV2Client(metaclass=ConfigServiceV2ClientMeta): 

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

115 

116 @staticmethod 

117 def _get_default_mtls_endpoint(api_endpoint): 

118 """Converts api endpoint to mTLS endpoint. 

119 

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

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

122 Args: 

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

124 Returns: 

125 str: converted mTLS api endpoint. 

126 """ 

127 if not api_endpoint: 

128 return api_endpoint 

129 

130 mtls_endpoint_re = re.compile( 

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

132 ) 

133 

134 m = mtls_endpoint_re.match(api_endpoint) 

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

136 if mtls or not googledomain: 

137 return api_endpoint 

138 

139 if sandbox: 

140 return api_endpoint.replace( 

141 "sandbox.googleapis.com", "mtls.sandbox.googleapis.com" 

142 ) 

143 

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

145 

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

147 DEFAULT_ENDPOINT = "logging.googleapis.com" 

148 DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore 

149 DEFAULT_ENDPOINT 

150 ) 

151 

152 _DEFAULT_ENDPOINT_TEMPLATE = "logging.{UNIVERSE_DOMAIN}" 

153 _DEFAULT_UNIVERSE = "googleapis.com" 

154 

155 @classmethod 

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

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

158 info. 

159 

160 Args: 

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

162 args: Additional arguments to pass to the constructor. 

163 kwargs: Additional arguments to pass to the constructor. 

164 

165 Returns: 

166 ConfigServiceV2Client: The constructed client. 

167 """ 

168 credentials = service_account.Credentials.from_service_account_info(info) 

169 kwargs["credentials"] = credentials 

170 return cls(*args, **kwargs) 

171 

172 @classmethod 

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

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

175 file. 

176 

177 Args: 

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

179 file. 

180 args: Additional arguments to pass to the constructor. 

181 kwargs: Additional arguments to pass to the constructor. 

182 

183 Returns: 

184 ConfigServiceV2Client: The constructed client. 

185 """ 

186 credentials = service_account.Credentials.from_service_account_file(filename) 

187 kwargs["credentials"] = credentials 

188 return cls(*args, **kwargs) 

189 

190 from_service_account_json = from_service_account_file 

191 

192 @property 

193 def transport(self) -> ConfigServiceV2Transport: 

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

195 

196 Returns: 

197 ConfigServiceV2Transport: The transport used by the client 

198 instance. 

199 """ 

200 return self._transport 

201 

202 @staticmethod 

203 def cmek_settings_path( 

204 project: str, 

205 ) -> str: 

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

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

208 project=project, 

209 ) 

210 

211 @staticmethod 

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

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

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

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

216 

217 @staticmethod 

218 def link_path( 

219 project: str, 

220 location: str, 

221 bucket: str, 

222 link: str, 

223 ) -> str: 

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

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

226 project=project, 

227 location=location, 

228 bucket=bucket, 

229 link=link, 

230 ) 

231 

232 @staticmethod 

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

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

235 m = re.match( 

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

237 path, 

238 ) 

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

240 

241 @staticmethod 

242 def log_bucket_path( 

243 project: str, 

244 location: str, 

245 bucket: str, 

246 ) -> str: 

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

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

249 project=project, 

250 location=location, 

251 bucket=bucket, 

252 ) 

253 

254 @staticmethod 

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

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

257 m = re.match( 

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

259 path, 

260 ) 

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

262 

263 @staticmethod 

264 def log_exclusion_path( 

265 project: str, 

266 exclusion: str, 

267 ) -> str: 

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

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

270 project=project, 

271 exclusion=exclusion, 

272 ) 

273 

274 @staticmethod 

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

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

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

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

279 

280 @staticmethod 

281 def log_sink_path( 

282 project: str, 

283 sink: str, 

284 ) -> str: 

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

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

287 project=project, 

288 sink=sink, 

289 ) 

290 

291 @staticmethod 

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

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

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

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

296 

297 @staticmethod 

298 def log_view_path( 

299 project: str, 

300 location: str, 

301 bucket: str, 

302 view: str, 

303 ) -> str: 

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

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

306 project=project, 

307 location=location, 

308 bucket=bucket, 

309 view=view, 

310 ) 

311 

312 @staticmethod 

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

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

315 m = re.match( 

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

317 path, 

318 ) 

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

320 

321 @staticmethod 

322 def settings_path( 

323 project: str, 

324 ) -> str: 

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

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

327 project=project, 

328 ) 

329 

330 @staticmethod 

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

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

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

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

335 

336 @staticmethod 

337 def common_billing_account_path( 

338 billing_account: str, 

339 ) -> str: 

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

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

342 billing_account=billing_account, 

343 ) 

344 

345 @staticmethod 

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

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

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

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

350 

351 @staticmethod 

352 def common_folder_path( 

353 folder: str, 

354 ) -> str: 

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

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

357 folder=folder, 

358 ) 

359 

360 @staticmethod 

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

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

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

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

365 

366 @staticmethod 

367 def common_organization_path( 

368 organization: str, 

369 ) -> str: 

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

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

372 organization=organization, 

373 ) 

374 

375 @staticmethod 

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

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

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

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

380 

381 @staticmethod 

382 def common_project_path( 

383 project: str, 

384 ) -> str: 

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

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

387 project=project, 

388 ) 

389 

390 @staticmethod 

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

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

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

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

395 

396 @staticmethod 

397 def common_location_path( 

398 project: str, 

399 location: str, 

400 ) -> str: 

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

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

403 project=project, 

404 location=location, 

405 ) 

406 

407 @staticmethod 

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

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

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

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

412 

413 @classmethod 

414 def get_mtls_endpoint_and_cert_source( 

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

416 ): 

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

418 

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

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

421 client cert source is None. 

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

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

424 source is None. 

425 

426 The API endpoint is determined in the following order: 

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

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

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

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

431 use the default API endpoint. 

432 

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

434 

435 Args: 

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

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

438 in this method. 

439 

440 Returns: 

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

442 client cert source to use. 

443 

444 Raises: 

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

446 """ 

447 

448 warnings.warn( 

449 "get_mtls_endpoint_and_cert_source is deprecated. Use the api_endpoint property instead.", 

450 DeprecationWarning, 

451 ) 

452 if client_options is None: 

453 client_options = client_options_lib.ClientOptions() 

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

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

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

457 raise ValueError( 

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

459 ) 

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

461 raise MutualTLSChannelError( 

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

463 ) 

464 

465 # Figure out the client cert source to use. 

466 client_cert_source = None 

467 if use_client_cert == "true": 

468 if client_options.client_cert_source: 

469 client_cert_source = client_options.client_cert_source 

470 elif mtls.has_default_client_cert_source(): 

471 client_cert_source = mtls.default_client_cert_source() 

472 

473 # Figure out which api endpoint to use. 

474 if client_options.api_endpoint is not None: 

475 api_endpoint = client_options.api_endpoint 

476 elif use_mtls_endpoint == "always" or ( 

477 use_mtls_endpoint == "auto" and client_cert_source 

478 ): 

479 api_endpoint = cls.DEFAULT_MTLS_ENDPOINT 

480 else: 

481 api_endpoint = cls.DEFAULT_ENDPOINT 

482 

483 return api_endpoint, client_cert_source 

484 

485 @staticmethod 

486 def _read_environment_variables(): 

487 """Returns the environment variables used by the client. 

488 

489 Returns: 

490 Tuple[bool, str, str]: returns the GOOGLE_API_USE_CLIENT_CERTIFICATE, 

491 GOOGLE_API_USE_MTLS_ENDPOINT, and GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variables. 

492 

493 Raises: 

494 ValueError: If GOOGLE_API_USE_CLIENT_CERTIFICATE is not 

495 any of ["true", "false"]. 

496 google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT 

497 is not any of ["auto", "never", "always"]. 

498 """ 

499 use_client_cert = os.getenv( 

500 "GOOGLE_API_USE_CLIENT_CERTIFICATE", "false" 

501 ).lower() 

502 use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower() 

503 universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN") 

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

505 raise ValueError( 

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

507 ) 

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

509 raise MutualTLSChannelError( 

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

511 ) 

512 return use_client_cert == "true", use_mtls_endpoint, universe_domain_env 

513 

514 @staticmethod 

515 def _get_client_cert_source(provided_cert_source, use_cert_flag): 

516 """Return the client cert source to be used by the client. 

517 

518 Args: 

519 provided_cert_source (bytes): The client certificate source provided. 

520 use_cert_flag (bool): A flag indicating whether to use the client certificate. 

521 

522 Returns: 

523 bytes or None: The client cert source to be used by the client. 

524 """ 

525 client_cert_source = None 

526 if use_cert_flag: 

527 if provided_cert_source: 

528 client_cert_source = provided_cert_source 

529 elif mtls.has_default_client_cert_source(): 

530 client_cert_source = mtls.default_client_cert_source() 

531 return client_cert_source 

532 

533 @staticmethod 

534 def _get_api_endpoint( 

535 api_override, client_cert_source, universe_domain, use_mtls_endpoint 

536 ): 

537 """Return the API endpoint used by the client. 

538 

539 Args: 

540 api_override (str): The API endpoint override. If specified, this is always 

541 the return value of this function and the other arguments are not used. 

542 client_cert_source (bytes): The client certificate source used by the client. 

543 universe_domain (str): The universe domain used by the client. 

544 use_mtls_endpoint (str): How to use the mTLS endpoint, which depends also on the other parameters. 

545 Possible values are "always", "auto", or "never". 

546 

547 Returns: 

548 str: The API endpoint to be used by the client. 

549 """ 

550 if api_override is not None: 

551 api_endpoint = api_override 

552 elif use_mtls_endpoint == "always" or ( 

553 use_mtls_endpoint == "auto" and client_cert_source 

554 ): 

555 _default_universe = ConfigServiceV2Client._DEFAULT_UNIVERSE 

556 if universe_domain != _default_universe: 

557 raise MutualTLSChannelError( 

558 f"mTLS is not supported in any universe other than {_default_universe}." 

559 ) 

560 api_endpoint = ConfigServiceV2Client.DEFAULT_MTLS_ENDPOINT 

561 else: 

562 api_endpoint = ConfigServiceV2Client._DEFAULT_ENDPOINT_TEMPLATE.format( 

563 UNIVERSE_DOMAIN=universe_domain 

564 ) 

565 return api_endpoint 

566 

567 @staticmethod 

568 def _get_universe_domain( 

569 client_universe_domain: Optional[str], universe_domain_env: Optional[str] 

570 ) -> str: 

571 """Return the universe domain used by the client. 

572 

573 Args: 

574 client_universe_domain (Optional[str]): The universe domain configured via the client options. 

575 universe_domain_env (Optional[str]): The universe domain configured via the "GOOGLE_CLOUD_UNIVERSE_DOMAIN" environment variable. 

576 

577 Returns: 

578 str: The universe domain to be used by the client. 

579 

580 Raises: 

581 ValueError: If the universe domain is an empty string. 

582 """ 

583 universe_domain = ConfigServiceV2Client._DEFAULT_UNIVERSE 

584 if client_universe_domain is not None: 

585 universe_domain = client_universe_domain 

586 elif universe_domain_env is not None: 

587 universe_domain = universe_domain_env 

588 if len(universe_domain.strip()) == 0: 

589 raise ValueError("Universe Domain cannot be an empty string.") 

590 return universe_domain 

591 

592 def _validate_universe_domain(self): 

593 """Validates client's and credentials' universe domains are consistent. 

594 

595 Returns: 

596 bool: True iff the configured universe domain is valid. 

597 

598 Raises: 

599 ValueError: If the configured universe domain is not valid. 

600 """ 

601 

602 # NOTE (b/349488459): universe validation is disabled until further notice. 

603 return True 

604 

605 def _add_cred_info_for_auth_errors( 

606 self, error: core_exceptions.GoogleAPICallError 

607 ) -> None: 

608 """Adds credential info string to error details for 401/403/404 errors. 

609 

610 Args: 

611 error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info. 

612 """ 

613 if error.code not in [ 

614 HTTPStatus.UNAUTHORIZED, 

615 HTTPStatus.FORBIDDEN, 

616 HTTPStatus.NOT_FOUND, 

617 ]: 

618 return 

619 

620 cred = self._transport._credentials 

621 

622 # get_cred_info is only available in google-auth>=2.35.0 

623 if not hasattr(cred, "get_cred_info"): 

624 return 

625 

626 # ignore the type check since pypy test fails when get_cred_info 

627 # is not available 

628 cred_info = cred.get_cred_info() # type: ignore 

629 if cred_info and hasattr(error._details, "append"): 

630 error._details.append(json.dumps(cred_info)) 

631 

632 @property 

633 def api_endpoint(self): 

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

635 

636 Returns: 

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

638 """ 

639 return self._api_endpoint 

640 

641 @property 

642 def universe_domain(self) -> str: 

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

644 

645 Returns: 

646 str: The universe domain used by the client instance. 

647 """ 

648 return self._universe_domain 

649 

650 def __init__( 

651 self, 

652 *, 

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

654 transport: Optional[ 

655 Union[ 

656 str, ConfigServiceV2Transport, Callable[..., ConfigServiceV2Transport] 

657 ] 

658 ] = None, 

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

660 client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, 

661 ) -> None: 

662 """Instantiates the config service v2 client. 

663 

664 Args: 

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

666 authorization credentials to attach to requests. These 

667 credentials identify the application to the service; if none 

668 are specified, the client will attempt to ascertain the 

669 credentials from the environment. 

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

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

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

673 arguments as used in the ConfigServiceV2Transport constructor. 

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

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

676 Custom options for the client. 

677 

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

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

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

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

682 determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment 

683 variable, which have one of the following values: 

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

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

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

687 the default value). 

688 

689 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable 

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

691 to provide a client certificate for mTLS transport. If 

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

693 present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not 

694 set, no client certificate will be used. 

695 

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

697 default "googleapis.com" universe. Note that the ``api_endpoint`` 

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

699 currently not supported for mTLS. 

700 

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

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

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

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

705 your own client library. 

706 

707 Raises: 

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

709 creation failed for any reason. 

710 """ 

711 self._client_options = client_options 

712 if isinstance(self._client_options, dict): 

713 self._client_options = client_options_lib.from_dict(self._client_options) 

714 if self._client_options is None: 

715 self._client_options = client_options_lib.ClientOptions() 

716 self._client_options = cast( 

717 client_options_lib.ClientOptions, self._client_options 

718 ) 

719 

720 universe_domain_opt = getattr(self._client_options, "universe_domain", None) 

721 

722 ( 

723 self._use_client_cert, 

724 self._use_mtls_endpoint, 

725 self._universe_domain_env, 

726 ) = ConfigServiceV2Client._read_environment_variables() 

727 self._client_cert_source = ConfigServiceV2Client._get_client_cert_source( 

728 self._client_options.client_cert_source, self._use_client_cert 

729 ) 

730 self._universe_domain = ConfigServiceV2Client._get_universe_domain( 

731 universe_domain_opt, self._universe_domain_env 

732 ) 

733 self._api_endpoint = None # updated below, depending on `transport` 

734 

735 # Initialize the universe domain validation. 

736 self._is_universe_domain_valid = False 

737 

738 if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER 

739 # Setup logging. 

740 client_logging.initialize_logging() 

741 

742 api_key_value = getattr(self._client_options, "api_key", None) 

743 if api_key_value and credentials: 

744 raise ValueError( 

745 "client_options.api_key and credentials are mutually exclusive" 

746 ) 

747 

748 # Save or instantiate the transport. 

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

750 # instance provides an extensibility point for unusual situations. 

751 transport_provided = isinstance(transport, ConfigServiceV2Transport) 

752 if transport_provided: 

753 # transport is a ConfigServiceV2Transport instance. 

754 if credentials or self._client_options.credentials_file or api_key_value: 

755 raise ValueError( 

756 "When providing a transport instance, " 

757 "provide its credentials directly." 

758 ) 

759 if self._client_options.scopes: 

760 raise ValueError( 

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

762 "directly." 

763 ) 

764 self._transport = cast(ConfigServiceV2Transport, transport) 

765 self._api_endpoint = self._transport.host 

766 

767 self._api_endpoint = ( 

768 self._api_endpoint 

769 or ConfigServiceV2Client._get_api_endpoint( 

770 self._client_options.api_endpoint, 

771 self._client_cert_source, 

772 self._universe_domain, 

773 self._use_mtls_endpoint, 

774 ) 

775 ) 

776 

777 if not transport_provided: 

778 import google.auth._default # type: ignore 

779 

780 if api_key_value and hasattr( 

781 google.auth._default, "get_api_key_credentials" 

782 ): 

783 credentials = google.auth._default.get_api_key_credentials( 

784 api_key_value 

785 ) 

786 

787 transport_init: Union[ 

788 Type[ConfigServiceV2Transport], Callable[..., ConfigServiceV2Transport] 

789 ] = ( 

790 ConfigServiceV2Client.get_transport_class(transport) 

791 if isinstance(transport, str) or transport is None 

792 else cast(Callable[..., ConfigServiceV2Transport], transport) 

793 ) 

794 # initialize with the provided callable or the passed in class 

795 self._transport = transport_init( 

796 credentials=credentials, 

797 credentials_file=self._client_options.credentials_file, 

798 host=self._api_endpoint, 

799 scopes=self._client_options.scopes, 

800 client_cert_source_for_mtls=self._client_cert_source, 

801 quota_project_id=self._client_options.quota_project_id, 

802 client_info=client_info, 

803 always_use_jwt_access=True, 

804 api_audience=self._client_options.api_audience, 

805 ) 

806 

807 if "async" not in str(self._transport): 

808 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

809 std_logging.DEBUG 

810 ): # pragma: NO COVER 

811 _LOGGER.debug( 

812 "Created client `google.logging_v2.ConfigServiceV2Client`.", 

813 extra={ 

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

815 "universeDomain": getattr( 

816 self._transport._credentials, "universe_domain", "" 

817 ), 

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

819 "credentialsInfo": getattr( 

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

821 )(), 

822 } 

823 if hasattr(self._transport, "_credentials") 

824 else { 

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

826 "credentialsType": None, 

827 }, 

828 ) 

829 

830 def list_buckets( 

831 self, 

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

833 *, 

834 parent: Optional[str] = None, 

835 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

838 ) -> pagers.ListBucketsPager: 

839 r"""Lists log buckets. 

840 

841 .. code-block:: python 

842 

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

844 # code template only. 

845 # It will require modifications to work: 

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

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

848 # client as shown in: 

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

850 from google.cloud import logging_v2 

851 

852 def sample_list_buckets(): 

853 # Create a client 

854 client = logging_v2.ConfigServiceV2Client() 

855 

856 # Initialize request argument(s) 

857 request = logging_v2.ListBucketsRequest( 

858 parent="parent_value", 

859 ) 

860 

861 # Make the request 

862 page_result = client.list_buckets(request=request) 

863 

864 # Handle the response 

865 for response in page_result: 

866 print(response) 

867 

868 Args: 

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

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

871 parent (str): 

872 Required. The parent resource whose buckets are to be 

873 listed: 

874 

875 :: 

876 

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

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

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

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

881 

882 Note: The locations portion of the resource must be 

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

884 [LOCATION_ID] will return all buckets. 

885 

886 This corresponds to the ``parent`` field 

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

888 should not be set. 

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

890 should be retried. 

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

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

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

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

895 be of type `bytes`. 

896 

897 Returns: 

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

899 The response from ListBuckets. 

900 

901 Iterating over this object will yield 

902 results and resolve additional pages 

903 automatically. 

904 

905 """ 

906 # Create or coerce a protobuf request object. 

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

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

909 flattened_params = [parent] 

910 has_flattened_params = ( 

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

912 ) 

913 if request is not None and has_flattened_params: 

914 raise ValueError( 

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

916 "the individual field arguments should be set." 

917 ) 

918 

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

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

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

922 request = logging_config.ListBucketsRequest(request) 

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

924 # request, apply these. 

925 if parent is not None: 

926 request.parent = parent 

927 

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

929 # and friendly error handling. 

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

931 

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

933 # add these here. 

934 metadata = tuple(metadata) + ( 

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

936 ) 

937 

938 # Validate the universe domain. 

939 self._validate_universe_domain() 

940 

941 # Send the request. 

942 response = rpc( 

943 request, 

944 retry=retry, 

945 timeout=timeout, 

946 metadata=metadata, 

947 ) 

948 

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

950 # an `__iter__` convenience method. 

951 response = pagers.ListBucketsPager( 

952 method=rpc, 

953 request=request, 

954 response=response, 

955 retry=retry, 

956 timeout=timeout, 

957 metadata=metadata, 

958 ) 

959 

960 # Done; return the response. 

961 return response 

962 

963 def get_bucket( 

964 self, 

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

966 *, 

967 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

970 ) -> logging_config.LogBucket: 

971 r"""Gets a log bucket. 

972 

973 .. code-block:: python 

974 

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

976 # code template only. 

977 # It will require modifications to work: 

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

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

980 # client as shown in: 

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

982 from google.cloud import logging_v2 

983 

984 def sample_get_bucket(): 

985 # Create a client 

986 client = logging_v2.ConfigServiceV2Client() 

987 

988 # Initialize request argument(s) 

989 request = logging_v2.GetBucketRequest( 

990 name="name_value", 

991 ) 

992 

993 # Make the request 

994 response = client.get_bucket(request=request) 

995 

996 # Handle the response 

997 print(response) 

998 

999 Args: 

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

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

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

1003 should be retried. 

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

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

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

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

1008 be of type `bytes`. 

1009 

1010 Returns: 

1011 google.cloud.logging_v2.types.LogBucket: 

1012 Describes a repository in which log 

1013 entries are stored. 

1014 

1015 """ 

1016 # Create or coerce a protobuf request object. 

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

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

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

1020 request = logging_config.GetBucketRequest(request) 

1021 

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

1023 # and friendly error handling. 

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

1025 

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

1027 # add these here. 

1028 metadata = tuple(metadata) + ( 

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

1030 ) 

1031 

1032 # Validate the universe domain. 

1033 self._validate_universe_domain() 

1034 

1035 # Send the request. 

1036 response = rpc( 

1037 request, 

1038 retry=retry, 

1039 timeout=timeout, 

1040 metadata=metadata, 

1041 ) 

1042 

1043 # Done; return the response. 

1044 return response 

1045 

1046 def create_bucket_async( 

1047 self, 

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

1049 *, 

1050 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

1053 ) -> operation.Operation: 

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

1055 to store log entries. 

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

1057 cannot be changed. 

1058 

1059 .. code-block:: python 

1060 

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

1062 # code template only. 

1063 # It will require modifications to work: 

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

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

1066 # client as shown in: 

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

1068 from google.cloud import logging_v2 

1069 

1070 def sample_create_bucket_async(): 

1071 # Create a client 

1072 client = logging_v2.ConfigServiceV2Client() 

1073 

1074 # Initialize request argument(s) 

1075 request = logging_v2.CreateBucketRequest( 

1076 parent="parent_value", 

1077 bucket_id="bucket_id_value", 

1078 ) 

1079 

1080 # Make the request 

1081 operation = client.create_bucket_async(request=request) 

1082 

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

1084 

1085 response = operation.result() 

1086 

1087 # Handle the response 

1088 print(response) 

1089 

1090 Args: 

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

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

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

1094 should be retried. 

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

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

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

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

1099 be of type `bytes`. 

1100 

1101 Returns: 

1102 google.api_core.operation.Operation: 

1103 An object representing a long-running operation. 

1104 

1105 The result type for the operation will be 

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

1107 Describes a repository in which log entries are stored. 

1108 

1109 """ 

1110 # Create or coerce a protobuf request object. 

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

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

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

1114 request = logging_config.CreateBucketRequest(request) 

1115 

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

1117 # and friendly error handling. 

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

1119 

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

1121 # add these here. 

1122 metadata = tuple(metadata) + ( 

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

1124 ) 

1125 

1126 # Validate the universe domain. 

1127 self._validate_universe_domain() 

1128 

1129 # Send the request. 

1130 response = rpc( 

1131 request, 

1132 retry=retry, 

1133 timeout=timeout, 

1134 metadata=metadata, 

1135 ) 

1136 

1137 # Wrap the response in an operation future. 

1138 response = operation.from_gapic( 

1139 response, 

1140 self._transport.operations_client, 

1141 logging_config.LogBucket, 

1142 metadata_type=logging_config.BucketMetadata, 

1143 ) 

1144 

1145 # Done; return the response. 

1146 return response 

1147 

1148 def update_bucket_async( 

1149 self, 

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

1151 *, 

1152 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

1155 ) -> operation.Operation: 

1156 r"""Updates a log bucket asynchronously. 

1157 

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

1159 then ``FAILED_PRECONDITION`` will be returned. 

1160 

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

1162 changed. 

1163 

1164 .. code-block:: python 

1165 

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

1167 # code template only. 

1168 # It will require modifications to work: 

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

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

1171 # client as shown in: 

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

1173 from google.cloud import logging_v2 

1174 

1175 def sample_update_bucket_async(): 

1176 # Create a client 

1177 client = logging_v2.ConfigServiceV2Client() 

1178 

1179 # Initialize request argument(s) 

1180 request = logging_v2.UpdateBucketRequest( 

1181 name="name_value", 

1182 ) 

1183 

1184 # Make the request 

1185 operation = client.update_bucket_async(request=request) 

1186 

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

1188 

1189 response = operation.result() 

1190 

1191 # Handle the response 

1192 print(response) 

1193 

1194 Args: 

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

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

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

1198 should be retried. 

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

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

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

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

1203 be of type `bytes`. 

1204 

1205 Returns: 

1206 google.api_core.operation.Operation: 

1207 An object representing a long-running operation. 

1208 

1209 The result type for the operation will be 

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

1211 Describes a repository in which log entries are stored. 

1212 

1213 """ 

1214 # Create or coerce a protobuf request object. 

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

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

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

1218 request = logging_config.UpdateBucketRequest(request) 

1219 

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

1221 # and friendly error handling. 

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

1223 

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

1225 # add these here. 

1226 metadata = tuple(metadata) + ( 

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

1228 ) 

1229 

1230 # Validate the universe domain. 

1231 self._validate_universe_domain() 

1232 

1233 # Send the request. 

1234 response = rpc( 

1235 request, 

1236 retry=retry, 

1237 timeout=timeout, 

1238 metadata=metadata, 

1239 ) 

1240 

1241 # Wrap the response in an operation future. 

1242 response = operation.from_gapic( 

1243 response, 

1244 self._transport.operations_client, 

1245 logging_config.LogBucket, 

1246 metadata_type=logging_config.BucketMetadata, 

1247 ) 

1248 

1249 # Done; return the response. 

1250 return response 

1251 

1252 def create_bucket( 

1253 self, 

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

1255 *, 

1256 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

1259 ) -> logging_config.LogBucket: 

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

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

1262 location cannot be changed. 

1263 

1264 .. code-block:: python 

1265 

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

1267 # code template only. 

1268 # It will require modifications to work: 

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

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

1271 # client as shown in: 

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

1273 from google.cloud import logging_v2 

1274 

1275 def sample_create_bucket(): 

1276 # Create a client 

1277 client = logging_v2.ConfigServiceV2Client() 

1278 

1279 # Initialize request argument(s) 

1280 request = logging_v2.CreateBucketRequest( 

1281 parent="parent_value", 

1282 bucket_id="bucket_id_value", 

1283 ) 

1284 

1285 # Make the request 

1286 response = client.create_bucket(request=request) 

1287 

1288 # Handle the response 

1289 print(response) 

1290 

1291 Args: 

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

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

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

1295 should be retried. 

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

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

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

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

1300 be of type `bytes`. 

1301 

1302 Returns: 

1303 google.cloud.logging_v2.types.LogBucket: 

1304 Describes a repository in which log 

1305 entries are stored. 

1306 

1307 """ 

1308 # Create or coerce a protobuf request object. 

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

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

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

1312 request = logging_config.CreateBucketRequest(request) 

1313 

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

1315 # and friendly error handling. 

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

1317 

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

1319 # add these here. 

1320 metadata = tuple(metadata) + ( 

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

1322 ) 

1323 

1324 # Validate the universe domain. 

1325 self._validate_universe_domain() 

1326 

1327 # Send the request. 

1328 response = rpc( 

1329 request, 

1330 retry=retry, 

1331 timeout=timeout, 

1332 metadata=metadata, 

1333 ) 

1334 

1335 # Done; return the response. 

1336 return response 

1337 

1338 def update_bucket( 

1339 self, 

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

1341 *, 

1342 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

1345 ) -> logging_config.LogBucket: 

1346 r"""Updates a log bucket. 

1347 

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

1349 then ``FAILED_PRECONDITION`` will be returned. 

1350 

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

1352 changed. 

1353 

1354 .. code-block:: python 

1355 

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

1357 # code template only. 

1358 # It will require modifications to work: 

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

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

1361 # client as shown in: 

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

1363 from google.cloud import logging_v2 

1364 

1365 def sample_update_bucket(): 

1366 # Create a client 

1367 client = logging_v2.ConfigServiceV2Client() 

1368 

1369 # Initialize request argument(s) 

1370 request = logging_v2.UpdateBucketRequest( 

1371 name="name_value", 

1372 ) 

1373 

1374 # Make the request 

1375 response = client.update_bucket(request=request) 

1376 

1377 # Handle the response 

1378 print(response) 

1379 

1380 Args: 

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

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

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

1384 should be retried. 

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

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

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

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

1389 be of type `bytes`. 

1390 

1391 Returns: 

1392 google.cloud.logging_v2.types.LogBucket: 

1393 Describes a repository in which log 

1394 entries are stored. 

1395 

1396 """ 

1397 # Create or coerce a protobuf request object. 

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

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

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

1401 request = logging_config.UpdateBucketRequest(request) 

1402 

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

1404 # and friendly error handling. 

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

1406 

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

1408 # add these here. 

1409 metadata = tuple(metadata) + ( 

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

1411 ) 

1412 

1413 # Validate the universe domain. 

1414 self._validate_universe_domain() 

1415 

1416 # Send the request. 

1417 response = rpc( 

1418 request, 

1419 retry=retry, 

1420 timeout=timeout, 

1421 metadata=metadata, 

1422 ) 

1423 

1424 # Done; return the response. 

1425 return response 

1426 

1427 def delete_bucket( 

1428 self, 

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

1430 *, 

1431 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

1434 ) -> None: 

1435 r"""Deletes a log bucket. 

1436 

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

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

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

1440 deleted. 

1441 

1442 .. code-block:: python 

1443 

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

1445 # code template only. 

1446 # It will require modifications to work: 

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

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

1449 # client as shown in: 

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

1451 from google.cloud import logging_v2 

1452 

1453 def sample_delete_bucket(): 

1454 # Create a client 

1455 client = logging_v2.ConfigServiceV2Client() 

1456 

1457 # Initialize request argument(s) 

1458 request = logging_v2.DeleteBucketRequest( 

1459 name="name_value", 

1460 ) 

1461 

1462 # Make the request 

1463 client.delete_bucket(request=request) 

1464 

1465 Args: 

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

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

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

1469 should be retried. 

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

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

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

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

1474 be of type `bytes`. 

1475 """ 

1476 # Create or coerce a protobuf request object. 

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

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

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

1480 request = logging_config.DeleteBucketRequest(request) 

1481 

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

1483 # and friendly error handling. 

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

1485 

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

1487 # add these here. 

1488 metadata = tuple(metadata) + ( 

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

1490 ) 

1491 

1492 # Validate the universe domain. 

1493 self._validate_universe_domain() 

1494 

1495 # Send the request. 

1496 rpc( 

1497 request, 

1498 retry=retry, 

1499 timeout=timeout, 

1500 metadata=metadata, 

1501 ) 

1502 

1503 def undelete_bucket( 

1504 self, 

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

1506 *, 

1507 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

1510 ) -> None: 

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

1512 deleted can be undeleted within the grace period of 7 

1513 days. 

1514 

1515 .. code-block:: python 

1516 

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

1518 # code template only. 

1519 # It will require modifications to work: 

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

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

1522 # client as shown in: 

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

1524 from google.cloud import logging_v2 

1525 

1526 def sample_undelete_bucket(): 

1527 # Create a client 

1528 client = logging_v2.ConfigServiceV2Client() 

1529 

1530 # Initialize request argument(s) 

1531 request = logging_v2.UndeleteBucketRequest( 

1532 name="name_value", 

1533 ) 

1534 

1535 # Make the request 

1536 client.undelete_bucket(request=request) 

1537 

1538 Args: 

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

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

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

1542 should be retried. 

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

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

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

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

1547 be of type `bytes`. 

1548 """ 

1549 # Create or coerce a protobuf request object. 

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

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

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

1553 request = logging_config.UndeleteBucketRequest(request) 

1554 

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

1556 # and friendly error handling. 

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

1558 

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

1560 # add these here. 

1561 metadata = tuple(metadata) + ( 

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

1563 ) 

1564 

1565 # Validate the universe domain. 

1566 self._validate_universe_domain() 

1567 

1568 # Send the request. 

1569 rpc( 

1570 request, 

1571 retry=retry, 

1572 timeout=timeout, 

1573 metadata=metadata, 

1574 ) 

1575 

1576 def list_views( 

1577 self, 

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

1579 *, 

1580 parent: Optional[str] = None, 

1581 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

1584 ) -> pagers.ListViewsPager: 

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

1586 

1587 .. code-block:: python 

1588 

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

1590 # code template only. 

1591 # It will require modifications to work: 

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

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

1594 # client as shown in: 

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

1596 from google.cloud import logging_v2 

1597 

1598 def sample_list_views(): 

1599 # Create a client 

1600 client = logging_v2.ConfigServiceV2Client() 

1601 

1602 # Initialize request argument(s) 

1603 request = logging_v2.ListViewsRequest( 

1604 parent="parent_value", 

1605 ) 

1606 

1607 # Make the request 

1608 page_result = client.list_views(request=request) 

1609 

1610 # Handle the response 

1611 for response in page_result: 

1612 print(response) 

1613 

1614 Args: 

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

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

1617 parent (str): 

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

1619 

1620 :: 

1621 

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

1623 

1624 This corresponds to the ``parent`` field 

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

1626 should not be set. 

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

1628 should be retried. 

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

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

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

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

1633 be of type `bytes`. 

1634 

1635 Returns: 

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

1637 The response from ListViews. 

1638 

1639 Iterating over this object will yield 

1640 results and resolve additional pages 

1641 automatically. 

1642 

1643 """ 

1644 # Create or coerce a protobuf request object. 

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

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

1647 flattened_params = [parent] 

1648 has_flattened_params = ( 

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

1650 ) 

1651 if request is not None and has_flattened_params: 

1652 raise ValueError( 

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

1654 "the individual field arguments should be set." 

1655 ) 

1656 

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

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

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

1660 request = logging_config.ListViewsRequest(request) 

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

1662 # request, apply these. 

1663 if parent is not None: 

1664 request.parent = parent 

1665 

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

1667 # and friendly error handling. 

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

1669 

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

1671 # add these here. 

1672 metadata = tuple(metadata) + ( 

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

1674 ) 

1675 

1676 # Validate the universe domain. 

1677 self._validate_universe_domain() 

1678 

1679 # Send the request. 

1680 response = rpc( 

1681 request, 

1682 retry=retry, 

1683 timeout=timeout, 

1684 metadata=metadata, 

1685 ) 

1686 

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

1688 # an `__iter__` convenience method. 

1689 response = pagers.ListViewsPager( 

1690 method=rpc, 

1691 request=request, 

1692 response=response, 

1693 retry=retry, 

1694 timeout=timeout, 

1695 metadata=metadata, 

1696 ) 

1697 

1698 # Done; return the response. 

1699 return response 

1700 

1701 def get_view( 

1702 self, 

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

1704 *, 

1705 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

1708 ) -> logging_config.LogView: 

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

1710 

1711 .. code-block:: python 

1712 

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

1714 # code template only. 

1715 # It will require modifications to work: 

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

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

1718 # client as shown in: 

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

1720 from google.cloud import logging_v2 

1721 

1722 def sample_get_view(): 

1723 # Create a client 

1724 client = logging_v2.ConfigServiceV2Client() 

1725 

1726 # Initialize request argument(s) 

1727 request = logging_v2.GetViewRequest( 

1728 name="name_value", 

1729 ) 

1730 

1731 # Make the request 

1732 response = client.get_view(request=request) 

1733 

1734 # Handle the response 

1735 print(response) 

1736 

1737 Args: 

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

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

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

1741 should be retried. 

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

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

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

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

1746 be of type `bytes`. 

1747 

1748 Returns: 

1749 google.cloud.logging_v2.types.LogView: 

1750 Describes a view over log entries in 

1751 a bucket. 

1752 

1753 """ 

1754 # Create or coerce a protobuf request object. 

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

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

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

1758 request = logging_config.GetViewRequest(request) 

1759 

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

1761 # and friendly error handling. 

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

1763 

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

1765 # add these here. 

1766 metadata = tuple(metadata) + ( 

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

1768 ) 

1769 

1770 # Validate the universe domain. 

1771 self._validate_universe_domain() 

1772 

1773 # Send the request. 

1774 response = rpc( 

1775 request, 

1776 retry=retry, 

1777 timeout=timeout, 

1778 metadata=metadata, 

1779 ) 

1780 

1781 # Done; return the response. 

1782 return response 

1783 

1784 def create_view( 

1785 self, 

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

1787 *, 

1788 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

1791 ) -> logging_config.LogView: 

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

1793 bucket may contain a maximum of 30 views. 

1794 

1795 .. code-block:: python 

1796 

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

1798 # code template only. 

1799 # It will require modifications to work: 

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

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

1802 # client as shown in: 

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

1804 from google.cloud import logging_v2 

1805 

1806 def sample_create_view(): 

1807 # Create a client 

1808 client = logging_v2.ConfigServiceV2Client() 

1809 

1810 # Initialize request argument(s) 

1811 request = logging_v2.CreateViewRequest( 

1812 parent="parent_value", 

1813 view_id="view_id_value", 

1814 ) 

1815 

1816 # Make the request 

1817 response = client.create_view(request=request) 

1818 

1819 # Handle the response 

1820 print(response) 

1821 

1822 Args: 

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

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

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

1826 should be retried. 

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

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

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

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

1831 be of type `bytes`. 

1832 

1833 Returns: 

1834 google.cloud.logging_v2.types.LogView: 

1835 Describes a view over log entries in 

1836 a bucket. 

1837 

1838 """ 

1839 # Create or coerce a protobuf request object. 

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

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

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

1843 request = logging_config.CreateViewRequest(request) 

1844 

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

1846 # and friendly error handling. 

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

1848 

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

1850 # add these here. 

1851 metadata = tuple(metadata) + ( 

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

1853 ) 

1854 

1855 # Validate the universe domain. 

1856 self._validate_universe_domain() 

1857 

1858 # Send the request. 

1859 response = rpc( 

1860 request, 

1861 retry=retry, 

1862 timeout=timeout, 

1863 metadata=metadata, 

1864 ) 

1865 

1866 # Done; return the response. 

1867 return response 

1868 

1869 def update_view( 

1870 self, 

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

1872 *, 

1873 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

1876 ) -> logging_config.LogView: 

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

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

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

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

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

1882 

1883 .. code-block:: python 

1884 

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

1886 # code template only. 

1887 # It will require modifications to work: 

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

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

1890 # client as shown in: 

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

1892 from google.cloud import logging_v2 

1893 

1894 def sample_update_view(): 

1895 # Create a client 

1896 client = logging_v2.ConfigServiceV2Client() 

1897 

1898 # Initialize request argument(s) 

1899 request = logging_v2.UpdateViewRequest( 

1900 name="name_value", 

1901 ) 

1902 

1903 # Make the request 

1904 response = client.update_view(request=request) 

1905 

1906 # Handle the response 

1907 print(response) 

1908 

1909 Args: 

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

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

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

1913 should be retried. 

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

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

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

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

1918 be of type `bytes`. 

1919 

1920 Returns: 

1921 google.cloud.logging_v2.types.LogView: 

1922 Describes a view over log entries in 

1923 a bucket. 

1924 

1925 """ 

1926 # Create or coerce a protobuf request object. 

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

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

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

1930 request = logging_config.UpdateViewRequest(request) 

1931 

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

1933 # and friendly error handling. 

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

1935 

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

1937 # add these here. 

1938 metadata = tuple(metadata) + ( 

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

1940 ) 

1941 

1942 # Validate the universe domain. 

1943 self._validate_universe_domain() 

1944 

1945 # Send the request. 

1946 response = rpc( 

1947 request, 

1948 retry=retry, 

1949 timeout=timeout, 

1950 metadata=metadata, 

1951 ) 

1952 

1953 # Done; return the response. 

1954 return response 

1955 

1956 def delete_view( 

1957 self, 

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

1959 *, 

1960 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

1963 ) -> None: 

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

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

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

1967 minutes. 

1968 

1969 .. code-block:: python 

1970 

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

1972 # code template only. 

1973 # It will require modifications to work: 

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

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

1976 # client as shown in: 

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

1978 from google.cloud import logging_v2 

1979 

1980 def sample_delete_view(): 

1981 # Create a client 

1982 client = logging_v2.ConfigServiceV2Client() 

1983 

1984 # Initialize request argument(s) 

1985 request = logging_v2.DeleteViewRequest( 

1986 name="name_value", 

1987 ) 

1988 

1989 # Make the request 

1990 client.delete_view(request=request) 

1991 

1992 Args: 

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

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

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

1996 should be retried. 

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

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

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

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

2001 be of type `bytes`. 

2002 """ 

2003 # Create or coerce a protobuf request object. 

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

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

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

2007 request = logging_config.DeleteViewRequest(request) 

2008 

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

2010 # and friendly error handling. 

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

2012 

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

2014 # add these here. 

2015 metadata = tuple(metadata) + ( 

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

2017 ) 

2018 

2019 # Validate the universe domain. 

2020 self._validate_universe_domain() 

2021 

2022 # Send the request. 

2023 rpc( 

2024 request, 

2025 retry=retry, 

2026 timeout=timeout, 

2027 metadata=metadata, 

2028 ) 

2029 

2030 def list_sinks( 

2031 self, 

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

2033 *, 

2034 parent: Optional[str] = None, 

2035 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

2038 ) -> pagers.ListSinksPager: 

2039 r"""Lists sinks. 

2040 

2041 .. code-block:: python 

2042 

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

2044 # code template only. 

2045 # It will require modifications to work: 

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

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

2048 # client as shown in: 

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

2050 from google.cloud import logging_v2 

2051 

2052 def sample_list_sinks(): 

2053 # Create a client 

2054 client = logging_v2.ConfigServiceV2Client() 

2055 

2056 # Initialize request argument(s) 

2057 request = logging_v2.ListSinksRequest( 

2058 parent="parent_value", 

2059 ) 

2060 

2061 # Make the request 

2062 page_result = client.list_sinks(request=request) 

2063 

2064 # Handle the response 

2065 for response in page_result: 

2066 print(response) 

2067 

2068 Args: 

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

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

2071 parent (str): 

2072 Required. The parent resource whose sinks are to be 

2073 listed: 

2074 

2075 :: 

2076 

2077 "projects/[PROJECT_ID]" 

2078 "organizations/[ORGANIZATION_ID]" 

2079 "billingAccounts/[BILLING_ACCOUNT_ID]" 

2080 "folders/[FOLDER_ID]" 

2081 

2082 This corresponds to the ``parent`` field 

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

2084 should not be set. 

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

2086 should be retried. 

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

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

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

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

2091 be of type `bytes`. 

2092 

2093 Returns: 

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

2095 Result returned from ListSinks. 

2096 

2097 Iterating over this object will yield results and 

2098 resolve additional pages automatically. 

2099 

2100 """ 

2101 # Create or coerce a protobuf request object. 

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

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

2104 flattened_params = [parent] 

2105 has_flattened_params = ( 

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

2107 ) 

2108 if request is not None and has_flattened_params: 

2109 raise ValueError( 

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

2111 "the individual field arguments should be set." 

2112 ) 

2113 

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

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

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

2117 request = logging_config.ListSinksRequest(request) 

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

2119 # request, apply these. 

2120 if parent is not None: 

2121 request.parent = parent 

2122 

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

2124 # and friendly error handling. 

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

2126 

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

2128 # add these here. 

2129 metadata = tuple(metadata) + ( 

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

2131 ) 

2132 

2133 # Validate the universe domain. 

2134 self._validate_universe_domain() 

2135 

2136 # Send the request. 

2137 response = rpc( 

2138 request, 

2139 retry=retry, 

2140 timeout=timeout, 

2141 metadata=metadata, 

2142 ) 

2143 

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

2145 # an `__iter__` convenience method. 

2146 response = pagers.ListSinksPager( 

2147 method=rpc, 

2148 request=request, 

2149 response=response, 

2150 retry=retry, 

2151 timeout=timeout, 

2152 metadata=metadata, 

2153 ) 

2154 

2155 # Done; return the response. 

2156 return response 

2157 

2158 def get_sink( 

2159 self, 

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

2161 *, 

2162 sink_name: Optional[str] = None, 

2163 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

2166 ) -> logging_config.LogSink: 

2167 r"""Gets a sink. 

2168 

2169 .. code-block:: python 

2170 

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

2172 # code template only. 

2173 # It will require modifications to work: 

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

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

2176 # client as shown in: 

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

2178 from google.cloud import logging_v2 

2179 

2180 def sample_get_sink(): 

2181 # Create a client 

2182 client = logging_v2.ConfigServiceV2Client() 

2183 

2184 # Initialize request argument(s) 

2185 request = logging_v2.GetSinkRequest( 

2186 sink_name="sink_name_value", 

2187 ) 

2188 

2189 # Make the request 

2190 response = client.get_sink(request=request) 

2191 

2192 # Handle the response 

2193 print(response) 

2194 

2195 Args: 

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

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

2198 sink_name (str): 

2199 Required. The resource name of the sink: 

2200 

2201 :: 

2202 

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

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

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

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

2207 

2208 For example: 

2209 

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

2211 

2212 This corresponds to the ``sink_name`` field 

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

2214 should not be set. 

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

2216 should be retried. 

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

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

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

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

2221 be of type `bytes`. 

2222 

2223 Returns: 

2224 google.cloud.logging_v2.types.LogSink: 

2225 Describes a sink used to export log 

2226 entries to one of the following 

2227 destinations in any project: a Cloud 

2228 Storage bucket, a BigQuery dataset, a 

2229 Pub/Sub topic or a Cloud Logging log 

2230 bucket. A logs filter controls which log 

2231 entries are exported. The sink must be 

2232 created within a project, organization, 

2233 billing account, or folder. 

2234 

2235 """ 

2236 # Create or coerce a protobuf request object. 

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

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

2239 flattened_params = [sink_name] 

2240 has_flattened_params = ( 

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

2242 ) 

2243 if request is not None and has_flattened_params: 

2244 raise ValueError( 

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

2246 "the individual field arguments should be set." 

2247 ) 

2248 

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

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

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

2252 request = logging_config.GetSinkRequest(request) 

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

2254 # request, apply these. 

2255 if sink_name is not None: 

2256 request.sink_name = sink_name 

2257 

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

2259 # and friendly error handling. 

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

2261 

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

2263 # add these here. 

2264 metadata = tuple(metadata) + ( 

2265 gapic_v1.routing_header.to_grpc_metadata( 

2266 (("sink_name", request.sink_name),) 

2267 ), 

2268 ) 

2269 

2270 # Validate the universe domain. 

2271 self._validate_universe_domain() 

2272 

2273 # Send the request. 

2274 response = rpc( 

2275 request, 

2276 retry=retry, 

2277 timeout=timeout, 

2278 metadata=metadata, 

2279 ) 

2280 

2281 # Done; return the response. 

2282 return response 

2283 

2284 def create_sink( 

2285 self, 

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

2287 *, 

2288 parent: Optional[str] = None, 

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

2290 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

2293 ) -> logging_config.LogSink: 

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

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

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

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

2298 entries only from the resource owning the sink. 

2299 

2300 .. code-block:: python 

2301 

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

2303 # code template only. 

2304 # It will require modifications to work: 

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

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

2307 # client as shown in: 

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

2309 from google.cloud import logging_v2 

2310 

2311 def sample_create_sink(): 

2312 # Create a client 

2313 client = logging_v2.ConfigServiceV2Client() 

2314 

2315 # Initialize request argument(s) 

2316 sink = logging_v2.LogSink() 

2317 sink.name = "name_value" 

2318 sink.destination = "destination_value" 

2319 

2320 request = logging_v2.CreateSinkRequest( 

2321 parent="parent_value", 

2322 sink=sink, 

2323 ) 

2324 

2325 # Make the request 

2326 response = client.create_sink(request=request) 

2327 

2328 # Handle the response 

2329 print(response) 

2330 

2331 Args: 

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

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

2334 parent (str): 

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

2336 

2337 :: 

2338 

2339 "projects/[PROJECT_ID]" 

2340 "organizations/[ORGANIZATION_ID]" 

2341 "billingAccounts/[BILLING_ACCOUNT_ID]" 

2342 "folders/[FOLDER_ID]" 

2343 

2344 For examples: 

2345 

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

2347 

2348 This corresponds to the ``parent`` field 

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

2350 should not be set. 

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

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

2353 sink identifier that is not already in use. 

2354 

2355 This corresponds to the ``sink`` field 

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

2357 should not be set. 

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

2359 should be retried. 

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

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

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

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

2364 be of type `bytes`. 

2365 

2366 Returns: 

2367 google.cloud.logging_v2.types.LogSink: 

2368 Describes a sink used to export log 

2369 entries to one of the following 

2370 destinations in any project: a Cloud 

2371 Storage bucket, a BigQuery dataset, a 

2372 Pub/Sub topic or a Cloud Logging log 

2373 bucket. A logs filter controls which log 

2374 entries are exported. The sink must be 

2375 created within a project, organization, 

2376 billing account, or folder. 

2377 

2378 """ 

2379 # Create or coerce a protobuf request object. 

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

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

2382 flattened_params = [parent, sink] 

2383 has_flattened_params = ( 

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

2385 ) 

2386 if request is not None and has_flattened_params: 

2387 raise ValueError( 

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

2389 "the individual field arguments should be set." 

2390 ) 

2391 

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

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

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

2395 request = logging_config.CreateSinkRequest(request) 

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

2397 # request, apply these. 

2398 if parent is not None: 

2399 request.parent = parent 

2400 if sink is not None: 

2401 request.sink = sink 

2402 

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

2404 # and friendly error handling. 

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

2406 

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

2408 # add these here. 

2409 metadata = tuple(metadata) + ( 

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

2411 ) 

2412 

2413 # Validate the universe domain. 

2414 self._validate_universe_domain() 

2415 

2416 # Send the request. 

2417 response = rpc( 

2418 request, 

2419 retry=retry, 

2420 timeout=timeout, 

2421 metadata=metadata, 

2422 ) 

2423 

2424 # Done; return the response. 

2425 return response 

2426 

2427 def update_sink( 

2428 self, 

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

2430 *, 

2431 sink_name: Optional[str] = None, 

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

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

2434 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

2437 ) -> logging_config.LogSink: 

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

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

2440 and ``filter``. 

2441 

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

2443 the ``unique_writer_identity`` field. 

2444 

2445 .. code-block:: python 

2446 

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

2448 # code template only. 

2449 # It will require modifications to work: 

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

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

2452 # client as shown in: 

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

2454 from google.cloud import logging_v2 

2455 

2456 def sample_update_sink(): 

2457 # Create a client 

2458 client = logging_v2.ConfigServiceV2Client() 

2459 

2460 # Initialize request argument(s) 

2461 sink = logging_v2.LogSink() 

2462 sink.name = "name_value" 

2463 sink.destination = "destination_value" 

2464 

2465 request = logging_v2.UpdateSinkRequest( 

2466 sink_name="sink_name_value", 

2467 sink=sink, 

2468 ) 

2469 

2470 # Make the request 

2471 response = client.update_sink(request=request) 

2472 

2473 # Handle the response 

2474 print(response) 

2475 

2476 Args: 

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

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

2479 sink_name (str): 

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

2481 including the parent resource and the sink identifier: 

2482 

2483 :: 

2484 

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

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

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

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

2489 

2490 For example: 

2491 

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

2493 

2494 This corresponds to the ``sink_name`` field 

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

2496 should not be set. 

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

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

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

2500 

2501 This corresponds to the ``sink`` field 

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

2503 should not be set. 

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

2505 Optional. Field mask that specifies the fields in 

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

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

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

2509 

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

2511 the following mask for backwards compatibility purposes: 

2512 

2513 ``destination,filter,includeChildren`` 

2514 

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

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

2517 

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

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

2520 

2521 For example: ``updateMask=filter`` 

2522 

2523 This corresponds to the ``update_mask`` field 

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

2525 should not be set. 

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

2527 should be retried. 

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

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

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

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

2532 be of type `bytes`. 

2533 

2534 Returns: 

2535 google.cloud.logging_v2.types.LogSink: 

2536 Describes a sink used to export log 

2537 entries to one of the following 

2538 destinations in any project: a Cloud 

2539 Storage bucket, a BigQuery dataset, a 

2540 Pub/Sub topic or a Cloud Logging log 

2541 bucket. A logs filter controls which log 

2542 entries are exported. The sink must be 

2543 created within a project, organization, 

2544 billing account, or folder. 

2545 

2546 """ 

2547 # Create or coerce a protobuf request object. 

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

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

2550 flattened_params = [sink_name, sink, update_mask] 

2551 has_flattened_params = ( 

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

2553 ) 

2554 if request is not None and has_flattened_params: 

2555 raise ValueError( 

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

2557 "the individual field arguments should be set." 

2558 ) 

2559 

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

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

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

2563 request = logging_config.UpdateSinkRequest(request) 

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

2565 # request, apply these. 

2566 if sink_name is not None: 

2567 request.sink_name = sink_name 

2568 if sink is not None: 

2569 request.sink = sink 

2570 if update_mask is not None: 

2571 request.update_mask = update_mask 

2572 

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

2574 # and friendly error handling. 

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

2576 

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

2578 # add these here. 

2579 metadata = tuple(metadata) + ( 

2580 gapic_v1.routing_header.to_grpc_metadata( 

2581 (("sink_name", request.sink_name),) 

2582 ), 

2583 ) 

2584 

2585 # Validate the universe domain. 

2586 self._validate_universe_domain() 

2587 

2588 # Send the request. 

2589 response = rpc( 

2590 request, 

2591 retry=retry, 

2592 timeout=timeout, 

2593 metadata=metadata, 

2594 ) 

2595 

2596 # Done; return the response. 

2597 return response 

2598 

2599 def delete_sink( 

2600 self, 

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

2602 *, 

2603 sink_name: Optional[str] = None, 

2604 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

2607 ) -> None: 

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

2609 then that service account is also deleted. 

2610 

2611 .. code-block:: python 

2612 

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

2614 # code template only. 

2615 # It will require modifications to work: 

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

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

2618 # client as shown in: 

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

2620 from google.cloud import logging_v2 

2621 

2622 def sample_delete_sink(): 

2623 # Create a client 

2624 client = logging_v2.ConfigServiceV2Client() 

2625 

2626 # Initialize request argument(s) 

2627 request = logging_v2.DeleteSinkRequest( 

2628 sink_name="sink_name_value", 

2629 ) 

2630 

2631 # Make the request 

2632 client.delete_sink(request=request) 

2633 

2634 Args: 

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

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

2637 sink_name (str): 

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

2639 including the parent resource and the sink identifier: 

2640 

2641 :: 

2642 

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

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

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

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

2647 

2648 For example: 

2649 

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

2651 

2652 This corresponds to the ``sink_name`` field 

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

2654 should not be set. 

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

2656 should be retried. 

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

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

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

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

2661 be of type `bytes`. 

2662 """ 

2663 # Create or coerce a protobuf request object. 

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

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

2666 flattened_params = [sink_name] 

2667 has_flattened_params = ( 

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

2669 ) 

2670 if request is not None and has_flattened_params: 

2671 raise ValueError( 

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

2673 "the individual field arguments should be set." 

2674 ) 

2675 

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

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

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

2679 request = logging_config.DeleteSinkRequest(request) 

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

2681 # request, apply these. 

2682 if sink_name is not None: 

2683 request.sink_name = sink_name 

2684 

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

2686 # and friendly error handling. 

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

2688 

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

2690 # add these here. 

2691 metadata = tuple(metadata) + ( 

2692 gapic_v1.routing_header.to_grpc_metadata( 

2693 (("sink_name", request.sink_name),) 

2694 ), 

2695 ) 

2696 

2697 # Validate the universe domain. 

2698 self._validate_universe_domain() 

2699 

2700 # Send the request. 

2701 rpc( 

2702 request, 

2703 retry=retry, 

2704 timeout=timeout, 

2705 metadata=metadata, 

2706 ) 

2707 

2708 def create_link( 

2709 self, 

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

2711 *, 

2712 parent: Optional[str] = None, 

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

2714 link_id: Optional[str] = None, 

2715 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

2718 ) -> operation.Operation: 

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

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

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

2722 only contain one link. 

2723 

2724 .. code-block:: python 

2725 

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

2727 # code template only. 

2728 # It will require modifications to work: 

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

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

2731 # client as shown in: 

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

2733 from google.cloud import logging_v2 

2734 

2735 def sample_create_link(): 

2736 # Create a client 

2737 client = logging_v2.ConfigServiceV2Client() 

2738 

2739 # Initialize request argument(s) 

2740 request = logging_v2.CreateLinkRequest( 

2741 parent="parent_value", 

2742 link_id="link_id_value", 

2743 ) 

2744 

2745 # Make the request 

2746 operation = client.create_link(request=request) 

2747 

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

2749 

2750 response = operation.result() 

2751 

2752 # Handle the response 

2753 print(response) 

2754 

2755 Args: 

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

2757 The request object. The parameters to CreateLink. 

2758 parent (str): 

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

2760 a link for. 

2761 

2762 :: 

2763 

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

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

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

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

2768 

2769 This corresponds to the ``parent`` field 

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

2771 should not be set. 

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

2773 Required. The new link. 

2774 This corresponds to the ``link`` field 

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

2776 should not be set. 

2777 link_id (str): 

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

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

2780 have alphanumeric characters and underscores within it. 

2781 

2782 This corresponds to the ``link_id`` field 

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

2784 should not be set. 

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

2786 should be retried. 

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

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

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

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

2791 be of type `bytes`. 

2792 

2793 Returns: 

2794 google.api_core.operation.Operation: 

2795 An object representing a long-running operation. 

2796 

2797 The result type for the operation will be 

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

2799 link connected to an analytics enabled bucket. 

2800 

2801 """ 

2802 # Create or coerce a protobuf request object. 

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

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

2805 flattened_params = [parent, link, link_id] 

2806 has_flattened_params = ( 

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

2808 ) 

2809 if request is not None and has_flattened_params: 

2810 raise ValueError( 

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

2812 "the individual field arguments should be set." 

2813 ) 

2814 

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

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

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

2818 request = logging_config.CreateLinkRequest(request) 

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

2820 # request, apply these. 

2821 if parent is not None: 

2822 request.parent = parent 

2823 if link is not None: 

2824 request.link = link 

2825 if link_id is not None: 

2826 request.link_id = link_id 

2827 

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

2829 # and friendly error handling. 

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

2831 

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

2833 # add these here. 

2834 metadata = tuple(metadata) + ( 

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

2836 ) 

2837 

2838 # Validate the universe domain. 

2839 self._validate_universe_domain() 

2840 

2841 # Send the request. 

2842 response = rpc( 

2843 request, 

2844 retry=retry, 

2845 timeout=timeout, 

2846 metadata=metadata, 

2847 ) 

2848 

2849 # Wrap the response in an operation future. 

2850 response = operation.from_gapic( 

2851 response, 

2852 self._transport.operations_client, 

2853 logging_config.Link, 

2854 metadata_type=logging_config.LinkMetadata, 

2855 ) 

2856 

2857 # Done; return the response. 

2858 return response 

2859 

2860 def delete_link( 

2861 self, 

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

2863 *, 

2864 name: Optional[str] = None, 

2865 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

2868 ) -> operation.Operation: 

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

2870 corresponding BigQuery linked dataset. 

2871 

2872 .. code-block:: python 

2873 

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

2875 # code template only. 

2876 # It will require modifications to work: 

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

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

2879 # client as shown in: 

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

2881 from google.cloud import logging_v2 

2882 

2883 def sample_delete_link(): 

2884 # Create a client 

2885 client = logging_v2.ConfigServiceV2Client() 

2886 

2887 # Initialize request argument(s) 

2888 request = logging_v2.DeleteLinkRequest( 

2889 name="name_value", 

2890 ) 

2891 

2892 # Make the request 

2893 operation = client.delete_link(request=request) 

2894 

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

2896 

2897 response = operation.result() 

2898 

2899 # Handle the response 

2900 print(response) 

2901 

2902 Args: 

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

2904 The request object. The parameters to DeleteLink. 

2905 name (str): 

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

2907 

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

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

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

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

2912 

2913 This corresponds to the ``name`` field 

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

2915 should not be set. 

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

2917 should be retried. 

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

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

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

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

2922 be of type `bytes`. 

2923 

2924 Returns: 

2925 google.api_core.operation.Operation: 

2926 An object representing a long-running operation. 

2927 

2928 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 

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

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

2931 method. For instance: 

2932 

2933 service Foo { 

2934 rpc Bar(google.protobuf.Empty) returns 

2935 (google.protobuf.Empty); 

2936 

2937 } 

2938 

2939 """ 

2940 # Create or coerce a protobuf request object. 

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

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

2943 flattened_params = [name] 

2944 has_flattened_params = ( 

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

2946 ) 

2947 if request is not None and has_flattened_params: 

2948 raise ValueError( 

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

2950 "the individual field arguments should be set." 

2951 ) 

2952 

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

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

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

2956 request = logging_config.DeleteLinkRequest(request) 

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

2958 # request, apply these. 

2959 if name is not None: 

2960 request.name = name 

2961 

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

2963 # and friendly error handling. 

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

2965 

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

2967 # add these here. 

2968 metadata = tuple(metadata) + ( 

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

2970 ) 

2971 

2972 # Validate the universe domain. 

2973 self._validate_universe_domain() 

2974 

2975 # Send the request. 

2976 response = rpc( 

2977 request, 

2978 retry=retry, 

2979 timeout=timeout, 

2980 metadata=metadata, 

2981 ) 

2982 

2983 # Wrap the response in an operation future. 

2984 response = operation.from_gapic( 

2985 response, 

2986 self._transport.operations_client, 

2987 empty_pb2.Empty, 

2988 metadata_type=logging_config.LinkMetadata, 

2989 ) 

2990 

2991 # Done; return the response. 

2992 return response 

2993 

2994 def list_links( 

2995 self, 

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

2997 *, 

2998 parent: Optional[str] = None, 

2999 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

3002 ) -> pagers.ListLinksPager: 

3003 r"""Lists links. 

3004 

3005 .. code-block:: python 

3006 

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

3008 # code template only. 

3009 # It will require modifications to work: 

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

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

3012 # client as shown in: 

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

3014 from google.cloud import logging_v2 

3015 

3016 def sample_list_links(): 

3017 # Create a client 

3018 client = logging_v2.ConfigServiceV2Client() 

3019 

3020 # Initialize request argument(s) 

3021 request = logging_v2.ListLinksRequest( 

3022 parent="parent_value", 

3023 ) 

3024 

3025 # Make the request 

3026 page_result = client.list_links(request=request) 

3027 

3028 # Handle the response 

3029 for response in page_result: 

3030 print(response) 

3031 

3032 Args: 

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

3034 The request object. The parameters to ListLinks. 

3035 parent (str): 

3036 Required. The parent resource whose links are to be 

3037 listed: 

3038 

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

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

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

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

3043 

3044 This corresponds to the ``parent`` field 

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

3046 should not be set. 

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

3048 should be retried. 

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

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

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

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

3053 be of type `bytes`. 

3054 

3055 Returns: 

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

3057 The response from ListLinks. 

3058 

3059 Iterating over this object will yield 

3060 results and resolve additional pages 

3061 automatically. 

3062 

3063 """ 

3064 # Create or coerce a protobuf request object. 

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

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

3067 flattened_params = [parent] 

3068 has_flattened_params = ( 

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

3070 ) 

3071 if request is not None and has_flattened_params: 

3072 raise ValueError( 

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

3074 "the individual field arguments should be set." 

3075 ) 

3076 

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

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

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

3080 request = logging_config.ListLinksRequest(request) 

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

3082 # request, apply these. 

3083 if parent is not None: 

3084 request.parent = parent 

3085 

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

3087 # and friendly error handling. 

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

3089 

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

3091 # add these here. 

3092 metadata = tuple(metadata) + ( 

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

3094 ) 

3095 

3096 # Validate the universe domain. 

3097 self._validate_universe_domain() 

3098 

3099 # Send the request. 

3100 response = rpc( 

3101 request, 

3102 retry=retry, 

3103 timeout=timeout, 

3104 metadata=metadata, 

3105 ) 

3106 

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

3108 # an `__iter__` convenience method. 

3109 response = pagers.ListLinksPager( 

3110 method=rpc, 

3111 request=request, 

3112 response=response, 

3113 retry=retry, 

3114 timeout=timeout, 

3115 metadata=metadata, 

3116 ) 

3117 

3118 # Done; return the response. 

3119 return response 

3120 

3121 def get_link( 

3122 self, 

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

3124 *, 

3125 name: Optional[str] = None, 

3126 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

3129 ) -> logging_config.Link: 

3130 r"""Gets a link. 

3131 

3132 .. code-block:: python 

3133 

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

3135 # code template only. 

3136 # It will require modifications to work: 

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

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

3139 # client as shown in: 

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

3141 from google.cloud import logging_v2 

3142 

3143 def sample_get_link(): 

3144 # Create a client 

3145 client = logging_v2.ConfigServiceV2Client() 

3146 

3147 # Initialize request argument(s) 

3148 request = logging_v2.GetLinkRequest( 

3149 name="name_value", 

3150 ) 

3151 

3152 # Make the request 

3153 response = client.get_link(request=request) 

3154 

3155 # Handle the response 

3156 print(response) 

3157 

3158 Args: 

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

3160 The request object. The parameters to GetLink. 

3161 name (str): 

3162 Required. The resource name of the link: 

3163 

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

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

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

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

3168 

3169 This corresponds to the ``name`` field 

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

3171 should not be set. 

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

3173 should be retried. 

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

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

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

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

3178 be of type `bytes`. 

3179 

3180 Returns: 

3181 google.cloud.logging_v2.types.Link: 

3182 Describes a link connected to an 

3183 analytics enabled bucket. 

3184 

3185 """ 

3186 # Create or coerce a protobuf request object. 

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

3188 # gotten any keyword arguments that map to the request. 

3189 flattened_params = [name] 

3190 has_flattened_params = ( 

3191 len([param for param in flattened_params if param is not None]) > 0 

3192 ) 

3193 if request is not None and has_flattened_params: 

3194 raise ValueError( 

3195 "If the `request` argument is set, then none of " 

3196 "the individual field arguments should be set." 

3197 ) 

3198 

3199 # - Use the request object if provided (there's no risk of modifying the input as 

3200 # there are no flattened fields), or create one. 

3201 if not isinstance(request, logging_config.GetLinkRequest): 

3202 request = logging_config.GetLinkRequest(request) 

3203 # If we have keyword arguments corresponding to fields on the 

3204 # request, apply these. 

3205 if name is not None: 

3206 request.name = name 

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.get_link] 

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((("name", request.name),)), 

3216 ) 

3217 

3218 # Validate the universe domain. 

3219 self._validate_universe_domain() 

3220 

3221 # Send the request. 

3222 response = rpc( 

3223 request, 

3224 retry=retry, 

3225 timeout=timeout, 

3226 metadata=metadata, 

3227 ) 

3228 

3229 # Done; return the response. 

3230 return response 

3231 

3232 def list_exclusions( 

3233 self, 

3234 request: Optional[Union[logging_config.ListExclusionsRequest, dict]] = None, 

3235 *, 

3236 parent: Optional[str] = None, 

3237 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3238 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

3239 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

3240 ) -> pagers.ListExclusionsPager: 

3241 r"""Lists all the exclusions on the \_Default sink in a parent 

3242 resource. 

3243 

3244 .. code-block:: python 

3245 

3246 # This snippet has been automatically generated and should be regarded as a 

3247 # code template only. 

3248 # It will require modifications to work: 

3249 # - It may require correct/in-range values for request initialization. 

3250 # - It may require specifying regional endpoints when creating the service 

3251 # client as shown in: 

3252 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

3253 from google.cloud import logging_v2 

3254 

3255 def sample_list_exclusions(): 

3256 # Create a client 

3257 client = logging_v2.ConfigServiceV2Client() 

3258 

3259 # Initialize request argument(s) 

3260 request = logging_v2.ListExclusionsRequest( 

3261 parent="parent_value", 

3262 ) 

3263 

3264 # Make the request 

3265 page_result = client.list_exclusions(request=request) 

3266 

3267 # Handle the response 

3268 for response in page_result: 

3269 print(response) 

3270 

3271 Args: 

3272 request (Union[google.cloud.logging_v2.types.ListExclusionsRequest, dict]): 

3273 The request object. The parameters to ``ListExclusions``. 

3274 parent (str): 

3275 Required. The parent resource whose exclusions are to be 

3276 listed. 

3277 

3278 :: 

3279 

3280 "projects/[PROJECT_ID]" 

3281 "organizations/[ORGANIZATION_ID]" 

3282 "billingAccounts/[BILLING_ACCOUNT_ID]" 

3283 "folders/[FOLDER_ID]" 

3284 

3285 This corresponds to the ``parent`` field 

3286 on the ``request`` instance; if ``request`` is provided, this 

3287 should not be set. 

3288 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

3289 should be retried. 

3290 timeout (float): The timeout for this request. 

3291 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

3292 sent along with the request as metadata. Normally, each value must be of type `str`, 

3293 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

3294 be of type `bytes`. 

3295 

3296 Returns: 

3297 google.cloud.logging_v2.services.config_service_v2.pagers.ListExclusionsPager: 

3298 Result returned from ListExclusions. 

3299 

3300 Iterating over this object will yield results and 

3301 resolve additional pages automatically. 

3302 

3303 """ 

3304 # Create or coerce a protobuf request object. 

3305 # - Quick check: If we got a request object, we should *not* have 

3306 # gotten any keyword arguments that map to the request. 

3307 flattened_params = [parent] 

3308 has_flattened_params = ( 

3309 len([param for param in flattened_params if param is not None]) > 0 

3310 ) 

3311 if request is not None and has_flattened_params: 

3312 raise ValueError( 

3313 "If the `request` argument is set, then none of " 

3314 "the individual field arguments should be set." 

3315 ) 

3316 

3317 # - Use the request object if provided (there's no risk of modifying the input as 

3318 # there are no flattened fields), or create one. 

3319 if not isinstance(request, logging_config.ListExclusionsRequest): 

3320 request = logging_config.ListExclusionsRequest(request) 

3321 # If we have keyword arguments corresponding to fields on the 

3322 # request, apply these. 

3323 if parent is not None: 

3324 request.parent = parent 

3325 

3326 # Wrap the RPC method; this adds retry and timeout information, 

3327 # and friendly error handling. 

3328 rpc = self._transport._wrapped_methods[self._transport.list_exclusions] 

3329 

3330 # Certain fields should be provided within the metadata header; 

3331 # add these here. 

3332 metadata = tuple(metadata) + ( 

3333 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), 

3334 ) 

3335 

3336 # Validate the universe domain. 

3337 self._validate_universe_domain() 

3338 

3339 # Send the request. 

3340 response = rpc( 

3341 request, 

3342 retry=retry, 

3343 timeout=timeout, 

3344 metadata=metadata, 

3345 ) 

3346 

3347 # This method is paged; wrap the response in a pager, which provides 

3348 # an `__iter__` convenience method. 

3349 response = pagers.ListExclusionsPager( 

3350 method=rpc, 

3351 request=request, 

3352 response=response, 

3353 retry=retry, 

3354 timeout=timeout, 

3355 metadata=metadata, 

3356 ) 

3357 

3358 # Done; return the response. 

3359 return response 

3360 

3361 def get_exclusion( 

3362 self, 

3363 request: Optional[Union[logging_config.GetExclusionRequest, dict]] = None, 

3364 *, 

3365 name: Optional[str] = None, 

3366 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3367 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

3368 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

3369 ) -> logging_config.LogExclusion: 

3370 r"""Gets the description of an exclusion in the \_Default sink. 

3371 

3372 .. code-block:: python 

3373 

3374 # This snippet has been automatically generated and should be regarded as a 

3375 # code template only. 

3376 # It will require modifications to work: 

3377 # - It may require correct/in-range values for request initialization. 

3378 # - It may require specifying regional endpoints when creating the service 

3379 # client as shown in: 

3380 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

3381 from google.cloud import logging_v2 

3382 

3383 def sample_get_exclusion(): 

3384 # Create a client 

3385 client = logging_v2.ConfigServiceV2Client() 

3386 

3387 # Initialize request argument(s) 

3388 request = logging_v2.GetExclusionRequest( 

3389 name="name_value", 

3390 ) 

3391 

3392 # Make the request 

3393 response = client.get_exclusion(request=request) 

3394 

3395 # Handle the response 

3396 print(response) 

3397 

3398 Args: 

3399 request (Union[google.cloud.logging_v2.types.GetExclusionRequest, dict]): 

3400 The request object. The parameters to ``GetExclusion``. 

3401 name (str): 

3402 Required. The resource name of an existing exclusion: 

3403 

3404 :: 

3405 

3406 "projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" 

3407 "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" 

3408 "billingAccounts/[BILLING_ACCOUNT_ID]/exclusions/[EXCLUSION_ID]" 

3409 "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]" 

3410 

3411 For example: 

3412 

3413 ``"projects/my-project/exclusions/my-exclusion"`` 

3414 

3415 This corresponds to the ``name`` field 

3416 on the ``request`` instance; if ``request`` is provided, this 

3417 should not be set. 

3418 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

3419 should be retried. 

3420 timeout (float): The timeout for this request. 

3421 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

3422 sent along with the request as metadata. Normally, each value must be of type `str`, 

3423 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

3424 be of type `bytes`. 

3425 

3426 Returns: 

3427 google.cloud.logging_v2.types.LogExclusion: 

3428 Specifies a set of log entries that are filtered out by a sink. If 

3429 your Google Cloud resource receives a large volume of 

3430 log entries, you can use exclusions to reduce your 

3431 chargeable logs. Note that exclusions on 

3432 organization-level and folder-level sinks don't apply 

3433 to child resources. Note also that you cannot modify 

3434 the \_Required sink or exclude logs from it. 

3435 

3436 """ 

3437 # Create or coerce a protobuf request object. 

3438 # - Quick check: If we got a request object, we should *not* have 

3439 # gotten any keyword arguments that map to the request. 

3440 flattened_params = [name] 

3441 has_flattened_params = ( 

3442 len([param for param in flattened_params if param is not None]) > 0 

3443 ) 

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 # - Use the request object if provided (there's no risk of modifying the input as 

3451 # there are no flattened fields), or create one. 

3452 if not isinstance(request, logging_config.GetExclusionRequest): 

3453 request = logging_config.GetExclusionRequest(request) 

3454 # If we have keyword arguments corresponding to fields on the 

3455 # request, apply these. 

3456 if name is not None: 

3457 request.name = name 

3458 

3459 # Wrap the RPC method; this adds retry and timeout information, 

3460 # and friendly error handling. 

3461 rpc = self._transport._wrapped_methods[self._transport.get_exclusion] 

3462 

3463 # Certain fields should be provided within the metadata header; 

3464 # add these here. 

3465 metadata = tuple(metadata) + ( 

3466 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

3467 ) 

3468 

3469 # Validate the universe domain. 

3470 self._validate_universe_domain() 

3471 

3472 # Send the request. 

3473 response = rpc( 

3474 request, 

3475 retry=retry, 

3476 timeout=timeout, 

3477 metadata=metadata, 

3478 ) 

3479 

3480 # Done; return the response. 

3481 return response 

3482 

3483 def create_exclusion( 

3484 self, 

3485 request: Optional[Union[logging_config.CreateExclusionRequest, dict]] = None, 

3486 *, 

3487 parent: Optional[str] = None, 

3488 exclusion: Optional[logging_config.LogExclusion] = None, 

3489 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3490 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

3491 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

3492 ) -> logging_config.LogExclusion: 

3493 r"""Creates a new exclusion in the \_Default sink in a specified 

3494 parent resource. Only log entries belonging to that resource can 

3495 be excluded. You can have up to 10 exclusions in a resource. 

3496 

3497 .. code-block:: python 

3498 

3499 # This snippet has been automatically generated and should be regarded as a 

3500 # code template only. 

3501 # It will require modifications to work: 

3502 # - It may require correct/in-range values for request initialization. 

3503 # - It may require specifying regional endpoints when creating the service 

3504 # client as shown in: 

3505 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

3506 from google.cloud import logging_v2 

3507 

3508 def sample_create_exclusion(): 

3509 # Create a client 

3510 client = logging_v2.ConfigServiceV2Client() 

3511 

3512 # Initialize request argument(s) 

3513 exclusion = logging_v2.LogExclusion() 

3514 exclusion.name = "name_value" 

3515 exclusion.filter = "filter_value" 

3516 

3517 request = logging_v2.CreateExclusionRequest( 

3518 parent="parent_value", 

3519 exclusion=exclusion, 

3520 ) 

3521 

3522 # Make the request 

3523 response = client.create_exclusion(request=request) 

3524 

3525 # Handle the response 

3526 print(response) 

3527 

3528 Args: 

3529 request (Union[google.cloud.logging_v2.types.CreateExclusionRequest, dict]): 

3530 The request object. The parameters to ``CreateExclusion``. 

3531 parent (str): 

3532 Required. The parent resource in which to create the 

3533 exclusion: 

3534 

3535 :: 

3536 

3537 "projects/[PROJECT_ID]" 

3538 "organizations/[ORGANIZATION_ID]" 

3539 "billingAccounts/[BILLING_ACCOUNT_ID]" 

3540 "folders/[FOLDER_ID]" 

3541 

3542 For examples: 

3543 

3544 ``"projects/my-logging-project"`` 

3545 ``"organizations/123456789"`` 

3546 

3547 This corresponds to the ``parent`` field 

3548 on the ``request`` instance; if ``request`` is provided, this 

3549 should not be set. 

3550 exclusion (google.cloud.logging_v2.types.LogExclusion): 

3551 Required. The new exclusion, whose ``name`` parameter is 

3552 an exclusion name that is not already used in the parent 

3553 resource. 

3554 

3555 This corresponds to the ``exclusion`` field 

3556 on the ``request`` instance; if ``request`` is provided, this 

3557 should not be set. 

3558 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

3559 should be retried. 

3560 timeout (float): The timeout for this request. 

3561 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

3562 sent along with the request as metadata. Normally, each value must be of type `str`, 

3563 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

3564 be of type `bytes`. 

3565 

3566 Returns: 

3567 google.cloud.logging_v2.types.LogExclusion: 

3568 Specifies a set of log entries that are filtered out by a sink. If 

3569 your Google Cloud resource receives a large volume of 

3570 log entries, you can use exclusions to reduce your 

3571 chargeable logs. Note that exclusions on 

3572 organization-level and folder-level sinks don't apply 

3573 to child resources. Note also that you cannot modify 

3574 the \_Required sink or exclude logs from it. 

3575 

3576 """ 

3577 # Create or coerce a protobuf request object. 

3578 # - Quick check: If we got a request object, we should *not* have 

3579 # gotten any keyword arguments that map to the request. 

3580 flattened_params = [parent, exclusion] 

3581 has_flattened_params = ( 

3582 len([param for param in flattened_params if param is not None]) > 0 

3583 ) 

3584 if request is not None and has_flattened_params: 

3585 raise ValueError( 

3586 "If the `request` argument is set, then none of " 

3587 "the individual field arguments should be set." 

3588 ) 

3589 

3590 # - Use the request object if provided (there's no risk of modifying the input as 

3591 # there are no flattened fields), or create one. 

3592 if not isinstance(request, logging_config.CreateExclusionRequest): 

3593 request = logging_config.CreateExclusionRequest(request) 

3594 # If we have keyword arguments corresponding to fields on the 

3595 # request, apply these. 

3596 if parent is not None: 

3597 request.parent = parent 

3598 if exclusion is not None: 

3599 request.exclusion = exclusion 

3600 

3601 # Wrap the RPC method; this adds retry and timeout information, 

3602 # and friendly error handling. 

3603 rpc = self._transport._wrapped_methods[self._transport.create_exclusion] 

3604 

3605 # Certain fields should be provided within the metadata header; 

3606 # add these here. 

3607 metadata = tuple(metadata) + ( 

3608 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), 

3609 ) 

3610 

3611 # Validate the universe domain. 

3612 self._validate_universe_domain() 

3613 

3614 # Send the request. 

3615 response = rpc( 

3616 request, 

3617 retry=retry, 

3618 timeout=timeout, 

3619 metadata=metadata, 

3620 ) 

3621 

3622 # Done; return the response. 

3623 return response 

3624 

3625 def update_exclusion( 

3626 self, 

3627 request: Optional[Union[logging_config.UpdateExclusionRequest, dict]] = None, 

3628 *, 

3629 name: Optional[str] = None, 

3630 exclusion: Optional[logging_config.LogExclusion] = None, 

3631 update_mask: Optional[field_mask_pb2.FieldMask] = None, 

3632 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3633 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

3634 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

3635 ) -> logging_config.LogExclusion: 

3636 r"""Changes one or more properties of an existing exclusion in the 

3637 \_Default sink. 

3638 

3639 .. code-block:: python 

3640 

3641 # This snippet has been automatically generated and should be regarded as a 

3642 # code template only. 

3643 # It will require modifications to work: 

3644 # - It may require correct/in-range values for request initialization. 

3645 # - It may require specifying regional endpoints when creating the service 

3646 # client as shown in: 

3647 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

3648 from google.cloud import logging_v2 

3649 

3650 def sample_update_exclusion(): 

3651 # Create a client 

3652 client = logging_v2.ConfigServiceV2Client() 

3653 

3654 # Initialize request argument(s) 

3655 exclusion = logging_v2.LogExclusion() 

3656 exclusion.name = "name_value" 

3657 exclusion.filter = "filter_value" 

3658 

3659 request = logging_v2.UpdateExclusionRequest( 

3660 name="name_value", 

3661 exclusion=exclusion, 

3662 ) 

3663 

3664 # Make the request 

3665 response = client.update_exclusion(request=request) 

3666 

3667 # Handle the response 

3668 print(response) 

3669 

3670 Args: 

3671 request (Union[google.cloud.logging_v2.types.UpdateExclusionRequest, dict]): 

3672 The request object. The parameters to ``UpdateExclusion``. 

3673 name (str): 

3674 Required. The resource name of the exclusion to update: 

3675 

3676 :: 

3677 

3678 "projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" 

3679 "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" 

3680 "billingAccounts/[BILLING_ACCOUNT_ID]/exclusions/[EXCLUSION_ID]" 

3681 "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]" 

3682 

3683 For example: 

3684 

3685 ``"projects/my-project/exclusions/my-exclusion"`` 

3686 

3687 This corresponds to the ``name`` field 

3688 on the ``request`` instance; if ``request`` is provided, this 

3689 should not be set. 

3690 exclusion (google.cloud.logging_v2.types.LogExclusion): 

3691 Required. New values for the existing exclusion. Only 

3692 the fields specified in ``update_mask`` are relevant. 

3693 

3694 This corresponds to the ``exclusion`` field 

3695 on the ``request`` instance; if ``request`` is provided, this 

3696 should not be set. 

3697 update_mask (google.protobuf.field_mask_pb2.FieldMask): 

3698 Required. A non-empty list of fields to change in the 

3699 existing exclusion. New values for the fields are taken 

3700 from the corresponding fields in the 

3701 [LogExclusion][google.logging.v2.LogExclusion] included 

3702 in this request. Fields not mentioned in ``update_mask`` 

3703 are not changed and are ignored in the request. 

3704 

3705 For example, to change the filter and description of an 

3706 exclusion, specify an ``update_mask`` of 

3707 ``"filter,description"``. 

3708 

3709 This corresponds to the ``update_mask`` field 

3710 on the ``request`` instance; if ``request`` is provided, this 

3711 should not be set. 

3712 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

3713 should be retried. 

3714 timeout (float): The timeout for this request. 

3715 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

3716 sent along with the request as metadata. Normally, each value must be of type `str`, 

3717 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

3718 be of type `bytes`. 

3719 

3720 Returns: 

3721 google.cloud.logging_v2.types.LogExclusion: 

3722 Specifies a set of log entries that are filtered out by a sink. If 

3723 your Google Cloud resource receives a large volume of 

3724 log entries, you can use exclusions to reduce your 

3725 chargeable logs. Note that exclusions on 

3726 organization-level and folder-level sinks don't apply 

3727 to child resources. Note also that you cannot modify 

3728 the \_Required sink or exclude logs from it. 

3729 

3730 """ 

3731 # Create or coerce a protobuf request object. 

3732 # - Quick check: If we got a request object, we should *not* have 

3733 # gotten any keyword arguments that map to the request. 

3734 flattened_params = [name, exclusion, update_mask] 

3735 has_flattened_params = ( 

3736 len([param for param in flattened_params if param is not None]) > 0 

3737 ) 

3738 if request is not None and has_flattened_params: 

3739 raise ValueError( 

3740 "If the `request` argument is set, then none of " 

3741 "the individual field arguments should be set." 

3742 ) 

3743 

3744 # - Use the request object if provided (there's no risk of modifying the input as 

3745 # there are no flattened fields), or create one. 

3746 if not isinstance(request, logging_config.UpdateExclusionRequest): 

3747 request = logging_config.UpdateExclusionRequest(request) 

3748 # If we have keyword arguments corresponding to fields on the 

3749 # request, apply these. 

3750 if name is not None: 

3751 request.name = name 

3752 if exclusion is not None: 

3753 request.exclusion = exclusion 

3754 if update_mask is not None: 

3755 request.update_mask = update_mask 

3756 

3757 # Wrap the RPC method; this adds retry and timeout information, 

3758 # and friendly error handling. 

3759 rpc = self._transport._wrapped_methods[self._transport.update_exclusion] 

3760 

3761 # Certain fields should be provided within the metadata header; 

3762 # add these here. 

3763 metadata = tuple(metadata) + ( 

3764 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

3765 ) 

3766 

3767 # Validate the universe domain. 

3768 self._validate_universe_domain() 

3769 

3770 # Send the request. 

3771 response = rpc( 

3772 request, 

3773 retry=retry, 

3774 timeout=timeout, 

3775 metadata=metadata, 

3776 ) 

3777 

3778 # Done; return the response. 

3779 return response 

3780 

3781 def delete_exclusion( 

3782 self, 

3783 request: Optional[Union[logging_config.DeleteExclusionRequest, dict]] = None, 

3784 *, 

3785 name: Optional[str] = None, 

3786 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3787 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

3788 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

3789 ) -> None: 

3790 r"""Deletes an exclusion in the \_Default sink. 

3791 

3792 .. code-block:: python 

3793 

3794 # This snippet has been automatically generated and should be regarded as a 

3795 # code template only. 

3796 # It will require modifications to work: 

3797 # - It may require correct/in-range values for request initialization. 

3798 # - It may require specifying regional endpoints when creating the service 

3799 # client as shown in: 

3800 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

3801 from google.cloud import logging_v2 

3802 

3803 def sample_delete_exclusion(): 

3804 # Create a client 

3805 client = logging_v2.ConfigServiceV2Client() 

3806 

3807 # Initialize request argument(s) 

3808 request = logging_v2.DeleteExclusionRequest( 

3809 name="name_value", 

3810 ) 

3811 

3812 # Make the request 

3813 client.delete_exclusion(request=request) 

3814 

3815 Args: 

3816 request (Union[google.cloud.logging_v2.types.DeleteExclusionRequest, dict]): 

3817 The request object. The parameters to ``DeleteExclusion``. 

3818 name (str): 

3819 Required. The resource name of an existing exclusion to 

3820 delete: 

3821 

3822 :: 

3823 

3824 "projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" 

3825 "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" 

3826 "billingAccounts/[BILLING_ACCOUNT_ID]/exclusions/[EXCLUSION_ID]" 

3827 "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]" 

3828 

3829 For example: 

3830 

3831 ``"projects/my-project/exclusions/my-exclusion"`` 

3832 

3833 This corresponds to the ``name`` field 

3834 on the ``request`` instance; if ``request`` is provided, this 

3835 should not be set. 

3836 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

3837 should be retried. 

3838 timeout (float): The timeout for this request. 

3839 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

3840 sent along with the request as metadata. Normally, each value must be of type `str`, 

3841 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

3842 be of type `bytes`. 

3843 """ 

3844 # Create or coerce a protobuf request object. 

3845 # - Quick check: If we got a request object, we should *not* have 

3846 # gotten any keyword arguments that map to the request. 

3847 flattened_params = [name] 

3848 has_flattened_params = ( 

3849 len([param for param in flattened_params if param is not None]) > 0 

3850 ) 

3851 if request is not None and has_flattened_params: 

3852 raise ValueError( 

3853 "If the `request` argument is set, then none of " 

3854 "the individual field arguments should be set." 

3855 ) 

3856 

3857 # - Use the request object if provided (there's no risk of modifying the input as 

3858 # there are no flattened fields), or create one. 

3859 if not isinstance(request, logging_config.DeleteExclusionRequest): 

3860 request = logging_config.DeleteExclusionRequest(request) 

3861 # If we have keyword arguments corresponding to fields on the 

3862 # request, apply these. 

3863 if name is not None: 

3864 request.name = name 

3865 

3866 # Wrap the RPC method; this adds retry and timeout information, 

3867 # and friendly error handling. 

3868 rpc = self._transport._wrapped_methods[self._transport.delete_exclusion] 

3869 

3870 # Certain fields should be provided within the metadata header; 

3871 # add these here. 

3872 metadata = tuple(metadata) + ( 

3873 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

3874 ) 

3875 

3876 # Validate the universe domain. 

3877 self._validate_universe_domain() 

3878 

3879 # Send the request. 

3880 rpc( 

3881 request, 

3882 retry=retry, 

3883 timeout=timeout, 

3884 metadata=metadata, 

3885 ) 

3886 

3887 def get_cmek_settings( 

3888 self, 

3889 request: Optional[Union[logging_config.GetCmekSettingsRequest, dict]] = None, 

3890 *, 

3891 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3892 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

3893 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

3894 ) -> logging_config.CmekSettings: 

3895 r"""Gets the Logging CMEK settings for the given resource. 

3896 

3897 Note: CMEK for the Log Router can be configured for Google Cloud 

3898 projects, folders, organizations and billing accounts. Once 

3899 configured for an organization, it applies to all projects and 

3900 folders in the Google Cloud organization. 

3901 

3902 See `Enabling CMEK for Log 

3903 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__ 

3904 for more information. 

3905 

3906 .. code-block:: python 

3907 

3908 # This snippet has been automatically generated and should be regarded as a 

3909 # code template only. 

3910 # It will require modifications to work: 

3911 # - It may require correct/in-range values for request initialization. 

3912 # - It may require specifying regional endpoints when creating the service 

3913 # client as shown in: 

3914 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

3915 from google.cloud import logging_v2 

3916 

3917 def sample_get_cmek_settings(): 

3918 # Create a client 

3919 client = logging_v2.ConfigServiceV2Client() 

3920 

3921 # Initialize request argument(s) 

3922 request = logging_v2.GetCmekSettingsRequest( 

3923 name="name_value", 

3924 ) 

3925 

3926 # Make the request 

3927 response = client.get_cmek_settings(request=request) 

3928 

3929 # Handle the response 

3930 print(response) 

3931 

3932 Args: 

3933 request (Union[google.cloud.logging_v2.types.GetCmekSettingsRequest, dict]): 

3934 The request object. The parameters to 

3935 [GetCmekSettings][google.logging.v2.ConfigServiceV2.GetCmekSettings]. 

3936 

3937 See `Enabling CMEK for Log 

3938 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__ 

3939 for more information. 

3940 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

3941 should be retried. 

3942 timeout (float): The timeout for this request. 

3943 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

3944 sent along with the request as metadata. Normally, each value must be of type `str`, 

3945 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

3946 be of type `bytes`. 

3947 

3948 Returns: 

3949 google.cloud.logging_v2.types.CmekSettings: 

3950 Describes the customer-managed encryption key (CMEK) settings associated with 

3951 a project, folder, organization, billing account, or 

3952 flexible resource. 

3953 

3954 Note: CMEK for the Log Router can currently only be 

3955 configured for Google Cloud organizations. Once 

3956 configured, it applies to all projects and folders in 

3957 the Google Cloud organization. 

3958 

3959 See [Enabling CMEK for Log 

3960 Router](\ https://cloud.google.com/logging/docs/routing/managed-encryption) 

3961 for more information. 

3962 

3963 """ 

3964 # Create or coerce a protobuf request object. 

3965 # - Use the request object if provided (there's no risk of modifying the input as 

3966 # there are no flattened fields), or create one. 

3967 if not isinstance(request, logging_config.GetCmekSettingsRequest): 

3968 request = logging_config.GetCmekSettingsRequest(request) 

3969 

3970 # Wrap the RPC method; this adds retry and timeout information, 

3971 # and friendly error handling. 

3972 rpc = self._transport._wrapped_methods[self._transport.get_cmek_settings] 

3973 

3974 # Certain fields should be provided within the metadata header; 

3975 # add these here. 

3976 metadata = tuple(metadata) + ( 

3977 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

3978 ) 

3979 

3980 # Validate the universe domain. 

3981 self._validate_universe_domain() 

3982 

3983 # Send the request. 

3984 response = rpc( 

3985 request, 

3986 retry=retry, 

3987 timeout=timeout, 

3988 metadata=metadata, 

3989 ) 

3990 

3991 # Done; return the response. 

3992 return response 

3993 

3994 def update_cmek_settings( 

3995 self, 

3996 request: Optional[Union[logging_config.UpdateCmekSettingsRequest, dict]] = None, 

3997 *, 

3998 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3999 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

4000 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

4001 ) -> logging_config.CmekSettings: 

4002 r"""Updates the Log Router CMEK settings for the given resource. 

4003 

4004 Note: CMEK for the Log Router can currently only be configured 

4005 for Google Cloud organizations. Once configured, it applies to 

4006 all projects and folders in the Google Cloud organization. 

4007 

4008 [UpdateCmekSettings][google.logging.v2.ConfigServiceV2.UpdateCmekSettings] 

4009 will fail if 1) ``kms_key_name`` is invalid, or 2) the 

4010 associated service account does not have the required 

4011 ``roles/cloudkms.cryptoKeyEncrypterDecrypter`` role assigned for 

4012 the key, or 3) access to the key is disabled. 

4013 

4014 See `Enabling CMEK for Log 

4015 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__ 

4016 for more information. 

4017 

4018 .. code-block:: python 

4019 

4020 # This snippet has been automatically generated and should be regarded as a 

4021 # code template only. 

4022 # It will require modifications to work: 

4023 # - It may require correct/in-range values for request initialization. 

4024 # - It may require specifying regional endpoints when creating the service 

4025 # client as shown in: 

4026 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

4027 from google.cloud import logging_v2 

4028 

4029 def sample_update_cmek_settings(): 

4030 # Create a client 

4031 client = logging_v2.ConfigServiceV2Client() 

4032 

4033 # Initialize request argument(s) 

4034 request = logging_v2.UpdateCmekSettingsRequest( 

4035 name="name_value", 

4036 ) 

4037 

4038 # Make the request 

4039 response = client.update_cmek_settings(request=request) 

4040 

4041 # Handle the response 

4042 print(response) 

4043 

4044 Args: 

4045 request (Union[google.cloud.logging_v2.types.UpdateCmekSettingsRequest, dict]): 

4046 The request object. The parameters to 

4047 [UpdateCmekSettings][google.logging.v2.ConfigServiceV2.UpdateCmekSettings]. 

4048 

4049 See `Enabling CMEK for Log 

4050 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__ 

4051 for more information. 

4052 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

4053 should be retried. 

4054 timeout (float): The timeout for this request. 

4055 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

4056 sent along with the request as metadata. Normally, each value must be of type `str`, 

4057 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

4058 be of type `bytes`. 

4059 

4060 Returns: 

4061 google.cloud.logging_v2.types.CmekSettings: 

4062 Describes the customer-managed encryption key (CMEK) settings associated with 

4063 a project, folder, organization, billing account, or 

4064 flexible resource. 

4065 

4066 Note: CMEK for the Log Router can currently only be 

4067 configured for Google Cloud organizations. Once 

4068 configured, it applies to all projects and folders in 

4069 the Google Cloud organization. 

4070 

4071 See [Enabling CMEK for Log 

4072 Router](\ https://cloud.google.com/logging/docs/routing/managed-encryption) 

4073 for more information. 

4074 

4075 """ 

4076 # Create or coerce a protobuf request object. 

4077 # - Use the request object if provided (there's no risk of modifying the input as 

4078 # there are no flattened fields), or create one. 

4079 if not isinstance(request, logging_config.UpdateCmekSettingsRequest): 

4080 request = logging_config.UpdateCmekSettingsRequest(request) 

4081 

4082 # Wrap the RPC method; this adds retry and timeout information, 

4083 # and friendly error handling. 

4084 rpc = self._transport._wrapped_methods[self._transport.update_cmek_settings] 

4085 

4086 # Certain fields should be provided within the metadata header; 

4087 # add these here. 

4088 metadata = tuple(metadata) + ( 

4089 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

4090 ) 

4091 

4092 # Validate the universe domain. 

4093 self._validate_universe_domain() 

4094 

4095 # Send the request. 

4096 response = rpc( 

4097 request, 

4098 retry=retry, 

4099 timeout=timeout, 

4100 metadata=metadata, 

4101 ) 

4102 

4103 # Done; return the response. 

4104 return response 

4105 

4106 def get_settings( 

4107 self, 

4108 request: Optional[Union[logging_config.GetSettingsRequest, dict]] = None, 

4109 *, 

4110 name: Optional[str] = None, 

4111 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

4112 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

4113 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

4114 ) -> logging_config.Settings: 

4115 r"""Gets the Log Router settings for the given resource. 

4116 

4117 Note: Settings for the Log Router can be get for Google Cloud 

4118 projects, folders, organizations and billing accounts. Currently 

4119 it can only be configured for organizations. Once configured for 

4120 an organization, it applies to all projects and folders in the 

4121 Google Cloud organization. 

4122 

4123 See `Enabling CMEK for Log 

4124 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__ 

4125 for more information. 

4126 

4127 .. code-block:: python 

4128 

4129 # This snippet has been automatically generated and should be regarded as a 

4130 # code template only. 

4131 # It will require modifications to work: 

4132 # - It may require correct/in-range values for request initialization. 

4133 # - It may require specifying regional endpoints when creating the service 

4134 # client as shown in: 

4135 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

4136 from google.cloud import logging_v2 

4137 

4138 def sample_get_settings(): 

4139 # Create a client 

4140 client = logging_v2.ConfigServiceV2Client() 

4141 

4142 # Initialize request argument(s) 

4143 request = logging_v2.GetSettingsRequest( 

4144 name="name_value", 

4145 ) 

4146 

4147 # Make the request 

4148 response = client.get_settings(request=request) 

4149 

4150 # Handle the response 

4151 print(response) 

4152 

4153 Args: 

4154 request (Union[google.cloud.logging_v2.types.GetSettingsRequest, dict]): 

4155 The request object. The parameters to 

4156 [GetSettings][google.logging.v2.ConfigServiceV2.GetSettings]. 

4157 

4158 See `Enabling CMEK for Log 

4159 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__ 

4160 for more information. 

4161 name (str): 

4162 Required. The resource for which to retrieve settings. 

4163 

4164 :: 

4165 

4166 "projects/[PROJECT_ID]/settings" 

4167 "organizations/[ORGANIZATION_ID]/settings" 

4168 "billingAccounts/[BILLING_ACCOUNT_ID]/settings" 

4169 "folders/[FOLDER_ID]/settings" 

4170 

4171 For example: 

4172 

4173 ``"organizations/12345/settings"`` 

4174 

4175 Note: Settings for the Log Router can be get for Google 

4176 Cloud projects, folders, organizations and billing 

4177 accounts. Currently it can only be configured for 

4178 organizations. Once configured for an organization, it 

4179 applies to all projects and folders in the Google Cloud 

4180 organization. 

4181 

4182 This corresponds to the ``name`` field 

4183 on the ``request`` instance; if ``request`` is provided, this 

4184 should not be set. 

4185 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

4186 should be retried. 

4187 timeout (float): The timeout for this request. 

4188 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

4189 sent along with the request as metadata. Normally, each value must be of type `str`, 

4190 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

4191 be of type `bytes`. 

4192 

4193 Returns: 

4194 google.cloud.logging_v2.types.Settings: 

4195 Describes the settings associated 

4196 with a project, folder, organization, 

4197 billing account, or flexible resource. 

4198 

4199 """ 

4200 # Create or coerce a protobuf request object. 

4201 # - Quick check: If we got a request object, we should *not* have 

4202 # gotten any keyword arguments that map to the request. 

4203 flattened_params = [name] 

4204 has_flattened_params = ( 

4205 len([param for param in flattened_params if param is not None]) > 0 

4206 ) 

4207 if request is not None and has_flattened_params: 

4208 raise ValueError( 

4209 "If the `request` argument is set, then none of " 

4210 "the individual field arguments should be set." 

4211 ) 

4212 

4213 # - Use the request object if provided (there's no risk of modifying the input as 

4214 # there are no flattened fields), or create one. 

4215 if not isinstance(request, logging_config.GetSettingsRequest): 

4216 request = logging_config.GetSettingsRequest(request) 

4217 # If we have keyword arguments corresponding to fields on the 

4218 # request, apply these. 

4219 if name is not None: 

4220 request.name = name 

4221 

4222 # Wrap the RPC method; this adds retry and timeout information, 

4223 # and friendly error handling. 

4224 rpc = self._transport._wrapped_methods[self._transport.get_settings] 

4225 

4226 # Certain fields should be provided within the metadata header; 

4227 # add these here. 

4228 metadata = tuple(metadata) + ( 

4229 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

4230 ) 

4231 

4232 # Validate the universe domain. 

4233 self._validate_universe_domain() 

4234 

4235 # Send the request. 

4236 response = rpc( 

4237 request, 

4238 retry=retry, 

4239 timeout=timeout, 

4240 metadata=metadata, 

4241 ) 

4242 

4243 # Done; return the response. 

4244 return response 

4245 

4246 def update_settings( 

4247 self, 

4248 request: Optional[Union[logging_config.UpdateSettingsRequest, dict]] = None, 

4249 *, 

4250 settings: Optional[logging_config.Settings] = None, 

4251 update_mask: Optional[field_mask_pb2.FieldMask] = None, 

4252 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

4253 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

4254 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

4255 ) -> logging_config.Settings: 

4256 r"""Updates the Log Router settings for the given resource. 

4257 

4258 Note: Settings for the Log Router can currently only be 

4259 configured for Google Cloud organizations. Once configured, it 

4260 applies to all projects and folders in the Google Cloud 

4261 organization. 

4262 

4263 [UpdateSettings][google.logging.v2.ConfigServiceV2.UpdateSettings] 

4264 will fail if 1) ``kms_key_name`` is invalid, or 2) the 

4265 associated service account does not have the required 

4266 ``roles/cloudkms.cryptoKeyEncrypterDecrypter`` role assigned for 

4267 the key, or 3) access to the key is disabled. 4) ``location_id`` 

4268 is not supported by Logging. 5) ``location_id`` violate 

4269 OrgPolicy. 

4270 

4271 See `Enabling CMEK for Log 

4272 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__ 

4273 for more information. 

4274 

4275 .. code-block:: python 

4276 

4277 # This snippet has been automatically generated and should be regarded as a 

4278 # code template only. 

4279 # It will require modifications to work: 

4280 # - It may require correct/in-range values for request initialization. 

4281 # - It may require specifying regional endpoints when creating the service 

4282 # client as shown in: 

4283 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

4284 from google.cloud import logging_v2 

4285 

4286 def sample_update_settings(): 

4287 # Create a client 

4288 client = logging_v2.ConfigServiceV2Client() 

4289 

4290 # Initialize request argument(s) 

4291 request = logging_v2.UpdateSettingsRequest( 

4292 name="name_value", 

4293 ) 

4294 

4295 # Make the request 

4296 response = client.update_settings(request=request) 

4297 

4298 # Handle the response 

4299 print(response) 

4300 

4301 Args: 

4302 request (Union[google.cloud.logging_v2.types.UpdateSettingsRequest, dict]): 

4303 The request object. The parameters to 

4304 [UpdateSettings][google.logging.v2.ConfigServiceV2.UpdateSettings]. 

4305 

4306 See `Enabling CMEK for Log 

4307 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__ 

4308 for more information. 

4309 settings (google.cloud.logging_v2.types.Settings): 

4310 Required. The settings to update. 

4311 

4312 See `Enabling CMEK for Log 

4313 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__ 

4314 for more information. 

4315 

4316 This corresponds to the ``settings`` field 

4317 on the ``request`` instance; if ``request`` is provided, this 

4318 should not be set. 

4319 update_mask (google.protobuf.field_mask_pb2.FieldMask): 

4320 Optional. Field mask identifying which fields from 

4321 ``settings`` should be updated. A field will be 

4322 overwritten if and only if it is in the update mask. 

4323 Output only fields cannot be updated. 

4324 

4325 See [FieldMask][google.protobuf.FieldMask] for more 

4326 information. 

4327 

4328 For example: ``"updateMask=kmsKeyName"`` 

4329 

4330 This corresponds to the ``update_mask`` field 

4331 on the ``request`` instance; if ``request`` is provided, this 

4332 should not be set. 

4333 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

4334 should be retried. 

4335 timeout (float): The timeout for this request. 

4336 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

4337 sent along with the request as metadata. Normally, each value must be of type `str`, 

4338 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

4339 be of type `bytes`. 

4340 

4341 Returns: 

4342 google.cloud.logging_v2.types.Settings: 

4343 Describes the settings associated 

4344 with a project, folder, organization, 

4345 billing account, or flexible resource. 

4346 

4347 """ 

4348 # Create or coerce a protobuf request object. 

4349 # - Quick check: If we got a request object, we should *not* have 

4350 # gotten any keyword arguments that map to the request. 

4351 flattened_params = [settings, update_mask] 

4352 has_flattened_params = ( 

4353 len([param for param in flattened_params if param is not None]) > 0 

4354 ) 

4355 if request is not None and has_flattened_params: 

4356 raise ValueError( 

4357 "If the `request` argument is set, then none of " 

4358 "the individual field arguments should be set." 

4359 ) 

4360 

4361 # - Use the request object if provided (there's no risk of modifying the input as 

4362 # there are no flattened fields), or create one. 

4363 if not isinstance(request, logging_config.UpdateSettingsRequest): 

4364 request = logging_config.UpdateSettingsRequest(request) 

4365 # If we have keyword arguments corresponding to fields on the 

4366 # request, apply these. 

4367 if settings is not None: 

4368 request.settings = settings 

4369 if update_mask is not None: 

4370 request.update_mask = update_mask 

4371 

4372 # Wrap the RPC method; this adds retry and timeout information, 

4373 # and friendly error handling. 

4374 rpc = self._transport._wrapped_methods[self._transport.update_settings] 

4375 

4376 # Certain fields should be provided within the metadata header; 

4377 # add these here. 

4378 metadata = tuple(metadata) + ( 

4379 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

4380 ) 

4381 

4382 # Validate the universe domain. 

4383 self._validate_universe_domain() 

4384 

4385 # Send the request. 

4386 response = rpc( 

4387 request, 

4388 retry=retry, 

4389 timeout=timeout, 

4390 metadata=metadata, 

4391 ) 

4392 

4393 # Done; return the response. 

4394 return response 

4395 

4396 def copy_log_entries( 

4397 self, 

4398 request: Optional[Union[logging_config.CopyLogEntriesRequest, dict]] = None, 

4399 *, 

4400 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

4401 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

4402 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

4403 ) -> operation.Operation: 

4404 r"""Copies a set of log entries from a log bucket to a 

4405 Cloud Storage bucket. 

4406 

4407 .. code-block:: python 

4408 

4409 # This snippet has been automatically generated and should be regarded as a 

4410 # code template only. 

4411 # It will require modifications to work: 

4412 # - It may require correct/in-range values for request initialization. 

4413 # - It may require specifying regional endpoints when creating the service 

4414 # client as shown in: 

4415 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

4416 from google.cloud import logging_v2 

4417 

4418 def sample_copy_log_entries(): 

4419 # Create a client 

4420 client = logging_v2.ConfigServiceV2Client() 

4421 

4422 # Initialize request argument(s) 

4423 request = logging_v2.CopyLogEntriesRequest( 

4424 name="name_value", 

4425 destination="destination_value", 

4426 ) 

4427 

4428 # Make the request 

4429 operation = client.copy_log_entries(request=request) 

4430 

4431 print("Waiting for operation to complete...") 

4432 

4433 response = operation.result() 

4434 

4435 # Handle the response 

4436 print(response) 

4437 

4438 Args: 

4439 request (Union[google.cloud.logging_v2.types.CopyLogEntriesRequest, dict]): 

4440 The request object. The parameters to CopyLogEntries. 

4441 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

4442 should be retried. 

4443 timeout (float): The timeout for this request. 

4444 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

4445 sent along with the request as metadata. Normally, each value must be of type `str`, 

4446 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

4447 be of type `bytes`. 

4448 

4449 Returns: 

4450 google.api_core.operation.Operation: 

4451 An object representing a long-running operation. 

4452 

4453 The result type for the operation will be 

4454 :class:`google.cloud.logging_v2.types.CopyLogEntriesResponse` 

4455 Response type for CopyLogEntries long running 

4456 operations. 

4457 

4458 """ 

4459 # Create or coerce a protobuf request object. 

4460 # - Use the request object if provided (there's no risk of modifying the input as 

4461 # there are no flattened fields), or create one. 

4462 if not isinstance(request, logging_config.CopyLogEntriesRequest): 

4463 request = logging_config.CopyLogEntriesRequest(request) 

4464 

4465 # Wrap the RPC method; this adds retry and timeout information, 

4466 # and friendly error handling. 

4467 rpc = self._transport._wrapped_methods[self._transport.copy_log_entries] 

4468 

4469 # Validate the universe domain. 

4470 self._validate_universe_domain() 

4471 

4472 # Send the request. 

4473 response = rpc( 

4474 request, 

4475 retry=retry, 

4476 timeout=timeout, 

4477 metadata=metadata, 

4478 ) 

4479 

4480 # Wrap the response in an operation future. 

4481 response = operation.from_gapic( 

4482 response, 

4483 self._transport.operations_client, 

4484 logging_config.CopyLogEntriesResponse, 

4485 metadata_type=logging_config.CopyLogEntriesMetadata, 

4486 ) 

4487 

4488 # Done; return the response. 

4489 return response 

4490 

4491 def __enter__(self) -> "ConfigServiceV2Client": 

4492 return self 

4493 

4494 def __exit__(self, type, value, traceback): 

4495 """Releases underlying transport's resources. 

4496 

4497 .. warning:: 

4498 ONLY use as a context manager if the transport is NOT shared 

4499 with other clients! Exiting the with block will CLOSE the transport 

4500 and may cause errors in other clients! 

4501 """ 

4502 self.transport.close() 

4503 

4504 def list_operations( 

4505 self, 

4506 request: Optional[operations_pb2.ListOperationsRequest] = None, 

4507 *, 

4508 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

4509 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

4510 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

4511 ) -> operations_pb2.ListOperationsResponse: 

4512 r"""Lists operations that match the specified filter in the request. 

4513 

4514 Args: 

4515 request (:class:`~.operations_pb2.ListOperationsRequest`): 

4516 The request object. Request message for 

4517 `ListOperations` method. 

4518 retry (google.api_core.retry.Retry): Designation of what errors, 

4519 if any, should be retried. 

4520 timeout (float): The timeout for this request. 

4521 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

4522 sent along with the request as metadata. Normally, each value must be of type `str`, 

4523 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

4524 be of type `bytes`. 

4525 Returns: 

4526 ~.operations_pb2.ListOperationsResponse: 

4527 Response message for ``ListOperations`` method. 

4528 """ 

4529 # Create or coerce a protobuf request object. 

4530 # The request isn't a proto-plus wrapped type, 

4531 # so it must be constructed via keyword expansion. 

4532 if isinstance(request, dict): 

4533 request = operations_pb2.ListOperationsRequest(**request) 

4534 

4535 # Wrap the RPC method; this adds retry and timeout information, 

4536 # and friendly error handling. 

4537 rpc = self._transport._wrapped_methods[self._transport.list_operations] 

4538 

4539 # Certain fields should be provided within the metadata header; 

4540 # add these here. 

4541 metadata = tuple(metadata) + ( 

4542 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

4543 ) 

4544 

4545 # Validate the universe domain. 

4546 self._validate_universe_domain() 

4547 

4548 try: 

4549 # Send the request. 

4550 response = rpc( 

4551 request, 

4552 retry=retry, 

4553 timeout=timeout, 

4554 metadata=metadata, 

4555 ) 

4556 

4557 # Done; return the response. 

4558 return response 

4559 except core_exceptions.GoogleAPICallError as e: 

4560 self._add_cred_info_for_auth_errors(e) 

4561 raise e 

4562 

4563 def get_operation( 

4564 self, 

4565 request: Optional[operations_pb2.GetOperationRequest] = None, 

4566 *, 

4567 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

4568 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

4569 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

4570 ) -> operations_pb2.Operation: 

4571 r"""Gets the latest state of a long-running operation. 

4572 

4573 Args: 

4574 request (:class:`~.operations_pb2.GetOperationRequest`): 

4575 The request object. Request message for 

4576 `GetOperation` method. 

4577 retry (google.api_core.retry.Retry): Designation of what errors, 

4578 if any, should be retried. 

4579 timeout (float): The timeout for this request. 

4580 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

4581 sent along with the request as metadata. Normally, each value must be of type `str`, 

4582 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

4583 be of type `bytes`. 

4584 Returns: 

4585 ~.operations_pb2.Operation: 

4586 An ``Operation`` object. 

4587 """ 

4588 # Create or coerce a protobuf request object. 

4589 # The request isn't a proto-plus wrapped type, 

4590 # so it must be constructed via keyword expansion. 

4591 if isinstance(request, dict): 

4592 request = operations_pb2.GetOperationRequest(**request) 

4593 

4594 # Wrap the RPC method; this adds retry and timeout information, 

4595 # and friendly error handling. 

4596 rpc = self._transport._wrapped_methods[self._transport.get_operation] 

4597 

4598 # Certain fields should be provided within the metadata header; 

4599 # add these here. 

4600 metadata = tuple(metadata) + ( 

4601 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

4602 ) 

4603 

4604 # Validate the universe domain. 

4605 self._validate_universe_domain() 

4606 

4607 try: 

4608 # Send the request. 

4609 response = rpc( 

4610 request, 

4611 retry=retry, 

4612 timeout=timeout, 

4613 metadata=metadata, 

4614 ) 

4615 

4616 # Done; return the response. 

4617 return response 

4618 except core_exceptions.GoogleAPICallError as e: 

4619 self._add_cred_info_for_auth_errors(e) 

4620 raise e 

4621 

4622 def cancel_operation( 

4623 self, 

4624 request: Optional[operations_pb2.CancelOperationRequest] = None, 

4625 *, 

4626 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

4627 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

4628 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

4629 ) -> None: 

4630 r"""Starts asynchronous cancellation on a long-running operation. 

4631 

4632 The server makes a best effort to cancel the operation, but success 

4633 is not guaranteed. If the server doesn't support this method, it returns 

4634 `google.rpc.Code.UNIMPLEMENTED`. 

4635 

4636 Args: 

4637 request (:class:`~.operations_pb2.CancelOperationRequest`): 

4638 The request object. Request message for 

4639 `CancelOperation` method. 

4640 retry (google.api_core.retry.Retry): Designation of what errors, 

4641 if any, should be retried. 

4642 timeout (float): The timeout for this request. 

4643 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

4644 sent along with the request as metadata. Normally, each value must be of type `str`, 

4645 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

4646 be of type `bytes`. 

4647 Returns: 

4648 None 

4649 """ 

4650 # Create or coerce a protobuf request object. 

4651 # The request isn't a proto-plus wrapped type, 

4652 # so it must be constructed via keyword expansion. 

4653 if isinstance(request, dict): 

4654 request = operations_pb2.CancelOperationRequest(**request) 

4655 

4656 # Wrap the RPC method; this adds retry and timeout information, 

4657 # and friendly error handling. 

4658 rpc = self._transport._wrapped_methods[self._transport.cancel_operation] 

4659 

4660 # Certain fields should be provided within the metadata header; 

4661 # add these here. 

4662 metadata = tuple(metadata) + ( 

4663 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

4664 ) 

4665 

4666 # Validate the universe domain. 

4667 self._validate_universe_domain() 

4668 

4669 # Send the request. 

4670 rpc( 

4671 request, 

4672 retry=retry, 

4673 timeout=timeout, 

4674 metadata=metadata, 

4675 ) 

4676 

4677 

4678DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( 

4679 gapic_version=package_version.__version__ 

4680) 

4681 

4682if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER 

4683 DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__ 

4684 

4685__all__ = ("ConfigServiceV2Client",)