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

695 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 uuid 

36import warnings 

37 

38from google.cloud.logging_v2 import gapic_version as package_version 

39 

40from google.api_core import client_options as client_options_lib 

41from google.api_core import exceptions as core_exceptions 

42from google.api_core import gapic_v1 

43from google.api_core import retry as retries 

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

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

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

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

48from google.oauth2 import service_account # type: ignore 

49import google.protobuf 

50 

51try: 

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

53except AttributeError: # pragma: NO COVER 

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

55 

56try: 

57 from google.api_core import client_logging # type: ignore 

58 

59 CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER 

60except ImportError: # pragma: NO COVER 

61 CLIENT_LOGGING_SUPPORTED = False 

62 

63_LOGGER = std_logging.getLogger(__name__) 

64 

65from google.api_core import operation # type: ignore 

66from google.api_core import operation_async # type: ignore 

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

68from google.cloud.logging_v2.types import logging_config 

69from google.longrunning import operations_pb2 # type: ignore 

70from google.protobuf import empty_pb2 # type: ignore 

71from google.protobuf import field_mask_pb2 # type: ignore 

72from google.protobuf import timestamp_pb2 # type: ignore 

73from .transports.base import ConfigServiceV2Transport, DEFAULT_CLIENT_INFO 

74from .transports.grpc import ConfigServiceV2GrpcTransport 

75from .transports.grpc_asyncio import ConfigServiceV2GrpcAsyncIOTransport 

76 

77 

78class ConfigServiceV2ClientMeta(type): 

79 """Metaclass for the ConfigServiceV2 client. 

80 

81 This provides class-level methods for building and retrieving 

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

83 objects. 

84 """ 

85 

86 _transport_registry = ( 

87 OrderedDict() 

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

89 _transport_registry["grpc"] = ConfigServiceV2GrpcTransport 

90 _transport_registry["grpc_asyncio"] = ConfigServiceV2GrpcAsyncIOTransport 

91 

92 def get_transport_class( 

93 cls, 

94 label: Optional[str] = None, 

95 ) -> Type[ConfigServiceV2Transport]: 

96 """Returns an appropriate transport class. 

97 

98 Args: 

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

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

101 

102 Returns: 

103 The transport class to use. 

104 """ 

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

106 if label: 

107 return cls._transport_registry[label] 

108 

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

110 # in the dictionary). 

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

112 

113 

114class ConfigServiceV2Client(metaclass=ConfigServiceV2ClientMeta): 

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

116 

117 @staticmethod 

118 def _get_default_mtls_endpoint(api_endpoint): 

119 """Converts api endpoint to mTLS endpoint. 

120 

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

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

123 Args: 

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

125 Returns: 

126 str: converted mTLS api endpoint. 

127 """ 

128 if not api_endpoint: 

129 return api_endpoint 

130 

131 mtls_endpoint_re = re.compile( 

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

133 ) 

134 

135 m = mtls_endpoint_re.match(api_endpoint) 

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

137 if mtls or not googledomain: 

138 return api_endpoint 

139 

140 if sandbox: 

141 return api_endpoint.replace( 

142 "sandbox.googleapis.com", "mtls.sandbox.googleapis.com" 

143 ) 

144 

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

146 

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

148 DEFAULT_ENDPOINT = "logging.googleapis.com" 

149 DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore 

150 DEFAULT_ENDPOINT 

151 ) 

152 

153 _DEFAULT_ENDPOINT_TEMPLATE = "logging.{UNIVERSE_DOMAIN}" 

154 _DEFAULT_UNIVERSE = "googleapis.com" 

155 

156 @classmethod 

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

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

159 info. 

160 

161 Args: 

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

163 args: Additional arguments to pass to the constructor. 

164 kwargs: Additional arguments to pass to the constructor. 

165 

166 Returns: 

167 ConfigServiceV2Client: The constructed client. 

168 """ 

169 credentials = service_account.Credentials.from_service_account_info(info) 

170 kwargs["credentials"] = credentials 

171 return cls(*args, **kwargs) 

172 

173 @classmethod 

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

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

176 file. 

177 

178 Args: 

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

180 file. 

181 args: Additional arguments to pass to the constructor. 

182 kwargs: Additional arguments to pass to the constructor. 

183 

184 Returns: 

185 ConfigServiceV2Client: The constructed client. 

186 """ 

187 credentials = service_account.Credentials.from_service_account_file(filename) 

188 kwargs["credentials"] = credentials 

189 return cls(*args, **kwargs) 

190 

191 from_service_account_json = from_service_account_file 

192 

193 @property 

194 def transport(self) -> ConfigServiceV2Transport: 

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

196 

197 Returns: 

198 ConfigServiceV2Transport: The transport used by the client 

199 instance. 

200 """ 

201 return self._transport 

202 

203 @staticmethod 

204 def cmek_settings_path( 

205 project: str, 

206 ) -> str: 

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

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

209 project=project, 

210 ) 

211 

212 @staticmethod 

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

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

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

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

217 

218 @staticmethod 

219 def link_path( 

220 project: str, 

221 location: str, 

222 bucket: str, 

223 link: str, 

224 ) -> str: 

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

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

227 project=project, 

228 location=location, 

229 bucket=bucket, 

230 link=link, 

231 ) 

232 

233 @staticmethod 

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

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

236 m = re.match( 

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

238 path, 

239 ) 

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

241 

242 @staticmethod 

243 def log_bucket_path( 

244 project: str, 

245 location: str, 

246 bucket: str, 

247 ) -> str: 

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

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

250 project=project, 

251 location=location, 

252 bucket=bucket, 

253 ) 

254 

255 @staticmethod 

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

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

258 m = re.match( 

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

260 path, 

261 ) 

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

263 

264 @staticmethod 

265 def log_exclusion_path( 

266 project: str, 

267 exclusion: str, 

268 ) -> str: 

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

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

271 project=project, 

272 exclusion=exclusion, 

273 ) 

274 

275 @staticmethod 

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

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

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

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

280 

281 @staticmethod 

282 def log_sink_path( 

283 project: str, 

284 sink: str, 

285 ) -> str: 

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

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

288 project=project, 

289 sink=sink, 

290 ) 

291 

292 @staticmethod 

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

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

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

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

297 

298 @staticmethod 

299 def log_view_path( 

300 project: str, 

301 location: str, 

302 bucket: str, 

303 view: str, 

304 ) -> str: 

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

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

307 project=project, 

308 location=location, 

309 bucket=bucket, 

310 view=view, 

311 ) 

312 

313 @staticmethod 

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

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

316 m = re.match( 

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

318 path, 

319 ) 

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

321 

322 @staticmethod 

323 def settings_path( 

324 project: str, 

325 ) -> str: 

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

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

328 project=project, 

329 ) 

330 

331 @staticmethod 

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

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

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

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

336 

337 @staticmethod 

338 def common_billing_account_path( 

339 billing_account: str, 

340 ) -> str: 

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

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

343 billing_account=billing_account, 

344 ) 

345 

346 @staticmethod 

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

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

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

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

351 

352 @staticmethod 

353 def common_folder_path( 

354 folder: str, 

355 ) -> str: 

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

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

358 folder=folder, 

359 ) 

360 

361 @staticmethod 

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

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

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

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

366 

367 @staticmethod 

368 def common_organization_path( 

369 organization: str, 

370 ) -> str: 

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

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

373 organization=organization, 

374 ) 

375 

376 @staticmethod 

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

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

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

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

381 

382 @staticmethod 

383 def common_project_path( 

384 project: str, 

385 ) -> str: 

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

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

388 project=project, 

389 ) 

390 

391 @staticmethod 

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

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

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

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

396 

397 @staticmethod 

398 def common_location_path( 

399 project: str, 

400 location: str, 

401 ) -> str: 

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

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

404 project=project, 

405 location=location, 

406 ) 

407 

408 @staticmethod 

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

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

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

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

413 

414 @classmethod 

415 def get_mtls_endpoint_and_cert_source( 

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

417 ): 

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

419 

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

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

422 client cert source is None. 

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

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

425 source is None. 

426 

427 The API endpoint is determined in the following order: 

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

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

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

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

432 use the default API endpoint. 

433 

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

435 

436 Args: 

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

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

439 in this method. 

440 

441 Returns: 

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

443 client cert source to use. 

444 

445 Raises: 

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

447 """ 

448 

449 warnings.warn( 

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

451 DeprecationWarning, 

452 ) 

453 if client_options is None: 

454 client_options = client_options_lib.ClientOptions() 

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

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

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

458 raise ValueError( 

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

460 ) 

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

462 raise MutualTLSChannelError( 

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

464 ) 

465 

466 # Figure out the client cert source to use. 

467 client_cert_source = None 

468 if use_client_cert == "true": 

469 if client_options.client_cert_source: 

470 client_cert_source = client_options.client_cert_source 

471 elif mtls.has_default_client_cert_source(): 

472 client_cert_source = mtls.default_client_cert_source() 

473 

474 # Figure out which api endpoint to use. 

475 if client_options.api_endpoint is not None: 

476 api_endpoint = client_options.api_endpoint 

477 elif use_mtls_endpoint == "always" or ( 

478 use_mtls_endpoint == "auto" and client_cert_source 

479 ): 

480 api_endpoint = cls.DEFAULT_MTLS_ENDPOINT 

481 else: 

482 api_endpoint = cls.DEFAULT_ENDPOINT 

483 

484 return api_endpoint, client_cert_source 

485 

486 @staticmethod 

487 def _read_environment_variables(): 

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

489 

490 Returns: 

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

492 GOOGLE_API_USE_MTLS_ENDPOINT, and GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variables. 

493 

494 Raises: 

495 ValueError: If GOOGLE_API_USE_CLIENT_CERTIFICATE is not 

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

497 google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT 

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

499 """ 

500 use_client_cert = os.getenv( 

501 "GOOGLE_API_USE_CLIENT_CERTIFICATE", "false" 

502 ).lower() 

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

504 universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN") 

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

506 raise ValueError( 

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

508 ) 

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

510 raise MutualTLSChannelError( 

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

512 ) 

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

514 

515 @staticmethod 

516 def _get_client_cert_source(provided_cert_source, use_cert_flag): 

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

518 

519 Args: 

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

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

522 

523 Returns: 

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

525 """ 

526 client_cert_source = None 

527 if use_cert_flag: 

528 if provided_cert_source: 

529 client_cert_source = provided_cert_source 

530 elif mtls.has_default_client_cert_source(): 

531 client_cert_source = mtls.default_client_cert_source() 

532 return client_cert_source 

533 

534 @staticmethod 

535 def _get_api_endpoint( 

536 api_override, client_cert_source, universe_domain, use_mtls_endpoint 

537 ): 

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

539 

540 Args: 

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

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

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

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

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

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

547 

548 Returns: 

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

550 """ 

551 if api_override is not None: 

552 api_endpoint = api_override 

553 elif use_mtls_endpoint == "always" or ( 

554 use_mtls_endpoint == "auto" and client_cert_source 

555 ): 

556 _default_universe = ConfigServiceV2Client._DEFAULT_UNIVERSE 

557 if universe_domain != _default_universe: 

558 raise MutualTLSChannelError( 

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

560 ) 

561 api_endpoint = ConfigServiceV2Client.DEFAULT_MTLS_ENDPOINT 

562 else: 

563 api_endpoint = ConfigServiceV2Client._DEFAULT_ENDPOINT_TEMPLATE.format( 

564 UNIVERSE_DOMAIN=universe_domain 

565 ) 

566 return api_endpoint 

567 

568 @staticmethod 

569 def _get_universe_domain( 

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

571 ) -> str: 

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

573 

574 Args: 

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

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

577 

578 Returns: 

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

580 

581 Raises: 

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

583 """ 

584 universe_domain = ConfigServiceV2Client._DEFAULT_UNIVERSE 

585 if client_universe_domain is not None: 

586 universe_domain = client_universe_domain 

587 elif universe_domain_env is not None: 

588 universe_domain = universe_domain_env 

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

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

591 return universe_domain 

592 

593 def _validate_universe_domain(self): 

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

595 

596 Returns: 

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

598 

599 Raises: 

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

601 """ 

602 

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

604 return True 

605 

606 def _add_cred_info_for_auth_errors( 

607 self, error: core_exceptions.GoogleAPICallError 

608 ) -> None: 

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

610 

611 Args: 

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

613 """ 

614 if error.code not in [ 

615 HTTPStatus.UNAUTHORIZED, 

616 HTTPStatus.FORBIDDEN, 

617 HTTPStatus.NOT_FOUND, 

618 ]: 

619 return 

620 

621 cred = self._transport._credentials 

622 

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

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

625 return 

626 

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

628 # is not available 

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

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

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

632 

633 @property 

634 def api_endpoint(self): 

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

636 

637 Returns: 

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

639 """ 

640 return self._api_endpoint 

641 

642 @property 

643 def universe_domain(self) -> str: 

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

645 

646 Returns: 

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

648 """ 

649 return self._universe_domain 

650 

651 def __init__( 

652 self, 

653 *, 

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

655 transport: Optional[ 

656 Union[ 

657 str, ConfigServiceV2Transport, Callable[..., ConfigServiceV2Transport] 

658 ] 

659 ] = None, 

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

661 client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, 

662 ) -> None: 

663 """Instantiates the config service v2 client. 

664 

665 Args: 

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

667 authorization credentials to attach to requests. These 

668 credentials identify the application to the service; if none 

669 are specified, the client will attempt to ascertain the 

670 credentials from the environment. 

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

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

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

674 arguments as used in the ConfigServiceV2Transport constructor. 

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

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

677 Custom options for the client. 

678 

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

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

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

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

683 determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment 

684 variable, which have one of the following values: 

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

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

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

688 the default value). 

689 

690 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable 

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

692 to provide a client certificate for mTLS transport. If 

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

694 present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not 

695 set, no client certificate will be used. 

696 

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

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

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

700 currently not supported for mTLS. 

701 

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

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

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

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

706 your own client library. 

707 

708 Raises: 

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

710 creation failed for any reason. 

711 """ 

712 self._client_options = client_options 

713 if isinstance(self._client_options, dict): 

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

715 if self._client_options is None: 

716 self._client_options = client_options_lib.ClientOptions() 

717 self._client_options = cast( 

718 client_options_lib.ClientOptions, self._client_options 

719 ) 

720 

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

722 

723 ( 

724 self._use_client_cert, 

725 self._use_mtls_endpoint, 

726 self._universe_domain_env, 

727 ) = ConfigServiceV2Client._read_environment_variables() 

728 self._client_cert_source = ConfigServiceV2Client._get_client_cert_source( 

729 self._client_options.client_cert_source, self._use_client_cert 

730 ) 

731 self._universe_domain = ConfigServiceV2Client._get_universe_domain( 

732 universe_domain_opt, self._universe_domain_env 

733 ) 

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

735 

736 # Initialize the universe domain validation. 

737 self._is_universe_domain_valid = False 

738 

739 if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER 

740 # Setup logging. 

741 client_logging.initialize_logging() 

742 

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

744 if api_key_value and credentials: 

745 raise ValueError( 

746 "client_options.api_key and credentials are mutually exclusive" 

747 ) 

748 

749 # Save or instantiate the transport. 

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

751 # instance provides an extensibility point for unusual situations. 

752 transport_provided = isinstance(transport, ConfigServiceV2Transport) 

753 if transport_provided: 

754 # transport is a ConfigServiceV2Transport instance. 

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

756 raise ValueError( 

757 "When providing a transport instance, " 

758 "provide its credentials directly." 

759 ) 

760 if self._client_options.scopes: 

761 raise ValueError( 

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

763 "directly." 

764 ) 

765 self._transport = cast(ConfigServiceV2Transport, transport) 

766 self._api_endpoint = self._transport.host 

767 

768 self._api_endpoint = ( 

769 self._api_endpoint 

770 or ConfigServiceV2Client._get_api_endpoint( 

771 self._client_options.api_endpoint, 

772 self._client_cert_source, 

773 self._universe_domain, 

774 self._use_mtls_endpoint, 

775 ) 

776 ) 

777 

778 if not transport_provided: 

779 import google.auth._default # type: ignore 

780 

781 if api_key_value and hasattr( 

782 google.auth._default, "get_api_key_credentials" 

783 ): 

784 credentials = google.auth._default.get_api_key_credentials( 

785 api_key_value 

786 ) 

787 

788 transport_init: Union[ 

789 Type[ConfigServiceV2Transport], Callable[..., ConfigServiceV2Transport] 

790 ] = ( 

791 ConfigServiceV2Client.get_transport_class(transport) 

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

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

794 ) 

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

796 self._transport = transport_init( 

797 credentials=credentials, 

798 credentials_file=self._client_options.credentials_file, 

799 host=self._api_endpoint, 

800 scopes=self._client_options.scopes, 

801 client_cert_source_for_mtls=self._client_cert_source, 

802 quota_project_id=self._client_options.quota_project_id, 

803 client_info=client_info, 

804 always_use_jwt_access=True, 

805 api_audience=self._client_options.api_audience, 

806 ) 

807 

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

809 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

810 std_logging.DEBUG 

811 ): # pragma: NO COVER 

812 _LOGGER.debug( 

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

814 extra={ 

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

816 "universeDomain": getattr( 

817 self._transport._credentials, "universe_domain", "" 

818 ), 

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

820 "credentialsInfo": getattr( 

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

822 )(), 

823 } 

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

825 else { 

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

827 "credentialsType": None, 

828 }, 

829 ) 

830 

831 def list_buckets( 

832 self, 

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

834 *, 

835 parent: Optional[str] = None, 

836 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

839 ) -> pagers.ListBucketsPager: 

840 r"""Lists log buckets. 

841 

842 .. code-block:: python 

843 

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

845 # code template only. 

846 # It will require modifications to work: 

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

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

849 # client as shown in: 

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

851 from google.cloud import logging_v2 

852 

853 def sample_list_buckets(): 

854 # Create a client 

855 client = logging_v2.ConfigServiceV2Client() 

856 

857 # Initialize request argument(s) 

858 request = logging_v2.ListBucketsRequest( 

859 parent="parent_value", 

860 ) 

861 

862 # Make the request 

863 page_result = client.list_buckets(request=request) 

864 

865 # Handle the response 

866 for response in page_result: 

867 print(response) 

868 

869 Args: 

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

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

872 parent (str): 

873 Required. The parent resource whose buckets are to be 

874 listed: 

875 

876 :: 

877 

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

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

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

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

882 

883 Note: The locations portion of the resource must be 

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

885 [LOCATION_ID] will return all buckets. 

886 

887 This corresponds to the ``parent`` field 

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

889 should not be set. 

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

891 should be retried. 

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

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

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

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

896 be of type `bytes`. 

897 

898 Returns: 

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

900 The response from ListBuckets. 

901 

902 Iterating over this object will yield 

903 results and resolve additional pages 

904 automatically. 

905 

906 """ 

907 # Create or coerce a protobuf request object. 

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

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

910 flattened_params = [parent] 

911 has_flattened_params = ( 

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

913 ) 

914 if request is not None and has_flattened_params: 

915 raise ValueError( 

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

917 "the individual field arguments should be set." 

918 ) 

919 

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

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

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

923 request = logging_config.ListBucketsRequest(request) 

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

925 # request, apply these. 

926 if parent is not None: 

927 request.parent = parent 

928 

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

930 # and friendly error handling. 

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

932 

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

934 # add these here. 

935 metadata = tuple(metadata) + ( 

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

937 ) 

938 

939 # Validate the universe domain. 

940 self._validate_universe_domain() 

941 

942 # Send the request. 

943 response = rpc( 

944 request, 

945 retry=retry, 

946 timeout=timeout, 

947 metadata=metadata, 

948 ) 

949 

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

951 # an `__iter__` convenience method. 

952 response = pagers.ListBucketsPager( 

953 method=rpc, 

954 request=request, 

955 response=response, 

956 retry=retry, 

957 timeout=timeout, 

958 metadata=metadata, 

959 ) 

960 

961 # Done; return the response. 

962 return response 

963 

964 def get_bucket( 

965 self, 

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

967 *, 

968 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

971 ) -> logging_config.LogBucket: 

972 r"""Gets a log bucket. 

973 

974 .. code-block:: python 

975 

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

977 # code template only. 

978 # It will require modifications to work: 

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

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

981 # client as shown in: 

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

983 from google.cloud import logging_v2 

984 

985 def sample_get_bucket(): 

986 # Create a client 

987 client = logging_v2.ConfigServiceV2Client() 

988 

989 # Initialize request argument(s) 

990 request = logging_v2.GetBucketRequest( 

991 name="name_value", 

992 ) 

993 

994 # Make the request 

995 response = client.get_bucket(request=request) 

996 

997 # Handle the response 

998 print(response) 

999 

1000 Args: 

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

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

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

1004 should be retried. 

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

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

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

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

1009 be of type `bytes`. 

1010 

1011 Returns: 

1012 google.cloud.logging_v2.types.LogBucket: 

1013 Describes a repository in which log 

1014 entries are stored. 

1015 

1016 """ 

1017 # Create or coerce a protobuf request object. 

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

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

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

1021 request = logging_config.GetBucketRequest(request) 

1022 

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

1024 # and friendly error handling. 

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

1026 

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

1028 # add these here. 

1029 metadata = tuple(metadata) + ( 

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

1031 ) 

1032 

1033 # Validate the universe domain. 

1034 self._validate_universe_domain() 

1035 

1036 # Send the request. 

1037 response = rpc( 

1038 request, 

1039 retry=retry, 

1040 timeout=timeout, 

1041 metadata=metadata, 

1042 ) 

1043 

1044 # Done; return the response. 

1045 return response 

1046 

1047 def create_bucket_async( 

1048 self, 

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

1050 *, 

1051 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

1054 ) -> operation.Operation: 

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

1056 to store log entries. 

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

1058 cannot be changed. 

1059 

1060 .. code-block:: python 

1061 

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

1063 # code template only. 

1064 # It will require modifications to work: 

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

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

1067 # client as shown in: 

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

1069 from google.cloud import logging_v2 

1070 

1071 def sample_create_bucket_async(): 

1072 # Create a client 

1073 client = logging_v2.ConfigServiceV2Client() 

1074 

1075 # Initialize request argument(s) 

1076 request = logging_v2.CreateBucketRequest( 

1077 parent="parent_value", 

1078 bucket_id="bucket_id_value", 

1079 ) 

1080 

1081 # Make the request 

1082 operation = client.create_bucket_async(request=request) 

1083 

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

1085 

1086 response = operation.result() 

1087 

1088 # Handle the response 

1089 print(response) 

1090 

1091 Args: 

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

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

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

1095 should be retried. 

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

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

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

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

1100 be of type `bytes`. 

1101 

1102 Returns: 

1103 google.api_core.operation.Operation: 

1104 An object representing a long-running operation. 

1105 

1106 The result type for the operation will be 

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

1108 Describes a repository in which log entries are stored. 

1109 

1110 """ 

1111 # Create or coerce a protobuf request object. 

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

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

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

1115 request = logging_config.CreateBucketRequest(request) 

1116 

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

1118 # and friendly error handling. 

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

1120 

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

1122 # add these here. 

1123 metadata = tuple(metadata) + ( 

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

1125 ) 

1126 

1127 # Validate the universe domain. 

1128 self._validate_universe_domain() 

1129 

1130 # Send the request. 

1131 response = rpc( 

1132 request, 

1133 retry=retry, 

1134 timeout=timeout, 

1135 metadata=metadata, 

1136 ) 

1137 

1138 # Wrap the response in an operation future. 

1139 response = operation.from_gapic( 

1140 response, 

1141 self._transport.operations_client, 

1142 logging_config.LogBucket, 

1143 metadata_type=logging_config.BucketMetadata, 

1144 ) 

1145 

1146 # Done; return the response. 

1147 return response 

1148 

1149 def update_bucket_async( 

1150 self, 

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

1152 *, 

1153 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

1156 ) -> operation.Operation: 

1157 r"""Updates a log bucket asynchronously. 

1158 

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

1160 then ``FAILED_PRECONDITION`` will be returned. 

1161 

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

1163 changed. 

1164 

1165 .. code-block:: python 

1166 

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

1168 # code template only. 

1169 # It will require modifications to work: 

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

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

1172 # client as shown in: 

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

1174 from google.cloud import logging_v2 

1175 

1176 def sample_update_bucket_async(): 

1177 # Create a client 

1178 client = logging_v2.ConfigServiceV2Client() 

1179 

1180 # Initialize request argument(s) 

1181 request = logging_v2.UpdateBucketRequest( 

1182 name="name_value", 

1183 ) 

1184 

1185 # Make the request 

1186 operation = client.update_bucket_async(request=request) 

1187 

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

1189 

1190 response = operation.result() 

1191 

1192 # Handle the response 

1193 print(response) 

1194 

1195 Args: 

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

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

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

1199 should be retried. 

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

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

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

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

1204 be of type `bytes`. 

1205 

1206 Returns: 

1207 google.api_core.operation.Operation: 

1208 An object representing a long-running operation. 

1209 

1210 The result type for the operation will be 

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

1212 Describes a repository in which log entries are stored. 

1213 

1214 """ 

1215 # Create or coerce a protobuf request object. 

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

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

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

1219 request = logging_config.UpdateBucketRequest(request) 

1220 

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

1222 # and friendly error handling. 

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

1224 

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

1226 # add these here. 

1227 metadata = tuple(metadata) + ( 

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

1229 ) 

1230 

1231 # Validate the universe domain. 

1232 self._validate_universe_domain() 

1233 

1234 # Send the request. 

1235 response = rpc( 

1236 request, 

1237 retry=retry, 

1238 timeout=timeout, 

1239 metadata=metadata, 

1240 ) 

1241 

1242 # Wrap the response in an operation future. 

1243 response = operation.from_gapic( 

1244 response, 

1245 self._transport.operations_client, 

1246 logging_config.LogBucket, 

1247 metadata_type=logging_config.BucketMetadata, 

1248 ) 

1249 

1250 # Done; return the response. 

1251 return response 

1252 

1253 def create_bucket( 

1254 self, 

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

1256 *, 

1257 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

1260 ) -> logging_config.LogBucket: 

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

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

1263 location cannot be changed. 

1264 

1265 .. code-block:: python 

1266 

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

1268 # code template only. 

1269 # It will require modifications to work: 

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

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

1272 # client as shown in: 

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

1274 from google.cloud import logging_v2 

1275 

1276 def sample_create_bucket(): 

1277 # Create a client 

1278 client = logging_v2.ConfigServiceV2Client() 

1279 

1280 # Initialize request argument(s) 

1281 request = logging_v2.CreateBucketRequest( 

1282 parent="parent_value", 

1283 bucket_id="bucket_id_value", 

1284 ) 

1285 

1286 # Make the request 

1287 response = client.create_bucket(request=request) 

1288 

1289 # Handle the response 

1290 print(response) 

1291 

1292 Args: 

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

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

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

1296 should be retried. 

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

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

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

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

1301 be of type `bytes`. 

1302 

1303 Returns: 

1304 google.cloud.logging_v2.types.LogBucket: 

1305 Describes a repository in which log 

1306 entries are stored. 

1307 

1308 """ 

1309 # Create or coerce a protobuf request object. 

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

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

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

1313 request = logging_config.CreateBucketRequest(request) 

1314 

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

1316 # and friendly error handling. 

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

1318 

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

1320 # add these here. 

1321 metadata = tuple(metadata) + ( 

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

1323 ) 

1324 

1325 # Validate the universe domain. 

1326 self._validate_universe_domain() 

1327 

1328 # Send the request. 

1329 response = rpc( 

1330 request, 

1331 retry=retry, 

1332 timeout=timeout, 

1333 metadata=metadata, 

1334 ) 

1335 

1336 # Done; return the response. 

1337 return response 

1338 

1339 def update_bucket( 

1340 self, 

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

1342 *, 

1343 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

1346 ) -> logging_config.LogBucket: 

1347 r"""Updates a log bucket. 

1348 

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

1350 then ``FAILED_PRECONDITION`` will be returned. 

1351 

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

1353 changed. 

1354 

1355 .. code-block:: python 

1356 

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

1358 # code template only. 

1359 # It will require modifications to work: 

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

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

1362 # client as shown in: 

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

1364 from google.cloud import logging_v2 

1365 

1366 def sample_update_bucket(): 

1367 # Create a client 

1368 client = logging_v2.ConfigServiceV2Client() 

1369 

1370 # Initialize request argument(s) 

1371 request = logging_v2.UpdateBucketRequest( 

1372 name="name_value", 

1373 ) 

1374 

1375 # Make the request 

1376 response = client.update_bucket(request=request) 

1377 

1378 # Handle the response 

1379 print(response) 

1380 

1381 Args: 

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

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

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

1385 should be retried. 

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

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

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

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

1390 be of type `bytes`. 

1391 

1392 Returns: 

1393 google.cloud.logging_v2.types.LogBucket: 

1394 Describes a repository in which log 

1395 entries are stored. 

1396 

1397 """ 

1398 # Create or coerce a protobuf request object. 

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

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

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

1402 request = logging_config.UpdateBucketRequest(request) 

1403 

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

1405 # and friendly error handling. 

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

1407 

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

1409 # add these here. 

1410 metadata = tuple(metadata) + ( 

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

1412 ) 

1413 

1414 # Validate the universe domain. 

1415 self._validate_universe_domain() 

1416 

1417 # Send the request. 

1418 response = rpc( 

1419 request, 

1420 retry=retry, 

1421 timeout=timeout, 

1422 metadata=metadata, 

1423 ) 

1424 

1425 # Done; return the response. 

1426 return response 

1427 

1428 def delete_bucket( 

1429 self, 

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

1431 *, 

1432 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

1435 ) -> None: 

1436 r"""Deletes a log bucket. 

1437 

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

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

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

1441 deleted. 

1442 

1443 .. code-block:: python 

1444 

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

1446 # code template only. 

1447 # It will require modifications to work: 

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

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

1450 # client as shown in: 

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

1452 from google.cloud import logging_v2 

1453 

1454 def sample_delete_bucket(): 

1455 # Create a client 

1456 client = logging_v2.ConfigServiceV2Client() 

1457 

1458 # Initialize request argument(s) 

1459 request = logging_v2.DeleteBucketRequest( 

1460 name="name_value", 

1461 ) 

1462 

1463 # Make the request 

1464 client.delete_bucket(request=request) 

1465 

1466 Args: 

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

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

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

1470 should be retried. 

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

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

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

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

1475 be of type `bytes`. 

1476 """ 

1477 # Create or coerce a protobuf request object. 

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

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

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

1481 request = logging_config.DeleteBucketRequest(request) 

1482 

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

1484 # and friendly error handling. 

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

1486 

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

1488 # add these here. 

1489 metadata = tuple(metadata) + ( 

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

1491 ) 

1492 

1493 # Validate the universe domain. 

1494 self._validate_universe_domain() 

1495 

1496 # Send the request. 

1497 rpc( 

1498 request, 

1499 retry=retry, 

1500 timeout=timeout, 

1501 metadata=metadata, 

1502 ) 

1503 

1504 def undelete_bucket( 

1505 self, 

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

1507 *, 

1508 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

1511 ) -> None: 

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

1513 deleted can be undeleted within the grace period of 7 

1514 days. 

1515 

1516 .. code-block:: python 

1517 

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

1519 # code template only. 

1520 # It will require modifications to work: 

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

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

1523 # client as shown in: 

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

1525 from google.cloud import logging_v2 

1526 

1527 def sample_undelete_bucket(): 

1528 # Create a client 

1529 client = logging_v2.ConfigServiceV2Client() 

1530 

1531 # Initialize request argument(s) 

1532 request = logging_v2.UndeleteBucketRequest( 

1533 name="name_value", 

1534 ) 

1535 

1536 # Make the request 

1537 client.undelete_bucket(request=request) 

1538 

1539 Args: 

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

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

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

1543 should be retried. 

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

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

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

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

1548 be of type `bytes`. 

1549 """ 

1550 # Create or coerce a protobuf request object. 

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

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

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

1554 request = logging_config.UndeleteBucketRequest(request) 

1555 

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

1557 # and friendly error handling. 

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

1559 

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

1561 # add these here. 

1562 metadata = tuple(metadata) + ( 

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

1564 ) 

1565 

1566 # Validate the universe domain. 

1567 self._validate_universe_domain() 

1568 

1569 # Send the request. 

1570 rpc( 

1571 request, 

1572 retry=retry, 

1573 timeout=timeout, 

1574 metadata=metadata, 

1575 ) 

1576 

1577 def list_views( 

1578 self, 

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

1580 *, 

1581 parent: Optional[str] = None, 

1582 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

1585 ) -> pagers.ListViewsPager: 

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

1587 

1588 .. code-block:: python 

1589 

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

1591 # code template only. 

1592 # It will require modifications to work: 

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

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

1595 # client as shown in: 

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

1597 from google.cloud import logging_v2 

1598 

1599 def sample_list_views(): 

1600 # Create a client 

1601 client = logging_v2.ConfigServiceV2Client() 

1602 

1603 # Initialize request argument(s) 

1604 request = logging_v2.ListViewsRequest( 

1605 parent="parent_value", 

1606 ) 

1607 

1608 # Make the request 

1609 page_result = client.list_views(request=request) 

1610 

1611 # Handle the response 

1612 for response in page_result: 

1613 print(response) 

1614 

1615 Args: 

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

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

1618 parent (str): 

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

1620 

1621 :: 

1622 

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

1624 

1625 This corresponds to the ``parent`` field 

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

1627 should not be set. 

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

1629 should be retried. 

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

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

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

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

1634 be of type `bytes`. 

1635 

1636 Returns: 

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

1638 The response from ListViews. 

1639 

1640 Iterating over this object will yield 

1641 results and resolve additional pages 

1642 automatically. 

1643 

1644 """ 

1645 # Create or coerce a protobuf request object. 

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

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

1648 flattened_params = [parent] 

1649 has_flattened_params = ( 

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

1651 ) 

1652 if request is not None and has_flattened_params: 

1653 raise ValueError( 

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

1655 "the individual field arguments should be set." 

1656 ) 

1657 

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

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

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

1661 request = logging_config.ListViewsRequest(request) 

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

1663 # request, apply these. 

1664 if parent is not None: 

1665 request.parent = parent 

1666 

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

1668 # and friendly error handling. 

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

1670 

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

1672 # add these here. 

1673 metadata = tuple(metadata) + ( 

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

1675 ) 

1676 

1677 # Validate the universe domain. 

1678 self._validate_universe_domain() 

1679 

1680 # Send the request. 

1681 response = rpc( 

1682 request, 

1683 retry=retry, 

1684 timeout=timeout, 

1685 metadata=metadata, 

1686 ) 

1687 

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

1689 # an `__iter__` convenience method. 

1690 response = pagers.ListViewsPager( 

1691 method=rpc, 

1692 request=request, 

1693 response=response, 

1694 retry=retry, 

1695 timeout=timeout, 

1696 metadata=metadata, 

1697 ) 

1698 

1699 # Done; return the response. 

1700 return response 

1701 

1702 def get_view( 

1703 self, 

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

1705 *, 

1706 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

1709 ) -> logging_config.LogView: 

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

1711 

1712 .. code-block:: python 

1713 

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

1715 # code template only. 

1716 # It will require modifications to work: 

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

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

1719 # client as shown in: 

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

1721 from google.cloud import logging_v2 

1722 

1723 def sample_get_view(): 

1724 # Create a client 

1725 client = logging_v2.ConfigServiceV2Client() 

1726 

1727 # Initialize request argument(s) 

1728 request = logging_v2.GetViewRequest( 

1729 name="name_value", 

1730 ) 

1731 

1732 # Make the request 

1733 response = client.get_view(request=request) 

1734 

1735 # Handle the response 

1736 print(response) 

1737 

1738 Args: 

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

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

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

1742 should be retried. 

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

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

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

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

1747 be of type `bytes`. 

1748 

1749 Returns: 

1750 google.cloud.logging_v2.types.LogView: 

1751 Describes a view over log entries in 

1752 a bucket. 

1753 

1754 """ 

1755 # Create or coerce a protobuf request object. 

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

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

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

1759 request = logging_config.GetViewRequest(request) 

1760 

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

1762 # and friendly error handling. 

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

1764 

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

1766 # add these here. 

1767 metadata = tuple(metadata) + ( 

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

1769 ) 

1770 

1771 # Validate the universe domain. 

1772 self._validate_universe_domain() 

1773 

1774 # Send the request. 

1775 response = rpc( 

1776 request, 

1777 retry=retry, 

1778 timeout=timeout, 

1779 metadata=metadata, 

1780 ) 

1781 

1782 # Done; return the response. 

1783 return response 

1784 

1785 def create_view( 

1786 self, 

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

1788 *, 

1789 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

1792 ) -> logging_config.LogView: 

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

1794 bucket may contain a maximum of 30 views. 

1795 

1796 .. code-block:: python 

1797 

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

1799 # code template only. 

1800 # It will require modifications to work: 

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

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

1803 # client as shown in: 

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

1805 from google.cloud import logging_v2 

1806 

1807 def sample_create_view(): 

1808 # Create a client 

1809 client = logging_v2.ConfigServiceV2Client() 

1810 

1811 # Initialize request argument(s) 

1812 request = logging_v2.CreateViewRequest( 

1813 parent="parent_value", 

1814 view_id="view_id_value", 

1815 ) 

1816 

1817 # Make the request 

1818 response = client.create_view(request=request) 

1819 

1820 # Handle the response 

1821 print(response) 

1822 

1823 Args: 

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

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

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

1827 should be retried. 

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

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

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

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

1832 be of type `bytes`. 

1833 

1834 Returns: 

1835 google.cloud.logging_v2.types.LogView: 

1836 Describes a view over log entries in 

1837 a bucket. 

1838 

1839 """ 

1840 # Create or coerce a protobuf request object. 

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

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

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

1844 request = logging_config.CreateViewRequest(request) 

1845 

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

1847 # and friendly error handling. 

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

1849 

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

1851 # add these here. 

1852 metadata = tuple(metadata) + ( 

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

1854 ) 

1855 

1856 # Validate the universe domain. 

1857 self._validate_universe_domain() 

1858 

1859 # Send the request. 

1860 response = rpc( 

1861 request, 

1862 retry=retry, 

1863 timeout=timeout, 

1864 metadata=metadata, 

1865 ) 

1866 

1867 # Done; return the response. 

1868 return response 

1869 

1870 def update_view( 

1871 self, 

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

1873 *, 

1874 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

1877 ) -> logging_config.LogView: 

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

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

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

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

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

1883 

1884 .. code-block:: python 

1885 

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

1887 # code template only. 

1888 # It will require modifications to work: 

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

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

1891 # client as shown in: 

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

1893 from google.cloud import logging_v2 

1894 

1895 def sample_update_view(): 

1896 # Create a client 

1897 client = logging_v2.ConfigServiceV2Client() 

1898 

1899 # Initialize request argument(s) 

1900 request = logging_v2.UpdateViewRequest( 

1901 name="name_value", 

1902 ) 

1903 

1904 # Make the request 

1905 response = client.update_view(request=request) 

1906 

1907 # Handle the response 

1908 print(response) 

1909 

1910 Args: 

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

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

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

1914 should be retried. 

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

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

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

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

1919 be of type `bytes`. 

1920 

1921 Returns: 

1922 google.cloud.logging_v2.types.LogView: 

1923 Describes a view over log entries in 

1924 a bucket. 

1925 

1926 """ 

1927 # Create or coerce a protobuf request object. 

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

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

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

1931 request = logging_config.UpdateViewRequest(request) 

1932 

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

1934 # and friendly error handling. 

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

1936 

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

1938 # add these here. 

1939 metadata = tuple(metadata) + ( 

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

1941 ) 

1942 

1943 # Validate the universe domain. 

1944 self._validate_universe_domain() 

1945 

1946 # Send the request. 

1947 response = rpc( 

1948 request, 

1949 retry=retry, 

1950 timeout=timeout, 

1951 metadata=metadata, 

1952 ) 

1953 

1954 # Done; return the response. 

1955 return response 

1956 

1957 def delete_view( 

1958 self, 

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

1960 *, 

1961 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

1964 ) -> None: 

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

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

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

1968 minutes. 

1969 

1970 .. code-block:: python 

1971 

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

1973 # code template only. 

1974 # It will require modifications to work: 

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

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

1977 # client as shown in: 

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

1979 from google.cloud import logging_v2 

1980 

1981 def sample_delete_view(): 

1982 # Create a client 

1983 client = logging_v2.ConfigServiceV2Client() 

1984 

1985 # Initialize request argument(s) 

1986 request = logging_v2.DeleteViewRequest( 

1987 name="name_value", 

1988 ) 

1989 

1990 # Make the request 

1991 client.delete_view(request=request) 

1992 

1993 Args: 

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

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

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

1997 should be retried. 

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

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

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

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

2002 be of type `bytes`. 

2003 """ 

2004 # Create or coerce a protobuf request object. 

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

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

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

2008 request = logging_config.DeleteViewRequest(request) 

2009 

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

2011 # and friendly error handling. 

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

2013 

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

2015 # add these here. 

2016 metadata = tuple(metadata) + ( 

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

2018 ) 

2019 

2020 # Validate the universe domain. 

2021 self._validate_universe_domain() 

2022 

2023 # Send the request. 

2024 rpc( 

2025 request, 

2026 retry=retry, 

2027 timeout=timeout, 

2028 metadata=metadata, 

2029 ) 

2030 

2031 def list_sinks( 

2032 self, 

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

2034 *, 

2035 parent: Optional[str] = None, 

2036 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

2039 ) -> pagers.ListSinksPager: 

2040 r"""Lists sinks. 

2041 

2042 .. code-block:: python 

2043 

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

2045 # code template only. 

2046 # It will require modifications to work: 

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

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

2049 # client as shown in: 

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

2051 from google.cloud import logging_v2 

2052 

2053 def sample_list_sinks(): 

2054 # Create a client 

2055 client = logging_v2.ConfigServiceV2Client() 

2056 

2057 # Initialize request argument(s) 

2058 request = logging_v2.ListSinksRequest( 

2059 parent="parent_value", 

2060 ) 

2061 

2062 # Make the request 

2063 page_result = client.list_sinks(request=request) 

2064 

2065 # Handle the response 

2066 for response in page_result: 

2067 print(response) 

2068 

2069 Args: 

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

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

2072 parent (str): 

2073 Required. The parent resource whose sinks are to be 

2074 listed: 

2075 

2076 :: 

2077 

2078 "projects/[PROJECT_ID]" 

2079 "organizations/[ORGANIZATION_ID]" 

2080 "billingAccounts/[BILLING_ACCOUNT_ID]" 

2081 "folders/[FOLDER_ID]" 

2082 

2083 This corresponds to the ``parent`` field 

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

2085 should not be set. 

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

2087 should be retried. 

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

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

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

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

2092 be of type `bytes`. 

2093 

2094 Returns: 

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

2096 Result returned from ListSinks. 

2097 

2098 Iterating over this object will yield results and 

2099 resolve additional pages automatically. 

2100 

2101 """ 

2102 # Create or coerce a protobuf request object. 

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

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

2105 flattened_params = [parent] 

2106 has_flattened_params = ( 

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

2108 ) 

2109 if request is not None and has_flattened_params: 

2110 raise ValueError( 

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

2112 "the individual field arguments should be set." 

2113 ) 

2114 

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

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

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

2118 request = logging_config.ListSinksRequest(request) 

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

2120 # request, apply these. 

2121 if parent is not None: 

2122 request.parent = parent 

2123 

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

2125 # and friendly error handling. 

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

2127 

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

2129 # add these here. 

2130 metadata = tuple(metadata) + ( 

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

2132 ) 

2133 

2134 # Validate the universe domain. 

2135 self._validate_universe_domain() 

2136 

2137 # Send the request. 

2138 response = rpc( 

2139 request, 

2140 retry=retry, 

2141 timeout=timeout, 

2142 metadata=metadata, 

2143 ) 

2144 

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

2146 # an `__iter__` convenience method. 

2147 response = pagers.ListSinksPager( 

2148 method=rpc, 

2149 request=request, 

2150 response=response, 

2151 retry=retry, 

2152 timeout=timeout, 

2153 metadata=metadata, 

2154 ) 

2155 

2156 # Done; return the response. 

2157 return response 

2158 

2159 def get_sink( 

2160 self, 

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

2162 *, 

2163 sink_name: Optional[str] = None, 

2164 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

2167 ) -> logging_config.LogSink: 

2168 r"""Gets a sink. 

2169 

2170 .. code-block:: python 

2171 

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

2173 # code template only. 

2174 # It will require modifications to work: 

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

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

2177 # client as shown in: 

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

2179 from google.cloud import logging_v2 

2180 

2181 def sample_get_sink(): 

2182 # Create a client 

2183 client = logging_v2.ConfigServiceV2Client() 

2184 

2185 # Initialize request argument(s) 

2186 request = logging_v2.GetSinkRequest( 

2187 sink_name="sink_name_value", 

2188 ) 

2189 

2190 # Make the request 

2191 response = client.get_sink(request=request) 

2192 

2193 # Handle the response 

2194 print(response) 

2195 

2196 Args: 

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

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

2199 sink_name (str): 

2200 Required. The resource name of the sink: 

2201 

2202 :: 

2203 

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

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

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

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

2208 

2209 For example: 

2210 

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

2212 

2213 This corresponds to the ``sink_name`` field 

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

2215 should not be set. 

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

2217 should be retried. 

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

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

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

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

2222 be of type `bytes`. 

2223 

2224 Returns: 

2225 google.cloud.logging_v2.types.LogSink: 

2226 Describes a sink used to export log 

2227 entries to one of the following 

2228 destinations in any project: a Cloud 

2229 Storage bucket, a BigQuery dataset, a 

2230 Pub/Sub topic or a Cloud Logging log 

2231 bucket. A logs filter controls which log 

2232 entries are exported. The sink must be 

2233 created within a project, organization, 

2234 billing account, or folder. 

2235 

2236 """ 

2237 # Create or coerce a protobuf request object. 

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

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

2240 flattened_params = [sink_name] 

2241 has_flattened_params = ( 

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

2243 ) 

2244 if request is not None and has_flattened_params: 

2245 raise ValueError( 

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

2247 "the individual field arguments should be set." 

2248 ) 

2249 

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

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

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

2253 request = logging_config.GetSinkRequest(request) 

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

2255 # request, apply these. 

2256 if sink_name is not None: 

2257 request.sink_name = sink_name 

2258 

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

2260 # and friendly error handling. 

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

2262 

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

2264 # add these here. 

2265 metadata = tuple(metadata) + ( 

2266 gapic_v1.routing_header.to_grpc_metadata( 

2267 (("sink_name", request.sink_name),) 

2268 ), 

2269 ) 

2270 

2271 # Validate the universe domain. 

2272 self._validate_universe_domain() 

2273 

2274 # Send the request. 

2275 response = rpc( 

2276 request, 

2277 retry=retry, 

2278 timeout=timeout, 

2279 metadata=metadata, 

2280 ) 

2281 

2282 # Done; return the response. 

2283 return response 

2284 

2285 def create_sink( 

2286 self, 

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

2288 *, 

2289 parent: Optional[str] = None, 

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

2291 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

2294 ) -> logging_config.LogSink: 

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

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

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

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

2299 entries only from the resource owning the sink. 

2300 

2301 .. code-block:: python 

2302 

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

2304 # code template only. 

2305 # It will require modifications to work: 

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

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

2308 # client as shown in: 

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

2310 from google.cloud import logging_v2 

2311 

2312 def sample_create_sink(): 

2313 # Create a client 

2314 client = logging_v2.ConfigServiceV2Client() 

2315 

2316 # Initialize request argument(s) 

2317 sink = logging_v2.LogSink() 

2318 sink.name = "name_value" 

2319 sink.destination = "destination_value" 

2320 

2321 request = logging_v2.CreateSinkRequest( 

2322 parent="parent_value", 

2323 sink=sink, 

2324 ) 

2325 

2326 # Make the request 

2327 response = client.create_sink(request=request) 

2328 

2329 # Handle the response 

2330 print(response) 

2331 

2332 Args: 

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

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

2335 parent (str): 

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

2337 

2338 :: 

2339 

2340 "projects/[PROJECT_ID]" 

2341 "organizations/[ORGANIZATION_ID]" 

2342 "billingAccounts/[BILLING_ACCOUNT_ID]" 

2343 "folders/[FOLDER_ID]" 

2344 

2345 For examples: 

2346 

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

2348 

2349 This corresponds to the ``parent`` field 

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

2351 should not be set. 

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

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

2354 sink identifier that is not already in use. 

2355 

2356 This corresponds to the ``sink`` field 

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

2358 should not be set. 

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

2360 should be retried. 

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

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

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

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

2365 be of type `bytes`. 

2366 

2367 Returns: 

2368 google.cloud.logging_v2.types.LogSink: 

2369 Describes a sink used to export log 

2370 entries to one of the following 

2371 destinations in any project: a Cloud 

2372 Storage bucket, a BigQuery dataset, a 

2373 Pub/Sub topic or a Cloud Logging log 

2374 bucket. A logs filter controls which log 

2375 entries are exported. The sink must be 

2376 created within a project, organization, 

2377 billing account, or folder. 

2378 

2379 """ 

2380 # Create or coerce a protobuf request object. 

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

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

2383 flattened_params = [parent, sink] 

2384 has_flattened_params = ( 

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

2386 ) 

2387 if request is not None and has_flattened_params: 

2388 raise ValueError( 

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

2390 "the individual field arguments should be set." 

2391 ) 

2392 

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

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

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

2396 request = logging_config.CreateSinkRequest(request) 

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

2398 # request, apply these. 

2399 if parent is not None: 

2400 request.parent = parent 

2401 if sink is not None: 

2402 request.sink = sink 

2403 

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

2405 # and friendly error handling. 

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

2407 

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

2409 # add these here. 

2410 metadata = tuple(metadata) + ( 

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

2412 ) 

2413 

2414 # Validate the universe domain. 

2415 self._validate_universe_domain() 

2416 

2417 # Send the request. 

2418 response = rpc( 

2419 request, 

2420 retry=retry, 

2421 timeout=timeout, 

2422 metadata=metadata, 

2423 ) 

2424 

2425 # Done; return the response. 

2426 return response 

2427 

2428 def update_sink( 

2429 self, 

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

2431 *, 

2432 sink_name: Optional[str] = None, 

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

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

2435 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

2438 ) -> logging_config.LogSink: 

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

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

2441 and ``filter``. 

2442 

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

2444 the ``unique_writer_identity`` field. 

2445 

2446 .. code-block:: python 

2447 

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

2449 # code template only. 

2450 # It will require modifications to work: 

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

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

2453 # client as shown in: 

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

2455 from google.cloud import logging_v2 

2456 

2457 def sample_update_sink(): 

2458 # Create a client 

2459 client = logging_v2.ConfigServiceV2Client() 

2460 

2461 # Initialize request argument(s) 

2462 sink = logging_v2.LogSink() 

2463 sink.name = "name_value" 

2464 sink.destination = "destination_value" 

2465 

2466 request = logging_v2.UpdateSinkRequest( 

2467 sink_name="sink_name_value", 

2468 sink=sink, 

2469 ) 

2470 

2471 # Make the request 

2472 response = client.update_sink(request=request) 

2473 

2474 # Handle the response 

2475 print(response) 

2476 

2477 Args: 

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

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

2480 sink_name (str): 

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

2482 including the parent resource and the sink identifier: 

2483 

2484 :: 

2485 

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

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

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

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

2490 

2491 For example: 

2492 

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

2494 

2495 This corresponds to the ``sink_name`` field 

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

2497 should not be set. 

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

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

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

2501 

2502 This corresponds to the ``sink`` field 

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

2504 should not be set. 

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

2506 Optional. Field mask that specifies the fields in 

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

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

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

2510 

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

2512 the following mask for backwards compatibility purposes: 

2513 

2514 ``destination,filter,includeChildren`` 

2515 

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

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

2518 

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

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

2521 

2522 For example: ``updateMask=filter`` 

2523 

2524 This corresponds to the ``update_mask`` field 

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

2526 should not be set. 

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

2528 should be retried. 

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

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

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

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

2533 be of type `bytes`. 

2534 

2535 Returns: 

2536 google.cloud.logging_v2.types.LogSink: 

2537 Describes a sink used to export log 

2538 entries to one of the following 

2539 destinations in any project: a Cloud 

2540 Storage bucket, a BigQuery dataset, a 

2541 Pub/Sub topic or a Cloud Logging log 

2542 bucket. A logs filter controls which log 

2543 entries are exported. The sink must be 

2544 created within a project, organization, 

2545 billing account, or folder. 

2546 

2547 """ 

2548 # Create or coerce a protobuf request object. 

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

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

2551 flattened_params = [sink_name, sink, update_mask] 

2552 has_flattened_params = ( 

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

2554 ) 

2555 if request is not None and has_flattened_params: 

2556 raise ValueError( 

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

2558 "the individual field arguments should be set." 

2559 ) 

2560 

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

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

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

2564 request = logging_config.UpdateSinkRequest(request) 

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

2566 # request, apply these. 

2567 if sink_name is not None: 

2568 request.sink_name = sink_name 

2569 if sink is not None: 

2570 request.sink = sink 

2571 if update_mask is not None: 

2572 request.update_mask = update_mask 

2573 

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

2575 # and friendly error handling. 

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

2577 

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

2579 # add these here. 

2580 metadata = tuple(metadata) + ( 

2581 gapic_v1.routing_header.to_grpc_metadata( 

2582 (("sink_name", request.sink_name),) 

2583 ), 

2584 ) 

2585 

2586 # Validate the universe domain. 

2587 self._validate_universe_domain() 

2588 

2589 # Send the request. 

2590 response = rpc( 

2591 request, 

2592 retry=retry, 

2593 timeout=timeout, 

2594 metadata=metadata, 

2595 ) 

2596 

2597 # Done; return the response. 

2598 return response 

2599 

2600 def delete_sink( 

2601 self, 

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

2603 *, 

2604 sink_name: Optional[str] = None, 

2605 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

2608 ) -> None: 

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

2610 then that service account is also deleted. 

2611 

2612 .. code-block:: python 

2613 

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

2615 # code template only. 

2616 # It will require modifications to work: 

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

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

2619 # client as shown in: 

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

2621 from google.cloud import logging_v2 

2622 

2623 def sample_delete_sink(): 

2624 # Create a client 

2625 client = logging_v2.ConfigServiceV2Client() 

2626 

2627 # Initialize request argument(s) 

2628 request = logging_v2.DeleteSinkRequest( 

2629 sink_name="sink_name_value", 

2630 ) 

2631 

2632 # Make the request 

2633 client.delete_sink(request=request) 

2634 

2635 Args: 

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

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

2638 sink_name (str): 

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

2640 including the parent resource and the sink identifier: 

2641 

2642 :: 

2643 

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

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

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

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

2648 

2649 For example: 

2650 

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

2652 

2653 This corresponds to the ``sink_name`` field 

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

2655 should not be set. 

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

2657 should be retried. 

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

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

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

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

2662 be of type `bytes`. 

2663 """ 

2664 # Create or coerce a protobuf request object. 

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

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

2667 flattened_params = [sink_name] 

2668 has_flattened_params = ( 

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

2670 ) 

2671 if request is not None and has_flattened_params: 

2672 raise ValueError( 

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

2674 "the individual field arguments should be set." 

2675 ) 

2676 

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

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

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

2680 request = logging_config.DeleteSinkRequest(request) 

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

2682 # request, apply these. 

2683 if sink_name is not None: 

2684 request.sink_name = sink_name 

2685 

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

2687 # and friendly error handling. 

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

2689 

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

2691 # add these here. 

2692 metadata = tuple(metadata) + ( 

2693 gapic_v1.routing_header.to_grpc_metadata( 

2694 (("sink_name", request.sink_name),) 

2695 ), 

2696 ) 

2697 

2698 # Validate the universe domain. 

2699 self._validate_universe_domain() 

2700 

2701 # Send the request. 

2702 rpc( 

2703 request, 

2704 retry=retry, 

2705 timeout=timeout, 

2706 metadata=metadata, 

2707 ) 

2708 

2709 def create_link( 

2710 self, 

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

2712 *, 

2713 parent: Optional[str] = None, 

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

2715 link_id: Optional[str] = None, 

2716 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

2719 ) -> operation.Operation: 

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

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

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

2723 only contain one link. 

2724 

2725 .. code-block:: python 

2726 

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

2728 # code template only. 

2729 # It will require modifications to work: 

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

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

2732 # client as shown in: 

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

2734 from google.cloud import logging_v2 

2735 

2736 def sample_create_link(): 

2737 # Create a client 

2738 client = logging_v2.ConfigServiceV2Client() 

2739 

2740 # Initialize request argument(s) 

2741 request = logging_v2.CreateLinkRequest( 

2742 parent="parent_value", 

2743 link_id="link_id_value", 

2744 ) 

2745 

2746 # Make the request 

2747 operation = client.create_link(request=request) 

2748 

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

2750 

2751 response = operation.result() 

2752 

2753 # Handle the response 

2754 print(response) 

2755 

2756 Args: 

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

2758 The request object. The parameters to CreateLink. 

2759 parent (str): 

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

2761 a link for. 

2762 

2763 :: 

2764 

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

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

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

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

2769 

2770 This corresponds to the ``parent`` field 

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

2772 should not be set. 

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

2774 Required. The new link. 

2775 This corresponds to the ``link`` field 

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

2777 should not be set. 

2778 link_id (str): 

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

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

2781 have alphanumeric characters and underscores within it. 

2782 

2783 This corresponds to the ``link_id`` field 

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

2785 should not be set. 

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

2787 should be retried. 

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

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

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

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

2792 be of type `bytes`. 

2793 

2794 Returns: 

2795 google.api_core.operation.Operation: 

2796 An object representing a long-running operation. 

2797 

2798 The result type for the operation will be 

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

2800 link connected to an analytics enabled bucket. 

2801 

2802 """ 

2803 # Create or coerce a protobuf request object. 

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

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

2806 flattened_params = [parent, link, link_id] 

2807 has_flattened_params = ( 

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

2809 ) 

2810 if request is not None and has_flattened_params: 

2811 raise ValueError( 

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

2813 "the individual field arguments should be set." 

2814 ) 

2815 

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

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

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

2819 request = logging_config.CreateLinkRequest(request) 

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

2821 # request, apply these. 

2822 if parent is not None: 

2823 request.parent = parent 

2824 if link is not None: 

2825 request.link = link 

2826 if link_id is not None: 

2827 request.link_id = link_id 

2828 

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

2830 # and friendly error handling. 

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

2832 

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

2834 # add these here. 

2835 metadata = tuple(metadata) + ( 

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

2837 ) 

2838 

2839 # Validate the universe domain. 

2840 self._validate_universe_domain() 

2841 

2842 # Send the request. 

2843 response = rpc( 

2844 request, 

2845 retry=retry, 

2846 timeout=timeout, 

2847 metadata=metadata, 

2848 ) 

2849 

2850 # Wrap the response in an operation future. 

2851 response = operation.from_gapic( 

2852 response, 

2853 self._transport.operations_client, 

2854 logging_config.Link, 

2855 metadata_type=logging_config.LinkMetadata, 

2856 ) 

2857 

2858 # Done; return the response. 

2859 return response 

2860 

2861 def delete_link( 

2862 self, 

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

2864 *, 

2865 name: Optional[str] = None, 

2866 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

2869 ) -> operation.Operation: 

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

2871 corresponding BigQuery linked dataset. 

2872 

2873 .. code-block:: python 

2874 

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

2876 # code template only. 

2877 # It will require modifications to work: 

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

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

2880 # client as shown in: 

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

2882 from google.cloud import logging_v2 

2883 

2884 def sample_delete_link(): 

2885 # Create a client 

2886 client = logging_v2.ConfigServiceV2Client() 

2887 

2888 # Initialize request argument(s) 

2889 request = logging_v2.DeleteLinkRequest( 

2890 name="name_value", 

2891 ) 

2892 

2893 # Make the request 

2894 operation = client.delete_link(request=request) 

2895 

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

2897 

2898 response = operation.result() 

2899 

2900 # Handle the response 

2901 print(response) 

2902 

2903 Args: 

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

2905 The request object. The parameters to DeleteLink. 

2906 name (str): 

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

2908 

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

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

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

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

2913 

2914 This corresponds to the ``name`` field 

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

2916 should not be set. 

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

2918 should be retried. 

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

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

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

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

2923 be of type `bytes`. 

2924 

2925 Returns: 

2926 google.api_core.operation.Operation: 

2927 An object representing a long-running operation. 

2928 

2929 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 

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

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

2932 method. For instance: 

2933 

2934 service Foo { 

2935 rpc Bar(google.protobuf.Empty) returns 

2936 (google.protobuf.Empty); 

2937 

2938 } 

2939 

2940 """ 

2941 # Create or coerce a protobuf request object. 

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

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

2944 flattened_params = [name] 

2945 has_flattened_params = ( 

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

2947 ) 

2948 if request is not None and has_flattened_params: 

2949 raise ValueError( 

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

2951 "the individual field arguments should be set." 

2952 ) 

2953 

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

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

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

2957 request = logging_config.DeleteLinkRequest(request) 

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

2959 # request, apply these. 

2960 if name is not None: 

2961 request.name = name 

2962 

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

2964 # and friendly error handling. 

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

2966 

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

2968 # add these here. 

2969 metadata = tuple(metadata) + ( 

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

2971 ) 

2972 

2973 # Validate the universe domain. 

2974 self._validate_universe_domain() 

2975 

2976 # Send the request. 

2977 response = rpc( 

2978 request, 

2979 retry=retry, 

2980 timeout=timeout, 

2981 metadata=metadata, 

2982 ) 

2983 

2984 # Wrap the response in an operation future. 

2985 response = operation.from_gapic( 

2986 response, 

2987 self._transport.operations_client, 

2988 empty_pb2.Empty, 

2989 metadata_type=logging_config.LinkMetadata, 

2990 ) 

2991 

2992 # Done; return the response. 

2993 return response 

2994 

2995 def list_links( 

2996 self, 

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

2998 *, 

2999 parent: Optional[str] = None, 

3000 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

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

3003 ) -> pagers.ListLinksPager: 

3004 r"""Lists links. 

3005 

3006 .. code-block:: python 

3007 

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

3009 # code template only. 

3010 # It will require modifications to work: 

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

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

3013 # client as shown in: 

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

3015 from google.cloud import logging_v2 

3016 

3017 def sample_list_links(): 

3018 # Create a client 

3019 client = logging_v2.ConfigServiceV2Client() 

3020 

3021 # Initialize request argument(s) 

3022 request = logging_v2.ListLinksRequest( 

3023 parent="parent_value", 

3024 ) 

3025 

3026 # Make the request 

3027 page_result = client.list_links(request=request) 

3028 

3029 # Handle the response 

3030 for response in page_result: 

3031 print(response) 

3032 

3033 Args: 

3034 request (Union[google.cloud.logging_v2.types.ListLinksRequest, dict]): 

3035 The request object. The parameters to ListLinks. 

3036 parent (str): 

3037 Required. The parent resource whose links are to be 

3038 listed: 

3039 

3040 "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/" 

3041 "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/" 

3042 "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/" 

3043 "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/ 

3044 

3045 This corresponds to the ``parent`` field 

3046 on the ``request`` instance; if ``request`` is provided, this 

3047 should not be set. 

3048 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

3049 should be retried. 

3050 timeout (float): The timeout for this request. 

3051 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

3052 sent along with the request as metadata. Normally, each value must be of type `str`, 

3053 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

3054 be of type `bytes`. 

3055 

3056 Returns: 

3057 google.cloud.logging_v2.services.config_service_v2.pagers.ListLinksPager: 

3058 The response from ListLinks. 

3059 

3060 Iterating over this object will yield 

3061 results and resolve additional pages 

3062 automatically. 

3063 

3064 """ 

3065 # Create or coerce a protobuf request object. 

3066 # - Quick check: If we got a request object, we should *not* have 

3067 # gotten any keyword arguments that map to the request. 

3068 flattened_params = [parent] 

3069 has_flattened_params = ( 

3070 len([param for param in flattened_params if param is not None]) > 0 

3071 ) 

3072 if request is not None and has_flattened_params: 

3073 raise ValueError( 

3074 "If the `request` argument is set, then none of " 

3075 "the individual field arguments should be set." 

3076 ) 

3077 

3078 # - Use the request object if provided (there's no risk of modifying the input as 

3079 # there are no flattened fields), or create one. 

3080 if not isinstance(request, logging_config.ListLinksRequest): 

3081 request = logging_config.ListLinksRequest(request) 

3082 # If we have keyword arguments corresponding to fields on the 

3083 # request, apply these. 

3084 if parent is not None: 

3085 request.parent = parent 

3086 

3087 # Wrap the RPC method; this adds retry and timeout information, 

3088 # and friendly error handling. 

3089 rpc = self._transport._wrapped_methods[self._transport.list_links] 

3090 

3091 # Certain fields should be provided within the metadata header; 

3092 # add these here. 

3093 metadata = tuple(metadata) + ( 

3094 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), 

3095 ) 

3096 

3097 # Validate the universe domain. 

3098 self._validate_universe_domain() 

3099 

3100 # Send the request. 

3101 response = rpc( 

3102 request, 

3103 retry=retry, 

3104 timeout=timeout, 

3105 metadata=metadata, 

3106 ) 

3107 

3108 # This method is paged; wrap the response in a pager, which provides 

3109 # an `__iter__` convenience method. 

3110 response = pagers.ListLinksPager( 

3111 method=rpc, 

3112 request=request, 

3113 response=response, 

3114 retry=retry, 

3115 timeout=timeout, 

3116 metadata=metadata, 

3117 ) 

3118 

3119 # Done; return the response. 

3120 return response 

3121 

3122 def get_link( 

3123 self, 

3124 request: Optional[Union[logging_config.GetLinkRequest, dict]] = None, 

3125 *, 

3126 name: Optional[str] = None, 

3127 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3128 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

3129 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

3130 ) -> logging_config.Link: 

3131 r"""Gets a link. 

3132 

3133 .. code-block:: python 

3134 

3135 # This snippet has been automatically generated and should be regarded as a 

3136 # code template only. 

3137 # It will require modifications to work: 

3138 # - It may require correct/in-range values for request initialization. 

3139 # - It may require specifying regional endpoints when creating the service 

3140 # client as shown in: 

3141 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

3142 from google.cloud import logging_v2 

3143 

3144 def sample_get_link(): 

3145 # Create a client 

3146 client = logging_v2.ConfigServiceV2Client() 

3147 

3148 # Initialize request argument(s) 

3149 request = logging_v2.GetLinkRequest( 

3150 name="name_value", 

3151 ) 

3152 

3153 # Make the request 

3154 response = client.get_link(request=request) 

3155 

3156 # Handle the response 

3157 print(response) 

3158 

3159 Args: 

3160 request (Union[google.cloud.logging_v2.types.GetLinkRequest, dict]): 

3161 The request object. The parameters to GetLink. 

3162 name (str): 

3163 Required. The resource name of the link: 

3164 

3165 "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID]" 

3166 "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID]" 

3167 "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID]" 

3168 "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID] 

3169 

3170 This corresponds to the ``name`` field 

3171 on the ``request`` instance; if ``request`` is provided, this 

3172 should not be set. 

3173 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

3174 should be retried. 

3175 timeout (float): The timeout for this request. 

3176 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

3177 sent along with the request as metadata. Normally, each value must be of type `str`, 

3178 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

3179 be of type `bytes`. 

3180 

3181 Returns: 

3182 google.cloud.logging_v2.types.Link: 

3183 Describes a link connected to an 

3184 analytics enabled bucket. 

3185 

3186 """ 

3187 # Create or coerce a protobuf request object. 

3188 # - Quick check: If we got a request object, we should *not* have 

3189 # gotten any keyword arguments that map to the request. 

3190 flattened_params = [name] 

3191 has_flattened_params = ( 

3192 len([param for param in flattened_params if param is not None]) > 0 

3193 ) 

3194 if request is not None and has_flattened_params: 

3195 raise ValueError( 

3196 "If the `request` argument is set, then none of " 

3197 "the individual field arguments should be set." 

3198 ) 

3199 

3200 # - Use the request object if provided (there's no risk of modifying the input as 

3201 # there are no flattened fields), or create one. 

3202 if not isinstance(request, logging_config.GetLinkRequest): 

3203 request = logging_config.GetLinkRequest(request) 

3204 # If we have keyword arguments corresponding to fields on the 

3205 # request, apply these. 

3206 if name is not None: 

3207 request.name = name 

3208 

3209 # Wrap the RPC method; this adds retry and timeout information, 

3210 # and friendly error handling. 

3211 rpc = self._transport._wrapped_methods[self._transport.get_link] 

3212 

3213 # Certain fields should be provided within the metadata header; 

3214 # add these here. 

3215 metadata = tuple(metadata) + ( 

3216 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

3217 ) 

3218 

3219 # Validate the universe domain. 

3220 self._validate_universe_domain() 

3221 

3222 # Send the request. 

3223 response = rpc( 

3224 request, 

3225 retry=retry, 

3226 timeout=timeout, 

3227 metadata=metadata, 

3228 ) 

3229 

3230 # Done; return the response. 

3231 return response 

3232 

3233 def list_exclusions( 

3234 self, 

3235 request: Optional[Union[logging_config.ListExclusionsRequest, dict]] = None, 

3236 *, 

3237 parent: Optional[str] = None, 

3238 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3239 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

3240 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

3241 ) -> pagers.ListExclusionsPager: 

3242 r"""Lists all the exclusions on the \_Default sink in a parent 

3243 resource. 

3244 

3245 .. code-block:: python 

3246 

3247 # This snippet has been automatically generated and should be regarded as a 

3248 # code template only. 

3249 # It will require modifications to work: 

3250 # - It may require correct/in-range values for request initialization. 

3251 # - It may require specifying regional endpoints when creating the service 

3252 # client as shown in: 

3253 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

3254 from google.cloud import logging_v2 

3255 

3256 def sample_list_exclusions(): 

3257 # Create a client 

3258 client = logging_v2.ConfigServiceV2Client() 

3259 

3260 # Initialize request argument(s) 

3261 request = logging_v2.ListExclusionsRequest( 

3262 parent="parent_value", 

3263 ) 

3264 

3265 # Make the request 

3266 page_result = client.list_exclusions(request=request) 

3267 

3268 # Handle the response 

3269 for response in page_result: 

3270 print(response) 

3271 

3272 Args: 

3273 request (Union[google.cloud.logging_v2.types.ListExclusionsRequest, dict]): 

3274 The request object. The parameters to ``ListExclusions``. 

3275 parent (str): 

3276 Required. The parent resource whose exclusions are to be 

3277 listed. 

3278 

3279 :: 

3280 

3281 "projects/[PROJECT_ID]" 

3282 "organizations/[ORGANIZATION_ID]" 

3283 "billingAccounts/[BILLING_ACCOUNT_ID]" 

3284 "folders/[FOLDER_ID]" 

3285 

3286 This corresponds to the ``parent`` field 

3287 on the ``request`` instance; if ``request`` is provided, this 

3288 should not be set. 

3289 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

3290 should be retried. 

3291 timeout (float): The timeout for this request. 

3292 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

3293 sent along with the request as metadata. Normally, each value must be of type `str`, 

3294 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

3295 be of type `bytes`. 

3296 

3297 Returns: 

3298 google.cloud.logging_v2.services.config_service_v2.pagers.ListExclusionsPager: 

3299 Result returned from ListExclusions. 

3300 

3301 Iterating over this object will yield results and 

3302 resolve additional pages automatically. 

3303 

3304 """ 

3305 # Create or coerce a protobuf request object. 

3306 # - Quick check: If we got a request object, we should *not* have 

3307 # gotten any keyword arguments that map to the request. 

3308 flattened_params = [parent] 

3309 has_flattened_params = ( 

3310 len([param for param in flattened_params if param is not None]) > 0 

3311 ) 

3312 if request is not None and has_flattened_params: 

3313 raise ValueError( 

3314 "If the `request` argument is set, then none of " 

3315 "the individual field arguments should be set." 

3316 ) 

3317 

3318 # - Use the request object if provided (there's no risk of modifying the input as 

3319 # there are no flattened fields), or create one. 

3320 if not isinstance(request, logging_config.ListExclusionsRequest): 

3321 request = logging_config.ListExclusionsRequest(request) 

3322 # If we have keyword arguments corresponding to fields on the 

3323 # request, apply these. 

3324 if parent is not None: 

3325 request.parent = parent 

3326 

3327 # Wrap the RPC method; this adds retry and timeout information, 

3328 # and friendly error handling. 

3329 rpc = self._transport._wrapped_methods[self._transport.list_exclusions] 

3330 

3331 # Certain fields should be provided within the metadata header; 

3332 # add these here. 

3333 metadata = tuple(metadata) + ( 

3334 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), 

3335 ) 

3336 

3337 # Validate the universe domain. 

3338 self._validate_universe_domain() 

3339 

3340 # Send the request. 

3341 response = rpc( 

3342 request, 

3343 retry=retry, 

3344 timeout=timeout, 

3345 metadata=metadata, 

3346 ) 

3347 

3348 # This method is paged; wrap the response in a pager, which provides 

3349 # an `__iter__` convenience method. 

3350 response = pagers.ListExclusionsPager( 

3351 method=rpc, 

3352 request=request, 

3353 response=response, 

3354 retry=retry, 

3355 timeout=timeout, 

3356 metadata=metadata, 

3357 ) 

3358 

3359 # Done; return the response. 

3360 return response 

3361 

3362 def get_exclusion( 

3363 self, 

3364 request: Optional[Union[logging_config.GetExclusionRequest, dict]] = None, 

3365 *, 

3366 name: Optional[str] = None, 

3367 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3368 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

3369 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

3370 ) -> logging_config.LogExclusion: 

3371 r"""Gets the description of an exclusion in the \_Default sink. 

3372 

3373 .. code-block:: python 

3374 

3375 # This snippet has been automatically generated and should be regarded as a 

3376 # code template only. 

3377 # It will require modifications to work: 

3378 # - It may require correct/in-range values for request initialization. 

3379 # - It may require specifying regional endpoints when creating the service 

3380 # client as shown in: 

3381 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

3382 from google.cloud import logging_v2 

3383 

3384 def sample_get_exclusion(): 

3385 # Create a client 

3386 client = logging_v2.ConfigServiceV2Client() 

3387 

3388 # Initialize request argument(s) 

3389 request = logging_v2.GetExclusionRequest( 

3390 name="name_value", 

3391 ) 

3392 

3393 # Make the request 

3394 response = client.get_exclusion(request=request) 

3395 

3396 # Handle the response 

3397 print(response) 

3398 

3399 Args: 

3400 request (Union[google.cloud.logging_v2.types.GetExclusionRequest, dict]): 

3401 The request object. The parameters to ``GetExclusion``. 

3402 name (str): 

3403 Required. The resource name of an existing exclusion: 

3404 

3405 :: 

3406 

3407 "projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" 

3408 "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" 

3409 "billingAccounts/[BILLING_ACCOUNT_ID]/exclusions/[EXCLUSION_ID]" 

3410 "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]" 

3411 

3412 For example: 

3413 

3414 ``"projects/my-project/exclusions/my-exclusion"`` 

3415 

3416 This corresponds to the ``name`` field 

3417 on the ``request`` instance; if ``request`` is provided, this 

3418 should not be set. 

3419 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

3420 should be retried. 

3421 timeout (float): The timeout for this request. 

3422 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

3423 sent along with the request as metadata. Normally, each value must be of type `str`, 

3424 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

3425 be of type `bytes`. 

3426 

3427 Returns: 

3428 google.cloud.logging_v2.types.LogExclusion: 

3429 Specifies a set of log entries that are filtered out by a sink. If 

3430 your Google Cloud resource receives a large volume of 

3431 log entries, you can use exclusions to reduce your 

3432 chargeable logs. Note that exclusions on 

3433 organization-level and folder-level sinks don't apply 

3434 to child resources. Note also that you cannot modify 

3435 the Required sink or exclude logs from it. 

3436 

3437 """ 

3438 # Create or coerce a protobuf request object. 

3439 # - Quick check: If we got a request object, we should *not* have 

3440 # gotten any keyword arguments that map to the request. 

3441 flattened_params = [name] 

3442 has_flattened_params = ( 

3443 len([param for param in flattened_params if param is not None]) > 0 

3444 ) 

3445 if request is not None and has_flattened_params: 

3446 raise ValueError( 

3447 "If the `request` argument is set, then none of " 

3448 "the individual field arguments should be set." 

3449 ) 

3450 

3451 # - Use the request object if provided (there's no risk of modifying the input as 

3452 # there are no flattened fields), or create one. 

3453 if not isinstance(request, logging_config.GetExclusionRequest): 

3454 request = logging_config.GetExclusionRequest(request) 

3455 # If we have keyword arguments corresponding to fields on the 

3456 # request, apply these. 

3457 if name is not None: 

3458 request.name = name 

3459 

3460 # Wrap the RPC method; this adds retry and timeout information, 

3461 # and friendly error handling. 

3462 rpc = self._transport._wrapped_methods[self._transport.get_exclusion] 

3463 

3464 # Certain fields should be provided within the metadata header; 

3465 # add these here. 

3466 metadata = tuple(metadata) + ( 

3467 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

3468 ) 

3469 

3470 # Validate the universe domain. 

3471 self._validate_universe_domain() 

3472 

3473 # Send the request. 

3474 response = rpc( 

3475 request, 

3476 retry=retry, 

3477 timeout=timeout, 

3478 metadata=metadata, 

3479 ) 

3480 

3481 # Done; return the response. 

3482 return response 

3483 

3484 def create_exclusion( 

3485 self, 

3486 request: Optional[Union[logging_config.CreateExclusionRequest, dict]] = None, 

3487 *, 

3488 parent: Optional[str] = None, 

3489 exclusion: Optional[logging_config.LogExclusion] = None, 

3490 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3491 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

3492 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

3493 ) -> logging_config.LogExclusion: 

3494 r"""Creates a new exclusion in the \_Default sink in a specified 

3495 parent resource. Only log entries belonging to that resource can 

3496 be excluded. You can have up to 10 exclusions in a resource. 

3497 

3498 .. code-block:: python 

3499 

3500 # This snippet has been automatically generated and should be regarded as a 

3501 # code template only. 

3502 # It will require modifications to work: 

3503 # - It may require correct/in-range values for request initialization. 

3504 # - It may require specifying regional endpoints when creating the service 

3505 # client as shown in: 

3506 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

3507 from google.cloud import logging_v2 

3508 

3509 def sample_create_exclusion(): 

3510 # Create a client 

3511 client = logging_v2.ConfigServiceV2Client() 

3512 

3513 # Initialize request argument(s) 

3514 exclusion = logging_v2.LogExclusion() 

3515 exclusion.name = "name_value" 

3516 exclusion.filter = "filter_value" 

3517 

3518 request = logging_v2.CreateExclusionRequest( 

3519 parent="parent_value", 

3520 exclusion=exclusion, 

3521 ) 

3522 

3523 # Make the request 

3524 response = client.create_exclusion(request=request) 

3525 

3526 # Handle the response 

3527 print(response) 

3528 

3529 Args: 

3530 request (Union[google.cloud.logging_v2.types.CreateExclusionRequest, dict]): 

3531 The request object. The parameters to ``CreateExclusion``. 

3532 parent (str): 

3533 Required. The parent resource in which to create the 

3534 exclusion: 

3535 

3536 :: 

3537 

3538 "projects/[PROJECT_ID]" 

3539 "organizations/[ORGANIZATION_ID]" 

3540 "billingAccounts/[BILLING_ACCOUNT_ID]" 

3541 "folders/[FOLDER_ID]" 

3542 

3543 For examples: 

3544 

3545 ``"projects/my-logging-project"`` 

3546 ``"organizations/123456789"`` 

3547 

3548 This corresponds to the ``parent`` field 

3549 on the ``request`` instance; if ``request`` is provided, this 

3550 should not be set. 

3551 exclusion (google.cloud.logging_v2.types.LogExclusion): 

3552 Required. The new exclusion, whose ``name`` parameter is 

3553 an exclusion name that is not already used in the parent 

3554 resource. 

3555 

3556 This corresponds to the ``exclusion`` field 

3557 on the ``request`` instance; if ``request`` is provided, this 

3558 should not be set. 

3559 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

3560 should be retried. 

3561 timeout (float): The timeout for this request. 

3562 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

3563 sent along with the request as metadata. Normally, each value must be of type `str`, 

3564 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

3565 be of type `bytes`. 

3566 

3567 Returns: 

3568 google.cloud.logging_v2.types.LogExclusion: 

3569 Specifies a set of log entries that are filtered out by a sink. If 

3570 your Google Cloud resource receives a large volume of 

3571 log entries, you can use exclusions to reduce your 

3572 chargeable logs. Note that exclusions on 

3573 organization-level and folder-level sinks don't apply 

3574 to child resources. Note also that you cannot modify 

3575 the Required sink or exclude logs from it. 

3576 

3577 """ 

3578 # Create or coerce a protobuf request object. 

3579 # - Quick check: If we got a request object, we should *not* have 

3580 # gotten any keyword arguments that map to the request. 

3581 flattened_params = [parent, exclusion] 

3582 has_flattened_params = ( 

3583 len([param for param in flattened_params if param is not None]) > 0 

3584 ) 

3585 if request is not None and has_flattened_params: 

3586 raise ValueError( 

3587 "If the `request` argument is set, then none of " 

3588 "the individual field arguments should be set." 

3589 ) 

3590 

3591 # - Use the request object if provided (there's no risk of modifying the input as 

3592 # there are no flattened fields), or create one. 

3593 if not isinstance(request, logging_config.CreateExclusionRequest): 

3594 request = logging_config.CreateExclusionRequest(request) 

3595 # If we have keyword arguments corresponding to fields on the 

3596 # request, apply these. 

3597 if parent is not None: 

3598 request.parent = parent 

3599 if exclusion is not None: 

3600 request.exclusion = exclusion 

3601 

3602 # Wrap the RPC method; this adds retry and timeout information, 

3603 # and friendly error handling. 

3604 rpc = self._transport._wrapped_methods[self._transport.create_exclusion] 

3605 

3606 # Certain fields should be provided within the metadata header; 

3607 # add these here. 

3608 metadata = tuple(metadata) + ( 

3609 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), 

3610 ) 

3611 

3612 # Validate the universe domain. 

3613 self._validate_universe_domain() 

3614 

3615 # Send the request. 

3616 response = rpc( 

3617 request, 

3618 retry=retry, 

3619 timeout=timeout, 

3620 metadata=metadata, 

3621 ) 

3622 

3623 # Done; return the response. 

3624 return response 

3625 

3626 def update_exclusion( 

3627 self, 

3628 request: Optional[Union[logging_config.UpdateExclusionRequest, dict]] = None, 

3629 *, 

3630 name: Optional[str] = None, 

3631 exclusion: Optional[logging_config.LogExclusion] = None, 

3632 update_mask: Optional[field_mask_pb2.FieldMask] = None, 

3633 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3634 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

3635 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

3636 ) -> logging_config.LogExclusion: 

3637 r"""Changes one or more properties of an existing exclusion in the 

3638 \_Default sink. 

3639 

3640 .. code-block:: python 

3641 

3642 # This snippet has been automatically generated and should be regarded as a 

3643 # code template only. 

3644 # It will require modifications to work: 

3645 # - It may require correct/in-range values for request initialization. 

3646 # - It may require specifying regional endpoints when creating the service 

3647 # client as shown in: 

3648 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

3649 from google.cloud import logging_v2 

3650 

3651 def sample_update_exclusion(): 

3652 # Create a client 

3653 client = logging_v2.ConfigServiceV2Client() 

3654 

3655 # Initialize request argument(s) 

3656 exclusion = logging_v2.LogExclusion() 

3657 exclusion.name = "name_value" 

3658 exclusion.filter = "filter_value" 

3659 

3660 request = logging_v2.UpdateExclusionRequest( 

3661 name="name_value", 

3662 exclusion=exclusion, 

3663 ) 

3664 

3665 # Make the request 

3666 response = client.update_exclusion(request=request) 

3667 

3668 # Handle the response 

3669 print(response) 

3670 

3671 Args: 

3672 request (Union[google.cloud.logging_v2.types.UpdateExclusionRequest, dict]): 

3673 The request object. The parameters to ``UpdateExclusion``. 

3674 name (str): 

3675 Required. The resource name of the exclusion to update: 

3676 

3677 :: 

3678 

3679 "projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" 

3680 "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" 

3681 "billingAccounts/[BILLING_ACCOUNT_ID]/exclusions/[EXCLUSION_ID]" 

3682 "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]" 

3683 

3684 For example: 

3685 

3686 ``"projects/my-project/exclusions/my-exclusion"`` 

3687 

3688 This corresponds to the ``name`` field 

3689 on the ``request`` instance; if ``request`` is provided, this 

3690 should not be set. 

3691 exclusion (google.cloud.logging_v2.types.LogExclusion): 

3692 Required. New values for the existing exclusion. Only 

3693 the fields specified in ``update_mask`` are relevant. 

3694 

3695 This corresponds to the ``exclusion`` field 

3696 on the ``request`` instance; if ``request`` is provided, this 

3697 should not be set. 

3698 update_mask (google.protobuf.field_mask_pb2.FieldMask): 

3699 Required. A non-empty list of fields to change in the 

3700 existing exclusion. New values for the fields are taken 

3701 from the corresponding fields in the 

3702 [LogExclusion][google.logging.v2.LogExclusion] included 

3703 in this request. Fields not mentioned in ``update_mask`` 

3704 are not changed and are ignored in the request. 

3705 

3706 For example, to change the filter and description of an 

3707 exclusion, specify an ``update_mask`` of 

3708 ``"filter,description"``. 

3709 

3710 This corresponds to the ``update_mask`` field 

3711 on the ``request`` instance; if ``request`` is provided, this 

3712 should not be set. 

3713 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

3714 should be retried. 

3715 timeout (float): The timeout for this request. 

3716 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

3717 sent along with the request as metadata. Normally, each value must be of type `str`, 

3718 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

3719 be of type `bytes`. 

3720 

3721 Returns: 

3722 google.cloud.logging_v2.types.LogExclusion: 

3723 Specifies a set of log entries that are filtered out by a sink. If 

3724 your Google Cloud resource receives a large volume of 

3725 log entries, you can use exclusions to reduce your 

3726 chargeable logs. Note that exclusions on 

3727 organization-level and folder-level sinks don't apply 

3728 to child resources. Note also that you cannot modify 

3729 the Required sink or exclude logs from it. 

3730 

3731 """ 

3732 # Create or coerce a protobuf request object. 

3733 # - Quick check: If we got a request object, we should *not* have 

3734 # gotten any keyword arguments that map to the request. 

3735 flattened_params = [name, exclusion, update_mask] 

3736 has_flattened_params = ( 

3737 len([param for param in flattened_params if param is not None]) > 0 

3738 ) 

3739 if request is not None and has_flattened_params: 

3740 raise ValueError( 

3741 "If the `request` argument is set, then none of " 

3742 "the individual field arguments should be set." 

3743 ) 

3744 

3745 # - Use the request object if provided (there's no risk of modifying the input as 

3746 # there are no flattened fields), or create one. 

3747 if not isinstance(request, logging_config.UpdateExclusionRequest): 

3748 request = logging_config.UpdateExclusionRequest(request) 

3749 # If we have keyword arguments corresponding to fields on the 

3750 # request, apply these. 

3751 if name is not None: 

3752 request.name = name 

3753 if exclusion is not None: 

3754 request.exclusion = exclusion 

3755 if update_mask is not None: 

3756 request.update_mask = update_mask 

3757 

3758 # Wrap the RPC method; this adds retry and timeout information, 

3759 # and friendly error handling. 

3760 rpc = self._transport._wrapped_methods[self._transport.update_exclusion] 

3761 

3762 # Certain fields should be provided within the metadata header; 

3763 # add these here. 

3764 metadata = tuple(metadata) + ( 

3765 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

3766 ) 

3767 

3768 # Validate the universe domain. 

3769 self._validate_universe_domain() 

3770 

3771 # Send the request. 

3772 response = rpc( 

3773 request, 

3774 retry=retry, 

3775 timeout=timeout, 

3776 metadata=metadata, 

3777 ) 

3778 

3779 # Done; return the response. 

3780 return response 

3781 

3782 def delete_exclusion( 

3783 self, 

3784 request: Optional[Union[logging_config.DeleteExclusionRequest, dict]] = None, 

3785 *, 

3786 name: Optional[str] = None, 

3787 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3788 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

3789 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

3790 ) -> None: 

3791 r"""Deletes an exclusion in the \_Default sink. 

3792 

3793 .. code-block:: python 

3794 

3795 # This snippet has been automatically generated and should be regarded as a 

3796 # code template only. 

3797 # It will require modifications to work: 

3798 # - It may require correct/in-range values for request initialization. 

3799 # - It may require specifying regional endpoints when creating the service 

3800 # client as shown in: 

3801 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

3802 from google.cloud import logging_v2 

3803 

3804 def sample_delete_exclusion(): 

3805 # Create a client 

3806 client = logging_v2.ConfigServiceV2Client() 

3807 

3808 # Initialize request argument(s) 

3809 request = logging_v2.DeleteExclusionRequest( 

3810 name="name_value", 

3811 ) 

3812 

3813 # Make the request 

3814 client.delete_exclusion(request=request) 

3815 

3816 Args: 

3817 request (Union[google.cloud.logging_v2.types.DeleteExclusionRequest, dict]): 

3818 The request object. The parameters to ``DeleteExclusion``. 

3819 name (str): 

3820 Required. The resource name of an existing exclusion to 

3821 delete: 

3822 

3823 :: 

3824 

3825 "projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" 

3826 "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" 

3827 "billingAccounts/[BILLING_ACCOUNT_ID]/exclusions/[EXCLUSION_ID]" 

3828 "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]" 

3829 

3830 For example: 

3831 

3832 ``"projects/my-project/exclusions/my-exclusion"`` 

3833 

3834 This corresponds to the ``name`` field 

3835 on the ``request`` instance; if ``request`` is provided, this 

3836 should not be set. 

3837 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

3838 should be retried. 

3839 timeout (float): The timeout for this request. 

3840 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

3841 sent along with the request as metadata. Normally, each value must be of type `str`, 

3842 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

3843 be of type `bytes`. 

3844 """ 

3845 # Create or coerce a protobuf request object. 

3846 # - Quick check: If we got a request object, we should *not* have 

3847 # gotten any keyword arguments that map to the request. 

3848 flattened_params = [name] 

3849 has_flattened_params = ( 

3850 len([param for param in flattened_params if param is not None]) > 0 

3851 ) 

3852 if request is not None and has_flattened_params: 

3853 raise ValueError( 

3854 "If the `request` argument is set, then none of " 

3855 "the individual field arguments should be set." 

3856 ) 

3857 

3858 # - Use the request object if provided (there's no risk of modifying the input as 

3859 # there are no flattened fields), or create one. 

3860 if not isinstance(request, logging_config.DeleteExclusionRequest): 

3861 request = logging_config.DeleteExclusionRequest(request) 

3862 # If we have keyword arguments corresponding to fields on the 

3863 # request, apply these. 

3864 if name is not None: 

3865 request.name = name 

3866 

3867 # Wrap the RPC method; this adds retry and timeout information, 

3868 # and friendly error handling. 

3869 rpc = self._transport._wrapped_methods[self._transport.delete_exclusion] 

3870 

3871 # Certain fields should be provided within the metadata header; 

3872 # add these here. 

3873 metadata = tuple(metadata) + ( 

3874 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

3875 ) 

3876 

3877 # Validate the universe domain. 

3878 self._validate_universe_domain() 

3879 

3880 # Send the request. 

3881 rpc( 

3882 request, 

3883 retry=retry, 

3884 timeout=timeout, 

3885 metadata=metadata, 

3886 ) 

3887 

3888 def get_cmek_settings( 

3889 self, 

3890 request: Optional[Union[logging_config.GetCmekSettingsRequest, dict]] = None, 

3891 *, 

3892 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3893 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

3894 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

3895 ) -> logging_config.CmekSettings: 

3896 r"""Gets the Logging CMEK settings for the given resource. 

3897 

3898 Note: CMEK for the Log Router can be configured for Google Cloud 

3899 projects, folders, organizations and billing accounts. Once 

3900 configured for an organization, it applies to all projects and 

3901 folders in the Google Cloud organization. 

3902 

3903 See `Enabling CMEK for Log 

3904 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__ 

3905 for more information. 

3906 

3907 .. code-block:: python 

3908 

3909 # This snippet has been automatically generated and should be regarded as a 

3910 # code template only. 

3911 # It will require modifications to work: 

3912 # - It may require correct/in-range values for request initialization. 

3913 # - It may require specifying regional endpoints when creating the service 

3914 # client as shown in: 

3915 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

3916 from google.cloud import logging_v2 

3917 

3918 def sample_get_cmek_settings(): 

3919 # Create a client 

3920 client = logging_v2.ConfigServiceV2Client() 

3921 

3922 # Initialize request argument(s) 

3923 request = logging_v2.GetCmekSettingsRequest( 

3924 name="name_value", 

3925 ) 

3926 

3927 # Make the request 

3928 response = client.get_cmek_settings(request=request) 

3929 

3930 # Handle the response 

3931 print(response) 

3932 

3933 Args: 

3934 request (Union[google.cloud.logging_v2.types.GetCmekSettingsRequest, dict]): 

3935 The request object. The parameters to 

3936 [GetCmekSettings][google.logging.v2.ConfigServiceV2.GetCmekSettings]. 

3937 

3938 See `Enabling CMEK for Log 

3939 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__ 

3940 for more information. 

3941 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

3942 should be retried. 

3943 timeout (float): The timeout for this request. 

3944 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

3945 sent along with the request as metadata. Normally, each value must be of type `str`, 

3946 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

3947 be of type `bytes`. 

3948 

3949 Returns: 

3950 google.cloud.logging_v2.types.CmekSettings: 

3951 Describes the customer-managed encryption key (CMEK) settings associated with 

3952 a project, folder, organization, billing account, or 

3953 flexible resource. 

3954 

3955 Note: CMEK for the Log Router can currently only be 

3956 configured for Google Cloud organizations. Once 

3957 configured, it applies to all projects and folders in 

3958 the Google Cloud organization. 

3959 

3960 See [Enabling CMEK for Log 

3961 Router](https://cloud.google.com/logging/docs/routing/managed-encryption) 

3962 for more information. 

3963 

3964 """ 

3965 # Create or coerce a protobuf request object. 

3966 # - Use the request object if provided (there's no risk of modifying the input as 

3967 # there are no flattened fields), or create one. 

3968 if not isinstance(request, logging_config.GetCmekSettingsRequest): 

3969 request = logging_config.GetCmekSettingsRequest(request) 

3970 

3971 # Wrap the RPC method; this adds retry and timeout information, 

3972 # and friendly error handling. 

3973 rpc = self._transport._wrapped_methods[self._transport.get_cmek_settings] 

3974 

3975 # Certain fields should be provided within the metadata header; 

3976 # add these here. 

3977 metadata = tuple(metadata) + ( 

3978 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

3979 ) 

3980 

3981 # Validate the universe domain. 

3982 self._validate_universe_domain() 

3983 

3984 # Send the request. 

3985 response = rpc( 

3986 request, 

3987 retry=retry, 

3988 timeout=timeout, 

3989 metadata=metadata, 

3990 ) 

3991 

3992 # Done; return the response. 

3993 return response 

3994 

3995 def update_cmek_settings( 

3996 self, 

3997 request: Optional[Union[logging_config.UpdateCmekSettingsRequest, dict]] = None, 

3998 *, 

3999 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

4000 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

4001 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

4002 ) -> logging_config.CmekSettings: 

4003 r"""Updates the Log Router CMEK settings for the given resource. 

4004 

4005 Note: CMEK for the Log Router can currently only be configured 

4006 for Google Cloud organizations. Once configured, it applies to 

4007 all projects and folders in the Google Cloud organization. 

4008 

4009 [UpdateCmekSettings][google.logging.v2.ConfigServiceV2.UpdateCmekSettings] 

4010 will fail if 1) ``kms_key_name`` is invalid, or 2) the 

4011 associated service account does not have the required 

4012 ``roles/cloudkms.cryptoKeyEncrypterDecrypter`` role assigned for 

4013 the key, or 3) access to the key is disabled. 

4014 

4015 See `Enabling CMEK for Log 

4016 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__ 

4017 for more information. 

4018 

4019 .. code-block:: python 

4020 

4021 # This snippet has been automatically generated and should be regarded as a 

4022 # code template only. 

4023 # It will require modifications to work: 

4024 # - It may require correct/in-range values for request initialization. 

4025 # - It may require specifying regional endpoints when creating the service 

4026 # client as shown in: 

4027 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

4028 from google.cloud import logging_v2 

4029 

4030 def sample_update_cmek_settings(): 

4031 # Create a client 

4032 client = logging_v2.ConfigServiceV2Client() 

4033 

4034 # Initialize request argument(s) 

4035 request = logging_v2.UpdateCmekSettingsRequest( 

4036 name="name_value", 

4037 ) 

4038 

4039 # Make the request 

4040 response = client.update_cmek_settings(request=request) 

4041 

4042 # Handle the response 

4043 print(response) 

4044 

4045 Args: 

4046 request (Union[google.cloud.logging_v2.types.UpdateCmekSettingsRequest, dict]): 

4047 The request object. The parameters to 

4048 [UpdateCmekSettings][google.logging.v2.ConfigServiceV2.UpdateCmekSettings]. 

4049 

4050 See `Enabling CMEK for Log 

4051 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__ 

4052 for more information. 

4053 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

4054 should be retried. 

4055 timeout (float): The timeout for this request. 

4056 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

4057 sent along with the request as metadata. Normally, each value must be of type `str`, 

4058 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

4059 be of type `bytes`. 

4060 

4061 Returns: 

4062 google.cloud.logging_v2.types.CmekSettings: 

4063 Describes the customer-managed encryption key (CMEK) settings associated with 

4064 a project, folder, organization, billing account, or 

4065 flexible resource. 

4066 

4067 Note: CMEK for the Log Router can currently only be 

4068 configured for Google Cloud organizations. Once 

4069 configured, it applies to all projects and folders in 

4070 the Google Cloud organization. 

4071 

4072 See [Enabling CMEK for Log 

4073 Router](https://cloud.google.com/logging/docs/routing/managed-encryption) 

4074 for more information. 

4075 

4076 """ 

4077 # Create or coerce a protobuf request object. 

4078 # - Use the request object if provided (there's no risk of modifying the input as 

4079 # there are no flattened fields), or create one. 

4080 if not isinstance(request, logging_config.UpdateCmekSettingsRequest): 

4081 request = logging_config.UpdateCmekSettingsRequest(request) 

4082 

4083 # Wrap the RPC method; this adds retry and timeout information, 

4084 # and friendly error handling. 

4085 rpc = self._transport._wrapped_methods[self._transport.update_cmek_settings] 

4086 

4087 # Certain fields should be provided within the metadata header; 

4088 # add these here. 

4089 metadata = tuple(metadata) + ( 

4090 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

4091 ) 

4092 

4093 # Validate the universe domain. 

4094 self._validate_universe_domain() 

4095 

4096 # Send the request. 

4097 response = rpc( 

4098 request, 

4099 retry=retry, 

4100 timeout=timeout, 

4101 metadata=metadata, 

4102 ) 

4103 

4104 # Done; return the response. 

4105 return response 

4106 

4107 def get_settings( 

4108 self, 

4109 request: Optional[Union[logging_config.GetSettingsRequest, dict]] = None, 

4110 *, 

4111 name: Optional[str] = None, 

4112 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

4113 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

4114 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

4115 ) -> logging_config.Settings: 

4116 r"""Gets the Log Router settings for the given resource. 

4117 

4118 Note: Settings for the Log Router can be get for Google Cloud 

4119 projects, folders, organizations and billing accounts. Currently 

4120 it can only be configured for organizations. Once configured for 

4121 an organization, it applies to all projects and folders in the 

4122 Google Cloud organization. 

4123 

4124 See `Enabling CMEK for Log 

4125 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__ 

4126 for more information. 

4127 

4128 .. code-block:: python 

4129 

4130 # This snippet has been automatically generated and should be regarded as a 

4131 # code template only. 

4132 # It will require modifications to work: 

4133 # - It may require correct/in-range values for request initialization. 

4134 # - It may require specifying regional endpoints when creating the service 

4135 # client as shown in: 

4136 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

4137 from google.cloud import logging_v2 

4138 

4139 def sample_get_settings(): 

4140 # Create a client 

4141 client = logging_v2.ConfigServiceV2Client() 

4142 

4143 # Initialize request argument(s) 

4144 request = logging_v2.GetSettingsRequest( 

4145 name="name_value", 

4146 ) 

4147 

4148 # Make the request 

4149 response = client.get_settings(request=request) 

4150 

4151 # Handle the response 

4152 print(response) 

4153 

4154 Args: 

4155 request (Union[google.cloud.logging_v2.types.GetSettingsRequest, dict]): 

4156 The request object. The parameters to 

4157 [GetSettings][google.logging.v2.ConfigServiceV2.GetSettings]. 

4158 

4159 See `Enabling CMEK for Log 

4160 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__ 

4161 for more information. 

4162 name (str): 

4163 Required. The resource for which to retrieve settings. 

4164 

4165 :: 

4166 

4167 "projects/[PROJECT_ID]/settings" 

4168 "organizations/[ORGANIZATION_ID]/settings" 

4169 "billingAccounts/[BILLING_ACCOUNT_ID]/settings" 

4170 "folders/[FOLDER_ID]/settings" 

4171 

4172 For example: 

4173 

4174 ``"organizations/12345/settings"`` 

4175 

4176 Note: Settings for the Log Router can be get for Google 

4177 Cloud projects, folders, organizations and billing 

4178 accounts. Currently it can only be configured for 

4179 organizations. Once configured for an organization, it 

4180 applies to all projects and folders in the Google Cloud 

4181 organization. 

4182 

4183 This corresponds to the ``name`` field 

4184 on the ``request`` instance; if ``request`` is provided, this 

4185 should not be set. 

4186 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

4187 should be retried. 

4188 timeout (float): The timeout for this request. 

4189 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

4190 sent along with the request as metadata. Normally, each value must be of type `str`, 

4191 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

4192 be of type `bytes`. 

4193 

4194 Returns: 

4195 google.cloud.logging_v2.types.Settings: 

4196 Describes the settings associated 

4197 with a project, folder, organization, 

4198 billing account, or flexible resource. 

4199 

4200 """ 

4201 # Create or coerce a protobuf request object. 

4202 # - Quick check: If we got a request object, we should *not* have 

4203 # gotten any keyword arguments that map to the request. 

4204 flattened_params = [name] 

4205 has_flattened_params = ( 

4206 len([param for param in flattened_params if param is not None]) > 0 

4207 ) 

4208 if request is not None and has_flattened_params: 

4209 raise ValueError( 

4210 "If the `request` argument is set, then none of " 

4211 "the individual field arguments should be set." 

4212 ) 

4213 

4214 # - Use the request object if provided (there's no risk of modifying the input as 

4215 # there are no flattened fields), or create one. 

4216 if not isinstance(request, logging_config.GetSettingsRequest): 

4217 request = logging_config.GetSettingsRequest(request) 

4218 # If we have keyword arguments corresponding to fields on the 

4219 # request, apply these. 

4220 if name is not None: 

4221 request.name = name 

4222 

4223 # Wrap the RPC method; this adds retry and timeout information, 

4224 # and friendly error handling. 

4225 rpc = self._transport._wrapped_methods[self._transport.get_settings] 

4226 

4227 # Certain fields should be provided within the metadata header; 

4228 # add these here. 

4229 metadata = tuple(metadata) + ( 

4230 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

4231 ) 

4232 

4233 # Validate the universe domain. 

4234 self._validate_universe_domain() 

4235 

4236 # Send the request. 

4237 response = rpc( 

4238 request, 

4239 retry=retry, 

4240 timeout=timeout, 

4241 metadata=metadata, 

4242 ) 

4243 

4244 # Done; return the response. 

4245 return response 

4246 

4247 def update_settings( 

4248 self, 

4249 request: Optional[Union[logging_config.UpdateSettingsRequest, dict]] = None, 

4250 *, 

4251 settings: Optional[logging_config.Settings] = None, 

4252 update_mask: Optional[field_mask_pb2.FieldMask] = None, 

4253 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

4254 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

4255 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

4256 ) -> logging_config.Settings: 

4257 r"""Updates the Log Router settings for the given resource. 

4258 

4259 Note: Settings for the Log Router can currently only be 

4260 configured for Google Cloud organizations. Once configured, it 

4261 applies to all projects and folders in the Google Cloud 

4262 organization. 

4263 

4264 [UpdateSettings][google.logging.v2.ConfigServiceV2.UpdateSettings] 

4265 will fail if 1) ``kms_key_name`` is invalid, or 2) the 

4266 associated service account does not have the required 

4267 ``roles/cloudkms.cryptoKeyEncrypterDecrypter`` role assigned for 

4268 the key, or 3) access to the key is disabled. 4) ``location_id`` 

4269 is not supported by Logging. 5) ``location_id`` violate 

4270 OrgPolicy. 

4271 

4272 See `Enabling CMEK for Log 

4273 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__ 

4274 for more information. 

4275 

4276 .. code-block:: python 

4277 

4278 # This snippet has been automatically generated and should be regarded as a 

4279 # code template only. 

4280 # It will require modifications to work: 

4281 # - It may require correct/in-range values for request initialization. 

4282 # - It may require specifying regional endpoints when creating the service 

4283 # client as shown in: 

4284 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

4285 from google.cloud import logging_v2 

4286 

4287 def sample_update_settings(): 

4288 # Create a client 

4289 client = logging_v2.ConfigServiceV2Client() 

4290 

4291 # Initialize request argument(s) 

4292 request = logging_v2.UpdateSettingsRequest( 

4293 name="name_value", 

4294 ) 

4295 

4296 # Make the request 

4297 response = client.update_settings(request=request) 

4298 

4299 # Handle the response 

4300 print(response) 

4301 

4302 Args: 

4303 request (Union[google.cloud.logging_v2.types.UpdateSettingsRequest, dict]): 

4304 The request object. The parameters to 

4305 [UpdateSettings][google.logging.v2.ConfigServiceV2.UpdateSettings]. 

4306 

4307 See `Enabling CMEK for Log 

4308 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__ 

4309 for more information. 

4310 settings (google.cloud.logging_v2.types.Settings): 

4311 Required. The settings to update. 

4312 

4313 See `Enabling CMEK for Log 

4314 Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__ 

4315 for more information. 

4316 

4317 This corresponds to the ``settings`` field 

4318 on the ``request`` instance; if ``request`` is provided, this 

4319 should not be set. 

4320 update_mask (google.protobuf.field_mask_pb2.FieldMask): 

4321 Optional. Field mask identifying which fields from 

4322 ``settings`` should be updated. A field will be 

4323 overwritten if and only if it is in the update mask. 

4324 Output only fields cannot be updated. 

4325 

4326 See [FieldMask][google.protobuf.FieldMask] for more 

4327 information. 

4328 

4329 For example: ``"updateMask=kmsKeyName"`` 

4330 

4331 This corresponds to the ``update_mask`` field 

4332 on the ``request`` instance; if ``request`` is provided, this 

4333 should not be set. 

4334 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

4335 should be retried. 

4336 timeout (float): The timeout for this request. 

4337 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

4338 sent along with the request as metadata. Normally, each value must be of type `str`, 

4339 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

4340 be of type `bytes`. 

4341 

4342 Returns: 

4343 google.cloud.logging_v2.types.Settings: 

4344 Describes the settings associated 

4345 with a project, folder, organization, 

4346 billing account, or flexible resource. 

4347 

4348 """ 

4349 # Create or coerce a protobuf request object. 

4350 # - Quick check: If we got a request object, we should *not* have 

4351 # gotten any keyword arguments that map to the request. 

4352 flattened_params = [settings, update_mask] 

4353 has_flattened_params = ( 

4354 len([param for param in flattened_params if param is not None]) > 0 

4355 ) 

4356 if request is not None and has_flattened_params: 

4357 raise ValueError( 

4358 "If the `request` argument is set, then none of " 

4359 "the individual field arguments should be set." 

4360 ) 

4361 

4362 # - Use the request object if provided (there's no risk of modifying the input as 

4363 # there are no flattened fields), or create one. 

4364 if not isinstance(request, logging_config.UpdateSettingsRequest): 

4365 request = logging_config.UpdateSettingsRequest(request) 

4366 # If we have keyword arguments corresponding to fields on the 

4367 # request, apply these. 

4368 if settings is not None: 

4369 request.settings = settings 

4370 if update_mask is not None: 

4371 request.update_mask = update_mask 

4372 

4373 # Wrap the RPC method; this adds retry and timeout information, 

4374 # and friendly error handling. 

4375 rpc = self._transport._wrapped_methods[self._transport.update_settings] 

4376 

4377 # Certain fields should be provided within the metadata header; 

4378 # add these here. 

4379 metadata = tuple(metadata) + ( 

4380 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

4381 ) 

4382 

4383 # Validate the universe domain. 

4384 self._validate_universe_domain() 

4385 

4386 # Send the request. 

4387 response = rpc( 

4388 request, 

4389 retry=retry, 

4390 timeout=timeout, 

4391 metadata=metadata, 

4392 ) 

4393 

4394 # Done; return the response. 

4395 return response 

4396 

4397 def copy_log_entries( 

4398 self, 

4399 request: Optional[Union[logging_config.CopyLogEntriesRequest, dict]] = None, 

4400 *, 

4401 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

4402 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

4403 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

4404 ) -> operation.Operation: 

4405 r"""Copies a set of log entries from a log bucket to a 

4406 Cloud Storage bucket. 

4407 

4408 .. code-block:: python 

4409 

4410 # This snippet has been automatically generated and should be regarded as a 

4411 # code template only. 

4412 # It will require modifications to work: 

4413 # - It may require correct/in-range values for request initialization. 

4414 # - It may require specifying regional endpoints when creating the service 

4415 # client as shown in: 

4416 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

4417 from google.cloud import logging_v2 

4418 

4419 def sample_copy_log_entries(): 

4420 # Create a client 

4421 client = logging_v2.ConfigServiceV2Client() 

4422 

4423 # Initialize request argument(s) 

4424 request = logging_v2.CopyLogEntriesRequest( 

4425 name="name_value", 

4426 destination="destination_value", 

4427 ) 

4428 

4429 # Make the request 

4430 operation = client.copy_log_entries(request=request) 

4431 

4432 print("Waiting for operation to complete...") 

4433 

4434 response = operation.result() 

4435 

4436 # Handle the response 

4437 print(response) 

4438 

4439 Args: 

4440 request (Union[google.cloud.logging_v2.types.CopyLogEntriesRequest, dict]): 

4441 The request object. The parameters to CopyLogEntries. 

4442 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

4443 should be retried. 

4444 timeout (float): The timeout for this request. 

4445 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

4446 sent along with the request as metadata. Normally, each value must be of type `str`, 

4447 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

4448 be of type `bytes`. 

4449 

4450 Returns: 

4451 google.api_core.operation.Operation: 

4452 An object representing a long-running operation. 

4453 

4454 The result type for the operation will be 

4455 :class:`google.cloud.logging_v2.types.CopyLogEntriesResponse` 

4456 Response type for CopyLogEntries long running 

4457 operations. 

4458 

4459 """ 

4460 # Create or coerce a protobuf request object. 

4461 # - Use the request object if provided (there's no risk of modifying the input as 

4462 # there are no flattened fields), or create one. 

4463 if not isinstance(request, logging_config.CopyLogEntriesRequest): 

4464 request = logging_config.CopyLogEntriesRequest(request) 

4465 

4466 # Wrap the RPC method; this adds retry and timeout information, 

4467 # and friendly error handling. 

4468 rpc = self._transport._wrapped_methods[self._transport.copy_log_entries] 

4469 

4470 # Validate the universe domain. 

4471 self._validate_universe_domain() 

4472 

4473 # Send the request. 

4474 response = rpc( 

4475 request, 

4476 retry=retry, 

4477 timeout=timeout, 

4478 metadata=metadata, 

4479 ) 

4480 

4481 # Wrap the response in an operation future. 

4482 response = operation.from_gapic( 

4483 response, 

4484 self._transport.operations_client, 

4485 logging_config.CopyLogEntriesResponse, 

4486 metadata_type=logging_config.CopyLogEntriesMetadata, 

4487 ) 

4488 

4489 # Done; return the response. 

4490 return response 

4491 

4492 def __enter__(self) -> "ConfigServiceV2Client": 

4493 return self 

4494 

4495 def __exit__(self, type, value, traceback): 

4496 """Releases underlying transport's resources. 

4497 

4498 .. warning:: 

4499 ONLY use as a context manager if the transport is NOT shared 

4500 with other clients! Exiting the with block will CLOSE the transport 

4501 and may cause errors in other clients! 

4502 """ 

4503 self.transport.close() 

4504 

4505 def list_operations( 

4506 self, 

4507 request: Optional[operations_pb2.ListOperationsRequest] = None, 

4508 *, 

4509 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

4510 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

4511 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

4512 ) -> operations_pb2.ListOperationsResponse: 

4513 r"""Lists operations that match the specified filter in the request. 

4514 

4515 Args: 

4516 request (:class:`~.operations_pb2.ListOperationsRequest`): 

4517 The request object. Request message for 

4518 `ListOperations` method. 

4519 retry (google.api_core.retry.Retry): Designation of what errors, 

4520 if any, should be retried. 

4521 timeout (float): The timeout for this request. 

4522 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

4523 sent along with the request as metadata. Normally, each value must be of type `str`, 

4524 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

4525 be of type `bytes`. 

4526 Returns: 

4527 ~.operations_pb2.ListOperationsResponse: 

4528 Response message for ``ListOperations`` method. 

4529 """ 

4530 # Create or coerce a protobuf request object. 

4531 # The request isn't a proto-plus wrapped type, 

4532 # so it must be constructed via keyword expansion. 

4533 if isinstance(request, dict): 

4534 request = operations_pb2.ListOperationsRequest(**request) 

4535 

4536 # Wrap the RPC method; this adds retry and timeout information, 

4537 # and friendly error handling. 

4538 rpc = self._transport._wrapped_methods[self._transport.list_operations] 

4539 

4540 # Certain fields should be provided within the metadata header; 

4541 # add these here. 

4542 metadata = tuple(metadata) + ( 

4543 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

4544 ) 

4545 

4546 # Validate the universe domain. 

4547 self._validate_universe_domain() 

4548 

4549 try: 

4550 # Send the request. 

4551 response = rpc( 

4552 request, 

4553 retry=retry, 

4554 timeout=timeout, 

4555 metadata=metadata, 

4556 ) 

4557 

4558 # Done; return the response. 

4559 return response 

4560 except core_exceptions.GoogleAPICallError as e: 

4561 self._add_cred_info_for_auth_errors(e) 

4562 raise e 

4563 

4564 def get_operation( 

4565 self, 

4566 request: Optional[operations_pb2.GetOperationRequest] = None, 

4567 *, 

4568 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

4569 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

4570 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

4571 ) -> operations_pb2.Operation: 

4572 r"""Gets the latest state of a long-running operation. 

4573 

4574 Args: 

4575 request (:class:`~.operations_pb2.GetOperationRequest`): 

4576 The request object. Request message for 

4577 `GetOperation` method. 

4578 retry (google.api_core.retry.Retry): Designation of what errors, 

4579 if any, should be retried. 

4580 timeout (float): The timeout for this request. 

4581 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

4582 sent along with the request as metadata. Normally, each value must be of type `str`, 

4583 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

4584 be of type `bytes`. 

4585 Returns: 

4586 ~.operations_pb2.Operation: 

4587 An ``Operation`` object. 

4588 """ 

4589 # Create or coerce a protobuf request object. 

4590 # The request isn't a proto-plus wrapped type, 

4591 # so it must be constructed via keyword expansion. 

4592 if isinstance(request, dict): 

4593 request = operations_pb2.GetOperationRequest(**request) 

4594 

4595 # Wrap the RPC method; this adds retry and timeout information, 

4596 # and friendly error handling. 

4597 rpc = self._transport._wrapped_methods[self._transport.get_operation] 

4598 

4599 # Certain fields should be provided within the metadata header; 

4600 # add these here. 

4601 metadata = tuple(metadata) + ( 

4602 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

4603 ) 

4604 

4605 # Validate the universe domain. 

4606 self._validate_universe_domain() 

4607 

4608 try: 

4609 # Send the request. 

4610 response = rpc( 

4611 request, 

4612 retry=retry, 

4613 timeout=timeout, 

4614 metadata=metadata, 

4615 ) 

4616 

4617 # Done; return the response. 

4618 return response 

4619 except core_exceptions.GoogleAPICallError as e: 

4620 self._add_cred_info_for_auth_errors(e) 

4621 raise e 

4622 

4623 def cancel_operation( 

4624 self, 

4625 request: Optional[operations_pb2.CancelOperationRequest] = None, 

4626 *, 

4627 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

4628 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

4629 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

4630 ) -> None: 

4631 r"""Starts asynchronous cancellation on a long-running operation. 

4632 

4633 The server makes a best effort to cancel the operation, but success 

4634 is not guaranteed. If the server doesn't support this method, it returns 

4635 `google.rpc.Code.UNIMPLEMENTED`. 

4636 

4637 Args: 

4638 request (:class:`~.operations_pb2.CancelOperationRequest`): 

4639 The request object. Request message for 

4640 `CancelOperation` method. 

4641 retry (google.api_core.retry.Retry): Designation of what errors, 

4642 if any, should be retried. 

4643 timeout (float): The timeout for this request. 

4644 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

4645 sent along with the request as metadata. Normally, each value must be of type `str`, 

4646 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

4647 be of type `bytes`. 

4648 Returns: 

4649 None 

4650 """ 

4651 # Create or coerce a protobuf request object. 

4652 # The request isn't a proto-plus wrapped type, 

4653 # so it must be constructed via keyword expansion. 

4654 if isinstance(request, dict): 

4655 request = operations_pb2.CancelOperationRequest(**request) 

4656 

4657 # Wrap the RPC method; this adds retry and timeout information, 

4658 # and friendly error handling. 

4659 rpc = self._transport._wrapped_methods[self._transport.cancel_operation] 

4660 

4661 # Certain fields should be provided within the metadata header; 

4662 # add these here. 

4663 metadata = tuple(metadata) + ( 

4664 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

4665 ) 

4666 

4667 # Validate the universe domain. 

4668 self._validate_universe_domain() 

4669 

4670 # Send the request. 

4671 rpc( 

4672 request, 

4673 retry=retry, 

4674 timeout=timeout, 

4675 metadata=metadata, 

4676 ) 

4677 

4678 

4679DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( 

4680 gapic_version=package_version.__version__ 

4681) 

4682 

4683if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER 

4684 DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__ 

4685 

4686__all__ = ("ConfigServiceV2Client",)