google-cloud-beyondcorp-clientgateways 0.4.16__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/beyondcorp_clientgateways/__init__.py +47 -0
  2. google/cloud/beyondcorp_clientgateways/gapic_version.py +16 -0
  3. google/cloud/beyondcorp_clientgateways/py.typed +2 -0
  4. google/cloud/beyondcorp_clientgateways_v1/__init__.py +45 -0
  5. google/cloud/beyondcorp_clientgateways_v1/gapic_metadata.json +88 -0
  6. google/cloud/beyondcorp_clientgateways_v1/gapic_version.py +16 -0
  7. google/cloud/beyondcorp_clientgateways_v1/py.typed +2 -0
  8. google/cloud/beyondcorp_clientgateways_v1/services/__init__.py +15 -0
  9. google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/__init__.py +22 -0
  10. google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/async_client.py +1489 -0
  11. google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/client.py +1932 -0
  12. google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/pagers.py +201 -0
  13. google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/transports/__init__.py +41 -0
  14. google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/transports/base.py +347 -0
  15. google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/transports/grpc.py +663 -0
  16. google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/transports/grpc_asyncio.py +747 -0
  17. google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/transports/rest.py +2591 -0
  18. google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/transports/rest_base.py +592 -0
  19. google/cloud/beyondcorp_clientgateways_v1/types/__init__.py +34 -0
  20. google/cloud/beyondcorp_clientgateways_v1/types/client_gateways_service.py +381 -0
  21. google_cloud_beyondcorp_clientgateways-0.4.16.dist-info/LICENSE +202 -0
  22. google_cloud_beyondcorp_clientgateways-0.4.16.dist-info/METADATA +229 -0
  23. google_cloud_beyondcorp_clientgateways-0.4.16.dist-info/RECORD +25 -0
  24. google_cloud_beyondcorp_clientgateways-0.4.16.dist-info/WHEEL +5 -0
  25. google_cloud_beyondcorp_clientgateways-0.4.16.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1932 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2024 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
+
47
+ from google.cloud.beyondcorp_clientgateways_v1 import gapic_version as package_version
48
+
49
+ try:
50
+ OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
51
+ except AttributeError: # pragma: NO COVER
52
+ OptionalRetry = Union[retries.Retry, object, None] # type: ignore
53
+
54
+ try:
55
+ from google.api_core import client_logging # type: ignore
56
+
57
+ CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
58
+ except ImportError: # pragma: NO COVER
59
+ CLIENT_LOGGING_SUPPORTED = False
60
+
61
+ _LOGGER = std_logging.getLogger(__name__)
62
+
63
+ from google.api_core import operation # type: ignore
64
+ from google.api_core import operation_async # type: ignore
65
+ from google.cloud.location import locations_pb2 # type: ignore
66
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
67
+ from google.iam.v1 import policy_pb2 # type: ignore
68
+ from google.longrunning import operations_pb2 # type: ignore
69
+ from google.protobuf import empty_pb2 # type: ignore
70
+ from google.protobuf import timestamp_pb2 # type: ignore
71
+
72
+ from google.cloud.beyondcorp_clientgateways_v1.services.client_gateways_service import (
73
+ pagers,
74
+ )
75
+ from google.cloud.beyondcorp_clientgateways_v1.types import client_gateways_service
76
+
77
+ from .transports.base import DEFAULT_CLIENT_INFO, ClientGatewaysServiceTransport
78
+ from .transports.grpc import ClientGatewaysServiceGrpcTransport
79
+ from .transports.grpc_asyncio import ClientGatewaysServiceGrpcAsyncIOTransport
80
+ from .transports.rest import ClientGatewaysServiceRestTransport
81
+
82
+
83
+ class ClientGatewaysServiceClientMeta(type):
84
+ """Metaclass for the ClientGatewaysService client.
85
+
86
+ This provides class-level methods for building and retrieving
87
+ support objects (e.g. transport) without polluting the client instance
88
+ objects.
89
+ """
90
+
91
+ _transport_registry = (
92
+ OrderedDict()
93
+ ) # type: Dict[str, Type[ClientGatewaysServiceTransport]]
94
+ _transport_registry["grpc"] = ClientGatewaysServiceGrpcTransport
95
+ _transport_registry["grpc_asyncio"] = ClientGatewaysServiceGrpcAsyncIOTransport
96
+ _transport_registry["rest"] = ClientGatewaysServiceRestTransport
97
+
98
+ def get_transport_class(
99
+ cls,
100
+ label: Optional[str] = None,
101
+ ) -> Type[ClientGatewaysServiceTransport]:
102
+ """Returns an appropriate transport class.
103
+
104
+ Args:
105
+ label: The name of the desired transport. If none is
106
+ provided, then the first transport in the registry is used.
107
+
108
+ Returns:
109
+ The transport class to use.
110
+ """
111
+ # If a specific transport is requested, return that one.
112
+ if label:
113
+ return cls._transport_registry[label]
114
+
115
+ # No transport is requested; return the default (that is, the first one
116
+ # in the dictionary).
117
+ return next(iter(cls._transport_registry.values()))
118
+
119
+
120
+ class ClientGatewaysServiceClient(metaclass=ClientGatewaysServiceClientMeta):
121
+ """API Overview:
122
+
123
+ The ``beyondcorp.googleapis.com`` service implements the Google
124
+ Cloud BeyondCorp API.
125
+
126
+ Data Model:
127
+
128
+ The ClientGatewaysService exposes the following resources:
129
+
130
+ - Client Gateways, named as follows:
131
+ ``projects/{project_id}/locations/{location_id}/clientGateways/{client_gateway_id}``.
132
+ """
133
+
134
+ @staticmethod
135
+ def _get_default_mtls_endpoint(api_endpoint):
136
+ """Converts api endpoint to mTLS endpoint.
137
+
138
+ Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
139
+ "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
140
+ Args:
141
+ api_endpoint (Optional[str]): the api endpoint to convert.
142
+ Returns:
143
+ str: converted mTLS api endpoint.
144
+ """
145
+ if not api_endpoint:
146
+ return api_endpoint
147
+
148
+ mtls_endpoint_re = re.compile(
149
+ r"(?P<name>[^.]+)(?P<mtls>\.mtls)?(?P<sandbox>\.sandbox)?(?P<googledomain>\.googleapis\.com)?"
150
+ )
151
+
152
+ m = mtls_endpoint_re.match(api_endpoint)
153
+ name, mtls, sandbox, googledomain = m.groups()
154
+ if mtls or not googledomain:
155
+ return api_endpoint
156
+
157
+ if sandbox:
158
+ return api_endpoint.replace(
159
+ "sandbox.googleapis.com", "mtls.sandbox.googleapis.com"
160
+ )
161
+
162
+ return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com")
163
+
164
+ # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
165
+ DEFAULT_ENDPOINT = "beyondcorp.googleapis.com"
166
+ DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore
167
+ DEFAULT_ENDPOINT
168
+ )
169
+
170
+ _DEFAULT_ENDPOINT_TEMPLATE = "beyondcorp.{UNIVERSE_DOMAIN}"
171
+ _DEFAULT_UNIVERSE = "googleapis.com"
172
+
173
+ @classmethod
174
+ def from_service_account_info(cls, info: dict, *args, **kwargs):
175
+ """Creates an instance of this client using the provided credentials
176
+ info.
177
+
178
+ Args:
179
+ info (dict): The service account private key info.
180
+ args: Additional arguments to pass to the constructor.
181
+ kwargs: Additional arguments to pass to the constructor.
182
+
183
+ Returns:
184
+ ClientGatewaysServiceClient: The constructed client.
185
+ """
186
+ credentials = service_account.Credentials.from_service_account_info(info)
187
+ kwargs["credentials"] = credentials
188
+ return cls(*args, **kwargs)
189
+
190
+ @classmethod
191
+ def from_service_account_file(cls, filename: str, *args, **kwargs):
192
+ """Creates an instance of this client using the provided credentials
193
+ file.
194
+
195
+ Args:
196
+ filename (str): The path to the service account private key json
197
+ file.
198
+ args: Additional arguments to pass to the constructor.
199
+ kwargs: Additional arguments to pass to the constructor.
200
+
201
+ Returns:
202
+ ClientGatewaysServiceClient: The constructed client.
203
+ """
204
+ credentials = service_account.Credentials.from_service_account_file(filename)
205
+ kwargs["credentials"] = credentials
206
+ return cls(*args, **kwargs)
207
+
208
+ from_service_account_json = from_service_account_file
209
+
210
+ @property
211
+ def transport(self) -> ClientGatewaysServiceTransport:
212
+ """Returns the transport used by the client instance.
213
+
214
+ Returns:
215
+ ClientGatewaysServiceTransport: The transport used by the client
216
+ instance.
217
+ """
218
+ return self._transport
219
+
220
+ @staticmethod
221
+ def client_gateway_path(
222
+ project: str,
223
+ location: str,
224
+ client_gateway: str,
225
+ ) -> str:
226
+ """Returns a fully-qualified client_gateway string."""
227
+ return "projects/{project}/locations/{location}/clientGateways/{client_gateway}".format(
228
+ project=project,
229
+ location=location,
230
+ client_gateway=client_gateway,
231
+ )
232
+
233
+ @staticmethod
234
+ def parse_client_gateway_path(path: str) -> Dict[str, str]:
235
+ """Parses a client_gateway path into its component segments."""
236
+ m = re.match(
237
+ r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/clientGateways/(?P<client_gateway>.+?)$",
238
+ path,
239
+ )
240
+ return m.groupdict() if m else {}
241
+
242
+ @staticmethod
243
+ def common_billing_account_path(
244
+ billing_account: str,
245
+ ) -> str:
246
+ """Returns a fully-qualified billing_account string."""
247
+ return "billingAccounts/{billing_account}".format(
248
+ billing_account=billing_account,
249
+ )
250
+
251
+ @staticmethod
252
+ def parse_common_billing_account_path(path: str) -> Dict[str, str]:
253
+ """Parse a billing_account path into its component segments."""
254
+ m = re.match(r"^billingAccounts/(?P<billing_account>.+?)$", path)
255
+ return m.groupdict() if m else {}
256
+
257
+ @staticmethod
258
+ def common_folder_path(
259
+ folder: str,
260
+ ) -> str:
261
+ """Returns a fully-qualified folder string."""
262
+ return "folders/{folder}".format(
263
+ folder=folder,
264
+ )
265
+
266
+ @staticmethod
267
+ def parse_common_folder_path(path: str) -> Dict[str, str]:
268
+ """Parse a folder path into its component segments."""
269
+ m = re.match(r"^folders/(?P<folder>.+?)$", path)
270
+ return m.groupdict() if m else {}
271
+
272
+ @staticmethod
273
+ def common_organization_path(
274
+ organization: str,
275
+ ) -> str:
276
+ """Returns a fully-qualified organization string."""
277
+ return "organizations/{organization}".format(
278
+ organization=organization,
279
+ )
280
+
281
+ @staticmethod
282
+ def parse_common_organization_path(path: str) -> Dict[str, str]:
283
+ """Parse a organization path into its component segments."""
284
+ m = re.match(r"^organizations/(?P<organization>.+?)$", path)
285
+ return m.groupdict() if m else {}
286
+
287
+ @staticmethod
288
+ def common_project_path(
289
+ project: str,
290
+ ) -> str:
291
+ """Returns a fully-qualified project string."""
292
+ return "projects/{project}".format(
293
+ project=project,
294
+ )
295
+
296
+ @staticmethod
297
+ def parse_common_project_path(path: str) -> Dict[str, str]:
298
+ """Parse a project path into its component segments."""
299
+ m = re.match(r"^projects/(?P<project>.+?)$", path)
300
+ return m.groupdict() if m else {}
301
+
302
+ @staticmethod
303
+ def common_location_path(
304
+ project: str,
305
+ location: str,
306
+ ) -> str:
307
+ """Returns a fully-qualified location string."""
308
+ return "projects/{project}/locations/{location}".format(
309
+ project=project,
310
+ location=location,
311
+ )
312
+
313
+ @staticmethod
314
+ def parse_common_location_path(path: str) -> Dict[str, str]:
315
+ """Parse a location path into its component segments."""
316
+ m = re.match(r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)$", path)
317
+ return m.groupdict() if m else {}
318
+
319
+ @classmethod
320
+ def get_mtls_endpoint_and_cert_source(
321
+ cls, client_options: Optional[client_options_lib.ClientOptions] = None
322
+ ):
323
+ """Deprecated. Return the API endpoint and client cert source for mutual TLS.
324
+
325
+ The client cert source is determined in the following order:
326
+ (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the
327
+ client cert source is None.
328
+ (2) if `client_options.client_cert_source` is provided, use the provided one; if the
329
+ default client cert source exists, use the default one; otherwise the client cert
330
+ source is None.
331
+
332
+ The API endpoint is determined in the following order:
333
+ (1) if `client_options.api_endpoint` if provided, use the provided one.
334
+ (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the
335
+ default mTLS endpoint; if the environment variable is "never", use the default API
336
+ endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
337
+ use the default API endpoint.
338
+
339
+ More details can be found at https://google.aip.dev/auth/4114.
340
+
341
+ Args:
342
+ client_options (google.api_core.client_options.ClientOptions): Custom options for the
343
+ client. Only the `api_endpoint` and `client_cert_source` properties may be used
344
+ in this method.
345
+
346
+ Returns:
347
+ Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the
348
+ client cert source to use.
349
+
350
+ Raises:
351
+ google.auth.exceptions.MutualTLSChannelError: If any errors happen.
352
+ """
353
+
354
+ warnings.warn(
355
+ "get_mtls_endpoint_and_cert_source is deprecated. Use the api_endpoint property instead.",
356
+ DeprecationWarning,
357
+ )
358
+ if client_options is None:
359
+ client_options = client_options_lib.ClientOptions()
360
+ use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")
361
+ use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto")
362
+ if use_client_cert not in ("true", "false"):
363
+ raise ValueError(
364
+ "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
365
+ )
366
+ if use_mtls_endpoint not in ("auto", "never", "always"):
367
+ raise MutualTLSChannelError(
368
+ "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
369
+ )
370
+
371
+ # Figure out the client cert source to use.
372
+ client_cert_source = None
373
+ if use_client_cert == "true":
374
+ if client_options.client_cert_source:
375
+ client_cert_source = client_options.client_cert_source
376
+ elif mtls.has_default_client_cert_source():
377
+ client_cert_source = mtls.default_client_cert_source()
378
+
379
+ # Figure out which api endpoint to use.
380
+ if client_options.api_endpoint is not None:
381
+ api_endpoint = client_options.api_endpoint
382
+ elif use_mtls_endpoint == "always" or (
383
+ use_mtls_endpoint == "auto" and client_cert_source
384
+ ):
385
+ api_endpoint = cls.DEFAULT_MTLS_ENDPOINT
386
+ else:
387
+ api_endpoint = cls.DEFAULT_ENDPOINT
388
+
389
+ return api_endpoint, client_cert_source
390
+
391
+ @staticmethod
392
+ def _read_environment_variables():
393
+ """Returns the environment variables used by the client.
394
+
395
+ Returns:
396
+ Tuple[bool, str, str]: returns the GOOGLE_API_USE_CLIENT_CERTIFICATE,
397
+ GOOGLE_API_USE_MTLS_ENDPOINT, and GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variables.
398
+
399
+ Raises:
400
+ ValueError: If GOOGLE_API_USE_CLIENT_CERTIFICATE is not
401
+ any of ["true", "false"].
402
+ google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT
403
+ is not any of ["auto", "never", "always"].
404
+ """
405
+ use_client_cert = os.getenv(
406
+ "GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
407
+ ).lower()
408
+ use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower()
409
+ universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN")
410
+ if use_client_cert not in ("true", "false"):
411
+ raise ValueError(
412
+ "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
413
+ )
414
+ if use_mtls_endpoint not in ("auto", "never", "always"):
415
+ raise MutualTLSChannelError(
416
+ "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
417
+ )
418
+ return use_client_cert == "true", use_mtls_endpoint, universe_domain_env
419
+
420
+ @staticmethod
421
+ def _get_client_cert_source(provided_cert_source, use_cert_flag):
422
+ """Return the client cert source to be used by the client.
423
+
424
+ Args:
425
+ provided_cert_source (bytes): The client certificate source provided.
426
+ use_cert_flag (bool): A flag indicating whether to use the client certificate.
427
+
428
+ Returns:
429
+ bytes or None: The client cert source to be used by the client.
430
+ """
431
+ client_cert_source = None
432
+ if use_cert_flag:
433
+ if provided_cert_source:
434
+ client_cert_source = provided_cert_source
435
+ elif mtls.has_default_client_cert_source():
436
+ client_cert_source = mtls.default_client_cert_source()
437
+ return client_cert_source
438
+
439
+ @staticmethod
440
+ def _get_api_endpoint(
441
+ api_override, client_cert_source, universe_domain, use_mtls_endpoint
442
+ ):
443
+ """Return the API endpoint used by the client.
444
+
445
+ Args:
446
+ api_override (str): The API endpoint override. If specified, this is always
447
+ the return value of this function and the other arguments are not used.
448
+ client_cert_source (bytes): The client certificate source used by the client.
449
+ universe_domain (str): The universe domain used by the client.
450
+ use_mtls_endpoint (str): How to use the mTLS endpoint, which depends also on the other parameters.
451
+ Possible values are "always", "auto", or "never".
452
+
453
+ Returns:
454
+ str: The API endpoint to be used by the client.
455
+ """
456
+ if api_override is not None:
457
+ api_endpoint = api_override
458
+ elif use_mtls_endpoint == "always" or (
459
+ use_mtls_endpoint == "auto" and client_cert_source
460
+ ):
461
+ _default_universe = ClientGatewaysServiceClient._DEFAULT_UNIVERSE
462
+ if universe_domain != _default_universe:
463
+ raise MutualTLSChannelError(
464
+ f"mTLS is not supported in any universe other than {_default_universe}."
465
+ )
466
+ api_endpoint = ClientGatewaysServiceClient.DEFAULT_MTLS_ENDPOINT
467
+ else:
468
+ api_endpoint = (
469
+ ClientGatewaysServiceClient._DEFAULT_ENDPOINT_TEMPLATE.format(
470
+ UNIVERSE_DOMAIN=universe_domain
471
+ )
472
+ )
473
+ return api_endpoint
474
+
475
+ @staticmethod
476
+ def _get_universe_domain(
477
+ client_universe_domain: Optional[str], universe_domain_env: Optional[str]
478
+ ) -> str:
479
+ """Return the universe domain used by the client.
480
+
481
+ Args:
482
+ client_universe_domain (Optional[str]): The universe domain configured via the client options.
483
+ universe_domain_env (Optional[str]): The universe domain configured via the "GOOGLE_CLOUD_UNIVERSE_DOMAIN" environment variable.
484
+
485
+ Returns:
486
+ str: The universe domain to be used by the client.
487
+
488
+ Raises:
489
+ ValueError: If the universe domain is an empty string.
490
+ """
491
+ universe_domain = ClientGatewaysServiceClient._DEFAULT_UNIVERSE
492
+ if client_universe_domain is not None:
493
+ universe_domain = client_universe_domain
494
+ elif universe_domain_env is not None:
495
+ universe_domain = universe_domain_env
496
+ if len(universe_domain.strip()) == 0:
497
+ raise ValueError("Universe Domain cannot be an empty string.")
498
+ return universe_domain
499
+
500
+ def _validate_universe_domain(self):
501
+ """Validates client's and credentials' universe domains are consistent.
502
+
503
+ Returns:
504
+ bool: True iff the configured universe domain is valid.
505
+
506
+ Raises:
507
+ ValueError: If the configured universe domain is not valid.
508
+ """
509
+
510
+ # NOTE (b/349488459): universe validation is disabled until further notice.
511
+ return True
512
+
513
+ def _add_cred_info_for_auth_errors(
514
+ self, error: core_exceptions.GoogleAPICallError
515
+ ) -> None:
516
+ """Adds credential info string to error details for 401/403/404 errors.
517
+
518
+ Args:
519
+ error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info.
520
+ """
521
+ if error.code not in [
522
+ HTTPStatus.UNAUTHORIZED,
523
+ HTTPStatus.FORBIDDEN,
524
+ HTTPStatus.NOT_FOUND,
525
+ ]:
526
+ return
527
+
528
+ cred = self._transport._credentials
529
+
530
+ # get_cred_info is only available in google-auth>=2.35.0
531
+ if not hasattr(cred, "get_cred_info"):
532
+ return
533
+
534
+ # ignore the type check since pypy test fails when get_cred_info
535
+ # is not available
536
+ cred_info = cred.get_cred_info() # type: ignore
537
+ if cred_info and hasattr(error._details, "append"):
538
+ error._details.append(json.dumps(cred_info))
539
+
540
+ @property
541
+ def api_endpoint(self):
542
+ """Return the API endpoint used by the client instance.
543
+
544
+ Returns:
545
+ str: The API endpoint used by the client instance.
546
+ """
547
+ return self._api_endpoint
548
+
549
+ @property
550
+ def universe_domain(self) -> str:
551
+ """Return the universe domain used by the client instance.
552
+
553
+ Returns:
554
+ str: The universe domain used by the client instance.
555
+ """
556
+ return self._universe_domain
557
+
558
+ def __init__(
559
+ self,
560
+ *,
561
+ credentials: Optional[ga_credentials.Credentials] = None,
562
+ transport: Optional[
563
+ Union[
564
+ str,
565
+ ClientGatewaysServiceTransport,
566
+ Callable[..., ClientGatewaysServiceTransport],
567
+ ]
568
+ ] = None,
569
+ client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,
570
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
571
+ ) -> None:
572
+ """Instantiates the client gateways service client.
573
+
574
+ Args:
575
+ credentials (Optional[google.auth.credentials.Credentials]): The
576
+ authorization credentials to attach to requests. These
577
+ credentials identify the application to the service; if none
578
+ are specified, the client will attempt to ascertain the
579
+ credentials from the environment.
580
+ transport (Optional[Union[str,ClientGatewaysServiceTransport,Callable[..., ClientGatewaysServiceTransport]]]):
581
+ The transport to use, or a Callable that constructs and returns a new transport.
582
+ If a Callable is given, it will be called with the same set of initialization
583
+ arguments as used in the ClientGatewaysServiceTransport constructor.
584
+ If set to None, a transport is chosen automatically.
585
+ client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
586
+ Custom options for the client.
587
+
588
+ 1. The ``api_endpoint`` property can be used to override the
589
+ default endpoint provided by the client when ``transport`` is
590
+ not explicitly provided. Only if this property is not set and
591
+ ``transport`` was not explicitly provided, the endpoint is
592
+ determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
593
+ variable, which have one of the following values:
594
+ "always" (always use the default mTLS endpoint), "never" (always
595
+ use the default regular endpoint) and "auto" (auto-switch to the
596
+ default mTLS endpoint if client certificate is present; this is
597
+ the default value).
598
+
599
+ 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
600
+ is "true", then the ``client_cert_source`` property can be used
601
+ to provide a client certificate for mTLS transport. If
602
+ not provided, the default SSL client certificate will be used if
603
+ present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
604
+ set, no client certificate will be used.
605
+
606
+ 3. The ``universe_domain`` property can be used to override the
607
+ default "googleapis.com" universe. Note that the ``api_endpoint``
608
+ property still takes precedence; and ``universe_domain`` is
609
+ currently not supported for mTLS.
610
+
611
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
612
+ The client info used to send a user-agent string along with
613
+ API requests. If ``None``, then default info will be used.
614
+ Generally, you only need to set this if you're developing
615
+ your own client library.
616
+
617
+ Raises:
618
+ google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
619
+ creation failed for any reason.
620
+ """
621
+ self._client_options = client_options
622
+ if isinstance(self._client_options, dict):
623
+ self._client_options = client_options_lib.from_dict(self._client_options)
624
+ if self._client_options is None:
625
+ self._client_options = client_options_lib.ClientOptions()
626
+ self._client_options = cast(
627
+ client_options_lib.ClientOptions, self._client_options
628
+ )
629
+
630
+ universe_domain_opt = getattr(self._client_options, "universe_domain", None)
631
+
632
+ (
633
+ self._use_client_cert,
634
+ self._use_mtls_endpoint,
635
+ self._universe_domain_env,
636
+ ) = ClientGatewaysServiceClient._read_environment_variables()
637
+ self._client_cert_source = ClientGatewaysServiceClient._get_client_cert_source(
638
+ self._client_options.client_cert_source, self._use_client_cert
639
+ )
640
+ self._universe_domain = ClientGatewaysServiceClient._get_universe_domain(
641
+ universe_domain_opt, self._universe_domain_env
642
+ )
643
+ self._api_endpoint = None # updated below, depending on `transport`
644
+
645
+ # Initialize the universe domain validation.
646
+ self._is_universe_domain_valid = False
647
+
648
+ if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER
649
+ # Setup logging.
650
+ client_logging.initialize_logging()
651
+
652
+ api_key_value = getattr(self._client_options, "api_key", None)
653
+ if api_key_value and credentials:
654
+ raise ValueError(
655
+ "client_options.api_key and credentials are mutually exclusive"
656
+ )
657
+
658
+ # Save or instantiate the transport.
659
+ # Ordinarily, we provide the transport, but allowing a custom transport
660
+ # instance provides an extensibility point for unusual situations.
661
+ transport_provided = isinstance(transport, ClientGatewaysServiceTransport)
662
+ if transport_provided:
663
+ # transport is a ClientGatewaysServiceTransport instance.
664
+ if credentials or self._client_options.credentials_file or api_key_value:
665
+ raise ValueError(
666
+ "When providing a transport instance, "
667
+ "provide its credentials directly."
668
+ )
669
+ if self._client_options.scopes:
670
+ raise ValueError(
671
+ "When providing a transport instance, provide its scopes "
672
+ "directly."
673
+ )
674
+ self._transport = cast(ClientGatewaysServiceTransport, transport)
675
+ self._api_endpoint = self._transport.host
676
+
677
+ self._api_endpoint = (
678
+ self._api_endpoint
679
+ or ClientGatewaysServiceClient._get_api_endpoint(
680
+ self._client_options.api_endpoint,
681
+ self._client_cert_source,
682
+ self._universe_domain,
683
+ self._use_mtls_endpoint,
684
+ )
685
+ )
686
+
687
+ if not transport_provided:
688
+ import google.auth._default # type: ignore
689
+
690
+ if api_key_value and hasattr(
691
+ google.auth._default, "get_api_key_credentials"
692
+ ):
693
+ credentials = google.auth._default.get_api_key_credentials(
694
+ api_key_value
695
+ )
696
+
697
+ transport_init: Union[
698
+ Type[ClientGatewaysServiceTransport],
699
+ Callable[..., ClientGatewaysServiceTransport],
700
+ ] = (
701
+ ClientGatewaysServiceClient.get_transport_class(transport)
702
+ if isinstance(transport, str) or transport is None
703
+ else cast(Callable[..., ClientGatewaysServiceTransport], transport)
704
+ )
705
+ # initialize with the provided callable or the passed in class
706
+ self._transport = transport_init(
707
+ credentials=credentials,
708
+ credentials_file=self._client_options.credentials_file,
709
+ host=self._api_endpoint,
710
+ scopes=self._client_options.scopes,
711
+ client_cert_source_for_mtls=self._client_cert_source,
712
+ quota_project_id=self._client_options.quota_project_id,
713
+ client_info=client_info,
714
+ always_use_jwt_access=True,
715
+ api_audience=self._client_options.api_audience,
716
+ )
717
+
718
+ if "async" not in str(self._transport):
719
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
720
+ std_logging.DEBUG
721
+ ): # pragma: NO COVER
722
+ _LOGGER.debug(
723
+ "Created client `google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient`.",
724
+ extra={
725
+ "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService",
726
+ "universeDomain": getattr(
727
+ self._transport._credentials, "universe_domain", ""
728
+ ),
729
+ "credentialsType": f"{type(self._transport._credentials).__module__}.{type(self._transport._credentials).__qualname__}",
730
+ "credentialsInfo": getattr(
731
+ self.transport._credentials, "get_cred_info", lambda: None
732
+ )(),
733
+ }
734
+ if hasattr(self._transport, "_credentials")
735
+ else {
736
+ "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService",
737
+ "credentialsType": None,
738
+ },
739
+ )
740
+
741
+ def list_client_gateways(
742
+ self,
743
+ request: Optional[
744
+ Union[client_gateways_service.ListClientGatewaysRequest, dict]
745
+ ] = None,
746
+ *,
747
+ parent: Optional[str] = None,
748
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
749
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
750
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
751
+ ) -> pagers.ListClientGatewaysPager:
752
+ r"""Lists ClientGateways in a given project and location.
753
+
754
+ .. code-block:: python
755
+
756
+ # This snippet has been automatically generated and should be regarded as a
757
+ # code template only.
758
+ # It will require modifications to work:
759
+ # - It may require correct/in-range values for request initialization.
760
+ # - It may require specifying regional endpoints when creating the service
761
+ # client as shown in:
762
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
763
+ from google.cloud import beyondcorp_clientgateways_v1
764
+
765
+ def sample_list_client_gateways():
766
+ # Create a client
767
+ client = beyondcorp_clientgateways_v1.ClientGatewaysServiceClient()
768
+
769
+ # Initialize request argument(s)
770
+ request = beyondcorp_clientgateways_v1.ListClientGatewaysRequest(
771
+ parent="parent_value",
772
+ )
773
+
774
+ # Make the request
775
+ page_result = client.list_client_gateways(request=request)
776
+
777
+ # Handle the response
778
+ for response in page_result:
779
+ print(response)
780
+
781
+ Args:
782
+ request (Union[google.cloud.beyondcorp_clientgateways_v1.types.ListClientGatewaysRequest, dict]):
783
+ The request object. Message for requesting list of
784
+ ClientGateways.
785
+ parent (str):
786
+ Required. Parent value for
787
+ ListClientGatewaysRequest.
788
+
789
+ This corresponds to the ``parent`` field
790
+ on the ``request`` instance; if ``request`` is provided, this
791
+ should not be set.
792
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
793
+ should be retried.
794
+ timeout (float): The timeout for this request.
795
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
796
+ sent along with the request as metadata. Normally, each value must be of type `str`,
797
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
798
+ be of type `bytes`.
799
+
800
+ Returns:
801
+ google.cloud.beyondcorp_clientgateways_v1.services.client_gateways_service.pagers.ListClientGatewaysPager:
802
+ Message for response to listing
803
+ ClientGateways.
804
+ Iterating over this object will yield
805
+ results and resolve additional pages
806
+ automatically.
807
+
808
+ """
809
+ # Create or coerce a protobuf request object.
810
+ # - Quick check: If we got a request object, we should *not* have
811
+ # gotten any keyword arguments that map to the request.
812
+ flattened_params = [parent]
813
+ has_flattened_params = (
814
+ len([param for param in flattened_params if param is not None]) > 0
815
+ )
816
+ if request is not None and has_flattened_params:
817
+ raise ValueError(
818
+ "If the `request` argument is set, then none of "
819
+ "the individual field arguments should be set."
820
+ )
821
+
822
+ # - Use the request object if provided (there's no risk of modifying the input as
823
+ # there are no flattened fields), or create one.
824
+ if not isinstance(request, client_gateways_service.ListClientGatewaysRequest):
825
+ request = client_gateways_service.ListClientGatewaysRequest(request)
826
+ # If we have keyword arguments corresponding to fields on the
827
+ # request, apply these.
828
+ if parent is not None:
829
+ request.parent = parent
830
+
831
+ # Wrap the RPC method; this adds retry and timeout information,
832
+ # and friendly error handling.
833
+ rpc = self._transport._wrapped_methods[self._transport.list_client_gateways]
834
+
835
+ # Certain fields should be provided within the metadata header;
836
+ # add these here.
837
+ metadata = tuple(metadata) + (
838
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
839
+ )
840
+
841
+ # Validate the universe domain.
842
+ self._validate_universe_domain()
843
+
844
+ # Send the request.
845
+ response = rpc(
846
+ request,
847
+ retry=retry,
848
+ timeout=timeout,
849
+ metadata=metadata,
850
+ )
851
+
852
+ # This method is paged; wrap the response in a pager, which provides
853
+ # an `__iter__` convenience method.
854
+ response = pagers.ListClientGatewaysPager(
855
+ method=rpc,
856
+ request=request,
857
+ response=response,
858
+ retry=retry,
859
+ timeout=timeout,
860
+ metadata=metadata,
861
+ )
862
+
863
+ # Done; return the response.
864
+ return response
865
+
866
+ def get_client_gateway(
867
+ self,
868
+ request: Optional[
869
+ Union[client_gateways_service.GetClientGatewayRequest, dict]
870
+ ] = None,
871
+ *,
872
+ name: Optional[str] = None,
873
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
874
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
875
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
876
+ ) -> client_gateways_service.ClientGateway:
877
+ r"""Gets details of a single ClientGateway.
878
+
879
+ .. code-block:: python
880
+
881
+ # This snippet has been automatically generated and should be regarded as a
882
+ # code template only.
883
+ # It will require modifications to work:
884
+ # - It may require correct/in-range values for request initialization.
885
+ # - It may require specifying regional endpoints when creating the service
886
+ # client as shown in:
887
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
888
+ from google.cloud import beyondcorp_clientgateways_v1
889
+
890
+ def sample_get_client_gateway():
891
+ # Create a client
892
+ client = beyondcorp_clientgateways_v1.ClientGatewaysServiceClient()
893
+
894
+ # Initialize request argument(s)
895
+ request = beyondcorp_clientgateways_v1.GetClientGatewayRequest(
896
+ name="name_value",
897
+ )
898
+
899
+ # Make the request
900
+ response = client.get_client_gateway(request=request)
901
+
902
+ # Handle the response
903
+ print(response)
904
+
905
+ Args:
906
+ request (Union[google.cloud.beyondcorp_clientgateways_v1.types.GetClientGatewayRequest, dict]):
907
+ The request object. Message for getting a ClientGateway.
908
+ name (str):
909
+ Required. Name of the resource
910
+ This corresponds to the ``name`` field
911
+ on the ``request`` instance; if ``request`` is provided, this
912
+ should not be set.
913
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
914
+ should be retried.
915
+ timeout (float): The timeout for this request.
916
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
917
+ sent along with the request as metadata. Normally, each value must be of type `str`,
918
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
919
+ be of type `bytes`.
920
+
921
+ Returns:
922
+ google.cloud.beyondcorp_clientgateways_v1.types.ClientGateway:
923
+ Message describing ClientGateway
924
+ object.
925
+
926
+ """
927
+ # Create or coerce a protobuf request object.
928
+ # - Quick check: If we got a request object, we should *not* have
929
+ # gotten any keyword arguments that map to the request.
930
+ flattened_params = [name]
931
+ has_flattened_params = (
932
+ len([param for param in flattened_params if param is not None]) > 0
933
+ )
934
+ if request is not None and has_flattened_params:
935
+ raise ValueError(
936
+ "If the `request` argument is set, then none of "
937
+ "the individual field arguments should be set."
938
+ )
939
+
940
+ # - Use the request object if provided (there's no risk of modifying the input as
941
+ # there are no flattened fields), or create one.
942
+ if not isinstance(request, client_gateways_service.GetClientGatewayRequest):
943
+ request = client_gateways_service.GetClientGatewayRequest(request)
944
+ # If we have keyword arguments corresponding to fields on the
945
+ # request, apply these.
946
+ if name is not None:
947
+ request.name = name
948
+
949
+ # Wrap the RPC method; this adds retry and timeout information,
950
+ # and friendly error handling.
951
+ rpc = self._transport._wrapped_methods[self._transport.get_client_gateway]
952
+
953
+ # Certain fields should be provided within the metadata header;
954
+ # add these here.
955
+ metadata = tuple(metadata) + (
956
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
957
+ )
958
+
959
+ # Validate the universe domain.
960
+ self._validate_universe_domain()
961
+
962
+ # Send the request.
963
+ response = rpc(
964
+ request,
965
+ retry=retry,
966
+ timeout=timeout,
967
+ metadata=metadata,
968
+ )
969
+
970
+ # Done; return the response.
971
+ return response
972
+
973
+ def create_client_gateway(
974
+ self,
975
+ request: Optional[
976
+ Union[client_gateways_service.CreateClientGatewayRequest, dict]
977
+ ] = None,
978
+ *,
979
+ parent: Optional[str] = None,
980
+ client_gateway: Optional[client_gateways_service.ClientGateway] = None,
981
+ client_gateway_id: Optional[str] = None,
982
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
983
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
984
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
985
+ ) -> operation.Operation:
986
+ r"""Creates a new ClientGateway in a given project and
987
+ location.
988
+
989
+ .. code-block:: python
990
+
991
+ # This snippet has been automatically generated and should be regarded as a
992
+ # code template only.
993
+ # It will require modifications to work:
994
+ # - It may require correct/in-range values for request initialization.
995
+ # - It may require specifying regional endpoints when creating the service
996
+ # client as shown in:
997
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
998
+ from google.cloud import beyondcorp_clientgateways_v1
999
+
1000
+ def sample_create_client_gateway():
1001
+ # Create a client
1002
+ client = beyondcorp_clientgateways_v1.ClientGatewaysServiceClient()
1003
+
1004
+ # Initialize request argument(s)
1005
+ client_gateway = beyondcorp_clientgateways_v1.ClientGateway()
1006
+ client_gateway.name = "name_value"
1007
+
1008
+ request = beyondcorp_clientgateways_v1.CreateClientGatewayRequest(
1009
+ parent="parent_value",
1010
+ client_gateway=client_gateway,
1011
+ )
1012
+
1013
+ # Make the request
1014
+ operation = client.create_client_gateway(request=request)
1015
+
1016
+ print("Waiting for operation to complete...")
1017
+
1018
+ response = operation.result()
1019
+
1020
+ # Handle the response
1021
+ print(response)
1022
+
1023
+ Args:
1024
+ request (Union[google.cloud.beyondcorp_clientgateways_v1.types.CreateClientGatewayRequest, dict]):
1025
+ The request object. Message for creating a ClientGateway.
1026
+ parent (str):
1027
+ Required. Value for parent.
1028
+ This corresponds to the ``parent`` field
1029
+ on the ``request`` instance; if ``request`` is provided, this
1030
+ should not be set.
1031
+ client_gateway (google.cloud.beyondcorp_clientgateways_v1.types.ClientGateway):
1032
+ Required. The resource being created.
1033
+ This corresponds to the ``client_gateway`` field
1034
+ on the ``request`` instance; if ``request`` is provided, this
1035
+ should not be set.
1036
+ client_gateway_id (str):
1037
+ Optional. User-settable client gateway resource ID.
1038
+
1039
+ - Must start with a letter.
1040
+ - Must contain between 4-63 characters from
1041
+ ``/[a-z][0-9]-/``.
1042
+ - Must end with a number or a letter.
1043
+
1044
+ This corresponds to the ``client_gateway_id`` field
1045
+ on the ``request`` instance; if ``request`` is provided, this
1046
+ should not be set.
1047
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1048
+ should be retried.
1049
+ timeout (float): The timeout for this request.
1050
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1051
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1052
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1053
+ be of type `bytes`.
1054
+
1055
+ Returns:
1056
+ google.api_core.operation.Operation:
1057
+ An object representing a long-running operation.
1058
+
1059
+ The result type for the operation will be
1060
+ :class:`google.cloud.beyondcorp_clientgateways_v1.types.ClientGateway`
1061
+ Message describing ClientGateway object.
1062
+
1063
+ """
1064
+ # Create or coerce a protobuf request object.
1065
+ # - Quick check: If we got a request object, we should *not* have
1066
+ # gotten any keyword arguments that map to the request.
1067
+ flattened_params = [parent, client_gateway, client_gateway_id]
1068
+ has_flattened_params = (
1069
+ len([param for param in flattened_params if param is not None]) > 0
1070
+ )
1071
+ if request is not None and has_flattened_params:
1072
+ raise ValueError(
1073
+ "If the `request` argument is set, then none of "
1074
+ "the individual field arguments should be set."
1075
+ )
1076
+
1077
+ # - Use the request object if provided (there's no risk of modifying the input as
1078
+ # there are no flattened fields), or create one.
1079
+ if not isinstance(request, client_gateways_service.CreateClientGatewayRequest):
1080
+ request = client_gateways_service.CreateClientGatewayRequest(request)
1081
+ # If we have keyword arguments corresponding to fields on the
1082
+ # request, apply these.
1083
+ if parent is not None:
1084
+ request.parent = parent
1085
+ if client_gateway is not None:
1086
+ request.client_gateway = client_gateway
1087
+ if client_gateway_id is not None:
1088
+ request.client_gateway_id = client_gateway_id
1089
+
1090
+ # Wrap the RPC method; this adds retry and timeout information,
1091
+ # and friendly error handling.
1092
+ rpc = self._transport._wrapped_methods[self._transport.create_client_gateway]
1093
+
1094
+ # Certain fields should be provided within the metadata header;
1095
+ # add these here.
1096
+ metadata = tuple(metadata) + (
1097
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
1098
+ )
1099
+
1100
+ # Validate the universe domain.
1101
+ self._validate_universe_domain()
1102
+
1103
+ # Send the request.
1104
+ response = rpc(
1105
+ request,
1106
+ retry=retry,
1107
+ timeout=timeout,
1108
+ metadata=metadata,
1109
+ )
1110
+
1111
+ # Wrap the response in an operation future.
1112
+ response = operation.from_gapic(
1113
+ response,
1114
+ self._transport.operations_client,
1115
+ client_gateways_service.ClientGateway,
1116
+ metadata_type=client_gateways_service.ClientGatewayOperationMetadata,
1117
+ )
1118
+
1119
+ # Done; return the response.
1120
+ return response
1121
+
1122
+ def delete_client_gateway(
1123
+ self,
1124
+ request: Optional[
1125
+ Union[client_gateways_service.DeleteClientGatewayRequest, dict]
1126
+ ] = None,
1127
+ *,
1128
+ name: Optional[str] = None,
1129
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1130
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1131
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1132
+ ) -> operation.Operation:
1133
+ r"""Deletes a single ClientGateway.
1134
+
1135
+ .. code-block:: python
1136
+
1137
+ # This snippet has been automatically generated and should be regarded as a
1138
+ # code template only.
1139
+ # It will require modifications to work:
1140
+ # - It may require correct/in-range values for request initialization.
1141
+ # - It may require specifying regional endpoints when creating the service
1142
+ # client as shown in:
1143
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1144
+ from google.cloud import beyondcorp_clientgateways_v1
1145
+
1146
+ def sample_delete_client_gateway():
1147
+ # Create a client
1148
+ client = beyondcorp_clientgateways_v1.ClientGatewaysServiceClient()
1149
+
1150
+ # Initialize request argument(s)
1151
+ request = beyondcorp_clientgateways_v1.DeleteClientGatewayRequest(
1152
+ name="name_value",
1153
+ )
1154
+
1155
+ # Make the request
1156
+ operation = client.delete_client_gateway(request=request)
1157
+
1158
+ print("Waiting for operation to complete...")
1159
+
1160
+ response = operation.result()
1161
+
1162
+ # Handle the response
1163
+ print(response)
1164
+
1165
+ Args:
1166
+ request (Union[google.cloud.beyondcorp_clientgateways_v1.types.DeleteClientGatewayRequest, dict]):
1167
+ The request object. Message for deleting a ClientGateway
1168
+ name (str):
1169
+ Required. Name of the resource
1170
+ This corresponds to the ``name`` field
1171
+ on the ``request`` instance; if ``request`` is provided, this
1172
+ should not be set.
1173
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1174
+ should be retried.
1175
+ timeout (float): The timeout for this request.
1176
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1177
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1178
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1179
+ be of type `bytes`.
1180
+
1181
+ Returns:
1182
+ google.api_core.operation.Operation:
1183
+ An object representing a long-running operation.
1184
+
1185
+ 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
1186
+ empty messages in your APIs. A typical example is to
1187
+ use it as the request or the response type of an API
1188
+ method. For instance:
1189
+
1190
+ service Foo {
1191
+ rpc Bar(google.protobuf.Empty) returns
1192
+ (google.protobuf.Empty);
1193
+
1194
+ }
1195
+
1196
+ """
1197
+ # Create or coerce a protobuf request object.
1198
+ # - Quick check: If we got a request object, we should *not* have
1199
+ # gotten any keyword arguments that map to the request.
1200
+ flattened_params = [name]
1201
+ has_flattened_params = (
1202
+ len([param for param in flattened_params if param is not None]) > 0
1203
+ )
1204
+ if request is not None and has_flattened_params:
1205
+ raise ValueError(
1206
+ "If the `request` argument is set, then none of "
1207
+ "the individual field arguments should be set."
1208
+ )
1209
+
1210
+ # - Use the request object if provided (there's no risk of modifying the input as
1211
+ # there are no flattened fields), or create one.
1212
+ if not isinstance(request, client_gateways_service.DeleteClientGatewayRequest):
1213
+ request = client_gateways_service.DeleteClientGatewayRequest(request)
1214
+ # If we have keyword arguments corresponding to fields on the
1215
+ # request, apply these.
1216
+ if name is not None:
1217
+ request.name = name
1218
+
1219
+ # Wrap the RPC method; this adds retry and timeout information,
1220
+ # and friendly error handling.
1221
+ rpc = self._transport._wrapped_methods[self._transport.delete_client_gateway]
1222
+
1223
+ # Certain fields should be provided within the metadata header;
1224
+ # add these here.
1225
+ metadata = tuple(metadata) + (
1226
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1227
+ )
1228
+
1229
+ # Validate the universe domain.
1230
+ self._validate_universe_domain()
1231
+
1232
+ # Send the request.
1233
+ response = rpc(
1234
+ request,
1235
+ retry=retry,
1236
+ timeout=timeout,
1237
+ metadata=metadata,
1238
+ )
1239
+
1240
+ # Wrap the response in an operation future.
1241
+ response = operation.from_gapic(
1242
+ response,
1243
+ self._transport.operations_client,
1244
+ empty_pb2.Empty,
1245
+ metadata_type=client_gateways_service.ClientGatewayOperationMetadata,
1246
+ )
1247
+
1248
+ # Done; return the response.
1249
+ return response
1250
+
1251
+ def __enter__(self) -> "ClientGatewaysServiceClient":
1252
+ return self
1253
+
1254
+ def __exit__(self, type, value, traceback):
1255
+ """Releases underlying transport's resources.
1256
+
1257
+ .. warning::
1258
+ ONLY use as a context manager if the transport is NOT shared
1259
+ with other clients! Exiting the with block will CLOSE the transport
1260
+ and may cause errors in other clients!
1261
+ """
1262
+ self.transport.close()
1263
+
1264
+ def list_operations(
1265
+ self,
1266
+ request: Optional[operations_pb2.ListOperationsRequest] = None,
1267
+ *,
1268
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1269
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1270
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1271
+ ) -> operations_pb2.ListOperationsResponse:
1272
+ r"""Lists operations that match the specified filter in the request.
1273
+
1274
+ Args:
1275
+ request (:class:`~.operations_pb2.ListOperationsRequest`):
1276
+ The request object. Request message for
1277
+ `ListOperations` method.
1278
+ retry (google.api_core.retry.Retry): Designation of what errors,
1279
+ if any, should be retried.
1280
+ timeout (float): The timeout for this request.
1281
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1282
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1283
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1284
+ be of type `bytes`.
1285
+ Returns:
1286
+ ~.operations_pb2.ListOperationsResponse:
1287
+ Response message for ``ListOperations`` method.
1288
+ """
1289
+ # Create or coerce a protobuf request object.
1290
+ # The request isn't a proto-plus wrapped type,
1291
+ # so it must be constructed via keyword expansion.
1292
+ if isinstance(request, dict):
1293
+ request = operations_pb2.ListOperationsRequest(**request)
1294
+
1295
+ # Wrap the RPC method; this adds retry and timeout information,
1296
+ # and friendly error handling.
1297
+ rpc = self._transport._wrapped_methods[self._transport.list_operations]
1298
+
1299
+ # Certain fields should be provided within the metadata header;
1300
+ # add these here.
1301
+ metadata = tuple(metadata) + (
1302
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1303
+ )
1304
+
1305
+ # Validate the universe domain.
1306
+ self._validate_universe_domain()
1307
+
1308
+ try:
1309
+ # Send the request.
1310
+ response = rpc(
1311
+ request,
1312
+ retry=retry,
1313
+ timeout=timeout,
1314
+ metadata=metadata,
1315
+ )
1316
+
1317
+ # Done; return the response.
1318
+ return response
1319
+ except core_exceptions.GoogleAPICallError as e:
1320
+ self._add_cred_info_for_auth_errors(e)
1321
+ raise e
1322
+
1323
+ def get_operation(
1324
+ self,
1325
+ request: Optional[operations_pb2.GetOperationRequest] = None,
1326
+ *,
1327
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1328
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1329
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1330
+ ) -> operations_pb2.Operation:
1331
+ r"""Gets the latest state of a long-running operation.
1332
+
1333
+ Args:
1334
+ request (:class:`~.operations_pb2.GetOperationRequest`):
1335
+ The request object. Request message for
1336
+ `GetOperation` method.
1337
+ retry (google.api_core.retry.Retry): Designation of what errors,
1338
+ if any, should be retried.
1339
+ timeout (float): The timeout for this request.
1340
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1341
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1342
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1343
+ be of type `bytes`.
1344
+ Returns:
1345
+ ~.operations_pb2.Operation:
1346
+ An ``Operation`` object.
1347
+ """
1348
+ # Create or coerce a protobuf request object.
1349
+ # The request isn't a proto-plus wrapped type,
1350
+ # so it must be constructed via keyword expansion.
1351
+ if isinstance(request, dict):
1352
+ request = operations_pb2.GetOperationRequest(**request)
1353
+
1354
+ # Wrap the RPC method; this adds retry and timeout information,
1355
+ # and friendly error handling.
1356
+ rpc = self._transport._wrapped_methods[self._transport.get_operation]
1357
+
1358
+ # Certain fields should be provided within the metadata header;
1359
+ # add these here.
1360
+ metadata = tuple(metadata) + (
1361
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1362
+ )
1363
+
1364
+ # Validate the universe domain.
1365
+ self._validate_universe_domain()
1366
+
1367
+ try:
1368
+ # Send the request.
1369
+ response = rpc(
1370
+ request,
1371
+ retry=retry,
1372
+ timeout=timeout,
1373
+ metadata=metadata,
1374
+ )
1375
+
1376
+ # Done; return the response.
1377
+ return response
1378
+ except core_exceptions.GoogleAPICallError as e:
1379
+ self._add_cred_info_for_auth_errors(e)
1380
+ raise e
1381
+
1382
+ def delete_operation(
1383
+ self,
1384
+ request: Optional[operations_pb2.DeleteOperationRequest] = None,
1385
+ *,
1386
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1387
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1388
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1389
+ ) -> None:
1390
+ r"""Deletes a long-running operation.
1391
+
1392
+ This method indicates that the client is no longer interested
1393
+ in the operation result. It does not cancel the operation.
1394
+ If the server doesn't support this method, it returns
1395
+ `google.rpc.Code.UNIMPLEMENTED`.
1396
+
1397
+ Args:
1398
+ request (:class:`~.operations_pb2.DeleteOperationRequest`):
1399
+ The request object. Request message for
1400
+ `DeleteOperation` method.
1401
+ retry (google.api_core.retry.Retry): Designation of what errors,
1402
+ if any, should be retried.
1403
+ timeout (float): The timeout for this request.
1404
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1405
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1406
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1407
+ be of type `bytes`.
1408
+ Returns:
1409
+ None
1410
+ """
1411
+ # Create or coerce a protobuf request object.
1412
+ # The request isn't a proto-plus wrapped type,
1413
+ # so it must be constructed via keyword expansion.
1414
+ if isinstance(request, dict):
1415
+ request = operations_pb2.DeleteOperationRequest(**request)
1416
+
1417
+ # Wrap the RPC method; this adds retry and timeout information,
1418
+ # and friendly error handling.
1419
+ rpc = self._transport._wrapped_methods[self._transport.delete_operation]
1420
+
1421
+ # Certain fields should be provided within the metadata header;
1422
+ # add these here.
1423
+ metadata = tuple(metadata) + (
1424
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1425
+ )
1426
+
1427
+ # Validate the universe domain.
1428
+ self._validate_universe_domain()
1429
+
1430
+ # Send the request.
1431
+ rpc(
1432
+ request,
1433
+ retry=retry,
1434
+ timeout=timeout,
1435
+ metadata=metadata,
1436
+ )
1437
+
1438
+ def cancel_operation(
1439
+ self,
1440
+ request: Optional[operations_pb2.CancelOperationRequest] = None,
1441
+ *,
1442
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1443
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1444
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1445
+ ) -> None:
1446
+ r"""Starts asynchronous cancellation on a long-running operation.
1447
+
1448
+ The server makes a best effort to cancel the operation, but success
1449
+ is not guaranteed. If the server doesn't support this method, it returns
1450
+ `google.rpc.Code.UNIMPLEMENTED`.
1451
+
1452
+ Args:
1453
+ request (:class:`~.operations_pb2.CancelOperationRequest`):
1454
+ The request object. Request message for
1455
+ `CancelOperation` method.
1456
+ retry (google.api_core.retry.Retry): Designation of what errors,
1457
+ if any, should be retried.
1458
+ timeout (float): The timeout for this request.
1459
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1460
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1461
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1462
+ be of type `bytes`.
1463
+ Returns:
1464
+ None
1465
+ """
1466
+ # Create or coerce a protobuf request object.
1467
+ # The request isn't a proto-plus wrapped type,
1468
+ # so it must be constructed via keyword expansion.
1469
+ if isinstance(request, dict):
1470
+ request = operations_pb2.CancelOperationRequest(**request)
1471
+
1472
+ # Wrap the RPC method; this adds retry and timeout information,
1473
+ # and friendly error handling.
1474
+ rpc = self._transport._wrapped_methods[self._transport.cancel_operation]
1475
+
1476
+ # Certain fields should be provided within the metadata header;
1477
+ # add these here.
1478
+ metadata = tuple(metadata) + (
1479
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1480
+ )
1481
+
1482
+ # Validate the universe domain.
1483
+ self._validate_universe_domain()
1484
+
1485
+ # Send the request.
1486
+ rpc(
1487
+ request,
1488
+ retry=retry,
1489
+ timeout=timeout,
1490
+ metadata=metadata,
1491
+ )
1492
+
1493
+ def set_iam_policy(
1494
+ self,
1495
+ request: Optional[iam_policy_pb2.SetIamPolicyRequest] = None,
1496
+ *,
1497
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1498
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1499
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1500
+ ) -> policy_pb2.Policy:
1501
+ r"""Sets the IAM access control policy on the specified function.
1502
+
1503
+ Replaces any existing policy.
1504
+
1505
+ Args:
1506
+ request (:class:`~.iam_policy_pb2.SetIamPolicyRequest`):
1507
+ The request object. Request message for `SetIamPolicy`
1508
+ method.
1509
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1510
+ should be retried.
1511
+ timeout (float): The timeout for this request.
1512
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1513
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1514
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1515
+ be of type `bytes`.
1516
+ Returns:
1517
+ ~.policy_pb2.Policy:
1518
+ Defines an Identity and Access Management (IAM) policy.
1519
+ It is used to specify access control policies for Cloud
1520
+ Platform resources.
1521
+ A ``Policy`` is a collection of ``bindings``. A
1522
+ ``binding`` binds one or more ``members`` to a single
1523
+ ``role``. Members can be user accounts, service
1524
+ accounts, Google groups, and domains (such as G Suite).
1525
+ A ``role`` is a named list of permissions (defined by
1526
+ IAM or configured by users). A ``binding`` can
1527
+ optionally specify a ``condition``, which is a logic
1528
+ expression that further constrains the role binding
1529
+ based on attributes about the request and/or target
1530
+ resource.
1531
+
1532
+ **JSON Example**
1533
+
1534
+ ::
1535
+
1536
+ {
1537
+ "bindings": [
1538
+ {
1539
+ "role": "roles/resourcemanager.organizationAdmin",
1540
+ "members": [
1541
+ "user:mike@example.com",
1542
+ "group:admins@example.com",
1543
+ "domain:google.com",
1544
+ "serviceAccount:my-project-id@appspot.gserviceaccount.com"
1545
+ ]
1546
+ },
1547
+ {
1548
+ "role": "roles/resourcemanager.organizationViewer",
1549
+ "members": ["user:eve@example.com"],
1550
+ "condition": {
1551
+ "title": "expirable access",
1552
+ "description": "Does not grant access after Sep 2020",
1553
+ "expression": "request.time <
1554
+ timestamp('2020-10-01T00:00:00.000Z')",
1555
+ }
1556
+ }
1557
+ ]
1558
+ }
1559
+
1560
+ **YAML Example**
1561
+
1562
+ ::
1563
+
1564
+ bindings:
1565
+ - members:
1566
+ - user:mike@example.com
1567
+ - group:admins@example.com
1568
+ - domain:google.com
1569
+ - serviceAccount:my-project-id@appspot.gserviceaccount.com
1570
+ role: roles/resourcemanager.organizationAdmin
1571
+ - members:
1572
+ - user:eve@example.com
1573
+ role: roles/resourcemanager.organizationViewer
1574
+ condition:
1575
+ title: expirable access
1576
+ description: Does not grant access after Sep 2020
1577
+ expression: request.time < timestamp('2020-10-01T00:00:00.000Z')
1578
+
1579
+ For a description of IAM and its features, see the `IAM
1580
+ developer's
1581
+ guide <https://cloud.google.com/iam/docs>`__.
1582
+ """
1583
+ # Create or coerce a protobuf request object.
1584
+
1585
+ # The request isn't a proto-plus wrapped type,
1586
+ # so it must be constructed via keyword expansion.
1587
+ if isinstance(request, dict):
1588
+ request = iam_policy_pb2.SetIamPolicyRequest(**request)
1589
+
1590
+ # Wrap the RPC method; this adds retry and timeout information,
1591
+ # and friendly error handling.
1592
+ rpc = self._transport._wrapped_methods[self._transport.set_iam_policy]
1593
+
1594
+ # Certain fields should be provided within the metadata header;
1595
+ # add these here.
1596
+ metadata = tuple(metadata) + (
1597
+ gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
1598
+ )
1599
+
1600
+ # Validate the universe domain.
1601
+ self._validate_universe_domain()
1602
+
1603
+ try:
1604
+ # Send the request.
1605
+ response = rpc(
1606
+ request,
1607
+ retry=retry,
1608
+ timeout=timeout,
1609
+ metadata=metadata,
1610
+ )
1611
+
1612
+ # Done; return the response.
1613
+ return response
1614
+ except core_exceptions.GoogleAPICallError as e:
1615
+ self._add_cred_info_for_auth_errors(e)
1616
+ raise e
1617
+
1618
+ def get_iam_policy(
1619
+ self,
1620
+ request: Optional[iam_policy_pb2.GetIamPolicyRequest] = None,
1621
+ *,
1622
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1623
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1624
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1625
+ ) -> policy_pb2.Policy:
1626
+ r"""Gets the IAM access control policy for a function.
1627
+
1628
+ Returns an empty policy if the function exists and does not have a
1629
+ policy set.
1630
+
1631
+ Args:
1632
+ request (:class:`~.iam_policy_pb2.GetIamPolicyRequest`):
1633
+ The request object. Request message for `GetIamPolicy`
1634
+ method.
1635
+ retry (google.api_core.retry.Retry): Designation of what errors, if
1636
+ any, should be retried.
1637
+ timeout (float): The timeout for this request.
1638
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1639
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1640
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1641
+ be of type `bytes`.
1642
+ Returns:
1643
+ ~.policy_pb2.Policy:
1644
+ Defines an Identity and Access Management (IAM) policy.
1645
+ It is used to specify access control policies for Cloud
1646
+ Platform resources.
1647
+ A ``Policy`` is a collection of ``bindings``. A
1648
+ ``binding`` binds one or more ``members`` to a single
1649
+ ``role``. Members can be user accounts, service
1650
+ accounts, Google groups, and domains (such as G Suite).
1651
+ A ``role`` is a named list of permissions (defined by
1652
+ IAM or configured by users). A ``binding`` can
1653
+ optionally specify a ``condition``, which is a logic
1654
+ expression that further constrains the role binding
1655
+ based on attributes about the request and/or target
1656
+ resource.
1657
+
1658
+ **JSON Example**
1659
+
1660
+ ::
1661
+
1662
+ {
1663
+ "bindings": [
1664
+ {
1665
+ "role": "roles/resourcemanager.organizationAdmin",
1666
+ "members": [
1667
+ "user:mike@example.com",
1668
+ "group:admins@example.com",
1669
+ "domain:google.com",
1670
+ "serviceAccount:my-project-id@appspot.gserviceaccount.com"
1671
+ ]
1672
+ },
1673
+ {
1674
+ "role": "roles/resourcemanager.organizationViewer",
1675
+ "members": ["user:eve@example.com"],
1676
+ "condition": {
1677
+ "title": "expirable access",
1678
+ "description": "Does not grant access after Sep 2020",
1679
+ "expression": "request.time <
1680
+ timestamp('2020-10-01T00:00:00.000Z')",
1681
+ }
1682
+ }
1683
+ ]
1684
+ }
1685
+
1686
+ **YAML Example**
1687
+
1688
+ ::
1689
+
1690
+ bindings:
1691
+ - members:
1692
+ - user:mike@example.com
1693
+ - group:admins@example.com
1694
+ - domain:google.com
1695
+ - serviceAccount:my-project-id@appspot.gserviceaccount.com
1696
+ role: roles/resourcemanager.organizationAdmin
1697
+ - members:
1698
+ - user:eve@example.com
1699
+ role: roles/resourcemanager.organizationViewer
1700
+ condition:
1701
+ title: expirable access
1702
+ description: Does not grant access after Sep 2020
1703
+ expression: request.time < timestamp('2020-10-01T00:00:00.000Z')
1704
+
1705
+ For a description of IAM and its features, see the `IAM
1706
+ developer's
1707
+ guide <https://cloud.google.com/iam/docs>`__.
1708
+ """
1709
+ # Create or coerce a protobuf request object.
1710
+
1711
+ # The request isn't a proto-plus wrapped type,
1712
+ # so it must be constructed via keyword expansion.
1713
+ if isinstance(request, dict):
1714
+ request = iam_policy_pb2.GetIamPolicyRequest(**request)
1715
+
1716
+ # Wrap the RPC method; this adds retry and timeout information,
1717
+ # and friendly error handling.
1718
+ rpc = self._transport._wrapped_methods[self._transport.get_iam_policy]
1719
+
1720
+ # Certain fields should be provided within the metadata header;
1721
+ # add these here.
1722
+ metadata = tuple(metadata) + (
1723
+ gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
1724
+ )
1725
+
1726
+ # Validate the universe domain.
1727
+ self._validate_universe_domain()
1728
+
1729
+ try:
1730
+ # Send the request.
1731
+ response = rpc(
1732
+ request,
1733
+ retry=retry,
1734
+ timeout=timeout,
1735
+ metadata=metadata,
1736
+ )
1737
+
1738
+ # Done; return the response.
1739
+ return response
1740
+ except core_exceptions.GoogleAPICallError as e:
1741
+ self._add_cred_info_for_auth_errors(e)
1742
+ raise e
1743
+
1744
+ def test_iam_permissions(
1745
+ self,
1746
+ request: Optional[iam_policy_pb2.TestIamPermissionsRequest] = None,
1747
+ *,
1748
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1749
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1750
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1751
+ ) -> iam_policy_pb2.TestIamPermissionsResponse:
1752
+ r"""Tests the specified IAM permissions against the IAM access control
1753
+ policy for a function.
1754
+
1755
+ If the function does not exist, this will return an empty set
1756
+ of permissions, not a NOT_FOUND error.
1757
+
1758
+ Args:
1759
+ request (:class:`~.iam_policy_pb2.TestIamPermissionsRequest`):
1760
+ The request object. Request message for
1761
+ `TestIamPermissions` method.
1762
+ retry (google.api_core.retry.Retry): Designation of what errors,
1763
+ if any, should be retried.
1764
+ timeout (float): The timeout for this request.
1765
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1766
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1767
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1768
+ be of type `bytes`.
1769
+ Returns:
1770
+ ~.iam_policy_pb2.TestIamPermissionsResponse:
1771
+ Response message for ``TestIamPermissions`` method.
1772
+ """
1773
+ # Create or coerce a protobuf request object.
1774
+
1775
+ # The request isn't a proto-plus wrapped type,
1776
+ # so it must be constructed via keyword expansion.
1777
+ if isinstance(request, dict):
1778
+ request = iam_policy_pb2.TestIamPermissionsRequest(**request)
1779
+
1780
+ # Wrap the RPC method; this adds retry and timeout information,
1781
+ # and friendly error handling.
1782
+ rpc = self._transport._wrapped_methods[self._transport.test_iam_permissions]
1783
+
1784
+ # Certain fields should be provided within the metadata header;
1785
+ # add these here.
1786
+ metadata = tuple(metadata) + (
1787
+ gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
1788
+ )
1789
+
1790
+ # Validate the universe domain.
1791
+ self._validate_universe_domain()
1792
+
1793
+ try:
1794
+ # Send the request.
1795
+ response = rpc(
1796
+ request,
1797
+ retry=retry,
1798
+ timeout=timeout,
1799
+ metadata=metadata,
1800
+ )
1801
+
1802
+ # Done; return the response.
1803
+ return response
1804
+ except core_exceptions.GoogleAPICallError as e:
1805
+ self._add_cred_info_for_auth_errors(e)
1806
+ raise e
1807
+
1808
+ def get_location(
1809
+ self,
1810
+ request: Optional[locations_pb2.GetLocationRequest] = None,
1811
+ *,
1812
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1813
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1814
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1815
+ ) -> locations_pb2.Location:
1816
+ r"""Gets information about a location.
1817
+
1818
+ Args:
1819
+ request (:class:`~.location_pb2.GetLocationRequest`):
1820
+ The request object. Request message for
1821
+ `GetLocation` method.
1822
+ retry (google.api_core.retry.Retry): Designation of what errors,
1823
+ if any, should be retried.
1824
+ timeout (float): The timeout for this request.
1825
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1826
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1827
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1828
+ be of type `bytes`.
1829
+ Returns:
1830
+ ~.location_pb2.Location:
1831
+ Location object.
1832
+ """
1833
+ # Create or coerce a protobuf request object.
1834
+ # The request isn't a proto-plus wrapped type,
1835
+ # so it must be constructed via keyword expansion.
1836
+ if isinstance(request, dict):
1837
+ request = locations_pb2.GetLocationRequest(**request)
1838
+
1839
+ # Wrap the RPC method; this adds retry and timeout information,
1840
+ # and friendly error handling.
1841
+ rpc = self._transport._wrapped_methods[self._transport.get_location]
1842
+
1843
+ # Certain fields should be provided within the metadata header;
1844
+ # add these here.
1845
+ metadata = tuple(metadata) + (
1846
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1847
+ )
1848
+
1849
+ # Validate the universe domain.
1850
+ self._validate_universe_domain()
1851
+
1852
+ try:
1853
+ # Send the request.
1854
+ response = rpc(
1855
+ request,
1856
+ retry=retry,
1857
+ timeout=timeout,
1858
+ metadata=metadata,
1859
+ )
1860
+
1861
+ # Done; return the response.
1862
+ return response
1863
+ except core_exceptions.GoogleAPICallError as e:
1864
+ self._add_cred_info_for_auth_errors(e)
1865
+ raise e
1866
+
1867
+ def list_locations(
1868
+ self,
1869
+ request: Optional[locations_pb2.ListLocationsRequest] = None,
1870
+ *,
1871
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1872
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1873
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1874
+ ) -> locations_pb2.ListLocationsResponse:
1875
+ r"""Lists information about the supported locations for this service.
1876
+
1877
+ Args:
1878
+ request (:class:`~.location_pb2.ListLocationsRequest`):
1879
+ The request object. Request message for
1880
+ `ListLocations` method.
1881
+ retry (google.api_core.retry.Retry): Designation of what errors,
1882
+ if any, should be retried.
1883
+ timeout (float): The timeout for this request.
1884
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1885
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1886
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1887
+ be of type `bytes`.
1888
+ Returns:
1889
+ ~.location_pb2.ListLocationsResponse:
1890
+ Response message for ``ListLocations`` method.
1891
+ """
1892
+ # Create or coerce a protobuf request object.
1893
+ # The request isn't a proto-plus wrapped type,
1894
+ # so it must be constructed via keyword expansion.
1895
+ if isinstance(request, dict):
1896
+ request = locations_pb2.ListLocationsRequest(**request)
1897
+
1898
+ # Wrap the RPC method; this adds retry and timeout information,
1899
+ # and friendly error handling.
1900
+ rpc = self._transport._wrapped_methods[self._transport.list_locations]
1901
+
1902
+ # Certain fields should be provided within the metadata header;
1903
+ # add these here.
1904
+ metadata = tuple(metadata) + (
1905
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1906
+ )
1907
+
1908
+ # Validate the universe domain.
1909
+ self._validate_universe_domain()
1910
+
1911
+ try:
1912
+ # Send the request.
1913
+ response = rpc(
1914
+ request,
1915
+ retry=retry,
1916
+ timeout=timeout,
1917
+ metadata=metadata,
1918
+ )
1919
+
1920
+ # Done; return the response.
1921
+ return response
1922
+ except core_exceptions.GoogleAPICallError as e:
1923
+ self._add_cred_info_for_auth_errors(e)
1924
+ raise e
1925
+
1926
+
1927
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
1928
+ gapic_version=package_version.__version__
1929
+ )
1930
+
1931
+
1932
+ __all__ = ("ClientGatewaysServiceClient",)