google-cloud-maintenance-api 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. google/cloud/maintenance_api/__init__.py +51 -0
  2. google/cloud/maintenance_api/gapic_version.py +16 -0
  3. google/cloud/maintenance_api/py.typed +2 -0
  4. google/cloud/maintenance_api_v1beta/__init__.py +46 -0
  5. google/cloud/maintenance_api_v1beta/gapic_metadata.json +73 -0
  6. google/cloud/maintenance_api_v1beta/gapic_version.py +16 -0
  7. google/cloud/maintenance_api_v1beta/py.typed +2 -0
  8. google/cloud/maintenance_api_v1beta/services/__init__.py +15 -0
  9. google/cloud/maintenance_api_v1beta/services/maintenance/__init__.py +22 -0
  10. google/cloud/maintenance_api_v1beta/services/maintenance/async_client.py +786 -0
  11. google/cloud/maintenance_api_v1beta/services/maintenance/client.py +1211 -0
  12. google/cloud/maintenance_api_v1beta/services/maintenance/pagers.py +361 -0
  13. google/cloud/maintenance_api_v1beta/services/maintenance/transports/__init__.py +36 -0
  14. google/cloud/maintenance_api_v1beta/services/maintenance/transports/base.py +234 -0
  15. google/cloud/maintenance_api_v1beta/services/maintenance/transports/grpc.py +456 -0
  16. google/cloud/maintenance_api_v1beta/services/maintenance/transports/grpc_asyncio.py +499 -0
  17. google/cloud/maintenance_api_v1beta/services/maintenance/transports/rest.py +1182 -0
  18. google/cloud/maintenance_api_v1beta/services/maintenance/transports/rest_base.py +283 -0
  19. google/cloud/maintenance_api_v1beta/types/__init__.py +38 -0
  20. google/cloud/maintenance_api_v1beta/types/maintenance_service.py +713 -0
  21. google_cloud_maintenance_api-0.1.0.dist-info/METADATA +239 -0
  22. google_cloud_maintenance_api-0.1.0.dist-info/RECORD +25 -0
  23. google_cloud_maintenance_api-0.1.0.dist-info/WHEEL +5 -0
  24. google_cloud_maintenance_api-0.1.0.dist-info/licenses/LICENSE +202 -0
  25. google_cloud_maintenance_api-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1211 @@
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
+ #
16
+ from collections import OrderedDict
17
+ from http import HTTPStatus
18
+ import json
19
+ import logging as std_logging
20
+ import os
21
+ import re
22
+ from typing import (
23
+ Callable,
24
+ Dict,
25
+ Mapping,
26
+ MutableMapping,
27
+ MutableSequence,
28
+ Optional,
29
+ Sequence,
30
+ Tuple,
31
+ Type,
32
+ Union,
33
+ cast,
34
+ )
35
+ import warnings
36
+
37
+ from google.api_core import client_options as client_options_lib
38
+ from google.api_core import exceptions as core_exceptions
39
+ from google.api_core import gapic_v1
40
+ from google.api_core import retry as retries
41
+ from google.auth import credentials as ga_credentials # type: ignore
42
+ from google.auth.exceptions import MutualTLSChannelError # type: ignore
43
+ from google.auth.transport import mtls # type: ignore
44
+ from google.auth.transport.grpc import SslCredentials # type: ignore
45
+ from google.oauth2 import service_account # type: ignore
46
+ import google.protobuf
47
+
48
+ from google.cloud.maintenance_api_v1beta import gapic_version as package_version
49
+
50
+ try:
51
+ OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
52
+ except AttributeError: # pragma: NO COVER
53
+ OptionalRetry = Union[retries.Retry, object, None] # type: ignore
54
+
55
+ try:
56
+ from google.api_core import client_logging # type: ignore
57
+
58
+ CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
59
+ except ImportError: # pragma: NO COVER
60
+ CLIENT_LOGGING_SUPPORTED = False
61
+
62
+ _LOGGER = std_logging.getLogger(__name__)
63
+
64
+ from google.cloud.location import locations_pb2 # type: ignore
65
+ from google.protobuf import timestamp_pb2 # type: ignore
66
+
67
+ from google.cloud.maintenance_api_v1beta.services.maintenance import pagers
68
+ from google.cloud.maintenance_api_v1beta.types import maintenance_service
69
+
70
+ from .transports.base import DEFAULT_CLIENT_INFO, MaintenanceTransport
71
+ from .transports.grpc import MaintenanceGrpcTransport
72
+ from .transports.grpc_asyncio import MaintenanceGrpcAsyncIOTransport
73
+ from .transports.rest import MaintenanceRestTransport
74
+
75
+
76
+ class MaintenanceClientMeta(type):
77
+ """Metaclass for the Maintenance client.
78
+
79
+ This provides class-level methods for building and retrieving
80
+ support objects (e.g. transport) without polluting the client instance
81
+ objects.
82
+ """
83
+
84
+ _transport_registry = OrderedDict() # type: Dict[str, Type[MaintenanceTransport]]
85
+ _transport_registry["grpc"] = MaintenanceGrpcTransport
86
+ _transport_registry["grpc_asyncio"] = MaintenanceGrpcAsyncIOTransport
87
+ _transport_registry["rest"] = MaintenanceRestTransport
88
+
89
+ def get_transport_class(
90
+ cls,
91
+ label: Optional[str] = None,
92
+ ) -> Type[MaintenanceTransport]:
93
+ """Returns an appropriate transport class.
94
+
95
+ Args:
96
+ label: The name of the desired transport. If none is
97
+ provided, then the first transport in the registry is used.
98
+
99
+ Returns:
100
+ The transport class to use.
101
+ """
102
+ # If a specific transport is requested, return that one.
103
+ if label:
104
+ return cls._transport_registry[label]
105
+
106
+ # No transport is requested; return the default (that is, the first one
107
+ # in the dictionary).
108
+ return next(iter(cls._transport_registry.values()))
109
+
110
+
111
+ class MaintenanceClient(metaclass=MaintenanceClientMeta):
112
+ """Unified Maintenance service"""
113
+
114
+ @staticmethod
115
+ def _get_default_mtls_endpoint(api_endpoint):
116
+ """Converts api endpoint to mTLS endpoint.
117
+
118
+ Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
119
+ "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
120
+ Args:
121
+ api_endpoint (Optional[str]): the api endpoint to convert.
122
+ Returns:
123
+ str: converted mTLS api endpoint.
124
+ """
125
+ if not api_endpoint:
126
+ return api_endpoint
127
+
128
+ mtls_endpoint_re = re.compile(
129
+ r"(?P<name>[^.]+)(?P<mtls>\.mtls)?(?P<sandbox>\.sandbox)?(?P<googledomain>\.googleapis\.com)?"
130
+ )
131
+
132
+ m = mtls_endpoint_re.match(api_endpoint)
133
+ name, mtls, sandbox, googledomain = m.groups()
134
+ if mtls or not googledomain:
135
+ return api_endpoint
136
+
137
+ if sandbox:
138
+ return api_endpoint.replace(
139
+ "sandbox.googleapis.com", "mtls.sandbox.googleapis.com"
140
+ )
141
+
142
+ return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com")
143
+
144
+ # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
145
+ DEFAULT_ENDPOINT = "maintenance.googleapis.com"
146
+ DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore
147
+ DEFAULT_ENDPOINT
148
+ )
149
+
150
+ _DEFAULT_ENDPOINT_TEMPLATE = "maintenance.{UNIVERSE_DOMAIN}"
151
+ _DEFAULT_UNIVERSE = "googleapis.com"
152
+
153
+ @classmethod
154
+ def from_service_account_info(cls, info: dict, *args, **kwargs):
155
+ """Creates an instance of this client using the provided credentials
156
+ info.
157
+
158
+ Args:
159
+ info (dict): The service account private key info.
160
+ args: Additional arguments to pass to the constructor.
161
+ kwargs: Additional arguments to pass to the constructor.
162
+
163
+ Returns:
164
+ MaintenanceClient: The constructed client.
165
+ """
166
+ credentials = service_account.Credentials.from_service_account_info(info)
167
+ kwargs["credentials"] = credentials
168
+ return cls(*args, **kwargs)
169
+
170
+ @classmethod
171
+ def from_service_account_file(cls, filename: str, *args, **kwargs):
172
+ """Creates an instance of this client using the provided credentials
173
+ file.
174
+
175
+ Args:
176
+ filename (str): The path to the service account private key json
177
+ file.
178
+ args: Additional arguments to pass to the constructor.
179
+ kwargs: Additional arguments to pass to the constructor.
180
+
181
+ Returns:
182
+ MaintenanceClient: The constructed client.
183
+ """
184
+ credentials = service_account.Credentials.from_service_account_file(filename)
185
+ kwargs["credentials"] = credentials
186
+ return cls(*args, **kwargs)
187
+
188
+ from_service_account_json = from_service_account_file
189
+
190
+ @property
191
+ def transport(self) -> MaintenanceTransport:
192
+ """Returns the transport used by the client instance.
193
+
194
+ Returns:
195
+ MaintenanceTransport: The transport used by the client
196
+ instance.
197
+ """
198
+ return self._transport
199
+
200
+ @staticmethod
201
+ def resource_maintenance_path(
202
+ project: str,
203
+ location: str,
204
+ resource_maintenance: str,
205
+ ) -> str:
206
+ """Returns a fully-qualified resource_maintenance string."""
207
+ return "projects/{project}/locations/{location}/resourceMaintenances/{resource_maintenance}".format(
208
+ project=project,
209
+ location=location,
210
+ resource_maintenance=resource_maintenance,
211
+ )
212
+
213
+ @staticmethod
214
+ def parse_resource_maintenance_path(path: str) -> Dict[str, str]:
215
+ """Parses a resource_maintenance path into its component segments."""
216
+ m = re.match(
217
+ r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/resourceMaintenances/(?P<resource_maintenance>.+?)$",
218
+ path,
219
+ )
220
+ return m.groupdict() if m else {}
221
+
222
+ @staticmethod
223
+ def common_billing_account_path(
224
+ billing_account: str,
225
+ ) -> str:
226
+ """Returns a fully-qualified billing_account string."""
227
+ return "billingAccounts/{billing_account}".format(
228
+ billing_account=billing_account,
229
+ )
230
+
231
+ @staticmethod
232
+ def parse_common_billing_account_path(path: str) -> Dict[str, str]:
233
+ """Parse a billing_account path into its component segments."""
234
+ m = re.match(r"^billingAccounts/(?P<billing_account>.+?)$", path)
235
+ return m.groupdict() if m else {}
236
+
237
+ @staticmethod
238
+ def common_folder_path(
239
+ folder: str,
240
+ ) -> str:
241
+ """Returns a fully-qualified folder string."""
242
+ return "folders/{folder}".format(
243
+ folder=folder,
244
+ )
245
+
246
+ @staticmethod
247
+ def parse_common_folder_path(path: str) -> Dict[str, str]:
248
+ """Parse a folder path into its component segments."""
249
+ m = re.match(r"^folders/(?P<folder>.+?)$", path)
250
+ return m.groupdict() if m else {}
251
+
252
+ @staticmethod
253
+ def common_organization_path(
254
+ organization: str,
255
+ ) -> str:
256
+ """Returns a fully-qualified organization string."""
257
+ return "organizations/{organization}".format(
258
+ organization=organization,
259
+ )
260
+
261
+ @staticmethod
262
+ def parse_common_organization_path(path: str) -> Dict[str, str]:
263
+ """Parse a organization path into its component segments."""
264
+ m = re.match(r"^organizations/(?P<organization>.+?)$", path)
265
+ return m.groupdict() if m else {}
266
+
267
+ @staticmethod
268
+ def common_project_path(
269
+ project: str,
270
+ ) -> str:
271
+ """Returns a fully-qualified project string."""
272
+ return "projects/{project}".format(
273
+ project=project,
274
+ )
275
+
276
+ @staticmethod
277
+ def parse_common_project_path(path: str) -> Dict[str, str]:
278
+ """Parse a project path into its component segments."""
279
+ m = re.match(r"^projects/(?P<project>.+?)$", path)
280
+ return m.groupdict() if m else {}
281
+
282
+ @staticmethod
283
+ def common_location_path(
284
+ project: str,
285
+ location: str,
286
+ ) -> str:
287
+ """Returns a fully-qualified location string."""
288
+ return "projects/{project}/locations/{location}".format(
289
+ project=project,
290
+ location=location,
291
+ )
292
+
293
+ @staticmethod
294
+ def parse_common_location_path(path: str) -> Dict[str, str]:
295
+ """Parse a location path into its component segments."""
296
+ m = re.match(r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)$", path)
297
+ return m.groupdict() if m else {}
298
+
299
+ @classmethod
300
+ def get_mtls_endpoint_and_cert_source(
301
+ cls, client_options: Optional[client_options_lib.ClientOptions] = None
302
+ ):
303
+ """Deprecated. Return the API endpoint and client cert source for mutual TLS.
304
+
305
+ The client cert source is determined in the following order:
306
+ (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the
307
+ client cert source is None.
308
+ (2) if `client_options.client_cert_source` is provided, use the provided one; if the
309
+ default client cert source exists, use the default one; otherwise the client cert
310
+ source is None.
311
+
312
+ The API endpoint is determined in the following order:
313
+ (1) if `client_options.api_endpoint` if provided, use the provided one.
314
+ (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the
315
+ default mTLS endpoint; if the environment variable is "never", use the default API
316
+ endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
317
+ use the default API endpoint.
318
+
319
+ More details can be found at https://google.aip.dev/auth/4114.
320
+
321
+ Args:
322
+ client_options (google.api_core.client_options.ClientOptions): Custom options for the
323
+ client. Only the `api_endpoint` and `client_cert_source` properties may be used
324
+ in this method.
325
+
326
+ Returns:
327
+ Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the
328
+ client cert source to use.
329
+
330
+ Raises:
331
+ google.auth.exceptions.MutualTLSChannelError: If any errors happen.
332
+ """
333
+
334
+ warnings.warn(
335
+ "get_mtls_endpoint_and_cert_source is deprecated. Use the api_endpoint property instead.",
336
+ DeprecationWarning,
337
+ )
338
+ if client_options is None:
339
+ client_options = client_options_lib.ClientOptions()
340
+ use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")
341
+ use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto")
342
+ if use_client_cert not in ("true", "false"):
343
+ raise ValueError(
344
+ "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
345
+ )
346
+ if use_mtls_endpoint not in ("auto", "never", "always"):
347
+ raise MutualTLSChannelError(
348
+ "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
349
+ )
350
+
351
+ # Figure out the client cert source to use.
352
+ client_cert_source = None
353
+ if use_client_cert == "true":
354
+ if client_options.client_cert_source:
355
+ client_cert_source = client_options.client_cert_source
356
+ elif mtls.has_default_client_cert_source():
357
+ client_cert_source = mtls.default_client_cert_source()
358
+
359
+ # Figure out which api endpoint to use.
360
+ if client_options.api_endpoint is not None:
361
+ api_endpoint = client_options.api_endpoint
362
+ elif use_mtls_endpoint == "always" or (
363
+ use_mtls_endpoint == "auto" and client_cert_source
364
+ ):
365
+ api_endpoint = cls.DEFAULT_MTLS_ENDPOINT
366
+ else:
367
+ api_endpoint = cls.DEFAULT_ENDPOINT
368
+
369
+ return api_endpoint, client_cert_source
370
+
371
+ @staticmethod
372
+ def _read_environment_variables():
373
+ """Returns the environment variables used by the client.
374
+
375
+ Returns:
376
+ Tuple[bool, str, str]: returns the GOOGLE_API_USE_CLIENT_CERTIFICATE,
377
+ GOOGLE_API_USE_MTLS_ENDPOINT, and GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variables.
378
+
379
+ Raises:
380
+ ValueError: If GOOGLE_API_USE_CLIENT_CERTIFICATE is not
381
+ any of ["true", "false"].
382
+ google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT
383
+ is not any of ["auto", "never", "always"].
384
+ """
385
+ use_client_cert = os.getenv(
386
+ "GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
387
+ ).lower()
388
+ use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower()
389
+ universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN")
390
+ if use_client_cert not in ("true", "false"):
391
+ raise ValueError(
392
+ "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
393
+ )
394
+ if use_mtls_endpoint not in ("auto", "never", "always"):
395
+ raise MutualTLSChannelError(
396
+ "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
397
+ )
398
+ return use_client_cert == "true", use_mtls_endpoint, universe_domain_env
399
+
400
+ @staticmethod
401
+ def _get_client_cert_source(provided_cert_source, use_cert_flag):
402
+ """Return the client cert source to be used by the client.
403
+
404
+ Args:
405
+ provided_cert_source (bytes): The client certificate source provided.
406
+ use_cert_flag (bool): A flag indicating whether to use the client certificate.
407
+
408
+ Returns:
409
+ bytes or None: The client cert source to be used by the client.
410
+ """
411
+ client_cert_source = None
412
+ if use_cert_flag:
413
+ if provided_cert_source:
414
+ client_cert_source = provided_cert_source
415
+ elif mtls.has_default_client_cert_source():
416
+ client_cert_source = mtls.default_client_cert_source()
417
+ return client_cert_source
418
+
419
+ @staticmethod
420
+ def _get_api_endpoint(
421
+ api_override, client_cert_source, universe_domain, use_mtls_endpoint
422
+ ):
423
+ """Return the API endpoint used by the client.
424
+
425
+ Args:
426
+ api_override (str): The API endpoint override. If specified, this is always
427
+ the return value of this function and the other arguments are not used.
428
+ client_cert_source (bytes): The client certificate source used by the client.
429
+ universe_domain (str): The universe domain used by the client.
430
+ use_mtls_endpoint (str): How to use the mTLS endpoint, which depends also on the other parameters.
431
+ Possible values are "always", "auto", or "never".
432
+
433
+ Returns:
434
+ str: The API endpoint to be used by the client.
435
+ """
436
+ if api_override is not None:
437
+ api_endpoint = api_override
438
+ elif use_mtls_endpoint == "always" or (
439
+ use_mtls_endpoint == "auto" and client_cert_source
440
+ ):
441
+ _default_universe = MaintenanceClient._DEFAULT_UNIVERSE
442
+ if universe_domain != _default_universe:
443
+ raise MutualTLSChannelError(
444
+ f"mTLS is not supported in any universe other than {_default_universe}."
445
+ )
446
+ api_endpoint = MaintenanceClient.DEFAULT_MTLS_ENDPOINT
447
+ else:
448
+ api_endpoint = MaintenanceClient._DEFAULT_ENDPOINT_TEMPLATE.format(
449
+ UNIVERSE_DOMAIN=universe_domain
450
+ )
451
+ return api_endpoint
452
+
453
+ @staticmethod
454
+ def _get_universe_domain(
455
+ client_universe_domain: Optional[str], universe_domain_env: Optional[str]
456
+ ) -> str:
457
+ """Return the universe domain used by the client.
458
+
459
+ Args:
460
+ client_universe_domain (Optional[str]): The universe domain configured via the client options.
461
+ universe_domain_env (Optional[str]): The universe domain configured via the "GOOGLE_CLOUD_UNIVERSE_DOMAIN" environment variable.
462
+
463
+ Returns:
464
+ str: The universe domain to be used by the client.
465
+
466
+ Raises:
467
+ ValueError: If the universe domain is an empty string.
468
+ """
469
+ universe_domain = MaintenanceClient._DEFAULT_UNIVERSE
470
+ if client_universe_domain is not None:
471
+ universe_domain = client_universe_domain
472
+ elif universe_domain_env is not None:
473
+ universe_domain = universe_domain_env
474
+ if len(universe_domain.strip()) == 0:
475
+ raise ValueError("Universe Domain cannot be an empty string.")
476
+ return universe_domain
477
+
478
+ def _validate_universe_domain(self):
479
+ """Validates client's and credentials' universe domains are consistent.
480
+
481
+ Returns:
482
+ bool: True iff the configured universe domain is valid.
483
+
484
+ Raises:
485
+ ValueError: If the configured universe domain is not valid.
486
+ """
487
+
488
+ # NOTE (b/349488459): universe validation is disabled until further notice.
489
+ return True
490
+
491
+ def _add_cred_info_for_auth_errors(
492
+ self, error: core_exceptions.GoogleAPICallError
493
+ ) -> None:
494
+ """Adds credential info string to error details for 401/403/404 errors.
495
+
496
+ Args:
497
+ error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info.
498
+ """
499
+ if error.code not in [
500
+ HTTPStatus.UNAUTHORIZED,
501
+ HTTPStatus.FORBIDDEN,
502
+ HTTPStatus.NOT_FOUND,
503
+ ]:
504
+ return
505
+
506
+ cred = self._transport._credentials
507
+
508
+ # get_cred_info is only available in google-auth>=2.35.0
509
+ if not hasattr(cred, "get_cred_info"):
510
+ return
511
+
512
+ # ignore the type check since pypy test fails when get_cred_info
513
+ # is not available
514
+ cred_info = cred.get_cred_info() # type: ignore
515
+ if cred_info and hasattr(error._details, "append"):
516
+ error._details.append(json.dumps(cred_info))
517
+
518
+ @property
519
+ def api_endpoint(self):
520
+ """Return the API endpoint used by the client instance.
521
+
522
+ Returns:
523
+ str: The API endpoint used by the client instance.
524
+ """
525
+ return self._api_endpoint
526
+
527
+ @property
528
+ def universe_domain(self) -> str:
529
+ """Return the universe domain used by the client instance.
530
+
531
+ Returns:
532
+ str: The universe domain used by the client instance.
533
+ """
534
+ return self._universe_domain
535
+
536
+ def __init__(
537
+ self,
538
+ *,
539
+ credentials: Optional[ga_credentials.Credentials] = None,
540
+ transport: Optional[
541
+ Union[str, MaintenanceTransport, Callable[..., MaintenanceTransport]]
542
+ ] = None,
543
+ client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,
544
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
545
+ ) -> None:
546
+ """Instantiates the maintenance client.
547
+
548
+ Args:
549
+ credentials (Optional[google.auth.credentials.Credentials]): The
550
+ authorization credentials to attach to requests. These
551
+ credentials identify the application to the service; if none
552
+ are specified, the client will attempt to ascertain the
553
+ credentials from the environment.
554
+ transport (Optional[Union[str,MaintenanceTransport,Callable[..., MaintenanceTransport]]]):
555
+ The transport to use, or a Callable that constructs and returns a new transport.
556
+ If a Callable is given, it will be called with the same set of initialization
557
+ arguments as used in the MaintenanceTransport constructor.
558
+ If set to None, a transport is chosen automatically.
559
+ client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
560
+ Custom options for the client.
561
+
562
+ 1. The ``api_endpoint`` property can be used to override the
563
+ default endpoint provided by the client when ``transport`` is
564
+ not explicitly provided. Only if this property is not set and
565
+ ``transport`` was not explicitly provided, the endpoint is
566
+ determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
567
+ variable, which have one of the following values:
568
+ "always" (always use the default mTLS endpoint), "never" (always
569
+ use the default regular endpoint) and "auto" (auto-switch to the
570
+ default mTLS endpoint if client certificate is present; this is
571
+ the default value).
572
+
573
+ 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
574
+ is "true", then the ``client_cert_source`` property can be used
575
+ to provide a client certificate for mTLS transport. If
576
+ not provided, the default SSL client certificate will be used if
577
+ present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
578
+ set, no client certificate will be used.
579
+
580
+ 3. The ``universe_domain`` property can be used to override the
581
+ default "googleapis.com" universe. Note that the ``api_endpoint``
582
+ property still takes precedence; and ``universe_domain`` is
583
+ currently not supported for mTLS.
584
+
585
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
586
+ The client info used to send a user-agent string along with
587
+ API requests. If ``None``, then default info will be used.
588
+ Generally, you only need to set this if you're developing
589
+ your own client library.
590
+
591
+ Raises:
592
+ google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
593
+ creation failed for any reason.
594
+ """
595
+ self._client_options = client_options
596
+ if isinstance(self._client_options, dict):
597
+ self._client_options = client_options_lib.from_dict(self._client_options)
598
+ if self._client_options is None:
599
+ self._client_options = client_options_lib.ClientOptions()
600
+ self._client_options = cast(
601
+ client_options_lib.ClientOptions, self._client_options
602
+ )
603
+
604
+ universe_domain_opt = getattr(self._client_options, "universe_domain", None)
605
+
606
+ (
607
+ self._use_client_cert,
608
+ self._use_mtls_endpoint,
609
+ self._universe_domain_env,
610
+ ) = MaintenanceClient._read_environment_variables()
611
+ self._client_cert_source = MaintenanceClient._get_client_cert_source(
612
+ self._client_options.client_cert_source, self._use_client_cert
613
+ )
614
+ self._universe_domain = MaintenanceClient._get_universe_domain(
615
+ universe_domain_opt, self._universe_domain_env
616
+ )
617
+ self._api_endpoint = None # updated below, depending on `transport`
618
+
619
+ # Initialize the universe domain validation.
620
+ self._is_universe_domain_valid = False
621
+
622
+ if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER
623
+ # Setup logging.
624
+ client_logging.initialize_logging()
625
+
626
+ api_key_value = getattr(self._client_options, "api_key", None)
627
+ if api_key_value and credentials:
628
+ raise ValueError(
629
+ "client_options.api_key and credentials are mutually exclusive"
630
+ )
631
+
632
+ # Save or instantiate the transport.
633
+ # Ordinarily, we provide the transport, but allowing a custom transport
634
+ # instance provides an extensibility point for unusual situations.
635
+ transport_provided = isinstance(transport, MaintenanceTransport)
636
+ if transport_provided:
637
+ # transport is a MaintenanceTransport instance.
638
+ if credentials or self._client_options.credentials_file or api_key_value:
639
+ raise ValueError(
640
+ "When providing a transport instance, "
641
+ "provide its credentials directly."
642
+ )
643
+ if self._client_options.scopes:
644
+ raise ValueError(
645
+ "When providing a transport instance, provide its scopes "
646
+ "directly."
647
+ )
648
+ self._transport = cast(MaintenanceTransport, transport)
649
+ self._api_endpoint = self._transport.host
650
+
651
+ self._api_endpoint = self._api_endpoint or MaintenanceClient._get_api_endpoint(
652
+ self._client_options.api_endpoint,
653
+ self._client_cert_source,
654
+ self._universe_domain,
655
+ self._use_mtls_endpoint,
656
+ )
657
+
658
+ if not transport_provided:
659
+ import google.auth._default # type: ignore
660
+
661
+ if api_key_value and hasattr(
662
+ google.auth._default, "get_api_key_credentials"
663
+ ):
664
+ credentials = google.auth._default.get_api_key_credentials(
665
+ api_key_value
666
+ )
667
+
668
+ transport_init: Union[
669
+ Type[MaintenanceTransport], Callable[..., MaintenanceTransport]
670
+ ] = (
671
+ MaintenanceClient.get_transport_class(transport)
672
+ if isinstance(transport, str) or transport is None
673
+ else cast(Callable[..., MaintenanceTransport], transport)
674
+ )
675
+ # initialize with the provided callable or the passed in class
676
+ self._transport = transport_init(
677
+ credentials=credentials,
678
+ credentials_file=self._client_options.credentials_file,
679
+ host=self._api_endpoint,
680
+ scopes=self._client_options.scopes,
681
+ client_cert_source_for_mtls=self._client_cert_source,
682
+ quota_project_id=self._client_options.quota_project_id,
683
+ client_info=client_info,
684
+ always_use_jwt_access=True,
685
+ api_audience=self._client_options.api_audience,
686
+ )
687
+
688
+ if "async" not in str(self._transport):
689
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
690
+ std_logging.DEBUG
691
+ ): # pragma: NO COVER
692
+ _LOGGER.debug(
693
+ "Created client `google.cloud.maintenance.api_v1beta.MaintenanceClient`.",
694
+ extra={
695
+ "serviceName": "google.cloud.maintenance.api.v1beta.Maintenance",
696
+ "universeDomain": getattr(
697
+ self._transport._credentials, "universe_domain", ""
698
+ ),
699
+ "credentialsType": f"{type(self._transport._credentials).__module__}.{type(self._transport._credentials).__qualname__}",
700
+ "credentialsInfo": getattr(
701
+ self.transport._credentials, "get_cred_info", lambda: None
702
+ )(),
703
+ }
704
+ if hasattr(self._transport, "_credentials")
705
+ else {
706
+ "serviceName": "google.cloud.maintenance.api.v1beta.Maintenance",
707
+ "credentialsType": None,
708
+ },
709
+ )
710
+
711
+ def summarize_maintenances(
712
+ self,
713
+ request: Optional[
714
+ Union[maintenance_service.SummarizeMaintenancesRequest, dict]
715
+ ] = None,
716
+ *,
717
+ parent: Optional[str] = None,
718
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
719
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
720
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
721
+ ) -> pagers.SummarizeMaintenancesPager:
722
+ r"""Retrieves the statistics of a specific maintenance.
723
+
724
+ .. code-block:: python
725
+
726
+ # This snippet has been automatically generated and should be regarded as a
727
+ # code template only.
728
+ # It will require modifications to work:
729
+ # - It may require correct/in-range values for request initialization.
730
+ # - It may require specifying regional endpoints when creating the service
731
+ # client as shown in:
732
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
733
+ from google.cloud import maintenance_api_v1beta
734
+
735
+ def sample_summarize_maintenances():
736
+ # Create a client
737
+ client = maintenance_api_v1beta.MaintenanceClient()
738
+
739
+ # Initialize request argument(s)
740
+ request = maintenance_api_v1beta.SummarizeMaintenancesRequest(
741
+ parent="parent_value",
742
+ )
743
+
744
+ # Make the request
745
+ page_result = client.summarize_maintenances(request=request)
746
+
747
+ # Handle the response
748
+ for response in page_result:
749
+ print(response)
750
+
751
+ Args:
752
+ request (Union[google.cloud.maintenance_api_v1beta.types.SummarizeMaintenancesRequest, dict]):
753
+ The request object. Request message for
754
+ SummarizeMaintenances custom method.
755
+ parent (str):
756
+ Required. The parent of the resource maintenance. eg.
757
+ ``projects/123/locations/*``
758
+
759
+ This corresponds to the ``parent`` field
760
+ on the ``request`` instance; if ``request`` is provided, this
761
+ should not be set.
762
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
763
+ should be retried.
764
+ timeout (float): The timeout for this request.
765
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
766
+ sent along with the request as metadata. Normally, each value must be of type `str`,
767
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
768
+ be of type `bytes`.
769
+
770
+ Returns:
771
+ google.cloud.maintenance_api_v1beta.services.maintenance.pagers.SummarizeMaintenancesPager:
772
+ Iterating over this object will yield
773
+ results and resolve additional pages
774
+ automatically.
775
+
776
+ """
777
+ # Create or coerce a protobuf request object.
778
+ # - Quick check: If we got a request object, we should *not* have
779
+ # gotten any keyword arguments that map to the request.
780
+ flattened_params = [parent]
781
+ has_flattened_params = (
782
+ len([param for param in flattened_params if param is not None]) > 0
783
+ )
784
+ if request is not None and has_flattened_params:
785
+ raise ValueError(
786
+ "If the `request` argument is set, then none of "
787
+ "the individual field arguments should be set."
788
+ )
789
+
790
+ # - Use the request object if provided (there's no risk of modifying the input as
791
+ # there are no flattened fields), or create one.
792
+ if not isinstance(request, maintenance_service.SummarizeMaintenancesRequest):
793
+ request = maintenance_service.SummarizeMaintenancesRequest(request)
794
+ # If we have keyword arguments corresponding to fields on the
795
+ # request, apply these.
796
+ if parent is not None:
797
+ request.parent = parent
798
+
799
+ # Wrap the RPC method; this adds retry and timeout information,
800
+ # and friendly error handling.
801
+ rpc = self._transport._wrapped_methods[self._transport.summarize_maintenances]
802
+
803
+ # Certain fields should be provided within the metadata header;
804
+ # add these here.
805
+ metadata = tuple(metadata) + (
806
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
807
+ )
808
+
809
+ # Validate the universe domain.
810
+ self._validate_universe_domain()
811
+
812
+ # Send the request.
813
+ response = rpc(
814
+ request,
815
+ retry=retry,
816
+ timeout=timeout,
817
+ metadata=metadata,
818
+ )
819
+
820
+ # This method is paged; wrap the response in a pager, which provides
821
+ # an `__iter__` convenience method.
822
+ response = pagers.SummarizeMaintenancesPager(
823
+ method=rpc,
824
+ request=request,
825
+ response=response,
826
+ retry=retry,
827
+ timeout=timeout,
828
+ metadata=metadata,
829
+ )
830
+
831
+ # Done; return the response.
832
+ return response
833
+
834
+ def list_resource_maintenances(
835
+ self,
836
+ request: Optional[
837
+ Union[maintenance_service.ListResourceMaintenancesRequest, dict]
838
+ ] = None,
839
+ *,
840
+ parent: Optional[str] = None,
841
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
842
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
843
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
844
+ ) -> pagers.ListResourceMaintenancesPager:
845
+ r"""Retrieve a collection of resource maintenances.
846
+
847
+ .. code-block:: python
848
+
849
+ # This snippet has been automatically generated and should be regarded as a
850
+ # code template only.
851
+ # It will require modifications to work:
852
+ # - It may require correct/in-range values for request initialization.
853
+ # - It may require specifying regional endpoints when creating the service
854
+ # client as shown in:
855
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
856
+ from google.cloud import maintenance_api_v1beta
857
+
858
+ def sample_list_resource_maintenances():
859
+ # Create a client
860
+ client = maintenance_api_v1beta.MaintenanceClient()
861
+
862
+ # Initialize request argument(s)
863
+ request = maintenance_api_v1beta.ListResourceMaintenancesRequest(
864
+ parent="parent_value",
865
+ )
866
+
867
+ # Make the request
868
+ page_result = client.list_resource_maintenances(request=request)
869
+
870
+ # Handle the response
871
+ for response in page_result:
872
+ print(response)
873
+
874
+ Args:
875
+ request (Union[google.cloud.maintenance_api_v1beta.types.ListResourceMaintenancesRequest, dict]):
876
+ The request object. The request structure for the
877
+ ListResourceMaintenances method.
878
+ parent (str):
879
+ Required. The parent of the resource
880
+ maintenance.
881
+
882
+ This corresponds to the ``parent`` field
883
+ on the ``request`` instance; if ``request`` is provided, this
884
+ should not be set.
885
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
886
+ should be retried.
887
+ timeout (float): The timeout for this request.
888
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
889
+ sent along with the request as metadata. Normally, each value must be of type `str`,
890
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
891
+ be of type `bytes`.
892
+
893
+ Returns:
894
+ google.cloud.maintenance_api_v1beta.services.maintenance.pagers.ListResourceMaintenancesPager:
895
+ The response structure for the
896
+ ListResourceMaintenances method.
897
+ Iterating over this object will yield
898
+ results and resolve additional pages
899
+ automatically.
900
+
901
+ """
902
+ # Create or coerce a protobuf request object.
903
+ # - Quick check: If we got a request object, we should *not* have
904
+ # gotten any keyword arguments that map to the request.
905
+ flattened_params = [parent]
906
+ has_flattened_params = (
907
+ len([param for param in flattened_params if param is not None]) > 0
908
+ )
909
+ if request is not None and has_flattened_params:
910
+ raise ValueError(
911
+ "If the `request` argument is set, then none of "
912
+ "the individual field arguments should be set."
913
+ )
914
+
915
+ # - Use the request object if provided (there's no risk of modifying the input as
916
+ # there are no flattened fields), or create one.
917
+ if not isinstance(request, maintenance_service.ListResourceMaintenancesRequest):
918
+ request = maintenance_service.ListResourceMaintenancesRequest(request)
919
+ # If we have keyword arguments corresponding to fields on the
920
+ # request, apply these.
921
+ if parent is not None:
922
+ request.parent = parent
923
+
924
+ # Wrap the RPC method; this adds retry and timeout information,
925
+ # and friendly error handling.
926
+ rpc = self._transport._wrapped_methods[
927
+ self._transport.list_resource_maintenances
928
+ ]
929
+
930
+ # Certain fields should be provided within the metadata header;
931
+ # add these here.
932
+ metadata = tuple(metadata) + (
933
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
934
+ )
935
+
936
+ # Validate the universe domain.
937
+ self._validate_universe_domain()
938
+
939
+ # Send the request.
940
+ response = rpc(
941
+ request,
942
+ retry=retry,
943
+ timeout=timeout,
944
+ metadata=metadata,
945
+ )
946
+
947
+ # This method is paged; wrap the response in a pager, which provides
948
+ # an `__iter__` convenience method.
949
+ response = pagers.ListResourceMaintenancesPager(
950
+ method=rpc,
951
+ request=request,
952
+ response=response,
953
+ retry=retry,
954
+ timeout=timeout,
955
+ metadata=metadata,
956
+ )
957
+
958
+ # Done; return the response.
959
+ return response
960
+
961
+ def get_resource_maintenance(
962
+ self,
963
+ request: Optional[
964
+ Union[maintenance_service.GetResourceMaintenanceRequest, dict]
965
+ ] = None,
966
+ *,
967
+ name: Optional[str] = None,
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
+ ) -> maintenance_service.ResourceMaintenance:
972
+ r"""Retrieve a single resource maintenance.
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 maintenance_api_v1beta
984
+
985
+ def sample_get_resource_maintenance():
986
+ # Create a client
987
+ client = maintenance_api_v1beta.MaintenanceClient()
988
+
989
+ # Initialize request argument(s)
990
+ request = maintenance_api_v1beta.GetResourceMaintenanceRequest(
991
+ name="name_value",
992
+ )
993
+
994
+ # Make the request
995
+ response = client.get_resource_maintenance(request=request)
996
+
997
+ # Handle the response
998
+ print(response)
999
+
1000
+ Args:
1001
+ request (Union[google.cloud.maintenance_api_v1beta.types.GetResourceMaintenanceRequest, dict]):
1002
+ The request object. The request structure for the
1003
+ GetResourceMaintenance method.
1004
+ name (str):
1005
+ Required. The resource name of the
1006
+ resource within a service.
1007
+
1008
+ This corresponds to the ``name`` field
1009
+ on the ``request`` instance; if ``request`` is provided, this
1010
+ should not be set.
1011
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1012
+ should be retried.
1013
+ timeout (float): The timeout for this request.
1014
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1015
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1016
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1017
+ be of type `bytes`.
1018
+
1019
+ Returns:
1020
+ google.cloud.maintenance_api_v1beta.types.ResourceMaintenance:
1021
+ ResourceMaintenance is a resource
1022
+ that represents a maintenance operation
1023
+ on a resource.
1024
+
1025
+ """
1026
+ # Create or coerce a protobuf request object.
1027
+ # - Quick check: If we got a request object, we should *not* have
1028
+ # gotten any keyword arguments that map to the request.
1029
+ flattened_params = [name]
1030
+ has_flattened_params = (
1031
+ len([param for param in flattened_params if param is not None]) > 0
1032
+ )
1033
+ if request is not None and has_flattened_params:
1034
+ raise ValueError(
1035
+ "If the `request` argument is set, then none of "
1036
+ "the individual field arguments should be set."
1037
+ )
1038
+
1039
+ # - Use the request object if provided (there's no risk of modifying the input as
1040
+ # there are no flattened fields), or create one.
1041
+ if not isinstance(request, maintenance_service.GetResourceMaintenanceRequest):
1042
+ request = maintenance_service.GetResourceMaintenanceRequest(request)
1043
+ # If we have keyword arguments corresponding to fields on the
1044
+ # request, apply these.
1045
+ if name is not None:
1046
+ request.name = name
1047
+
1048
+ # Wrap the RPC method; this adds retry and timeout information,
1049
+ # and friendly error handling.
1050
+ rpc = self._transport._wrapped_methods[self._transport.get_resource_maintenance]
1051
+
1052
+ # Certain fields should be provided within the metadata header;
1053
+ # add these here.
1054
+ metadata = tuple(metadata) + (
1055
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1056
+ )
1057
+
1058
+ # Validate the universe domain.
1059
+ self._validate_universe_domain()
1060
+
1061
+ # Send the request.
1062
+ response = rpc(
1063
+ request,
1064
+ retry=retry,
1065
+ timeout=timeout,
1066
+ metadata=metadata,
1067
+ )
1068
+
1069
+ # Done; return the response.
1070
+ return response
1071
+
1072
+ def __enter__(self) -> "MaintenanceClient":
1073
+ return self
1074
+
1075
+ def __exit__(self, type, value, traceback):
1076
+ """Releases underlying transport's resources.
1077
+
1078
+ .. warning::
1079
+ ONLY use as a context manager if the transport is NOT shared
1080
+ with other clients! Exiting the with block will CLOSE the transport
1081
+ and may cause errors in other clients!
1082
+ """
1083
+ self.transport.close()
1084
+
1085
+ def get_location(
1086
+ self,
1087
+ request: Optional[locations_pb2.GetLocationRequest] = None,
1088
+ *,
1089
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1090
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1091
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1092
+ ) -> locations_pb2.Location:
1093
+ r"""Gets information about a location.
1094
+
1095
+ Args:
1096
+ request (:class:`~.location_pb2.GetLocationRequest`):
1097
+ The request object. Request message for
1098
+ `GetLocation` method.
1099
+ retry (google.api_core.retry.Retry): Designation of what errors,
1100
+ if any, should be retried.
1101
+ timeout (float): The timeout for this request.
1102
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1103
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1104
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1105
+ be of type `bytes`.
1106
+ Returns:
1107
+ ~.location_pb2.Location:
1108
+ Location object.
1109
+ """
1110
+ # Create or coerce a protobuf request object.
1111
+ # The request isn't a proto-plus wrapped type,
1112
+ # so it must be constructed via keyword expansion.
1113
+ if isinstance(request, dict):
1114
+ request = locations_pb2.GetLocationRequest(**request)
1115
+
1116
+ # Wrap the RPC method; this adds retry and timeout information,
1117
+ # and friendly error handling.
1118
+ rpc = self._transport._wrapped_methods[self._transport.get_location]
1119
+
1120
+ # Certain fields should be provided within the metadata header;
1121
+ # add these here.
1122
+ metadata = tuple(metadata) + (
1123
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1124
+ )
1125
+
1126
+ # Validate the universe domain.
1127
+ self._validate_universe_domain()
1128
+
1129
+ try:
1130
+ # Send the request.
1131
+ response = rpc(
1132
+ request,
1133
+ retry=retry,
1134
+ timeout=timeout,
1135
+ metadata=metadata,
1136
+ )
1137
+
1138
+ # Done; return the response.
1139
+ return response
1140
+ except core_exceptions.GoogleAPICallError as e:
1141
+ self._add_cred_info_for_auth_errors(e)
1142
+ raise e
1143
+
1144
+ def list_locations(
1145
+ self,
1146
+ request: Optional[locations_pb2.ListLocationsRequest] = None,
1147
+ *,
1148
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1149
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1150
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1151
+ ) -> locations_pb2.ListLocationsResponse:
1152
+ r"""Lists information about the supported locations for this service.
1153
+
1154
+ Args:
1155
+ request (:class:`~.location_pb2.ListLocationsRequest`):
1156
+ The request object. Request message for
1157
+ `ListLocations` method.
1158
+ retry (google.api_core.retry.Retry): Designation of what errors,
1159
+ if any, should be retried.
1160
+ timeout (float): The timeout for this request.
1161
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1162
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1163
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1164
+ be of type `bytes`.
1165
+ Returns:
1166
+ ~.location_pb2.ListLocationsResponse:
1167
+ Response message for ``ListLocations`` method.
1168
+ """
1169
+ # Create or coerce a protobuf request object.
1170
+ # The request isn't a proto-plus wrapped type,
1171
+ # so it must be constructed via keyword expansion.
1172
+ if isinstance(request, dict):
1173
+ request = locations_pb2.ListLocationsRequest(**request)
1174
+
1175
+ # Wrap the RPC method; this adds retry and timeout information,
1176
+ # and friendly error handling.
1177
+ rpc = self._transport._wrapped_methods[self._transport.list_locations]
1178
+
1179
+ # Certain fields should be provided within the metadata header;
1180
+ # add these here.
1181
+ metadata = tuple(metadata) + (
1182
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1183
+ )
1184
+
1185
+ # Validate the universe domain.
1186
+ self._validate_universe_domain()
1187
+
1188
+ try:
1189
+ # Send the request.
1190
+ response = rpc(
1191
+ request,
1192
+ retry=retry,
1193
+ timeout=timeout,
1194
+ metadata=metadata,
1195
+ )
1196
+
1197
+ # Done; return the response.
1198
+ return response
1199
+ except core_exceptions.GoogleAPICallError as e:
1200
+ self._add_cred_info_for_auth_errors(e)
1201
+ raise e
1202
+
1203
+
1204
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
1205
+ gapic_version=package_version.__version__
1206
+ )
1207
+
1208
+ if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
1209
+ DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
1210
+
1211
+ __all__ = ("MaintenanceClient",)