1# -*- coding: utf-8 -*-
2# Copyright 2022 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#
16from typing import Callable, Dict, Optional, Sequence, Tuple, Union
17import warnings
18
19from google.api_core import gapic_v1, grpc_helpers, operations_v1
20import google.auth # type: ignore
21from google.auth import credentials as ga_credentials # type: ignore
22from google.auth.transport.grpc import SslCredentials # type: ignore
23from google.iam.v1 import iam_policy_pb2 # type: ignore
24from google.iam.v1 import policy_pb2 # type: ignore
25from google.longrunning import operations_pb2 # type: ignore
26import grpc # type: ignore
27
28from google.cloud.resourcemanager_v3.types import folders
29
30from .base import DEFAULT_CLIENT_INFO, FoldersTransport
31
32
33class FoldersGrpcTransport(FoldersTransport):
34 """gRPC backend transport for Folders.
35
36 Manages Cloud Platform folder resources.
37 Folders can be used to organize the resources under an
38 organization and to control the policies applied to groups of
39 resources.
40
41 This class defines the same methods as the primary client, so the
42 primary client can load the underlying transport implementation
43 and call it.
44
45 It sends protocol buffers over the wire using gRPC (which is built on
46 top of HTTP/2); the ``grpcio`` package must be installed.
47 """
48
49 _stubs: Dict[str, Callable]
50
51 def __init__(
52 self,
53 *,
54 host: str = "cloudresourcemanager.googleapis.com",
55 credentials: Optional[ga_credentials.Credentials] = None,
56 credentials_file: Optional[str] = None,
57 scopes: Optional[Sequence[str]] = None,
58 channel: Optional[grpc.Channel] = None,
59 api_mtls_endpoint: Optional[str] = None,
60 client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
61 ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None,
62 client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
63 quota_project_id: Optional[str] = None,
64 client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
65 always_use_jwt_access: Optional[bool] = False,
66 api_audience: Optional[str] = None,
67 ) -> None:
68 """Instantiate the transport.
69
70 Args:
71 host (Optional[str]):
72 The hostname to connect to.
73 credentials (Optional[google.auth.credentials.Credentials]): The
74 authorization credentials to attach to requests. These
75 credentials identify the application to the service; if none
76 are specified, the client will attempt to ascertain the
77 credentials from the environment.
78 This argument is ignored if ``channel`` is provided.
79 credentials_file (Optional[str]): A file with credentials that can
80 be loaded with :func:`google.auth.load_credentials_from_file`.
81 This argument is ignored if ``channel`` is provided.
82 scopes (Optional(Sequence[str])): A list of scopes. This argument is
83 ignored if ``channel`` is provided.
84 channel (Optional[grpc.Channel]): A ``Channel`` instance through
85 which to make calls.
86 api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
87 If provided, it overrides the ``host`` argument and tries to create
88 a mutual TLS channel with client SSL credentials from
89 ``client_cert_source`` or application default SSL credentials.
90 client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
91 Deprecated. A callback to provide client SSL certificate bytes and
92 private key bytes, both in PEM format. It is ignored if
93 ``api_mtls_endpoint`` is None.
94 ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
95 for the grpc channel. It is ignored if ``channel`` is provided.
96 client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]):
97 A callback to provide client certificate bytes and private key bytes,
98 both in PEM format. It is used to configure a mutual TLS channel. It is
99 ignored if ``channel`` or ``ssl_channel_credentials`` is provided.
100 quota_project_id (Optional[str]): An optional project to use for billing
101 and quota.
102 client_info (google.api_core.gapic_v1.client_info.ClientInfo):
103 The client info used to send a user-agent string along with
104 API requests. If ``None``, then default info will be used.
105 Generally, you only need to set this if you're developing
106 your own client library.
107 always_use_jwt_access (Optional[bool]): Whether self signed JWT should
108 be used for service account credentials.
109
110 Raises:
111 google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
112 creation failed for any reason.
113 google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
114 and ``credentials_file`` are passed.
115 """
116 self._grpc_channel = None
117 self._ssl_channel_credentials = ssl_channel_credentials
118 self._stubs: Dict[str, Callable] = {}
119 self._operations_client: Optional[operations_v1.OperationsClient] = None
120
121 if api_mtls_endpoint:
122 warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
123 if client_cert_source:
124 warnings.warn("client_cert_source is deprecated", DeprecationWarning)
125
126 if channel:
127 # Ignore credentials if a channel was passed.
128 credentials = False
129 # If a channel was explicitly provided, set it.
130 self._grpc_channel = channel
131 self._ssl_channel_credentials = None
132
133 else:
134 if api_mtls_endpoint:
135 host = api_mtls_endpoint
136
137 # Create SSL credentials with client_cert_source or application
138 # default SSL credentials.
139 if client_cert_source:
140 cert, key = client_cert_source()
141 self._ssl_channel_credentials = grpc.ssl_channel_credentials(
142 certificate_chain=cert, private_key=key
143 )
144 else:
145 self._ssl_channel_credentials = SslCredentials().ssl_credentials
146
147 else:
148 if client_cert_source_for_mtls and not ssl_channel_credentials:
149 cert, key = client_cert_source_for_mtls()
150 self._ssl_channel_credentials = grpc.ssl_channel_credentials(
151 certificate_chain=cert, private_key=key
152 )
153
154 # The base transport sets the host, credentials and scopes
155 super().__init__(
156 host=host,
157 credentials=credentials,
158 credentials_file=credentials_file,
159 scopes=scopes,
160 quota_project_id=quota_project_id,
161 client_info=client_info,
162 always_use_jwt_access=always_use_jwt_access,
163 api_audience=api_audience,
164 )
165
166 if not self._grpc_channel:
167 self._grpc_channel = type(self).create_channel(
168 self._host,
169 # use the credentials which are saved
170 credentials=self._credentials,
171 # Set ``credentials_file`` to ``None`` here as
172 # the credentials that we saved earlier should be used.
173 credentials_file=None,
174 scopes=self._scopes,
175 ssl_credentials=self._ssl_channel_credentials,
176 quota_project_id=quota_project_id,
177 options=[
178 ("grpc.max_send_message_length", -1),
179 ("grpc.max_receive_message_length", -1),
180 ],
181 )
182
183 # Wrap messages. This must be done after self._grpc_channel exists
184 self._prep_wrapped_messages(client_info)
185
186 @classmethod
187 def create_channel(
188 cls,
189 host: str = "cloudresourcemanager.googleapis.com",
190 credentials: Optional[ga_credentials.Credentials] = None,
191 credentials_file: Optional[str] = None,
192 scopes: Optional[Sequence[str]] = None,
193 quota_project_id: Optional[str] = None,
194 **kwargs,
195 ) -> grpc.Channel:
196 """Create and return a gRPC channel object.
197 Args:
198 host (Optional[str]): The host for the channel to use.
199 credentials (Optional[~.Credentials]): The
200 authorization credentials to attach to requests. These
201 credentials identify this application to the service. If
202 none are specified, the client will attempt to ascertain
203 the credentials from the environment.
204 credentials_file (Optional[str]): A file with credentials that can
205 be loaded with :func:`google.auth.load_credentials_from_file`.
206 This argument is mutually exclusive with credentials.
207 scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
208 service. These are only used when credentials are not specified and
209 are passed to :func:`google.auth.default`.
210 quota_project_id (Optional[str]): An optional project to use for billing
211 and quota.
212 kwargs (Optional[dict]): Keyword arguments, which are passed to the
213 channel creation.
214 Returns:
215 grpc.Channel: A gRPC channel object.
216
217 Raises:
218 google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
219 and ``credentials_file`` are passed.
220 """
221
222 return grpc_helpers.create_channel(
223 host,
224 credentials=credentials,
225 credentials_file=credentials_file,
226 quota_project_id=quota_project_id,
227 default_scopes=cls.AUTH_SCOPES,
228 scopes=scopes,
229 default_host=cls.DEFAULT_HOST,
230 **kwargs,
231 )
232
233 @property
234 def grpc_channel(self) -> grpc.Channel:
235 """Return the channel designed to connect to this service."""
236 return self._grpc_channel
237
238 @property
239 def operations_client(self) -> operations_v1.OperationsClient:
240 """Create the client designed to process long-running operations.
241
242 This property caches on the instance; repeated calls return the same
243 client.
244 """
245 # Quick check: Only create a new client if we do not already have one.
246 if self._operations_client is None:
247 self._operations_client = operations_v1.OperationsClient(self.grpc_channel)
248
249 # Return the client from cache.
250 return self._operations_client
251
252 @property
253 def get_folder(self) -> Callable[[folders.GetFolderRequest], folders.Folder]:
254 r"""Return a callable for the get folder method over gRPC.
255
256 Retrieves a folder identified by the supplied resource name.
257 Valid folder resource names have the format
258 ``folders/{folder_id}`` (for example, ``folders/1234``). The
259 caller must have ``resourcemanager.folders.get`` permission on
260 the identified folder.
261
262 Returns:
263 Callable[[~.GetFolderRequest],
264 ~.Folder]:
265 A function that, when called, will call the underlying RPC
266 on the server.
267 """
268 # Generate a "stub function" on-the-fly which will actually make
269 # the request.
270 # gRPC handles serialization and deserialization, so we just need
271 # to pass in the functions for each.
272 if "get_folder" not in self._stubs:
273 self._stubs["get_folder"] = self.grpc_channel.unary_unary(
274 "/google.cloud.resourcemanager.v3.Folders/GetFolder",
275 request_serializer=folders.GetFolderRequest.serialize,
276 response_deserializer=folders.Folder.deserialize,
277 )
278 return self._stubs["get_folder"]
279
280 @property
281 def list_folders(
282 self,
283 ) -> Callable[[folders.ListFoldersRequest], folders.ListFoldersResponse]:
284 r"""Return a callable for the list folders method over gRPC.
285
286 Lists the folders that are direct descendants of supplied parent
287 resource. ``list()`` provides a strongly consistent view of the
288 folders underneath the specified parent resource. ``list()``
289 returns folders sorted based upon the (ascending) lexical
290 ordering of their display_name. The caller must have
291 ``resourcemanager.folders.list`` permission on the identified
292 parent.
293
294 Returns:
295 Callable[[~.ListFoldersRequest],
296 ~.ListFoldersResponse]:
297 A function that, when called, will call the underlying RPC
298 on the server.
299 """
300 # Generate a "stub function" on-the-fly which will actually make
301 # the request.
302 # gRPC handles serialization and deserialization, so we just need
303 # to pass in the functions for each.
304 if "list_folders" not in self._stubs:
305 self._stubs["list_folders"] = self.grpc_channel.unary_unary(
306 "/google.cloud.resourcemanager.v3.Folders/ListFolders",
307 request_serializer=folders.ListFoldersRequest.serialize,
308 response_deserializer=folders.ListFoldersResponse.deserialize,
309 )
310 return self._stubs["list_folders"]
311
312 @property
313 def search_folders(
314 self,
315 ) -> Callable[[folders.SearchFoldersRequest], folders.SearchFoldersResponse]:
316 r"""Return a callable for the search folders method over gRPC.
317
318 Search for folders that match specific filter criteria.
319 ``search()`` provides an eventually consistent view of the
320 folders a user has access to which meet the specified filter
321 criteria.
322
323 This will only return folders on which the caller has the
324 permission ``resourcemanager.folders.get``.
325
326 Returns:
327 Callable[[~.SearchFoldersRequest],
328 ~.SearchFoldersResponse]:
329 A function that, when called, will call the underlying RPC
330 on the server.
331 """
332 # Generate a "stub function" on-the-fly which will actually make
333 # the request.
334 # gRPC handles serialization and deserialization, so we just need
335 # to pass in the functions for each.
336 if "search_folders" not in self._stubs:
337 self._stubs["search_folders"] = self.grpc_channel.unary_unary(
338 "/google.cloud.resourcemanager.v3.Folders/SearchFolders",
339 request_serializer=folders.SearchFoldersRequest.serialize,
340 response_deserializer=folders.SearchFoldersResponse.deserialize,
341 )
342 return self._stubs["search_folders"]
343
344 @property
345 def create_folder(
346 self,
347 ) -> Callable[[folders.CreateFolderRequest], operations_pb2.Operation]:
348 r"""Return a callable for the create folder method over gRPC.
349
350 Creates a folder in the resource hierarchy. Returns an
351 ``Operation`` which can be used to track the progress of the
352 folder creation workflow. Upon success, the
353 ``Operation.response`` field will be populated with the created
354 Folder.
355
356 In order to succeed, the addition of this new folder must not
357 violate the folder naming, height, or fanout constraints.
358
359 - The folder's ``display_name`` must be distinct from all other
360 folders that share its parent.
361 - The addition of the folder must not cause the active folder
362 hierarchy to exceed a height of 10. Note, the full active +
363 deleted folder hierarchy is allowed to reach a height of 20;
364 this provides additional headroom when moving folders that
365 contain deleted folders.
366 - The addition of the folder must not cause the total number of
367 folders under its parent to exceed 300.
368
369 If the operation fails due to a folder constraint violation,
370 some errors may be returned by the ``CreateFolder`` request,
371 with status code ``FAILED_PRECONDITION`` and an error
372 description. Other folder constraint violations will be
373 communicated in the ``Operation``, with the specific
374 ``PreconditionFailure`` returned in the details list in the
375 ``Operation.error`` field.
376
377 The caller must have ``resourcemanager.folders.create``
378 permission on the identified parent.
379
380 Returns:
381 Callable[[~.CreateFolderRequest],
382 ~.Operation]:
383 A function that, when called, will call the underlying RPC
384 on the server.
385 """
386 # Generate a "stub function" on-the-fly which will actually make
387 # the request.
388 # gRPC handles serialization and deserialization, so we just need
389 # to pass in the functions for each.
390 if "create_folder" not in self._stubs:
391 self._stubs["create_folder"] = self.grpc_channel.unary_unary(
392 "/google.cloud.resourcemanager.v3.Folders/CreateFolder",
393 request_serializer=folders.CreateFolderRequest.serialize,
394 response_deserializer=operations_pb2.Operation.FromString,
395 )
396 return self._stubs["create_folder"]
397
398 @property
399 def update_folder(
400 self,
401 ) -> Callable[[folders.UpdateFolderRequest], operations_pb2.Operation]:
402 r"""Return a callable for the update folder method over gRPC.
403
404 Updates a folder, changing its ``display_name``. Changes to the
405 folder ``display_name`` will be rejected if they violate either
406 the ``display_name`` formatting rules or the naming constraints
407 described in the
408 [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder]
409 documentation.
410
411 The folder's ``display_name`` must start and end with a letter
412 or digit, may contain letters, digits, spaces, hyphens and
413 underscores and can be between 3 and 30 characters. This is
414 captured by the regular expression:
415 ``[\p{L}\p{N}][\p{L}\p{N}_- ]{1,28}[\p{L}\p{N}]``. The caller
416 must have ``resourcemanager.folders.update`` permission on the
417 identified folder.
418
419 If the update fails due to the unique name constraint then a
420 ``PreconditionFailure`` explaining this violation will be
421 returned in the Status.details field.
422
423 Returns:
424 Callable[[~.UpdateFolderRequest],
425 ~.Operation]:
426 A function that, when called, will call the underlying RPC
427 on the server.
428 """
429 # Generate a "stub function" on-the-fly which will actually make
430 # the request.
431 # gRPC handles serialization and deserialization, so we just need
432 # to pass in the functions for each.
433 if "update_folder" not in self._stubs:
434 self._stubs["update_folder"] = self.grpc_channel.unary_unary(
435 "/google.cloud.resourcemanager.v3.Folders/UpdateFolder",
436 request_serializer=folders.UpdateFolderRequest.serialize,
437 response_deserializer=operations_pb2.Operation.FromString,
438 )
439 return self._stubs["update_folder"]
440
441 @property
442 def move_folder(
443 self,
444 ) -> Callable[[folders.MoveFolderRequest], operations_pb2.Operation]:
445 r"""Return a callable for the move folder method over gRPC.
446
447 Moves a folder under a new resource parent. Returns an
448 ``Operation`` which can be used to track the progress of the
449 folder move workflow. Upon success, the ``Operation.response``
450 field will be populated with the moved folder. Upon failure, a
451 ``FolderOperationError`` categorizing the failure cause will be
452 returned - if the failure occurs synchronously then the
453 ``FolderOperationError`` will be returned in the
454 ``Status.details`` field. If it occurs asynchronously, then the
455 FolderOperation will be returned in the ``Operation.error``
456 field. In addition, the ``Operation.metadata`` field will be
457 populated with a ``FolderOperation`` message as an aid to
458 stateless clients. Folder moves will be rejected if they violate
459 either the naming, height, or fanout constraints described in
460 the
461 [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder]
462 documentation. The caller must have
463 ``resourcemanager.folders.move`` permission on the folder's
464 current and proposed new parent.
465
466 Returns:
467 Callable[[~.MoveFolderRequest],
468 ~.Operation]:
469 A function that, when called, will call the underlying RPC
470 on the server.
471 """
472 # Generate a "stub function" on-the-fly which will actually make
473 # the request.
474 # gRPC handles serialization and deserialization, so we just need
475 # to pass in the functions for each.
476 if "move_folder" not in self._stubs:
477 self._stubs["move_folder"] = self.grpc_channel.unary_unary(
478 "/google.cloud.resourcemanager.v3.Folders/MoveFolder",
479 request_serializer=folders.MoveFolderRequest.serialize,
480 response_deserializer=operations_pb2.Operation.FromString,
481 )
482 return self._stubs["move_folder"]
483
484 @property
485 def delete_folder(
486 self,
487 ) -> Callable[[folders.DeleteFolderRequest], operations_pb2.Operation]:
488 r"""Return a callable for the delete folder method over gRPC.
489
490 Requests deletion of a folder. The folder is moved into the
491 [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED]
492 state immediately, and is deleted approximately 30 days later.
493 This method may only be called on an empty folder, where a
494 folder is empty if it doesn't contain any folders or projects in
495 the
496 [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE]
497 state. If called on a folder in
498 [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED]
499 state the operation will result in a no-op success. The caller
500 must have ``resourcemanager.folders.delete`` permission on the
501 identified folder.
502
503 Returns:
504 Callable[[~.DeleteFolderRequest],
505 ~.Operation]:
506 A function that, when called, will call the underlying RPC
507 on the server.
508 """
509 # Generate a "stub function" on-the-fly which will actually make
510 # the request.
511 # gRPC handles serialization and deserialization, so we just need
512 # to pass in the functions for each.
513 if "delete_folder" not in self._stubs:
514 self._stubs["delete_folder"] = self.grpc_channel.unary_unary(
515 "/google.cloud.resourcemanager.v3.Folders/DeleteFolder",
516 request_serializer=folders.DeleteFolderRequest.serialize,
517 response_deserializer=operations_pb2.Operation.FromString,
518 )
519 return self._stubs["delete_folder"]
520
521 @property
522 def undelete_folder(
523 self,
524 ) -> Callable[[folders.UndeleteFolderRequest], operations_pb2.Operation]:
525 r"""Return a callable for the undelete folder method over gRPC.
526
527 Cancels the deletion request for a folder. This method may be
528 called on a folder in any state. If the folder is in the
529 [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE]
530 state the result will be a no-op success. In order to succeed,
531 the folder's parent must be in the
532 [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE]
533 state. In addition, reintroducing the folder into the tree must
534 not violate folder naming, height, and fanout constraints
535 described in the
536 [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder]
537 documentation. The caller must have
538 ``resourcemanager.folders.undelete`` permission on the
539 identified folder.
540
541 Returns:
542 Callable[[~.UndeleteFolderRequest],
543 ~.Operation]:
544 A function that, when called, will call the underlying RPC
545 on the server.
546 """
547 # Generate a "stub function" on-the-fly which will actually make
548 # the request.
549 # gRPC handles serialization and deserialization, so we just need
550 # to pass in the functions for each.
551 if "undelete_folder" not in self._stubs:
552 self._stubs["undelete_folder"] = self.grpc_channel.unary_unary(
553 "/google.cloud.resourcemanager.v3.Folders/UndeleteFolder",
554 request_serializer=folders.UndeleteFolderRequest.serialize,
555 response_deserializer=operations_pb2.Operation.FromString,
556 )
557 return self._stubs["undelete_folder"]
558
559 @property
560 def get_iam_policy(
561 self,
562 ) -> Callable[[iam_policy_pb2.GetIamPolicyRequest], policy_pb2.Policy]:
563 r"""Return a callable for the get iam policy method over gRPC.
564
565 Gets the access control policy for a folder. The returned policy
566 may be empty if no such policy or resource exists. The
567 ``resource`` field should be the folder's resource name, for
568 example: "folders/1234". The caller must have
569 ``resourcemanager.folders.getIamPolicy`` permission on the
570 identified folder.
571
572 Returns:
573 Callable[[~.GetIamPolicyRequest],
574 ~.Policy]:
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 "get_iam_policy" not in self._stubs:
583 self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary(
584 "/google.cloud.resourcemanager.v3.Folders/GetIamPolicy",
585 request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString,
586 response_deserializer=policy_pb2.Policy.FromString,
587 )
588 return self._stubs["get_iam_policy"]
589
590 @property
591 def set_iam_policy(
592 self,
593 ) -> Callable[[iam_policy_pb2.SetIamPolicyRequest], policy_pb2.Policy]:
594 r"""Return a callable for the set iam policy method over gRPC.
595
596 Sets the access control policy on a folder, replacing any
597 existing policy. The ``resource`` field should be the folder's
598 resource name, for example: "folders/1234". The caller must have
599 ``resourcemanager.folders.setIamPolicy`` permission on the
600 identified folder.
601
602 Returns:
603 Callable[[~.SetIamPolicyRequest],
604 ~.Policy]:
605 A function that, when called, will call the underlying RPC
606 on the server.
607 """
608 # Generate a "stub function" on-the-fly which will actually make
609 # the request.
610 # gRPC handles serialization and deserialization, so we just need
611 # to pass in the functions for each.
612 if "set_iam_policy" not in self._stubs:
613 self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary(
614 "/google.cloud.resourcemanager.v3.Folders/SetIamPolicy",
615 request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString,
616 response_deserializer=policy_pb2.Policy.FromString,
617 )
618 return self._stubs["set_iam_policy"]
619
620 @property
621 def test_iam_permissions(
622 self,
623 ) -> Callable[
624 [iam_policy_pb2.TestIamPermissionsRequest],
625 iam_policy_pb2.TestIamPermissionsResponse,
626 ]:
627 r"""Return a callable for the test iam permissions method over gRPC.
628
629 Returns permissions that a caller has on the specified folder.
630 The ``resource`` field should be the folder's resource name, for
631 example: "folders/1234".
632
633 There are no permissions required for making this API call.
634
635 Returns:
636 Callable[[~.TestIamPermissionsRequest],
637 ~.TestIamPermissionsResponse]:
638 A function that, when called, will call the underlying RPC
639 on the server.
640 """
641 # Generate a "stub function" on-the-fly which will actually make
642 # the request.
643 # gRPC handles serialization and deserialization, so we just need
644 # to pass in the functions for each.
645 if "test_iam_permissions" not in self._stubs:
646 self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary(
647 "/google.cloud.resourcemanager.v3.Folders/TestIamPermissions",
648 request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString,
649 response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString,
650 )
651 return self._stubs["test_iam_permissions"]
652
653 def close(self):
654 self.grpc_channel.close()
655
656 @property
657 def get_operation(
658 self,
659 ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]:
660 r"""Return a callable for the get_operation method over gRPC."""
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 "get_operation" not in self._stubs:
666 self._stubs["get_operation"] = self.grpc_channel.unary_unary(
667 "/google.longrunning.Operations/GetOperation",
668 request_serializer=operations_pb2.GetOperationRequest.SerializeToString,
669 response_deserializer=operations_pb2.Operation.FromString,
670 )
671 return self._stubs["get_operation"]
672
673 @property
674 def kind(self) -> str:
675 return "grpc"
676
677
678__all__ = ("FoldersGrpcTransport",)