1# -*- coding: utf-8 -*-
2# Copyright 2025 Google LLC
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16import json
17import logging as std_logging
18import pickle
19import warnings
20from typing import Callable, Dict, Optional, Sequence, Tuple, Union
21
22from google.api_core import grpc_helpers
23from google.api_core import gapic_v1
24import google.auth # type: ignore
25from google.auth import credentials as ga_credentials # type: ignore
26from google.auth.transport.grpc import SslCredentials # type: ignore
27from google.protobuf.json_format import MessageToJson
28import google.protobuf.message
29
30import grpc # type: ignore
31import proto # type: ignore
32
33from google.iam.v1 import iam_policy_pb2 # type: ignore
34from google.iam.v1 import policy_pb2 # type: ignore
35from google.protobuf import empty_pb2 # type: ignore
36from google.pubsub_v1.types import schema
37from google.pubsub_v1.types import schema as gp_schema
38from .base import SchemaServiceTransport, DEFAULT_CLIENT_INFO
39
40try:
41 from google.api_core import client_logging # type: ignore
42
43 CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
44except ImportError: # pragma: NO COVER
45 CLIENT_LOGGING_SUPPORTED = False
46
47_LOGGER = std_logging.getLogger(__name__)
48
49
50class _LoggingClientInterceptor(grpc.UnaryUnaryClientInterceptor): # pragma: NO COVER
51 def intercept_unary_unary(self, continuation, client_call_details, request):
52 logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
53 std_logging.DEBUG
54 )
55 if logging_enabled: # pragma: NO COVER
56 request_metadata = client_call_details.metadata
57 if isinstance(request, proto.Message):
58 request_payload = type(request).to_json(request)
59 elif isinstance(request, google.protobuf.message.Message):
60 request_payload = MessageToJson(request)
61 else:
62 request_payload = f"{type(request).__name__}: {pickle.dumps(request)}"
63
64 request_metadata = {
65 key: value.decode("utf-8") if isinstance(value, bytes) else value
66 for key, value in request_metadata
67 }
68 grpc_request = {
69 "payload": request_payload,
70 "requestMethod": "grpc",
71 "metadata": dict(request_metadata),
72 }
73 _LOGGER.debug(
74 f"Sending request for {client_call_details.method}",
75 extra={
76 "serviceName": "google.pubsub.v1.SchemaService",
77 "rpcName": str(client_call_details.method),
78 "request": grpc_request,
79 "metadata": grpc_request["metadata"],
80 },
81 )
82 response = continuation(client_call_details, request)
83 if logging_enabled: # pragma: NO COVER
84 response_metadata = response.trailing_metadata()
85 # Convert gRPC metadata `<class 'grpc.aio._metadata.Metadata'>` to list of tuples
86 metadata = (
87 dict([(k, str(v)) for k, v in response_metadata])
88 if response_metadata
89 else None
90 )
91 result = response.result()
92 if isinstance(result, proto.Message):
93 response_payload = type(result).to_json(result)
94 elif isinstance(result, google.protobuf.message.Message):
95 response_payload = MessageToJson(result)
96 else:
97 response_payload = f"{type(result).__name__}: {pickle.dumps(result)}"
98 grpc_response = {
99 "payload": response_payload,
100 "metadata": metadata,
101 "status": "OK",
102 }
103 _LOGGER.debug(
104 f"Received response for {client_call_details.method}.",
105 extra={
106 "serviceName": "google.pubsub.v1.SchemaService",
107 "rpcName": client_call_details.method,
108 "response": grpc_response,
109 "metadata": grpc_response["metadata"],
110 },
111 )
112 return response
113
114
115class SchemaServiceGrpcTransport(SchemaServiceTransport):
116 """gRPC backend transport for SchemaService.
117
118 Service for doing schema-related operations.
119
120 This class defines the same methods as the primary client, so the
121 primary client can load the underlying transport implementation
122 and call it.
123
124 It sends protocol buffers over the wire using gRPC (which is built on
125 top of HTTP/2); the ``grpcio`` package must be installed.
126 """
127
128 _stubs: Dict[str, Callable]
129
130 def __init__(
131 self,
132 *,
133 host: str = "pubsub.googleapis.com",
134 credentials: Optional[ga_credentials.Credentials] = None,
135 credentials_file: Optional[str] = None,
136 scopes: Optional[Sequence[str]] = None,
137 channel: Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]] = None,
138 api_mtls_endpoint: Optional[str] = None,
139 client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
140 ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None,
141 client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
142 quota_project_id: Optional[str] = None,
143 client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
144 always_use_jwt_access: Optional[bool] = False,
145 api_audience: Optional[str] = None,
146 ) -> None:
147 """Instantiate the transport.
148
149 Args:
150 host (Optional[str]):
151 The hostname to connect to (default: 'pubsub.googleapis.com').
152 credentials (Optional[google.auth.credentials.Credentials]): The
153 authorization credentials to attach to requests. These
154 credentials identify the application to the service; if none
155 are specified, the client will attempt to ascertain the
156 credentials from the environment.
157 This argument is ignored if a ``channel`` instance is provided.
158 credentials_file (Optional[str]): Deprecated. A file with credentials that can
159 be loaded with :func:`google.auth.load_credentials_from_file`.
160 This argument is ignored if a ``channel`` instance is provided.
161 This argument will be removed in the next major version of this library.
162 scopes (Optional(Sequence[str])): A list of scopes. This argument is
163 ignored if a ``channel`` instance is provided.
164 channel (Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]]):
165 A ``Channel`` instance through which to make calls, or a Callable
166 that constructs and returns one. If set to None, ``self.create_channel``
167 is used to create the channel. If a Callable is given, it will be called
168 with the same arguments as used in ``self.create_channel``.
169 api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
170 If provided, it overrides the ``host`` argument and tries to create
171 a mutual TLS channel with client SSL credentials from
172 ``client_cert_source`` or application default SSL credentials.
173 client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
174 Deprecated. A callback to provide client SSL certificate bytes and
175 private key bytes, both in PEM format. It is ignored if
176 ``api_mtls_endpoint`` is None.
177 ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
178 for the grpc channel. It is ignored if a ``channel`` instance is provided.
179 client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]):
180 A callback to provide client certificate bytes and private key bytes,
181 both in PEM format. It is used to configure a mutual TLS channel. It is
182 ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided.
183 quota_project_id (Optional[str]): An optional project to use for billing
184 and quota.
185 client_info (google.api_core.gapic_v1.client_info.ClientInfo):
186 The client info used to send a user-agent string along with
187 API requests. If ``None``, then default info will be used.
188 Generally, you only need to set this if you're developing
189 your own client library.
190 always_use_jwt_access (Optional[bool]): Whether self signed JWT should
191 be used for service account credentials.
192
193 Raises:
194 google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
195 creation failed for any reason.
196 google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
197 and ``credentials_file`` are passed.
198 """
199 self._grpc_channel = None
200 self._ssl_channel_credentials = ssl_channel_credentials
201 self._stubs: Dict[str, Callable] = {}
202
203 if api_mtls_endpoint:
204 warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
205 if client_cert_source:
206 warnings.warn("client_cert_source is deprecated", DeprecationWarning)
207
208 if isinstance(channel, grpc.Channel):
209 # Ignore credentials if a channel was passed.
210 credentials = None
211 self._ignore_credentials = True
212 # If a channel was explicitly provided, set it.
213 self._grpc_channel = channel
214 self._ssl_channel_credentials = None
215
216 else:
217 if api_mtls_endpoint:
218 host = api_mtls_endpoint
219
220 # Create SSL credentials with client_cert_source or application
221 # default SSL credentials.
222 if client_cert_source:
223 cert, key = client_cert_source()
224 self._ssl_channel_credentials = grpc.ssl_channel_credentials(
225 certificate_chain=cert, private_key=key
226 )
227 else:
228 self._ssl_channel_credentials = SslCredentials().ssl_credentials
229
230 else:
231 if client_cert_source_for_mtls and not ssl_channel_credentials:
232 cert, key = client_cert_source_for_mtls()
233 self._ssl_channel_credentials = grpc.ssl_channel_credentials(
234 certificate_chain=cert, private_key=key
235 )
236
237 # The base transport sets the host, credentials and scopes
238 super().__init__(
239 host=host,
240 credentials=credentials,
241 credentials_file=credentials_file,
242 scopes=scopes,
243 quota_project_id=quota_project_id,
244 client_info=client_info,
245 always_use_jwt_access=always_use_jwt_access,
246 api_audience=api_audience,
247 )
248
249 if not self._grpc_channel:
250 # initialize with the provided callable or the default channel
251 channel_init = channel or type(self).create_channel
252 self._grpc_channel = channel_init(
253 self._host,
254 # use the credentials which are saved
255 credentials=self._credentials,
256 # Set ``credentials_file`` to ``None`` here as
257 # the credentials that we saved earlier should be used.
258 credentials_file=None,
259 scopes=self._scopes,
260 ssl_credentials=self._ssl_channel_credentials,
261 quota_project_id=quota_project_id,
262 options=[
263 ("grpc.max_send_message_length", -1),
264 ("grpc.max_receive_message_length", -1),
265 ("grpc.max_metadata_size", 4 * 1024 * 1024),
266 ("grpc.keepalive_time_ms", 30000),
267 ],
268 )
269
270 self._interceptor = _LoggingClientInterceptor()
271 self._logged_channel = grpc.intercept_channel(
272 self._grpc_channel, self._interceptor
273 )
274
275 # Wrap messages. This must be done after self._logged_channel exists
276 self._prep_wrapped_messages(client_info)
277
278 @classmethod
279 def create_channel(
280 cls,
281 host: str = "pubsub.googleapis.com",
282 credentials: Optional[ga_credentials.Credentials] = None,
283 credentials_file: Optional[str] = None,
284 scopes: Optional[Sequence[str]] = None,
285 quota_project_id: Optional[str] = None,
286 **kwargs,
287 ) -> grpc.Channel:
288 """Create and return a gRPC channel object.
289 Args:
290 host (Optional[str]): The host for the channel to use.
291 credentials (Optional[~.Credentials]): The
292 authorization credentials to attach to requests. These
293 credentials identify this application to the service. If
294 none are specified, the client will attempt to ascertain
295 the credentials from the environment.
296 credentials_file (Optional[str]): Deprecated. A file with credentials that can
297 be loaded with :func:`google.auth.load_credentials_from_file`.
298 This argument is mutually exclusive with credentials. This argument will be
299 removed in the next major version of this library.
300 scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
301 service. These are only used when credentials are not specified and
302 are passed to :func:`google.auth.default`.
303 quota_project_id (Optional[str]): An optional project to use for billing
304 and quota.
305 kwargs (Optional[dict]): Keyword arguments, which are passed to the
306 channel creation.
307 Returns:
308 grpc.Channel: A gRPC channel object.
309
310 Raises:
311 google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
312 and ``credentials_file`` are passed.
313 """
314
315 return grpc_helpers.create_channel(
316 host,
317 credentials=credentials,
318 credentials_file=credentials_file,
319 quota_project_id=quota_project_id,
320 default_scopes=cls.AUTH_SCOPES,
321 scopes=scopes,
322 default_host=cls.DEFAULT_HOST,
323 **kwargs,
324 )
325
326 @property
327 def grpc_channel(self) -> grpc.Channel:
328 """Return the channel designed to connect to this service."""
329 return self._grpc_channel
330
331 @property
332 def create_schema(
333 self,
334 ) -> Callable[[gp_schema.CreateSchemaRequest], gp_schema.Schema]:
335 r"""Return a callable for the create schema method over gRPC.
336
337 Creates a schema.
338
339 Returns:
340 Callable[[~.CreateSchemaRequest],
341 ~.Schema]:
342 A function that, when called, will call the underlying RPC
343 on the server.
344 """
345 # Generate a "stub function" on-the-fly which will actually make
346 # the request.
347 # gRPC handles serialization and deserialization, so we just need
348 # to pass in the functions for each.
349 if "create_schema" not in self._stubs:
350 self._stubs["create_schema"] = self._logged_channel.unary_unary(
351 "/google.pubsub.v1.SchemaService/CreateSchema",
352 request_serializer=gp_schema.CreateSchemaRequest.serialize,
353 response_deserializer=gp_schema.Schema.deserialize,
354 )
355 return self._stubs["create_schema"]
356
357 @property
358 def get_schema(self) -> Callable[[schema.GetSchemaRequest], schema.Schema]:
359 r"""Return a callable for the get schema method over gRPC.
360
361 Gets a schema.
362
363 Returns:
364 Callable[[~.GetSchemaRequest],
365 ~.Schema]:
366 A function that, when called, will call the underlying RPC
367 on the server.
368 """
369 # Generate a "stub function" on-the-fly which will actually make
370 # the request.
371 # gRPC handles serialization and deserialization, so we just need
372 # to pass in the functions for each.
373 if "get_schema" not in self._stubs:
374 self._stubs["get_schema"] = self._logged_channel.unary_unary(
375 "/google.pubsub.v1.SchemaService/GetSchema",
376 request_serializer=schema.GetSchemaRequest.serialize,
377 response_deserializer=schema.Schema.deserialize,
378 )
379 return self._stubs["get_schema"]
380
381 @property
382 def list_schemas(
383 self,
384 ) -> Callable[[schema.ListSchemasRequest], schema.ListSchemasResponse]:
385 r"""Return a callable for the list schemas method over gRPC.
386
387 Lists schemas in a project.
388
389 Returns:
390 Callable[[~.ListSchemasRequest],
391 ~.ListSchemasResponse]:
392 A function that, when called, will call the underlying RPC
393 on the server.
394 """
395 # Generate a "stub function" on-the-fly which will actually make
396 # the request.
397 # gRPC handles serialization and deserialization, so we just need
398 # to pass in the functions for each.
399 if "list_schemas" not in self._stubs:
400 self._stubs["list_schemas"] = self._logged_channel.unary_unary(
401 "/google.pubsub.v1.SchemaService/ListSchemas",
402 request_serializer=schema.ListSchemasRequest.serialize,
403 response_deserializer=schema.ListSchemasResponse.deserialize,
404 )
405 return self._stubs["list_schemas"]
406
407 @property
408 def list_schema_revisions(
409 self,
410 ) -> Callable[
411 [schema.ListSchemaRevisionsRequest], schema.ListSchemaRevisionsResponse
412 ]:
413 r"""Return a callable for the list schema revisions method over gRPC.
414
415 Lists all schema revisions for the named schema.
416
417 Returns:
418 Callable[[~.ListSchemaRevisionsRequest],
419 ~.ListSchemaRevisionsResponse]:
420 A function that, when called, will call the underlying RPC
421 on the server.
422 """
423 # Generate a "stub function" on-the-fly which will actually make
424 # the request.
425 # gRPC handles serialization and deserialization, so we just need
426 # to pass in the functions for each.
427 if "list_schema_revisions" not in self._stubs:
428 self._stubs["list_schema_revisions"] = self._logged_channel.unary_unary(
429 "/google.pubsub.v1.SchemaService/ListSchemaRevisions",
430 request_serializer=schema.ListSchemaRevisionsRequest.serialize,
431 response_deserializer=schema.ListSchemaRevisionsResponse.deserialize,
432 )
433 return self._stubs["list_schema_revisions"]
434
435 @property
436 def commit_schema(
437 self,
438 ) -> Callable[[gp_schema.CommitSchemaRequest], gp_schema.Schema]:
439 r"""Return a callable for the commit schema method over gRPC.
440
441 Commits a new schema revision to an existing schema.
442
443 Returns:
444 Callable[[~.CommitSchemaRequest],
445 ~.Schema]:
446 A function that, when called, will call the underlying RPC
447 on the server.
448 """
449 # Generate a "stub function" on-the-fly which will actually make
450 # the request.
451 # gRPC handles serialization and deserialization, so we just need
452 # to pass in the functions for each.
453 if "commit_schema" not in self._stubs:
454 self._stubs["commit_schema"] = self._logged_channel.unary_unary(
455 "/google.pubsub.v1.SchemaService/CommitSchema",
456 request_serializer=gp_schema.CommitSchemaRequest.serialize,
457 response_deserializer=gp_schema.Schema.deserialize,
458 )
459 return self._stubs["commit_schema"]
460
461 @property
462 def rollback_schema(
463 self,
464 ) -> Callable[[schema.RollbackSchemaRequest], schema.Schema]:
465 r"""Return a callable for the rollback schema method over gRPC.
466
467 Creates a new schema revision that is a copy of the provided
468 revision_id.
469
470 Returns:
471 Callable[[~.RollbackSchemaRequest],
472 ~.Schema]:
473 A function that, when called, will call the underlying RPC
474 on the server.
475 """
476 # Generate a "stub function" on-the-fly which will actually make
477 # the request.
478 # gRPC handles serialization and deserialization, so we just need
479 # to pass in the functions for each.
480 if "rollback_schema" not in self._stubs:
481 self._stubs["rollback_schema"] = self._logged_channel.unary_unary(
482 "/google.pubsub.v1.SchemaService/RollbackSchema",
483 request_serializer=schema.RollbackSchemaRequest.serialize,
484 response_deserializer=schema.Schema.deserialize,
485 )
486 return self._stubs["rollback_schema"]
487
488 @property
489 def delete_schema_revision(
490 self,
491 ) -> Callable[[schema.DeleteSchemaRevisionRequest], schema.Schema]:
492 r"""Return a callable for the delete schema revision method over gRPC.
493
494 Deletes a specific schema revision.
495
496 Returns:
497 Callable[[~.DeleteSchemaRevisionRequest],
498 ~.Schema]:
499 A function that, when called, will call the underlying RPC
500 on the server.
501 """
502 # Generate a "stub function" on-the-fly which will actually make
503 # the request.
504 # gRPC handles serialization and deserialization, so we just need
505 # to pass in the functions for each.
506 if "delete_schema_revision" not in self._stubs:
507 self._stubs["delete_schema_revision"] = self._logged_channel.unary_unary(
508 "/google.pubsub.v1.SchemaService/DeleteSchemaRevision",
509 request_serializer=schema.DeleteSchemaRevisionRequest.serialize,
510 response_deserializer=schema.Schema.deserialize,
511 )
512 return self._stubs["delete_schema_revision"]
513
514 @property
515 def delete_schema(self) -> Callable[[schema.DeleteSchemaRequest], empty_pb2.Empty]:
516 r"""Return a callable for the delete schema method over gRPC.
517
518 Deletes a schema.
519
520 Returns:
521 Callable[[~.DeleteSchemaRequest],
522 ~.Empty]:
523 A function that, when called, will call the underlying RPC
524 on the server.
525 """
526 # Generate a "stub function" on-the-fly which will actually make
527 # the request.
528 # gRPC handles serialization and deserialization, so we just need
529 # to pass in the functions for each.
530 if "delete_schema" not in self._stubs:
531 self._stubs["delete_schema"] = self._logged_channel.unary_unary(
532 "/google.pubsub.v1.SchemaService/DeleteSchema",
533 request_serializer=schema.DeleteSchemaRequest.serialize,
534 response_deserializer=empty_pb2.Empty.FromString,
535 )
536 return self._stubs["delete_schema"]
537
538 @property
539 def validate_schema(
540 self,
541 ) -> Callable[[gp_schema.ValidateSchemaRequest], gp_schema.ValidateSchemaResponse]:
542 r"""Return a callable for the validate schema method over gRPC.
543
544 Validates a schema.
545
546 Returns:
547 Callable[[~.ValidateSchemaRequest],
548 ~.ValidateSchemaResponse]:
549 A function that, when called, will call the underlying RPC
550 on the server.
551 """
552 # Generate a "stub function" on-the-fly which will actually make
553 # the request.
554 # gRPC handles serialization and deserialization, so we just need
555 # to pass in the functions for each.
556 if "validate_schema" not in self._stubs:
557 self._stubs["validate_schema"] = self._logged_channel.unary_unary(
558 "/google.pubsub.v1.SchemaService/ValidateSchema",
559 request_serializer=gp_schema.ValidateSchemaRequest.serialize,
560 response_deserializer=gp_schema.ValidateSchemaResponse.deserialize,
561 )
562 return self._stubs["validate_schema"]
563
564 @property
565 def validate_message(
566 self,
567 ) -> Callable[[schema.ValidateMessageRequest], schema.ValidateMessageResponse]:
568 r"""Return a callable for the validate message method over gRPC.
569
570 Validates a message against a schema.
571
572 Returns:
573 Callable[[~.ValidateMessageRequest],
574 ~.ValidateMessageResponse]:
575 A function that, when called, will call the underlying RPC
576 on the server.
577 """
578 # Generate a "stub function" on-the-fly which will actually make
579 # the request.
580 # gRPC handles serialization and deserialization, so we just need
581 # to pass in the functions for each.
582 if "validate_message" not in self._stubs:
583 self._stubs["validate_message"] = self._logged_channel.unary_unary(
584 "/google.pubsub.v1.SchemaService/ValidateMessage",
585 request_serializer=schema.ValidateMessageRequest.serialize,
586 response_deserializer=schema.ValidateMessageResponse.deserialize,
587 )
588 return self._stubs["validate_message"]
589
590 def close(self):
591 self._logged_channel.close()
592
593 @property
594 def set_iam_policy(
595 self,
596 ) -> Callable[[iam_policy_pb2.SetIamPolicyRequest], policy_pb2.Policy]:
597 r"""Return a callable for the set iam policy method over gRPC.
598 Sets the IAM access control policy on the specified
599 function. Replaces any existing policy.
600 Returns:
601 Callable[[~.SetIamPolicyRequest],
602 ~.Policy]:
603 A function that, when called, will call the underlying RPC
604 on the server.
605 """
606 # Generate a "stub function" on-the-fly which will actually make
607 # the request.
608 # gRPC handles serialization and deserialization, so we just need
609 # to pass in the functions for each.
610 if "set_iam_policy" not in self._stubs:
611 self._stubs["set_iam_policy"] = self._logged_channel.unary_unary(
612 "/google.iam.v1.IAMPolicy/SetIamPolicy",
613 request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString,
614 response_deserializer=policy_pb2.Policy.FromString,
615 )
616 return self._stubs["set_iam_policy"]
617
618 @property
619 def get_iam_policy(
620 self,
621 ) -> Callable[[iam_policy_pb2.GetIamPolicyRequest], policy_pb2.Policy]:
622 r"""Return a callable for the get iam policy method over gRPC.
623 Gets the IAM access control policy for a function.
624 Returns an empty policy if the function exists and does
625 not have a policy set.
626 Returns:
627 Callable[[~.GetIamPolicyRequest],
628 ~.Policy]:
629 A function that, when called, will call the underlying RPC
630 on the server.
631 """
632 # Generate a "stub function" on-the-fly which will actually make
633 # the request.
634 # gRPC handles serialization and deserialization, so we just need
635 # to pass in the functions for each.
636 if "get_iam_policy" not in self._stubs:
637 self._stubs["get_iam_policy"] = self._logged_channel.unary_unary(
638 "/google.iam.v1.IAMPolicy/GetIamPolicy",
639 request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString,
640 response_deserializer=policy_pb2.Policy.FromString,
641 )
642 return self._stubs["get_iam_policy"]
643
644 @property
645 def test_iam_permissions(
646 self,
647 ) -> Callable[
648 [iam_policy_pb2.TestIamPermissionsRequest],
649 iam_policy_pb2.TestIamPermissionsResponse,
650 ]:
651 r"""Return a callable for the test iam permissions method over gRPC.
652 Tests the specified permissions against the IAM access control
653 policy for a function. If the function does not exist, this will
654 return an empty set of permissions, not a NOT_FOUND error.
655 Returns:
656 Callable[[~.TestIamPermissionsRequest],
657 ~.TestIamPermissionsResponse]:
658 A function that, when called, will call the underlying RPC
659 on the server.
660 """
661 # Generate a "stub function" on-the-fly which will actually make
662 # the request.
663 # gRPC handles serialization and deserialization, so we just need
664 # to pass in the functions for each.
665 if "test_iam_permissions" not in self._stubs:
666 self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary(
667 "/google.iam.v1.IAMPolicy/TestIamPermissions",
668 request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString,
669 response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString,
670 )
671 return self._stubs["test_iam_permissions"]
672
673 @property
674 def kind(self) -> str:
675 return "grpc"
676
677
678__all__ = ("SchemaServiceGrpcTransport",)