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,607 @@
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
+ import json
17
+ import logging as std_logging
18
+ import pickle
19
+ from typing import Callable, Dict, Optional, Sequence, Tuple, Union
20
+ import warnings
21
+
22
+ from google.api_core import gapic_v1, grpc_helpers
23
+ import google.auth # type: ignore
24
+ from google.auth import credentials as ga_credentials # type: ignore
25
+ from google.auth.transport.grpc import SslCredentials # type: ignore
26
+ from google.cloud.location import locations_pb2 # type: ignore
27
+ from google.protobuf import empty_pb2 # type: ignore
28
+ from google.protobuf.json_format import MessageToJson
29
+ import google.protobuf.message
30
+ import grpc # type: ignore
31
+ import proto # type: ignore
32
+
33
+ from google.cloud.modelarmor_v1.types import service
34
+
35
+ from .base import DEFAULT_CLIENT_INFO, ModelArmorTransport
36
+
37
+ try:
38
+ from google.api_core import client_logging # type: ignore
39
+
40
+ CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
41
+ except ImportError: # pragma: NO COVER
42
+ CLIENT_LOGGING_SUPPORTED = False
43
+
44
+ _LOGGER = std_logging.getLogger(__name__)
45
+
46
+
47
+ class _LoggingClientInterceptor(grpc.UnaryUnaryClientInterceptor): # pragma: NO COVER
48
+ def intercept_unary_unary(self, continuation, client_call_details, request):
49
+ logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
50
+ std_logging.DEBUG
51
+ )
52
+ if logging_enabled: # pragma: NO COVER
53
+ request_metadata = client_call_details.metadata
54
+ if isinstance(request, proto.Message):
55
+ request_payload = type(request).to_json(request)
56
+ elif isinstance(request, google.protobuf.message.Message):
57
+ request_payload = MessageToJson(request)
58
+ else:
59
+ request_payload = f"{type(request).__name__}: {pickle.dumps(request)}"
60
+
61
+ request_metadata = {
62
+ key: value.decode("utf-8") if isinstance(value, bytes) else value
63
+ for key, value in request_metadata
64
+ }
65
+ grpc_request = {
66
+ "payload": request_payload,
67
+ "requestMethod": "grpc",
68
+ "metadata": dict(request_metadata),
69
+ }
70
+ _LOGGER.debug(
71
+ f"Sending request for {client_call_details.method}",
72
+ extra={
73
+ "serviceName": "google.cloud.modelarmor.v1.ModelArmor",
74
+ "rpcName": client_call_details.method,
75
+ "request": grpc_request,
76
+ "metadata": grpc_request["metadata"],
77
+ },
78
+ )
79
+
80
+ response = continuation(client_call_details, request)
81
+ if logging_enabled: # pragma: NO COVER
82
+ response_metadata = response.trailing_metadata()
83
+ # Convert gRPC metadata `<class 'grpc.aio._metadata.Metadata'>` to list of tuples
84
+ metadata = (
85
+ dict([(k, str(v)) for k, v in response_metadata])
86
+ if response_metadata
87
+ else None
88
+ )
89
+ result = response.result()
90
+ if isinstance(result, proto.Message):
91
+ response_payload = type(result).to_json(result)
92
+ elif isinstance(result, google.protobuf.message.Message):
93
+ response_payload = MessageToJson(result)
94
+ else:
95
+ response_payload = f"{type(result).__name__}: {pickle.dumps(result)}"
96
+ grpc_response = {
97
+ "payload": response_payload,
98
+ "metadata": metadata,
99
+ "status": "OK",
100
+ }
101
+ _LOGGER.debug(
102
+ f"Received response for {client_call_details.method}.",
103
+ extra={
104
+ "serviceName": "google.cloud.modelarmor.v1.ModelArmor",
105
+ "rpcName": client_call_details.method,
106
+ "response": grpc_response,
107
+ "metadata": grpc_response["metadata"],
108
+ },
109
+ )
110
+ return response
111
+
112
+
113
+ class ModelArmorGrpcTransport(ModelArmorTransport):
114
+ """gRPC backend transport for ModelArmor.
115
+
116
+ Service describing handlers for resources
117
+
118
+ This class defines the same methods as the primary client, so the
119
+ primary client can load the underlying transport implementation
120
+ and call it.
121
+
122
+ It sends protocol buffers over the wire using gRPC (which is built on
123
+ top of HTTP/2); the ``grpcio`` package must be installed.
124
+ """
125
+
126
+ _stubs: Dict[str, Callable]
127
+
128
+ def __init__(
129
+ self,
130
+ *,
131
+ host: str = "modelarmor.googleapis.com",
132
+ credentials: Optional[ga_credentials.Credentials] = None,
133
+ credentials_file: Optional[str] = None,
134
+ scopes: Optional[Sequence[str]] = None,
135
+ channel: Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]] = None,
136
+ api_mtls_endpoint: Optional[str] = None,
137
+ client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
138
+ ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None,
139
+ client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
140
+ quota_project_id: Optional[str] = None,
141
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
142
+ always_use_jwt_access: Optional[bool] = False,
143
+ api_audience: Optional[str] = None,
144
+ ) -> None:
145
+ """Instantiate the transport.
146
+
147
+ Args:
148
+ host (Optional[str]):
149
+ The hostname to connect to (default: 'modelarmor.googleapis.com').
150
+ credentials (Optional[google.auth.credentials.Credentials]): The
151
+ authorization credentials to attach to requests. These
152
+ credentials identify the application to the service; if none
153
+ are specified, the client will attempt to ascertain the
154
+ credentials from the environment.
155
+ This argument is ignored if a ``channel`` instance is provided.
156
+ credentials_file (Optional[str]): A file with credentials that can
157
+ be loaded with :func:`google.auth.load_credentials_from_file`.
158
+ This argument is ignored if a ``channel`` instance is provided.
159
+ scopes (Optional(Sequence[str])): A list of scopes. This argument is
160
+ ignored if a ``channel`` instance is provided.
161
+ channel (Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]]):
162
+ A ``Channel`` instance through which to make calls, or a Callable
163
+ that constructs and returns one. If set to None, ``self.create_channel``
164
+ is used to create the channel. If a Callable is given, it will be called
165
+ with the same arguments as used in ``self.create_channel``.
166
+ api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
167
+ If provided, it overrides the ``host`` argument and tries to create
168
+ a mutual TLS channel with client SSL credentials from
169
+ ``client_cert_source`` or application default SSL credentials.
170
+ client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
171
+ Deprecated. A callback to provide client SSL certificate bytes and
172
+ private key bytes, both in PEM format. It is ignored if
173
+ ``api_mtls_endpoint`` is None.
174
+ ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
175
+ for the grpc channel. It is ignored if a ``channel`` instance is provided.
176
+ client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]):
177
+ A callback to provide client certificate bytes and private key bytes,
178
+ both in PEM format. It is used to configure a mutual TLS channel. It is
179
+ ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided.
180
+ quota_project_id (Optional[str]): An optional project to use for billing
181
+ and quota.
182
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
183
+ The client info used to send a user-agent string along with
184
+ API requests. If ``None``, then default info will be used.
185
+ Generally, you only need to set this if you're developing
186
+ your own client library.
187
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
188
+ be used for service account credentials.
189
+
190
+ Raises:
191
+ google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
192
+ creation failed for any reason.
193
+ google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
194
+ and ``credentials_file`` are passed.
195
+ """
196
+ self._grpc_channel = None
197
+ self._ssl_channel_credentials = ssl_channel_credentials
198
+ self._stubs: Dict[str, Callable] = {}
199
+
200
+ if api_mtls_endpoint:
201
+ warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
202
+ if client_cert_source:
203
+ warnings.warn("client_cert_source is deprecated", DeprecationWarning)
204
+
205
+ if isinstance(channel, grpc.Channel):
206
+ # Ignore credentials if a channel was passed.
207
+ credentials = None
208
+ self._ignore_credentials = True
209
+ # If a channel was explicitly provided, set it.
210
+ self._grpc_channel = channel
211
+ self._ssl_channel_credentials = None
212
+
213
+ else:
214
+ if api_mtls_endpoint:
215
+ host = api_mtls_endpoint
216
+
217
+ # Create SSL credentials with client_cert_source or application
218
+ # default SSL credentials.
219
+ if client_cert_source:
220
+ cert, key = client_cert_source()
221
+ self._ssl_channel_credentials = grpc.ssl_channel_credentials(
222
+ certificate_chain=cert, private_key=key
223
+ )
224
+ else:
225
+ self._ssl_channel_credentials = SslCredentials().ssl_credentials
226
+
227
+ else:
228
+ if client_cert_source_for_mtls and not ssl_channel_credentials:
229
+ cert, key = client_cert_source_for_mtls()
230
+ self._ssl_channel_credentials = grpc.ssl_channel_credentials(
231
+ certificate_chain=cert, private_key=key
232
+ )
233
+
234
+ # The base transport sets the host, credentials and scopes
235
+ super().__init__(
236
+ host=host,
237
+ credentials=credentials,
238
+ credentials_file=credentials_file,
239
+ scopes=scopes,
240
+ quota_project_id=quota_project_id,
241
+ client_info=client_info,
242
+ always_use_jwt_access=always_use_jwt_access,
243
+ api_audience=api_audience,
244
+ )
245
+
246
+ if not self._grpc_channel:
247
+ # initialize with the provided callable or the default channel
248
+ channel_init = channel or type(self).create_channel
249
+ self._grpc_channel = channel_init(
250
+ self._host,
251
+ # use the credentials which are saved
252
+ credentials=self._credentials,
253
+ # Set ``credentials_file`` to ``None`` here as
254
+ # the credentials that we saved earlier should be used.
255
+ credentials_file=None,
256
+ scopes=self._scopes,
257
+ ssl_credentials=self._ssl_channel_credentials,
258
+ quota_project_id=quota_project_id,
259
+ options=[
260
+ ("grpc.max_send_message_length", -1),
261
+ ("grpc.max_receive_message_length", -1),
262
+ ],
263
+ )
264
+
265
+ self._interceptor = _LoggingClientInterceptor()
266
+ self._logged_channel = grpc.intercept_channel(
267
+ self._grpc_channel, self._interceptor
268
+ )
269
+
270
+ # Wrap messages. This must be done after self._logged_channel exists
271
+ self._prep_wrapped_messages(client_info)
272
+
273
+ @classmethod
274
+ def create_channel(
275
+ cls,
276
+ host: str = "modelarmor.googleapis.com",
277
+ credentials: Optional[ga_credentials.Credentials] = None,
278
+ credentials_file: Optional[str] = None,
279
+ scopes: Optional[Sequence[str]] = None,
280
+ quota_project_id: Optional[str] = None,
281
+ **kwargs,
282
+ ) -> grpc.Channel:
283
+ """Create and return a gRPC channel object.
284
+ Args:
285
+ host (Optional[str]): The host for the channel to use.
286
+ credentials (Optional[~.Credentials]): The
287
+ authorization credentials to attach to requests. These
288
+ credentials identify this application to the service. If
289
+ none are specified, the client will attempt to ascertain
290
+ the credentials from the environment.
291
+ credentials_file (Optional[str]): A file with credentials that can
292
+ be loaded with :func:`google.auth.load_credentials_from_file`.
293
+ This argument is mutually exclusive with credentials.
294
+ scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
295
+ service. These are only used when credentials are not specified and
296
+ are passed to :func:`google.auth.default`.
297
+ quota_project_id (Optional[str]): An optional project to use for billing
298
+ and quota.
299
+ kwargs (Optional[dict]): Keyword arguments, which are passed to the
300
+ channel creation.
301
+ Returns:
302
+ grpc.Channel: A gRPC channel object.
303
+
304
+ Raises:
305
+ google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
306
+ and ``credentials_file`` are passed.
307
+ """
308
+
309
+ return grpc_helpers.create_channel(
310
+ host,
311
+ credentials=credentials,
312
+ credentials_file=credentials_file,
313
+ quota_project_id=quota_project_id,
314
+ default_scopes=cls.AUTH_SCOPES,
315
+ scopes=scopes,
316
+ default_host=cls.DEFAULT_HOST,
317
+ **kwargs,
318
+ )
319
+
320
+ @property
321
+ def grpc_channel(self) -> grpc.Channel:
322
+ """Return the channel designed to connect to this service."""
323
+ return self._grpc_channel
324
+
325
+ @property
326
+ def list_templates(
327
+ self,
328
+ ) -> Callable[[service.ListTemplatesRequest], service.ListTemplatesResponse]:
329
+ r"""Return a callable for the list templates method over gRPC.
330
+
331
+ Lists Templates in a given project and location.
332
+
333
+ Returns:
334
+ Callable[[~.ListTemplatesRequest],
335
+ ~.ListTemplatesResponse]:
336
+ A function that, when called, will call the underlying RPC
337
+ on the server.
338
+ """
339
+ # Generate a "stub function" on-the-fly which will actually make
340
+ # the request.
341
+ # gRPC handles serialization and deserialization, so we just need
342
+ # to pass in the functions for each.
343
+ if "list_templates" not in self._stubs:
344
+ self._stubs["list_templates"] = self._logged_channel.unary_unary(
345
+ "/google.cloud.modelarmor.v1.ModelArmor/ListTemplates",
346
+ request_serializer=service.ListTemplatesRequest.serialize,
347
+ response_deserializer=service.ListTemplatesResponse.deserialize,
348
+ )
349
+ return self._stubs["list_templates"]
350
+
351
+ @property
352
+ def get_template(self) -> Callable[[service.GetTemplateRequest], service.Template]:
353
+ r"""Return a callable for the get template method over gRPC.
354
+
355
+ Gets details of a single Template.
356
+
357
+ Returns:
358
+ Callable[[~.GetTemplateRequest],
359
+ ~.Template]:
360
+ A function that, when called, will call the underlying RPC
361
+ on the server.
362
+ """
363
+ # Generate a "stub function" on-the-fly which will actually make
364
+ # the request.
365
+ # gRPC handles serialization and deserialization, so we just need
366
+ # to pass in the functions for each.
367
+ if "get_template" not in self._stubs:
368
+ self._stubs["get_template"] = self._logged_channel.unary_unary(
369
+ "/google.cloud.modelarmor.v1.ModelArmor/GetTemplate",
370
+ request_serializer=service.GetTemplateRequest.serialize,
371
+ response_deserializer=service.Template.deserialize,
372
+ )
373
+ return self._stubs["get_template"]
374
+
375
+ @property
376
+ def create_template(
377
+ self,
378
+ ) -> Callable[[service.CreateTemplateRequest], service.Template]:
379
+ r"""Return a callable for the create template method over gRPC.
380
+
381
+ Creates a new Template in a given project and
382
+ location.
383
+
384
+ Returns:
385
+ Callable[[~.CreateTemplateRequest],
386
+ ~.Template]:
387
+ A function that, when called, will call the underlying RPC
388
+ on the server.
389
+ """
390
+ # Generate a "stub function" on-the-fly which will actually make
391
+ # the request.
392
+ # gRPC handles serialization and deserialization, so we just need
393
+ # to pass in the functions for each.
394
+ if "create_template" not in self._stubs:
395
+ self._stubs["create_template"] = self._logged_channel.unary_unary(
396
+ "/google.cloud.modelarmor.v1.ModelArmor/CreateTemplate",
397
+ request_serializer=service.CreateTemplateRequest.serialize,
398
+ response_deserializer=service.Template.deserialize,
399
+ )
400
+ return self._stubs["create_template"]
401
+
402
+ @property
403
+ def update_template(
404
+ self,
405
+ ) -> Callable[[service.UpdateTemplateRequest], service.Template]:
406
+ r"""Return a callable for the update template method over gRPC.
407
+
408
+ Updates the parameters of a single Template.
409
+
410
+ Returns:
411
+ Callable[[~.UpdateTemplateRequest],
412
+ ~.Template]:
413
+ A function that, when called, will call the underlying RPC
414
+ on the server.
415
+ """
416
+ # Generate a "stub function" on-the-fly which will actually make
417
+ # the request.
418
+ # gRPC handles serialization and deserialization, so we just need
419
+ # to pass in the functions for each.
420
+ if "update_template" not in self._stubs:
421
+ self._stubs["update_template"] = self._logged_channel.unary_unary(
422
+ "/google.cloud.modelarmor.v1.ModelArmor/UpdateTemplate",
423
+ request_serializer=service.UpdateTemplateRequest.serialize,
424
+ response_deserializer=service.Template.deserialize,
425
+ )
426
+ return self._stubs["update_template"]
427
+
428
+ @property
429
+ def delete_template(
430
+ self,
431
+ ) -> Callable[[service.DeleteTemplateRequest], empty_pb2.Empty]:
432
+ r"""Return a callable for the delete template method over gRPC.
433
+
434
+ Deletes a single Template.
435
+
436
+ Returns:
437
+ Callable[[~.DeleteTemplateRequest],
438
+ ~.Empty]:
439
+ A function that, when called, will call the underlying RPC
440
+ on the server.
441
+ """
442
+ # Generate a "stub function" on-the-fly which will actually make
443
+ # the request.
444
+ # gRPC handles serialization and deserialization, so we just need
445
+ # to pass in the functions for each.
446
+ if "delete_template" not in self._stubs:
447
+ self._stubs["delete_template"] = self._logged_channel.unary_unary(
448
+ "/google.cloud.modelarmor.v1.ModelArmor/DeleteTemplate",
449
+ request_serializer=service.DeleteTemplateRequest.serialize,
450
+ response_deserializer=empty_pb2.Empty.FromString,
451
+ )
452
+ return self._stubs["delete_template"]
453
+
454
+ @property
455
+ def get_floor_setting(
456
+ self,
457
+ ) -> Callable[[service.GetFloorSettingRequest], service.FloorSetting]:
458
+ r"""Return a callable for the get floor setting method over gRPC.
459
+
460
+ Gets details of a single floor setting of a project
461
+
462
+ Returns:
463
+ Callable[[~.GetFloorSettingRequest],
464
+ ~.FloorSetting]:
465
+ A function that, when called, will call the underlying RPC
466
+ on the server.
467
+ """
468
+ # Generate a "stub function" on-the-fly which will actually make
469
+ # the request.
470
+ # gRPC handles serialization and deserialization, so we just need
471
+ # to pass in the functions for each.
472
+ if "get_floor_setting" not in self._stubs:
473
+ self._stubs["get_floor_setting"] = self._logged_channel.unary_unary(
474
+ "/google.cloud.modelarmor.v1.ModelArmor/GetFloorSetting",
475
+ request_serializer=service.GetFloorSettingRequest.serialize,
476
+ response_deserializer=service.FloorSetting.deserialize,
477
+ )
478
+ return self._stubs["get_floor_setting"]
479
+
480
+ @property
481
+ def update_floor_setting(
482
+ self,
483
+ ) -> Callable[[service.UpdateFloorSettingRequest], service.FloorSetting]:
484
+ r"""Return a callable for the update floor setting method over gRPC.
485
+
486
+ Updates the parameters of a single floor setting of a
487
+ project
488
+
489
+ Returns:
490
+ Callable[[~.UpdateFloorSettingRequest],
491
+ ~.FloorSetting]:
492
+ A function that, when called, will call the underlying RPC
493
+ on the server.
494
+ """
495
+ # Generate a "stub function" on-the-fly which will actually make
496
+ # the request.
497
+ # gRPC handles serialization and deserialization, so we just need
498
+ # to pass in the functions for each.
499
+ if "update_floor_setting" not in self._stubs:
500
+ self._stubs["update_floor_setting"] = self._logged_channel.unary_unary(
501
+ "/google.cloud.modelarmor.v1.ModelArmor/UpdateFloorSetting",
502
+ request_serializer=service.UpdateFloorSettingRequest.serialize,
503
+ response_deserializer=service.FloorSetting.deserialize,
504
+ )
505
+ return self._stubs["update_floor_setting"]
506
+
507
+ @property
508
+ def sanitize_user_prompt(
509
+ self,
510
+ ) -> Callable[
511
+ [service.SanitizeUserPromptRequest], service.SanitizeUserPromptResponse
512
+ ]:
513
+ r"""Return a callable for the sanitize user prompt method over gRPC.
514
+
515
+ Sanitizes User Prompt.
516
+
517
+ Returns:
518
+ Callable[[~.SanitizeUserPromptRequest],
519
+ ~.SanitizeUserPromptResponse]:
520
+ A function that, when called, will call the underlying RPC
521
+ on the server.
522
+ """
523
+ # Generate a "stub function" on-the-fly which will actually make
524
+ # the request.
525
+ # gRPC handles serialization and deserialization, so we just need
526
+ # to pass in the functions for each.
527
+ if "sanitize_user_prompt" not in self._stubs:
528
+ self._stubs["sanitize_user_prompt"] = self._logged_channel.unary_unary(
529
+ "/google.cloud.modelarmor.v1.ModelArmor/SanitizeUserPrompt",
530
+ request_serializer=service.SanitizeUserPromptRequest.serialize,
531
+ response_deserializer=service.SanitizeUserPromptResponse.deserialize,
532
+ )
533
+ return self._stubs["sanitize_user_prompt"]
534
+
535
+ @property
536
+ def sanitize_model_response(
537
+ self,
538
+ ) -> Callable[
539
+ [service.SanitizeModelResponseRequest], service.SanitizeModelResponseResponse
540
+ ]:
541
+ r"""Return a callable for the sanitize model response method over gRPC.
542
+
543
+ Sanitizes Model Response.
544
+
545
+ Returns:
546
+ Callable[[~.SanitizeModelResponseRequest],
547
+ ~.SanitizeModelResponseResponse]:
548
+ A function that, when called, will call the underlying RPC
549
+ on the server.
550
+ """
551
+ # Generate a "stub function" on-the-fly which will actually make
552
+ # the request.
553
+ # gRPC handles serialization and deserialization, so we just need
554
+ # to pass in the functions for each.
555
+ if "sanitize_model_response" not in self._stubs:
556
+ self._stubs["sanitize_model_response"] = self._logged_channel.unary_unary(
557
+ "/google.cloud.modelarmor.v1.ModelArmor/SanitizeModelResponse",
558
+ request_serializer=service.SanitizeModelResponseRequest.serialize,
559
+ response_deserializer=service.SanitizeModelResponseResponse.deserialize,
560
+ )
561
+ return self._stubs["sanitize_model_response"]
562
+
563
+ def close(self):
564
+ self._logged_channel.close()
565
+
566
+ @property
567
+ def list_locations(
568
+ self,
569
+ ) -> Callable[
570
+ [locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse
571
+ ]:
572
+ r"""Return a callable for the list locations method over gRPC."""
573
+ # Generate a "stub function" on-the-fly which will actually make
574
+ # the request.
575
+ # gRPC handles serialization and deserialization, so we just need
576
+ # to pass in the functions for each.
577
+ if "list_locations" not in self._stubs:
578
+ self._stubs["list_locations"] = self._logged_channel.unary_unary(
579
+ "/google.cloud.location.Locations/ListLocations",
580
+ request_serializer=locations_pb2.ListLocationsRequest.SerializeToString,
581
+ response_deserializer=locations_pb2.ListLocationsResponse.FromString,
582
+ )
583
+ return self._stubs["list_locations"]
584
+
585
+ @property
586
+ def get_location(
587
+ self,
588
+ ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]:
589
+ r"""Return a callable for the list locations method over gRPC."""
590
+ # Generate a "stub function" on-the-fly which will actually make
591
+ # the request.
592
+ # gRPC handles serialization and deserialization, so we just need
593
+ # to pass in the functions for each.
594
+ if "get_location" not in self._stubs:
595
+ self._stubs["get_location"] = self._logged_channel.unary_unary(
596
+ "/google.cloud.location.Locations/GetLocation",
597
+ request_serializer=locations_pb2.GetLocationRequest.SerializeToString,
598
+ response_deserializer=locations_pb2.Location.FromString,
599
+ )
600
+ return self._stubs["get_location"]
601
+
602
+ @property
603
+ def kind(self) -> str:
604
+ return "grpc"
605
+
606
+
607
+ __all__ = ("ModelArmorGrpcTransport",)