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