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.
- google/cloud/modelarmor/__init__.py +117 -0
- google/cloud/modelarmor/gapic_version.py +16 -0
- google/cloud/modelarmor/py.typed +2 -0
- google/cloud/modelarmor_v1/__init__.py +114 -0
- google/cloud/modelarmor_v1/gapic_metadata.json +163 -0
- google/cloud/modelarmor_v1/gapic_version.py +16 -0
- google/cloud/modelarmor_v1/py.typed +2 -0
- google/cloud/modelarmor_v1/services/__init__.py +15 -0
- google/cloud/modelarmor_v1/services/model_armor/__init__.py +22 -0
- google/cloud/modelarmor_v1/services/model_armor/async_client.py +1377 -0
- google/cloud/modelarmor_v1/services/model_armor/client.py +1772 -0
- google/cloud/modelarmor_v1/services/model_armor/pagers.py +197 -0
- google/cloud/modelarmor_v1/services/model_armor/transports/__init__.py +36 -0
- google/cloud/modelarmor_v1/services/model_armor/transports/base.py +357 -0
- google/cloud/modelarmor_v1/services/model_armor/transports/grpc.py +607 -0
- google/cloud/modelarmor_v1/services/model_armor/transports/grpc_asyncio.py +730 -0
- google/cloud/modelarmor_v1/services/model_armor/transports/rest.py +2143 -0
- google/cloud/modelarmor_v1/services/model_armor/transports/rest_base.py +638 -0
- google/cloud/modelarmor_v1/types/__init__.py +106 -0
- google/cloud/modelarmor_v1/types/service.py +1881 -0
- google_cloud_modelarmor-0.1.0.dist-info/LICENSE +202 -0
- google_cloud_modelarmor-0.1.0.dist-info/METADATA +139 -0
- google_cloud_modelarmor-0.1.0.dist-info/RECORD +25 -0
- google_cloud_modelarmor-0.1.0.dist-info/WHEEL +5 -0
- google_cloud_modelarmor-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,1377 @@
|
|
|
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 re
|
|
19
|
+
from typing import (
|
|
20
|
+
Callable,
|
|
21
|
+
Dict,
|
|
22
|
+
Mapping,
|
|
23
|
+
MutableMapping,
|
|
24
|
+
MutableSequence,
|
|
25
|
+
Optional,
|
|
26
|
+
Sequence,
|
|
27
|
+
Tuple,
|
|
28
|
+
Type,
|
|
29
|
+
Union,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
from google.api_core import exceptions as core_exceptions
|
|
33
|
+
from google.api_core import gapic_v1
|
|
34
|
+
from google.api_core import retry_async as retries
|
|
35
|
+
from google.api_core.client_options import ClientOptions
|
|
36
|
+
from google.auth import credentials as ga_credentials # type: ignore
|
|
37
|
+
from google.oauth2 import service_account # type: ignore
|
|
38
|
+
|
|
39
|
+
from google.cloud.modelarmor_v1 import gapic_version as package_version
|
|
40
|
+
|
|
41
|
+
try:
|
|
42
|
+
OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault, None]
|
|
43
|
+
except AttributeError: # pragma: NO COVER
|
|
44
|
+
OptionalRetry = Union[retries.AsyncRetry, object, None] # type: ignore
|
|
45
|
+
|
|
46
|
+
from google.cloud.location import locations_pb2 # type: ignore
|
|
47
|
+
from google.protobuf import field_mask_pb2 # type: ignore
|
|
48
|
+
from google.protobuf import timestamp_pb2 # type: ignore
|
|
49
|
+
|
|
50
|
+
from google.cloud.modelarmor_v1.services.model_armor import pagers
|
|
51
|
+
from google.cloud.modelarmor_v1.types import service
|
|
52
|
+
|
|
53
|
+
from .client import ModelArmorClient
|
|
54
|
+
from .transports.base import DEFAULT_CLIENT_INFO, ModelArmorTransport
|
|
55
|
+
from .transports.grpc_asyncio import ModelArmorGrpcAsyncIOTransport
|
|
56
|
+
|
|
57
|
+
try:
|
|
58
|
+
from google.api_core import client_logging # type: ignore
|
|
59
|
+
|
|
60
|
+
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
|
|
61
|
+
except ImportError: # pragma: NO COVER
|
|
62
|
+
CLIENT_LOGGING_SUPPORTED = False
|
|
63
|
+
|
|
64
|
+
_LOGGER = std_logging.getLogger(__name__)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class ModelArmorAsyncClient:
|
|
68
|
+
"""Service describing handlers for resources"""
|
|
69
|
+
|
|
70
|
+
_client: ModelArmorClient
|
|
71
|
+
|
|
72
|
+
# Copy defaults from the synchronous client for use here.
|
|
73
|
+
# Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
|
|
74
|
+
DEFAULT_ENDPOINT = ModelArmorClient.DEFAULT_ENDPOINT
|
|
75
|
+
DEFAULT_MTLS_ENDPOINT = ModelArmorClient.DEFAULT_MTLS_ENDPOINT
|
|
76
|
+
_DEFAULT_ENDPOINT_TEMPLATE = ModelArmorClient._DEFAULT_ENDPOINT_TEMPLATE
|
|
77
|
+
_DEFAULT_UNIVERSE = ModelArmorClient._DEFAULT_UNIVERSE
|
|
78
|
+
|
|
79
|
+
floor_setting_path = staticmethod(ModelArmorClient.floor_setting_path)
|
|
80
|
+
parse_floor_setting_path = staticmethod(ModelArmorClient.parse_floor_setting_path)
|
|
81
|
+
template_path = staticmethod(ModelArmorClient.template_path)
|
|
82
|
+
parse_template_path = staticmethod(ModelArmorClient.parse_template_path)
|
|
83
|
+
common_billing_account_path = staticmethod(
|
|
84
|
+
ModelArmorClient.common_billing_account_path
|
|
85
|
+
)
|
|
86
|
+
parse_common_billing_account_path = staticmethod(
|
|
87
|
+
ModelArmorClient.parse_common_billing_account_path
|
|
88
|
+
)
|
|
89
|
+
common_folder_path = staticmethod(ModelArmorClient.common_folder_path)
|
|
90
|
+
parse_common_folder_path = staticmethod(ModelArmorClient.parse_common_folder_path)
|
|
91
|
+
common_organization_path = staticmethod(ModelArmorClient.common_organization_path)
|
|
92
|
+
parse_common_organization_path = staticmethod(
|
|
93
|
+
ModelArmorClient.parse_common_organization_path
|
|
94
|
+
)
|
|
95
|
+
common_project_path = staticmethod(ModelArmorClient.common_project_path)
|
|
96
|
+
parse_common_project_path = staticmethod(ModelArmorClient.parse_common_project_path)
|
|
97
|
+
common_location_path = staticmethod(ModelArmorClient.common_location_path)
|
|
98
|
+
parse_common_location_path = staticmethod(
|
|
99
|
+
ModelArmorClient.parse_common_location_path
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
@classmethod
|
|
103
|
+
def from_service_account_info(cls, info: dict, *args, **kwargs):
|
|
104
|
+
"""Creates an instance of this client using the provided credentials
|
|
105
|
+
info.
|
|
106
|
+
|
|
107
|
+
Args:
|
|
108
|
+
info (dict): The service account private key info.
|
|
109
|
+
args: Additional arguments to pass to the constructor.
|
|
110
|
+
kwargs: Additional arguments to pass to the constructor.
|
|
111
|
+
|
|
112
|
+
Returns:
|
|
113
|
+
ModelArmorAsyncClient: The constructed client.
|
|
114
|
+
"""
|
|
115
|
+
return ModelArmorClient.from_service_account_info.__func__(ModelArmorAsyncClient, info, *args, **kwargs) # type: ignore
|
|
116
|
+
|
|
117
|
+
@classmethod
|
|
118
|
+
def from_service_account_file(cls, filename: str, *args, **kwargs):
|
|
119
|
+
"""Creates an instance of this client using the provided credentials
|
|
120
|
+
file.
|
|
121
|
+
|
|
122
|
+
Args:
|
|
123
|
+
filename (str): The path to the service account private key json
|
|
124
|
+
file.
|
|
125
|
+
args: Additional arguments to pass to the constructor.
|
|
126
|
+
kwargs: Additional arguments to pass to the constructor.
|
|
127
|
+
|
|
128
|
+
Returns:
|
|
129
|
+
ModelArmorAsyncClient: The constructed client.
|
|
130
|
+
"""
|
|
131
|
+
return ModelArmorClient.from_service_account_file.__func__(ModelArmorAsyncClient, filename, *args, **kwargs) # type: ignore
|
|
132
|
+
|
|
133
|
+
from_service_account_json = from_service_account_file
|
|
134
|
+
|
|
135
|
+
@classmethod
|
|
136
|
+
def get_mtls_endpoint_and_cert_source(
|
|
137
|
+
cls, client_options: Optional[ClientOptions] = None
|
|
138
|
+
):
|
|
139
|
+
"""Return the API endpoint and client cert source for mutual TLS.
|
|
140
|
+
|
|
141
|
+
The client cert source is determined in the following order:
|
|
142
|
+
(1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the
|
|
143
|
+
client cert source is None.
|
|
144
|
+
(2) if `client_options.client_cert_source` is provided, use the provided one; if the
|
|
145
|
+
default client cert source exists, use the default one; otherwise the client cert
|
|
146
|
+
source is None.
|
|
147
|
+
|
|
148
|
+
The API endpoint is determined in the following order:
|
|
149
|
+
(1) if `client_options.api_endpoint` if provided, use the provided one.
|
|
150
|
+
(2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the
|
|
151
|
+
default mTLS endpoint; if the environment variable is "never", use the default API
|
|
152
|
+
endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
|
|
153
|
+
use the default API endpoint.
|
|
154
|
+
|
|
155
|
+
More details can be found at https://google.aip.dev/auth/4114.
|
|
156
|
+
|
|
157
|
+
Args:
|
|
158
|
+
client_options (google.api_core.client_options.ClientOptions): Custom options for the
|
|
159
|
+
client. Only the `api_endpoint` and `client_cert_source` properties may be used
|
|
160
|
+
in this method.
|
|
161
|
+
|
|
162
|
+
Returns:
|
|
163
|
+
Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the
|
|
164
|
+
client cert source to use.
|
|
165
|
+
|
|
166
|
+
Raises:
|
|
167
|
+
google.auth.exceptions.MutualTLSChannelError: If any errors happen.
|
|
168
|
+
"""
|
|
169
|
+
return ModelArmorClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore
|
|
170
|
+
|
|
171
|
+
@property
|
|
172
|
+
def transport(self) -> ModelArmorTransport:
|
|
173
|
+
"""Returns the transport used by the client instance.
|
|
174
|
+
|
|
175
|
+
Returns:
|
|
176
|
+
ModelArmorTransport: The transport used by the client instance.
|
|
177
|
+
"""
|
|
178
|
+
return self._client.transport
|
|
179
|
+
|
|
180
|
+
@property
|
|
181
|
+
def api_endpoint(self):
|
|
182
|
+
"""Return the API endpoint used by the client instance.
|
|
183
|
+
|
|
184
|
+
Returns:
|
|
185
|
+
str: The API endpoint used by the client instance.
|
|
186
|
+
"""
|
|
187
|
+
return self._client._api_endpoint
|
|
188
|
+
|
|
189
|
+
@property
|
|
190
|
+
def universe_domain(self) -> str:
|
|
191
|
+
"""Return the universe domain used by the client instance.
|
|
192
|
+
|
|
193
|
+
Returns:
|
|
194
|
+
str: The universe domain used
|
|
195
|
+
by the client instance.
|
|
196
|
+
"""
|
|
197
|
+
return self._client._universe_domain
|
|
198
|
+
|
|
199
|
+
get_transport_class = ModelArmorClient.get_transport_class
|
|
200
|
+
|
|
201
|
+
def __init__(
|
|
202
|
+
self,
|
|
203
|
+
*,
|
|
204
|
+
credentials: Optional[ga_credentials.Credentials] = None,
|
|
205
|
+
transport: Optional[
|
|
206
|
+
Union[str, ModelArmorTransport, Callable[..., ModelArmorTransport]]
|
|
207
|
+
] = "grpc_asyncio",
|
|
208
|
+
client_options: Optional[ClientOptions] = None,
|
|
209
|
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
|
210
|
+
) -> None:
|
|
211
|
+
"""Instantiates the model armor async client.
|
|
212
|
+
|
|
213
|
+
Args:
|
|
214
|
+
credentials (Optional[google.auth.credentials.Credentials]): The
|
|
215
|
+
authorization credentials to attach to requests. These
|
|
216
|
+
credentials identify the application to the service; if none
|
|
217
|
+
are specified, the client will attempt to ascertain the
|
|
218
|
+
credentials from the environment.
|
|
219
|
+
transport (Optional[Union[str,ModelArmorTransport,Callable[..., ModelArmorTransport]]]):
|
|
220
|
+
The transport to use, or a Callable that constructs and returns a new transport to use.
|
|
221
|
+
If a Callable is given, it will be called with the same set of initialization
|
|
222
|
+
arguments as used in the ModelArmorTransport constructor.
|
|
223
|
+
If set to None, a transport is chosen automatically.
|
|
224
|
+
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
|
|
225
|
+
Custom options for the client.
|
|
226
|
+
|
|
227
|
+
1. The ``api_endpoint`` property can be used to override the
|
|
228
|
+
default endpoint provided by the client when ``transport`` is
|
|
229
|
+
not explicitly provided. Only if this property is not set and
|
|
230
|
+
``transport`` was not explicitly provided, the endpoint is
|
|
231
|
+
determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
|
|
232
|
+
variable, which have one of the following values:
|
|
233
|
+
"always" (always use the default mTLS endpoint), "never" (always
|
|
234
|
+
use the default regular endpoint) and "auto" (auto-switch to the
|
|
235
|
+
default mTLS endpoint if client certificate is present; this is
|
|
236
|
+
the default value).
|
|
237
|
+
|
|
238
|
+
2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
|
|
239
|
+
is "true", then the ``client_cert_source`` property can be used
|
|
240
|
+
to provide a client certificate for mTLS transport. If
|
|
241
|
+
not provided, the default SSL client certificate will be used if
|
|
242
|
+
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
|
|
243
|
+
set, no client certificate will be used.
|
|
244
|
+
|
|
245
|
+
3. The ``universe_domain`` property can be used to override the
|
|
246
|
+
default "googleapis.com" universe. Note that ``api_endpoint``
|
|
247
|
+
property still takes precedence; and ``universe_domain`` is
|
|
248
|
+
currently not supported for mTLS.
|
|
249
|
+
|
|
250
|
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
|
251
|
+
The client info used to send a user-agent string along with
|
|
252
|
+
API requests. If ``None``, then default info will be used.
|
|
253
|
+
Generally, you only need to set this if you're developing
|
|
254
|
+
your own client library.
|
|
255
|
+
|
|
256
|
+
Raises:
|
|
257
|
+
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
|
|
258
|
+
creation failed for any reason.
|
|
259
|
+
"""
|
|
260
|
+
self._client = ModelArmorClient(
|
|
261
|
+
credentials=credentials,
|
|
262
|
+
transport=transport,
|
|
263
|
+
client_options=client_options,
|
|
264
|
+
client_info=client_info,
|
|
265
|
+
)
|
|
266
|
+
|
|
267
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
268
|
+
std_logging.DEBUG
|
|
269
|
+
): # pragma: NO COVER
|
|
270
|
+
_LOGGER.debug(
|
|
271
|
+
"Created client `google.cloud.modelarmor_v1.ModelArmorAsyncClient`.",
|
|
272
|
+
extra={
|
|
273
|
+
"serviceName": "google.cloud.modelarmor.v1.ModelArmor",
|
|
274
|
+
"universeDomain": getattr(
|
|
275
|
+
self._client._transport._credentials, "universe_domain", ""
|
|
276
|
+
),
|
|
277
|
+
"credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}",
|
|
278
|
+
"credentialsInfo": getattr(
|
|
279
|
+
self.transport._credentials, "get_cred_info", lambda: None
|
|
280
|
+
)(),
|
|
281
|
+
}
|
|
282
|
+
if hasattr(self._client._transport, "_credentials")
|
|
283
|
+
else {
|
|
284
|
+
"serviceName": "google.cloud.modelarmor.v1.ModelArmor",
|
|
285
|
+
"credentialsType": None,
|
|
286
|
+
},
|
|
287
|
+
)
|
|
288
|
+
|
|
289
|
+
async def list_templates(
|
|
290
|
+
self,
|
|
291
|
+
request: Optional[Union[service.ListTemplatesRequest, dict]] = None,
|
|
292
|
+
*,
|
|
293
|
+
parent: Optional[str] = None,
|
|
294
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
295
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
296
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
297
|
+
) -> pagers.ListTemplatesAsyncPager:
|
|
298
|
+
r"""Lists Templates in a given project and location.
|
|
299
|
+
|
|
300
|
+
.. code-block:: python
|
|
301
|
+
|
|
302
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
303
|
+
# code template only.
|
|
304
|
+
# It will require modifications to work:
|
|
305
|
+
# - It may require correct/in-range values for request initialization.
|
|
306
|
+
# - It may require specifying regional endpoints when creating the service
|
|
307
|
+
# client as shown in:
|
|
308
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
309
|
+
from google.cloud import modelarmor_v1
|
|
310
|
+
|
|
311
|
+
async def sample_list_templates():
|
|
312
|
+
# Create a client
|
|
313
|
+
client = modelarmor_v1.ModelArmorAsyncClient()
|
|
314
|
+
|
|
315
|
+
# Initialize request argument(s)
|
|
316
|
+
request = modelarmor_v1.ListTemplatesRequest(
|
|
317
|
+
parent="parent_value",
|
|
318
|
+
)
|
|
319
|
+
|
|
320
|
+
# Make the request
|
|
321
|
+
page_result = client.list_templates(request=request)
|
|
322
|
+
|
|
323
|
+
# Handle the response
|
|
324
|
+
async for response in page_result:
|
|
325
|
+
print(response)
|
|
326
|
+
|
|
327
|
+
Args:
|
|
328
|
+
request (Optional[Union[google.cloud.modelarmor_v1.types.ListTemplatesRequest, dict]]):
|
|
329
|
+
The request object. Message for requesting list of
|
|
330
|
+
Templates
|
|
331
|
+
parent (:class:`str`):
|
|
332
|
+
Required. Parent value for
|
|
333
|
+
ListTemplatesRequest
|
|
334
|
+
|
|
335
|
+
This corresponds to the ``parent`` field
|
|
336
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
337
|
+
should not be set.
|
|
338
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
339
|
+
should be retried.
|
|
340
|
+
timeout (float): The timeout for this request.
|
|
341
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
342
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
343
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
344
|
+
be of type `bytes`.
|
|
345
|
+
|
|
346
|
+
Returns:
|
|
347
|
+
google.cloud.modelarmor_v1.services.model_armor.pagers.ListTemplatesAsyncPager:
|
|
348
|
+
Message for response to listing
|
|
349
|
+
Templates
|
|
350
|
+
Iterating over this object will yield
|
|
351
|
+
results and resolve additional pages
|
|
352
|
+
automatically.
|
|
353
|
+
|
|
354
|
+
"""
|
|
355
|
+
# Create or coerce a protobuf request object.
|
|
356
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
357
|
+
# gotten any keyword arguments that map to the request.
|
|
358
|
+
has_flattened_params = any([parent])
|
|
359
|
+
if request is not None and has_flattened_params:
|
|
360
|
+
raise ValueError(
|
|
361
|
+
"If the `request` argument is set, then none of "
|
|
362
|
+
"the individual field arguments should be set."
|
|
363
|
+
)
|
|
364
|
+
|
|
365
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
366
|
+
# there are no flattened fields), or create one.
|
|
367
|
+
if not isinstance(request, service.ListTemplatesRequest):
|
|
368
|
+
request = service.ListTemplatesRequest(request)
|
|
369
|
+
|
|
370
|
+
# If we have keyword arguments corresponding to fields on the
|
|
371
|
+
# request, apply these.
|
|
372
|
+
if parent is not None:
|
|
373
|
+
request.parent = parent
|
|
374
|
+
|
|
375
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
376
|
+
# and friendly error handling.
|
|
377
|
+
rpc = self._client._transport._wrapped_methods[
|
|
378
|
+
self._client._transport.list_templates
|
|
379
|
+
]
|
|
380
|
+
|
|
381
|
+
# Certain fields should be provided within the metadata header;
|
|
382
|
+
# add these here.
|
|
383
|
+
metadata = tuple(metadata) + (
|
|
384
|
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
|
385
|
+
)
|
|
386
|
+
|
|
387
|
+
# Validate the universe domain.
|
|
388
|
+
self._client._validate_universe_domain()
|
|
389
|
+
|
|
390
|
+
# Send the request.
|
|
391
|
+
response = await rpc(
|
|
392
|
+
request,
|
|
393
|
+
retry=retry,
|
|
394
|
+
timeout=timeout,
|
|
395
|
+
metadata=metadata,
|
|
396
|
+
)
|
|
397
|
+
|
|
398
|
+
# This method is paged; wrap the response in a pager, which provides
|
|
399
|
+
# an `__aiter__` convenience method.
|
|
400
|
+
response = pagers.ListTemplatesAsyncPager(
|
|
401
|
+
method=rpc,
|
|
402
|
+
request=request,
|
|
403
|
+
response=response,
|
|
404
|
+
retry=retry,
|
|
405
|
+
timeout=timeout,
|
|
406
|
+
metadata=metadata,
|
|
407
|
+
)
|
|
408
|
+
|
|
409
|
+
# Done; return the response.
|
|
410
|
+
return response
|
|
411
|
+
|
|
412
|
+
async def get_template(
|
|
413
|
+
self,
|
|
414
|
+
request: Optional[Union[service.GetTemplateRequest, dict]] = None,
|
|
415
|
+
*,
|
|
416
|
+
name: Optional[str] = None,
|
|
417
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
418
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
419
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
420
|
+
) -> service.Template:
|
|
421
|
+
r"""Gets details of a single Template.
|
|
422
|
+
|
|
423
|
+
.. code-block:: python
|
|
424
|
+
|
|
425
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
426
|
+
# code template only.
|
|
427
|
+
# It will require modifications to work:
|
|
428
|
+
# - It may require correct/in-range values for request initialization.
|
|
429
|
+
# - It may require specifying regional endpoints when creating the service
|
|
430
|
+
# client as shown in:
|
|
431
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
432
|
+
from google.cloud import modelarmor_v1
|
|
433
|
+
|
|
434
|
+
async def sample_get_template():
|
|
435
|
+
# Create a client
|
|
436
|
+
client = modelarmor_v1.ModelArmorAsyncClient()
|
|
437
|
+
|
|
438
|
+
# Initialize request argument(s)
|
|
439
|
+
request = modelarmor_v1.GetTemplateRequest(
|
|
440
|
+
name="name_value",
|
|
441
|
+
)
|
|
442
|
+
|
|
443
|
+
# Make the request
|
|
444
|
+
response = await client.get_template(request=request)
|
|
445
|
+
|
|
446
|
+
# Handle the response
|
|
447
|
+
print(response)
|
|
448
|
+
|
|
449
|
+
Args:
|
|
450
|
+
request (Optional[Union[google.cloud.modelarmor_v1.types.GetTemplateRequest, dict]]):
|
|
451
|
+
The request object. Message for getting a Template
|
|
452
|
+
name (:class:`str`):
|
|
453
|
+
Required. Name of the resource
|
|
454
|
+
This corresponds to the ``name`` field
|
|
455
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
456
|
+
should not be set.
|
|
457
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
458
|
+
should be retried.
|
|
459
|
+
timeout (float): The timeout for this request.
|
|
460
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
461
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
462
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
463
|
+
be of type `bytes`.
|
|
464
|
+
|
|
465
|
+
Returns:
|
|
466
|
+
google.cloud.modelarmor_v1.types.Template:
|
|
467
|
+
Message describing Template resource
|
|
468
|
+
"""
|
|
469
|
+
# Create or coerce a protobuf request object.
|
|
470
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
471
|
+
# gotten any keyword arguments that map to the request.
|
|
472
|
+
has_flattened_params = any([name])
|
|
473
|
+
if request is not None and has_flattened_params:
|
|
474
|
+
raise ValueError(
|
|
475
|
+
"If the `request` argument is set, then none of "
|
|
476
|
+
"the individual field arguments should be set."
|
|
477
|
+
)
|
|
478
|
+
|
|
479
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
480
|
+
# there are no flattened fields), or create one.
|
|
481
|
+
if not isinstance(request, service.GetTemplateRequest):
|
|
482
|
+
request = service.GetTemplateRequest(request)
|
|
483
|
+
|
|
484
|
+
# If we have keyword arguments corresponding to fields on the
|
|
485
|
+
# request, apply these.
|
|
486
|
+
if name is not None:
|
|
487
|
+
request.name = name
|
|
488
|
+
|
|
489
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
490
|
+
# and friendly error handling.
|
|
491
|
+
rpc = self._client._transport._wrapped_methods[
|
|
492
|
+
self._client._transport.get_template
|
|
493
|
+
]
|
|
494
|
+
|
|
495
|
+
# Certain fields should be provided within the metadata header;
|
|
496
|
+
# add these here.
|
|
497
|
+
metadata = tuple(metadata) + (
|
|
498
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
499
|
+
)
|
|
500
|
+
|
|
501
|
+
# Validate the universe domain.
|
|
502
|
+
self._client._validate_universe_domain()
|
|
503
|
+
|
|
504
|
+
# Send the request.
|
|
505
|
+
response = await rpc(
|
|
506
|
+
request,
|
|
507
|
+
retry=retry,
|
|
508
|
+
timeout=timeout,
|
|
509
|
+
metadata=metadata,
|
|
510
|
+
)
|
|
511
|
+
|
|
512
|
+
# Done; return the response.
|
|
513
|
+
return response
|
|
514
|
+
|
|
515
|
+
async def create_template(
|
|
516
|
+
self,
|
|
517
|
+
request: Optional[Union[service.CreateTemplateRequest, dict]] = None,
|
|
518
|
+
*,
|
|
519
|
+
parent: Optional[str] = None,
|
|
520
|
+
template: Optional[service.Template] = None,
|
|
521
|
+
template_id: Optional[str] = None,
|
|
522
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
523
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
524
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
525
|
+
) -> service.Template:
|
|
526
|
+
r"""Creates a new Template in a given project and
|
|
527
|
+
location.
|
|
528
|
+
|
|
529
|
+
.. code-block:: python
|
|
530
|
+
|
|
531
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
532
|
+
# code template only.
|
|
533
|
+
# It will require modifications to work:
|
|
534
|
+
# - It may require correct/in-range values for request initialization.
|
|
535
|
+
# - It may require specifying regional endpoints when creating the service
|
|
536
|
+
# client as shown in:
|
|
537
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
538
|
+
from google.cloud import modelarmor_v1
|
|
539
|
+
|
|
540
|
+
async def sample_create_template():
|
|
541
|
+
# Create a client
|
|
542
|
+
client = modelarmor_v1.ModelArmorAsyncClient()
|
|
543
|
+
|
|
544
|
+
# Initialize request argument(s)
|
|
545
|
+
request = modelarmor_v1.CreateTemplateRequest(
|
|
546
|
+
parent="parent_value",
|
|
547
|
+
template_id="template_id_value",
|
|
548
|
+
)
|
|
549
|
+
|
|
550
|
+
# Make the request
|
|
551
|
+
response = await client.create_template(request=request)
|
|
552
|
+
|
|
553
|
+
# Handle the response
|
|
554
|
+
print(response)
|
|
555
|
+
|
|
556
|
+
Args:
|
|
557
|
+
request (Optional[Union[google.cloud.modelarmor_v1.types.CreateTemplateRequest, dict]]):
|
|
558
|
+
The request object. Message for creating a Template
|
|
559
|
+
parent (:class:`str`):
|
|
560
|
+
Required. Value for parent.
|
|
561
|
+
This corresponds to the ``parent`` field
|
|
562
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
563
|
+
should not be set.
|
|
564
|
+
template (:class:`google.cloud.modelarmor_v1.types.Template`):
|
|
565
|
+
Required. The resource being created
|
|
566
|
+
This corresponds to the ``template`` field
|
|
567
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
568
|
+
should not be set.
|
|
569
|
+
template_id (:class:`str`):
|
|
570
|
+
Required. Id of the requesting object If auto-generating
|
|
571
|
+
Id server-side, remove this field and template_id from
|
|
572
|
+
the method_signature of Create RPC
|
|
573
|
+
|
|
574
|
+
This corresponds to the ``template_id`` field
|
|
575
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
576
|
+
should not be set.
|
|
577
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
578
|
+
should be retried.
|
|
579
|
+
timeout (float): The timeout for this request.
|
|
580
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
581
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
582
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
583
|
+
be of type `bytes`.
|
|
584
|
+
|
|
585
|
+
Returns:
|
|
586
|
+
google.cloud.modelarmor_v1.types.Template:
|
|
587
|
+
Message describing Template resource
|
|
588
|
+
"""
|
|
589
|
+
# Create or coerce a protobuf request object.
|
|
590
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
591
|
+
# gotten any keyword arguments that map to the request.
|
|
592
|
+
has_flattened_params = any([parent, template, template_id])
|
|
593
|
+
if request is not None and has_flattened_params:
|
|
594
|
+
raise ValueError(
|
|
595
|
+
"If the `request` argument is set, then none of "
|
|
596
|
+
"the individual field arguments should be set."
|
|
597
|
+
)
|
|
598
|
+
|
|
599
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
600
|
+
# there are no flattened fields), or create one.
|
|
601
|
+
if not isinstance(request, service.CreateTemplateRequest):
|
|
602
|
+
request = service.CreateTemplateRequest(request)
|
|
603
|
+
|
|
604
|
+
# If we have keyword arguments corresponding to fields on the
|
|
605
|
+
# request, apply these.
|
|
606
|
+
if parent is not None:
|
|
607
|
+
request.parent = parent
|
|
608
|
+
if template is not None:
|
|
609
|
+
request.template = template
|
|
610
|
+
if template_id is not None:
|
|
611
|
+
request.template_id = template_id
|
|
612
|
+
|
|
613
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
614
|
+
# and friendly error handling.
|
|
615
|
+
rpc = self._client._transport._wrapped_methods[
|
|
616
|
+
self._client._transport.create_template
|
|
617
|
+
]
|
|
618
|
+
|
|
619
|
+
# Certain fields should be provided within the metadata header;
|
|
620
|
+
# add these here.
|
|
621
|
+
metadata = tuple(metadata) + (
|
|
622
|
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
|
623
|
+
)
|
|
624
|
+
|
|
625
|
+
# Validate the universe domain.
|
|
626
|
+
self._client._validate_universe_domain()
|
|
627
|
+
|
|
628
|
+
# Send the request.
|
|
629
|
+
response = await rpc(
|
|
630
|
+
request,
|
|
631
|
+
retry=retry,
|
|
632
|
+
timeout=timeout,
|
|
633
|
+
metadata=metadata,
|
|
634
|
+
)
|
|
635
|
+
|
|
636
|
+
# Done; return the response.
|
|
637
|
+
return response
|
|
638
|
+
|
|
639
|
+
async def update_template(
|
|
640
|
+
self,
|
|
641
|
+
request: Optional[Union[service.UpdateTemplateRequest, dict]] = None,
|
|
642
|
+
*,
|
|
643
|
+
template: Optional[service.Template] = None,
|
|
644
|
+
update_mask: Optional[field_mask_pb2.FieldMask] = None,
|
|
645
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
646
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
647
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
648
|
+
) -> service.Template:
|
|
649
|
+
r"""Updates the parameters of a single Template.
|
|
650
|
+
|
|
651
|
+
.. code-block:: python
|
|
652
|
+
|
|
653
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
654
|
+
# code template only.
|
|
655
|
+
# It will require modifications to work:
|
|
656
|
+
# - It may require correct/in-range values for request initialization.
|
|
657
|
+
# - It may require specifying regional endpoints when creating the service
|
|
658
|
+
# client as shown in:
|
|
659
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
660
|
+
from google.cloud import modelarmor_v1
|
|
661
|
+
|
|
662
|
+
async def sample_update_template():
|
|
663
|
+
# Create a client
|
|
664
|
+
client = modelarmor_v1.ModelArmorAsyncClient()
|
|
665
|
+
|
|
666
|
+
# Initialize request argument(s)
|
|
667
|
+
request = modelarmor_v1.UpdateTemplateRequest(
|
|
668
|
+
)
|
|
669
|
+
|
|
670
|
+
# Make the request
|
|
671
|
+
response = await client.update_template(request=request)
|
|
672
|
+
|
|
673
|
+
# Handle the response
|
|
674
|
+
print(response)
|
|
675
|
+
|
|
676
|
+
Args:
|
|
677
|
+
request (Optional[Union[google.cloud.modelarmor_v1.types.UpdateTemplateRequest, dict]]):
|
|
678
|
+
The request object. Message for updating a Template
|
|
679
|
+
template (:class:`google.cloud.modelarmor_v1.types.Template`):
|
|
680
|
+
Required. The resource being updated
|
|
681
|
+
This corresponds to the ``template`` field
|
|
682
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
683
|
+
should not be set.
|
|
684
|
+
update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
|
|
685
|
+
Required. Field mask is used to specify the fields to be
|
|
686
|
+
overwritten in the Template resource by the update. The
|
|
687
|
+
fields specified in the update_mask are relative to the
|
|
688
|
+
resource, not the full request. A field will be
|
|
689
|
+
overwritten if it is in the mask. If the user does not
|
|
690
|
+
provide a mask then all fields will be overwritten.
|
|
691
|
+
|
|
692
|
+
This corresponds to the ``update_mask`` field
|
|
693
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
694
|
+
should not be set.
|
|
695
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
696
|
+
should be retried.
|
|
697
|
+
timeout (float): The timeout for this request.
|
|
698
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
699
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
700
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
701
|
+
be of type `bytes`.
|
|
702
|
+
|
|
703
|
+
Returns:
|
|
704
|
+
google.cloud.modelarmor_v1.types.Template:
|
|
705
|
+
Message describing Template resource
|
|
706
|
+
"""
|
|
707
|
+
# Create or coerce a protobuf request object.
|
|
708
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
709
|
+
# gotten any keyword arguments that map to the request.
|
|
710
|
+
has_flattened_params = any([template, update_mask])
|
|
711
|
+
if request is not None and has_flattened_params:
|
|
712
|
+
raise ValueError(
|
|
713
|
+
"If the `request` argument is set, then none of "
|
|
714
|
+
"the individual field arguments should be set."
|
|
715
|
+
)
|
|
716
|
+
|
|
717
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
718
|
+
# there are no flattened fields), or create one.
|
|
719
|
+
if not isinstance(request, service.UpdateTemplateRequest):
|
|
720
|
+
request = service.UpdateTemplateRequest(request)
|
|
721
|
+
|
|
722
|
+
# If we have keyword arguments corresponding to fields on the
|
|
723
|
+
# request, apply these.
|
|
724
|
+
if template is not None:
|
|
725
|
+
request.template = template
|
|
726
|
+
if update_mask is not None:
|
|
727
|
+
request.update_mask = update_mask
|
|
728
|
+
|
|
729
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
730
|
+
# and friendly error handling.
|
|
731
|
+
rpc = self._client._transport._wrapped_methods[
|
|
732
|
+
self._client._transport.update_template
|
|
733
|
+
]
|
|
734
|
+
|
|
735
|
+
# Certain fields should be provided within the metadata header;
|
|
736
|
+
# add these here.
|
|
737
|
+
metadata = tuple(metadata) + (
|
|
738
|
+
gapic_v1.routing_header.to_grpc_metadata(
|
|
739
|
+
(("template.name", request.template.name),)
|
|
740
|
+
),
|
|
741
|
+
)
|
|
742
|
+
|
|
743
|
+
# Validate the universe domain.
|
|
744
|
+
self._client._validate_universe_domain()
|
|
745
|
+
|
|
746
|
+
# Send the request.
|
|
747
|
+
response = await rpc(
|
|
748
|
+
request,
|
|
749
|
+
retry=retry,
|
|
750
|
+
timeout=timeout,
|
|
751
|
+
metadata=metadata,
|
|
752
|
+
)
|
|
753
|
+
|
|
754
|
+
# Done; return the response.
|
|
755
|
+
return response
|
|
756
|
+
|
|
757
|
+
async def delete_template(
|
|
758
|
+
self,
|
|
759
|
+
request: Optional[Union[service.DeleteTemplateRequest, dict]] = None,
|
|
760
|
+
*,
|
|
761
|
+
name: Optional[str] = None,
|
|
762
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
763
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
764
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
765
|
+
) -> None:
|
|
766
|
+
r"""Deletes a single Template.
|
|
767
|
+
|
|
768
|
+
.. code-block:: python
|
|
769
|
+
|
|
770
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
771
|
+
# code template only.
|
|
772
|
+
# It will require modifications to work:
|
|
773
|
+
# - It may require correct/in-range values for request initialization.
|
|
774
|
+
# - It may require specifying regional endpoints when creating the service
|
|
775
|
+
# client as shown in:
|
|
776
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
777
|
+
from google.cloud import modelarmor_v1
|
|
778
|
+
|
|
779
|
+
async def sample_delete_template():
|
|
780
|
+
# Create a client
|
|
781
|
+
client = modelarmor_v1.ModelArmorAsyncClient()
|
|
782
|
+
|
|
783
|
+
# Initialize request argument(s)
|
|
784
|
+
request = modelarmor_v1.DeleteTemplateRequest(
|
|
785
|
+
name="name_value",
|
|
786
|
+
)
|
|
787
|
+
|
|
788
|
+
# Make the request
|
|
789
|
+
await client.delete_template(request=request)
|
|
790
|
+
|
|
791
|
+
Args:
|
|
792
|
+
request (Optional[Union[google.cloud.modelarmor_v1.types.DeleteTemplateRequest, dict]]):
|
|
793
|
+
The request object. Message for deleting a Template
|
|
794
|
+
name (:class:`str`):
|
|
795
|
+
Required. Name of the resource
|
|
796
|
+
This corresponds to the ``name`` field
|
|
797
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
798
|
+
should not be set.
|
|
799
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
800
|
+
should be retried.
|
|
801
|
+
timeout (float): The timeout for this request.
|
|
802
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
803
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
804
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
805
|
+
be of type `bytes`.
|
|
806
|
+
"""
|
|
807
|
+
# Create or coerce a protobuf request object.
|
|
808
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
809
|
+
# gotten any keyword arguments that map to the request.
|
|
810
|
+
has_flattened_params = any([name])
|
|
811
|
+
if request is not None and has_flattened_params:
|
|
812
|
+
raise ValueError(
|
|
813
|
+
"If the `request` argument is set, then none of "
|
|
814
|
+
"the individual field arguments should be set."
|
|
815
|
+
)
|
|
816
|
+
|
|
817
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
818
|
+
# there are no flattened fields), or create one.
|
|
819
|
+
if not isinstance(request, service.DeleteTemplateRequest):
|
|
820
|
+
request = service.DeleteTemplateRequest(request)
|
|
821
|
+
|
|
822
|
+
# If we have keyword arguments corresponding to fields on the
|
|
823
|
+
# request, apply these.
|
|
824
|
+
if name is not None:
|
|
825
|
+
request.name = name
|
|
826
|
+
|
|
827
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
828
|
+
# and friendly error handling.
|
|
829
|
+
rpc = self._client._transport._wrapped_methods[
|
|
830
|
+
self._client._transport.delete_template
|
|
831
|
+
]
|
|
832
|
+
|
|
833
|
+
# Certain fields should be provided within the metadata header;
|
|
834
|
+
# add these here.
|
|
835
|
+
metadata = tuple(metadata) + (
|
|
836
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
837
|
+
)
|
|
838
|
+
|
|
839
|
+
# Validate the universe domain.
|
|
840
|
+
self._client._validate_universe_domain()
|
|
841
|
+
|
|
842
|
+
# Send the request.
|
|
843
|
+
await rpc(
|
|
844
|
+
request,
|
|
845
|
+
retry=retry,
|
|
846
|
+
timeout=timeout,
|
|
847
|
+
metadata=metadata,
|
|
848
|
+
)
|
|
849
|
+
|
|
850
|
+
async def get_floor_setting(
|
|
851
|
+
self,
|
|
852
|
+
request: Optional[Union[service.GetFloorSettingRequest, dict]] = None,
|
|
853
|
+
*,
|
|
854
|
+
name: Optional[str] = None,
|
|
855
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
856
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
857
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
858
|
+
) -> service.FloorSetting:
|
|
859
|
+
r"""Gets details of a single floor setting of a project
|
|
860
|
+
|
|
861
|
+
.. code-block:: python
|
|
862
|
+
|
|
863
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
864
|
+
# code template only.
|
|
865
|
+
# It will require modifications to work:
|
|
866
|
+
# - It may require correct/in-range values for request initialization.
|
|
867
|
+
# - It may require specifying regional endpoints when creating the service
|
|
868
|
+
# client as shown in:
|
|
869
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
870
|
+
from google.cloud import modelarmor_v1
|
|
871
|
+
|
|
872
|
+
async def sample_get_floor_setting():
|
|
873
|
+
# Create a client
|
|
874
|
+
client = modelarmor_v1.ModelArmorAsyncClient()
|
|
875
|
+
|
|
876
|
+
# Initialize request argument(s)
|
|
877
|
+
request = modelarmor_v1.GetFloorSettingRequest(
|
|
878
|
+
name="name_value",
|
|
879
|
+
)
|
|
880
|
+
|
|
881
|
+
# Make the request
|
|
882
|
+
response = await client.get_floor_setting(request=request)
|
|
883
|
+
|
|
884
|
+
# Handle the response
|
|
885
|
+
print(response)
|
|
886
|
+
|
|
887
|
+
Args:
|
|
888
|
+
request (Optional[Union[google.cloud.modelarmor_v1.types.GetFloorSettingRequest, dict]]):
|
|
889
|
+
The request object. Message for getting a Floor Setting
|
|
890
|
+
name (:class:`str`):
|
|
891
|
+
Required. The name of the floor
|
|
892
|
+
setting to get, example
|
|
893
|
+
projects/123/floorsetting.
|
|
894
|
+
|
|
895
|
+
This corresponds to the ``name`` field
|
|
896
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
897
|
+
should not be set.
|
|
898
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
899
|
+
should be retried.
|
|
900
|
+
timeout (float): The timeout for this request.
|
|
901
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
902
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
903
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
904
|
+
be of type `bytes`.
|
|
905
|
+
|
|
906
|
+
Returns:
|
|
907
|
+
google.cloud.modelarmor_v1.types.FloorSetting:
|
|
908
|
+
Message describing FloorSetting
|
|
909
|
+
resource
|
|
910
|
+
|
|
911
|
+
"""
|
|
912
|
+
# Create or coerce a protobuf request object.
|
|
913
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
914
|
+
# gotten any keyword arguments that map to the request.
|
|
915
|
+
has_flattened_params = any([name])
|
|
916
|
+
if request is not None and has_flattened_params:
|
|
917
|
+
raise ValueError(
|
|
918
|
+
"If the `request` argument is set, then none of "
|
|
919
|
+
"the individual field arguments should be set."
|
|
920
|
+
)
|
|
921
|
+
|
|
922
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
923
|
+
# there are no flattened fields), or create one.
|
|
924
|
+
if not isinstance(request, service.GetFloorSettingRequest):
|
|
925
|
+
request = service.GetFloorSettingRequest(request)
|
|
926
|
+
|
|
927
|
+
# If we have keyword arguments corresponding to fields on the
|
|
928
|
+
# request, apply these.
|
|
929
|
+
if name is not None:
|
|
930
|
+
request.name = name
|
|
931
|
+
|
|
932
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
933
|
+
# and friendly error handling.
|
|
934
|
+
rpc = self._client._transport._wrapped_methods[
|
|
935
|
+
self._client._transport.get_floor_setting
|
|
936
|
+
]
|
|
937
|
+
|
|
938
|
+
# Certain fields should be provided within the metadata header;
|
|
939
|
+
# add these here.
|
|
940
|
+
metadata = tuple(metadata) + (
|
|
941
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
942
|
+
)
|
|
943
|
+
|
|
944
|
+
# Validate the universe domain.
|
|
945
|
+
self._client._validate_universe_domain()
|
|
946
|
+
|
|
947
|
+
# Send the request.
|
|
948
|
+
response = await rpc(
|
|
949
|
+
request,
|
|
950
|
+
retry=retry,
|
|
951
|
+
timeout=timeout,
|
|
952
|
+
metadata=metadata,
|
|
953
|
+
)
|
|
954
|
+
|
|
955
|
+
# Done; return the response.
|
|
956
|
+
return response
|
|
957
|
+
|
|
958
|
+
async def update_floor_setting(
|
|
959
|
+
self,
|
|
960
|
+
request: Optional[Union[service.UpdateFloorSettingRequest, dict]] = None,
|
|
961
|
+
*,
|
|
962
|
+
floor_setting: Optional[service.FloorSetting] = None,
|
|
963
|
+
update_mask: Optional[field_mask_pb2.FieldMask] = None,
|
|
964
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
965
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
966
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
967
|
+
) -> service.FloorSetting:
|
|
968
|
+
r"""Updates the parameters of a single floor setting of a
|
|
969
|
+
project
|
|
970
|
+
|
|
971
|
+
.. code-block:: python
|
|
972
|
+
|
|
973
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
974
|
+
# code template only.
|
|
975
|
+
# It will require modifications to work:
|
|
976
|
+
# - It may require correct/in-range values for request initialization.
|
|
977
|
+
# - It may require specifying regional endpoints when creating the service
|
|
978
|
+
# client as shown in:
|
|
979
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
980
|
+
from google.cloud import modelarmor_v1
|
|
981
|
+
|
|
982
|
+
async def sample_update_floor_setting():
|
|
983
|
+
# Create a client
|
|
984
|
+
client = modelarmor_v1.ModelArmorAsyncClient()
|
|
985
|
+
|
|
986
|
+
# Initialize request argument(s)
|
|
987
|
+
request = modelarmor_v1.UpdateFloorSettingRequest(
|
|
988
|
+
)
|
|
989
|
+
|
|
990
|
+
# Make the request
|
|
991
|
+
response = await client.update_floor_setting(request=request)
|
|
992
|
+
|
|
993
|
+
# Handle the response
|
|
994
|
+
print(response)
|
|
995
|
+
|
|
996
|
+
Args:
|
|
997
|
+
request (Optional[Union[google.cloud.modelarmor_v1.types.UpdateFloorSettingRequest, dict]]):
|
|
998
|
+
The request object. Message for Updating a Floor Setting
|
|
999
|
+
floor_setting (:class:`google.cloud.modelarmor_v1.types.FloorSetting`):
|
|
1000
|
+
Required. The floor setting being
|
|
1001
|
+
updated.
|
|
1002
|
+
|
|
1003
|
+
This corresponds to the ``floor_setting`` field
|
|
1004
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1005
|
+
should not be set.
|
|
1006
|
+
update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
|
|
1007
|
+
Optional. Field mask is used to specify the fields to be
|
|
1008
|
+
overwritten in the FloorSetting resource by the update.
|
|
1009
|
+
The fields specified in the update_mask are relative to
|
|
1010
|
+
the resource, not the full request. A field will be
|
|
1011
|
+
overwritten if it is in the mask. If the user does not
|
|
1012
|
+
provide a mask then all fields will be overwritten.
|
|
1013
|
+
|
|
1014
|
+
This corresponds to the ``update_mask`` field
|
|
1015
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
1016
|
+
should not be set.
|
|
1017
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
1018
|
+
should be retried.
|
|
1019
|
+
timeout (float): The timeout for this request.
|
|
1020
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
1021
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
1022
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
1023
|
+
be of type `bytes`.
|
|
1024
|
+
|
|
1025
|
+
Returns:
|
|
1026
|
+
google.cloud.modelarmor_v1.types.FloorSetting:
|
|
1027
|
+
Message describing FloorSetting
|
|
1028
|
+
resource
|
|
1029
|
+
|
|
1030
|
+
"""
|
|
1031
|
+
# Create or coerce a protobuf request object.
|
|
1032
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
1033
|
+
# gotten any keyword arguments that map to the request.
|
|
1034
|
+
has_flattened_params = any([floor_setting, update_mask])
|
|
1035
|
+
if request is not None and has_flattened_params:
|
|
1036
|
+
raise ValueError(
|
|
1037
|
+
"If the `request` argument is set, then none of "
|
|
1038
|
+
"the individual field arguments should be set."
|
|
1039
|
+
)
|
|
1040
|
+
|
|
1041
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
1042
|
+
# there are no flattened fields), or create one.
|
|
1043
|
+
if not isinstance(request, service.UpdateFloorSettingRequest):
|
|
1044
|
+
request = service.UpdateFloorSettingRequest(request)
|
|
1045
|
+
|
|
1046
|
+
# If we have keyword arguments corresponding to fields on the
|
|
1047
|
+
# request, apply these.
|
|
1048
|
+
if floor_setting is not None:
|
|
1049
|
+
request.floor_setting = floor_setting
|
|
1050
|
+
if update_mask is not None:
|
|
1051
|
+
request.update_mask = update_mask
|
|
1052
|
+
|
|
1053
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
1054
|
+
# and friendly error handling.
|
|
1055
|
+
rpc = self._client._transport._wrapped_methods[
|
|
1056
|
+
self._client._transport.update_floor_setting
|
|
1057
|
+
]
|
|
1058
|
+
|
|
1059
|
+
# Certain fields should be provided within the metadata header;
|
|
1060
|
+
# add these here.
|
|
1061
|
+
metadata = tuple(metadata) + (
|
|
1062
|
+
gapic_v1.routing_header.to_grpc_metadata(
|
|
1063
|
+
(("floor_setting.name", request.floor_setting.name),)
|
|
1064
|
+
),
|
|
1065
|
+
)
|
|
1066
|
+
|
|
1067
|
+
# Validate the universe domain.
|
|
1068
|
+
self._client._validate_universe_domain()
|
|
1069
|
+
|
|
1070
|
+
# Send the request.
|
|
1071
|
+
response = await rpc(
|
|
1072
|
+
request,
|
|
1073
|
+
retry=retry,
|
|
1074
|
+
timeout=timeout,
|
|
1075
|
+
metadata=metadata,
|
|
1076
|
+
)
|
|
1077
|
+
|
|
1078
|
+
# Done; return the response.
|
|
1079
|
+
return response
|
|
1080
|
+
|
|
1081
|
+
async def sanitize_user_prompt(
|
|
1082
|
+
self,
|
|
1083
|
+
request: Optional[Union[service.SanitizeUserPromptRequest, dict]] = None,
|
|
1084
|
+
*,
|
|
1085
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1086
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
1087
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
1088
|
+
) -> service.SanitizeUserPromptResponse:
|
|
1089
|
+
r"""Sanitizes User Prompt.
|
|
1090
|
+
|
|
1091
|
+
.. code-block:: python
|
|
1092
|
+
|
|
1093
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
1094
|
+
# code template only.
|
|
1095
|
+
# It will require modifications to work:
|
|
1096
|
+
# - It may require correct/in-range values for request initialization.
|
|
1097
|
+
# - It may require specifying regional endpoints when creating the service
|
|
1098
|
+
# client as shown in:
|
|
1099
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
1100
|
+
from google.cloud import modelarmor_v1
|
|
1101
|
+
|
|
1102
|
+
async def sample_sanitize_user_prompt():
|
|
1103
|
+
# Create a client
|
|
1104
|
+
client = modelarmor_v1.ModelArmorAsyncClient()
|
|
1105
|
+
|
|
1106
|
+
# Initialize request argument(s)
|
|
1107
|
+
user_prompt_data = modelarmor_v1.DataItem()
|
|
1108
|
+
user_prompt_data.text = "text_value"
|
|
1109
|
+
|
|
1110
|
+
request = modelarmor_v1.SanitizeUserPromptRequest(
|
|
1111
|
+
name="name_value",
|
|
1112
|
+
user_prompt_data=user_prompt_data,
|
|
1113
|
+
)
|
|
1114
|
+
|
|
1115
|
+
# Make the request
|
|
1116
|
+
response = await client.sanitize_user_prompt(request=request)
|
|
1117
|
+
|
|
1118
|
+
# Handle the response
|
|
1119
|
+
print(response)
|
|
1120
|
+
|
|
1121
|
+
Args:
|
|
1122
|
+
request (Optional[Union[google.cloud.modelarmor_v1.types.SanitizeUserPromptRequest, dict]]):
|
|
1123
|
+
The request object. Sanitize User Prompt request.
|
|
1124
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
1125
|
+
should be retried.
|
|
1126
|
+
timeout (float): The timeout for this request.
|
|
1127
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
1128
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
1129
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
1130
|
+
be of type `bytes`.
|
|
1131
|
+
|
|
1132
|
+
Returns:
|
|
1133
|
+
google.cloud.modelarmor_v1.types.SanitizeUserPromptResponse:
|
|
1134
|
+
Sanitized User Prompt Response.
|
|
1135
|
+
"""
|
|
1136
|
+
# Create or coerce a protobuf request object.
|
|
1137
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
1138
|
+
# there are no flattened fields), or create one.
|
|
1139
|
+
if not isinstance(request, service.SanitizeUserPromptRequest):
|
|
1140
|
+
request = service.SanitizeUserPromptRequest(request)
|
|
1141
|
+
|
|
1142
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
1143
|
+
# and friendly error handling.
|
|
1144
|
+
rpc = self._client._transport._wrapped_methods[
|
|
1145
|
+
self._client._transport.sanitize_user_prompt
|
|
1146
|
+
]
|
|
1147
|
+
|
|
1148
|
+
# Certain fields should be provided within the metadata header;
|
|
1149
|
+
# add these here.
|
|
1150
|
+
metadata = tuple(metadata) + (
|
|
1151
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
1152
|
+
)
|
|
1153
|
+
|
|
1154
|
+
# Validate the universe domain.
|
|
1155
|
+
self._client._validate_universe_domain()
|
|
1156
|
+
|
|
1157
|
+
# Send the request.
|
|
1158
|
+
response = await rpc(
|
|
1159
|
+
request,
|
|
1160
|
+
retry=retry,
|
|
1161
|
+
timeout=timeout,
|
|
1162
|
+
metadata=metadata,
|
|
1163
|
+
)
|
|
1164
|
+
|
|
1165
|
+
# Done; return the response.
|
|
1166
|
+
return response
|
|
1167
|
+
|
|
1168
|
+
async def sanitize_model_response(
|
|
1169
|
+
self,
|
|
1170
|
+
request: Optional[Union[service.SanitizeModelResponseRequest, dict]] = None,
|
|
1171
|
+
*,
|
|
1172
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1173
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
1174
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
1175
|
+
) -> service.SanitizeModelResponseResponse:
|
|
1176
|
+
r"""Sanitizes Model Response.
|
|
1177
|
+
|
|
1178
|
+
.. code-block:: python
|
|
1179
|
+
|
|
1180
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
1181
|
+
# code template only.
|
|
1182
|
+
# It will require modifications to work:
|
|
1183
|
+
# - It may require correct/in-range values for request initialization.
|
|
1184
|
+
# - It may require specifying regional endpoints when creating the service
|
|
1185
|
+
# client as shown in:
|
|
1186
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
1187
|
+
from google.cloud import modelarmor_v1
|
|
1188
|
+
|
|
1189
|
+
async def sample_sanitize_model_response():
|
|
1190
|
+
# Create a client
|
|
1191
|
+
client = modelarmor_v1.ModelArmorAsyncClient()
|
|
1192
|
+
|
|
1193
|
+
# Initialize request argument(s)
|
|
1194
|
+
model_response_data = modelarmor_v1.DataItem()
|
|
1195
|
+
model_response_data.text = "text_value"
|
|
1196
|
+
|
|
1197
|
+
request = modelarmor_v1.SanitizeModelResponseRequest(
|
|
1198
|
+
name="name_value",
|
|
1199
|
+
model_response_data=model_response_data,
|
|
1200
|
+
)
|
|
1201
|
+
|
|
1202
|
+
# Make the request
|
|
1203
|
+
response = await client.sanitize_model_response(request=request)
|
|
1204
|
+
|
|
1205
|
+
# Handle the response
|
|
1206
|
+
print(response)
|
|
1207
|
+
|
|
1208
|
+
Args:
|
|
1209
|
+
request (Optional[Union[google.cloud.modelarmor_v1.types.SanitizeModelResponseRequest, dict]]):
|
|
1210
|
+
The request object. Sanitize Model Response request.
|
|
1211
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
1212
|
+
should be retried.
|
|
1213
|
+
timeout (float): The timeout for this request.
|
|
1214
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
1215
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
1216
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
1217
|
+
be of type `bytes`.
|
|
1218
|
+
|
|
1219
|
+
Returns:
|
|
1220
|
+
google.cloud.modelarmor_v1.types.SanitizeModelResponseResponse:
|
|
1221
|
+
Sanitized Model Response Response.
|
|
1222
|
+
"""
|
|
1223
|
+
# Create or coerce a protobuf request object.
|
|
1224
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
1225
|
+
# there are no flattened fields), or create one.
|
|
1226
|
+
if not isinstance(request, service.SanitizeModelResponseRequest):
|
|
1227
|
+
request = service.SanitizeModelResponseRequest(request)
|
|
1228
|
+
|
|
1229
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
1230
|
+
# and friendly error handling.
|
|
1231
|
+
rpc = self._client._transport._wrapped_methods[
|
|
1232
|
+
self._client._transport.sanitize_model_response
|
|
1233
|
+
]
|
|
1234
|
+
|
|
1235
|
+
# Certain fields should be provided within the metadata header;
|
|
1236
|
+
# add these here.
|
|
1237
|
+
metadata = tuple(metadata) + (
|
|
1238
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
1239
|
+
)
|
|
1240
|
+
|
|
1241
|
+
# Validate the universe domain.
|
|
1242
|
+
self._client._validate_universe_domain()
|
|
1243
|
+
|
|
1244
|
+
# Send the request.
|
|
1245
|
+
response = await rpc(
|
|
1246
|
+
request,
|
|
1247
|
+
retry=retry,
|
|
1248
|
+
timeout=timeout,
|
|
1249
|
+
metadata=metadata,
|
|
1250
|
+
)
|
|
1251
|
+
|
|
1252
|
+
# Done; return the response.
|
|
1253
|
+
return response
|
|
1254
|
+
|
|
1255
|
+
async def get_location(
|
|
1256
|
+
self,
|
|
1257
|
+
request: Optional[locations_pb2.GetLocationRequest] = None,
|
|
1258
|
+
*,
|
|
1259
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1260
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
1261
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
1262
|
+
) -> locations_pb2.Location:
|
|
1263
|
+
r"""Gets information about a location.
|
|
1264
|
+
|
|
1265
|
+
Args:
|
|
1266
|
+
request (:class:`~.location_pb2.GetLocationRequest`):
|
|
1267
|
+
The request object. Request message for
|
|
1268
|
+
`GetLocation` method.
|
|
1269
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
|
|
1270
|
+
if any, should be retried.
|
|
1271
|
+
timeout (float): The timeout for this request.
|
|
1272
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
1273
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
1274
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
1275
|
+
be of type `bytes`.
|
|
1276
|
+
Returns:
|
|
1277
|
+
~.location_pb2.Location:
|
|
1278
|
+
Location object.
|
|
1279
|
+
"""
|
|
1280
|
+
# Create or coerce a protobuf request object.
|
|
1281
|
+
# The request isn't a proto-plus wrapped type,
|
|
1282
|
+
# so it must be constructed via keyword expansion.
|
|
1283
|
+
if isinstance(request, dict):
|
|
1284
|
+
request = locations_pb2.GetLocationRequest(**request)
|
|
1285
|
+
|
|
1286
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
1287
|
+
# and friendly error handling.
|
|
1288
|
+
rpc = self.transport._wrapped_methods[self._client._transport.get_location]
|
|
1289
|
+
|
|
1290
|
+
# Certain fields should be provided within the metadata header;
|
|
1291
|
+
# add these here.
|
|
1292
|
+
metadata = tuple(metadata) + (
|
|
1293
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
1294
|
+
)
|
|
1295
|
+
|
|
1296
|
+
# Validate the universe domain.
|
|
1297
|
+
self._client._validate_universe_domain()
|
|
1298
|
+
|
|
1299
|
+
# Send the request.
|
|
1300
|
+
response = await rpc(
|
|
1301
|
+
request,
|
|
1302
|
+
retry=retry,
|
|
1303
|
+
timeout=timeout,
|
|
1304
|
+
metadata=metadata,
|
|
1305
|
+
)
|
|
1306
|
+
|
|
1307
|
+
# Done; return the response.
|
|
1308
|
+
return response
|
|
1309
|
+
|
|
1310
|
+
async def list_locations(
|
|
1311
|
+
self,
|
|
1312
|
+
request: Optional[locations_pb2.ListLocationsRequest] = None,
|
|
1313
|
+
*,
|
|
1314
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1315
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
1316
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
1317
|
+
) -> locations_pb2.ListLocationsResponse:
|
|
1318
|
+
r"""Lists information about the supported locations for this service.
|
|
1319
|
+
|
|
1320
|
+
Args:
|
|
1321
|
+
request (:class:`~.location_pb2.ListLocationsRequest`):
|
|
1322
|
+
The request object. Request message for
|
|
1323
|
+
`ListLocations` method.
|
|
1324
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
|
|
1325
|
+
if any, should be retried.
|
|
1326
|
+
timeout (float): The timeout for this request.
|
|
1327
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
1328
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
1329
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
1330
|
+
be of type `bytes`.
|
|
1331
|
+
Returns:
|
|
1332
|
+
~.location_pb2.ListLocationsResponse:
|
|
1333
|
+
Response message for ``ListLocations`` method.
|
|
1334
|
+
"""
|
|
1335
|
+
# Create or coerce a protobuf request object.
|
|
1336
|
+
# The request isn't a proto-plus wrapped type,
|
|
1337
|
+
# so it must be constructed via keyword expansion.
|
|
1338
|
+
if isinstance(request, dict):
|
|
1339
|
+
request = locations_pb2.ListLocationsRequest(**request)
|
|
1340
|
+
|
|
1341
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
1342
|
+
# and friendly error handling.
|
|
1343
|
+
rpc = self.transport._wrapped_methods[self._client._transport.list_locations]
|
|
1344
|
+
|
|
1345
|
+
# Certain fields should be provided within the metadata header;
|
|
1346
|
+
# add these here.
|
|
1347
|
+
metadata = tuple(metadata) + (
|
|
1348
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
1349
|
+
)
|
|
1350
|
+
|
|
1351
|
+
# Validate the universe domain.
|
|
1352
|
+
self._client._validate_universe_domain()
|
|
1353
|
+
|
|
1354
|
+
# Send the request.
|
|
1355
|
+
response = await rpc(
|
|
1356
|
+
request,
|
|
1357
|
+
retry=retry,
|
|
1358
|
+
timeout=timeout,
|
|
1359
|
+
metadata=metadata,
|
|
1360
|
+
)
|
|
1361
|
+
|
|
1362
|
+
# Done; return the response.
|
|
1363
|
+
return response
|
|
1364
|
+
|
|
1365
|
+
async def __aenter__(self) -> "ModelArmorAsyncClient":
|
|
1366
|
+
return self
|
|
1367
|
+
|
|
1368
|
+
async def __aexit__(self, exc_type, exc, tb):
|
|
1369
|
+
await self.transport.close()
|
|
1370
|
+
|
|
1371
|
+
|
|
1372
|
+
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
|
|
1373
|
+
gapic_version=package_version.__version__
|
|
1374
|
+
)
|
|
1375
|
+
|
|
1376
|
+
|
|
1377
|
+
__all__ = ("ModelArmorAsyncClient",)
|