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]): 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 scopes (Optional(Sequence[str])): A list of scopes. This argument is
162 ignored if a ``channel`` instance is provided.
163 channel (Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]]):
164 A ``Channel`` instance through which to make calls, or a Callable
165 that constructs and returns one. If set to None, ``self.create_channel``
166 is used to create the channel. If a Callable is given, it will be called
167 with the same arguments as used in ``self.create_channel``.
168 api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
169 If provided, it overrides the ``host`` argument and tries to create
170 a mutual TLS channel with client SSL credentials from
171 ``client_cert_source`` or application default SSL credentials.
172 client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
173 Deprecated. A callback to provide client SSL certificate bytes and
174 private key bytes, both in PEM format. It is ignored if
175 ``api_mtls_endpoint`` is None.
176 ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
177 for the grpc channel. It is ignored if a ``channel`` instance is provided.
178 client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]):
179 A callback to provide client certificate bytes and private key bytes,
180 both in PEM format. It is used to configure a mutual TLS channel. It is
181 ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided.
182 quota_project_id (Optional[str]): An optional project to use for billing
183 and quota.
184 client_info (google.api_core.gapic_v1.client_info.ClientInfo):
185 The client info used to send a user-agent string along with
186 API requests. If ``None``, then default info will be used.
187 Generally, you only need to set this if you're developing
188 your own client library.
189 always_use_jwt_access (Optional[bool]): Whether self signed JWT should
190 be used for service account credentials.
191
192 Raises:
193 google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
194 creation failed for any reason.
195 google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
196 and ``credentials_file`` are passed.
197 """
198 self._grpc_channel = None
199 self._ssl_channel_credentials = ssl_channel_credentials
200 self._stubs: Dict[str, Callable] = {}
201
202 if api_mtls_endpoint:
203 warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
204 if client_cert_source:
205 warnings.warn("client_cert_source is deprecated", DeprecationWarning)
206
207 if isinstance(channel, grpc.Channel):
208 # Ignore credentials if a channel was passed.
209 credentials = None
210 self._ignore_credentials = True
211 # If a channel was explicitly provided, set it.
212 self._grpc_channel = channel
213 self._ssl_channel_credentials = None
214
215 else:
216 if api_mtls_endpoint:
217 host = api_mtls_endpoint
218
219 # Create SSL credentials with client_cert_source or application
220 # default SSL credentials.
221 if client_cert_source:
222 cert, key = client_cert_source()
223 self._ssl_channel_credentials = grpc.ssl_channel_credentials(
224 certificate_chain=cert, private_key=key
225 )
226 else:
227 self._ssl_channel_credentials = SslCredentials().ssl_credentials
228
229 else:
230 if client_cert_source_for_mtls and not ssl_channel_credentials:
231 cert, key = client_cert_source_for_mtls()
232 self._ssl_channel_credentials = grpc.ssl_channel_credentials(
233 certificate_chain=cert, private_key=key
234 )
235
236 # The base transport sets the host, credentials and scopes
237 super().__init__(
238 host=host,
239 credentials=credentials,
240 credentials_file=credentials_file,
241 scopes=scopes,
242 quota_project_id=quota_project_id,
243 client_info=client_info,
244 always_use_jwt_access=always_use_jwt_access,
245 api_audience=api_audience,
246 )
247
248 if not self._grpc_channel:
249 # initialize with the provided callable or the default channel
250 channel_init = channel or type(self).create_channel
251 self._grpc_channel = channel_init(
252 self._host,
253 # use the credentials which are saved
254 credentials=self._credentials,
255 # Set ``credentials_file`` to ``None`` here as
256 # the credentials that we saved earlier should be used.
257 credentials_file=None,
258 scopes=self._scopes,
259 ssl_credentials=self._ssl_channel_credentials,
260 quota_project_id=quota_project_id,
261 options=[
262 ("grpc.max_send_message_length", -1),
263 ("grpc.max_receive_message_length", -1),
264 ("grpc.max_metadata_size", 4 * 1024 * 1024),
265 ("grpc.keepalive_time_ms", 30000),
266 ],
267 )
268
269 self._interceptor = _LoggingClientInterceptor()
270 self._logged_channel = grpc.intercept_channel(
271 self._grpc_channel, self._interceptor
272 )
273
274 # Wrap messages. This must be done after self._logged_channel exists
275 self._prep_wrapped_messages(client_info)
276
277 @classmethod
278 def create_channel(
279 cls,
280 host: str = "pubsub.googleapis.com",
281 credentials: Optional[ga_credentials.Credentials] = None,
282 credentials_file: Optional[str] = None,
283 scopes: Optional[Sequence[str]] = None,
284 quota_project_id: Optional[str] = None,
285 **kwargs,
286 ) -> grpc.Channel:
287 """Create and return a gRPC channel object.
288 Args:
289 host (Optional[str]): The host for the channel to use.
290 credentials (Optional[~.Credentials]): The
291 authorization credentials to attach to requests. These
292 credentials identify this application to the service. If
293 none are specified, the client will attempt to ascertain
294 the credentials from the environment.
295 credentials_file (Optional[str]): A file with credentials that can
296 be loaded with :func:`google.auth.load_credentials_from_file`.
297 This argument is mutually exclusive with credentials.
298 scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
299 service. These are only used when credentials are not specified and
300 are passed to :func:`google.auth.default`.
301 quota_project_id (Optional[str]): An optional project to use for billing
302 and quota.
303 kwargs (Optional[dict]): Keyword arguments, which are passed to the
304 channel creation.
305 Returns:
306 grpc.Channel: A gRPC channel object.
307
308 Raises:
309 google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
310 and ``credentials_file`` are passed.
311 """
312
313 return grpc_helpers.create_channel(
314 host,
315 credentials=credentials,
316 credentials_file=credentials_file,
317 quota_project_id=quota_project_id,
318 default_scopes=cls.AUTH_SCOPES,
319 scopes=scopes,
320 default_host=cls.DEFAULT_HOST,
321 **kwargs,
322 )
323
324 @property
325 def grpc_channel(self) -> grpc.Channel:
326 """Return the channel designed to connect to this service."""
327 return self._grpc_channel
328
329 @property
330 def create_schema(
331 self,
332 ) -> Callable[[gp_schema.CreateSchemaRequest], gp_schema.Schema]:
333 r"""Return a callable for the create schema method over gRPC.
334
335 Creates a schema.
336
337 Returns:
338 Callable[[~.CreateSchemaRequest],
339 ~.Schema]:
340 A function that, when called, will call the underlying RPC
341 on the server.
342 """
343 # Generate a "stub function" on-the-fly which will actually make
344 # the request.
345 # gRPC handles serialization and deserialization, so we just need
346 # to pass in the functions for each.
347 if "create_schema" not in self._stubs:
348 self._stubs["create_schema"] = self._logged_channel.unary_unary(
349 "/google.pubsub.v1.SchemaService/CreateSchema",
350 request_serializer=gp_schema.CreateSchemaRequest.serialize,
351 response_deserializer=gp_schema.Schema.deserialize,
352 )
353 return self._stubs["create_schema"]
354
355 @property
356 def get_schema(self) -> Callable[[schema.GetSchemaRequest], schema.Schema]:
357 r"""Return a callable for the get schema method over gRPC.
358
359 Gets a schema.
360
361 Returns:
362 Callable[[~.GetSchemaRequest],
363 ~.Schema]:
364 A function that, when called, will call the underlying RPC
365 on the server.
366 """
367 # Generate a "stub function" on-the-fly which will actually make
368 # the request.
369 # gRPC handles serialization and deserialization, so we just need
370 # to pass in the functions for each.
371 if "get_schema" not in self._stubs:
372 self._stubs["get_schema"] = self._logged_channel.unary_unary(
373 "/google.pubsub.v1.SchemaService/GetSchema",
374 request_serializer=schema.GetSchemaRequest.serialize,
375 response_deserializer=schema.Schema.deserialize,
376 )
377 return self._stubs["get_schema"]
378
379 @property
380 def list_schemas(
381 self,
382 ) -> Callable[[schema.ListSchemasRequest], schema.ListSchemasResponse]:
383 r"""Return a callable for the list schemas method over gRPC.
384
385 Lists schemas in a project.
386
387 Returns:
388 Callable[[~.ListSchemasRequest],
389 ~.ListSchemasResponse]:
390 A function that, when called, will call the underlying RPC
391 on the server.
392 """
393 # Generate a "stub function" on-the-fly which will actually make
394 # the request.
395 # gRPC handles serialization and deserialization, so we just need
396 # to pass in the functions for each.
397 if "list_schemas" not in self._stubs:
398 self._stubs["list_schemas"] = self._logged_channel.unary_unary(
399 "/google.pubsub.v1.SchemaService/ListSchemas",
400 request_serializer=schema.ListSchemasRequest.serialize,
401 response_deserializer=schema.ListSchemasResponse.deserialize,
402 )
403 return self._stubs["list_schemas"]
404
405 @property
406 def list_schema_revisions(
407 self,
408 ) -> Callable[
409 [schema.ListSchemaRevisionsRequest], schema.ListSchemaRevisionsResponse
410 ]:
411 r"""Return a callable for the list schema revisions method over gRPC.
412
413 Lists all schema revisions for the named schema.
414
415 Returns:
416 Callable[[~.ListSchemaRevisionsRequest],
417 ~.ListSchemaRevisionsResponse]:
418 A function that, when called, will call the underlying RPC
419 on the server.
420 """
421 # Generate a "stub function" on-the-fly which will actually make
422 # the request.
423 # gRPC handles serialization and deserialization, so we just need
424 # to pass in the functions for each.
425 if "list_schema_revisions" not in self._stubs:
426 self._stubs["list_schema_revisions"] = self._logged_channel.unary_unary(
427 "/google.pubsub.v1.SchemaService/ListSchemaRevisions",
428 request_serializer=schema.ListSchemaRevisionsRequest.serialize,
429 response_deserializer=schema.ListSchemaRevisionsResponse.deserialize,
430 )
431 return self._stubs["list_schema_revisions"]
432
433 @property
434 def commit_schema(
435 self,
436 ) -> Callable[[gp_schema.CommitSchemaRequest], gp_schema.Schema]:
437 r"""Return a callable for the commit schema method over gRPC.
438
439 Commits a new schema revision to an existing schema.
440
441 Returns:
442 Callable[[~.CommitSchemaRequest],
443 ~.Schema]:
444 A function that, when called, will call the underlying RPC
445 on the server.
446 """
447 # Generate a "stub function" on-the-fly which will actually make
448 # the request.
449 # gRPC handles serialization and deserialization, so we just need
450 # to pass in the functions for each.
451 if "commit_schema" not in self._stubs:
452 self._stubs["commit_schema"] = self._logged_channel.unary_unary(
453 "/google.pubsub.v1.SchemaService/CommitSchema",
454 request_serializer=gp_schema.CommitSchemaRequest.serialize,
455 response_deserializer=gp_schema.Schema.deserialize,
456 )
457 return self._stubs["commit_schema"]
458
459 @property
460 def rollback_schema(
461 self,
462 ) -> Callable[[schema.RollbackSchemaRequest], schema.Schema]:
463 r"""Return a callable for the rollback schema method over gRPC.
464
465 Creates a new schema revision that is a copy of the provided
466 revision_id.
467
468 Returns:
469 Callable[[~.RollbackSchemaRequest],
470 ~.Schema]:
471 A function that, when called, will call the underlying RPC
472 on the server.
473 """
474 # Generate a "stub function" on-the-fly which will actually make
475 # the request.
476 # gRPC handles serialization and deserialization, so we just need
477 # to pass in the functions for each.
478 if "rollback_schema" not in self._stubs:
479 self._stubs["rollback_schema"] = self._logged_channel.unary_unary(
480 "/google.pubsub.v1.SchemaService/RollbackSchema",
481 request_serializer=schema.RollbackSchemaRequest.serialize,
482 response_deserializer=schema.Schema.deserialize,
483 )
484 return self._stubs["rollback_schema"]
485
486 @property
487 def delete_schema_revision(
488 self,
489 ) -> Callable[[schema.DeleteSchemaRevisionRequest], schema.Schema]:
490 r"""Return a callable for the delete schema revision method over gRPC.
491
492 Deletes a specific schema revision.
493
494 Returns:
495 Callable[[~.DeleteSchemaRevisionRequest],
496 ~.Schema]:
497 A function that, when called, will call the underlying RPC
498 on the server.
499 """
500 # Generate a "stub function" on-the-fly which will actually make
501 # the request.
502 # gRPC handles serialization and deserialization, so we just need
503 # to pass in the functions for each.
504 if "delete_schema_revision" not in self._stubs:
505 self._stubs["delete_schema_revision"] = self._logged_channel.unary_unary(
506 "/google.pubsub.v1.SchemaService/DeleteSchemaRevision",
507 request_serializer=schema.DeleteSchemaRevisionRequest.serialize,
508 response_deserializer=schema.Schema.deserialize,
509 )
510 return self._stubs["delete_schema_revision"]
511
512 @property
513 def delete_schema(self) -> Callable[[schema.DeleteSchemaRequest], empty_pb2.Empty]:
514 r"""Return a callable for the delete schema method over gRPC.
515
516 Deletes a schema.
517
518 Returns:
519 Callable[[~.DeleteSchemaRequest],
520 ~.Empty]:
521 A function that, when called, will call the underlying RPC
522 on the server.
523 """
524 # Generate a "stub function" on-the-fly which will actually make
525 # the request.
526 # gRPC handles serialization and deserialization, so we just need
527 # to pass in the functions for each.
528 if "delete_schema" not in self._stubs:
529 self._stubs["delete_schema"] = self._logged_channel.unary_unary(
530 "/google.pubsub.v1.SchemaService/DeleteSchema",
531 request_serializer=schema.DeleteSchemaRequest.serialize,
532 response_deserializer=empty_pb2.Empty.FromString,
533 )
534 return self._stubs["delete_schema"]
535
536 @property
537 def validate_schema(
538 self,
539 ) -> Callable[[gp_schema.ValidateSchemaRequest], gp_schema.ValidateSchemaResponse]:
540 r"""Return a callable for the validate schema method over gRPC.
541
542 Validates a schema.
543
544 Returns:
545 Callable[[~.ValidateSchemaRequest],
546 ~.ValidateSchemaResponse]:
547 A function that, when called, will call the underlying RPC
548 on the server.
549 """
550 # Generate a "stub function" on-the-fly which will actually make
551 # the request.
552 # gRPC handles serialization and deserialization, so we just need
553 # to pass in the functions for each.
554 if "validate_schema" not in self._stubs:
555 self._stubs["validate_schema"] = self._logged_channel.unary_unary(
556 "/google.pubsub.v1.SchemaService/ValidateSchema",
557 request_serializer=gp_schema.ValidateSchemaRequest.serialize,
558 response_deserializer=gp_schema.ValidateSchemaResponse.deserialize,
559 )
560 return self._stubs["validate_schema"]
561
562 @property
563 def validate_message(
564 self,
565 ) -> Callable[[schema.ValidateMessageRequest], schema.ValidateMessageResponse]:
566 r"""Return a callable for the validate message method over gRPC.
567
568 Validates a message against a schema.
569
570 Returns:
571 Callable[[~.ValidateMessageRequest],
572 ~.ValidateMessageResponse]:
573 A function that, when called, will call the underlying RPC
574 on the server.
575 """
576 # Generate a "stub function" on-the-fly which will actually make
577 # the request.
578 # gRPC handles serialization and deserialization, so we just need
579 # to pass in the functions for each.
580 if "validate_message" not in self._stubs:
581 self._stubs["validate_message"] = self._logged_channel.unary_unary(
582 "/google.pubsub.v1.SchemaService/ValidateMessage",
583 request_serializer=schema.ValidateMessageRequest.serialize,
584 response_deserializer=schema.ValidateMessageResponse.deserialize,
585 )
586 return self._stubs["validate_message"]
587
588 def close(self):
589 self._logged_channel.close()
590
591 @property
592 def set_iam_policy(
593 self,
594 ) -> Callable[[iam_policy_pb2.SetIamPolicyRequest], policy_pb2.Policy]:
595 r"""Return a callable for the set iam policy method over gRPC.
596 Sets the IAM access control policy on the specified
597 function. Replaces any existing policy.
598 Returns:
599 Callable[[~.SetIamPolicyRequest],
600 ~.Policy]:
601 A function that, when called, will call the underlying RPC
602 on the server.
603 """
604 # Generate a "stub function" on-the-fly which will actually make
605 # the request.
606 # gRPC handles serialization and deserialization, so we just need
607 # to pass in the functions for each.
608 if "set_iam_policy" not in self._stubs:
609 self._stubs["set_iam_policy"] = self._logged_channel.unary_unary(
610 "/google.iam.v1.IAMPolicy/SetIamPolicy",
611 request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString,
612 response_deserializer=policy_pb2.Policy.FromString,
613 )
614 return self._stubs["set_iam_policy"]
615
616 @property
617 def get_iam_policy(
618 self,
619 ) -> Callable[[iam_policy_pb2.GetIamPolicyRequest], policy_pb2.Policy]:
620 r"""Return a callable for the get iam policy method over gRPC.
621 Gets the IAM access control policy for a function.
622 Returns an empty policy if the function exists and does
623 not have a policy set.
624 Returns:
625 Callable[[~.GetIamPolicyRequest],
626 ~.Policy]:
627 A function that, when called, will call the underlying RPC
628 on the server.
629 """
630 # Generate a "stub function" on-the-fly which will actually make
631 # the request.
632 # gRPC handles serialization and deserialization, so we just need
633 # to pass in the functions for each.
634 if "get_iam_policy" not in self._stubs:
635 self._stubs["get_iam_policy"] = self._logged_channel.unary_unary(
636 "/google.iam.v1.IAMPolicy/GetIamPolicy",
637 request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString,
638 response_deserializer=policy_pb2.Policy.FromString,
639 )
640 return self._stubs["get_iam_policy"]
641
642 @property
643 def test_iam_permissions(
644 self,
645 ) -> Callable[
646 [iam_policy_pb2.TestIamPermissionsRequest],
647 iam_policy_pb2.TestIamPermissionsResponse,
648 ]:
649 r"""Return a callable for the test iam permissions method over gRPC.
650 Tests the specified permissions against the IAM access control
651 policy for a function. If the function does not exist, this will
652 return an empty set of permissions, not a NOT_FOUND error.
653 Returns:
654 Callable[[~.TestIamPermissionsRequest],
655 ~.TestIamPermissionsResponse]:
656 A function that, when called, will call the underlying RPC
657 on the server.
658 """
659 # Generate a "stub function" on-the-fly which will actually make
660 # the request.
661 # gRPC handles serialization and deserialization, so we just need
662 # to pass in the functions for each.
663 if "test_iam_permissions" not in self._stubs:
664 self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary(
665 "/google.iam.v1.IAMPolicy/TestIamPermissions",
666 request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString,
667 response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString,
668 )
669 return self._stubs["test_iam_permissions"]
670
671 @property
672 def kind(self) -> str:
673 return "grpc"
674
675
676__all__ = ("SchemaServiceGrpcTransport",)