Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.10/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

486 statements  

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

2# Copyright 2024 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 

26 

27from google.protobuf import json_format 

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

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

30 

31from requests import __version__ as requests_version 

32import dataclasses 

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

34import warnings 

35 

36 

37from google.protobuf import empty_pb2 # type: ignore 

38from google.pubsub_v1.types import schema 

39from google.pubsub_v1.types import schema as gp_schema 

40 

41 

42from .rest_base import _BaseSchemaServiceRestTransport 

43from .base import DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO 

44 

45try: 

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

47except AttributeError: # pragma: NO COVER 

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

49 

50try: 

51 from google.api_core import client_logging # type: ignore 

52 

53 CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER 

54except ImportError: # pragma: NO COVER 

55 CLIENT_LOGGING_SUPPORTED = False 

56 

57_LOGGER = logging.getLogger(__name__) 

58 

59DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( 

60 gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, 

61 grpc_version=None, 

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

63) 

64 

65 

66class SchemaServiceRestInterceptor: 

67 """Interceptor for SchemaService. 

68 

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

70 in arbitrary ways. 

71 Example use cases include: 

72 * Logging 

73 * Verifying requests according to service or custom semantics 

74 * Stripping extraneous information from responses 

75 

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

77 instance of a custom subclass when constructing the SchemaServiceRestTransport. 

78 

79 .. code-block:: python 

80 class MyCustomSchemaServiceInterceptor(SchemaServiceRestInterceptor): 

81 def pre_commit_schema(self, request, metadata): 

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

83 return request, metadata 

84 

85 def post_commit_schema(self, response): 

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

87 return response 

88 

89 def pre_create_schema(self, request, metadata): 

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

91 return request, metadata 

92 

93 def post_create_schema(self, response): 

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

95 return response 

96 

97 def pre_delete_schema(self, request, metadata): 

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

99 return request, metadata 

100 

101 def pre_delete_schema_revision(self, request, metadata): 

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

103 return request, metadata 

104 

105 def post_delete_schema_revision(self, response): 

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

107 return response 

108 

109 def pre_get_schema(self, request, metadata): 

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

111 return request, metadata 

112 

113 def post_get_schema(self, response): 

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

115 return response 

116 

117 def pre_list_schema_revisions(self, request, metadata): 

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

119 return request, metadata 

120 

121 def post_list_schema_revisions(self, response): 

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

123 return response 

124 

125 def pre_list_schemas(self, request, metadata): 

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

127 return request, metadata 

128 

129 def post_list_schemas(self, response): 

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

131 return response 

132 

133 def pre_rollback_schema(self, request, metadata): 

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

135 return request, metadata 

136 

137 def post_rollback_schema(self, response): 

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

139 return response 

140 

141 def pre_validate_message(self, request, metadata): 

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

143 return request, metadata 

144 

145 def post_validate_message(self, response): 

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

147 return response 

148 

149 def pre_validate_schema(self, request, metadata): 

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

151 return request, metadata 

152 

153 def post_validate_schema(self, response): 

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

155 return response 

156 

157 transport = SchemaServiceRestTransport(interceptor=MyCustomSchemaServiceInterceptor()) 

158 client = SchemaServiceClient(transport=transport) 

159 

160 

161 """ 

162 

163 def pre_commit_schema( 

164 self, 

165 request: gp_schema.CommitSchemaRequest, 

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

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

168 """Pre-rpc interceptor for commit_schema 

169 

170 Override in a subclass to manipulate the request or metadata 

171 before they are sent to the SchemaService server. 

172 """ 

173 return request, metadata 

174 

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

176 """Post-rpc interceptor for commit_schema 

177 

178 DEPRECATED. Please use the `post_commit_schema_with_metadata` 

179 interceptor instead. 

180 

181 Override in a subclass to read or manipulate the response 

182 after it is returned by the SchemaService server but before 

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

184 before the `post_commit_schema_with_metadata` interceptor. 

185 """ 

186 return response 

187 

188 def post_commit_schema_with_metadata( 

189 self, 

190 response: gp_schema.Schema, 

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

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

193 """Post-rpc interceptor for commit_schema 

194 

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

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

197 

198 We recommend only using this `post_commit_schema_with_metadata` 

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

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

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

202 `post_commit_schema` will be passed to 

203 `post_commit_schema_with_metadata`. 

204 """ 

205 return response, metadata 

206 

207 def pre_create_schema( 

208 self, 

209 request: gp_schema.CreateSchemaRequest, 

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

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

212 """Pre-rpc interceptor for create_schema 

213 

214 Override in a subclass to manipulate the request or metadata 

215 before they are sent to the SchemaService server. 

216 """ 

217 return request, metadata 

218 

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

220 """Post-rpc interceptor for create_schema 

221 

222 DEPRECATED. Please use the `post_create_schema_with_metadata` 

223 interceptor instead. 

224 

225 Override in a subclass to read or manipulate the response 

226 after it is returned by the SchemaService server but before 

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

228 before the `post_create_schema_with_metadata` interceptor. 

229 """ 

230 return response 

231 

232 def post_create_schema_with_metadata( 

233 self, 

234 response: gp_schema.Schema, 

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

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

237 """Post-rpc interceptor for create_schema 

238 

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

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

241 

242 We recommend only using this `post_create_schema_with_metadata` 

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

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

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

246 `post_create_schema` will be passed to 

247 `post_create_schema_with_metadata`. 

248 """ 

249 return response, metadata 

250 

251 def pre_delete_schema( 

252 self, 

253 request: schema.DeleteSchemaRequest, 

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

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

256 """Pre-rpc interceptor for delete_schema 

257 

258 Override in a subclass to manipulate the request or metadata 

259 before they are sent to the SchemaService server. 

260 """ 

261 return request, metadata 

262 

263 def pre_delete_schema_revision( 

264 self, 

265 request: schema.DeleteSchemaRevisionRequest, 

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

267 ) -> Tuple[ 

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

269 ]: 

270 """Pre-rpc interceptor for delete_schema_revision 

271 

272 Override in a subclass to manipulate the request or metadata 

273 before they are sent to the SchemaService server. 

274 """ 

275 return request, metadata 

276 

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

278 """Post-rpc interceptor for delete_schema_revision 

279 

280 DEPRECATED. Please use the `post_delete_schema_revision_with_metadata` 

281 interceptor instead. 

282 

283 Override in a subclass to read or manipulate the response 

284 after it is returned by the SchemaService server but before 

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

286 before the `post_delete_schema_revision_with_metadata` interceptor. 

287 """ 

288 return response 

289 

290 def post_delete_schema_revision_with_metadata( 

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

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

293 """Post-rpc interceptor for delete_schema_revision 

294 

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

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

297 

298 We recommend only using this `post_delete_schema_revision_with_metadata` 

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

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

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

302 `post_delete_schema_revision` will be passed to 

303 `post_delete_schema_revision_with_metadata`. 

304 """ 

305 return response, metadata 

306 

307 def pre_get_schema( 

308 self, 

309 request: schema.GetSchemaRequest, 

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

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

312 """Pre-rpc interceptor for get_schema 

313 

314 Override in a subclass to manipulate the request or metadata 

315 before they are sent to the SchemaService server. 

316 """ 

317 return request, metadata 

318 

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

320 """Post-rpc interceptor for get_schema 

321 

322 DEPRECATED. Please use the `post_get_schema_with_metadata` 

323 interceptor instead. 

324 

325 Override in a subclass to read or manipulate the response 

326 after it is returned by the SchemaService server but before 

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

328 before the `post_get_schema_with_metadata` interceptor. 

329 """ 

330 return response 

331 

332 def post_get_schema_with_metadata( 

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

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

335 """Post-rpc interceptor for get_schema 

336 

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

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

339 

340 We recommend only using this `post_get_schema_with_metadata` 

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

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

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

344 `post_get_schema` will be passed to 

345 `post_get_schema_with_metadata`. 

346 """ 

347 return response, metadata 

348 

349 def pre_list_schema_revisions( 

350 self, 

351 request: schema.ListSchemaRevisionsRequest, 

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

353 ) -> Tuple[ 

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

355 ]: 

356 """Pre-rpc interceptor for list_schema_revisions 

357 

358 Override in a subclass to manipulate the request or metadata 

359 before they are sent to the SchemaService server. 

360 """ 

361 return request, metadata 

362 

363 def post_list_schema_revisions( 

364 self, response: schema.ListSchemaRevisionsResponse 

365 ) -> schema.ListSchemaRevisionsResponse: 

366 """Post-rpc interceptor for list_schema_revisions 

367 

368 DEPRECATED. Please use the `post_list_schema_revisions_with_metadata` 

369 interceptor instead. 

370 

371 Override in a subclass to read or manipulate the response 

372 after it is returned by the SchemaService server but before 

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

374 before the `post_list_schema_revisions_with_metadata` interceptor. 

375 """ 

376 return response 

377 

378 def post_list_schema_revisions_with_metadata( 

379 self, 

380 response: schema.ListSchemaRevisionsResponse, 

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

382 ) -> Tuple[ 

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

384 ]: 

385 """Post-rpc interceptor for list_schema_revisions 

386 

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

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

389 

390 We recommend only using this `post_list_schema_revisions_with_metadata` 

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

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

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

394 `post_list_schema_revisions` will be passed to 

395 `post_list_schema_revisions_with_metadata`. 

396 """ 

397 return response, metadata 

398 

399 def pre_list_schemas( 

400 self, 

401 request: schema.ListSchemasRequest, 

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

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

404 """Pre-rpc interceptor for list_schemas 

405 

406 Override in a subclass to manipulate the request or metadata 

407 before they are sent to the SchemaService server. 

408 """ 

409 return request, metadata 

410 

411 def post_list_schemas( 

412 self, response: schema.ListSchemasResponse 

413 ) -> schema.ListSchemasResponse: 

414 """Post-rpc interceptor for list_schemas 

415 

416 DEPRECATED. Please use the `post_list_schemas_with_metadata` 

417 interceptor instead. 

418 

419 Override in a subclass to read or manipulate the response 

420 after it is returned by the SchemaService server but before 

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

422 before the `post_list_schemas_with_metadata` interceptor. 

423 """ 

424 return response 

425 

426 def post_list_schemas_with_metadata( 

427 self, 

428 response: schema.ListSchemasResponse, 

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

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

431 """Post-rpc interceptor for list_schemas 

432 

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

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

435 

436 We recommend only using this `post_list_schemas_with_metadata` 

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

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

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

440 `post_list_schemas` will be passed to 

441 `post_list_schemas_with_metadata`. 

442 """ 

443 return response, metadata 

444 

445 def pre_rollback_schema( 

446 self, 

447 request: schema.RollbackSchemaRequest, 

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

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

450 """Pre-rpc interceptor for rollback_schema 

451 

452 Override in a subclass to manipulate the request or metadata 

453 before they are sent to the SchemaService server. 

454 """ 

455 return request, metadata 

456 

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

458 """Post-rpc interceptor for rollback_schema 

459 

460 DEPRECATED. Please use the `post_rollback_schema_with_metadata` 

461 interceptor instead. 

462 

463 Override in a subclass to read or manipulate the response 

464 after it is returned by the SchemaService server but before 

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

466 before the `post_rollback_schema_with_metadata` interceptor. 

467 """ 

468 return response 

469 

470 def post_rollback_schema_with_metadata( 

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

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

473 """Post-rpc interceptor for rollback_schema 

474 

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

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

477 

478 We recommend only using this `post_rollback_schema_with_metadata` 

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

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

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

482 `post_rollback_schema` will be passed to 

483 `post_rollback_schema_with_metadata`. 

484 """ 

485 return response, metadata 

486 

487 def pre_validate_message( 

488 self, 

489 request: schema.ValidateMessageRequest, 

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

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

492 """Pre-rpc interceptor for validate_message 

493 

494 Override in a subclass to manipulate the request or metadata 

495 before they are sent to the SchemaService server. 

496 """ 

497 return request, metadata 

498 

499 def post_validate_message( 

500 self, response: schema.ValidateMessageResponse 

501 ) -> schema.ValidateMessageResponse: 

502 """Post-rpc interceptor for validate_message 

503 

504 DEPRECATED. Please use the `post_validate_message_with_metadata` 

505 interceptor instead. 

506 

507 Override in a subclass to read or manipulate the response 

508 after it is returned by the SchemaService server but before 

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

510 before the `post_validate_message_with_metadata` interceptor. 

511 """ 

512 return response 

513 

514 def post_validate_message_with_metadata( 

515 self, 

516 response: schema.ValidateMessageResponse, 

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

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

519 """Post-rpc interceptor for validate_message 

520 

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

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

523 

524 We recommend only using this `post_validate_message_with_metadata` 

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

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

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

528 `post_validate_message` will be passed to 

529 `post_validate_message_with_metadata`. 

530 """ 

531 return response, metadata 

532 

533 def pre_validate_schema( 

534 self, 

535 request: gp_schema.ValidateSchemaRequest, 

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

537 ) -> Tuple[ 

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

539 ]: 

540 """Pre-rpc interceptor for validate_schema 

541 

542 Override in a subclass to manipulate the request or metadata 

543 before they are sent to the SchemaService server. 

544 """ 

545 return request, metadata 

546 

547 def post_validate_schema( 

548 self, response: gp_schema.ValidateSchemaResponse 

549 ) -> gp_schema.ValidateSchemaResponse: 

550 """Post-rpc interceptor for validate_schema 

551 

552 DEPRECATED. Please use the `post_validate_schema_with_metadata` 

553 interceptor instead. 

554 

555 Override in a subclass to read or manipulate the response 

556 after it is returned by the SchemaService server but before 

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

558 before the `post_validate_schema_with_metadata` interceptor. 

559 """ 

560 return response 

561 

562 def post_validate_schema_with_metadata( 

563 self, 

564 response: gp_schema.ValidateSchemaResponse, 

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

566 ) -> Tuple[ 

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

568 ]: 

569 """Post-rpc interceptor for validate_schema 

570 

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

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

573 

574 We recommend only using this `post_validate_schema_with_metadata` 

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

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

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

578 `post_validate_schema` will be passed to 

579 `post_validate_schema_with_metadata`. 

580 """ 

581 return response, metadata 

582 

583 def pre_get_iam_policy( 

584 self, 

585 request: iam_policy_pb2.GetIamPolicyRequest, 

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

587 ) -> Tuple[ 

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

589 ]: 

590 """Pre-rpc interceptor for get_iam_policy 

591 

592 Override in a subclass to manipulate the request or metadata 

593 before they are sent to the SchemaService server. 

594 """ 

595 return request, metadata 

596 

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

598 """Post-rpc interceptor for get_iam_policy 

599 

600 Override in a subclass to manipulate the response 

601 after it is returned by the SchemaService server but before 

602 it is returned to user code. 

603 """ 

604 return response 

605 

606 def pre_set_iam_policy( 

607 self, 

608 request: iam_policy_pb2.SetIamPolicyRequest, 

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

610 ) -> Tuple[ 

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

612 ]: 

613 """Pre-rpc interceptor for set_iam_policy 

614 

615 Override in a subclass to manipulate the request or metadata 

616 before they are sent to the SchemaService server. 

617 """ 

618 return request, metadata 

619 

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

621 """Post-rpc interceptor for set_iam_policy 

622 

623 Override in a subclass to manipulate the response 

624 after it is returned by the SchemaService server but before 

625 it is returned to user code. 

626 """ 

627 return response 

628 

629 def pre_test_iam_permissions( 

630 self, 

631 request: iam_policy_pb2.TestIamPermissionsRequest, 

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

633 ) -> Tuple[ 

634 iam_policy_pb2.TestIamPermissionsRequest, 

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

636 ]: 

637 """Pre-rpc interceptor for test_iam_permissions 

638 

639 Override in a subclass to manipulate the request or metadata 

640 before they are sent to the SchemaService server. 

641 """ 

642 return request, metadata 

643 

644 def post_test_iam_permissions( 

645 self, response: iam_policy_pb2.TestIamPermissionsResponse 

646 ) -> iam_policy_pb2.TestIamPermissionsResponse: 

647 """Post-rpc interceptor for test_iam_permissions 

648 

649 Override in a subclass to manipulate the response 

650 after it is returned by the SchemaService server but before 

651 it is returned to user code. 

652 """ 

653 return response 

654 

655 

656@dataclasses.dataclass 

657class SchemaServiceRestStub: 

658 _session: AuthorizedSession 

659 _host: str 

660 _interceptor: SchemaServiceRestInterceptor 

661 

662 

663class SchemaServiceRestTransport(_BaseSchemaServiceRestTransport): 

664 """REST backend synchronous transport for SchemaService. 

665 

666 Service for doing schema-related operations. 

667 

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

669 primary client can load the underlying transport implementation 

670 and call it. 

671 

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

673 """ 

674 

675 def __init__( 

676 self, 

677 *, 

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

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

680 credentials_file: Optional[str] = None, 

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

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

683 quota_project_id: Optional[str] = None, 

684 client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, 

685 always_use_jwt_access: Optional[bool] = False, 

686 url_scheme: str = "https", 

687 interceptor: Optional[SchemaServiceRestInterceptor] = None, 

688 api_audience: Optional[str] = None, 

689 ) -> None: 

690 """Instantiate the transport. 

691 

692 Args: 

693 host (Optional[str]): 

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

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

696 authorization credentials to attach to requests. These 

697 credentials identify the application to the service; if none 

698 are specified, the client will attempt to ascertain the 

699 credentials from the environment. 

700 

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

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

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

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

705 ignored if ``channel`` is provided. 

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

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

708 if ``channel`` is provided. 

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

710 and quota. 

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

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

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

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

715 your own client library. 

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

717 be used for service account credentials. 

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

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

720 "http" can be specified. 

721 """ 

722 # Run the base constructor 

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

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

725 # credentials object 

726 super().__init__( 

727 host=host, 

728 credentials=credentials, 

729 client_info=client_info, 

730 always_use_jwt_access=always_use_jwt_access, 

731 url_scheme=url_scheme, 

732 api_audience=api_audience, 

733 ) 

734 self._session = AuthorizedSession( 

735 self._credentials, default_host=self.DEFAULT_HOST 

736 ) 

737 if client_cert_source_for_mtls: 

738 self._session.configure_mtls_channel(client_cert_source_for_mtls) 

739 self._interceptor = interceptor or SchemaServiceRestInterceptor() 

740 self._prep_wrapped_messages(client_info) 

741 

742 class _CommitSchema( 

743 _BaseSchemaServiceRestTransport._BaseCommitSchema, SchemaServiceRestStub 

744 ): 

745 def __hash__(self): 

746 return hash("SchemaServiceRestTransport.CommitSchema") 

747 

748 @staticmethod 

749 def _get_response( 

750 host, 

751 metadata, 

752 query_params, 

753 session, 

754 timeout, 

755 transcoded_request, 

756 body=None, 

757 ): 

758 uri = transcoded_request["uri"] 

759 method = transcoded_request["method"] 

760 headers = dict(metadata) 

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

762 response = getattr(session, method)( 

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

764 timeout=timeout, 

765 headers=headers, 

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

767 data=body, 

768 ) 

769 return response 

770 

771 def __call__( 

772 self, 

773 request: gp_schema.CommitSchemaRequest, 

774 *, 

775 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

776 timeout: Optional[float] = None, 

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

778 ) -> gp_schema.Schema: 

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

780 

781 Args: 

782 request (~.gp_schema.CommitSchemaRequest): 

783 The request object. Request for CommitSchema method. 

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

785 should be retried. 

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

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

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

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

790 be of type `bytes`. 

791 

792 Returns: 

793 ~.gp_schema.Schema: 

794 A schema resource. 

795 """ 

796 

797 http_options = ( 

798 _BaseSchemaServiceRestTransport._BaseCommitSchema._get_http_options() 

799 ) 

800 

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

802 transcoded_request = _BaseSchemaServiceRestTransport._BaseCommitSchema._get_transcoded_request( 

803 http_options, request 

804 ) 

805 

806 body = _BaseSchemaServiceRestTransport._BaseCommitSchema._get_request_body_json( 

807 transcoded_request 

808 ) 

809 

810 # Jsonify the query params 

811 query_params = _BaseSchemaServiceRestTransport._BaseCommitSchema._get_query_params_json( 

812 transcoded_request 

813 ) 

814 

815 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

816 logging.DEBUG 

817 ): # pragma: NO COVER 

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

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

820 ) 

821 method = transcoded_request["method"] 

822 try: 

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

824 except: 

825 request_payload = None 

826 http_request = { 

827 "payload": request_payload, 

828 "requestMethod": method, 

829 "requestUrl": request_url, 

830 "headers": dict(metadata), 

831 } 

832 _LOGGER.debug( 

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

834 extra={ 

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

836 "rpcName": "CommitSchema", 

837 "httpRequest": http_request, 

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

839 }, 

840 ) 

841 

842 # Send the request 

843 response = SchemaServiceRestTransport._CommitSchema._get_response( 

844 self._host, 

845 metadata, 

846 query_params, 

847 self._session, 

848 timeout, 

849 transcoded_request, 

850 body, 

851 ) 

852 

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

854 # subclass. 

855 if response.status_code >= 400: 

856 raise core_exceptions.from_http_response(response) 

857 

858 # Return the response 

859 resp = gp_schema.Schema() 

860 pb_resp = gp_schema.Schema.pb(resp) 

861 

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

863 

864 resp = self._interceptor.post_commit_schema(resp) 

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

866 resp, _ = self._interceptor.post_commit_schema_with_metadata( 

867 resp, response_metadata 

868 ) 

869 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

870 logging.DEBUG 

871 ): # pragma: NO COVER 

872 try: 

873 response_payload = gp_schema.Schema.to_json(response) 

874 except: 

875 response_payload = None 

876 http_response = { 

877 "payload": response_payload, 

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

879 "status": response.status_code, 

880 } 

881 _LOGGER.debug( 

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

883 extra={ 

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

885 "rpcName": "CommitSchema", 

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

887 "httpResponse": http_response, 

888 }, 

889 ) 

890 return resp 

891 

892 class _CreateSchema( 

893 _BaseSchemaServiceRestTransport._BaseCreateSchema, SchemaServiceRestStub 

894 ): 

895 def __hash__(self): 

896 return hash("SchemaServiceRestTransport.CreateSchema") 

897 

898 @staticmethod 

899 def _get_response( 

900 host, 

901 metadata, 

902 query_params, 

903 session, 

904 timeout, 

905 transcoded_request, 

906 body=None, 

907 ): 

908 uri = transcoded_request["uri"] 

909 method = transcoded_request["method"] 

910 headers = dict(metadata) 

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

912 response = getattr(session, method)( 

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

914 timeout=timeout, 

915 headers=headers, 

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

917 data=body, 

918 ) 

919 return response 

920 

921 def __call__( 

922 self, 

923 request: gp_schema.CreateSchemaRequest, 

924 *, 

925 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

926 timeout: Optional[float] = None, 

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

928 ) -> gp_schema.Schema: 

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

930 

931 Args: 

932 request (~.gp_schema.CreateSchemaRequest): 

933 The request object. Request for the CreateSchema method. 

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

935 should be retried. 

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

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

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

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

940 be of type `bytes`. 

941 

942 Returns: 

943 ~.gp_schema.Schema: 

944 A schema resource. 

945 """ 

946 

947 http_options = ( 

948 _BaseSchemaServiceRestTransport._BaseCreateSchema._get_http_options() 

949 ) 

950 

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

952 transcoded_request = _BaseSchemaServiceRestTransport._BaseCreateSchema._get_transcoded_request( 

953 http_options, request 

954 ) 

955 

956 body = _BaseSchemaServiceRestTransport._BaseCreateSchema._get_request_body_json( 

957 transcoded_request 

958 ) 

959 

960 # Jsonify the query params 

961 query_params = _BaseSchemaServiceRestTransport._BaseCreateSchema._get_query_params_json( 

962 transcoded_request 

963 ) 

964 

965 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

966 logging.DEBUG 

967 ): # pragma: NO COVER 

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

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

970 ) 

971 method = transcoded_request["method"] 

972 try: 

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

974 except: 

975 request_payload = None 

976 http_request = { 

977 "payload": request_payload, 

978 "requestMethod": method, 

979 "requestUrl": request_url, 

980 "headers": dict(metadata), 

981 } 

982 _LOGGER.debug( 

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

984 extra={ 

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

986 "rpcName": "CreateSchema", 

987 "httpRequest": http_request, 

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

989 }, 

990 ) 

991 

992 # Send the request 

993 response = SchemaServiceRestTransport._CreateSchema._get_response( 

994 self._host, 

995 metadata, 

996 query_params, 

997 self._session, 

998 timeout, 

999 transcoded_request, 

1000 body, 

1001 ) 

1002 

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

1004 # subclass. 

1005 if response.status_code >= 400: 

1006 raise core_exceptions.from_http_response(response) 

1007 

1008 # Return the response 

1009 resp = gp_schema.Schema() 

1010 pb_resp = gp_schema.Schema.pb(resp) 

1011 

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

1013 

1014 resp = self._interceptor.post_create_schema(resp) 

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

1016 resp, _ = self._interceptor.post_create_schema_with_metadata( 

1017 resp, response_metadata 

1018 ) 

1019 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1020 logging.DEBUG 

1021 ): # pragma: NO COVER 

1022 try: 

1023 response_payload = gp_schema.Schema.to_json(response) 

1024 except: 

1025 response_payload = None 

1026 http_response = { 

1027 "payload": response_payload, 

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

1029 "status": response.status_code, 

1030 } 

1031 _LOGGER.debug( 

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

1033 extra={ 

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

1035 "rpcName": "CreateSchema", 

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

1037 "httpResponse": http_response, 

1038 }, 

1039 ) 

1040 return resp 

1041 

1042 class _DeleteSchema( 

1043 _BaseSchemaServiceRestTransport._BaseDeleteSchema, SchemaServiceRestStub 

1044 ): 

1045 def __hash__(self): 

1046 return hash("SchemaServiceRestTransport.DeleteSchema") 

1047 

1048 @staticmethod 

1049 def _get_response( 

1050 host, 

1051 metadata, 

1052 query_params, 

1053 session, 

1054 timeout, 

1055 transcoded_request, 

1056 body=None, 

1057 ): 

1058 uri = transcoded_request["uri"] 

1059 method = transcoded_request["method"] 

1060 headers = dict(metadata) 

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

1062 response = getattr(session, method)( 

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

1064 timeout=timeout, 

1065 headers=headers, 

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

1067 ) 

1068 return response 

1069 

1070 def __call__( 

1071 self, 

1072 request: schema.DeleteSchemaRequest, 

1073 *, 

1074 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1075 timeout: Optional[float] = None, 

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

1077 ): 

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

1079 

1080 Args: 

1081 request (~.schema.DeleteSchemaRequest): 

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

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

1084 should be retried. 

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

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

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

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

1089 be of type `bytes`. 

1090 """ 

1091 

1092 http_options = ( 

1093 _BaseSchemaServiceRestTransport._BaseDeleteSchema._get_http_options() 

1094 ) 

1095 

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

1097 transcoded_request = _BaseSchemaServiceRestTransport._BaseDeleteSchema._get_transcoded_request( 

1098 http_options, request 

1099 ) 

1100 

1101 # Jsonify the query params 

1102 query_params = _BaseSchemaServiceRestTransport._BaseDeleteSchema._get_query_params_json( 

1103 transcoded_request 

1104 ) 

1105 

1106 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1107 logging.DEBUG 

1108 ): # pragma: NO COVER 

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

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

1111 ) 

1112 method = transcoded_request["method"] 

1113 try: 

1114 request_payload = json_format.MessageToJson(request) 

1115 except: 

1116 request_payload = None 

1117 http_request = { 

1118 "payload": request_payload, 

1119 "requestMethod": method, 

1120 "requestUrl": request_url, 

1121 "headers": dict(metadata), 

1122 } 

1123 _LOGGER.debug( 

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

1125 extra={ 

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

1127 "rpcName": "DeleteSchema", 

1128 "httpRequest": http_request, 

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

1130 }, 

1131 ) 

1132 

1133 # Send the request 

1134 response = SchemaServiceRestTransport._DeleteSchema._get_response( 

1135 self._host, 

1136 metadata, 

1137 query_params, 

1138 self._session, 

1139 timeout, 

1140 transcoded_request, 

1141 ) 

1142 

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

1144 # subclass. 

1145 if response.status_code >= 400: 

1146 raise core_exceptions.from_http_response(response) 

1147 

1148 class _DeleteSchemaRevision( 

1149 _BaseSchemaServiceRestTransport._BaseDeleteSchemaRevision, SchemaServiceRestStub 

1150 ): 

1151 def __hash__(self): 

1152 return hash("SchemaServiceRestTransport.DeleteSchemaRevision") 

1153 

1154 @staticmethod 

1155 def _get_response( 

1156 host, 

1157 metadata, 

1158 query_params, 

1159 session, 

1160 timeout, 

1161 transcoded_request, 

1162 body=None, 

1163 ): 

1164 uri = transcoded_request["uri"] 

1165 method = transcoded_request["method"] 

1166 headers = dict(metadata) 

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

1168 response = getattr(session, method)( 

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

1170 timeout=timeout, 

1171 headers=headers, 

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

1173 ) 

1174 return response 

1175 

1176 def __call__( 

1177 self, 

1178 request: schema.DeleteSchemaRevisionRequest, 

1179 *, 

1180 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1181 timeout: Optional[float] = None, 

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

1183 ) -> schema.Schema: 

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

1185 

1186 Args: 

1187 request (~.schema.DeleteSchemaRevisionRequest): 

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

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

1190 should be retried. 

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

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

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

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

1195 be of type `bytes`. 

1196 

1197 Returns: 

1198 ~.schema.Schema: 

1199 A schema resource. 

1200 """ 

1201 

1202 http_options = ( 

1203 _BaseSchemaServiceRestTransport._BaseDeleteSchemaRevision._get_http_options() 

1204 ) 

1205 

1206 request, metadata = self._interceptor.pre_delete_schema_revision( 

1207 request, metadata 

1208 ) 

1209 transcoded_request = _BaseSchemaServiceRestTransport._BaseDeleteSchemaRevision._get_transcoded_request( 

1210 http_options, request 

1211 ) 

1212 

1213 # Jsonify the query params 

1214 query_params = _BaseSchemaServiceRestTransport._BaseDeleteSchemaRevision._get_query_params_json( 

1215 transcoded_request 

1216 ) 

1217 

1218 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1219 logging.DEBUG 

1220 ): # pragma: NO COVER 

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

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

1223 ) 

1224 method = transcoded_request["method"] 

1225 try: 

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

1227 except: 

1228 request_payload = None 

1229 http_request = { 

1230 "payload": request_payload, 

1231 "requestMethod": method, 

1232 "requestUrl": request_url, 

1233 "headers": dict(metadata), 

1234 } 

1235 _LOGGER.debug( 

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

1237 extra={ 

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

1239 "rpcName": "DeleteSchemaRevision", 

1240 "httpRequest": http_request, 

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

1242 }, 

1243 ) 

1244 

1245 # Send the request 

1246 response = SchemaServiceRestTransport._DeleteSchemaRevision._get_response( 

1247 self._host, 

1248 metadata, 

1249 query_params, 

1250 self._session, 

1251 timeout, 

1252 transcoded_request, 

1253 ) 

1254 

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

1256 # subclass. 

1257 if response.status_code >= 400: 

1258 raise core_exceptions.from_http_response(response) 

1259 

1260 # Return the response 

1261 resp = schema.Schema() 

1262 pb_resp = schema.Schema.pb(resp) 

1263 

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

1265 

1266 resp = self._interceptor.post_delete_schema_revision(resp) 

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

1268 resp, _ = self._interceptor.post_delete_schema_revision_with_metadata( 

1269 resp, response_metadata 

1270 ) 

1271 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1272 logging.DEBUG 

1273 ): # pragma: NO COVER 

1274 try: 

1275 response_payload = schema.Schema.to_json(response) 

1276 except: 

1277 response_payload = None 

1278 http_response = { 

1279 "payload": response_payload, 

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

1281 "status": response.status_code, 

1282 } 

1283 _LOGGER.debug( 

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

1285 extra={ 

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

1287 "rpcName": "DeleteSchemaRevision", 

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

1289 "httpResponse": http_response, 

1290 }, 

1291 ) 

1292 return resp 

1293 

1294 class _GetSchema( 

1295 _BaseSchemaServiceRestTransport._BaseGetSchema, SchemaServiceRestStub 

1296 ): 

1297 def __hash__(self): 

1298 return hash("SchemaServiceRestTransport.GetSchema") 

1299 

1300 @staticmethod 

1301 def _get_response( 

1302 host, 

1303 metadata, 

1304 query_params, 

1305 session, 

1306 timeout, 

1307 transcoded_request, 

1308 body=None, 

1309 ): 

1310 uri = transcoded_request["uri"] 

1311 method = transcoded_request["method"] 

1312 headers = dict(metadata) 

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

1314 response = getattr(session, method)( 

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

1316 timeout=timeout, 

1317 headers=headers, 

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

1319 ) 

1320 return response 

1321 

1322 def __call__( 

1323 self, 

1324 request: schema.GetSchemaRequest, 

1325 *, 

1326 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1327 timeout: Optional[float] = None, 

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

1329 ) -> schema.Schema: 

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

1331 

1332 Args: 

1333 request (~.schema.GetSchemaRequest): 

1334 The request object. Request for the GetSchema method. 

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

1336 should be retried. 

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

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

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

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

1341 be of type `bytes`. 

1342 

1343 Returns: 

1344 ~.schema.Schema: 

1345 A schema resource. 

1346 """ 

1347 

1348 http_options = ( 

1349 _BaseSchemaServiceRestTransport._BaseGetSchema._get_http_options() 

1350 ) 

1351 

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

1353 transcoded_request = ( 

1354 _BaseSchemaServiceRestTransport._BaseGetSchema._get_transcoded_request( 

1355 http_options, request 

1356 ) 

1357 ) 

1358 

1359 # Jsonify the query params 

1360 query_params = ( 

1361 _BaseSchemaServiceRestTransport._BaseGetSchema._get_query_params_json( 

1362 transcoded_request 

1363 ) 

1364 ) 

1365 

1366 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1367 logging.DEBUG 

1368 ): # pragma: NO COVER 

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

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

1371 ) 

1372 method = transcoded_request["method"] 

1373 try: 

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

1375 except: 

1376 request_payload = None 

1377 http_request = { 

1378 "payload": request_payload, 

1379 "requestMethod": method, 

1380 "requestUrl": request_url, 

1381 "headers": dict(metadata), 

1382 } 

1383 _LOGGER.debug( 

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

1385 extra={ 

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

1387 "rpcName": "GetSchema", 

1388 "httpRequest": http_request, 

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

1390 }, 

1391 ) 

1392 

1393 # Send the request 

1394 response = SchemaServiceRestTransport._GetSchema._get_response( 

1395 self._host, 

1396 metadata, 

1397 query_params, 

1398 self._session, 

1399 timeout, 

1400 transcoded_request, 

1401 ) 

1402 

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

1404 # subclass. 

1405 if response.status_code >= 400: 

1406 raise core_exceptions.from_http_response(response) 

1407 

1408 # Return the response 

1409 resp = schema.Schema() 

1410 pb_resp = schema.Schema.pb(resp) 

1411 

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

1413 

1414 resp = self._interceptor.post_get_schema(resp) 

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

1416 resp, _ = self._interceptor.post_get_schema_with_metadata( 

1417 resp, response_metadata 

1418 ) 

1419 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1420 logging.DEBUG 

1421 ): # pragma: NO COVER 

1422 try: 

1423 response_payload = schema.Schema.to_json(response) 

1424 except: 

1425 response_payload = None 

1426 http_response = { 

1427 "payload": response_payload, 

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

1429 "status": response.status_code, 

1430 } 

1431 _LOGGER.debug( 

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

1433 extra={ 

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

1435 "rpcName": "GetSchema", 

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

1437 "httpResponse": http_response, 

1438 }, 

1439 ) 

1440 return resp 

1441 

1442 class _ListSchemaRevisions( 

1443 _BaseSchemaServiceRestTransport._BaseListSchemaRevisions, SchemaServiceRestStub 

1444 ): 

1445 def __hash__(self): 

1446 return hash("SchemaServiceRestTransport.ListSchemaRevisions") 

1447 

1448 @staticmethod 

1449 def _get_response( 

1450 host, 

1451 metadata, 

1452 query_params, 

1453 session, 

1454 timeout, 

1455 transcoded_request, 

1456 body=None, 

1457 ): 

1458 uri = transcoded_request["uri"] 

1459 method = transcoded_request["method"] 

1460 headers = dict(metadata) 

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

1462 response = getattr(session, method)( 

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

1464 timeout=timeout, 

1465 headers=headers, 

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

1467 ) 

1468 return response 

1469 

1470 def __call__( 

1471 self, 

1472 request: schema.ListSchemaRevisionsRequest, 

1473 *, 

1474 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1475 timeout: Optional[float] = None, 

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

1477 ) -> schema.ListSchemaRevisionsResponse: 

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

1479 

1480 Args: 

1481 request (~.schema.ListSchemaRevisionsRequest): 

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

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

1484 should be retried. 

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

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

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

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

1489 be of type `bytes`. 

1490 

1491 Returns: 

1492 ~.schema.ListSchemaRevisionsResponse: 

1493 Response for the ``ListSchemaRevisions`` method. 

1494 """ 

1495 

1496 http_options = ( 

1497 _BaseSchemaServiceRestTransport._BaseListSchemaRevisions._get_http_options() 

1498 ) 

1499 

1500 request, metadata = self._interceptor.pre_list_schema_revisions( 

1501 request, metadata 

1502 ) 

1503 transcoded_request = _BaseSchemaServiceRestTransport._BaseListSchemaRevisions._get_transcoded_request( 

1504 http_options, request 

1505 ) 

1506 

1507 # Jsonify the query params 

1508 query_params = _BaseSchemaServiceRestTransport._BaseListSchemaRevisions._get_query_params_json( 

1509 transcoded_request 

1510 ) 

1511 

1512 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1513 logging.DEBUG 

1514 ): # pragma: NO COVER 

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

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

1517 ) 

1518 method = transcoded_request["method"] 

1519 try: 

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

1521 except: 

1522 request_payload = None 

1523 http_request = { 

1524 "payload": request_payload, 

1525 "requestMethod": method, 

1526 "requestUrl": request_url, 

1527 "headers": dict(metadata), 

1528 } 

1529 _LOGGER.debug( 

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

1531 extra={ 

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

1533 "rpcName": "ListSchemaRevisions", 

1534 "httpRequest": http_request, 

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

1536 }, 

1537 ) 

1538 

1539 # Send the request 

1540 response = SchemaServiceRestTransport._ListSchemaRevisions._get_response( 

1541 self._host, 

1542 metadata, 

1543 query_params, 

1544 self._session, 

1545 timeout, 

1546 transcoded_request, 

1547 ) 

1548 

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

1550 # subclass. 

1551 if response.status_code >= 400: 

1552 raise core_exceptions.from_http_response(response) 

1553 

1554 # Return the response 

1555 resp = schema.ListSchemaRevisionsResponse() 

1556 pb_resp = schema.ListSchemaRevisionsResponse.pb(resp) 

1557 

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

1559 

1560 resp = self._interceptor.post_list_schema_revisions(resp) 

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

1562 resp, _ = self._interceptor.post_list_schema_revisions_with_metadata( 

1563 resp, response_metadata 

1564 ) 

1565 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1566 logging.DEBUG 

1567 ): # pragma: NO COVER 

1568 try: 

1569 response_payload = schema.ListSchemaRevisionsResponse.to_json( 

1570 response 

1571 ) 

1572 except: 

1573 response_payload = None 

1574 http_response = { 

1575 "payload": response_payload, 

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

1577 "status": response.status_code, 

1578 } 

1579 _LOGGER.debug( 

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

1581 extra={ 

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

1583 "rpcName": "ListSchemaRevisions", 

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

1585 "httpResponse": http_response, 

1586 }, 

1587 ) 

1588 return resp 

1589 

1590 class _ListSchemas( 

1591 _BaseSchemaServiceRestTransport._BaseListSchemas, SchemaServiceRestStub 

1592 ): 

1593 def __hash__(self): 

1594 return hash("SchemaServiceRestTransport.ListSchemas") 

1595 

1596 @staticmethod 

1597 def _get_response( 

1598 host, 

1599 metadata, 

1600 query_params, 

1601 session, 

1602 timeout, 

1603 transcoded_request, 

1604 body=None, 

1605 ): 

1606 uri = transcoded_request["uri"] 

1607 method = transcoded_request["method"] 

1608 headers = dict(metadata) 

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

1610 response = getattr(session, method)( 

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

1612 timeout=timeout, 

1613 headers=headers, 

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

1615 ) 

1616 return response 

1617 

1618 def __call__( 

1619 self, 

1620 request: schema.ListSchemasRequest, 

1621 *, 

1622 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1623 timeout: Optional[float] = None, 

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

1625 ) -> schema.ListSchemasResponse: 

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

1627 

1628 Args: 

1629 request (~.schema.ListSchemasRequest): 

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

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

1632 should be retried. 

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

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

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

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

1637 be of type `bytes`. 

1638 

1639 Returns: 

1640 ~.schema.ListSchemasResponse: 

1641 Response for the ``ListSchemas`` method. 

1642 """ 

1643 

1644 http_options = ( 

1645 _BaseSchemaServiceRestTransport._BaseListSchemas._get_http_options() 

1646 ) 

1647 

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

1649 transcoded_request = _BaseSchemaServiceRestTransport._BaseListSchemas._get_transcoded_request( 

1650 http_options, request 

1651 ) 

1652 

1653 # Jsonify the query params 

1654 query_params = ( 

1655 _BaseSchemaServiceRestTransport._BaseListSchemas._get_query_params_json( 

1656 transcoded_request 

1657 ) 

1658 ) 

1659 

1660 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1661 logging.DEBUG 

1662 ): # pragma: NO COVER 

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

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

1665 ) 

1666 method = transcoded_request["method"] 

1667 try: 

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

1669 except: 

1670 request_payload = None 

1671 http_request = { 

1672 "payload": request_payload, 

1673 "requestMethod": method, 

1674 "requestUrl": request_url, 

1675 "headers": dict(metadata), 

1676 } 

1677 _LOGGER.debug( 

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

1679 extra={ 

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

1681 "rpcName": "ListSchemas", 

1682 "httpRequest": http_request, 

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

1684 }, 

1685 ) 

1686 

1687 # Send the request 

1688 response = SchemaServiceRestTransport._ListSchemas._get_response( 

1689 self._host, 

1690 metadata, 

1691 query_params, 

1692 self._session, 

1693 timeout, 

1694 transcoded_request, 

1695 ) 

1696 

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

1698 # subclass. 

1699 if response.status_code >= 400: 

1700 raise core_exceptions.from_http_response(response) 

1701 

1702 # Return the response 

1703 resp = schema.ListSchemasResponse() 

1704 pb_resp = schema.ListSchemasResponse.pb(resp) 

1705 

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

1707 

1708 resp = self._interceptor.post_list_schemas(resp) 

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

1710 resp, _ = self._interceptor.post_list_schemas_with_metadata( 

1711 resp, response_metadata 

1712 ) 

1713 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1714 logging.DEBUG 

1715 ): # pragma: NO COVER 

1716 try: 

1717 response_payload = schema.ListSchemasResponse.to_json(response) 

1718 except: 

1719 response_payload = None 

1720 http_response = { 

1721 "payload": response_payload, 

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

1723 "status": response.status_code, 

1724 } 

1725 _LOGGER.debug( 

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

1727 extra={ 

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

1729 "rpcName": "ListSchemas", 

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

1731 "httpResponse": http_response, 

1732 }, 

1733 ) 

1734 return resp 

1735 

1736 class _RollbackSchema( 

1737 _BaseSchemaServiceRestTransport._BaseRollbackSchema, SchemaServiceRestStub 

1738 ): 

1739 def __hash__(self): 

1740 return hash("SchemaServiceRestTransport.RollbackSchema") 

1741 

1742 @staticmethod 

1743 def _get_response( 

1744 host, 

1745 metadata, 

1746 query_params, 

1747 session, 

1748 timeout, 

1749 transcoded_request, 

1750 body=None, 

1751 ): 

1752 uri = transcoded_request["uri"] 

1753 method = transcoded_request["method"] 

1754 headers = dict(metadata) 

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

1756 response = getattr(session, method)( 

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

1758 timeout=timeout, 

1759 headers=headers, 

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

1761 data=body, 

1762 ) 

1763 return response 

1764 

1765 def __call__( 

1766 self, 

1767 request: schema.RollbackSchemaRequest, 

1768 *, 

1769 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1770 timeout: Optional[float] = None, 

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

1772 ) -> schema.Schema: 

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

1774 

1775 Args: 

1776 request (~.schema.RollbackSchemaRequest): 

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

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

1779 should be retried. 

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

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

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

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

1784 be of type `bytes`. 

1785 

1786 Returns: 

1787 ~.schema.Schema: 

1788 A schema resource. 

1789 """ 

1790 

1791 http_options = ( 

1792 _BaseSchemaServiceRestTransport._BaseRollbackSchema._get_http_options() 

1793 ) 

1794 

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

1796 transcoded_request = _BaseSchemaServiceRestTransport._BaseRollbackSchema._get_transcoded_request( 

1797 http_options, request 

1798 ) 

1799 

1800 body = _BaseSchemaServiceRestTransport._BaseRollbackSchema._get_request_body_json( 

1801 transcoded_request 

1802 ) 

1803 

1804 # Jsonify the query params 

1805 query_params = _BaseSchemaServiceRestTransport._BaseRollbackSchema._get_query_params_json( 

1806 transcoded_request 

1807 ) 

1808 

1809 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1810 logging.DEBUG 

1811 ): # pragma: NO COVER 

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

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

1814 ) 

1815 method = transcoded_request["method"] 

1816 try: 

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

1818 except: 

1819 request_payload = None 

1820 http_request = { 

1821 "payload": request_payload, 

1822 "requestMethod": method, 

1823 "requestUrl": request_url, 

1824 "headers": dict(metadata), 

1825 } 

1826 _LOGGER.debug( 

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

1828 extra={ 

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

1830 "rpcName": "RollbackSchema", 

1831 "httpRequest": http_request, 

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

1833 }, 

1834 ) 

1835 

1836 # Send the request 

1837 response = SchemaServiceRestTransport._RollbackSchema._get_response( 

1838 self._host, 

1839 metadata, 

1840 query_params, 

1841 self._session, 

1842 timeout, 

1843 transcoded_request, 

1844 body, 

1845 ) 

1846 

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

1848 # subclass. 

1849 if response.status_code >= 400: 

1850 raise core_exceptions.from_http_response(response) 

1851 

1852 # Return the response 

1853 resp = schema.Schema() 

1854 pb_resp = schema.Schema.pb(resp) 

1855 

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

1857 

1858 resp = self._interceptor.post_rollback_schema(resp) 

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

1860 resp, _ = self._interceptor.post_rollback_schema_with_metadata( 

1861 resp, response_metadata 

1862 ) 

1863 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1864 logging.DEBUG 

1865 ): # pragma: NO COVER 

1866 try: 

1867 response_payload = schema.Schema.to_json(response) 

1868 except: 

1869 response_payload = None 

1870 http_response = { 

1871 "payload": response_payload, 

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

1873 "status": response.status_code, 

1874 } 

1875 _LOGGER.debug( 

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

1877 extra={ 

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

1879 "rpcName": "RollbackSchema", 

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

1881 "httpResponse": http_response, 

1882 }, 

1883 ) 

1884 return resp 

1885 

1886 class _ValidateMessage( 

1887 _BaseSchemaServiceRestTransport._BaseValidateMessage, SchemaServiceRestStub 

1888 ): 

1889 def __hash__(self): 

1890 return hash("SchemaServiceRestTransport.ValidateMessage") 

1891 

1892 @staticmethod 

1893 def _get_response( 

1894 host, 

1895 metadata, 

1896 query_params, 

1897 session, 

1898 timeout, 

1899 transcoded_request, 

1900 body=None, 

1901 ): 

1902 uri = transcoded_request["uri"] 

1903 method = transcoded_request["method"] 

1904 headers = dict(metadata) 

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

1906 response = getattr(session, method)( 

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

1908 timeout=timeout, 

1909 headers=headers, 

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

1911 data=body, 

1912 ) 

1913 return response 

1914 

1915 def __call__( 

1916 self, 

1917 request: schema.ValidateMessageRequest, 

1918 *, 

1919 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1920 timeout: Optional[float] = None, 

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

1922 ) -> schema.ValidateMessageResponse: 

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

1924 

1925 Args: 

1926 request (~.schema.ValidateMessageRequest): 

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

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

1929 should be retried. 

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

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

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

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

1934 be of type `bytes`. 

1935 

1936 Returns: 

1937 ~.schema.ValidateMessageResponse: 

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

1939 now. 

1940 

1941 """ 

1942 

1943 http_options = ( 

1944 _BaseSchemaServiceRestTransport._BaseValidateMessage._get_http_options() 

1945 ) 

1946 

1947 request, metadata = self._interceptor.pre_validate_message( 

1948 request, metadata 

1949 ) 

1950 transcoded_request = _BaseSchemaServiceRestTransport._BaseValidateMessage._get_transcoded_request( 

1951 http_options, request 

1952 ) 

1953 

1954 body = _BaseSchemaServiceRestTransport._BaseValidateMessage._get_request_body_json( 

1955 transcoded_request 

1956 ) 

1957 

1958 # Jsonify the query params 

1959 query_params = _BaseSchemaServiceRestTransport._BaseValidateMessage._get_query_params_json( 

1960 transcoded_request 

1961 ) 

1962 

1963 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1964 logging.DEBUG 

1965 ): # pragma: NO COVER 

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

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

1968 ) 

1969 method = transcoded_request["method"] 

1970 try: 

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

1972 except: 

1973 request_payload = None 

1974 http_request = { 

1975 "payload": request_payload, 

1976 "requestMethod": method, 

1977 "requestUrl": request_url, 

1978 "headers": dict(metadata), 

1979 } 

1980 _LOGGER.debug( 

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

1982 extra={ 

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

1984 "rpcName": "ValidateMessage", 

1985 "httpRequest": http_request, 

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

1987 }, 

1988 ) 

1989 

1990 # Send the request 

1991 response = SchemaServiceRestTransport._ValidateMessage._get_response( 

1992 self._host, 

1993 metadata, 

1994 query_params, 

1995 self._session, 

1996 timeout, 

1997 transcoded_request, 

1998 body, 

1999 ) 

2000 

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

2002 # subclass. 

2003 if response.status_code >= 400: 

2004 raise core_exceptions.from_http_response(response) 

2005 

2006 # Return the response 

2007 resp = schema.ValidateMessageResponse() 

2008 pb_resp = schema.ValidateMessageResponse.pb(resp) 

2009 

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

2011 

2012 resp = self._interceptor.post_validate_message(resp) 

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

2014 resp, _ = self._interceptor.post_validate_message_with_metadata( 

2015 resp, response_metadata 

2016 ) 

2017 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

2018 logging.DEBUG 

2019 ): # pragma: NO COVER 

2020 try: 

2021 response_payload = schema.ValidateMessageResponse.to_json(response) 

2022 except: 

2023 response_payload = None 

2024 http_response = { 

2025 "payload": response_payload, 

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

2027 "status": response.status_code, 

2028 } 

2029 _LOGGER.debug( 

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

2031 extra={ 

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

2033 "rpcName": "ValidateMessage", 

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

2035 "httpResponse": http_response, 

2036 }, 

2037 ) 

2038 return resp 

2039 

2040 class _ValidateSchema( 

2041 _BaseSchemaServiceRestTransport._BaseValidateSchema, SchemaServiceRestStub 

2042 ): 

2043 def __hash__(self): 

2044 return hash("SchemaServiceRestTransport.ValidateSchema") 

2045 

2046 @staticmethod 

2047 def _get_response( 

2048 host, 

2049 metadata, 

2050 query_params, 

2051 session, 

2052 timeout, 

2053 transcoded_request, 

2054 body=None, 

2055 ): 

2056 uri = transcoded_request["uri"] 

2057 method = transcoded_request["method"] 

2058 headers = dict(metadata) 

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

2060 response = getattr(session, method)( 

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

2062 timeout=timeout, 

2063 headers=headers, 

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

2065 data=body, 

2066 ) 

2067 return response 

2068 

2069 def __call__( 

2070 self, 

2071 request: gp_schema.ValidateSchemaRequest, 

2072 *, 

2073 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

2074 timeout: Optional[float] = None, 

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

2076 ) -> gp_schema.ValidateSchemaResponse: 

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

2078 

2079 Args: 

2080 request (~.gp_schema.ValidateSchemaRequest): 

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

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

2083 should be retried. 

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

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

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

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

2088 be of type `bytes`. 

2089 

2090 Returns: 

2091 ~.gp_schema.ValidateSchemaResponse: 

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

2093 now. 

2094 

2095 """ 

2096 

2097 http_options = ( 

2098 _BaseSchemaServiceRestTransport._BaseValidateSchema._get_http_options() 

2099 ) 

2100 

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

2102 transcoded_request = _BaseSchemaServiceRestTransport._BaseValidateSchema._get_transcoded_request( 

2103 http_options, request 

2104 ) 

2105 

2106 body = _BaseSchemaServiceRestTransport._BaseValidateSchema._get_request_body_json( 

2107 transcoded_request 

2108 ) 

2109 

2110 # Jsonify the query params 

2111 query_params = _BaseSchemaServiceRestTransport._BaseValidateSchema._get_query_params_json( 

2112 transcoded_request 

2113 ) 

2114 

2115 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

2116 logging.DEBUG 

2117 ): # pragma: NO COVER 

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

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

2120 ) 

2121 method = transcoded_request["method"] 

2122 try: 

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

2124 except: 

2125 request_payload = None 

2126 http_request = { 

2127 "payload": request_payload, 

2128 "requestMethod": method, 

2129 "requestUrl": request_url, 

2130 "headers": dict(metadata), 

2131 } 

2132 _LOGGER.debug( 

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

2134 extra={ 

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

2136 "rpcName": "ValidateSchema", 

2137 "httpRequest": http_request, 

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

2139 }, 

2140 ) 

2141 

2142 # Send the request 

2143 response = SchemaServiceRestTransport._ValidateSchema._get_response( 

2144 self._host, 

2145 metadata, 

2146 query_params, 

2147 self._session, 

2148 timeout, 

2149 transcoded_request, 

2150 body, 

2151 ) 

2152 

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

2154 # subclass. 

2155 if response.status_code >= 400: 

2156 raise core_exceptions.from_http_response(response) 

2157 

2158 # Return the response 

2159 resp = gp_schema.ValidateSchemaResponse() 

2160 pb_resp = gp_schema.ValidateSchemaResponse.pb(resp) 

2161 

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

2163 

2164 resp = self._interceptor.post_validate_schema(resp) 

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

2166 resp, _ = self._interceptor.post_validate_schema_with_metadata( 

2167 resp, response_metadata 

2168 ) 

2169 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

2170 logging.DEBUG 

2171 ): # pragma: NO COVER 

2172 try: 

2173 response_payload = gp_schema.ValidateSchemaResponse.to_json( 

2174 response 

2175 ) 

2176 except: 

2177 response_payload = None 

2178 http_response = { 

2179 "payload": response_payload, 

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

2181 "status": response.status_code, 

2182 } 

2183 _LOGGER.debug( 

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

2185 extra={ 

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

2187 "rpcName": "ValidateSchema", 

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

2189 "httpResponse": http_response, 

2190 }, 

2191 ) 

2192 return resp 

2193 

2194 @property 

2195 def commit_schema( 

2196 self, 

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

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

2199 # In C++ this would require a dynamic_cast 

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

2201 

2202 @property 

2203 def create_schema( 

2204 self, 

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

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

2207 # In C++ this would require a dynamic_cast 

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

2209 

2210 @property 

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

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

2213 # In C++ this would require a dynamic_cast 

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

2215 

2216 @property 

2217 def delete_schema_revision( 

2218 self, 

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

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

2221 # In C++ this would require a dynamic_cast 

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

2223 

2224 @property 

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

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

2227 # In C++ this would require a dynamic_cast 

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

2229 

2230 @property 

2231 def list_schema_revisions( 

2232 self, 

2233 ) -> Callable[ 

2234 [schema.ListSchemaRevisionsRequest], schema.ListSchemaRevisionsResponse 

2235 ]: 

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

2237 # In C++ this would require a dynamic_cast 

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

2239 

2240 @property 

2241 def list_schemas( 

2242 self, 

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

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

2245 # In C++ this would require a dynamic_cast 

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

2247 

2248 @property 

2249 def rollback_schema( 

2250 self, 

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

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

2253 # In C++ this would require a dynamic_cast 

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

2255 

2256 @property 

2257 def validate_message( 

2258 self, 

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

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

2261 # In C++ this would require a dynamic_cast 

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

2263 

2264 @property 

2265 def validate_schema( 

2266 self, 

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

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

2269 # In C++ this would require a dynamic_cast 

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

2271 

2272 @property 

2273 def get_iam_policy(self): 

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

2275 

2276 class _GetIamPolicy( 

2277 _BaseSchemaServiceRestTransport._BaseGetIamPolicy, SchemaServiceRestStub 

2278 ): 

2279 def __hash__(self): 

2280 return hash("SchemaServiceRestTransport.GetIamPolicy") 

2281 

2282 @staticmethod 

2283 def _get_response( 

2284 host, 

2285 metadata, 

2286 query_params, 

2287 session, 

2288 timeout, 

2289 transcoded_request, 

2290 body=None, 

2291 ): 

2292 uri = transcoded_request["uri"] 

2293 method = transcoded_request["method"] 

2294 headers = dict(metadata) 

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

2296 response = getattr(session, method)( 

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

2298 timeout=timeout, 

2299 headers=headers, 

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

2301 ) 

2302 return response 

2303 

2304 def __call__( 

2305 self, 

2306 request: iam_policy_pb2.GetIamPolicyRequest, 

2307 *, 

2308 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

2309 timeout: Optional[float] = None, 

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

2311 ) -> policy_pb2.Policy: 

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

2313 

2314 Args: 

2315 request (iam_policy_pb2.GetIamPolicyRequest): 

2316 The request object for GetIamPolicy method. 

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

2318 should be retried. 

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

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

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

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

2323 be of type `bytes`. 

2324 

2325 Returns: 

2326 policy_pb2.Policy: Response from GetIamPolicy method. 

2327 """ 

2328 

2329 http_options = ( 

2330 _BaseSchemaServiceRestTransport._BaseGetIamPolicy._get_http_options() 

2331 ) 

2332 

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

2334 transcoded_request = _BaseSchemaServiceRestTransport._BaseGetIamPolicy._get_transcoded_request( 

2335 http_options, request 

2336 ) 

2337 

2338 # Jsonify the query params 

2339 query_params = _BaseSchemaServiceRestTransport._BaseGetIamPolicy._get_query_params_json( 

2340 transcoded_request 

2341 ) 

2342 

2343 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

2344 logging.DEBUG 

2345 ): # pragma: NO COVER 

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

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

2348 ) 

2349 method = transcoded_request["method"] 

2350 try: 

2351 request_payload = json_format.MessageToJson(request) 

2352 except: 

2353 request_payload = None 

2354 http_request = { 

2355 "payload": request_payload, 

2356 "requestMethod": method, 

2357 "requestUrl": request_url, 

2358 "headers": dict(metadata), 

2359 } 

2360 _LOGGER.debug( 

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

2362 extra={ 

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

2364 "rpcName": "GetIamPolicy", 

2365 "httpRequest": http_request, 

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

2367 }, 

2368 ) 

2369 

2370 # Send the request 

2371 response = SchemaServiceRestTransport._GetIamPolicy._get_response( 

2372 self._host, 

2373 metadata, 

2374 query_params, 

2375 self._session, 

2376 timeout, 

2377 transcoded_request, 

2378 ) 

2379 

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

2381 # subclass. 

2382 if response.status_code >= 400: 

2383 raise core_exceptions.from_http_response(response) 

2384 

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

2386 resp = policy_pb2.Policy() 

2387 resp = json_format.Parse(content, resp) 

2388 resp = self._interceptor.post_get_iam_policy(resp) 

2389 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

2390 logging.DEBUG 

2391 ): # pragma: NO COVER 

2392 try: 

2393 response_payload = json_format.MessageToJson(resp) 

2394 except: 

2395 response_payload = None 

2396 http_response = { 

2397 "payload": response_payload, 

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

2399 "status": response.status_code, 

2400 } 

2401 _LOGGER.debug( 

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

2403 extra={ 

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

2405 "rpcName": "GetIamPolicy", 

2406 "httpResponse": http_response, 

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

2408 }, 

2409 ) 

2410 return resp 

2411 

2412 @property 

2413 def set_iam_policy(self): 

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

2415 

2416 class _SetIamPolicy( 

2417 _BaseSchemaServiceRestTransport._BaseSetIamPolicy, SchemaServiceRestStub 

2418 ): 

2419 def __hash__(self): 

2420 return hash("SchemaServiceRestTransport.SetIamPolicy") 

2421 

2422 @staticmethod 

2423 def _get_response( 

2424 host, 

2425 metadata, 

2426 query_params, 

2427 session, 

2428 timeout, 

2429 transcoded_request, 

2430 body=None, 

2431 ): 

2432 uri = transcoded_request["uri"] 

2433 method = transcoded_request["method"] 

2434 headers = dict(metadata) 

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

2436 response = getattr(session, method)( 

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

2438 timeout=timeout, 

2439 headers=headers, 

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

2441 data=body, 

2442 ) 

2443 return response 

2444 

2445 def __call__( 

2446 self, 

2447 request: iam_policy_pb2.SetIamPolicyRequest, 

2448 *, 

2449 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

2450 timeout: Optional[float] = None, 

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

2452 ) -> policy_pb2.Policy: 

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

2454 

2455 Args: 

2456 request (iam_policy_pb2.SetIamPolicyRequest): 

2457 The request object for SetIamPolicy method. 

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

2459 should be retried. 

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

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

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

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

2464 be of type `bytes`. 

2465 

2466 Returns: 

2467 policy_pb2.Policy: Response from SetIamPolicy method. 

2468 """ 

2469 

2470 http_options = ( 

2471 _BaseSchemaServiceRestTransport._BaseSetIamPolicy._get_http_options() 

2472 ) 

2473 

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

2475 transcoded_request = _BaseSchemaServiceRestTransport._BaseSetIamPolicy._get_transcoded_request( 

2476 http_options, request 

2477 ) 

2478 

2479 body = _BaseSchemaServiceRestTransport._BaseSetIamPolicy._get_request_body_json( 

2480 transcoded_request 

2481 ) 

2482 

2483 # Jsonify the query params 

2484 query_params = _BaseSchemaServiceRestTransport._BaseSetIamPolicy._get_query_params_json( 

2485 transcoded_request 

2486 ) 

2487 

2488 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

2489 logging.DEBUG 

2490 ): # pragma: NO COVER 

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

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

2493 ) 

2494 method = transcoded_request["method"] 

2495 try: 

2496 request_payload = json_format.MessageToJson(request) 

2497 except: 

2498 request_payload = None 

2499 http_request = { 

2500 "payload": request_payload, 

2501 "requestMethod": method, 

2502 "requestUrl": request_url, 

2503 "headers": dict(metadata), 

2504 } 

2505 _LOGGER.debug( 

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

2507 extra={ 

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

2509 "rpcName": "SetIamPolicy", 

2510 "httpRequest": http_request, 

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

2512 }, 

2513 ) 

2514 

2515 # Send the request 

2516 response = SchemaServiceRestTransport._SetIamPolicy._get_response( 

2517 self._host, 

2518 metadata, 

2519 query_params, 

2520 self._session, 

2521 timeout, 

2522 transcoded_request, 

2523 body, 

2524 ) 

2525 

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

2527 # subclass. 

2528 if response.status_code >= 400: 

2529 raise core_exceptions.from_http_response(response) 

2530 

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

2532 resp = policy_pb2.Policy() 

2533 resp = json_format.Parse(content, resp) 

2534 resp = self._interceptor.post_set_iam_policy(resp) 

2535 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

2536 logging.DEBUG 

2537 ): # pragma: NO COVER 

2538 try: 

2539 response_payload = json_format.MessageToJson(resp) 

2540 except: 

2541 response_payload = None 

2542 http_response = { 

2543 "payload": response_payload, 

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

2545 "status": response.status_code, 

2546 } 

2547 _LOGGER.debug( 

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

2549 extra={ 

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

2551 "rpcName": "SetIamPolicy", 

2552 "httpResponse": http_response, 

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

2554 }, 

2555 ) 

2556 return resp 

2557 

2558 @property 

2559 def test_iam_permissions(self): 

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

2561 

2562 class _TestIamPermissions( 

2563 _BaseSchemaServiceRestTransport._BaseTestIamPermissions, SchemaServiceRestStub 

2564 ): 

2565 def __hash__(self): 

2566 return hash("SchemaServiceRestTransport.TestIamPermissions") 

2567 

2568 @staticmethod 

2569 def _get_response( 

2570 host, 

2571 metadata, 

2572 query_params, 

2573 session, 

2574 timeout, 

2575 transcoded_request, 

2576 body=None, 

2577 ): 

2578 uri = transcoded_request["uri"] 

2579 method = transcoded_request["method"] 

2580 headers = dict(metadata) 

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

2582 response = getattr(session, method)( 

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

2584 timeout=timeout, 

2585 headers=headers, 

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

2587 data=body, 

2588 ) 

2589 return response 

2590 

2591 def __call__( 

2592 self, 

2593 request: iam_policy_pb2.TestIamPermissionsRequest, 

2594 *, 

2595 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

2596 timeout: Optional[float] = None, 

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

2598 ) -> iam_policy_pb2.TestIamPermissionsResponse: 

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

2600 

2601 Args: 

2602 request (iam_policy_pb2.TestIamPermissionsRequest): 

2603 The request object for TestIamPermissions method. 

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

2605 should be retried. 

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

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

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

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

2610 be of type `bytes`. 

2611 

2612 Returns: 

2613 iam_policy_pb2.TestIamPermissionsResponse: Response from TestIamPermissions method. 

2614 """ 

2615 

2616 http_options = ( 

2617 _BaseSchemaServiceRestTransport._BaseTestIamPermissions._get_http_options() 

2618 ) 

2619 

2620 request, metadata = self._interceptor.pre_test_iam_permissions( 

2621 request, metadata 

2622 ) 

2623 transcoded_request = _BaseSchemaServiceRestTransport._BaseTestIamPermissions._get_transcoded_request( 

2624 http_options, request 

2625 ) 

2626 

2627 body = _BaseSchemaServiceRestTransport._BaseTestIamPermissions._get_request_body_json( 

2628 transcoded_request 

2629 ) 

2630 

2631 # Jsonify the query params 

2632 query_params = _BaseSchemaServiceRestTransport._BaseTestIamPermissions._get_query_params_json( 

2633 transcoded_request 

2634 ) 

2635 

2636 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

2637 logging.DEBUG 

2638 ): # pragma: NO COVER 

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

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

2641 ) 

2642 method = transcoded_request["method"] 

2643 try: 

2644 request_payload = json_format.MessageToJson(request) 

2645 except: 

2646 request_payload = None 

2647 http_request = { 

2648 "payload": request_payload, 

2649 "requestMethod": method, 

2650 "requestUrl": request_url, 

2651 "headers": dict(metadata), 

2652 } 

2653 _LOGGER.debug( 

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

2655 extra={ 

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

2657 "rpcName": "TestIamPermissions", 

2658 "httpRequest": http_request, 

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

2660 }, 

2661 ) 

2662 

2663 # Send the request 

2664 response = SchemaServiceRestTransport._TestIamPermissions._get_response( 

2665 self._host, 

2666 metadata, 

2667 query_params, 

2668 self._session, 

2669 timeout, 

2670 transcoded_request, 

2671 body, 

2672 ) 

2673 

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

2675 # subclass. 

2676 if response.status_code >= 400: 

2677 raise core_exceptions.from_http_response(response) 

2678 

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

2680 resp = iam_policy_pb2.TestIamPermissionsResponse() 

2681 resp = json_format.Parse(content, resp) 

2682 resp = self._interceptor.post_test_iam_permissions(resp) 

2683 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

2684 logging.DEBUG 

2685 ): # pragma: NO COVER 

2686 try: 

2687 response_payload = json_format.MessageToJson(resp) 

2688 except: 

2689 response_payload = None 

2690 http_response = { 

2691 "payload": response_payload, 

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

2693 "status": response.status_code, 

2694 } 

2695 _LOGGER.debug( 

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

2697 extra={ 

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

2699 "rpcName": "TestIamPermissions", 

2700 "httpResponse": http_response, 

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

2702 }, 

2703 ) 

2704 return resp 

2705 

2706 @property 

2707 def kind(self) -> str: 

2708 return "rest" 

2709 

2710 def close(self): 

2711 self._session.close() 

2712 

2713 

2714__all__ = ("SchemaServiceRestTransport",)