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

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

488 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 

17import json # type: ignore 

18 

19from google.auth.transport.requests import AuthorizedSession # type: ignore 

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

21from google.api_core import exceptions as core_exceptions 

22from google.api_core import retry as retries 

23from google.api_core import rest_helpers 

24from google.api_core import rest_streaming 

25from google.api_core import gapic_v1 

26import google.protobuf 

27 

28from google.protobuf import json_format 

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

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

31 

32from requests import __version__ as requests_version 

33import dataclasses 

34from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union 

35import warnings 

36 

37 

38from google.protobuf import empty_pb2 # type: ignore 

39from google.pubsub_v1.types import schema 

40from google.pubsub_v1.types import schema as gp_schema 

41 

42 

43from .rest_base import _BaseSchemaServiceRestTransport 

44from .base import DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO 

45 

46try: 

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

48except AttributeError: # pragma: NO COVER 

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

50 

51try: 

52 from google.api_core import client_logging # type: ignore 

53 

54 CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER 

55except ImportError: # pragma: NO COVER 

56 CLIENT_LOGGING_SUPPORTED = False 

57 

58_LOGGER = logging.getLogger(__name__) 

59 

60DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( 

61 gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, 

62 grpc_version=None, 

63 rest_version=f"requests@{requests_version}", 

64) 

65 

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

67 DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__ 

68 

69 

70class SchemaServiceRestInterceptor: 

71 """Interceptor for SchemaService. 

72 

73 Interceptors are used to manipulate requests, request metadata, and responses 

74 in arbitrary ways. 

75 Example use cases include: 

76 * Logging 

77 * Verifying requests according to service or custom semantics 

78 * Stripping extraneous information from responses 

79 

80 These use cases and more can be enabled by injecting an 

81 instance of a custom subclass when constructing the SchemaServiceRestTransport. 

82 

83 .. code-block:: python 

84 class MyCustomSchemaServiceInterceptor(SchemaServiceRestInterceptor): 

85 def pre_commit_schema(self, request, metadata): 

86 logging.log(f"Received request: {request}") 

87 return request, metadata 

88 

89 def post_commit_schema(self, response): 

90 logging.log(f"Received response: {response}") 

91 return response 

92 

93 def pre_create_schema(self, request, metadata): 

94 logging.log(f"Received request: {request}") 

95 return request, metadata 

96 

97 def post_create_schema(self, response): 

98 logging.log(f"Received response: {response}") 

99 return response 

100 

101 def pre_delete_schema(self, request, metadata): 

102 logging.log(f"Received request: {request}") 

103 return request, metadata 

104 

105 def pre_delete_schema_revision(self, request, metadata): 

106 logging.log(f"Received request: {request}") 

107 return request, metadata 

108 

109 def post_delete_schema_revision(self, response): 

110 logging.log(f"Received response: {response}") 

111 return response 

112 

113 def pre_get_schema(self, request, metadata): 

114 logging.log(f"Received request: {request}") 

115 return request, metadata 

116 

117 def post_get_schema(self, response): 

118 logging.log(f"Received response: {response}") 

119 return response 

120 

121 def pre_list_schema_revisions(self, request, metadata): 

122 logging.log(f"Received request: {request}") 

123 return request, metadata 

124 

125 def post_list_schema_revisions(self, response): 

126 logging.log(f"Received response: {response}") 

127 return response 

128 

129 def pre_list_schemas(self, request, metadata): 

130 logging.log(f"Received request: {request}") 

131 return request, metadata 

132 

133 def post_list_schemas(self, response): 

134 logging.log(f"Received response: {response}") 

135 return response 

136 

137 def pre_rollback_schema(self, request, metadata): 

138 logging.log(f"Received request: {request}") 

139 return request, metadata 

140 

141 def post_rollback_schema(self, response): 

142 logging.log(f"Received response: {response}") 

143 return response 

144 

145 def pre_validate_message(self, request, metadata): 

146 logging.log(f"Received request: {request}") 

147 return request, metadata 

148 

149 def post_validate_message(self, response): 

150 logging.log(f"Received response: {response}") 

151 return response 

152 

153 def pre_validate_schema(self, request, metadata): 

154 logging.log(f"Received request: {request}") 

155 return request, metadata 

156 

157 def post_validate_schema(self, response): 

158 logging.log(f"Received response: {response}") 

159 return response 

160 

161 transport = SchemaServiceRestTransport(interceptor=MyCustomSchemaServiceInterceptor()) 

162 client = SchemaServiceClient(transport=transport) 

163 

164 

165 """ 

166 

167 def pre_commit_schema( 

168 self, 

169 request: gp_schema.CommitSchemaRequest, 

170 metadata: Sequence[Tuple[str, Union[str, bytes]]], 

171 ) -> Tuple[gp_schema.CommitSchemaRequest, Sequence[Tuple[str, Union[str, bytes]]]]: 

172 """Pre-rpc interceptor for commit_schema 

173 

174 Override in a subclass to manipulate the request or metadata 

175 before they are sent to the SchemaService server. 

176 """ 

177 return request, metadata 

178 

179 def post_commit_schema(self, response: gp_schema.Schema) -> gp_schema.Schema: 

180 """Post-rpc interceptor for commit_schema 

181 

182 DEPRECATED. Please use the `post_commit_schema_with_metadata` 

183 interceptor instead. 

184 

185 Override in a subclass to read or manipulate the response 

186 after it is returned by the SchemaService server but before 

187 it is returned to user code. This `post_commit_schema` interceptor runs 

188 before the `post_commit_schema_with_metadata` interceptor. 

189 """ 

190 return response 

191 

192 def post_commit_schema_with_metadata( 

193 self, 

194 response: gp_schema.Schema, 

195 metadata: Sequence[Tuple[str, Union[str, bytes]]], 

196 ) -> Tuple[gp_schema.Schema, Sequence[Tuple[str, Union[str, bytes]]]]: 

197 """Post-rpc interceptor for commit_schema 

198 

199 Override in a subclass to read or manipulate the response or metadata after it 

200 is returned by the SchemaService server but before it is returned to user code. 

201 

202 We recommend only using this `post_commit_schema_with_metadata` 

203 interceptor in new development instead of the `post_commit_schema` interceptor. 

204 When both interceptors are used, this `post_commit_schema_with_metadata` interceptor runs after the 

205 `post_commit_schema` interceptor. The (possibly modified) response returned by 

206 `post_commit_schema` will be passed to 

207 `post_commit_schema_with_metadata`. 

208 """ 

209 return response, metadata 

210 

211 def pre_create_schema( 

212 self, 

213 request: gp_schema.CreateSchemaRequest, 

214 metadata: Sequence[Tuple[str, Union[str, bytes]]], 

215 ) -> Tuple[gp_schema.CreateSchemaRequest, Sequence[Tuple[str, Union[str, bytes]]]]: 

216 """Pre-rpc interceptor for create_schema 

217 

218 Override in a subclass to manipulate the request or metadata 

219 before they are sent to the SchemaService server. 

220 """ 

221 return request, metadata 

222 

223 def post_create_schema(self, response: gp_schema.Schema) -> gp_schema.Schema: 

224 """Post-rpc interceptor for create_schema 

225 

226 DEPRECATED. Please use the `post_create_schema_with_metadata` 

227 interceptor instead. 

228 

229 Override in a subclass to read or manipulate the response 

230 after it is returned by the SchemaService server but before 

231 it is returned to user code. This `post_create_schema` interceptor runs 

232 before the `post_create_schema_with_metadata` interceptor. 

233 """ 

234 return response 

235 

236 def post_create_schema_with_metadata( 

237 self, 

238 response: gp_schema.Schema, 

239 metadata: Sequence[Tuple[str, Union[str, bytes]]], 

240 ) -> Tuple[gp_schema.Schema, Sequence[Tuple[str, Union[str, bytes]]]]: 

241 """Post-rpc interceptor for create_schema 

242 

243 Override in a subclass to read or manipulate the response or metadata after it 

244 is returned by the SchemaService server but before it is returned to user code. 

245 

246 We recommend only using this `post_create_schema_with_metadata` 

247 interceptor in new development instead of the `post_create_schema` interceptor. 

248 When both interceptors are used, this `post_create_schema_with_metadata` interceptor runs after the 

249 `post_create_schema` interceptor. The (possibly modified) response returned by 

250 `post_create_schema` will be passed to 

251 `post_create_schema_with_metadata`. 

252 """ 

253 return response, metadata 

254 

255 def pre_delete_schema( 

256 self, 

257 request: schema.DeleteSchemaRequest, 

258 metadata: Sequence[Tuple[str, Union[str, bytes]]], 

259 ) -> Tuple[schema.DeleteSchemaRequest, Sequence[Tuple[str, Union[str, bytes]]]]: 

260 """Pre-rpc interceptor for delete_schema 

261 

262 Override in a subclass to manipulate the request or metadata 

263 before they are sent to the SchemaService server. 

264 """ 

265 return request, metadata 

266 

267 def pre_delete_schema_revision( 

268 self, 

269 request: schema.DeleteSchemaRevisionRequest, 

270 metadata: Sequence[Tuple[str, Union[str, bytes]]], 

271 ) -> Tuple[ 

272 schema.DeleteSchemaRevisionRequest, Sequence[Tuple[str, Union[str, bytes]]] 

273 ]: 

274 """Pre-rpc interceptor for delete_schema_revision 

275 

276 Override in a subclass to manipulate the request or metadata 

277 before they are sent to the SchemaService server. 

278 """ 

279 return request, metadata 

280 

281 def post_delete_schema_revision(self, response: schema.Schema) -> schema.Schema: 

282 """Post-rpc interceptor for delete_schema_revision 

283 

284 DEPRECATED. Please use the `post_delete_schema_revision_with_metadata` 

285 interceptor instead. 

286 

287 Override in a subclass to read or manipulate the response 

288 after it is returned by the SchemaService server but before 

289 it is returned to user code. This `post_delete_schema_revision` interceptor runs 

290 before the `post_delete_schema_revision_with_metadata` interceptor. 

291 """ 

292 return response 

293 

294 def post_delete_schema_revision_with_metadata( 

295 self, response: schema.Schema, metadata: Sequence[Tuple[str, Union[str, bytes]]] 

296 ) -> Tuple[schema.Schema, Sequence[Tuple[str, Union[str, bytes]]]]: 

297 """Post-rpc interceptor for delete_schema_revision 

298 

299 Override in a subclass to read or manipulate the response or metadata after it 

300 is returned by the SchemaService server but before it is returned to user code. 

301 

302 We recommend only using this `post_delete_schema_revision_with_metadata` 

303 interceptor in new development instead of the `post_delete_schema_revision` interceptor. 

304 When both interceptors are used, this `post_delete_schema_revision_with_metadata` interceptor runs after the 

305 `post_delete_schema_revision` interceptor. The (possibly modified) response returned by 

306 `post_delete_schema_revision` will be passed to 

307 `post_delete_schema_revision_with_metadata`. 

308 """ 

309 return response, metadata 

310 

311 def pre_get_schema( 

312 self, 

313 request: schema.GetSchemaRequest, 

314 metadata: Sequence[Tuple[str, Union[str, bytes]]], 

315 ) -> Tuple[schema.GetSchemaRequest, Sequence[Tuple[str, Union[str, bytes]]]]: 

316 """Pre-rpc interceptor for get_schema 

317 

318 Override in a subclass to manipulate the request or metadata 

319 before they are sent to the SchemaService server. 

320 """ 

321 return request, metadata 

322 

323 def post_get_schema(self, response: schema.Schema) -> schema.Schema: 

324 """Post-rpc interceptor for get_schema 

325 

326 DEPRECATED. Please use the `post_get_schema_with_metadata` 

327 interceptor instead. 

328 

329 Override in a subclass to read or manipulate the response 

330 after it is returned by the SchemaService server but before 

331 it is returned to user code. This `post_get_schema` interceptor runs 

332 before the `post_get_schema_with_metadata` interceptor. 

333 """ 

334 return response 

335 

336 def post_get_schema_with_metadata( 

337 self, response: schema.Schema, metadata: Sequence[Tuple[str, Union[str, bytes]]] 

338 ) -> Tuple[schema.Schema, Sequence[Tuple[str, Union[str, bytes]]]]: 

339 """Post-rpc interceptor for get_schema 

340 

341 Override in a subclass to read or manipulate the response or metadata after it 

342 is returned by the SchemaService server but before it is returned to user code. 

343 

344 We recommend only using this `post_get_schema_with_metadata` 

345 interceptor in new development instead of the `post_get_schema` interceptor. 

346 When both interceptors are used, this `post_get_schema_with_metadata` interceptor runs after the 

347 `post_get_schema` interceptor. The (possibly modified) response returned by 

348 `post_get_schema` will be passed to 

349 `post_get_schema_with_metadata`. 

350 """ 

351 return response, metadata 

352 

353 def pre_list_schema_revisions( 

354 self, 

355 request: schema.ListSchemaRevisionsRequest, 

356 metadata: Sequence[Tuple[str, Union[str, bytes]]], 

357 ) -> Tuple[ 

358 schema.ListSchemaRevisionsRequest, Sequence[Tuple[str, Union[str, bytes]]] 

359 ]: 

360 """Pre-rpc interceptor for list_schema_revisions 

361 

362 Override in a subclass to manipulate the request or metadata 

363 before they are sent to the SchemaService server. 

364 """ 

365 return request, metadata 

366 

367 def post_list_schema_revisions( 

368 self, response: schema.ListSchemaRevisionsResponse 

369 ) -> schema.ListSchemaRevisionsResponse: 

370 """Post-rpc interceptor for list_schema_revisions 

371 

372 DEPRECATED. Please use the `post_list_schema_revisions_with_metadata` 

373 interceptor instead. 

374 

375 Override in a subclass to read or manipulate the response 

376 after it is returned by the SchemaService server but before 

377 it is returned to user code. This `post_list_schema_revisions` interceptor runs 

378 before the `post_list_schema_revisions_with_metadata` interceptor. 

379 """ 

380 return response 

381 

382 def post_list_schema_revisions_with_metadata( 

383 self, 

384 response: schema.ListSchemaRevisionsResponse, 

385 metadata: Sequence[Tuple[str, Union[str, bytes]]], 

386 ) -> Tuple[ 

387 schema.ListSchemaRevisionsResponse, Sequence[Tuple[str, Union[str, bytes]]] 

388 ]: 

389 """Post-rpc interceptor for list_schema_revisions 

390 

391 Override in a subclass to read or manipulate the response or metadata after it 

392 is returned by the SchemaService server but before it is returned to user code. 

393 

394 We recommend only using this `post_list_schema_revisions_with_metadata` 

395 interceptor in new development instead of the `post_list_schema_revisions` interceptor. 

396 When both interceptors are used, this `post_list_schema_revisions_with_metadata` interceptor runs after the 

397 `post_list_schema_revisions` interceptor. The (possibly modified) response returned by 

398 `post_list_schema_revisions` will be passed to 

399 `post_list_schema_revisions_with_metadata`. 

400 """ 

401 return response, metadata 

402 

403 def pre_list_schemas( 

404 self, 

405 request: schema.ListSchemasRequest, 

406 metadata: Sequence[Tuple[str, Union[str, bytes]]], 

407 ) -> Tuple[schema.ListSchemasRequest, Sequence[Tuple[str, Union[str, bytes]]]]: 

408 """Pre-rpc interceptor for list_schemas 

409 

410 Override in a subclass to manipulate the request or metadata 

411 before they are sent to the SchemaService server. 

412 """ 

413 return request, metadata 

414 

415 def post_list_schemas( 

416 self, response: schema.ListSchemasResponse 

417 ) -> schema.ListSchemasResponse: 

418 """Post-rpc interceptor for list_schemas 

419 

420 DEPRECATED. Please use the `post_list_schemas_with_metadata` 

421 interceptor instead. 

422 

423 Override in a subclass to read or manipulate the response 

424 after it is returned by the SchemaService server but before 

425 it is returned to user code. This `post_list_schemas` interceptor runs 

426 before the `post_list_schemas_with_metadata` interceptor. 

427 """ 

428 return response 

429 

430 def post_list_schemas_with_metadata( 

431 self, 

432 response: schema.ListSchemasResponse, 

433 metadata: Sequence[Tuple[str, Union[str, bytes]]], 

434 ) -> Tuple[schema.ListSchemasResponse, Sequence[Tuple[str, Union[str, bytes]]]]: 

435 """Post-rpc interceptor for list_schemas 

436 

437 Override in a subclass to read or manipulate the response or metadata after it 

438 is returned by the SchemaService server but before it is returned to user code. 

439 

440 We recommend only using this `post_list_schemas_with_metadata` 

441 interceptor in new development instead of the `post_list_schemas` interceptor. 

442 When both interceptors are used, this `post_list_schemas_with_metadata` interceptor runs after the 

443 `post_list_schemas` interceptor. The (possibly modified) response returned by 

444 `post_list_schemas` will be passed to 

445 `post_list_schemas_with_metadata`. 

446 """ 

447 return response, metadata 

448 

449 def pre_rollback_schema( 

450 self, 

451 request: schema.RollbackSchemaRequest, 

452 metadata: Sequence[Tuple[str, Union[str, bytes]]], 

453 ) -> Tuple[schema.RollbackSchemaRequest, Sequence[Tuple[str, Union[str, bytes]]]]: 

454 """Pre-rpc interceptor for rollback_schema 

455 

456 Override in a subclass to manipulate the request or metadata 

457 before they are sent to the SchemaService server. 

458 """ 

459 return request, metadata 

460 

461 def post_rollback_schema(self, response: schema.Schema) -> schema.Schema: 

462 """Post-rpc interceptor for rollback_schema 

463 

464 DEPRECATED. Please use the `post_rollback_schema_with_metadata` 

465 interceptor instead. 

466 

467 Override in a subclass to read or manipulate the response 

468 after it is returned by the SchemaService server but before 

469 it is returned to user code. This `post_rollback_schema` interceptor runs 

470 before the `post_rollback_schema_with_metadata` interceptor. 

471 """ 

472 return response 

473 

474 def post_rollback_schema_with_metadata( 

475 self, response: schema.Schema, metadata: Sequence[Tuple[str, Union[str, bytes]]] 

476 ) -> Tuple[schema.Schema, Sequence[Tuple[str, Union[str, bytes]]]]: 

477 """Post-rpc interceptor for rollback_schema 

478 

479 Override in a subclass to read or manipulate the response or metadata after it 

480 is returned by the SchemaService server but before it is returned to user code. 

481 

482 We recommend only using this `post_rollback_schema_with_metadata` 

483 interceptor in new development instead of the `post_rollback_schema` interceptor. 

484 When both interceptors are used, this `post_rollback_schema_with_metadata` interceptor runs after the 

485 `post_rollback_schema` interceptor. The (possibly modified) response returned by 

486 `post_rollback_schema` will be passed to 

487 `post_rollback_schema_with_metadata`. 

488 """ 

489 return response, metadata 

490 

491 def pre_validate_message( 

492 self, 

493 request: schema.ValidateMessageRequest, 

494 metadata: Sequence[Tuple[str, Union[str, bytes]]], 

495 ) -> Tuple[schema.ValidateMessageRequest, Sequence[Tuple[str, Union[str, bytes]]]]: 

496 """Pre-rpc interceptor for validate_message 

497 

498 Override in a subclass to manipulate the request or metadata 

499 before they are sent to the SchemaService server. 

500 """ 

501 return request, metadata 

502 

503 def post_validate_message( 

504 self, response: schema.ValidateMessageResponse 

505 ) -> schema.ValidateMessageResponse: 

506 """Post-rpc interceptor for validate_message 

507 

508 DEPRECATED. Please use the `post_validate_message_with_metadata` 

509 interceptor instead. 

510 

511 Override in a subclass to read or manipulate the response 

512 after it is returned by the SchemaService server but before 

513 it is returned to user code. This `post_validate_message` interceptor runs 

514 before the `post_validate_message_with_metadata` interceptor. 

515 """ 

516 return response 

517 

518 def post_validate_message_with_metadata( 

519 self, 

520 response: schema.ValidateMessageResponse, 

521 metadata: Sequence[Tuple[str, Union[str, bytes]]], 

522 ) -> Tuple[schema.ValidateMessageResponse, Sequence[Tuple[str, Union[str, bytes]]]]: 

523 """Post-rpc interceptor for validate_message 

524 

525 Override in a subclass to read or manipulate the response or metadata after it 

526 is returned by the SchemaService server but before it is returned to user code. 

527 

528 We recommend only using this `post_validate_message_with_metadata` 

529 interceptor in new development instead of the `post_validate_message` interceptor. 

530 When both interceptors are used, this `post_validate_message_with_metadata` interceptor runs after the 

531 `post_validate_message` interceptor. The (possibly modified) response returned by 

532 `post_validate_message` will be passed to 

533 `post_validate_message_with_metadata`. 

534 """ 

535 return response, metadata 

536 

537 def pre_validate_schema( 

538 self, 

539 request: gp_schema.ValidateSchemaRequest, 

540 metadata: Sequence[Tuple[str, Union[str, bytes]]], 

541 ) -> Tuple[ 

542 gp_schema.ValidateSchemaRequest, Sequence[Tuple[str, Union[str, bytes]]] 

543 ]: 

544 """Pre-rpc interceptor for validate_schema 

545 

546 Override in a subclass to manipulate the request or metadata 

547 before they are sent to the SchemaService server. 

548 """ 

549 return request, metadata 

550 

551 def post_validate_schema( 

552 self, response: gp_schema.ValidateSchemaResponse 

553 ) -> gp_schema.ValidateSchemaResponse: 

554 """Post-rpc interceptor for validate_schema 

555 

556 DEPRECATED. Please use the `post_validate_schema_with_metadata` 

557 interceptor instead. 

558 

559 Override in a subclass to read or manipulate the response 

560 after it is returned by the SchemaService server but before 

561 it is returned to user code. This `post_validate_schema` interceptor runs 

562 before the `post_validate_schema_with_metadata` interceptor. 

563 """ 

564 return response 

565 

566 def post_validate_schema_with_metadata( 

567 self, 

568 response: gp_schema.ValidateSchemaResponse, 

569 metadata: Sequence[Tuple[str, Union[str, bytes]]], 

570 ) -> Tuple[ 

571 gp_schema.ValidateSchemaResponse, Sequence[Tuple[str, Union[str, bytes]]] 

572 ]: 

573 """Post-rpc interceptor for validate_schema 

574 

575 Override in a subclass to read or manipulate the response or metadata after it 

576 is returned by the SchemaService server but before it is returned to user code. 

577 

578 We recommend only using this `post_validate_schema_with_metadata` 

579 interceptor in new development instead of the `post_validate_schema` interceptor. 

580 When both interceptors are used, this `post_validate_schema_with_metadata` interceptor runs after the 

581 `post_validate_schema` interceptor. The (possibly modified) response returned by 

582 `post_validate_schema` will be passed to 

583 `post_validate_schema_with_metadata`. 

584 """ 

585 return response, metadata 

586 

587 def pre_get_iam_policy( 

588 self, 

589 request: iam_policy_pb2.GetIamPolicyRequest, 

590 metadata: Sequence[Tuple[str, Union[str, bytes]]], 

591 ) -> Tuple[ 

592 iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] 

593 ]: 

594 """Pre-rpc interceptor for get_iam_policy 

595 

596 Override in a subclass to manipulate the request or metadata 

597 before they are sent to the SchemaService server. 

598 """ 

599 return request, metadata 

600 

601 def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: 

602 """Post-rpc interceptor for get_iam_policy 

603 

604 Override in a subclass to manipulate the response 

605 after it is returned by the SchemaService server but before 

606 it is returned to user code. 

607 """ 

608 return response 

609 

610 def pre_set_iam_policy( 

611 self, 

612 request: iam_policy_pb2.SetIamPolicyRequest, 

613 metadata: Sequence[Tuple[str, Union[str, bytes]]], 

614 ) -> Tuple[ 

615 iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] 

616 ]: 

617 """Pre-rpc interceptor for set_iam_policy 

618 

619 Override in a subclass to manipulate the request or metadata 

620 before they are sent to the SchemaService server. 

621 """ 

622 return request, metadata 

623 

624 def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: 

625 """Post-rpc interceptor for set_iam_policy 

626 

627 Override in a subclass to manipulate the response 

628 after it is returned by the SchemaService server but before 

629 it is returned to user code. 

630 """ 

631 return response 

632 

633 def pre_test_iam_permissions( 

634 self, 

635 request: iam_policy_pb2.TestIamPermissionsRequest, 

636 metadata: Sequence[Tuple[str, Union[str, bytes]]], 

637 ) -> Tuple[ 

638 iam_policy_pb2.TestIamPermissionsRequest, 

639 Sequence[Tuple[str, Union[str, bytes]]], 

640 ]: 

641 """Pre-rpc interceptor for test_iam_permissions 

642 

643 Override in a subclass to manipulate the request or metadata 

644 before they are sent to the SchemaService server. 

645 """ 

646 return request, metadata 

647 

648 def post_test_iam_permissions( 

649 self, response: iam_policy_pb2.TestIamPermissionsResponse 

650 ) -> iam_policy_pb2.TestIamPermissionsResponse: 

651 """Post-rpc interceptor for test_iam_permissions 

652 

653 Override in a subclass to manipulate the response 

654 after it is returned by the SchemaService server but before 

655 it is returned to user code. 

656 """ 

657 return response 

658 

659 

660@dataclasses.dataclass 

661class SchemaServiceRestStub: 

662 _session: AuthorizedSession 

663 _host: str 

664 _interceptor: SchemaServiceRestInterceptor 

665 

666 

667class SchemaServiceRestTransport(_BaseSchemaServiceRestTransport): 

668 """REST backend synchronous transport for SchemaService. 

669 

670 Service for doing schema-related operations. 

671 

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

673 primary client can load the underlying transport implementation 

674 and call it. 

675 

676 It sends JSON representations of protocol buffers over HTTP/1.1 

677 """ 

678 

679 def __init__( 

680 self, 

681 *, 

682 host: str = "pubsub.googleapis.com", 

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

684 credentials_file: Optional[str] = None, 

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

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

687 quota_project_id: Optional[str] = None, 

688 client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, 

689 always_use_jwt_access: Optional[bool] = False, 

690 url_scheme: str = "https", 

691 interceptor: Optional[SchemaServiceRestInterceptor] = None, 

692 api_audience: Optional[str] = None, 

693 ) -> None: 

694 """Instantiate the transport. 

695 

696 Args: 

697 host (Optional[str]): 

698 The hostname to connect to (default: 'pubsub.googleapis.com'). 

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

700 authorization credentials to attach to requests. These 

701 credentials identify the application to the service; if none 

702 are specified, the client will attempt to ascertain the 

703 credentials from the environment. 

704 

705 credentials_file (Optional[str]): Deprecated. A file with credentials that can 

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

707 This argument is ignored if ``channel`` is provided. This argument will be 

708 removed in the next major version of this library. 

709 scopes (Optional(Sequence[str])): A list of scopes. This argument is 

710 ignored if ``channel`` is provided. 

711 client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client 

712 certificate to configure mutual TLS HTTP channel. It is ignored 

713 if ``channel`` is provided. 

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

715 and quota. 

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

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

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

719 Generally, you only need to set this if you are developing 

720 your own client library. 

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

722 be used for service account credentials. 

723 url_scheme: the protocol scheme for the API endpoint. Normally 

724 "https", but for testing or local servers, 

725 "http" can be specified. 

726 """ 

727 # Run the base constructor 

728 # TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc. 

729 # TODO: When custom host (api_endpoint) is set, `scopes` must *also* be set on the 

730 # credentials object 

731 super().__init__( 

732 host=host, 

733 credentials=credentials, 

734 client_info=client_info, 

735 always_use_jwt_access=always_use_jwt_access, 

736 url_scheme=url_scheme, 

737 api_audience=api_audience, 

738 ) 

739 self._session = AuthorizedSession( 

740 self._credentials, default_host=self.DEFAULT_HOST 

741 ) 

742 if client_cert_source_for_mtls: 

743 self._session.configure_mtls_channel(client_cert_source_for_mtls) 

744 self._interceptor = interceptor or SchemaServiceRestInterceptor() 

745 self._prep_wrapped_messages(client_info) 

746 

747 class _CommitSchema( 

748 _BaseSchemaServiceRestTransport._BaseCommitSchema, SchemaServiceRestStub 

749 ): 

750 def __hash__(self): 

751 return hash("SchemaServiceRestTransport.CommitSchema") 

752 

753 @staticmethod 

754 def _get_response( 

755 host, 

756 metadata, 

757 query_params, 

758 session, 

759 timeout, 

760 transcoded_request, 

761 body=None, 

762 ): 

763 uri = transcoded_request["uri"] 

764 method = transcoded_request["method"] 

765 headers = dict(metadata) 

766 headers["Content-Type"] = "application/json" 

767 response = getattr(session, method)( 

768 "{host}{uri}".format(host=host, uri=uri), 

769 timeout=timeout, 

770 headers=headers, 

771 params=rest_helpers.flatten_query_params(query_params, strict=True), 

772 data=body, 

773 ) 

774 return response 

775 

776 def __call__( 

777 self, 

778 request: gp_schema.CommitSchemaRequest, 

779 *, 

780 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

781 timeout: Optional[float] = None, 

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

783 ) -> gp_schema.Schema: 

784 r"""Call the commit schema method over HTTP. 

785 

786 Args: 

787 request (~.gp_schema.CommitSchemaRequest): 

788 The request object. Request for CommitSchema method. 

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

790 should be retried. 

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

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

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

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

795 be of type `bytes`. 

796 

797 Returns: 

798 ~.gp_schema.Schema: 

799 A schema resource. 

800 """ 

801 

802 http_options = ( 

803 _BaseSchemaServiceRestTransport._BaseCommitSchema._get_http_options() 

804 ) 

805 

806 request, metadata = self._interceptor.pre_commit_schema(request, metadata) 

807 transcoded_request = _BaseSchemaServiceRestTransport._BaseCommitSchema._get_transcoded_request( 

808 http_options, request 

809 ) 

810 

811 body = _BaseSchemaServiceRestTransport._BaseCommitSchema._get_request_body_json( 

812 transcoded_request 

813 ) 

814 

815 # Jsonify the query params 

816 query_params = _BaseSchemaServiceRestTransport._BaseCommitSchema._get_query_params_json( 

817 transcoded_request 

818 ) 

819 

820 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

821 logging.DEBUG 

822 ): # pragma: NO COVER 

823 request_url = "{host}{uri}".format( 

824 host=self._host, uri=transcoded_request["uri"] 

825 ) 

826 method = transcoded_request["method"] 

827 try: 

828 request_payload = type(request).to_json(request) 

829 except: 

830 request_payload = None 

831 http_request = { 

832 "payload": request_payload, 

833 "requestMethod": method, 

834 "requestUrl": request_url, 

835 "headers": dict(metadata), 

836 } 

837 _LOGGER.debug( 

838 f"Sending request for google.pubsub_v1.SchemaServiceClient.CommitSchema", 

839 extra={ 

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

841 "rpcName": "CommitSchema", 

842 "httpRequest": http_request, 

843 "metadata": http_request["headers"], 

844 }, 

845 ) 

846 

847 # Send the request 

848 response = SchemaServiceRestTransport._CommitSchema._get_response( 

849 self._host, 

850 metadata, 

851 query_params, 

852 self._session, 

853 timeout, 

854 transcoded_request, 

855 body, 

856 ) 

857 

858 # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception 

859 # subclass. 

860 if response.status_code >= 400: 

861 raise core_exceptions.from_http_response(response) 

862 

863 # Return the response 

864 resp = gp_schema.Schema() 

865 pb_resp = gp_schema.Schema.pb(resp) 

866 

867 json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) 

868 

869 resp = self._interceptor.post_commit_schema(resp) 

870 response_metadata = [(k, str(v)) for k, v in response.headers.items()] 

871 resp, _ = self._interceptor.post_commit_schema_with_metadata( 

872 resp, response_metadata 

873 ) 

874 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

875 logging.DEBUG 

876 ): # pragma: NO COVER 

877 try: 

878 response_payload = gp_schema.Schema.to_json(response) 

879 except: 

880 response_payload = None 

881 http_response = { 

882 "payload": response_payload, 

883 "headers": dict(response.headers), 

884 "status": response.status_code, 

885 } 

886 _LOGGER.debug( 

887 "Received response for google.pubsub_v1.SchemaServiceClient.commit_schema", 

888 extra={ 

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

890 "rpcName": "CommitSchema", 

891 "metadata": http_response["headers"], 

892 "httpResponse": http_response, 

893 }, 

894 ) 

895 return resp 

896 

897 class _CreateSchema( 

898 _BaseSchemaServiceRestTransport._BaseCreateSchema, SchemaServiceRestStub 

899 ): 

900 def __hash__(self): 

901 return hash("SchemaServiceRestTransport.CreateSchema") 

902 

903 @staticmethod 

904 def _get_response( 

905 host, 

906 metadata, 

907 query_params, 

908 session, 

909 timeout, 

910 transcoded_request, 

911 body=None, 

912 ): 

913 uri = transcoded_request["uri"] 

914 method = transcoded_request["method"] 

915 headers = dict(metadata) 

916 headers["Content-Type"] = "application/json" 

917 response = getattr(session, method)( 

918 "{host}{uri}".format(host=host, uri=uri), 

919 timeout=timeout, 

920 headers=headers, 

921 params=rest_helpers.flatten_query_params(query_params, strict=True), 

922 data=body, 

923 ) 

924 return response 

925 

926 def __call__( 

927 self, 

928 request: gp_schema.CreateSchemaRequest, 

929 *, 

930 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

931 timeout: Optional[float] = None, 

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

933 ) -> gp_schema.Schema: 

934 r"""Call the create schema method over HTTP. 

935 

936 Args: 

937 request (~.gp_schema.CreateSchemaRequest): 

938 The request object. Request for the CreateSchema method. 

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

940 should be retried. 

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

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

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

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

945 be of type `bytes`. 

946 

947 Returns: 

948 ~.gp_schema.Schema: 

949 A schema resource. 

950 """ 

951 

952 http_options = ( 

953 _BaseSchemaServiceRestTransport._BaseCreateSchema._get_http_options() 

954 ) 

955 

956 request, metadata = self._interceptor.pre_create_schema(request, metadata) 

957 transcoded_request = _BaseSchemaServiceRestTransport._BaseCreateSchema._get_transcoded_request( 

958 http_options, request 

959 ) 

960 

961 body = _BaseSchemaServiceRestTransport._BaseCreateSchema._get_request_body_json( 

962 transcoded_request 

963 ) 

964 

965 # Jsonify the query params 

966 query_params = _BaseSchemaServiceRestTransport._BaseCreateSchema._get_query_params_json( 

967 transcoded_request 

968 ) 

969 

970 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

971 logging.DEBUG 

972 ): # pragma: NO COVER 

973 request_url = "{host}{uri}".format( 

974 host=self._host, uri=transcoded_request["uri"] 

975 ) 

976 method = transcoded_request["method"] 

977 try: 

978 request_payload = type(request).to_json(request) 

979 except: 

980 request_payload = None 

981 http_request = { 

982 "payload": request_payload, 

983 "requestMethod": method, 

984 "requestUrl": request_url, 

985 "headers": dict(metadata), 

986 } 

987 _LOGGER.debug( 

988 f"Sending request for google.pubsub_v1.SchemaServiceClient.CreateSchema", 

989 extra={ 

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

991 "rpcName": "CreateSchema", 

992 "httpRequest": http_request, 

993 "metadata": http_request["headers"], 

994 }, 

995 ) 

996 

997 # Send the request 

998 response = SchemaServiceRestTransport._CreateSchema._get_response( 

999 self._host, 

1000 metadata, 

1001 query_params, 

1002 self._session, 

1003 timeout, 

1004 transcoded_request, 

1005 body, 

1006 ) 

1007 

1008 # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception 

1009 # subclass. 

1010 if response.status_code >= 400: 

1011 raise core_exceptions.from_http_response(response) 

1012 

1013 # Return the response 

1014 resp = gp_schema.Schema() 

1015 pb_resp = gp_schema.Schema.pb(resp) 

1016 

1017 json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) 

1018 

1019 resp = self._interceptor.post_create_schema(resp) 

1020 response_metadata = [(k, str(v)) for k, v in response.headers.items()] 

1021 resp, _ = self._interceptor.post_create_schema_with_metadata( 

1022 resp, response_metadata 

1023 ) 

1024 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1025 logging.DEBUG 

1026 ): # pragma: NO COVER 

1027 try: 

1028 response_payload = gp_schema.Schema.to_json(response) 

1029 except: 

1030 response_payload = None 

1031 http_response = { 

1032 "payload": response_payload, 

1033 "headers": dict(response.headers), 

1034 "status": response.status_code, 

1035 } 

1036 _LOGGER.debug( 

1037 "Received response for google.pubsub_v1.SchemaServiceClient.create_schema", 

1038 extra={ 

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

1040 "rpcName": "CreateSchema", 

1041 "metadata": http_response["headers"], 

1042 "httpResponse": http_response, 

1043 }, 

1044 ) 

1045 return resp 

1046 

1047 class _DeleteSchema( 

1048 _BaseSchemaServiceRestTransport._BaseDeleteSchema, SchemaServiceRestStub 

1049 ): 

1050 def __hash__(self): 

1051 return hash("SchemaServiceRestTransport.DeleteSchema") 

1052 

1053 @staticmethod 

1054 def _get_response( 

1055 host, 

1056 metadata, 

1057 query_params, 

1058 session, 

1059 timeout, 

1060 transcoded_request, 

1061 body=None, 

1062 ): 

1063 uri = transcoded_request["uri"] 

1064 method = transcoded_request["method"] 

1065 headers = dict(metadata) 

1066 headers["Content-Type"] = "application/json" 

1067 response = getattr(session, method)( 

1068 "{host}{uri}".format(host=host, uri=uri), 

1069 timeout=timeout, 

1070 headers=headers, 

1071 params=rest_helpers.flatten_query_params(query_params, strict=True), 

1072 ) 

1073 return response 

1074 

1075 def __call__( 

1076 self, 

1077 request: schema.DeleteSchemaRequest, 

1078 *, 

1079 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1080 timeout: Optional[float] = None, 

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

1082 ): 

1083 r"""Call the delete schema method over HTTP. 

1084 

1085 Args: 

1086 request (~.schema.DeleteSchemaRequest): 

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

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

1089 should be retried. 

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

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

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

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

1094 be of type `bytes`. 

1095 """ 

1096 

1097 http_options = ( 

1098 _BaseSchemaServiceRestTransport._BaseDeleteSchema._get_http_options() 

1099 ) 

1100 

1101 request, metadata = self._interceptor.pre_delete_schema(request, metadata) 

1102 transcoded_request = _BaseSchemaServiceRestTransport._BaseDeleteSchema._get_transcoded_request( 

1103 http_options, request 

1104 ) 

1105 

1106 # Jsonify the query params 

1107 query_params = _BaseSchemaServiceRestTransport._BaseDeleteSchema._get_query_params_json( 

1108 transcoded_request 

1109 ) 

1110 

1111 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1112 logging.DEBUG 

1113 ): # pragma: NO COVER 

1114 request_url = "{host}{uri}".format( 

1115 host=self._host, uri=transcoded_request["uri"] 

1116 ) 

1117 method = transcoded_request["method"] 

1118 try: 

1119 request_payload = json_format.MessageToJson(request) 

1120 except: 

1121 request_payload = None 

1122 http_request = { 

1123 "payload": request_payload, 

1124 "requestMethod": method, 

1125 "requestUrl": request_url, 

1126 "headers": dict(metadata), 

1127 } 

1128 _LOGGER.debug( 

1129 f"Sending request for google.pubsub_v1.SchemaServiceClient.DeleteSchema", 

1130 extra={ 

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

1132 "rpcName": "DeleteSchema", 

1133 "httpRequest": http_request, 

1134 "metadata": http_request["headers"], 

1135 }, 

1136 ) 

1137 

1138 # Send the request 

1139 response = SchemaServiceRestTransport._DeleteSchema._get_response( 

1140 self._host, 

1141 metadata, 

1142 query_params, 

1143 self._session, 

1144 timeout, 

1145 transcoded_request, 

1146 ) 

1147 

1148 # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception 

1149 # subclass. 

1150 if response.status_code >= 400: 

1151 raise core_exceptions.from_http_response(response) 

1152 

1153 class _DeleteSchemaRevision( 

1154 _BaseSchemaServiceRestTransport._BaseDeleteSchemaRevision, SchemaServiceRestStub 

1155 ): 

1156 def __hash__(self): 

1157 return hash("SchemaServiceRestTransport.DeleteSchemaRevision") 

1158 

1159 @staticmethod 

1160 def _get_response( 

1161 host, 

1162 metadata, 

1163 query_params, 

1164 session, 

1165 timeout, 

1166 transcoded_request, 

1167 body=None, 

1168 ): 

1169 uri = transcoded_request["uri"] 

1170 method = transcoded_request["method"] 

1171 headers = dict(metadata) 

1172 headers["Content-Type"] = "application/json" 

1173 response = getattr(session, method)( 

1174 "{host}{uri}".format(host=host, uri=uri), 

1175 timeout=timeout, 

1176 headers=headers, 

1177 params=rest_helpers.flatten_query_params(query_params, strict=True), 

1178 ) 

1179 return response 

1180 

1181 def __call__( 

1182 self, 

1183 request: schema.DeleteSchemaRevisionRequest, 

1184 *, 

1185 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1186 timeout: Optional[float] = None, 

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

1188 ) -> schema.Schema: 

1189 r"""Call the delete schema revision method over HTTP. 

1190 

1191 Args: 

1192 request (~.schema.DeleteSchemaRevisionRequest): 

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

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

1195 should be retried. 

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

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

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

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

1200 be of type `bytes`. 

1201 

1202 Returns: 

1203 ~.schema.Schema: 

1204 A schema resource. 

1205 """ 

1206 

1207 http_options = ( 

1208 _BaseSchemaServiceRestTransport._BaseDeleteSchemaRevision._get_http_options() 

1209 ) 

1210 

1211 request, metadata = self._interceptor.pre_delete_schema_revision( 

1212 request, metadata 

1213 ) 

1214 transcoded_request = _BaseSchemaServiceRestTransport._BaseDeleteSchemaRevision._get_transcoded_request( 

1215 http_options, request 

1216 ) 

1217 

1218 # Jsonify the query params 

1219 query_params = _BaseSchemaServiceRestTransport._BaseDeleteSchemaRevision._get_query_params_json( 

1220 transcoded_request 

1221 ) 

1222 

1223 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1224 logging.DEBUG 

1225 ): # pragma: NO COVER 

1226 request_url = "{host}{uri}".format( 

1227 host=self._host, uri=transcoded_request["uri"] 

1228 ) 

1229 method = transcoded_request["method"] 

1230 try: 

1231 request_payload = type(request).to_json(request) 

1232 except: 

1233 request_payload = None 

1234 http_request = { 

1235 "payload": request_payload, 

1236 "requestMethod": method, 

1237 "requestUrl": request_url, 

1238 "headers": dict(metadata), 

1239 } 

1240 _LOGGER.debug( 

1241 f"Sending request for google.pubsub_v1.SchemaServiceClient.DeleteSchemaRevision", 

1242 extra={ 

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

1244 "rpcName": "DeleteSchemaRevision", 

1245 "httpRequest": http_request, 

1246 "metadata": http_request["headers"], 

1247 }, 

1248 ) 

1249 

1250 # Send the request 

1251 response = SchemaServiceRestTransport._DeleteSchemaRevision._get_response( 

1252 self._host, 

1253 metadata, 

1254 query_params, 

1255 self._session, 

1256 timeout, 

1257 transcoded_request, 

1258 ) 

1259 

1260 # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception 

1261 # subclass. 

1262 if response.status_code >= 400: 

1263 raise core_exceptions.from_http_response(response) 

1264 

1265 # Return the response 

1266 resp = schema.Schema() 

1267 pb_resp = schema.Schema.pb(resp) 

1268 

1269 json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) 

1270 

1271 resp = self._interceptor.post_delete_schema_revision(resp) 

1272 response_metadata = [(k, str(v)) for k, v in response.headers.items()] 

1273 resp, _ = self._interceptor.post_delete_schema_revision_with_metadata( 

1274 resp, response_metadata 

1275 ) 

1276 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1277 logging.DEBUG 

1278 ): # pragma: NO COVER 

1279 try: 

1280 response_payload = schema.Schema.to_json(response) 

1281 except: 

1282 response_payload = None 

1283 http_response = { 

1284 "payload": response_payload, 

1285 "headers": dict(response.headers), 

1286 "status": response.status_code, 

1287 } 

1288 _LOGGER.debug( 

1289 "Received response for google.pubsub_v1.SchemaServiceClient.delete_schema_revision", 

1290 extra={ 

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

1292 "rpcName": "DeleteSchemaRevision", 

1293 "metadata": http_response["headers"], 

1294 "httpResponse": http_response, 

1295 }, 

1296 ) 

1297 return resp 

1298 

1299 class _GetSchema( 

1300 _BaseSchemaServiceRestTransport._BaseGetSchema, SchemaServiceRestStub 

1301 ): 

1302 def __hash__(self): 

1303 return hash("SchemaServiceRestTransport.GetSchema") 

1304 

1305 @staticmethod 

1306 def _get_response( 

1307 host, 

1308 metadata, 

1309 query_params, 

1310 session, 

1311 timeout, 

1312 transcoded_request, 

1313 body=None, 

1314 ): 

1315 uri = transcoded_request["uri"] 

1316 method = transcoded_request["method"] 

1317 headers = dict(metadata) 

1318 headers["Content-Type"] = "application/json" 

1319 response = getattr(session, method)( 

1320 "{host}{uri}".format(host=host, uri=uri), 

1321 timeout=timeout, 

1322 headers=headers, 

1323 params=rest_helpers.flatten_query_params(query_params, strict=True), 

1324 ) 

1325 return response 

1326 

1327 def __call__( 

1328 self, 

1329 request: schema.GetSchemaRequest, 

1330 *, 

1331 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1332 timeout: Optional[float] = None, 

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

1334 ) -> schema.Schema: 

1335 r"""Call the get schema method over HTTP. 

1336 

1337 Args: 

1338 request (~.schema.GetSchemaRequest): 

1339 The request object. Request for the GetSchema method. 

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

1341 should be retried. 

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

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

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

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

1346 be of type `bytes`. 

1347 

1348 Returns: 

1349 ~.schema.Schema: 

1350 A schema resource. 

1351 """ 

1352 

1353 http_options = ( 

1354 _BaseSchemaServiceRestTransport._BaseGetSchema._get_http_options() 

1355 ) 

1356 

1357 request, metadata = self._interceptor.pre_get_schema(request, metadata) 

1358 transcoded_request = ( 

1359 _BaseSchemaServiceRestTransport._BaseGetSchema._get_transcoded_request( 

1360 http_options, request 

1361 ) 

1362 ) 

1363 

1364 # Jsonify the query params 

1365 query_params = ( 

1366 _BaseSchemaServiceRestTransport._BaseGetSchema._get_query_params_json( 

1367 transcoded_request 

1368 ) 

1369 ) 

1370 

1371 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1372 logging.DEBUG 

1373 ): # pragma: NO COVER 

1374 request_url = "{host}{uri}".format( 

1375 host=self._host, uri=transcoded_request["uri"] 

1376 ) 

1377 method = transcoded_request["method"] 

1378 try: 

1379 request_payload = type(request).to_json(request) 

1380 except: 

1381 request_payload = None 

1382 http_request = { 

1383 "payload": request_payload, 

1384 "requestMethod": method, 

1385 "requestUrl": request_url, 

1386 "headers": dict(metadata), 

1387 } 

1388 _LOGGER.debug( 

1389 f"Sending request for google.pubsub_v1.SchemaServiceClient.GetSchema", 

1390 extra={ 

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

1392 "rpcName": "GetSchema", 

1393 "httpRequest": http_request, 

1394 "metadata": http_request["headers"], 

1395 }, 

1396 ) 

1397 

1398 # Send the request 

1399 response = SchemaServiceRestTransport._GetSchema._get_response( 

1400 self._host, 

1401 metadata, 

1402 query_params, 

1403 self._session, 

1404 timeout, 

1405 transcoded_request, 

1406 ) 

1407 

1408 # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception 

1409 # subclass. 

1410 if response.status_code >= 400: 

1411 raise core_exceptions.from_http_response(response) 

1412 

1413 # Return the response 

1414 resp = schema.Schema() 

1415 pb_resp = schema.Schema.pb(resp) 

1416 

1417 json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) 

1418 

1419 resp = self._interceptor.post_get_schema(resp) 

1420 response_metadata = [(k, str(v)) for k, v in response.headers.items()] 

1421 resp, _ = self._interceptor.post_get_schema_with_metadata( 

1422 resp, response_metadata 

1423 ) 

1424 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1425 logging.DEBUG 

1426 ): # pragma: NO COVER 

1427 try: 

1428 response_payload = schema.Schema.to_json(response) 

1429 except: 

1430 response_payload = None 

1431 http_response = { 

1432 "payload": response_payload, 

1433 "headers": dict(response.headers), 

1434 "status": response.status_code, 

1435 } 

1436 _LOGGER.debug( 

1437 "Received response for google.pubsub_v1.SchemaServiceClient.get_schema", 

1438 extra={ 

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

1440 "rpcName": "GetSchema", 

1441 "metadata": http_response["headers"], 

1442 "httpResponse": http_response, 

1443 }, 

1444 ) 

1445 return resp 

1446 

1447 class _ListSchemaRevisions( 

1448 _BaseSchemaServiceRestTransport._BaseListSchemaRevisions, SchemaServiceRestStub 

1449 ): 

1450 def __hash__(self): 

1451 return hash("SchemaServiceRestTransport.ListSchemaRevisions") 

1452 

1453 @staticmethod 

1454 def _get_response( 

1455 host, 

1456 metadata, 

1457 query_params, 

1458 session, 

1459 timeout, 

1460 transcoded_request, 

1461 body=None, 

1462 ): 

1463 uri = transcoded_request["uri"] 

1464 method = transcoded_request["method"] 

1465 headers = dict(metadata) 

1466 headers["Content-Type"] = "application/json" 

1467 response = getattr(session, method)( 

1468 "{host}{uri}".format(host=host, uri=uri), 

1469 timeout=timeout, 

1470 headers=headers, 

1471 params=rest_helpers.flatten_query_params(query_params, strict=True), 

1472 ) 

1473 return response 

1474 

1475 def __call__( 

1476 self, 

1477 request: schema.ListSchemaRevisionsRequest, 

1478 *, 

1479 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1480 timeout: Optional[float] = None, 

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

1482 ) -> schema.ListSchemaRevisionsResponse: 

1483 r"""Call the list schema revisions method over HTTP. 

1484 

1485 Args: 

1486 request (~.schema.ListSchemaRevisionsRequest): 

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

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

1489 should be retried. 

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

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

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

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

1494 be of type `bytes`. 

1495 

1496 Returns: 

1497 ~.schema.ListSchemaRevisionsResponse: 

1498 Response for the ``ListSchemaRevisions`` method. 

1499 """ 

1500 

1501 http_options = ( 

1502 _BaseSchemaServiceRestTransport._BaseListSchemaRevisions._get_http_options() 

1503 ) 

1504 

1505 request, metadata = self._interceptor.pre_list_schema_revisions( 

1506 request, metadata 

1507 ) 

1508 transcoded_request = _BaseSchemaServiceRestTransport._BaseListSchemaRevisions._get_transcoded_request( 

1509 http_options, request 

1510 ) 

1511 

1512 # Jsonify the query params 

1513 query_params = _BaseSchemaServiceRestTransport._BaseListSchemaRevisions._get_query_params_json( 

1514 transcoded_request 

1515 ) 

1516 

1517 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1518 logging.DEBUG 

1519 ): # pragma: NO COVER 

1520 request_url = "{host}{uri}".format( 

1521 host=self._host, uri=transcoded_request["uri"] 

1522 ) 

1523 method = transcoded_request["method"] 

1524 try: 

1525 request_payload = type(request).to_json(request) 

1526 except: 

1527 request_payload = None 

1528 http_request = { 

1529 "payload": request_payload, 

1530 "requestMethod": method, 

1531 "requestUrl": request_url, 

1532 "headers": dict(metadata), 

1533 } 

1534 _LOGGER.debug( 

1535 f"Sending request for google.pubsub_v1.SchemaServiceClient.ListSchemaRevisions", 

1536 extra={ 

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

1538 "rpcName": "ListSchemaRevisions", 

1539 "httpRequest": http_request, 

1540 "metadata": http_request["headers"], 

1541 }, 

1542 ) 

1543 

1544 # Send the request 

1545 response = SchemaServiceRestTransport._ListSchemaRevisions._get_response( 

1546 self._host, 

1547 metadata, 

1548 query_params, 

1549 self._session, 

1550 timeout, 

1551 transcoded_request, 

1552 ) 

1553 

1554 # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception 

1555 # subclass. 

1556 if response.status_code >= 400: 

1557 raise core_exceptions.from_http_response(response) 

1558 

1559 # Return the response 

1560 resp = schema.ListSchemaRevisionsResponse() 

1561 pb_resp = schema.ListSchemaRevisionsResponse.pb(resp) 

1562 

1563 json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) 

1564 

1565 resp = self._interceptor.post_list_schema_revisions(resp) 

1566 response_metadata = [(k, str(v)) for k, v in response.headers.items()] 

1567 resp, _ = self._interceptor.post_list_schema_revisions_with_metadata( 

1568 resp, response_metadata 

1569 ) 

1570 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1571 logging.DEBUG 

1572 ): # pragma: NO COVER 

1573 try: 

1574 response_payload = schema.ListSchemaRevisionsResponse.to_json( 

1575 response 

1576 ) 

1577 except: 

1578 response_payload = None 

1579 http_response = { 

1580 "payload": response_payload, 

1581 "headers": dict(response.headers), 

1582 "status": response.status_code, 

1583 } 

1584 _LOGGER.debug( 

1585 "Received response for google.pubsub_v1.SchemaServiceClient.list_schema_revisions", 

1586 extra={ 

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

1588 "rpcName": "ListSchemaRevisions", 

1589 "metadata": http_response["headers"], 

1590 "httpResponse": http_response, 

1591 }, 

1592 ) 

1593 return resp 

1594 

1595 class _ListSchemas( 

1596 _BaseSchemaServiceRestTransport._BaseListSchemas, SchemaServiceRestStub 

1597 ): 

1598 def __hash__(self): 

1599 return hash("SchemaServiceRestTransport.ListSchemas") 

1600 

1601 @staticmethod 

1602 def _get_response( 

1603 host, 

1604 metadata, 

1605 query_params, 

1606 session, 

1607 timeout, 

1608 transcoded_request, 

1609 body=None, 

1610 ): 

1611 uri = transcoded_request["uri"] 

1612 method = transcoded_request["method"] 

1613 headers = dict(metadata) 

1614 headers["Content-Type"] = "application/json" 

1615 response = getattr(session, method)( 

1616 "{host}{uri}".format(host=host, uri=uri), 

1617 timeout=timeout, 

1618 headers=headers, 

1619 params=rest_helpers.flatten_query_params(query_params, strict=True), 

1620 ) 

1621 return response 

1622 

1623 def __call__( 

1624 self, 

1625 request: schema.ListSchemasRequest, 

1626 *, 

1627 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1628 timeout: Optional[float] = None, 

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

1630 ) -> schema.ListSchemasResponse: 

1631 r"""Call the list schemas method over HTTP. 

1632 

1633 Args: 

1634 request (~.schema.ListSchemasRequest): 

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

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

1637 should be retried. 

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

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

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

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

1642 be of type `bytes`. 

1643 

1644 Returns: 

1645 ~.schema.ListSchemasResponse: 

1646 Response for the ``ListSchemas`` method. 

1647 """ 

1648 

1649 http_options = ( 

1650 _BaseSchemaServiceRestTransport._BaseListSchemas._get_http_options() 

1651 ) 

1652 

1653 request, metadata = self._interceptor.pre_list_schemas(request, metadata) 

1654 transcoded_request = _BaseSchemaServiceRestTransport._BaseListSchemas._get_transcoded_request( 

1655 http_options, request 

1656 ) 

1657 

1658 # Jsonify the query params 

1659 query_params = ( 

1660 _BaseSchemaServiceRestTransport._BaseListSchemas._get_query_params_json( 

1661 transcoded_request 

1662 ) 

1663 ) 

1664 

1665 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1666 logging.DEBUG 

1667 ): # pragma: NO COVER 

1668 request_url = "{host}{uri}".format( 

1669 host=self._host, uri=transcoded_request["uri"] 

1670 ) 

1671 method = transcoded_request["method"] 

1672 try: 

1673 request_payload = type(request).to_json(request) 

1674 except: 

1675 request_payload = None 

1676 http_request = { 

1677 "payload": request_payload, 

1678 "requestMethod": method, 

1679 "requestUrl": request_url, 

1680 "headers": dict(metadata), 

1681 } 

1682 _LOGGER.debug( 

1683 f"Sending request for google.pubsub_v1.SchemaServiceClient.ListSchemas", 

1684 extra={ 

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

1686 "rpcName": "ListSchemas", 

1687 "httpRequest": http_request, 

1688 "metadata": http_request["headers"], 

1689 }, 

1690 ) 

1691 

1692 # Send the request 

1693 response = SchemaServiceRestTransport._ListSchemas._get_response( 

1694 self._host, 

1695 metadata, 

1696 query_params, 

1697 self._session, 

1698 timeout, 

1699 transcoded_request, 

1700 ) 

1701 

1702 # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception 

1703 # subclass. 

1704 if response.status_code >= 400: 

1705 raise core_exceptions.from_http_response(response) 

1706 

1707 # Return the response 

1708 resp = schema.ListSchemasResponse() 

1709 pb_resp = schema.ListSchemasResponse.pb(resp) 

1710 

1711 json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) 

1712 

1713 resp = self._interceptor.post_list_schemas(resp) 

1714 response_metadata = [(k, str(v)) for k, v in response.headers.items()] 

1715 resp, _ = self._interceptor.post_list_schemas_with_metadata( 

1716 resp, response_metadata 

1717 ) 

1718 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1719 logging.DEBUG 

1720 ): # pragma: NO COVER 

1721 try: 

1722 response_payload = schema.ListSchemasResponse.to_json(response) 

1723 except: 

1724 response_payload = None 

1725 http_response = { 

1726 "payload": response_payload, 

1727 "headers": dict(response.headers), 

1728 "status": response.status_code, 

1729 } 

1730 _LOGGER.debug( 

1731 "Received response for google.pubsub_v1.SchemaServiceClient.list_schemas", 

1732 extra={ 

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

1734 "rpcName": "ListSchemas", 

1735 "metadata": http_response["headers"], 

1736 "httpResponse": http_response, 

1737 }, 

1738 ) 

1739 return resp 

1740 

1741 class _RollbackSchema( 

1742 _BaseSchemaServiceRestTransport._BaseRollbackSchema, SchemaServiceRestStub 

1743 ): 

1744 def __hash__(self): 

1745 return hash("SchemaServiceRestTransport.RollbackSchema") 

1746 

1747 @staticmethod 

1748 def _get_response( 

1749 host, 

1750 metadata, 

1751 query_params, 

1752 session, 

1753 timeout, 

1754 transcoded_request, 

1755 body=None, 

1756 ): 

1757 uri = transcoded_request["uri"] 

1758 method = transcoded_request["method"] 

1759 headers = dict(metadata) 

1760 headers["Content-Type"] = "application/json" 

1761 response = getattr(session, method)( 

1762 "{host}{uri}".format(host=host, uri=uri), 

1763 timeout=timeout, 

1764 headers=headers, 

1765 params=rest_helpers.flatten_query_params(query_params, strict=True), 

1766 data=body, 

1767 ) 

1768 return response 

1769 

1770 def __call__( 

1771 self, 

1772 request: schema.RollbackSchemaRequest, 

1773 *, 

1774 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1775 timeout: Optional[float] = None, 

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

1777 ) -> schema.Schema: 

1778 r"""Call the rollback schema method over HTTP. 

1779 

1780 Args: 

1781 request (~.schema.RollbackSchemaRequest): 

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

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

1784 should be retried. 

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

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

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

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

1789 be of type `bytes`. 

1790 

1791 Returns: 

1792 ~.schema.Schema: 

1793 A schema resource. 

1794 """ 

1795 

1796 http_options = ( 

1797 _BaseSchemaServiceRestTransport._BaseRollbackSchema._get_http_options() 

1798 ) 

1799 

1800 request, metadata = self._interceptor.pre_rollback_schema(request, metadata) 

1801 transcoded_request = _BaseSchemaServiceRestTransport._BaseRollbackSchema._get_transcoded_request( 

1802 http_options, request 

1803 ) 

1804 

1805 body = _BaseSchemaServiceRestTransport._BaseRollbackSchema._get_request_body_json( 

1806 transcoded_request 

1807 ) 

1808 

1809 # Jsonify the query params 

1810 query_params = _BaseSchemaServiceRestTransport._BaseRollbackSchema._get_query_params_json( 

1811 transcoded_request 

1812 ) 

1813 

1814 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1815 logging.DEBUG 

1816 ): # pragma: NO COVER 

1817 request_url = "{host}{uri}".format( 

1818 host=self._host, uri=transcoded_request["uri"] 

1819 ) 

1820 method = transcoded_request["method"] 

1821 try: 

1822 request_payload = type(request).to_json(request) 

1823 except: 

1824 request_payload = None 

1825 http_request = { 

1826 "payload": request_payload, 

1827 "requestMethod": method, 

1828 "requestUrl": request_url, 

1829 "headers": dict(metadata), 

1830 } 

1831 _LOGGER.debug( 

1832 f"Sending request for google.pubsub_v1.SchemaServiceClient.RollbackSchema", 

1833 extra={ 

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

1835 "rpcName": "RollbackSchema", 

1836 "httpRequest": http_request, 

1837 "metadata": http_request["headers"], 

1838 }, 

1839 ) 

1840 

1841 # Send the request 

1842 response = SchemaServiceRestTransport._RollbackSchema._get_response( 

1843 self._host, 

1844 metadata, 

1845 query_params, 

1846 self._session, 

1847 timeout, 

1848 transcoded_request, 

1849 body, 

1850 ) 

1851 

1852 # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception 

1853 # subclass. 

1854 if response.status_code >= 400: 

1855 raise core_exceptions.from_http_response(response) 

1856 

1857 # Return the response 

1858 resp = schema.Schema() 

1859 pb_resp = schema.Schema.pb(resp) 

1860 

1861 json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) 

1862 

1863 resp = self._interceptor.post_rollback_schema(resp) 

1864 response_metadata = [(k, str(v)) for k, v in response.headers.items()] 

1865 resp, _ = self._interceptor.post_rollback_schema_with_metadata( 

1866 resp, response_metadata 

1867 ) 

1868 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1869 logging.DEBUG 

1870 ): # pragma: NO COVER 

1871 try: 

1872 response_payload = schema.Schema.to_json(response) 

1873 except: 

1874 response_payload = None 

1875 http_response = { 

1876 "payload": response_payload, 

1877 "headers": dict(response.headers), 

1878 "status": response.status_code, 

1879 } 

1880 _LOGGER.debug( 

1881 "Received response for google.pubsub_v1.SchemaServiceClient.rollback_schema", 

1882 extra={ 

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

1884 "rpcName": "RollbackSchema", 

1885 "metadata": http_response["headers"], 

1886 "httpResponse": http_response, 

1887 }, 

1888 ) 

1889 return resp 

1890 

1891 class _ValidateMessage( 

1892 _BaseSchemaServiceRestTransport._BaseValidateMessage, SchemaServiceRestStub 

1893 ): 

1894 def __hash__(self): 

1895 return hash("SchemaServiceRestTransport.ValidateMessage") 

1896 

1897 @staticmethod 

1898 def _get_response( 

1899 host, 

1900 metadata, 

1901 query_params, 

1902 session, 

1903 timeout, 

1904 transcoded_request, 

1905 body=None, 

1906 ): 

1907 uri = transcoded_request["uri"] 

1908 method = transcoded_request["method"] 

1909 headers = dict(metadata) 

1910 headers["Content-Type"] = "application/json" 

1911 response = getattr(session, method)( 

1912 "{host}{uri}".format(host=host, uri=uri), 

1913 timeout=timeout, 

1914 headers=headers, 

1915 params=rest_helpers.flatten_query_params(query_params, strict=True), 

1916 data=body, 

1917 ) 

1918 return response 

1919 

1920 def __call__( 

1921 self, 

1922 request: schema.ValidateMessageRequest, 

1923 *, 

1924 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1925 timeout: Optional[float] = None, 

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

1927 ) -> schema.ValidateMessageResponse: 

1928 r"""Call the validate message method over HTTP. 

1929 

1930 Args: 

1931 request (~.schema.ValidateMessageRequest): 

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

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

1934 should be retried. 

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

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

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

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

1939 be of type `bytes`. 

1940 

1941 Returns: 

1942 ~.schema.ValidateMessageResponse: 

1943 Response for the ``ValidateMessage`` method. Empty for 

1944 now. 

1945 

1946 """ 

1947 

1948 http_options = ( 

1949 _BaseSchemaServiceRestTransport._BaseValidateMessage._get_http_options() 

1950 ) 

1951 

1952 request, metadata = self._interceptor.pre_validate_message( 

1953 request, metadata 

1954 ) 

1955 transcoded_request = _BaseSchemaServiceRestTransport._BaseValidateMessage._get_transcoded_request( 

1956 http_options, request 

1957 ) 

1958 

1959 body = _BaseSchemaServiceRestTransport._BaseValidateMessage._get_request_body_json( 

1960 transcoded_request 

1961 ) 

1962 

1963 # Jsonify the query params 

1964 query_params = _BaseSchemaServiceRestTransport._BaseValidateMessage._get_query_params_json( 

1965 transcoded_request 

1966 ) 

1967 

1968 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1969 logging.DEBUG 

1970 ): # pragma: NO COVER 

1971 request_url = "{host}{uri}".format( 

1972 host=self._host, uri=transcoded_request["uri"] 

1973 ) 

1974 method = transcoded_request["method"] 

1975 try: 

1976 request_payload = type(request).to_json(request) 

1977 except: 

1978 request_payload = None 

1979 http_request = { 

1980 "payload": request_payload, 

1981 "requestMethod": method, 

1982 "requestUrl": request_url, 

1983 "headers": dict(metadata), 

1984 } 

1985 _LOGGER.debug( 

1986 f"Sending request for google.pubsub_v1.SchemaServiceClient.ValidateMessage", 

1987 extra={ 

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

1989 "rpcName": "ValidateMessage", 

1990 "httpRequest": http_request, 

1991 "metadata": http_request["headers"], 

1992 }, 

1993 ) 

1994 

1995 # Send the request 

1996 response = SchemaServiceRestTransport._ValidateMessage._get_response( 

1997 self._host, 

1998 metadata, 

1999 query_params, 

2000 self._session, 

2001 timeout, 

2002 transcoded_request, 

2003 body, 

2004 ) 

2005 

2006 # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception 

2007 # subclass. 

2008 if response.status_code >= 400: 

2009 raise core_exceptions.from_http_response(response) 

2010 

2011 # Return the response 

2012 resp = schema.ValidateMessageResponse() 

2013 pb_resp = schema.ValidateMessageResponse.pb(resp) 

2014 

2015 json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) 

2016 

2017 resp = self._interceptor.post_validate_message(resp) 

2018 response_metadata = [(k, str(v)) for k, v in response.headers.items()] 

2019 resp, _ = self._interceptor.post_validate_message_with_metadata( 

2020 resp, response_metadata 

2021 ) 

2022 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

2023 logging.DEBUG 

2024 ): # pragma: NO COVER 

2025 try: 

2026 response_payload = schema.ValidateMessageResponse.to_json(response) 

2027 except: 

2028 response_payload = None 

2029 http_response = { 

2030 "payload": response_payload, 

2031 "headers": dict(response.headers), 

2032 "status": response.status_code, 

2033 } 

2034 _LOGGER.debug( 

2035 "Received response for google.pubsub_v1.SchemaServiceClient.validate_message", 

2036 extra={ 

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

2038 "rpcName": "ValidateMessage", 

2039 "metadata": http_response["headers"], 

2040 "httpResponse": http_response, 

2041 }, 

2042 ) 

2043 return resp 

2044 

2045 class _ValidateSchema( 

2046 _BaseSchemaServiceRestTransport._BaseValidateSchema, SchemaServiceRestStub 

2047 ): 

2048 def __hash__(self): 

2049 return hash("SchemaServiceRestTransport.ValidateSchema") 

2050 

2051 @staticmethod 

2052 def _get_response( 

2053 host, 

2054 metadata, 

2055 query_params, 

2056 session, 

2057 timeout, 

2058 transcoded_request, 

2059 body=None, 

2060 ): 

2061 uri = transcoded_request["uri"] 

2062 method = transcoded_request["method"] 

2063 headers = dict(metadata) 

2064 headers["Content-Type"] = "application/json" 

2065 response = getattr(session, method)( 

2066 "{host}{uri}".format(host=host, uri=uri), 

2067 timeout=timeout, 

2068 headers=headers, 

2069 params=rest_helpers.flatten_query_params(query_params, strict=True), 

2070 data=body, 

2071 ) 

2072 return response 

2073 

2074 def __call__( 

2075 self, 

2076 request: gp_schema.ValidateSchemaRequest, 

2077 *, 

2078 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

2079 timeout: Optional[float] = None, 

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

2081 ) -> gp_schema.ValidateSchemaResponse: 

2082 r"""Call the validate schema method over HTTP. 

2083 

2084 Args: 

2085 request (~.gp_schema.ValidateSchemaRequest): 

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

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

2088 should be retried. 

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

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

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

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

2093 be of type `bytes`. 

2094 

2095 Returns: 

2096 ~.gp_schema.ValidateSchemaResponse: 

2097 Response for the ``ValidateSchema`` method. Empty for 

2098 now. 

2099 

2100 """ 

2101 

2102 http_options = ( 

2103 _BaseSchemaServiceRestTransport._BaseValidateSchema._get_http_options() 

2104 ) 

2105 

2106 request, metadata = self._interceptor.pre_validate_schema(request, metadata) 

2107 transcoded_request = _BaseSchemaServiceRestTransport._BaseValidateSchema._get_transcoded_request( 

2108 http_options, request 

2109 ) 

2110 

2111 body = _BaseSchemaServiceRestTransport._BaseValidateSchema._get_request_body_json( 

2112 transcoded_request 

2113 ) 

2114 

2115 # Jsonify the query params 

2116 query_params = _BaseSchemaServiceRestTransport._BaseValidateSchema._get_query_params_json( 

2117 transcoded_request 

2118 ) 

2119 

2120 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

2121 logging.DEBUG 

2122 ): # pragma: NO COVER 

2123 request_url = "{host}{uri}".format( 

2124 host=self._host, uri=transcoded_request["uri"] 

2125 ) 

2126 method = transcoded_request["method"] 

2127 try: 

2128 request_payload = type(request).to_json(request) 

2129 except: 

2130 request_payload = None 

2131 http_request = { 

2132 "payload": request_payload, 

2133 "requestMethod": method, 

2134 "requestUrl": request_url, 

2135 "headers": dict(metadata), 

2136 } 

2137 _LOGGER.debug( 

2138 f"Sending request for google.pubsub_v1.SchemaServiceClient.ValidateSchema", 

2139 extra={ 

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

2141 "rpcName": "ValidateSchema", 

2142 "httpRequest": http_request, 

2143 "metadata": http_request["headers"], 

2144 }, 

2145 ) 

2146 

2147 # Send the request 

2148 response = SchemaServiceRestTransport._ValidateSchema._get_response( 

2149 self._host, 

2150 metadata, 

2151 query_params, 

2152 self._session, 

2153 timeout, 

2154 transcoded_request, 

2155 body, 

2156 ) 

2157 

2158 # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception 

2159 # subclass. 

2160 if response.status_code >= 400: 

2161 raise core_exceptions.from_http_response(response) 

2162 

2163 # Return the response 

2164 resp = gp_schema.ValidateSchemaResponse() 

2165 pb_resp = gp_schema.ValidateSchemaResponse.pb(resp) 

2166 

2167 json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) 

2168 

2169 resp = self._interceptor.post_validate_schema(resp) 

2170 response_metadata = [(k, str(v)) for k, v in response.headers.items()] 

2171 resp, _ = self._interceptor.post_validate_schema_with_metadata( 

2172 resp, response_metadata 

2173 ) 

2174 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

2175 logging.DEBUG 

2176 ): # pragma: NO COVER 

2177 try: 

2178 response_payload = gp_schema.ValidateSchemaResponse.to_json( 

2179 response 

2180 ) 

2181 except: 

2182 response_payload = None 

2183 http_response = { 

2184 "payload": response_payload, 

2185 "headers": dict(response.headers), 

2186 "status": response.status_code, 

2187 } 

2188 _LOGGER.debug( 

2189 "Received response for google.pubsub_v1.SchemaServiceClient.validate_schema", 

2190 extra={ 

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

2192 "rpcName": "ValidateSchema", 

2193 "metadata": http_response["headers"], 

2194 "httpResponse": http_response, 

2195 }, 

2196 ) 

2197 return resp 

2198 

2199 @property 

2200 def commit_schema( 

2201 self, 

2202 ) -> Callable[[gp_schema.CommitSchemaRequest], gp_schema.Schema]: 

2203 # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. 

2204 # In C++ this would require a dynamic_cast 

2205 return self._CommitSchema(self._session, self._host, self._interceptor) # type: ignore 

2206 

2207 @property 

2208 def create_schema( 

2209 self, 

2210 ) -> Callable[[gp_schema.CreateSchemaRequest], gp_schema.Schema]: 

2211 # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. 

2212 # In C++ this would require a dynamic_cast 

2213 return self._CreateSchema(self._session, self._host, self._interceptor) # type: ignore 

2214 

2215 @property 

2216 def delete_schema(self) -> Callable[[schema.DeleteSchemaRequest], empty_pb2.Empty]: 

2217 # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. 

2218 # In C++ this would require a dynamic_cast 

2219 return self._DeleteSchema(self._session, self._host, self._interceptor) # type: ignore 

2220 

2221 @property 

2222 def delete_schema_revision( 

2223 self, 

2224 ) -> Callable[[schema.DeleteSchemaRevisionRequest], schema.Schema]: 

2225 # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. 

2226 # In C++ this would require a dynamic_cast 

2227 return self._DeleteSchemaRevision(self._session, self._host, self._interceptor) # type: ignore 

2228 

2229 @property 

2230 def get_schema(self) -> Callable[[schema.GetSchemaRequest], schema.Schema]: 

2231 # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. 

2232 # In C++ this would require a dynamic_cast 

2233 return self._GetSchema(self._session, self._host, self._interceptor) # type: ignore 

2234 

2235 @property 

2236 def list_schema_revisions( 

2237 self, 

2238 ) -> Callable[ 

2239 [schema.ListSchemaRevisionsRequest], schema.ListSchemaRevisionsResponse 

2240 ]: 

2241 # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. 

2242 # In C++ this would require a dynamic_cast 

2243 return self._ListSchemaRevisions(self._session, self._host, self._interceptor) # type: ignore 

2244 

2245 @property 

2246 def list_schemas( 

2247 self, 

2248 ) -> Callable[[schema.ListSchemasRequest], schema.ListSchemasResponse]: 

2249 # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. 

2250 # In C++ this would require a dynamic_cast 

2251 return self._ListSchemas(self._session, self._host, self._interceptor) # type: ignore 

2252 

2253 @property 

2254 def rollback_schema( 

2255 self, 

2256 ) -> Callable[[schema.RollbackSchemaRequest], schema.Schema]: 

2257 # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. 

2258 # In C++ this would require a dynamic_cast 

2259 return self._RollbackSchema(self._session, self._host, self._interceptor) # type: ignore 

2260 

2261 @property 

2262 def validate_message( 

2263 self, 

2264 ) -> Callable[[schema.ValidateMessageRequest], schema.ValidateMessageResponse]: 

2265 # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. 

2266 # In C++ this would require a dynamic_cast 

2267 return self._ValidateMessage(self._session, self._host, self._interceptor) # type: ignore 

2268 

2269 @property 

2270 def validate_schema( 

2271 self, 

2272 ) -> Callable[[gp_schema.ValidateSchemaRequest], gp_schema.ValidateSchemaResponse]: 

2273 # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. 

2274 # In C++ this would require a dynamic_cast 

2275 return self._ValidateSchema(self._session, self._host, self._interceptor) # type: ignore 

2276 

2277 @property 

2278 def get_iam_policy(self): 

2279 return self._GetIamPolicy(self._session, self._host, self._interceptor) # type: ignore 

2280 

2281 class _GetIamPolicy( 

2282 _BaseSchemaServiceRestTransport._BaseGetIamPolicy, SchemaServiceRestStub 

2283 ): 

2284 def __hash__(self): 

2285 return hash("SchemaServiceRestTransport.GetIamPolicy") 

2286 

2287 @staticmethod 

2288 def _get_response( 

2289 host, 

2290 metadata, 

2291 query_params, 

2292 session, 

2293 timeout, 

2294 transcoded_request, 

2295 body=None, 

2296 ): 

2297 uri = transcoded_request["uri"] 

2298 method = transcoded_request["method"] 

2299 headers = dict(metadata) 

2300 headers["Content-Type"] = "application/json" 

2301 response = getattr(session, method)( 

2302 "{host}{uri}".format(host=host, uri=uri), 

2303 timeout=timeout, 

2304 headers=headers, 

2305 params=rest_helpers.flatten_query_params(query_params, strict=True), 

2306 ) 

2307 return response 

2308 

2309 def __call__( 

2310 self, 

2311 request: iam_policy_pb2.GetIamPolicyRequest, 

2312 *, 

2313 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

2314 timeout: Optional[float] = None, 

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

2316 ) -> policy_pb2.Policy: 

2317 r"""Call the get iam policy method over HTTP. 

2318 

2319 Args: 

2320 request (iam_policy_pb2.GetIamPolicyRequest): 

2321 The request object for GetIamPolicy method. 

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

2323 should be retried. 

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

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

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

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

2328 be of type `bytes`. 

2329 

2330 Returns: 

2331 policy_pb2.Policy: Response from GetIamPolicy method. 

2332 """ 

2333 

2334 http_options = ( 

2335 _BaseSchemaServiceRestTransport._BaseGetIamPolicy._get_http_options() 

2336 ) 

2337 

2338 request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) 

2339 transcoded_request = _BaseSchemaServiceRestTransport._BaseGetIamPolicy._get_transcoded_request( 

2340 http_options, request 

2341 ) 

2342 

2343 # Jsonify the query params 

2344 query_params = _BaseSchemaServiceRestTransport._BaseGetIamPolicy._get_query_params_json( 

2345 transcoded_request 

2346 ) 

2347 

2348 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

2349 logging.DEBUG 

2350 ): # pragma: NO COVER 

2351 request_url = "{host}{uri}".format( 

2352 host=self._host, uri=transcoded_request["uri"] 

2353 ) 

2354 method = transcoded_request["method"] 

2355 try: 

2356 request_payload = json_format.MessageToJson(request) 

2357 except: 

2358 request_payload = None 

2359 http_request = { 

2360 "payload": request_payload, 

2361 "requestMethod": method, 

2362 "requestUrl": request_url, 

2363 "headers": dict(metadata), 

2364 } 

2365 _LOGGER.debug( 

2366 f"Sending request for google.pubsub_v1.SchemaServiceClient.GetIamPolicy", 

2367 extra={ 

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

2369 "rpcName": "GetIamPolicy", 

2370 "httpRequest": http_request, 

2371 "metadata": http_request["headers"], 

2372 }, 

2373 ) 

2374 

2375 # Send the request 

2376 response = SchemaServiceRestTransport._GetIamPolicy._get_response( 

2377 self._host, 

2378 metadata, 

2379 query_params, 

2380 self._session, 

2381 timeout, 

2382 transcoded_request, 

2383 ) 

2384 

2385 # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception 

2386 # subclass. 

2387 if response.status_code >= 400: 

2388 raise core_exceptions.from_http_response(response) 

2389 

2390 content = response.content.decode("utf-8") 

2391 resp = policy_pb2.Policy() 

2392 resp = json_format.Parse(content, resp) 

2393 resp = self._interceptor.post_get_iam_policy(resp) 

2394 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

2395 logging.DEBUG 

2396 ): # pragma: NO COVER 

2397 try: 

2398 response_payload = json_format.MessageToJson(resp) 

2399 except: 

2400 response_payload = None 

2401 http_response = { 

2402 "payload": response_payload, 

2403 "headers": dict(response.headers), 

2404 "status": response.status_code, 

2405 } 

2406 _LOGGER.debug( 

2407 "Received response for google.pubsub_v1.SchemaServiceAsyncClient.GetIamPolicy", 

2408 extra={ 

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

2410 "rpcName": "GetIamPolicy", 

2411 "httpResponse": http_response, 

2412 "metadata": http_response["headers"], 

2413 }, 

2414 ) 

2415 return resp 

2416 

2417 @property 

2418 def set_iam_policy(self): 

2419 return self._SetIamPolicy(self._session, self._host, self._interceptor) # type: ignore 

2420 

2421 class _SetIamPolicy( 

2422 _BaseSchemaServiceRestTransport._BaseSetIamPolicy, SchemaServiceRestStub 

2423 ): 

2424 def __hash__(self): 

2425 return hash("SchemaServiceRestTransport.SetIamPolicy") 

2426 

2427 @staticmethod 

2428 def _get_response( 

2429 host, 

2430 metadata, 

2431 query_params, 

2432 session, 

2433 timeout, 

2434 transcoded_request, 

2435 body=None, 

2436 ): 

2437 uri = transcoded_request["uri"] 

2438 method = transcoded_request["method"] 

2439 headers = dict(metadata) 

2440 headers["Content-Type"] = "application/json" 

2441 response = getattr(session, method)( 

2442 "{host}{uri}".format(host=host, uri=uri), 

2443 timeout=timeout, 

2444 headers=headers, 

2445 params=rest_helpers.flatten_query_params(query_params, strict=True), 

2446 data=body, 

2447 ) 

2448 return response 

2449 

2450 def __call__( 

2451 self, 

2452 request: iam_policy_pb2.SetIamPolicyRequest, 

2453 *, 

2454 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

2455 timeout: Optional[float] = None, 

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

2457 ) -> policy_pb2.Policy: 

2458 r"""Call the set iam policy method over HTTP. 

2459 

2460 Args: 

2461 request (iam_policy_pb2.SetIamPolicyRequest): 

2462 The request object for SetIamPolicy method. 

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

2464 should be retried. 

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

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

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

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

2469 be of type `bytes`. 

2470 

2471 Returns: 

2472 policy_pb2.Policy: Response from SetIamPolicy method. 

2473 """ 

2474 

2475 http_options = ( 

2476 _BaseSchemaServiceRestTransport._BaseSetIamPolicy._get_http_options() 

2477 ) 

2478 

2479 request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) 

2480 transcoded_request = _BaseSchemaServiceRestTransport._BaseSetIamPolicy._get_transcoded_request( 

2481 http_options, request 

2482 ) 

2483 

2484 body = _BaseSchemaServiceRestTransport._BaseSetIamPolicy._get_request_body_json( 

2485 transcoded_request 

2486 ) 

2487 

2488 # Jsonify the query params 

2489 query_params = _BaseSchemaServiceRestTransport._BaseSetIamPolicy._get_query_params_json( 

2490 transcoded_request 

2491 ) 

2492 

2493 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

2494 logging.DEBUG 

2495 ): # pragma: NO COVER 

2496 request_url = "{host}{uri}".format( 

2497 host=self._host, uri=transcoded_request["uri"] 

2498 ) 

2499 method = transcoded_request["method"] 

2500 try: 

2501 request_payload = json_format.MessageToJson(request) 

2502 except: 

2503 request_payload = None 

2504 http_request = { 

2505 "payload": request_payload, 

2506 "requestMethod": method, 

2507 "requestUrl": request_url, 

2508 "headers": dict(metadata), 

2509 } 

2510 _LOGGER.debug( 

2511 f"Sending request for google.pubsub_v1.SchemaServiceClient.SetIamPolicy", 

2512 extra={ 

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

2514 "rpcName": "SetIamPolicy", 

2515 "httpRequest": http_request, 

2516 "metadata": http_request["headers"], 

2517 }, 

2518 ) 

2519 

2520 # Send the request 

2521 response = SchemaServiceRestTransport._SetIamPolicy._get_response( 

2522 self._host, 

2523 metadata, 

2524 query_params, 

2525 self._session, 

2526 timeout, 

2527 transcoded_request, 

2528 body, 

2529 ) 

2530 

2531 # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception 

2532 # subclass. 

2533 if response.status_code >= 400: 

2534 raise core_exceptions.from_http_response(response) 

2535 

2536 content = response.content.decode("utf-8") 

2537 resp = policy_pb2.Policy() 

2538 resp = json_format.Parse(content, resp) 

2539 resp = self._interceptor.post_set_iam_policy(resp) 

2540 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

2541 logging.DEBUG 

2542 ): # pragma: NO COVER 

2543 try: 

2544 response_payload = json_format.MessageToJson(resp) 

2545 except: 

2546 response_payload = None 

2547 http_response = { 

2548 "payload": response_payload, 

2549 "headers": dict(response.headers), 

2550 "status": response.status_code, 

2551 } 

2552 _LOGGER.debug( 

2553 "Received response for google.pubsub_v1.SchemaServiceAsyncClient.SetIamPolicy", 

2554 extra={ 

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

2556 "rpcName": "SetIamPolicy", 

2557 "httpResponse": http_response, 

2558 "metadata": http_response["headers"], 

2559 }, 

2560 ) 

2561 return resp 

2562 

2563 @property 

2564 def test_iam_permissions(self): 

2565 return self._TestIamPermissions(self._session, self._host, self._interceptor) # type: ignore 

2566 

2567 class _TestIamPermissions( 

2568 _BaseSchemaServiceRestTransport._BaseTestIamPermissions, SchemaServiceRestStub 

2569 ): 

2570 def __hash__(self): 

2571 return hash("SchemaServiceRestTransport.TestIamPermissions") 

2572 

2573 @staticmethod 

2574 def _get_response( 

2575 host, 

2576 metadata, 

2577 query_params, 

2578 session, 

2579 timeout, 

2580 transcoded_request, 

2581 body=None, 

2582 ): 

2583 uri = transcoded_request["uri"] 

2584 method = transcoded_request["method"] 

2585 headers = dict(metadata) 

2586 headers["Content-Type"] = "application/json" 

2587 response = getattr(session, method)( 

2588 "{host}{uri}".format(host=host, uri=uri), 

2589 timeout=timeout, 

2590 headers=headers, 

2591 params=rest_helpers.flatten_query_params(query_params, strict=True), 

2592 data=body, 

2593 ) 

2594 return response 

2595 

2596 def __call__( 

2597 self, 

2598 request: iam_policy_pb2.TestIamPermissionsRequest, 

2599 *, 

2600 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

2601 timeout: Optional[float] = None, 

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

2603 ) -> iam_policy_pb2.TestIamPermissionsResponse: 

2604 r"""Call the test iam permissions method over HTTP. 

2605 

2606 Args: 

2607 request (iam_policy_pb2.TestIamPermissionsRequest): 

2608 The request object for TestIamPermissions method. 

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

2610 should be retried. 

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

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

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

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

2615 be of type `bytes`. 

2616 

2617 Returns: 

2618 iam_policy_pb2.TestIamPermissionsResponse: Response from TestIamPermissions method. 

2619 """ 

2620 

2621 http_options = ( 

2622 _BaseSchemaServiceRestTransport._BaseTestIamPermissions._get_http_options() 

2623 ) 

2624 

2625 request, metadata = self._interceptor.pre_test_iam_permissions( 

2626 request, metadata 

2627 ) 

2628 transcoded_request = _BaseSchemaServiceRestTransport._BaseTestIamPermissions._get_transcoded_request( 

2629 http_options, request 

2630 ) 

2631 

2632 body = _BaseSchemaServiceRestTransport._BaseTestIamPermissions._get_request_body_json( 

2633 transcoded_request 

2634 ) 

2635 

2636 # Jsonify the query params 

2637 query_params = _BaseSchemaServiceRestTransport._BaseTestIamPermissions._get_query_params_json( 

2638 transcoded_request 

2639 ) 

2640 

2641 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

2642 logging.DEBUG 

2643 ): # pragma: NO COVER 

2644 request_url = "{host}{uri}".format( 

2645 host=self._host, uri=transcoded_request["uri"] 

2646 ) 

2647 method = transcoded_request["method"] 

2648 try: 

2649 request_payload = json_format.MessageToJson(request) 

2650 except: 

2651 request_payload = None 

2652 http_request = { 

2653 "payload": request_payload, 

2654 "requestMethod": method, 

2655 "requestUrl": request_url, 

2656 "headers": dict(metadata), 

2657 } 

2658 _LOGGER.debug( 

2659 f"Sending request for google.pubsub_v1.SchemaServiceClient.TestIamPermissions", 

2660 extra={ 

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

2662 "rpcName": "TestIamPermissions", 

2663 "httpRequest": http_request, 

2664 "metadata": http_request["headers"], 

2665 }, 

2666 ) 

2667 

2668 # Send the request 

2669 response = SchemaServiceRestTransport._TestIamPermissions._get_response( 

2670 self._host, 

2671 metadata, 

2672 query_params, 

2673 self._session, 

2674 timeout, 

2675 transcoded_request, 

2676 body, 

2677 ) 

2678 

2679 # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception 

2680 # subclass. 

2681 if response.status_code >= 400: 

2682 raise core_exceptions.from_http_response(response) 

2683 

2684 content = response.content.decode("utf-8") 

2685 resp = iam_policy_pb2.TestIamPermissionsResponse() 

2686 resp = json_format.Parse(content, resp) 

2687 resp = self._interceptor.post_test_iam_permissions(resp) 

2688 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

2689 logging.DEBUG 

2690 ): # pragma: NO COVER 

2691 try: 

2692 response_payload = json_format.MessageToJson(resp) 

2693 except: 

2694 response_payload = None 

2695 http_response = { 

2696 "payload": response_payload, 

2697 "headers": dict(response.headers), 

2698 "status": response.status_code, 

2699 } 

2700 _LOGGER.debug( 

2701 "Received response for google.pubsub_v1.SchemaServiceAsyncClient.TestIamPermissions", 

2702 extra={ 

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

2704 "rpcName": "TestIamPermissions", 

2705 "httpResponse": http_response, 

2706 "metadata": http_response["headers"], 

2707 }, 

2708 ) 

2709 return resp 

2710 

2711 @property 

2712 def kind(self) -> str: 

2713 return "rest" 

2714 

2715 def close(self): 

2716 self._session.close() 

2717 

2718 

2719__all__ = ("SchemaServiceRestTransport",)