Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/google/pubsub_v1/services/schema_service/async_client.py: 33%

199 statements  

« prev     ^ index     » next       coverage.py v7.2.2, created at 2023-03-26 06:25 +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 collections import OrderedDict 

17import functools 

18import re 

19from typing import ( 

20 Dict, 

21 Mapping, 

22 MutableMapping, 

23 MutableSequence, 

24 Optional, 

25 Sequence, 

26 Tuple, 

27 Type, 

28 Union, 

29) 

30 

31from google.pubsub_v1 import gapic_version as package_version 

32 

33from google.api_core.client_options import ClientOptions 

34from google.api_core import exceptions as core_exceptions 

35from google.api_core import gapic_v1 

36from google.api_core import retry as retries 

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

38from google.oauth2 import service_account # type: ignore 

39 

40try: 

41 OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] 

42except AttributeError: # pragma: NO COVER 

43 OptionalRetry = Union[retries.Retry, object] # type: ignore 

44 

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

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

47from google.protobuf import timestamp_pb2 # type: ignore 

48from google.pubsub_v1.services.schema_service import pagers 

49from google.pubsub_v1.types import schema 

50from google.pubsub_v1.types import schema as gp_schema 

51from .transports.base import SchemaServiceTransport, DEFAULT_CLIENT_INFO 

52from .transports.grpc_asyncio import SchemaServiceGrpcAsyncIOTransport 

53from .client import SchemaServiceClient 

54 

55 

56class SchemaServiceAsyncClient: 

57 """Service for doing schema-related operations.""" 

58 

59 _client: SchemaServiceClient 

60 

61 DEFAULT_ENDPOINT = SchemaServiceClient.DEFAULT_ENDPOINT 

62 DEFAULT_MTLS_ENDPOINT = SchemaServiceClient.DEFAULT_MTLS_ENDPOINT 

63 

64 schema_path = staticmethod(SchemaServiceClient.schema_path) 

65 parse_schema_path = staticmethod(SchemaServiceClient.parse_schema_path) 

66 common_billing_account_path = staticmethod( 

67 SchemaServiceClient.common_billing_account_path 

68 ) 

69 parse_common_billing_account_path = staticmethod( 

70 SchemaServiceClient.parse_common_billing_account_path 

71 ) 

72 common_folder_path = staticmethod(SchemaServiceClient.common_folder_path) 

73 parse_common_folder_path = staticmethod( 

74 SchemaServiceClient.parse_common_folder_path 

75 ) 

76 common_organization_path = staticmethod( 

77 SchemaServiceClient.common_organization_path 

78 ) 

79 parse_common_organization_path = staticmethod( 

80 SchemaServiceClient.parse_common_organization_path 

81 ) 

82 common_project_path = staticmethod(SchemaServiceClient.common_project_path) 

83 parse_common_project_path = staticmethod( 

84 SchemaServiceClient.parse_common_project_path 

85 ) 

86 common_location_path = staticmethod(SchemaServiceClient.common_location_path) 

87 parse_common_location_path = staticmethod( 

88 SchemaServiceClient.parse_common_location_path 

89 ) 

90 

91 @classmethod 

92 def from_service_account_info(cls, info: dict, *args, **kwargs): 

93 """Creates an instance of this client using the provided credentials 

94 info. 

95 

96 Args: 

97 info (dict): The service account private key info. 

98 args: Additional arguments to pass to the constructor. 

99 kwargs: Additional arguments to pass to the constructor. 

100 

101 Returns: 

102 SchemaServiceAsyncClient: The constructed client. 

103 """ 

104 return SchemaServiceClient.from_service_account_info.__func__(SchemaServiceAsyncClient, info, *args, **kwargs) # type: ignore 

105 

106 @classmethod 

107 def from_service_account_file(cls, filename: str, *args, **kwargs): 

108 """Creates an instance of this client using the provided credentials 

109 file. 

110 

111 Args: 

112 filename (str): The path to the service account private key json 

113 file. 

114 args: Additional arguments to pass to the constructor. 

115 kwargs: Additional arguments to pass to the constructor. 

116 

117 Returns: 

118 SchemaServiceAsyncClient: The constructed client. 

119 """ 

120 return SchemaServiceClient.from_service_account_file.__func__(SchemaServiceAsyncClient, filename, *args, **kwargs) # type: ignore 

121 

122 from_service_account_json = from_service_account_file 

123 

124 @classmethod 

125 def get_mtls_endpoint_and_cert_source( 

126 cls, client_options: Optional[ClientOptions] = None 

127 ): 

128 """Return the API endpoint and client cert source for mutual TLS. 

129 

130 The client cert source is determined in the following order: 

131 (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the 

132 client cert source is None. 

133 (2) if `client_options.client_cert_source` is provided, use the provided one; if the 

134 default client cert source exists, use the default one; otherwise the client cert 

135 source is None. 

136 

137 The API endpoint is determined in the following order: 

138 (1) if `client_options.api_endpoint` if provided, use the provided one. 

139 (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the 

140 default mTLS endpoint; if the environment variable is "never", use the default API 

141 endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise 

142 use the default API endpoint. 

143 

144 More details can be found at https://google.aip.dev/auth/4114. 

145 

146 Args: 

147 client_options (google.api_core.client_options.ClientOptions): Custom options for the 

148 client. Only the `api_endpoint` and `client_cert_source` properties may be used 

149 in this method. 

150 

151 Returns: 

152 Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the 

153 client cert source to use. 

154 

155 Raises: 

156 google.auth.exceptions.MutualTLSChannelError: If any errors happen. 

157 """ 

158 return SchemaServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore 

159 

160 @property 

161 def transport(self) -> SchemaServiceTransport: 

162 """Returns the transport used by the client instance. 

163 

164 Returns: 

165 SchemaServiceTransport: The transport used by the client instance. 

166 """ 

167 return self._client.transport 

168 

169 get_transport_class = functools.partial( 

170 type(SchemaServiceClient).get_transport_class, type(SchemaServiceClient) 

171 ) 

172 

173 def __init__( 

174 self, 

175 *, 

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

177 transport: Union[str, SchemaServiceTransport] = "grpc_asyncio", 

178 client_options: Optional[ClientOptions] = None, 

179 client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, 

180 ) -> None: 

181 """Instantiates the schema service client. 

182 

183 Args: 

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

185 authorization credentials to attach to requests. These 

186 credentials identify the application to the service; if none 

187 are specified, the client will attempt to ascertain the 

188 credentials from the environment. 

189 transport (Union[str, ~.SchemaServiceTransport]): The 

190 transport to use. If set to None, a transport is chosen 

191 automatically. 

192 client_options (ClientOptions): Custom options for the client. It 

193 won't take effect if a ``transport`` instance is provided. 

194 (1) The ``api_endpoint`` property can be used to override the 

195 default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT 

196 environment variable can also be used to override the endpoint: 

197 "always" (always use the default mTLS endpoint), "never" (always 

198 use the default regular endpoint) and "auto" (auto switch to the 

199 default mTLS endpoint if client certificate is present, this is 

200 the default value). However, the ``api_endpoint`` property takes 

201 precedence if provided. 

202 (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable 

203 is "true", then the ``client_cert_source`` property can be used 

204 to provide client certificate for mutual TLS transport. If 

205 not provided, the default SSL client certificate will be used if 

206 present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not 

207 set, no client certificate will be used. 

208 

209 Raises: 

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

211 creation failed for any reason. 

212 """ 

213 self._client = SchemaServiceClient( 

214 credentials=credentials, 

215 transport=transport, 

216 client_options=client_options, 

217 client_info=client_info, 

218 ) 

219 

220 async def create_schema( 

221 self, 

222 request: Optional[Union[gp_schema.CreateSchemaRequest, dict]] = None, 

223 *, 

224 parent: Optional[str] = None, 

225 schema: Optional[gp_schema.Schema] = None, 

226 schema_id: Optional[str] = None, 

227 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

228 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

229 metadata: Sequence[Tuple[str, str]] = (), 

230 ) -> gp_schema.Schema: 

231 r"""Creates a schema. 

232 

233 .. code-block:: python 

234 

235 # This snippet has been automatically generated and should be regarded as a 

236 # code template only. 

237 # It will require modifications to work: 

238 # - It may require correct/in-range values for request initialization. 

239 # - It may require specifying regional endpoints when creating the service 

240 # client as shown in: 

241 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

242 from google import pubsub_v1 

243 

244 async def sample_create_schema(): 

245 # Create a client 

246 client = pubsub_v1.SchemaServiceAsyncClient() 

247 

248 # Initialize request argument(s) 

249 schema = pubsub_v1.Schema() 

250 schema.name = "name_value" 

251 

252 request = pubsub_v1.CreateSchemaRequest( 

253 parent="parent_value", 

254 schema=schema, 

255 ) 

256 

257 # Make the request 

258 response = await client.create_schema(request=request) 

259 

260 # Handle the response 

261 print(response) 

262 

263 Args: 

264 request (Optional[Union[google.pubsub_v1.types.CreateSchemaRequest, dict]]): 

265 The request object. Request for the CreateSchema method. 

266 parent (:class:`str`): 

267 Required. The name of the project in which to create the 

268 schema. Format is ``projects/{project-id}``. 

269 

270 This corresponds to the ``parent`` field 

271 on the ``request`` instance; if ``request`` is provided, this 

272 should not be set. 

273 schema (:class:`google.pubsub_v1.types.Schema`): 

274 Required. The schema object to create. 

275 

276 This schema's ``name`` parameter is ignored. The schema 

277 object returned by CreateSchema will have a ``name`` 

278 made using the given ``parent`` and ``schema_id``. 

279 

280 This corresponds to the ``schema`` field 

281 on the ``request`` instance; if ``request`` is provided, this 

282 should not be set. 

283 schema_id (:class:`str`): 

284 The ID to use for the schema, which will become the 

285 final component of the schema's resource name. 

286 

287 See 

288 https://cloud.google.com/pubsub/docs/admin#resource_names 

289 for resource name constraints. 

290 

291 This corresponds to the ``schema_id`` field 

292 on the ``request`` instance; if ``request`` is provided, this 

293 should not be set. 

294 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

295 should be retried. 

296 timeout (float): The timeout for this request. 

297 metadata (Sequence[Tuple[str, str]]): Strings which should be 

298 sent along with the request as metadata. 

299 

300 Returns: 

301 google.pubsub_v1.types.Schema: 

302 A schema resource. 

303 """ 

304 # Create or coerce a protobuf request object. 

305 # Quick check: If we got a request object, we should *not* have 

306 # gotten any keyword arguments that map to the request. 

307 has_flattened_params = any([parent, schema, schema_id]) 

308 if request is not None and has_flattened_params: 

309 raise ValueError( 

310 "If the `request` argument is set, then none of " 

311 "the individual field arguments should be set." 

312 ) 

313 

314 request = gp_schema.CreateSchemaRequest(request) 

315 

316 # If we have keyword arguments corresponding to fields on the 

317 # request, apply these. 

318 if parent is not None: 

319 request.parent = parent 

320 if schema is not None: 

321 request.schema = schema 

322 if schema_id is not None: 

323 request.schema_id = schema_id 

324 

325 # Wrap the RPC method; this adds retry and timeout information, 

326 # and friendly error handling. 

327 rpc = gapic_v1.method_async.wrap_method( 

328 self._client._transport.create_schema, 

329 default_timeout=None, 

330 client_info=DEFAULT_CLIENT_INFO, 

331 ) 

332 

333 # Certain fields should be provided within the metadata header; 

334 # add these here. 

335 metadata = tuple(metadata) + ( 

336 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), 

337 ) 

338 

339 # Send the request. 

340 response = await rpc( 

341 request, 

342 retry=retry, 

343 timeout=timeout, 

344 metadata=metadata, 

345 ) 

346 

347 # Done; return the response. 

348 return response 

349 

350 async def get_schema( 

351 self, 

352 request: Optional[Union[schema.GetSchemaRequest, dict]] = None, 

353 *, 

354 name: Optional[str] = None, 

355 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

356 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

357 metadata: Sequence[Tuple[str, str]] = (), 

358 ) -> schema.Schema: 

359 r"""Gets a schema. 

360 

361 .. code-block:: python 

362 

363 # This snippet has been automatically generated and should be regarded as a 

364 # code template only. 

365 # It will require modifications to work: 

366 # - It may require correct/in-range values for request initialization. 

367 # - It may require specifying regional endpoints when creating the service 

368 # client as shown in: 

369 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

370 from google import pubsub_v1 

371 

372 async def sample_get_schema(): 

373 # Create a client 

374 client = pubsub_v1.SchemaServiceAsyncClient() 

375 

376 # Initialize request argument(s) 

377 request = pubsub_v1.GetSchemaRequest( 

378 name="name_value", 

379 ) 

380 

381 # Make the request 

382 response = await client.get_schema(request=request) 

383 

384 # Handle the response 

385 print(response) 

386 

387 Args: 

388 request (Optional[Union[google.pubsub_v1.types.GetSchemaRequest, dict]]): 

389 The request object. Request for the GetSchema method. 

390 name (:class:`str`): 

391 Required. The name of the schema to get. Format is 

392 ``projects/{project}/schemas/{schema}``. 

393 

394 This corresponds to the ``name`` field 

395 on the ``request`` instance; if ``request`` is provided, this 

396 should not be set. 

397 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

398 should be retried. 

399 timeout (float): The timeout for this request. 

400 metadata (Sequence[Tuple[str, str]]): Strings which should be 

401 sent along with the request as metadata. 

402 

403 Returns: 

404 google.pubsub_v1.types.Schema: 

405 A schema resource. 

406 """ 

407 # Create or coerce a protobuf request object. 

408 # Quick check: If we got a request object, we should *not* have 

409 # gotten any keyword arguments that map to the request. 

410 has_flattened_params = any([name]) 

411 if request is not None and has_flattened_params: 

412 raise ValueError( 

413 "If the `request` argument is set, then none of " 

414 "the individual field arguments should be set." 

415 ) 

416 

417 request = schema.GetSchemaRequest(request) 

418 

419 # If we have keyword arguments corresponding to fields on the 

420 # request, apply these. 

421 if name is not None: 

422 request.name = name 

423 

424 # Wrap the RPC method; this adds retry and timeout information, 

425 # and friendly error handling. 

426 rpc = gapic_v1.method_async.wrap_method( 

427 self._client._transport.get_schema, 

428 default_timeout=None, 

429 client_info=DEFAULT_CLIENT_INFO, 

430 ) 

431 

432 # Certain fields should be provided within the metadata header; 

433 # add these here. 

434 metadata = tuple(metadata) + ( 

435 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

436 ) 

437 

438 # Send the request. 

439 response = await rpc( 

440 request, 

441 retry=retry, 

442 timeout=timeout, 

443 metadata=metadata, 

444 ) 

445 

446 # Done; return the response. 

447 return response 

448 

449 async def list_schemas( 

450 self, 

451 request: Optional[Union[schema.ListSchemasRequest, dict]] = None, 

452 *, 

453 parent: Optional[str] = None, 

454 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

455 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

456 metadata: Sequence[Tuple[str, str]] = (), 

457 ) -> pagers.ListSchemasAsyncPager: 

458 r"""Lists schemas in a project. 

459 

460 .. code-block:: python 

461 

462 # This snippet has been automatically generated and should be regarded as a 

463 # code template only. 

464 # It will require modifications to work: 

465 # - It may require correct/in-range values for request initialization. 

466 # - It may require specifying regional endpoints when creating the service 

467 # client as shown in: 

468 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

469 from google import pubsub_v1 

470 

471 async def sample_list_schemas(): 

472 # Create a client 

473 client = pubsub_v1.SchemaServiceAsyncClient() 

474 

475 # Initialize request argument(s) 

476 request = pubsub_v1.ListSchemasRequest( 

477 parent="parent_value", 

478 ) 

479 

480 # Make the request 

481 page_result = client.list_schemas(request=request) 

482 

483 # Handle the response 

484 async for response in page_result: 

485 print(response) 

486 

487 Args: 

488 request (Optional[Union[google.pubsub_v1.types.ListSchemasRequest, dict]]): 

489 The request object. Request for the `ListSchemas` 

490 method. 

491 parent (:class:`str`): 

492 Required. The name of the project in which to list 

493 schemas. Format is ``projects/{project-id}``. 

494 

495 This corresponds to the ``parent`` field 

496 on the ``request`` instance; if ``request`` is provided, this 

497 should not be set. 

498 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

499 should be retried. 

500 timeout (float): The timeout for this request. 

501 metadata (Sequence[Tuple[str, str]]): Strings which should be 

502 sent along with the request as metadata. 

503 

504 Returns: 

505 google.pubsub_v1.services.schema_service.pagers.ListSchemasAsyncPager: 

506 Response for the ListSchemas method. 

507 

508 Iterating over this object will yield results and 

509 resolve additional pages automatically. 

510 

511 """ 

512 # Create or coerce a protobuf request object. 

513 # Quick check: If we got a request object, we should *not* have 

514 # gotten any keyword arguments that map to the request. 

515 has_flattened_params = any([parent]) 

516 if request is not None and has_flattened_params: 

517 raise ValueError( 

518 "If the `request` argument is set, then none of " 

519 "the individual field arguments should be set." 

520 ) 

521 

522 request = schema.ListSchemasRequest(request) 

523 

524 # If we have keyword arguments corresponding to fields on the 

525 # request, apply these. 

526 if parent is not None: 

527 request.parent = parent 

528 

529 # Wrap the RPC method; this adds retry and timeout information, 

530 # and friendly error handling. 

531 rpc = gapic_v1.method_async.wrap_method( 

532 self._client._transport.list_schemas, 

533 default_timeout=None, 

534 client_info=DEFAULT_CLIENT_INFO, 

535 ) 

536 

537 # Certain fields should be provided within the metadata header; 

538 # add these here. 

539 metadata = tuple(metadata) + ( 

540 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), 

541 ) 

542 

543 # Send the request. 

544 response = await rpc( 

545 request, 

546 retry=retry, 

547 timeout=timeout, 

548 metadata=metadata, 

549 ) 

550 

551 # This method is paged; wrap the response in a pager, which provides 

552 # an `__aiter__` convenience method. 

553 response = pagers.ListSchemasAsyncPager( 

554 method=rpc, 

555 request=request, 

556 response=response, 

557 metadata=metadata, 

558 ) 

559 

560 # Done; return the response. 

561 return response 

562 

563 async def list_schema_revisions( 

564 self, 

565 request: Optional[Union[schema.ListSchemaRevisionsRequest, dict]] = None, 

566 *, 

567 name: Optional[str] = None, 

568 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

569 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

570 metadata: Sequence[Tuple[str, str]] = (), 

571 ) -> pagers.ListSchemaRevisionsAsyncPager: 

572 r"""Lists all schema revisions for the named schema. 

573 

574 .. code-block:: python 

575 

576 # This snippet has been automatically generated and should be regarded as a 

577 # code template only. 

578 # It will require modifications to work: 

579 # - It may require correct/in-range values for request initialization. 

580 # - It may require specifying regional endpoints when creating the service 

581 # client as shown in: 

582 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

583 from google import pubsub_v1 

584 

585 async def sample_list_schema_revisions(): 

586 # Create a client 

587 client = pubsub_v1.SchemaServiceAsyncClient() 

588 

589 # Initialize request argument(s) 

590 request = pubsub_v1.ListSchemaRevisionsRequest( 

591 name="name_value", 

592 ) 

593 

594 # Make the request 

595 page_result = client.list_schema_revisions(request=request) 

596 

597 # Handle the response 

598 async for response in page_result: 

599 print(response) 

600 

601 Args: 

602 request (Optional[Union[google.pubsub_v1.types.ListSchemaRevisionsRequest, dict]]): 

603 The request object. Request for the 

604 `ListSchemaRevisions` method. 

605 name (:class:`str`): 

606 Required. The name of the schema to 

607 list revisions for. 

608 

609 This corresponds to the ``name`` field 

610 on the ``request`` instance; if ``request`` is provided, this 

611 should not be set. 

612 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

613 should be retried. 

614 timeout (float): The timeout for this request. 

615 metadata (Sequence[Tuple[str, str]]): Strings which should be 

616 sent along with the request as metadata. 

617 

618 Returns: 

619 google.pubsub_v1.services.schema_service.pagers.ListSchemaRevisionsAsyncPager: 

620 Response for the ListSchemaRevisions method. 

621 

622 Iterating over this object will yield results and 

623 resolve additional pages automatically. 

624 

625 """ 

626 # Create or coerce a protobuf request object. 

627 # Quick check: If we got a request object, we should *not* have 

628 # gotten any keyword arguments that map to the request. 

629 has_flattened_params = any([name]) 

630 if request is not None and has_flattened_params: 

631 raise ValueError( 

632 "If the `request` argument is set, then none of " 

633 "the individual field arguments should be set." 

634 ) 

635 

636 request = schema.ListSchemaRevisionsRequest(request) 

637 

638 # If we have keyword arguments corresponding to fields on the 

639 # request, apply these. 

640 if name is not None: 

641 request.name = name 

642 

643 # Wrap the RPC method; this adds retry and timeout information, 

644 # and friendly error handling. 

645 rpc = gapic_v1.method_async.wrap_method( 

646 self._client._transport.list_schema_revisions, 

647 default_timeout=None, 

648 client_info=DEFAULT_CLIENT_INFO, 

649 ) 

650 

651 # Certain fields should be provided within the metadata header; 

652 # add these here. 

653 metadata = tuple(metadata) + ( 

654 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

655 ) 

656 

657 # Send the request. 

658 response = await rpc( 

659 request, 

660 retry=retry, 

661 timeout=timeout, 

662 metadata=metadata, 

663 ) 

664 

665 # This method is paged; wrap the response in a pager, which provides 

666 # an `__aiter__` convenience method. 

667 response = pagers.ListSchemaRevisionsAsyncPager( 

668 method=rpc, 

669 request=request, 

670 response=response, 

671 metadata=metadata, 

672 ) 

673 

674 # Done; return the response. 

675 return response 

676 

677 async def commit_schema( 

678 self, 

679 request: Optional[Union[gp_schema.CommitSchemaRequest, dict]] = None, 

680 *, 

681 name: Optional[str] = None, 

682 schema: Optional[gp_schema.Schema] = None, 

683 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

684 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

685 metadata: Sequence[Tuple[str, str]] = (), 

686 ) -> gp_schema.Schema: 

687 r"""Commits a new schema revision to an existing schema. 

688 

689 .. code-block:: python 

690 

691 # This snippet has been automatically generated and should be regarded as a 

692 # code template only. 

693 # It will require modifications to work: 

694 # - It may require correct/in-range values for request initialization. 

695 # - It may require specifying regional endpoints when creating the service 

696 # client as shown in: 

697 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

698 from google import pubsub_v1 

699 

700 async def sample_commit_schema(): 

701 # Create a client 

702 client = pubsub_v1.SchemaServiceAsyncClient() 

703 

704 # Initialize request argument(s) 

705 schema = pubsub_v1.Schema() 

706 schema.name = "name_value" 

707 

708 request = pubsub_v1.CommitSchemaRequest( 

709 name="name_value", 

710 schema=schema, 

711 ) 

712 

713 # Make the request 

714 response = await client.commit_schema(request=request) 

715 

716 # Handle the response 

717 print(response) 

718 

719 Args: 

720 request (Optional[Union[google.pubsub_v1.types.CommitSchemaRequest, dict]]): 

721 The request object. Request for CommitSchema method. 

722 name (:class:`str`): 

723 Required. The name of the schema we are revising. Format 

724 is ``projects/{project}/schemas/{schema}``. 

725 

726 This corresponds to the ``name`` field 

727 on the ``request`` instance; if ``request`` is provided, this 

728 should not be set. 

729 schema (:class:`google.pubsub_v1.types.Schema`): 

730 Required. The schema revision to 

731 commit. 

732 

733 This corresponds to the ``schema`` field 

734 on the ``request`` instance; if ``request`` is provided, this 

735 should not be set. 

736 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

737 should be retried. 

738 timeout (float): The timeout for this request. 

739 metadata (Sequence[Tuple[str, str]]): Strings which should be 

740 sent along with the request as metadata. 

741 

742 Returns: 

743 google.pubsub_v1.types.Schema: 

744 A schema resource. 

745 """ 

746 # Create or coerce a protobuf request object. 

747 # Quick check: If we got a request object, we should *not* have 

748 # gotten any keyword arguments that map to the request. 

749 has_flattened_params = any([name, schema]) 

750 if request is not None and has_flattened_params: 

751 raise ValueError( 

752 "If the `request` argument is set, then none of " 

753 "the individual field arguments should be set." 

754 ) 

755 

756 request = gp_schema.CommitSchemaRequest(request) 

757 

758 # If we have keyword arguments corresponding to fields on the 

759 # request, apply these. 

760 if name is not None: 

761 request.name = name 

762 if schema is not None: 

763 request.schema = schema 

764 

765 # Wrap the RPC method; this adds retry and timeout information, 

766 # and friendly error handling. 

767 rpc = gapic_v1.method_async.wrap_method( 

768 self._client._transport.commit_schema, 

769 default_timeout=None, 

770 client_info=DEFAULT_CLIENT_INFO, 

771 ) 

772 

773 # Certain fields should be provided within the metadata header; 

774 # add these here. 

775 metadata = tuple(metadata) + ( 

776 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

777 ) 

778 

779 # Send the request. 

780 response = await rpc( 

781 request, 

782 retry=retry, 

783 timeout=timeout, 

784 metadata=metadata, 

785 ) 

786 

787 # Done; return the response. 

788 return response 

789 

790 async def rollback_schema( 

791 self, 

792 request: Optional[Union[schema.RollbackSchemaRequest, dict]] = None, 

793 *, 

794 name: Optional[str] = None, 

795 revision_id: Optional[str] = None, 

796 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

797 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

798 metadata: Sequence[Tuple[str, str]] = (), 

799 ) -> schema.Schema: 

800 r"""Creates a new schema revision that is a copy of the provided 

801 revision_id. 

802 

803 .. code-block:: python 

804 

805 # This snippet has been automatically generated and should be regarded as a 

806 # code template only. 

807 # It will require modifications to work: 

808 # - It may require correct/in-range values for request initialization. 

809 # - It may require specifying regional endpoints when creating the service 

810 # client as shown in: 

811 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

812 from google import pubsub_v1 

813 

814 async def sample_rollback_schema(): 

815 # Create a client 

816 client = pubsub_v1.SchemaServiceAsyncClient() 

817 

818 # Initialize request argument(s) 

819 request = pubsub_v1.RollbackSchemaRequest( 

820 name="name_value", 

821 revision_id="revision_id_value", 

822 ) 

823 

824 # Make the request 

825 response = await client.rollback_schema(request=request) 

826 

827 # Handle the response 

828 print(response) 

829 

830 Args: 

831 request (Optional[Union[google.pubsub_v1.types.RollbackSchemaRequest, dict]]): 

832 The request object. Request for the `RollbackSchema` 

833 method. 

834 name (:class:`str`): 

835 Required. The schema being rolled 

836 back with revision id. 

837 

838 This corresponds to the ``name`` field 

839 on the ``request`` instance; if ``request`` is provided, this 

840 should not be set. 

841 revision_id (:class:`str`): 

842 Required. The revision ID to roll 

843 back to. It must be a revision of the 

844 same schema. 

845 Example: c7cfa2a8 

846 

847 This corresponds to the ``revision_id`` field 

848 on the ``request`` instance; if ``request`` is provided, this 

849 should not be set. 

850 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

851 should be retried. 

852 timeout (float): The timeout for this request. 

853 metadata (Sequence[Tuple[str, str]]): Strings which should be 

854 sent along with the request as metadata. 

855 

856 Returns: 

857 google.pubsub_v1.types.Schema: 

858 A schema resource. 

859 """ 

860 # Create or coerce a protobuf request object. 

861 # Quick check: If we got a request object, we should *not* have 

862 # gotten any keyword arguments that map to the request. 

863 has_flattened_params = any([name, revision_id]) 

864 if request is not None and has_flattened_params: 

865 raise ValueError( 

866 "If the `request` argument is set, then none of " 

867 "the individual field arguments should be set." 

868 ) 

869 

870 request = schema.RollbackSchemaRequest(request) 

871 

872 # If we have keyword arguments corresponding to fields on the 

873 # request, apply these. 

874 if name is not None: 

875 request.name = name 

876 if revision_id is not None: 

877 request.revision_id = revision_id 

878 

879 # Wrap the RPC method; this adds retry and timeout information, 

880 # and friendly error handling. 

881 rpc = gapic_v1.method_async.wrap_method( 

882 self._client._transport.rollback_schema, 

883 default_timeout=None, 

884 client_info=DEFAULT_CLIENT_INFO, 

885 ) 

886 

887 # Certain fields should be provided within the metadata header; 

888 # add these here. 

889 metadata = tuple(metadata) + ( 

890 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

891 ) 

892 

893 # Send the request. 

894 response = await rpc( 

895 request, 

896 retry=retry, 

897 timeout=timeout, 

898 metadata=metadata, 

899 ) 

900 

901 # Done; return the response. 

902 return response 

903 

904 async def delete_schema_revision( 

905 self, 

906 request: Optional[Union[schema.DeleteSchemaRevisionRequest, dict]] = None, 

907 *, 

908 name: Optional[str] = None, 

909 revision_id: Optional[str] = None, 

910 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

911 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

912 metadata: Sequence[Tuple[str, str]] = (), 

913 ) -> schema.Schema: 

914 r"""Deletes a specific schema revision. 

915 

916 .. code-block:: python 

917 

918 # This snippet has been automatically generated and should be regarded as a 

919 # code template only. 

920 # It will require modifications to work: 

921 # - It may require correct/in-range values for request initialization. 

922 # - It may require specifying regional endpoints when creating the service 

923 # client as shown in: 

924 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

925 from google import pubsub_v1 

926 

927 async def sample_delete_schema_revision(): 

928 # Create a client 

929 client = pubsub_v1.SchemaServiceAsyncClient() 

930 

931 # Initialize request argument(s) 

932 request = pubsub_v1.DeleteSchemaRevisionRequest( 

933 name="name_value", 

934 ) 

935 

936 # Make the request 

937 response = await client.delete_schema_revision(request=request) 

938 

939 # Handle the response 

940 print(response) 

941 

942 Args: 

943 request (Optional[Union[google.pubsub_v1.types.DeleteSchemaRevisionRequest, dict]]): 

944 The request object. Request for the 

945 `DeleteSchemaRevision` method. 

946 name (:class:`str`): 

947 Required. The name of the schema revision to be deleted, 

948 with a revision ID explicitly included. 

949 

950 Example: ``projects/123/schemas/my-schema@c7cfa2a8`` 

951 

952 This corresponds to the ``name`` field 

953 on the ``request`` instance; if ``request`` is provided, this 

954 should not be set. 

955 revision_id (:class:`str`): 

956 Optional. This field is deprecated and should not be 

957 used for specifying the revision ID. The revision ID 

958 should be specified via the ``name`` parameter. 

959 

960 This corresponds to the ``revision_id`` field 

961 on the ``request`` instance; if ``request`` is provided, this 

962 should not be set. 

963 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

964 should be retried. 

965 timeout (float): The timeout for this request. 

966 metadata (Sequence[Tuple[str, str]]): Strings which should be 

967 sent along with the request as metadata. 

968 

969 Returns: 

970 google.pubsub_v1.types.Schema: 

971 A schema resource. 

972 """ 

973 # Create or coerce a protobuf request object. 

974 # Quick check: If we got a request object, we should *not* have 

975 # gotten any keyword arguments that map to the request. 

976 has_flattened_params = any([name, revision_id]) 

977 if request is not None and has_flattened_params: 

978 raise ValueError( 

979 "If the `request` argument is set, then none of " 

980 "the individual field arguments should be set." 

981 ) 

982 

983 request = schema.DeleteSchemaRevisionRequest(request) 

984 

985 # If we have keyword arguments corresponding to fields on the 

986 # request, apply these. 

987 if name is not None: 

988 request.name = name 

989 if revision_id is not None: 

990 request.revision_id = revision_id 

991 

992 # Wrap the RPC method; this adds retry and timeout information, 

993 # and friendly error handling. 

994 rpc = gapic_v1.method_async.wrap_method( 

995 self._client._transport.delete_schema_revision, 

996 default_timeout=None, 

997 client_info=DEFAULT_CLIENT_INFO, 

998 ) 

999 

1000 # Certain fields should be provided within the metadata header; 

1001 # add these here. 

1002 metadata = tuple(metadata) + ( 

1003 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

1004 ) 

1005 

1006 # Send the request. 

1007 response = await rpc( 

1008 request, 

1009 retry=retry, 

1010 timeout=timeout, 

1011 metadata=metadata, 

1012 ) 

1013 

1014 # Done; return the response. 

1015 return response 

1016 

1017 async def delete_schema( 

1018 self, 

1019 request: Optional[Union[schema.DeleteSchemaRequest, dict]] = None, 

1020 *, 

1021 name: Optional[str] = None, 

1022 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1023 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

1024 metadata: Sequence[Tuple[str, str]] = (), 

1025 ) -> None: 

1026 r"""Deletes a schema. 

1027 

1028 .. code-block:: python 

1029 

1030 # This snippet has been automatically generated and should be regarded as a 

1031 # code template only. 

1032 # It will require modifications to work: 

1033 # - It may require correct/in-range values for request initialization. 

1034 # - It may require specifying regional endpoints when creating the service 

1035 # client as shown in: 

1036 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

1037 from google import pubsub_v1 

1038 

1039 async def sample_delete_schema(): 

1040 # Create a client 

1041 client = pubsub_v1.SchemaServiceAsyncClient() 

1042 

1043 # Initialize request argument(s) 

1044 request = pubsub_v1.DeleteSchemaRequest( 

1045 name="name_value", 

1046 ) 

1047 

1048 # Make the request 

1049 await client.delete_schema(request=request) 

1050 

1051 Args: 

1052 request (Optional[Union[google.pubsub_v1.types.DeleteSchemaRequest, dict]]): 

1053 The request object. Request for the `DeleteSchema` 

1054 method. 

1055 name (:class:`str`): 

1056 Required. Name of the schema to delete. Format is 

1057 ``projects/{project}/schemas/{schema}``. 

1058 

1059 This corresponds to the ``name`` field 

1060 on the ``request`` instance; if ``request`` is provided, this 

1061 should not be set. 

1062 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

1063 should be retried. 

1064 timeout (float): The timeout for this request. 

1065 metadata (Sequence[Tuple[str, str]]): Strings which should be 

1066 sent along with the request as metadata. 

1067 """ 

1068 # Create or coerce a protobuf request object. 

1069 # Quick check: If we got a request object, we should *not* have 

1070 # gotten any keyword arguments that map to the request. 

1071 has_flattened_params = any([name]) 

1072 if request is not None and has_flattened_params: 

1073 raise ValueError( 

1074 "If the `request` argument is set, then none of " 

1075 "the individual field arguments should be set." 

1076 ) 

1077 

1078 request = schema.DeleteSchemaRequest(request) 

1079 

1080 # If we have keyword arguments corresponding to fields on the 

1081 # request, apply these. 

1082 if name is not None: 

1083 request.name = name 

1084 

1085 # Wrap the RPC method; this adds retry and timeout information, 

1086 # and friendly error handling. 

1087 rpc = gapic_v1.method_async.wrap_method( 

1088 self._client._transport.delete_schema, 

1089 default_timeout=None, 

1090 client_info=DEFAULT_CLIENT_INFO, 

1091 ) 

1092 

1093 # Certain fields should be provided within the metadata header; 

1094 # add these here. 

1095 metadata = tuple(metadata) + ( 

1096 gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), 

1097 ) 

1098 

1099 # Send the request. 

1100 await rpc( 

1101 request, 

1102 retry=retry, 

1103 timeout=timeout, 

1104 metadata=metadata, 

1105 ) 

1106 

1107 async def validate_schema( 

1108 self, 

1109 request: Optional[Union[gp_schema.ValidateSchemaRequest, dict]] = None, 

1110 *, 

1111 parent: Optional[str] = None, 

1112 schema: Optional[gp_schema.Schema] = None, 

1113 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1114 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

1115 metadata: Sequence[Tuple[str, str]] = (), 

1116 ) -> gp_schema.ValidateSchemaResponse: 

1117 r"""Validates a schema. 

1118 

1119 .. code-block:: python 

1120 

1121 # This snippet has been automatically generated and should be regarded as a 

1122 # code template only. 

1123 # It will require modifications to work: 

1124 # - It may require correct/in-range values for request initialization. 

1125 # - It may require specifying regional endpoints when creating the service 

1126 # client as shown in: 

1127 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

1128 from google import pubsub_v1 

1129 

1130 async def sample_validate_schema(): 

1131 # Create a client 

1132 client = pubsub_v1.SchemaServiceAsyncClient() 

1133 

1134 # Initialize request argument(s) 

1135 schema = pubsub_v1.Schema() 

1136 schema.name = "name_value" 

1137 

1138 request = pubsub_v1.ValidateSchemaRequest( 

1139 parent="parent_value", 

1140 schema=schema, 

1141 ) 

1142 

1143 # Make the request 

1144 response = await client.validate_schema(request=request) 

1145 

1146 # Handle the response 

1147 print(response) 

1148 

1149 Args: 

1150 request (Optional[Union[google.pubsub_v1.types.ValidateSchemaRequest, dict]]): 

1151 The request object. Request for the `ValidateSchema` 

1152 method. 

1153 parent (:class:`str`): 

1154 Required. The name of the project in which to validate 

1155 schemas. Format is ``projects/{project-id}``. 

1156 

1157 This corresponds to the ``parent`` field 

1158 on the ``request`` instance; if ``request`` is provided, this 

1159 should not be set. 

1160 schema (:class:`google.pubsub_v1.types.Schema`): 

1161 Required. The schema object to 

1162 validate. 

1163 

1164 This corresponds to the ``schema`` field 

1165 on the ``request`` instance; if ``request`` is provided, this 

1166 should not be set. 

1167 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

1168 should be retried. 

1169 timeout (float): The timeout for this request. 

1170 metadata (Sequence[Tuple[str, str]]): Strings which should be 

1171 sent along with the request as metadata. 

1172 

1173 Returns: 

1174 google.pubsub_v1.types.ValidateSchemaResponse: 

1175 Response for the ValidateSchema method. 

1176 Empty for now. 

1177 

1178 """ 

1179 # Create or coerce a protobuf request object. 

1180 # Quick check: If we got a request object, we should *not* have 

1181 # gotten any keyword arguments that map to the request. 

1182 has_flattened_params = any([parent, schema]) 

1183 if request is not None and has_flattened_params: 

1184 raise ValueError( 

1185 "If the `request` argument is set, then none of " 

1186 "the individual field arguments should be set." 

1187 ) 

1188 

1189 request = gp_schema.ValidateSchemaRequest(request) 

1190 

1191 # If we have keyword arguments corresponding to fields on the 

1192 # request, apply these. 

1193 if parent is not None: 

1194 request.parent = parent 

1195 if schema is not None: 

1196 request.schema = schema 

1197 

1198 # Wrap the RPC method; this adds retry and timeout information, 

1199 # and friendly error handling. 

1200 rpc = gapic_v1.method_async.wrap_method( 

1201 self._client._transport.validate_schema, 

1202 default_timeout=None, 

1203 client_info=DEFAULT_CLIENT_INFO, 

1204 ) 

1205 

1206 # Certain fields should be provided within the metadata header; 

1207 # add these here. 

1208 metadata = tuple(metadata) + ( 

1209 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), 

1210 ) 

1211 

1212 # Send the request. 

1213 response = await rpc( 

1214 request, 

1215 retry=retry, 

1216 timeout=timeout, 

1217 metadata=metadata, 

1218 ) 

1219 

1220 # Done; return the response. 

1221 return response 

1222 

1223 async def validate_message( 

1224 self, 

1225 request: Optional[Union[schema.ValidateMessageRequest, dict]] = None, 

1226 *, 

1227 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1228 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

1229 metadata: Sequence[Tuple[str, str]] = (), 

1230 ) -> schema.ValidateMessageResponse: 

1231 r"""Validates a message against a schema. 

1232 

1233 .. code-block:: python 

1234 

1235 # This snippet has been automatically generated and should be regarded as a 

1236 # code template only. 

1237 # It will require modifications to work: 

1238 # - It may require correct/in-range values for request initialization. 

1239 # - It may require specifying regional endpoints when creating the service 

1240 # client as shown in: 

1241 # https://googleapis.dev/python/google-api-core/latest/client_options.html 

1242 from google import pubsub_v1 

1243 

1244 async def sample_validate_message(): 

1245 # Create a client 

1246 client = pubsub_v1.SchemaServiceAsyncClient() 

1247 

1248 # Initialize request argument(s) 

1249 request = pubsub_v1.ValidateMessageRequest( 

1250 name="name_value", 

1251 parent="parent_value", 

1252 ) 

1253 

1254 # Make the request 

1255 response = await client.validate_message(request=request) 

1256 

1257 # Handle the response 

1258 print(response) 

1259 

1260 Args: 

1261 request (Optional[Union[google.pubsub_v1.types.ValidateMessageRequest, dict]]): 

1262 The request object. Request for the `ValidateMessage` 

1263 method. 

1264 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

1265 should be retried. 

1266 timeout (float): The timeout for this request. 

1267 metadata (Sequence[Tuple[str, str]]): Strings which should be 

1268 sent along with the request as metadata. 

1269 

1270 Returns: 

1271 google.pubsub_v1.types.ValidateMessageResponse: 

1272 Response for the ValidateMessage method. 

1273 Empty for now. 

1274 

1275 """ 

1276 # Create or coerce a protobuf request object. 

1277 request = schema.ValidateMessageRequest(request) 

1278 

1279 # Wrap the RPC method; this adds retry and timeout information, 

1280 # and friendly error handling. 

1281 rpc = gapic_v1.method_async.wrap_method( 

1282 self._client._transport.validate_message, 

1283 default_timeout=None, 

1284 client_info=DEFAULT_CLIENT_INFO, 

1285 ) 

1286 

1287 # Certain fields should be provided within the metadata header; 

1288 # add these here. 

1289 metadata = tuple(metadata) + ( 

1290 gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), 

1291 ) 

1292 

1293 # Send the request. 

1294 response = await rpc( 

1295 request, 

1296 retry=retry, 

1297 timeout=timeout, 

1298 metadata=metadata, 

1299 ) 

1300 

1301 # Done; return the response. 

1302 return response 

1303 

1304 async def set_iam_policy( 

1305 self, 

1306 request: Optional[iam_policy_pb2.SetIamPolicyRequest] = None, 

1307 *, 

1308 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1309 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

1310 metadata: Sequence[Tuple[str, str]] = (), 

1311 ) -> policy_pb2.Policy: 

1312 r"""Sets the IAM access control policy on the specified function. 

1313 

1314 Replaces any existing policy. 

1315 

1316 Args: 

1317 request (:class:`~.policy_pb2.SetIamPolicyRequest`): 

1318 The request object. Request message for `SetIamPolicy` 

1319 method. 

1320 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

1321 should be retried. 

1322 timeout (float): The timeout for this request. 

1323 metadata (Sequence[Tuple[str, str]]): Strings which should be 

1324 sent along with the request as metadata. 

1325 Returns: 

1326 ~.policy_pb2.Policy: 

1327 Defines an Identity and Access Management (IAM) policy. 

1328 It is used to specify access control policies for Cloud 

1329 Platform resources. 

1330 A ``Policy`` is a collection of ``bindings``. A 

1331 ``binding`` binds one or more ``members`` to a single 

1332 ``role``. Members can be user accounts, service 

1333 accounts, Google groups, and domains (such as G Suite). 

1334 A ``role`` is a named list of permissions (defined by 

1335 IAM or configured by users). A ``binding`` can 

1336 optionally specify a ``condition``, which is a logic 

1337 expression that further constrains the role binding 

1338 based on attributes about the request and/or target 

1339 resource. 

1340 

1341 **JSON Example** 

1342 

1343 :: 

1344 { 

1345 "bindings": [ 

1346 { 

1347 "role": "roles/resourcemanager.organizationAdmin", 

1348 "members": [ 

1349 "user:mike@example.com", 

1350 "group:admins@example.com", 

1351 "domain:google.com", 

1352 "serviceAccount:my-project-id@appspot.gserviceaccount.com" 

1353 ] 

1354 }, 

1355 { 

1356 "role": "roles/resourcemanager.organizationViewer", 

1357 "members": ["user:eve@example.com"], 

1358 "condition": { 

1359 "title": "expirable access", 

1360 "description": "Does not grant access after Sep 2020", 

1361 "expression": "request.time < 

1362 timestamp('2020-10-01T00:00:00.000Z')", 

1363 } 

1364 } 

1365 ] 

1366 } 

1367 

1368 **YAML Example** 

1369 

1370 :: 

1371 

1372 bindings: 

1373 - members: 

1374 - user:mike@example.com 

1375 - group:admins@example.com 

1376 - domain:google.com 

1377 - serviceAccount:my-project-id@appspot.gserviceaccount.com 

1378 role: roles/resourcemanager.organizationAdmin 

1379 - members: 

1380 - user:eve@example.com 

1381 role: roles/resourcemanager.organizationViewer 

1382 condition: 

1383 title: expirable access 

1384 description: Does not grant access after Sep 2020 

1385 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') 

1386 

1387 For a description of IAM and its features, see the `IAM 

1388 developer's 

1389 guide <https://cloud.google.com/iam/docs>`__. 

1390 """ 

1391 # Create or coerce a protobuf request object. 

1392 

1393 # The request isn't a proto-plus wrapped type, 

1394 # so it must be constructed via keyword expansion. 

1395 if isinstance(request, dict): 

1396 request = iam_policy_pb2.SetIamPolicyRequest(**request) 

1397 

1398 # Wrap the RPC method; this adds retry and timeout information, 

1399 # and friendly error handling. 

1400 rpc = gapic_v1.method_async.wrap_method( 

1401 self._client._transport.set_iam_policy, 

1402 default_timeout=None, 

1403 client_info=DEFAULT_CLIENT_INFO, 

1404 ) 

1405 

1406 # Certain fields should be provided within the metadata header; 

1407 # add these here. 

1408 metadata = tuple(metadata) + ( 

1409 gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)), 

1410 ) 

1411 

1412 # Send the request. 

1413 response = await rpc( 

1414 request, 

1415 retry=retry, 

1416 timeout=timeout, 

1417 metadata=metadata, 

1418 ) 

1419 

1420 # Done; return the response. 

1421 return response 

1422 

1423 async def get_iam_policy( 

1424 self, 

1425 request: Optional[iam_policy_pb2.GetIamPolicyRequest] = None, 

1426 *, 

1427 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1428 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

1429 metadata: Sequence[Tuple[str, str]] = (), 

1430 ) -> policy_pb2.Policy: 

1431 r"""Gets the IAM access control policy for a function. 

1432 

1433 Returns an empty policy if the function exists and does 

1434 not have a policy set. 

1435 

1436 Args: 

1437 request (:class:`~.iam_policy_pb2.GetIamPolicyRequest`): 

1438 The request object. Request message for `GetIamPolicy` 

1439 method. 

1440 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

1441 should be retried. 

1442 timeout (float): The timeout for this request. 

1443 metadata (Sequence[Tuple[str, str]]): Strings which should be 

1444 sent along with the request as metadata. 

1445 Returns: 

1446 ~.policy_pb2.Policy: 

1447 Defines an Identity and Access Management (IAM) policy. 

1448 It is used to specify access control policies for Cloud 

1449 Platform resources. 

1450 A ``Policy`` is a collection of ``bindings``. A 

1451 ``binding`` binds one or more ``members`` to a single 

1452 ``role``. Members can be user accounts, service 

1453 accounts, Google groups, and domains (such as G Suite). 

1454 A ``role`` is a named list of permissions (defined by 

1455 IAM or configured by users). A ``binding`` can 

1456 optionally specify a ``condition``, which is a logic 

1457 expression that further constrains the role binding 

1458 based on attributes about the request and/or target 

1459 resource. 

1460 

1461 **JSON Example** 

1462 

1463 :: 

1464 

1465 { 

1466 "bindings": [ 

1467 { 

1468 "role": "roles/resourcemanager.organizationAdmin", 

1469 "members": [ 

1470 "user:mike@example.com", 

1471 "group:admins@example.com", 

1472 "domain:google.com", 

1473 "serviceAccount:my-project-id@appspot.gserviceaccount.com" 

1474 ] 

1475 }, 

1476 { 

1477 "role": "roles/resourcemanager.organizationViewer", 

1478 "members": ["user:eve@example.com"], 

1479 "condition": { 

1480 "title": "expirable access", 

1481 "description": "Does not grant access after Sep 2020", 

1482 "expression": "request.time < 

1483 timestamp('2020-10-01T00:00:00.000Z')", 

1484 } 

1485 } 

1486 ] 

1487 } 

1488 

1489 **YAML Example** 

1490 

1491 :: 

1492 

1493 bindings: 

1494 - members: 

1495 - user:mike@example.com 

1496 - group:admins@example.com 

1497 - domain:google.com 

1498 - serviceAccount:my-project-id@appspot.gserviceaccount.com 

1499 role: roles/resourcemanager.organizationAdmin 

1500 - members: 

1501 - user:eve@example.com 

1502 role: roles/resourcemanager.organizationViewer 

1503 condition: 

1504 title: expirable access 

1505 description: Does not grant access after Sep 2020 

1506 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') 

1507 

1508 For a description of IAM and its features, see the `IAM 

1509 developer's 

1510 guide <https://cloud.google.com/iam/docs>`__. 

1511 """ 

1512 # Create or coerce a protobuf request object. 

1513 

1514 # The request isn't a proto-plus wrapped type, 

1515 # so it must be constructed via keyword expansion. 

1516 if isinstance(request, dict): 

1517 request = iam_policy_pb2.GetIamPolicyRequest(**request) 

1518 

1519 # Wrap the RPC method; this adds retry and timeout information, 

1520 # and friendly error handling. 

1521 rpc = gapic_v1.method_async.wrap_method( 

1522 self._client._transport.get_iam_policy, 

1523 default_timeout=None, 

1524 client_info=DEFAULT_CLIENT_INFO, 

1525 ) 

1526 

1527 # Certain fields should be provided within the metadata header; 

1528 # add these here. 

1529 metadata = tuple(metadata) + ( 

1530 gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)), 

1531 ) 

1532 

1533 # Send the request. 

1534 response = await rpc( 

1535 request, 

1536 retry=retry, 

1537 timeout=timeout, 

1538 metadata=metadata, 

1539 ) 

1540 

1541 # Done; return the response. 

1542 return response 

1543 

1544 async def test_iam_permissions( 

1545 self, 

1546 request: Optional[iam_policy_pb2.TestIamPermissionsRequest] = None, 

1547 *, 

1548 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1549 timeout: Union[float, object] = gapic_v1.method.DEFAULT, 

1550 metadata: Sequence[Tuple[str, str]] = (), 

1551 ) -> iam_policy_pb2.TestIamPermissionsResponse: 

1552 r"""Tests the specified permissions against the IAM access control 

1553 policy for a function. 

1554 

1555 If the function does not exist, this will 

1556 return an empty set of permissions, not a NOT_FOUND error. 

1557 

1558 Args: 

1559 request (:class:`~.iam_policy_pb2.TestIamPermissionsRequest`): 

1560 The request object. Request message for 

1561 `TestIamPermissions` method. 

1562 retry (google.api_core.retry.Retry): Designation of what errors, if any, 

1563 should be retried. 

1564 timeout (float): The timeout for this request. 

1565 metadata (Sequence[Tuple[str, str]]): Strings which should be 

1566 sent along with the request as metadata. 

1567 Returns: 

1568 ~iam_policy_pb2.PolicyTestIamPermissionsResponse: 

1569 Response message for ``TestIamPermissions`` method. 

1570 """ 

1571 # Create or coerce a protobuf request object. 

1572 

1573 # The request isn't a proto-plus wrapped type, 

1574 # so it must be constructed via keyword expansion. 

1575 if isinstance(request, dict): 

1576 request = iam_policy_pb2.TestIamPermissionsRequest(**request) 

1577 

1578 # Wrap the RPC method; this adds retry and timeout information, 

1579 # and friendly error handling. 

1580 rpc = gapic_v1.method_async.wrap_method( 

1581 self._client._transport.test_iam_permissions, 

1582 default_timeout=None, 

1583 client_info=DEFAULT_CLIENT_INFO, 

1584 ) 

1585 

1586 # Certain fields should be provided within the metadata header; 

1587 # add these here. 

1588 metadata = tuple(metadata) + ( 

1589 gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)), 

1590 ) 

1591 

1592 # Send the request. 

1593 response = await rpc( 

1594 request, 

1595 retry=retry, 

1596 timeout=timeout, 

1597 metadata=metadata, 

1598 ) 

1599 

1600 # Done; return the response. 

1601 return response 

1602 

1603 async def __aenter__(self): 

1604 return self 

1605 

1606 async def __aexit__(self, exc_type, exc, tb): 

1607 await self.transport.close() 

1608 

1609 

1610DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( 

1611 client_library_version=package_version.__version__ 

1612) 

1613 

1614 

1615__all__ = ("SchemaServiceAsyncClient",)