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

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

244 statements  

1# -*- coding: utf-8 -*- 

2# Copyright 2025 Google LLC 

3# 

4# Licensed under the Apache License, Version 2.0 (the "License"); 

5# you may not use this file except in compliance with the License. 

6# You may obtain a copy of the License at 

7# 

8# http://www.apache.org/licenses/LICENSE-2.0 

9# 

10# Unless required by applicable law or agreed to in writing, software 

11# distributed under the License is distributed on an "AS IS" BASIS, 

12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

13# See the License for the specific language governing permissions and 

14# limitations under the License. 

15# 

16import logging as std_logging 

17from collections import OrderedDict 

18import re 

19from typing import ( 

20 Dict, 

21 Callable, 

22 Mapping, 

23 MutableMapping, 

24 MutableSequence, 

25 Optional, 

26 Sequence, 

27 Tuple, 

28 Type, 

29 Union, 

30) 

31 

32from google.pubsub_v1 import gapic_version as package_version 

33 

34from google.api_core.client_options import ClientOptions 

35from google.api_core import exceptions as core_exceptions 

36from google.api_core import gapic_v1 

37from google.api_core import retry_async as retries 

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

39from google.oauth2 import service_account # type: ignore 

40import google.protobuf 

41 

42 

43try: 

44 OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault, None] 

45except AttributeError: # pragma: NO COVER 

46 OptionalRetry = Union[retries.AsyncRetry, object, None] # type: ignore 

47 

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

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

50from google.protobuf import timestamp_pb2 # type: ignore 

51from google.pubsub_v1.services.schema_service import pagers 

52from google.pubsub_v1.types import schema 

53from google.pubsub_v1.types import schema as gp_schema 

54from .transports.base import SchemaServiceTransport, DEFAULT_CLIENT_INFO 

55from .transports.grpc_asyncio import SchemaServiceGrpcAsyncIOTransport 

56from .client import SchemaServiceClient 

57 

58try: 

59 from google.api_core import client_logging # type: ignore 

60 

61 CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER 

62except ImportError: # pragma: NO COVER 

63 CLIENT_LOGGING_SUPPORTED = False 

64 

65_LOGGER = std_logging.getLogger(__name__) 

66 

67 

68class SchemaServiceAsyncClient: 

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

70 

71 _client: SchemaServiceClient 

72 

73 # Copy defaults from the synchronous client for use here. 

74 # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead. 

75 DEFAULT_ENDPOINT = SchemaServiceClient.DEFAULT_ENDPOINT 

76 DEFAULT_MTLS_ENDPOINT = SchemaServiceClient.DEFAULT_MTLS_ENDPOINT 

77 _DEFAULT_ENDPOINT_TEMPLATE = SchemaServiceClient._DEFAULT_ENDPOINT_TEMPLATE 

78 _DEFAULT_UNIVERSE = SchemaServiceClient._DEFAULT_UNIVERSE 

79 

80 schema_path = staticmethod(SchemaServiceClient.schema_path) 

81 parse_schema_path = staticmethod(SchemaServiceClient.parse_schema_path) 

82 common_billing_account_path = staticmethod( 

83 SchemaServiceClient.common_billing_account_path 

84 ) 

85 parse_common_billing_account_path = staticmethod( 

86 SchemaServiceClient.parse_common_billing_account_path 

87 ) 

88 common_folder_path = staticmethod(SchemaServiceClient.common_folder_path) 

89 parse_common_folder_path = staticmethod( 

90 SchemaServiceClient.parse_common_folder_path 

91 ) 

92 common_organization_path = staticmethod( 

93 SchemaServiceClient.common_organization_path 

94 ) 

95 parse_common_organization_path = staticmethod( 

96 SchemaServiceClient.parse_common_organization_path 

97 ) 

98 common_project_path = staticmethod(SchemaServiceClient.common_project_path) 

99 parse_common_project_path = staticmethod( 

100 SchemaServiceClient.parse_common_project_path 

101 ) 

102 common_location_path = staticmethod(SchemaServiceClient.common_location_path) 

103 parse_common_location_path = staticmethod( 

104 SchemaServiceClient.parse_common_location_path 

105 ) 

106 

107 @classmethod 

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

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

110 info. 

111 

112 Args: 

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

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_info.__func__(SchemaServiceAsyncClient, info, *args, **kwargs) # type: ignore 

121 

122 @classmethod 

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

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

125 file. 

126 

127 Args: 

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

129 file. 

130 args: Additional arguments to pass to the constructor. 

131 kwargs: Additional arguments to pass to the constructor. 

132 

133 Returns: 

134 SchemaServiceAsyncClient: The constructed client. 

135 """ 

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

137 

138 from_service_account_json = from_service_account_file 

139 

140 @classmethod 

141 def get_mtls_endpoint_and_cert_source( 

142 cls, client_options: Optional[ClientOptions] = None 

143 ): 

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

145 

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

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

148 client cert source is None. 

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

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

151 source is None. 

152 

153 The API endpoint is determined in the following order: 

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

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

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

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

158 use the default API endpoint. 

159 

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

161 

162 Args: 

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

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

165 in this method. 

166 

167 Returns: 

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

169 client cert source to use. 

170 

171 Raises: 

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

173 """ 

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

175 

176 @property 

177 def transport(self) -> SchemaServiceTransport: 

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

179 

180 Returns: 

181 SchemaServiceTransport: The transport used by the client instance. 

182 """ 

183 return self._client.transport 

184 

185 @property 

186 def api_endpoint(self): 

187 """Return the API endpoint used by the client instance. 

188 

189 Returns: 

190 str: The API endpoint used by the client instance. 

191 """ 

192 return self._client._api_endpoint 

193 

194 @property 

195 def universe_domain(self) -> str: 

196 """Return the universe domain used by the client instance. 

197 

198 Returns: 

199 str: The universe domain used 

200 by the client instance. 

201 """ 

202 return self._client._universe_domain 

203 

204 get_transport_class = SchemaServiceClient.get_transport_class 

205 

206 def __init__( 

207 self, 

208 *, 

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

210 transport: Optional[ 

211 Union[str, SchemaServiceTransport, Callable[..., SchemaServiceTransport]] 

212 ] = "grpc_asyncio", 

213 client_options: Optional[ClientOptions] = None, 

214 client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, 

215 ) -> None: 

216 """Instantiates the schema service async client. 

217 

218 Args: 

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

220 authorization credentials to attach to requests. These 

221 credentials identify the application to the service; if none 

222 are specified, the client will attempt to ascertain the 

223 credentials from the environment. 

224 transport (Optional[Union[str,SchemaServiceTransport,Callable[..., SchemaServiceTransport]]]): 

225 The transport to use, or a Callable that constructs and returns a new transport to use. 

226 If a Callable is given, it will be called with the same set of initialization 

227 arguments as used in the SchemaServiceTransport constructor. 

228 If set to None, a transport is chosen automatically. 

229 client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): 

230 Custom options for the client. 

231 

232 1. The ``api_endpoint`` property can be used to override the 

233 default endpoint provided by the client when ``transport`` is 

234 not explicitly provided. Only if this property is not set and 

235 ``transport`` was not explicitly provided, the endpoint is 

236 determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment 

237 variable, which have one of the following values: 

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

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

240 default mTLS endpoint if client certificate is present; this is 

241 the default value). 

242 

243 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable 

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

245 to provide a client certificate for mTLS transport. If 

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

247 present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not 

248 set, no client certificate will be used. 

249 

250 3. The ``universe_domain`` property can be used to override the 

251 default "googleapis.com" universe. Note that ``api_endpoint`` 

252 property still takes precedence; and ``universe_domain`` is 

253 currently not supported for mTLS. 

254 

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

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

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

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

259 your own client library. 

260 

261 Raises: 

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

263 creation failed for any reason. 

264 """ 

265 self._client = SchemaServiceClient( 

266 credentials=credentials, 

267 transport=transport, 

268 client_options=client_options, 

269 client_info=client_info, 

270 ) 

271 

272 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

273 std_logging.DEBUG 

274 ): # pragma: NO COVER 

275 _LOGGER.debug( 

276 "Created client `google.pubsub_v1.SchemaServiceAsyncClient`.", 

277 extra={ 

278 "serviceName": "google.pubsub.v1.SchemaService", 

279 "universeDomain": getattr( 

280 self._client._transport._credentials, "universe_domain", "" 

281 ), 

282 "credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}", 

283 "credentialsInfo": getattr( 

284 self.transport._credentials, "get_cred_info", lambda: None 

285 )(), 

286 } 

287 if hasattr(self._client._transport, "_credentials") 

288 else { 

289 "serviceName": "google.pubsub.v1.SchemaService", 

290 "credentialsType": None, 

291 }, 

292 ) 

293 

294 async def create_schema( 

295 self, 

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

297 *, 

298 parent: Optional[str] = None, 

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

300 schema_id: Optional[str] = None, 

301 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

303 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

304 ) -> gp_schema.Schema: 

305 r"""Creates a schema. 

306 

307 .. code-block:: python 

308 

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

310 # code template only. 

311 # It will require modifications to work: 

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

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

314 # client as shown in: 

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

316 from google import pubsub_v1 

317 

318 async def sample_create_schema(): 

319 # Create a client 

320 client = pubsub_v1.SchemaServiceAsyncClient() 

321 

322 # Initialize request argument(s) 

323 schema = pubsub_v1.Schema() 

324 schema.name = "name_value" 

325 

326 request = pubsub_v1.CreateSchemaRequest( 

327 parent="parent_value", 

328 schema=schema, 

329 ) 

330 

331 # Make the request 

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

333 

334 # Handle the response 

335 print(response) 

336 

337 Args: 

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

339 The request object. Request for the CreateSchema method. 

340 parent (:class:`str`): 

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

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

343 

344 This corresponds to the ``parent`` field 

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

346 should not be set. 

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

348 Required. The schema object to create. 

349 

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

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

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

353 

354 This corresponds to the ``schema`` field 

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

356 should not be set. 

357 schema_id (:class:`str`): 

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

359 final component of the schema's resource name. 

360 

361 See 

362 https://cloud.google.com/pubsub/docs/pubsub-basics#resource_names 

363 for resource name constraints. 

364 

365 This corresponds to the ``schema_id`` field 

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

367 should not be set. 

368 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

369 should be retried. 

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

371 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

372 sent along with the request as metadata. Normally, each value must be of type `str`, 

373 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

374 be of type `bytes`. 

375 

376 Returns: 

377 google.pubsub_v1.types.Schema: 

378 A schema resource. 

379 """ 

380 # Create or coerce a protobuf request object. 

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

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

383 flattened_params = [parent, schema, schema_id] 

384 has_flattened_params = ( 

385 len([param for param in flattened_params if param is not None]) > 0 

386 ) 

387 if request is not None and has_flattened_params: 

388 raise ValueError( 

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

390 "the individual field arguments should be set." 

391 ) 

392 

393 # - Use the request object if provided (there's no risk of modifying the input as 

394 # there are no flattened fields), or create one. 

395 if not isinstance(request, gp_schema.CreateSchemaRequest): 

396 request = gp_schema.CreateSchemaRequest(request) 

397 

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

399 # request, apply these. 

400 if parent is not None: 

401 request.parent = parent 

402 if schema is not None: 

403 request.schema = schema 

404 if schema_id is not None: 

405 request.schema_id = schema_id 

406 

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

408 # and friendly error handling. 

409 rpc = self._client._transport._wrapped_methods[ 

410 self._client._transport.create_schema 

411 ] 

412 

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

414 # add these here. 

415 metadata = tuple(metadata) + ( 

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

417 ) 

418 

419 # Validate the universe domain. 

420 self._client._validate_universe_domain() 

421 

422 # Send the request. 

423 response = await rpc( 

424 request, 

425 retry=retry, 

426 timeout=timeout, 

427 metadata=metadata, 

428 ) 

429 

430 # Done; return the response. 

431 return response 

432 

433 async def get_schema( 

434 self, 

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

436 *, 

437 name: Optional[str] = None, 

438 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

440 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

441 ) -> schema.Schema: 

442 r"""Gets a schema. 

443 

444 .. code-block:: python 

445 

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

447 # code template only. 

448 # It will require modifications to work: 

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

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

451 # client as shown in: 

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

453 from google import pubsub_v1 

454 

455 async def sample_get_schema(): 

456 # Create a client 

457 client = pubsub_v1.SchemaServiceAsyncClient() 

458 

459 # Initialize request argument(s) 

460 request = pubsub_v1.GetSchemaRequest( 

461 name="name_value", 

462 ) 

463 

464 # Make the request 

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

466 

467 # Handle the response 

468 print(response) 

469 

470 Args: 

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

472 The request object. Request for the GetSchema method. 

473 name (:class:`str`): 

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

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

476 

477 This corresponds to the ``name`` field 

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

479 should not be set. 

480 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

481 should be retried. 

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

483 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

484 sent along with the request as metadata. Normally, each value must be of type `str`, 

485 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

486 be of type `bytes`. 

487 

488 Returns: 

489 google.pubsub_v1.types.Schema: 

490 A schema resource. 

491 """ 

492 # Create or coerce a protobuf request object. 

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

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

495 flattened_params = [name] 

496 has_flattened_params = ( 

497 len([param for param in flattened_params if param is not None]) > 0 

498 ) 

499 if request is not None and has_flattened_params: 

500 raise ValueError( 

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

502 "the individual field arguments should be set." 

503 ) 

504 

505 # - Use the request object if provided (there's no risk of modifying the input as 

506 # there are no flattened fields), or create one. 

507 if not isinstance(request, schema.GetSchemaRequest): 

508 request = schema.GetSchemaRequest(request) 

509 

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

511 # request, apply these. 

512 if name is not None: 

513 request.name = name 

514 

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

516 # and friendly error handling. 

517 rpc = self._client._transport._wrapped_methods[ 

518 self._client._transport.get_schema 

519 ] 

520 

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

522 # add these here. 

523 metadata = tuple(metadata) + ( 

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

525 ) 

526 

527 # Validate the universe domain. 

528 self._client._validate_universe_domain() 

529 

530 # Send the request. 

531 response = await rpc( 

532 request, 

533 retry=retry, 

534 timeout=timeout, 

535 metadata=metadata, 

536 ) 

537 

538 # Done; return the response. 

539 return response 

540 

541 async def list_schemas( 

542 self, 

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

544 *, 

545 parent: Optional[str] = None, 

546 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

548 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

549 ) -> pagers.ListSchemasAsyncPager: 

550 r"""Lists schemas in a project. 

551 

552 .. code-block:: python 

553 

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

555 # code template only. 

556 # It will require modifications to work: 

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

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

559 # client as shown in: 

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

561 from google import pubsub_v1 

562 

563 async def sample_list_schemas(): 

564 # Create a client 

565 client = pubsub_v1.SchemaServiceAsyncClient() 

566 

567 # Initialize request argument(s) 

568 request = pubsub_v1.ListSchemasRequest( 

569 parent="parent_value", 

570 ) 

571 

572 # Make the request 

573 page_result = client.list_schemas(request=request) 

574 

575 # Handle the response 

576 async for response in page_result: 

577 print(response) 

578 

579 Args: 

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

581 The request object. Request for the ``ListSchemas`` method. 

582 parent (:class:`str`): 

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

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

585 

586 This corresponds to the ``parent`` field 

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

588 should not be set. 

589 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

590 should be retried. 

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

592 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

593 sent along with the request as metadata. Normally, each value must be of type `str`, 

594 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

595 be of type `bytes`. 

596 

597 Returns: 

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

599 Response for the ListSchemas method. 

600 

601 Iterating over this object will yield results and 

602 resolve additional pages automatically. 

603 

604 """ 

605 # Create or coerce a protobuf request object. 

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

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

608 flattened_params = [parent] 

609 has_flattened_params = ( 

610 len([param for param in flattened_params if param is not None]) > 0 

611 ) 

612 if request is not None and has_flattened_params: 

613 raise ValueError( 

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

615 "the individual field arguments should be set." 

616 ) 

617 

618 # - Use the request object if provided (there's no risk of modifying the input as 

619 # there are no flattened fields), or create one. 

620 if not isinstance(request, schema.ListSchemasRequest): 

621 request = schema.ListSchemasRequest(request) 

622 

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

624 # request, apply these. 

625 if parent is not None: 

626 request.parent = parent 

627 

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

629 # and friendly error handling. 

630 rpc = self._client._transport._wrapped_methods[ 

631 self._client._transport.list_schemas 

632 ] 

633 

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

635 # add these here. 

636 metadata = tuple(metadata) + ( 

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

638 ) 

639 

640 # Validate the universe domain. 

641 self._client._validate_universe_domain() 

642 

643 # Send the request. 

644 response = await rpc( 

645 request, 

646 retry=retry, 

647 timeout=timeout, 

648 metadata=metadata, 

649 ) 

650 

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

652 # an `__aiter__` convenience method. 

653 response = pagers.ListSchemasAsyncPager( 

654 method=rpc, 

655 request=request, 

656 response=response, 

657 retry=retry, 

658 timeout=timeout, 

659 metadata=metadata, 

660 ) 

661 

662 # Done; return the response. 

663 return response 

664 

665 async def list_schema_revisions( 

666 self, 

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

668 *, 

669 name: Optional[str] = None, 

670 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

672 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

673 ) -> pagers.ListSchemaRevisionsAsyncPager: 

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

675 

676 .. code-block:: python 

677 

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

679 # code template only. 

680 # It will require modifications to work: 

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

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

683 # client as shown in: 

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

685 from google import pubsub_v1 

686 

687 async def sample_list_schema_revisions(): 

688 # Create a client 

689 client = pubsub_v1.SchemaServiceAsyncClient() 

690 

691 # Initialize request argument(s) 

692 request = pubsub_v1.ListSchemaRevisionsRequest( 

693 name="name_value", 

694 ) 

695 

696 # Make the request 

697 page_result = client.list_schema_revisions(request=request) 

698 

699 # Handle the response 

700 async for response in page_result: 

701 print(response) 

702 

703 Args: 

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

705 The request object. Request for the ``ListSchemaRevisions`` method. 

706 name (:class:`str`): 

707 Required. The name of the schema to 

708 list revisions for. 

709 

710 This corresponds to the ``name`` field 

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

712 should not be set. 

713 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

714 should be retried. 

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

716 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

717 sent along with the request as metadata. Normally, each value must be of type `str`, 

718 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

719 be of type `bytes`. 

720 

721 Returns: 

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

723 Response for the ListSchemaRevisions method. 

724 

725 Iterating over this object will yield results and 

726 resolve additional pages automatically. 

727 

728 """ 

729 # Create or coerce a protobuf request object. 

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

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

732 flattened_params = [name] 

733 has_flattened_params = ( 

734 len([param for param in flattened_params if param is not None]) > 0 

735 ) 

736 if request is not None and has_flattened_params: 

737 raise ValueError( 

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

739 "the individual field arguments should be set." 

740 ) 

741 

742 # - Use the request object if provided (there's no risk of modifying the input as 

743 # there are no flattened fields), or create one. 

744 if not isinstance(request, schema.ListSchemaRevisionsRequest): 

745 request = schema.ListSchemaRevisionsRequest(request) 

746 

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

748 # request, apply these. 

749 if name is not None: 

750 request.name = name 

751 

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

753 # and friendly error handling. 

754 rpc = self._client._transport._wrapped_methods[ 

755 self._client._transport.list_schema_revisions 

756 ] 

757 

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

759 # add these here. 

760 metadata = tuple(metadata) + ( 

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

762 ) 

763 

764 # Validate the universe domain. 

765 self._client._validate_universe_domain() 

766 

767 # Send the request. 

768 response = await rpc( 

769 request, 

770 retry=retry, 

771 timeout=timeout, 

772 metadata=metadata, 

773 ) 

774 

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

776 # an `__aiter__` convenience method. 

777 response = pagers.ListSchemaRevisionsAsyncPager( 

778 method=rpc, 

779 request=request, 

780 response=response, 

781 retry=retry, 

782 timeout=timeout, 

783 metadata=metadata, 

784 ) 

785 

786 # Done; return the response. 

787 return response 

788 

789 async def commit_schema( 

790 self, 

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

792 *, 

793 name: Optional[str] = None, 

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

795 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

797 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

798 ) -> gp_schema.Schema: 

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

800 

801 .. code-block:: python 

802 

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

804 # code template only. 

805 # It will require modifications to work: 

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

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

808 # client as shown in: 

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

810 from google import pubsub_v1 

811 

812 async def sample_commit_schema(): 

813 # Create a client 

814 client = pubsub_v1.SchemaServiceAsyncClient() 

815 

816 # Initialize request argument(s) 

817 schema = pubsub_v1.Schema() 

818 schema.name = "name_value" 

819 

820 request = pubsub_v1.CommitSchemaRequest( 

821 name="name_value", 

822 schema=schema, 

823 ) 

824 

825 # Make the request 

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

827 

828 # Handle the response 

829 print(response) 

830 

831 Args: 

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

833 The request object. Request for CommitSchema method. 

834 name (:class:`str`): 

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

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

837 

838 This corresponds to the ``name`` field 

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

840 should not be set. 

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

842 Required. The schema revision to 

843 commit. 

844 

845 This corresponds to the ``schema`` field 

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

847 should not be set. 

848 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

849 should be retried. 

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

851 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

852 sent along with the request as metadata. Normally, each value must be of type `str`, 

853 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

854 be of type `bytes`. 

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 flattened_params = [name, schema] 

864 has_flattened_params = ( 

865 len([param for param in flattened_params if param is not None]) > 0 

866 ) 

867 if request is not None and has_flattened_params: 

868 raise ValueError( 

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

870 "the individual field arguments should be set." 

871 ) 

872 

873 # - Use the request object if provided (there's no risk of modifying the input as 

874 # there are no flattened fields), or create one. 

875 if not isinstance(request, gp_schema.CommitSchemaRequest): 

876 request = gp_schema.CommitSchemaRequest(request) 

877 

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

879 # request, apply these. 

880 if name is not None: 

881 request.name = name 

882 if schema is not None: 

883 request.schema = schema 

884 

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

886 # and friendly error handling. 

887 rpc = self._client._transport._wrapped_methods[ 

888 self._client._transport.commit_schema 

889 ] 

890 

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

892 # add these here. 

893 metadata = tuple(metadata) + ( 

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

895 ) 

896 

897 # Validate the universe domain. 

898 self._client._validate_universe_domain() 

899 

900 # Send the request. 

901 response = await rpc( 

902 request, 

903 retry=retry, 

904 timeout=timeout, 

905 metadata=metadata, 

906 ) 

907 

908 # Done; return the response. 

909 return response 

910 

911 async def rollback_schema( 

912 self, 

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

914 *, 

915 name: Optional[str] = None, 

916 revision_id: Optional[str] = None, 

917 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

919 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

920 ) -> schema.Schema: 

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

922 revision_id. 

923 

924 .. code-block:: python 

925 

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

927 # code template only. 

928 # It will require modifications to work: 

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

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

931 # client as shown in: 

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

933 from google import pubsub_v1 

934 

935 async def sample_rollback_schema(): 

936 # Create a client 

937 client = pubsub_v1.SchemaServiceAsyncClient() 

938 

939 # Initialize request argument(s) 

940 request = pubsub_v1.RollbackSchemaRequest( 

941 name="name_value", 

942 revision_id="revision_id_value", 

943 ) 

944 

945 # Make the request 

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

947 

948 # Handle the response 

949 print(response) 

950 

951 Args: 

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

953 The request object. Request for the ``RollbackSchema`` method. 

954 name (:class:`str`): 

955 Required. The schema being rolled 

956 back with revision id. 

957 

958 This corresponds to the ``name`` field 

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

960 should not be set. 

961 revision_id (:class:`str`): 

962 Required. The revision ID to roll 

963 back to. It must be a revision of the 

964 same schema. 

965 

966 Example: c7cfa2a8 

967 

968 This corresponds to the ``revision_id`` field 

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

970 should not be set. 

971 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

972 should be retried. 

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

974 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

975 sent along with the request as metadata. Normally, each value must be of type `str`, 

976 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

977 be of type `bytes`. 

978 

979 Returns: 

980 google.pubsub_v1.types.Schema: 

981 A schema resource. 

982 """ 

983 # Create or coerce a protobuf request object. 

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

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

986 flattened_params = [name, revision_id] 

987 has_flattened_params = ( 

988 len([param for param in flattened_params if param is not None]) > 0 

989 ) 

990 if request is not None and has_flattened_params: 

991 raise ValueError( 

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

993 "the individual field arguments should be set." 

994 ) 

995 

996 # - Use the request object if provided (there's no risk of modifying the input as 

997 # there are no flattened fields), or create one. 

998 if not isinstance(request, schema.RollbackSchemaRequest): 

999 request = schema.RollbackSchemaRequest(request) 

1000 

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

1002 # request, apply these. 

1003 if name is not None: 

1004 request.name = name 

1005 if revision_id is not None: 

1006 request.revision_id = revision_id 

1007 

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

1009 # and friendly error handling. 

1010 rpc = self._client._transport._wrapped_methods[ 

1011 self._client._transport.rollback_schema 

1012 ] 

1013 

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

1015 # add these here. 

1016 metadata = tuple(metadata) + ( 

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

1018 ) 

1019 

1020 # Validate the universe domain. 

1021 self._client._validate_universe_domain() 

1022 

1023 # Send the request. 

1024 response = await rpc( 

1025 request, 

1026 retry=retry, 

1027 timeout=timeout, 

1028 metadata=metadata, 

1029 ) 

1030 

1031 # Done; return the response. 

1032 return response 

1033 

1034 async def delete_schema_revision( 

1035 self, 

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

1037 *, 

1038 name: Optional[str] = None, 

1039 revision_id: Optional[str] = None, 

1040 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

1042 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

1043 ) -> schema.Schema: 

1044 r"""Deletes a specific schema revision. 

1045 

1046 .. code-block:: python 

1047 

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

1049 # code template only. 

1050 # It will require modifications to work: 

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

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

1053 # client as shown in: 

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

1055 from google import pubsub_v1 

1056 

1057 async def sample_delete_schema_revision(): 

1058 # Create a client 

1059 client = pubsub_v1.SchemaServiceAsyncClient() 

1060 

1061 # Initialize request argument(s) 

1062 request = pubsub_v1.DeleteSchemaRevisionRequest( 

1063 name="name_value", 

1064 ) 

1065 

1066 # Make the request 

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

1068 

1069 # Handle the response 

1070 print(response) 

1071 

1072 Args: 

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

1074 The request object. Request for the ``DeleteSchemaRevision`` method. 

1075 name (:class:`str`): 

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

1077 with a revision ID explicitly included. 

1078 

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

1080 

1081 This corresponds to the ``name`` field 

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

1083 should not be set. 

1084 revision_id (:class:`str`): 

1085 Optional. This field is deprecated and should not be 

1086 used for specifying the revision ID. The revision ID 

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

1088 

1089 This corresponds to the ``revision_id`` field 

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

1091 should not be set. 

1092 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

1093 should be retried. 

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

1095 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

1096 sent along with the request as metadata. Normally, each value must be of type `str`, 

1097 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

1098 be of type `bytes`. 

1099 

1100 Returns: 

1101 google.pubsub_v1.types.Schema: 

1102 A schema resource. 

1103 """ 

1104 # Create or coerce a protobuf request object. 

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

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

1107 flattened_params = [name, revision_id] 

1108 has_flattened_params = ( 

1109 len([param for param in flattened_params if param is not None]) > 0 

1110 ) 

1111 if request is not None and has_flattened_params: 

1112 raise ValueError( 

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

1114 "the individual field arguments should be set." 

1115 ) 

1116 

1117 # - Use the request object if provided (there's no risk of modifying the input as 

1118 # there are no flattened fields), or create one. 

1119 if not isinstance(request, schema.DeleteSchemaRevisionRequest): 

1120 request = schema.DeleteSchemaRevisionRequest(request) 

1121 

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

1123 # request, apply these. 

1124 if name is not None: 

1125 request.name = name 

1126 if revision_id is not None: 

1127 request.revision_id = revision_id 

1128 

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

1130 # and friendly error handling. 

1131 rpc = self._client._transport._wrapped_methods[ 

1132 self._client._transport.delete_schema_revision 

1133 ] 

1134 

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

1136 # add these here. 

1137 metadata = tuple(metadata) + ( 

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

1139 ) 

1140 

1141 # Validate the universe domain. 

1142 self._client._validate_universe_domain() 

1143 

1144 # Send the request. 

1145 response = await rpc( 

1146 request, 

1147 retry=retry, 

1148 timeout=timeout, 

1149 metadata=metadata, 

1150 ) 

1151 

1152 # Done; return the response. 

1153 return response 

1154 

1155 async def delete_schema( 

1156 self, 

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

1158 *, 

1159 name: Optional[str] = None, 

1160 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

1162 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

1163 ) -> None: 

1164 r"""Deletes a schema. 

1165 

1166 .. code-block:: python 

1167 

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

1169 # code template only. 

1170 # It will require modifications to work: 

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

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

1173 # client as shown in: 

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

1175 from google import pubsub_v1 

1176 

1177 async def sample_delete_schema(): 

1178 # Create a client 

1179 client = pubsub_v1.SchemaServiceAsyncClient() 

1180 

1181 # Initialize request argument(s) 

1182 request = pubsub_v1.DeleteSchemaRequest( 

1183 name="name_value", 

1184 ) 

1185 

1186 # Make the request 

1187 await client.delete_schema(request=request) 

1188 

1189 Args: 

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

1191 The request object. Request for the ``DeleteSchema`` method. 

1192 name (:class:`str`): 

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

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

1195 

1196 This corresponds to the ``name`` field 

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

1198 should not be set. 

1199 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

1200 should be retried. 

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

1202 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

1203 sent along with the request as metadata. Normally, each value must be of type `str`, 

1204 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

1205 be of type `bytes`. 

1206 """ 

1207 # Create or coerce a protobuf request object. 

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

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

1210 flattened_params = [name] 

1211 has_flattened_params = ( 

1212 len([param for param in flattened_params if param is not None]) > 0 

1213 ) 

1214 if request is not None and has_flattened_params: 

1215 raise ValueError( 

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

1217 "the individual field arguments should be set." 

1218 ) 

1219 

1220 # - Use the request object if provided (there's no risk of modifying the input as 

1221 # there are no flattened fields), or create one. 

1222 if not isinstance(request, schema.DeleteSchemaRequest): 

1223 request = schema.DeleteSchemaRequest(request) 

1224 

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

1226 # request, apply these. 

1227 if name is not None: 

1228 request.name = name 

1229 

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

1231 # and friendly error handling. 

1232 rpc = self._client._transport._wrapped_methods[ 

1233 self._client._transport.delete_schema 

1234 ] 

1235 

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

1237 # add these here. 

1238 metadata = tuple(metadata) + ( 

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

1240 ) 

1241 

1242 # Validate the universe domain. 

1243 self._client._validate_universe_domain() 

1244 

1245 # Send the request. 

1246 await rpc( 

1247 request, 

1248 retry=retry, 

1249 timeout=timeout, 

1250 metadata=metadata, 

1251 ) 

1252 

1253 async def validate_schema( 

1254 self, 

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

1256 *, 

1257 parent: Optional[str] = None, 

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

1259 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

1261 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

1262 ) -> gp_schema.ValidateSchemaResponse: 

1263 r"""Validates a schema. 

1264 

1265 .. code-block:: python 

1266 

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

1268 # code template only. 

1269 # It will require modifications to work: 

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

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

1272 # client as shown in: 

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

1274 from google import pubsub_v1 

1275 

1276 async def sample_validate_schema(): 

1277 # Create a client 

1278 client = pubsub_v1.SchemaServiceAsyncClient() 

1279 

1280 # Initialize request argument(s) 

1281 schema = pubsub_v1.Schema() 

1282 schema.name = "name_value" 

1283 

1284 request = pubsub_v1.ValidateSchemaRequest( 

1285 parent="parent_value", 

1286 schema=schema, 

1287 ) 

1288 

1289 # Make the request 

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

1291 

1292 # Handle the response 

1293 print(response) 

1294 

1295 Args: 

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

1297 The request object. Request for the ``ValidateSchema`` method. 

1298 parent (:class:`str`): 

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

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

1301 

1302 This corresponds to the ``parent`` field 

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

1304 should not be set. 

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

1306 Required. The schema object to 

1307 validate. 

1308 

1309 This corresponds to the ``schema`` field 

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

1311 should not be set. 

1312 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

1313 should be retried. 

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

1315 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

1316 sent along with the request as metadata. Normally, each value must be of type `str`, 

1317 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

1318 be of type `bytes`. 

1319 

1320 Returns: 

1321 google.pubsub_v1.types.ValidateSchemaResponse: 

1322 Response for the ValidateSchema method. 

1323 Empty for now. 

1324 

1325 """ 

1326 # Create or coerce a protobuf request object. 

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

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

1329 flattened_params = [parent, schema] 

1330 has_flattened_params = ( 

1331 len([param for param in flattened_params if param is not None]) > 0 

1332 ) 

1333 if request is not None and has_flattened_params: 

1334 raise ValueError( 

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

1336 "the individual field arguments should be set." 

1337 ) 

1338 

1339 # - Use the request object if provided (there's no risk of modifying the input as 

1340 # there are no flattened fields), or create one. 

1341 if not isinstance(request, gp_schema.ValidateSchemaRequest): 

1342 request = gp_schema.ValidateSchemaRequest(request) 

1343 

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

1345 # request, apply these. 

1346 if parent is not None: 

1347 request.parent = parent 

1348 if schema is not None: 

1349 request.schema = schema 

1350 

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

1352 # and friendly error handling. 

1353 rpc = self._client._transport._wrapped_methods[ 

1354 self._client._transport.validate_schema 

1355 ] 

1356 

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

1358 # add these here. 

1359 metadata = tuple(metadata) + ( 

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

1361 ) 

1362 

1363 # Validate the universe domain. 

1364 self._client._validate_universe_domain() 

1365 

1366 # Send the request. 

1367 response = await rpc( 

1368 request, 

1369 retry=retry, 

1370 timeout=timeout, 

1371 metadata=metadata, 

1372 ) 

1373 

1374 # Done; return the response. 

1375 return response 

1376 

1377 async def validate_message( 

1378 self, 

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

1380 *, 

1381 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

1383 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

1384 ) -> schema.ValidateMessageResponse: 

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

1386 

1387 .. code-block:: python 

1388 

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

1390 # code template only. 

1391 # It will require modifications to work: 

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

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

1394 # client as shown in: 

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

1396 from google import pubsub_v1 

1397 

1398 async def sample_validate_message(): 

1399 # Create a client 

1400 client = pubsub_v1.SchemaServiceAsyncClient() 

1401 

1402 # Initialize request argument(s) 

1403 request = pubsub_v1.ValidateMessageRequest( 

1404 name="name_value", 

1405 parent="parent_value", 

1406 ) 

1407 

1408 # Make the request 

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

1410 

1411 # Handle the response 

1412 print(response) 

1413 

1414 Args: 

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

1416 The request object. Request for the ``ValidateMessage`` method. 

1417 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

1418 should be retried. 

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

1420 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

1421 sent along with the request as metadata. Normally, each value must be of type `str`, 

1422 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

1423 be of type `bytes`. 

1424 

1425 Returns: 

1426 google.pubsub_v1.types.ValidateMessageResponse: 

1427 Response for the ValidateMessage method. 

1428 Empty for now. 

1429 

1430 """ 

1431 # Create or coerce a protobuf request object. 

1432 # - Use the request object if provided (there's no risk of modifying the input as 

1433 # there are no flattened fields), or create one. 

1434 if not isinstance(request, schema.ValidateMessageRequest): 

1435 request = schema.ValidateMessageRequest(request) 

1436 

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

1438 # and friendly error handling. 

1439 rpc = self._client._transport._wrapped_methods[ 

1440 self._client._transport.validate_message 

1441 ] 

1442 

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

1444 # add these here. 

1445 metadata = tuple(metadata) + ( 

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

1447 ) 

1448 

1449 # Validate the universe domain. 

1450 self._client._validate_universe_domain() 

1451 

1452 # Send the request. 

1453 response = await rpc( 

1454 request, 

1455 retry=retry, 

1456 timeout=timeout, 

1457 metadata=metadata, 

1458 ) 

1459 

1460 # Done; return the response. 

1461 return response 

1462 

1463 async def set_iam_policy( 

1464 self, 

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

1466 *, 

1467 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

1469 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

1470 ) -> policy_pb2.Policy: 

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

1472 

1473 Replaces any existing policy. 

1474 

1475 Args: 

1476 request (:class:`~.iam_policy_pb2.SetIamPolicyRequest`): 

1477 The request object. Request message for `SetIamPolicy` 

1478 method. 

1479 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, 

1480 should be retried. 

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

1482 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

1483 sent along with the request as metadata. Normally, each value must be of type `str`, 

1484 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

1485 be of type `bytes`. 

1486 Returns: 

1487 ~.policy_pb2.Policy: 

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

1489 It is used to specify access control policies for Cloud 

1490 Platform resources. 

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

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

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

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

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

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

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

1498 expression that further constrains the role binding 

1499 based on attributes about the request and/or target 

1500 resource. 

1501 

1502 **JSON Example** 

1503 

1504 :: 

1505 

1506 { 

1507 "bindings": [ 

1508 { 

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

1510 "members": [ 

1511 "user:mike@example.com", 

1512 "group:admins@example.com", 

1513 "domain:google.com", 

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

1515 ] 

1516 }, 

1517 { 

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

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

1520 "condition": { 

1521 "title": "expirable access", 

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

1523 "expression": "request.time < 

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

1525 } 

1526 } 

1527 ] 

1528 } 

1529 

1530 **YAML Example** 

1531 

1532 :: 

1533 

1534 bindings: 

1535 - members: 

1536 - user:mike@example.com 

1537 - group:admins@example.com 

1538 - domain:google.com 

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

1540 role: roles/resourcemanager.organizationAdmin 

1541 - members: 

1542 - user:eve@example.com 

1543 role: roles/resourcemanager.organizationViewer 

1544 condition: 

1545 title: expirable access 

1546 description: Does not grant access after Sep 2020 

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

1548 

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

1550 developer's 

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

1552 """ 

1553 # Create or coerce a protobuf request object. 

1554 

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

1556 # so it must be constructed via keyword expansion. 

1557 if isinstance(request, dict): 

1558 request = iam_policy_pb2.SetIamPolicyRequest(**request) 

1559 

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

1561 # and friendly error handling. 

1562 rpc = self.transport._wrapped_methods[self._client._transport.set_iam_policy] 

1563 

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

1565 # add these here. 

1566 metadata = tuple(metadata) + ( 

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

1568 ) 

1569 

1570 # Validate the universe domain. 

1571 self._client._validate_universe_domain() 

1572 

1573 # Send the request. 

1574 response = await rpc( 

1575 request, 

1576 retry=retry, 

1577 timeout=timeout, 

1578 metadata=metadata, 

1579 ) 

1580 

1581 # Done; return the response. 

1582 return response 

1583 

1584 async def get_iam_policy( 

1585 self, 

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

1587 *, 

1588 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

1590 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

1591 ) -> policy_pb2.Policy: 

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

1593 

1594 Returns an empty policy if the function exists and does not have a 

1595 policy set. 

1596 

1597 Args: 

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

1599 The request object. Request message for `GetIamPolicy` 

1600 method. 

1601 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if 

1602 any, should be retried. 

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

1604 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

1605 sent along with the request as metadata. Normally, each value must be of type `str`, 

1606 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

1607 be of type `bytes`. 

1608 Returns: 

1609 ~.policy_pb2.Policy: 

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

1611 It is used to specify access control policies for Cloud 

1612 Platform resources. 

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

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

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

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

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

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

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

1620 expression that further constrains the role binding 

1621 based on attributes about the request and/or target 

1622 resource. 

1623 

1624 **JSON Example** 

1625 

1626 :: 

1627 

1628 { 

1629 "bindings": [ 

1630 { 

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

1632 "members": [ 

1633 "user:mike@example.com", 

1634 "group:admins@example.com", 

1635 "domain:google.com", 

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

1637 ] 

1638 }, 

1639 { 

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

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

1642 "condition": { 

1643 "title": "expirable access", 

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

1645 "expression": "request.time < 

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

1647 } 

1648 } 

1649 ] 

1650 } 

1651 

1652 **YAML Example** 

1653 

1654 :: 

1655 

1656 bindings: 

1657 - members: 

1658 - user:mike@example.com 

1659 - group:admins@example.com 

1660 - domain:google.com 

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

1662 role: roles/resourcemanager.organizationAdmin 

1663 - members: 

1664 - user:eve@example.com 

1665 role: roles/resourcemanager.organizationViewer 

1666 condition: 

1667 title: expirable access 

1668 description: Does not grant access after Sep 2020 

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

1670 

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

1672 developer's 

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

1674 """ 

1675 # Create or coerce a protobuf request object. 

1676 

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

1678 # so it must be constructed via keyword expansion. 

1679 if isinstance(request, dict): 

1680 request = iam_policy_pb2.GetIamPolicyRequest(**request) 

1681 

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

1683 # and friendly error handling. 

1684 rpc = self.transport._wrapped_methods[self._client._transport.get_iam_policy] 

1685 

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

1687 # add these here. 

1688 metadata = tuple(metadata) + ( 

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

1690 ) 

1691 

1692 # Validate the universe domain. 

1693 self._client._validate_universe_domain() 

1694 

1695 # Send the request. 

1696 response = await rpc( 

1697 request, 

1698 retry=retry, 

1699 timeout=timeout, 

1700 metadata=metadata, 

1701 ) 

1702 

1703 # Done; return the response. 

1704 return response 

1705 

1706 async def test_iam_permissions( 

1707 self, 

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

1709 *, 

1710 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

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

1712 metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), 

1713 ) -> iam_policy_pb2.TestIamPermissionsResponse: 

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

1715 policy for a function. 

1716 

1717 If the function does not exist, this will return an empty set 

1718 of permissions, not a NOT_FOUND error. 

1719 

1720 Args: 

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

1722 The request object. Request message for 

1723 `TestIamPermissions` method. 

1724 retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, 

1725 if any, should be retried. 

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

1727 metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be 

1728 sent along with the request as metadata. Normally, each value must be of type `str`, 

1729 but for metadata keys ending with the suffix `-bin`, the corresponding values must 

1730 be of type `bytes`. 

1731 Returns: 

1732 ~.iam_policy_pb2.TestIamPermissionsResponse: 

1733 Response message for ``TestIamPermissions`` method. 

1734 """ 

1735 # Create or coerce a protobuf request object. 

1736 

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

1738 # so it must be constructed via keyword expansion. 

1739 if isinstance(request, dict): 

1740 request = iam_policy_pb2.TestIamPermissionsRequest(**request) 

1741 

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

1743 # and friendly error handling. 

1744 rpc = self.transport._wrapped_methods[ 

1745 self._client._transport.test_iam_permissions 

1746 ] 

1747 

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

1749 # add these here. 

1750 metadata = tuple(metadata) + ( 

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

1752 ) 

1753 

1754 # Validate the universe domain. 

1755 self._client._validate_universe_domain() 

1756 

1757 # Send the request. 

1758 response = await rpc( 

1759 request, 

1760 retry=retry, 

1761 timeout=timeout, 

1762 metadata=metadata, 

1763 ) 

1764 

1765 # Done; return the response. 

1766 return response 

1767 

1768 async def __aenter__(self) -> "SchemaServiceAsyncClient": 

1769 return self 

1770 

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

1772 await self.transport.close() 

1773 

1774 

1775DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( 

1776 client_library_version=package_version.__version__ 

1777) 

1778 

1779if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER 

1780 DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__ 

1781 

1782 

1783__all__ = ("SchemaServiceAsyncClient",)