Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/google/cloud/resourcemanager_v3/services/folders/transports/grpc_asyncio.py: 42%

116 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-06 06:03 +0000

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 Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union 

17import warnings 

18 

19from google.api_core import gapic_v1, grpc_helpers_async, operations_v1 

20from google.auth import credentials as ga_credentials # type: ignore 

21from google.auth.transport.grpc import SslCredentials # type: ignore 

22from google.iam.v1 import iam_policy_pb2 # type: ignore 

23from google.iam.v1 import policy_pb2 # type: ignore 

24from google.longrunning import operations_pb2 # type: ignore 

25import grpc # type: ignore 

26from grpc.experimental import aio # type: ignore 

27 

28from google.cloud.resourcemanager_v3.types import folders 

29 

30from .base import DEFAULT_CLIENT_INFO, FoldersTransport 

31from .grpc import FoldersGrpcTransport 

32 

33 

34class FoldersGrpcAsyncIOTransport(FoldersTransport): 

35 """gRPC AsyncIO backend transport for Folders. 

36 

37 Manages Cloud Platform folder resources. 

38 Folders can be used to organize the resources under an 

39 organization and to control the policies applied to groups of 

40 resources. 

41 

42 This class defines the same methods as the primary client, so the 

43 primary client can load the underlying transport implementation 

44 and call it. 

45 

46 It sends protocol buffers over the wire using gRPC (which is built on 

47 top of HTTP/2); the ``grpcio`` package must be installed. 

48 """ 

49 

50 _grpc_channel: aio.Channel 

51 _stubs: Dict[str, Callable] = {} 

52 

53 @classmethod 

54 def create_channel( 

55 cls, 

56 host: str = "cloudresourcemanager.googleapis.com", 

57 credentials: Optional[ga_credentials.Credentials] = None, 

58 credentials_file: Optional[str] = None, 

59 scopes: Optional[Sequence[str]] = None, 

60 quota_project_id: Optional[str] = None, 

61 **kwargs, 

62 ) -> aio.Channel: 

63 """Create and return a gRPC AsyncIO channel object. 

64 Args: 

65 host (Optional[str]): The host for the channel to use. 

66 credentials (Optional[~.Credentials]): The 

67 authorization credentials to attach to requests. These 

68 credentials identify this application to the service. If 

69 none are specified, the client will attempt to ascertain 

70 the credentials from the environment. 

71 credentials_file (Optional[str]): A file with credentials that can 

72 be loaded with :func:`google.auth.load_credentials_from_file`. 

73 This argument is ignored if ``channel`` is provided. 

74 scopes (Optional[Sequence[str]]): A optional list of scopes needed for this 

75 service. These are only used when credentials are not specified and 

76 are passed to :func:`google.auth.default`. 

77 quota_project_id (Optional[str]): An optional project to use for billing 

78 and quota. 

79 kwargs (Optional[dict]): Keyword arguments, which are passed to the 

80 channel creation. 

81 Returns: 

82 aio.Channel: A gRPC AsyncIO channel object. 

83 """ 

84 

85 return grpc_helpers_async.create_channel( 

86 host, 

87 credentials=credentials, 

88 credentials_file=credentials_file, 

89 quota_project_id=quota_project_id, 

90 default_scopes=cls.AUTH_SCOPES, 

91 scopes=scopes, 

92 default_host=cls.DEFAULT_HOST, 

93 **kwargs, 

94 ) 

95 

96 def __init__( 

97 self, 

98 *, 

99 host: str = "cloudresourcemanager.googleapis.com", 

100 credentials: Optional[ga_credentials.Credentials] = None, 

101 credentials_file: Optional[str] = None, 

102 scopes: Optional[Sequence[str]] = None, 

103 channel: Optional[aio.Channel] = None, 

104 api_mtls_endpoint: Optional[str] = None, 

105 client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, 

106 ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, 

107 client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, 

108 quota_project_id: Optional[str] = None, 

109 client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, 

110 always_use_jwt_access: Optional[bool] = False, 

111 api_audience: Optional[str] = None, 

112 ) -> None: 

113 """Instantiate the transport. 

114 

115 Args: 

116 host (Optional[str]): 

117 The hostname to connect to. 

118 credentials (Optional[google.auth.credentials.Credentials]): The 

119 authorization credentials to attach to requests. These 

120 credentials identify the application to the service; if none 

121 are specified, the client will attempt to ascertain the 

122 credentials from the environment. 

123 This argument is ignored if ``channel`` is provided. 

124 credentials_file (Optional[str]): A file with credentials that can 

125 be loaded with :func:`google.auth.load_credentials_from_file`. 

126 This argument is ignored if ``channel`` is provided. 

127 scopes (Optional[Sequence[str]]): A optional list of scopes needed for this 

128 service. These are only used when credentials are not specified and 

129 are passed to :func:`google.auth.default`. 

130 channel (Optional[aio.Channel]): A ``Channel`` instance through 

131 which to make calls. 

132 api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. 

133 If provided, it overrides the ``host`` argument and tries to create 

134 a mutual TLS channel with client SSL credentials from 

135 ``client_cert_source`` or application default SSL credentials. 

136 client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): 

137 Deprecated. A callback to provide client SSL certificate bytes and 

138 private key bytes, both in PEM format. It is ignored if 

139 ``api_mtls_endpoint`` is None. 

140 ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials 

141 for the grpc channel. It is ignored if ``channel`` is provided. 

142 client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): 

143 A callback to provide client certificate bytes and private key bytes, 

144 both in PEM format. It is used to configure a mutual TLS channel. It is 

145 ignored if ``channel`` or ``ssl_channel_credentials`` is provided. 

146 quota_project_id (Optional[str]): An optional project to use for billing 

147 and quota. 

148 client_info (google.api_core.gapic_v1.client_info.ClientInfo): 

149 The client info used to send a user-agent string along with 

150 API requests. If ``None``, then default info will be used. 

151 Generally, you only need to set this if you're developing 

152 your own client library. 

153 always_use_jwt_access (Optional[bool]): Whether self signed JWT should 

154 be used for service account credentials. 

155 

156 Raises: 

157 google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport 

158 creation failed for any reason. 

159 google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` 

160 and ``credentials_file`` are passed. 

161 """ 

162 self._grpc_channel = None 

163 self._ssl_channel_credentials = ssl_channel_credentials 

164 self._stubs: Dict[str, Callable] = {} 

165 self._operations_client: Optional[operations_v1.OperationsAsyncClient] = None 

166 

167 if api_mtls_endpoint: 

168 warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) 

169 if client_cert_source: 

170 warnings.warn("client_cert_source is deprecated", DeprecationWarning) 

171 

172 if channel: 

173 # Ignore credentials if a channel was passed. 

174 credentials = False 

175 # If a channel was explicitly provided, set it. 

176 self._grpc_channel = channel 

177 self._ssl_channel_credentials = None 

178 else: 

179 if api_mtls_endpoint: 

180 host = api_mtls_endpoint 

181 

182 # Create SSL credentials with client_cert_source or application 

183 # default SSL credentials. 

184 if client_cert_source: 

185 cert, key = client_cert_source() 

186 self._ssl_channel_credentials = grpc.ssl_channel_credentials( 

187 certificate_chain=cert, private_key=key 

188 ) 

189 else: 

190 self._ssl_channel_credentials = SslCredentials().ssl_credentials 

191 

192 else: 

193 if client_cert_source_for_mtls and not ssl_channel_credentials: 

194 cert, key = client_cert_source_for_mtls() 

195 self._ssl_channel_credentials = grpc.ssl_channel_credentials( 

196 certificate_chain=cert, private_key=key 

197 ) 

198 

199 # The base transport sets the host, credentials and scopes 

200 super().__init__( 

201 host=host, 

202 credentials=credentials, 

203 credentials_file=credentials_file, 

204 scopes=scopes, 

205 quota_project_id=quota_project_id, 

206 client_info=client_info, 

207 always_use_jwt_access=always_use_jwt_access, 

208 api_audience=api_audience, 

209 ) 

210 

211 if not self._grpc_channel: 

212 self._grpc_channel = type(self).create_channel( 

213 self._host, 

214 # use the credentials which are saved 

215 credentials=self._credentials, 

216 # Set ``credentials_file`` to ``None`` here as 

217 # the credentials that we saved earlier should be used. 

218 credentials_file=None, 

219 scopes=self._scopes, 

220 ssl_credentials=self._ssl_channel_credentials, 

221 quota_project_id=quota_project_id, 

222 options=[ 

223 ("grpc.max_send_message_length", -1), 

224 ("grpc.max_receive_message_length", -1), 

225 ], 

226 ) 

227 

228 # Wrap messages. This must be done after self._grpc_channel exists 

229 self._prep_wrapped_messages(client_info) 

230 

231 @property 

232 def grpc_channel(self) -> aio.Channel: 

233 """Create the channel designed to connect to this service. 

234 

235 This property caches on the instance; repeated calls return 

236 the same channel. 

237 """ 

238 # Return the channel from cache. 

239 return self._grpc_channel 

240 

241 @property 

242 def operations_client(self) -> operations_v1.OperationsAsyncClient: 

243 """Create the client designed to process long-running operations. 

244 

245 This property caches on the instance; repeated calls return the same 

246 client. 

247 """ 

248 # Quick check: Only create a new client if we do not already have one. 

249 if self._operations_client is None: 

250 self._operations_client = operations_v1.OperationsAsyncClient( 

251 self.grpc_channel 

252 ) 

253 

254 # Return the client from cache. 

255 return self._operations_client 

256 

257 @property 

258 def get_folder( 

259 self, 

260 ) -> Callable[[folders.GetFolderRequest], Awaitable[folders.Folder]]: 

261 r"""Return a callable for the get folder method over gRPC. 

262 

263 Retrieves a folder identified by the supplied resource name. 

264 Valid folder resource names have the format 

265 ``folders/{folder_id}`` (for example, ``folders/1234``). The 

266 caller must have ``resourcemanager.folders.get`` permission on 

267 the identified folder. 

268 

269 Returns: 

270 Callable[[~.GetFolderRequest], 

271 Awaitable[~.Folder]]: 

272 A function that, when called, will call the underlying RPC 

273 on the server. 

274 """ 

275 # Generate a "stub function" on-the-fly which will actually make 

276 # the request. 

277 # gRPC handles serialization and deserialization, so we just need 

278 # to pass in the functions for each. 

279 if "get_folder" not in self._stubs: 

280 self._stubs["get_folder"] = self.grpc_channel.unary_unary( 

281 "/google.cloud.resourcemanager.v3.Folders/GetFolder", 

282 request_serializer=folders.GetFolderRequest.serialize, 

283 response_deserializer=folders.Folder.deserialize, 

284 ) 

285 return self._stubs["get_folder"] 

286 

287 @property 

288 def list_folders( 

289 self, 

290 ) -> Callable[[folders.ListFoldersRequest], Awaitable[folders.ListFoldersResponse]]: 

291 r"""Return a callable for the list folders method over gRPC. 

292 

293 Lists the folders that are direct descendants of supplied parent 

294 resource. ``list()`` provides a strongly consistent view of the 

295 folders underneath the specified parent resource. ``list()`` 

296 returns folders sorted based upon the (ascending) lexical 

297 ordering of their display_name. The caller must have 

298 ``resourcemanager.folders.list`` permission on the identified 

299 parent. 

300 

301 Returns: 

302 Callable[[~.ListFoldersRequest], 

303 Awaitable[~.ListFoldersResponse]]: 

304 A function that, when called, will call the underlying RPC 

305 on the server. 

306 """ 

307 # Generate a "stub function" on-the-fly which will actually make 

308 # the request. 

309 # gRPC handles serialization and deserialization, so we just need 

310 # to pass in the functions for each. 

311 if "list_folders" not in self._stubs: 

312 self._stubs["list_folders"] = self.grpc_channel.unary_unary( 

313 "/google.cloud.resourcemanager.v3.Folders/ListFolders", 

314 request_serializer=folders.ListFoldersRequest.serialize, 

315 response_deserializer=folders.ListFoldersResponse.deserialize, 

316 ) 

317 return self._stubs["list_folders"] 

318 

319 @property 

320 def search_folders( 

321 self, 

322 ) -> Callable[ 

323 [folders.SearchFoldersRequest], Awaitable[folders.SearchFoldersResponse] 

324 ]: 

325 r"""Return a callable for the search folders method over gRPC. 

326 

327 Search for folders that match specific filter criteria. 

328 ``search()`` provides an eventually consistent view of the 

329 folders a user has access to which meet the specified filter 

330 criteria. 

331 

332 This will only return folders on which the caller has the 

333 permission ``resourcemanager.folders.get``. 

334 

335 Returns: 

336 Callable[[~.SearchFoldersRequest], 

337 Awaitable[~.SearchFoldersResponse]]: 

338 A function that, when called, will call the underlying RPC 

339 on the server. 

340 """ 

341 # Generate a "stub function" on-the-fly which will actually make 

342 # the request. 

343 # gRPC handles serialization and deserialization, so we just need 

344 # to pass in the functions for each. 

345 if "search_folders" not in self._stubs: 

346 self._stubs["search_folders"] = self.grpc_channel.unary_unary( 

347 "/google.cloud.resourcemanager.v3.Folders/SearchFolders", 

348 request_serializer=folders.SearchFoldersRequest.serialize, 

349 response_deserializer=folders.SearchFoldersResponse.deserialize, 

350 ) 

351 return self._stubs["search_folders"] 

352 

353 @property 

354 def create_folder( 

355 self, 

356 ) -> Callable[[folders.CreateFolderRequest], Awaitable[operations_pb2.Operation]]: 

357 r"""Return a callable for the create folder method over gRPC. 

358 

359 Creates a folder in the resource hierarchy. Returns an 

360 ``Operation`` which can be used to track the progress of the 

361 folder creation workflow. Upon success, the 

362 ``Operation.response`` field will be populated with the created 

363 Folder. 

364 

365 In order to succeed, the addition of this new folder must not 

366 violate the folder naming, height, or fanout constraints. 

367 

368 - The folder's ``display_name`` must be distinct from all other 

369 folders that share its parent. 

370 - The addition of the folder must not cause the active folder 

371 hierarchy to exceed a height of 10. Note, the full active + 

372 deleted folder hierarchy is allowed to reach a height of 20; 

373 this provides additional headroom when moving folders that 

374 contain deleted folders. 

375 - The addition of the folder must not cause the total number of 

376 folders under its parent to exceed 300. 

377 

378 If the operation fails due to a folder constraint violation, 

379 some errors may be returned by the ``CreateFolder`` request, 

380 with status code ``FAILED_PRECONDITION`` and an error 

381 description. Other folder constraint violations will be 

382 communicated in the ``Operation``, with the specific 

383 ``PreconditionFailure`` returned in the details list in the 

384 ``Operation.error`` field. 

385 

386 The caller must have ``resourcemanager.folders.create`` 

387 permission on the identified parent. 

388 

389 Returns: 

390 Callable[[~.CreateFolderRequest], 

391 Awaitable[~.Operation]]: 

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 "create_folder" not in self._stubs: 

400 self._stubs["create_folder"] = self.grpc_channel.unary_unary( 

401 "/google.cloud.resourcemanager.v3.Folders/CreateFolder", 

402 request_serializer=folders.CreateFolderRequest.serialize, 

403 response_deserializer=operations_pb2.Operation.FromString, 

404 ) 

405 return self._stubs["create_folder"] 

406 

407 @property 

408 def update_folder( 

409 self, 

410 ) -> Callable[[folders.UpdateFolderRequest], Awaitable[operations_pb2.Operation]]: 

411 r"""Return a callable for the update folder method over gRPC. 

412 

413 Updates a folder, changing its ``display_name``. Changes to the 

414 folder ``display_name`` will be rejected if they violate either 

415 the ``display_name`` formatting rules or the naming constraints 

416 described in the 

417 [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder] 

418 documentation. 

419 

420 The folder's ``display_name`` must start and end with a letter 

421 or digit, may contain letters, digits, spaces, hyphens and 

422 underscores and can be between 3 and 30 characters. This is 

423 captured by the regular expression: 

424 ``[\p{L}\p{N}][\p{L}\p{N}_- ]{1,28}[\p{L}\p{N}]``. The caller 

425 must have ``resourcemanager.folders.update`` permission on the 

426 identified folder. 

427 

428 If the update fails due to the unique name constraint then a 

429 ``PreconditionFailure`` explaining this violation will be 

430 returned in the Status.details field. 

431 

432 Returns: 

433 Callable[[~.UpdateFolderRequest], 

434 Awaitable[~.Operation]]: 

435 A function that, when called, will call the underlying RPC 

436 on the server. 

437 """ 

438 # Generate a "stub function" on-the-fly which will actually make 

439 # the request. 

440 # gRPC handles serialization and deserialization, so we just need 

441 # to pass in the functions for each. 

442 if "update_folder" not in self._stubs: 

443 self._stubs["update_folder"] = self.grpc_channel.unary_unary( 

444 "/google.cloud.resourcemanager.v3.Folders/UpdateFolder", 

445 request_serializer=folders.UpdateFolderRequest.serialize, 

446 response_deserializer=operations_pb2.Operation.FromString, 

447 ) 

448 return self._stubs["update_folder"] 

449 

450 @property 

451 def move_folder( 

452 self, 

453 ) -> Callable[[folders.MoveFolderRequest], Awaitable[operations_pb2.Operation]]: 

454 r"""Return a callable for the move folder method over gRPC. 

455 

456 Moves a folder under a new resource parent. Returns an 

457 ``Operation`` which can be used to track the progress of the 

458 folder move workflow. Upon success, the ``Operation.response`` 

459 field will be populated with the moved folder. Upon failure, a 

460 ``FolderOperationError`` categorizing the failure cause will be 

461 returned - if the failure occurs synchronously then the 

462 ``FolderOperationError`` will be returned in the 

463 ``Status.details`` field. If it occurs asynchronously, then the 

464 FolderOperation will be returned in the ``Operation.error`` 

465 field. In addition, the ``Operation.metadata`` field will be 

466 populated with a ``FolderOperation`` message as an aid to 

467 stateless clients. Folder moves will be rejected if they violate 

468 either the naming, height, or fanout constraints described in 

469 the 

470 [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder] 

471 documentation. The caller must have 

472 ``resourcemanager.folders.move`` permission on the folder's 

473 current and proposed new parent. 

474 

475 Returns: 

476 Callable[[~.MoveFolderRequest], 

477 Awaitable[~.Operation]]: 

478 A function that, when called, will call the underlying RPC 

479 on the server. 

480 """ 

481 # Generate a "stub function" on-the-fly which will actually make 

482 # the request. 

483 # gRPC handles serialization and deserialization, so we just need 

484 # to pass in the functions for each. 

485 if "move_folder" not in self._stubs: 

486 self._stubs["move_folder"] = self.grpc_channel.unary_unary( 

487 "/google.cloud.resourcemanager.v3.Folders/MoveFolder", 

488 request_serializer=folders.MoveFolderRequest.serialize, 

489 response_deserializer=operations_pb2.Operation.FromString, 

490 ) 

491 return self._stubs["move_folder"] 

492 

493 @property 

494 def delete_folder( 

495 self, 

496 ) -> Callable[[folders.DeleteFolderRequest], Awaitable[operations_pb2.Operation]]: 

497 r"""Return a callable for the delete folder method over gRPC. 

498 

499 Requests deletion of a folder. The folder is moved into the 

500 [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED] 

501 state immediately, and is deleted approximately 30 days later. 

502 This method may only be called on an empty folder, where a 

503 folder is empty if it doesn't contain any folders or projects in 

504 the 

505 [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] 

506 state. If called on a folder in 

507 [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED] 

508 state the operation will result in a no-op success. The caller 

509 must have ``resourcemanager.folders.delete`` permission on the 

510 identified folder. 

511 

512 Returns: 

513 Callable[[~.DeleteFolderRequest], 

514 Awaitable[~.Operation]]: 

515 A function that, when called, will call the underlying RPC 

516 on the server. 

517 """ 

518 # Generate a "stub function" on-the-fly which will actually make 

519 # the request. 

520 # gRPC handles serialization and deserialization, so we just need 

521 # to pass in the functions for each. 

522 if "delete_folder" not in self._stubs: 

523 self._stubs["delete_folder"] = self.grpc_channel.unary_unary( 

524 "/google.cloud.resourcemanager.v3.Folders/DeleteFolder", 

525 request_serializer=folders.DeleteFolderRequest.serialize, 

526 response_deserializer=operations_pb2.Operation.FromString, 

527 ) 

528 return self._stubs["delete_folder"] 

529 

530 @property 

531 def undelete_folder( 

532 self, 

533 ) -> Callable[[folders.UndeleteFolderRequest], Awaitable[operations_pb2.Operation]]: 

534 r"""Return a callable for the undelete folder method over gRPC. 

535 

536 Cancels the deletion request for a folder. This method may be 

537 called on a folder in any state. If the folder is in the 

538 [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] 

539 state the result will be a no-op success. In order to succeed, 

540 the folder's parent must be in the 

541 [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] 

542 state. In addition, reintroducing the folder into the tree must 

543 not violate folder naming, height, and fanout constraints 

544 described in the 

545 [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder] 

546 documentation. The caller must have 

547 ``resourcemanager.folders.undelete`` permission on the 

548 identified folder. 

549 

550 Returns: 

551 Callable[[~.UndeleteFolderRequest], 

552 Awaitable[~.Operation]]: 

553 A function that, when called, will call the underlying RPC 

554 on the server. 

555 """ 

556 # Generate a "stub function" on-the-fly which will actually make 

557 # the request. 

558 # gRPC handles serialization and deserialization, so we just need 

559 # to pass in the functions for each. 

560 if "undelete_folder" not in self._stubs: 

561 self._stubs["undelete_folder"] = self.grpc_channel.unary_unary( 

562 "/google.cloud.resourcemanager.v3.Folders/UndeleteFolder", 

563 request_serializer=folders.UndeleteFolderRequest.serialize, 

564 response_deserializer=operations_pb2.Operation.FromString, 

565 ) 

566 return self._stubs["undelete_folder"] 

567 

568 @property 

569 def get_iam_policy( 

570 self, 

571 ) -> Callable[[iam_policy_pb2.GetIamPolicyRequest], Awaitable[policy_pb2.Policy]]: 

572 r"""Return a callable for the get iam policy method over gRPC. 

573 

574 Gets the access control policy for a folder. The returned policy 

575 may be empty if no such policy or resource exists. The 

576 ``resource`` field should be the folder's resource name, for 

577 example: "folders/1234". The caller must have 

578 ``resourcemanager.folders.getIamPolicy`` permission on the 

579 identified folder. 

580 

581 Returns: 

582 Callable[[~.GetIamPolicyRequest], 

583 Awaitable[~.Policy]]: 

584 A function that, when called, will call the underlying RPC 

585 on the server. 

586 """ 

587 # Generate a "stub function" on-the-fly which will actually make 

588 # the request. 

589 # gRPC handles serialization and deserialization, so we just need 

590 # to pass in the functions for each. 

591 if "get_iam_policy" not in self._stubs: 

592 self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( 

593 "/google.cloud.resourcemanager.v3.Folders/GetIamPolicy", 

594 request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, 

595 response_deserializer=policy_pb2.Policy.FromString, 

596 ) 

597 return self._stubs["get_iam_policy"] 

598 

599 @property 

600 def set_iam_policy( 

601 self, 

602 ) -> Callable[[iam_policy_pb2.SetIamPolicyRequest], Awaitable[policy_pb2.Policy]]: 

603 r"""Return a callable for the set iam policy method over gRPC. 

604 

605 Sets the access control policy on a folder, replacing any 

606 existing policy. The ``resource`` field should be the folder's 

607 resource name, for example: "folders/1234". The caller must have 

608 ``resourcemanager.folders.setIamPolicy`` permission on the 

609 identified folder. 

610 

611 Returns: 

612 Callable[[~.SetIamPolicyRequest], 

613 Awaitable[~.Policy]]: 

614 A function that, when called, will call the underlying RPC 

615 on the server. 

616 """ 

617 # Generate a "stub function" on-the-fly which will actually make 

618 # the request. 

619 # gRPC handles serialization and deserialization, so we just need 

620 # to pass in the functions for each. 

621 if "set_iam_policy" not in self._stubs: 

622 self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( 

623 "/google.cloud.resourcemanager.v3.Folders/SetIamPolicy", 

624 request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, 

625 response_deserializer=policy_pb2.Policy.FromString, 

626 ) 

627 return self._stubs["set_iam_policy"] 

628 

629 @property 

630 def test_iam_permissions( 

631 self, 

632 ) -> Callable[ 

633 [iam_policy_pb2.TestIamPermissionsRequest], 

634 Awaitable[iam_policy_pb2.TestIamPermissionsResponse], 

635 ]: 

636 r"""Return a callable for the test iam permissions method over gRPC. 

637 

638 Returns permissions that a caller has on the specified folder. 

639 The ``resource`` field should be the folder's resource name, for 

640 example: "folders/1234". 

641 

642 There are no permissions required for making this API call. 

643 

644 Returns: 

645 Callable[[~.TestIamPermissionsRequest], 

646 Awaitable[~.TestIamPermissionsResponse]]: 

647 A function that, when called, will call the underlying RPC 

648 on the server. 

649 """ 

650 # Generate a "stub function" on-the-fly which will actually make 

651 # the request. 

652 # gRPC handles serialization and deserialization, so we just need 

653 # to pass in the functions for each. 

654 if "test_iam_permissions" not in self._stubs: 

655 self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( 

656 "/google.cloud.resourcemanager.v3.Folders/TestIamPermissions", 

657 request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, 

658 response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, 

659 ) 

660 return self._stubs["test_iam_permissions"] 

661 

662 def close(self): 

663 return self.grpc_channel.close() 

664 

665 @property 

666 def get_operation( 

667 self, 

668 ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]: 

669 r"""Return a callable for the get_operation method over gRPC.""" 

670 # Generate a "stub function" on-the-fly which will actually make 

671 # the request. 

672 # gRPC handles serialization and deserialization, so we just need 

673 # to pass in the functions for each. 

674 if "get_operation" not in self._stubs: 

675 self._stubs["get_operation"] = self.grpc_channel.unary_unary( 

676 "/google.longrunning.Operations/GetOperation", 

677 request_serializer=operations_pb2.GetOperationRequest.SerializeToString, 

678 response_deserializer=operations_pb2.Operation.FromString, 

679 ) 

680 return self._stubs["get_operation"] 

681 

682 

683__all__ = ("FoldersGrpcAsyncIOTransport",)