Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/google/cloud/tasks_v2/services/cloud_tasks/transports/rest.py: 33%

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

661 statements  

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

2# Copyright 2025 Google LLC 

3# 

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

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

6# You may obtain a copy of the License at 

7# 

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

9# 

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

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

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

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

14# limitations under the License. 

15# 

16import dataclasses 

17import json # type: ignore 

18import logging 

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

20import warnings 

21 

22from google.api_core import exceptions as core_exceptions 

23from google.api_core import gapic_v1, rest_helpers, rest_streaming 

24from google.api_core import retry as retries 

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

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

27from google.cloud.location import locations_pb2 # type: ignore 

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

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

30import google.protobuf 

31from google.protobuf import empty_pb2 # type: ignore 

32from google.protobuf import json_format 

33from requests import __version__ as requests_version 

34 

35from google.cloud.tasks_v2.types import cloudtasks 

36from google.cloud.tasks_v2.types import queue 

37from google.cloud.tasks_v2.types import queue as gct_queue 

38from google.cloud.tasks_v2.types import task 

39from google.cloud.tasks_v2.types import task as gct_task 

40 

41from .base import DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO 

42from .rest_base import _BaseCloudTasksRestTransport 

43 

44try: 

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

46except AttributeError: # pragma: NO COVER 

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

48 

49try: 

50 from google.api_core import client_logging # type: ignore 

51 

52 CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER 

53except ImportError: # pragma: NO COVER 

54 CLIENT_LOGGING_SUPPORTED = False 

55 

56_LOGGER = logging.getLogger(__name__) 

57 

58DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( 

59 gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, 

60 grpc_version=None, 

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

62) 

63 

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

65 DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__ 

66 

67 

68class CloudTasksRestInterceptor: 

69 """Interceptor for CloudTasks. 

70 

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

72 in arbitrary ways. 

73 Example use cases include: 

74 * Logging 

75 * Verifying requests according to service or custom semantics 

76 * Stripping extraneous information from responses 

77 

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

79 instance of a custom subclass when constructing the CloudTasksRestTransport. 

80 

81 .. code-block:: python 

82 class MyCustomCloudTasksInterceptor(CloudTasksRestInterceptor): 

83 def pre_create_queue(self, request, metadata): 

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

85 return request, metadata 

86 

87 def post_create_queue(self, response): 

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

89 return response 

90 

91 def pre_create_task(self, request, metadata): 

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

93 return request, metadata 

94 

95 def post_create_task(self, response): 

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

97 return response 

98 

99 def pre_delete_queue(self, request, metadata): 

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

101 return request, metadata 

102 

103 def pre_delete_task(self, request, metadata): 

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

105 return request, metadata 

106 

107 def pre_get_iam_policy(self, request, metadata): 

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

109 return request, metadata 

110 

111 def post_get_iam_policy(self, response): 

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

113 return response 

114 

115 def pre_get_queue(self, request, metadata): 

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

117 return request, metadata 

118 

119 def post_get_queue(self, response): 

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

121 return response 

122 

123 def pre_get_task(self, request, metadata): 

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

125 return request, metadata 

126 

127 def post_get_task(self, response): 

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

129 return response 

130 

131 def pre_list_queues(self, request, metadata): 

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

133 return request, metadata 

134 

135 def post_list_queues(self, response): 

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

137 return response 

138 

139 def pre_list_tasks(self, request, metadata): 

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

141 return request, metadata 

142 

143 def post_list_tasks(self, response): 

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

145 return response 

146 

147 def pre_pause_queue(self, request, metadata): 

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

149 return request, metadata 

150 

151 def post_pause_queue(self, response): 

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

153 return response 

154 

155 def pre_purge_queue(self, request, metadata): 

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

157 return request, metadata 

158 

159 def post_purge_queue(self, response): 

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

161 return response 

162 

163 def pre_resume_queue(self, request, metadata): 

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

165 return request, metadata 

166 

167 def post_resume_queue(self, response): 

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

169 return response 

170 

171 def pre_run_task(self, request, metadata): 

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

173 return request, metadata 

174 

175 def post_run_task(self, response): 

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

177 return response 

178 

179 def pre_set_iam_policy(self, request, metadata): 

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

181 return request, metadata 

182 

183 def post_set_iam_policy(self, response): 

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

185 return response 

186 

187 def pre_test_iam_permissions(self, request, metadata): 

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

189 return request, metadata 

190 

191 def post_test_iam_permissions(self, response): 

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

193 return response 

194 

195 def pre_update_queue(self, request, metadata): 

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

197 return request, metadata 

198 

199 def post_update_queue(self, response): 

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

201 return response 

202 

203 transport = CloudTasksRestTransport(interceptor=MyCustomCloudTasksInterceptor()) 

204 client = CloudTasksClient(transport=transport) 

205 

206 

207 """ 

208 

209 def pre_create_queue( 

210 self, 

211 request: cloudtasks.CreateQueueRequest, 

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

213 ) -> Tuple[cloudtasks.CreateQueueRequest, Sequence[Tuple[str, Union[str, bytes]]]]: 

214 """Pre-rpc interceptor for create_queue 

215 

216 Override in a subclass to manipulate the request or metadata 

217 before they are sent to the CloudTasks server. 

218 """ 

219 return request, metadata 

220 

221 def post_create_queue(self, response: gct_queue.Queue) -> gct_queue.Queue: 

222 """Post-rpc interceptor for create_queue 

223 

224 DEPRECATED. Please use the `post_create_queue_with_metadata` 

225 interceptor instead. 

226 

227 Override in a subclass to read or manipulate the response 

228 after it is returned by the CloudTasks server but before 

229 it is returned to user code. This `post_create_queue` interceptor runs 

230 before the `post_create_queue_with_metadata` interceptor. 

231 """ 

232 return response 

233 

234 def post_create_queue_with_metadata( 

235 self, 

236 response: gct_queue.Queue, 

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

238 ) -> Tuple[gct_queue.Queue, Sequence[Tuple[str, Union[str, bytes]]]]: 

239 """Post-rpc interceptor for create_queue 

240 

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

242 is returned by the CloudTasks server but before it is returned to user code. 

243 

244 We recommend only using this `post_create_queue_with_metadata` 

245 interceptor in new development instead of the `post_create_queue` interceptor. 

246 When both interceptors are used, this `post_create_queue_with_metadata` interceptor runs after the 

247 `post_create_queue` interceptor. The (possibly modified) response returned by 

248 `post_create_queue` will be passed to 

249 `post_create_queue_with_metadata`. 

250 """ 

251 return response, metadata 

252 

253 def pre_create_task( 

254 self, 

255 request: cloudtasks.CreateTaskRequest, 

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

257 ) -> Tuple[cloudtasks.CreateTaskRequest, Sequence[Tuple[str, Union[str, bytes]]]]: 

258 """Pre-rpc interceptor for create_task 

259 

260 Override in a subclass to manipulate the request or metadata 

261 before they are sent to the CloudTasks server. 

262 """ 

263 return request, metadata 

264 

265 def post_create_task(self, response: gct_task.Task) -> gct_task.Task: 

266 """Post-rpc interceptor for create_task 

267 

268 DEPRECATED. Please use the `post_create_task_with_metadata` 

269 interceptor instead. 

270 

271 Override in a subclass to read or manipulate the response 

272 after it is returned by the CloudTasks server but before 

273 it is returned to user code. This `post_create_task` interceptor runs 

274 before the `post_create_task_with_metadata` interceptor. 

275 """ 

276 return response 

277 

278 def post_create_task_with_metadata( 

279 self, response: gct_task.Task, metadata: Sequence[Tuple[str, Union[str, bytes]]] 

280 ) -> Tuple[gct_task.Task, Sequence[Tuple[str, Union[str, bytes]]]]: 

281 """Post-rpc interceptor for create_task 

282 

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

284 is returned by the CloudTasks server but before it is returned to user code. 

285 

286 We recommend only using this `post_create_task_with_metadata` 

287 interceptor in new development instead of the `post_create_task` interceptor. 

288 When both interceptors are used, this `post_create_task_with_metadata` interceptor runs after the 

289 `post_create_task` interceptor. The (possibly modified) response returned by 

290 `post_create_task` will be passed to 

291 `post_create_task_with_metadata`. 

292 """ 

293 return response, metadata 

294 

295 def pre_delete_queue( 

296 self, 

297 request: cloudtasks.DeleteQueueRequest, 

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

299 ) -> Tuple[cloudtasks.DeleteQueueRequest, Sequence[Tuple[str, Union[str, bytes]]]]: 

300 """Pre-rpc interceptor for delete_queue 

301 

302 Override in a subclass to manipulate the request or metadata 

303 before they are sent to the CloudTasks server. 

304 """ 

305 return request, metadata 

306 

307 def pre_delete_task( 

308 self, 

309 request: cloudtasks.DeleteTaskRequest, 

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

311 ) -> Tuple[cloudtasks.DeleteTaskRequest, Sequence[Tuple[str, Union[str, bytes]]]]: 

312 """Pre-rpc interceptor for delete_task 

313 

314 Override in a subclass to manipulate the request or metadata 

315 before they are sent to the CloudTasks server. 

316 """ 

317 return request, metadata 

318 

319 def pre_get_iam_policy( 

320 self, 

321 request: iam_policy_pb2.GetIamPolicyRequest, 

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

323 ) -> Tuple[ 

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

325 ]: 

326 """Pre-rpc interceptor for get_iam_policy 

327 

328 Override in a subclass to manipulate the request or metadata 

329 before they are sent to the CloudTasks server. 

330 """ 

331 return request, metadata 

332 

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

334 """Post-rpc interceptor for get_iam_policy 

335 

336 DEPRECATED. Please use the `post_get_iam_policy_with_metadata` 

337 interceptor instead. 

338 

339 Override in a subclass to read or manipulate the response 

340 after it is returned by the CloudTasks server but before 

341 it is returned to user code. This `post_get_iam_policy` interceptor runs 

342 before the `post_get_iam_policy_with_metadata` interceptor. 

343 """ 

344 return response 

345 

346 def post_get_iam_policy_with_metadata( 

347 self, 

348 response: policy_pb2.Policy, 

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

350 ) -> Tuple[policy_pb2.Policy, Sequence[Tuple[str, Union[str, bytes]]]]: 

351 """Post-rpc interceptor for get_iam_policy 

352 

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

354 is returned by the CloudTasks server but before it is returned to user code. 

355 

356 We recommend only using this `post_get_iam_policy_with_metadata` 

357 interceptor in new development instead of the `post_get_iam_policy` interceptor. 

358 When both interceptors are used, this `post_get_iam_policy_with_metadata` interceptor runs after the 

359 `post_get_iam_policy` interceptor. The (possibly modified) response returned by 

360 `post_get_iam_policy` will be passed to 

361 `post_get_iam_policy_with_metadata`. 

362 """ 

363 return response, metadata 

364 

365 def pre_get_queue( 

366 self, 

367 request: cloudtasks.GetQueueRequest, 

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

369 ) -> Tuple[cloudtasks.GetQueueRequest, Sequence[Tuple[str, Union[str, bytes]]]]: 

370 """Pre-rpc interceptor for get_queue 

371 

372 Override in a subclass to manipulate the request or metadata 

373 before they are sent to the CloudTasks server. 

374 """ 

375 return request, metadata 

376 

377 def post_get_queue(self, response: queue.Queue) -> queue.Queue: 

378 """Post-rpc interceptor for get_queue 

379 

380 DEPRECATED. Please use the `post_get_queue_with_metadata` 

381 interceptor instead. 

382 

383 Override in a subclass to read or manipulate the response 

384 after it is returned by the CloudTasks server but before 

385 it is returned to user code. This `post_get_queue` interceptor runs 

386 before the `post_get_queue_with_metadata` interceptor. 

387 """ 

388 return response 

389 

390 def post_get_queue_with_metadata( 

391 self, response: queue.Queue, metadata: Sequence[Tuple[str, Union[str, bytes]]] 

392 ) -> Tuple[queue.Queue, Sequence[Tuple[str, Union[str, bytes]]]]: 

393 """Post-rpc interceptor for get_queue 

394 

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

396 is returned by the CloudTasks server but before it is returned to user code. 

397 

398 We recommend only using this `post_get_queue_with_metadata` 

399 interceptor in new development instead of the `post_get_queue` interceptor. 

400 When both interceptors are used, this `post_get_queue_with_metadata` interceptor runs after the 

401 `post_get_queue` interceptor. The (possibly modified) response returned by 

402 `post_get_queue` will be passed to 

403 `post_get_queue_with_metadata`. 

404 """ 

405 return response, metadata 

406 

407 def pre_get_task( 

408 self, 

409 request: cloudtasks.GetTaskRequest, 

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

411 ) -> Tuple[cloudtasks.GetTaskRequest, Sequence[Tuple[str, Union[str, bytes]]]]: 

412 """Pre-rpc interceptor for get_task 

413 

414 Override in a subclass to manipulate the request or metadata 

415 before they are sent to the CloudTasks server. 

416 """ 

417 return request, metadata 

418 

419 def post_get_task(self, response: task.Task) -> task.Task: 

420 """Post-rpc interceptor for get_task 

421 

422 DEPRECATED. Please use the `post_get_task_with_metadata` 

423 interceptor instead. 

424 

425 Override in a subclass to read or manipulate the response 

426 after it is returned by the CloudTasks server but before 

427 it is returned to user code. This `post_get_task` interceptor runs 

428 before the `post_get_task_with_metadata` interceptor. 

429 """ 

430 return response 

431 

432 def post_get_task_with_metadata( 

433 self, response: task.Task, metadata: Sequence[Tuple[str, Union[str, bytes]]] 

434 ) -> Tuple[task.Task, Sequence[Tuple[str, Union[str, bytes]]]]: 

435 """Post-rpc interceptor for get_task 

436 

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

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

439 

440 We recommend only using this `post_get_task_with_metadata` 

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

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

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

444 `post_get_task` will be passed to 

445 `post_get_task_with_metadata`. 

446 """ 

447 return response, metadata 

448 

449 def pre_list_queues( 

450 self, 

451 request: cloudtasks.ListQueuesRequest, 

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

453 ) -> Tuple[cloudtasks.ListQueuesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: 

454 """Pre-rpc interceptor for list_queues 

455 

456 Override in a subclass to manipulate the request or metadata 

457 before they are sent to the CloudTasks server. 

458 """ 

459 return request, metadata 

460 

461 def post_list_queues( 

462 self, response: cloudtasks.ListQueuesResponse 

463 ) -> cloudtasks.ListQueuesResponse: 

464 """Post-rpc interceptor for list_queues 

465 

466 DEPRECATED. Please use the `post_list_queues_with_metadata` 

467 interceptor instead. 

468 

469 Override in a subclass to read or manipulate the response 

470 after it is returned by the CloudTasks server but before 

471 it is returned to user code. This `post_list_queues` interceptor runs 

472 before the `post_list_queues_with_metadata` interceptor. 

473 """ 

474 return response 

475 

476 def post_list_queues_with_metadata( 

477 self, 

478 response: cloudtasks.ListQueuesResponse, 

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

480 ) -> Tuple[cloudtasks.ListQueuesResponse, Sequence[Tuple[str, Union[str, bytes]]]]: 

481 """Post-rpc interceptor for list_queues 

482 

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

484 is returned by the CloudTasks server but before it is returned to user code. 

485 

486 We recommend only using this `post_list_queues_with_metadata` 

487 interceptor in new development instead of the `post_list_queues` interceptor. 

488 When both interceptors are used, this `post_list_queues_with_metadata` interceptor runs after the 

489 `post_list_queues` interceptor. The (possibly modified) response returned by 

490 `post_list_queues` will be passed to 

491 `post_list_queues_with_metadata`. 

492 """ 

493 return response, metadata 

494 

495 def pre_list_tasks( 

496 self, 

497 request: cloudtasks.ListTasksRequest, 

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

499 ) -> Tuple[cloudtasks.ListTasksRequest, Sequence[Tuple[str, Union[str, bytes]]]]: 

500 """Pre-rpc interceptor for list_tasks 

501 

502 Override in a subclass to manipulate the request or metadata 

503 before they are sent to the CloudTasks server. 

504 """ 

505 return request, metadata 

506 

507 def post_list_tasks( 

508 self, response: cloudtasks.ListTasksResponse 

509 ) -> cloudtasks.ListTasksResponse: 

510 """Post-rpc interceptor for list_tasks 

511 

512 DEPRECATED. Please use the `post_list_tasks_with_metadata` 

513 interceptor instead. 

514 

515 Override in a subclass to read or manipulate the response 

516 after it is returned by the CloudTasks server but before 

517 it is returned to user code. This `post_list_tasks` interceptor runs 

518 before the `post_list_tasks_with_metadata` interceptor. 

519 """ 

520 return response 

521 

522 def post_list_tasks_with_metadata( 

523 self, 

524 response: cloudtasks.ListTasksResponse, 

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

526 ) -> Tuple[cloudtasks.ListTasksResponse, Sequence[Tuple[str, Union[str, bytes]]]]: 

527 """Post-rpc interceptor for list_tasks 

528 

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

530 is returned by the CloudTasks server but before it is returned to user code. 

531 

532 We recommend only using this `post_list_tasks_with_metadata` 

533 interceptor in new development instead of the `post_list_tasks` interceptor. 

534 When both interceptors are used, this `post_list_tasks_with_metadata` interceptor runs after the 

535 `post_list_tasks` interceptor. The (possibly modified) response returned by 

536 `post_list_tasks` will be passed to 

537 `post_list_tasks_with_metadata`. 

538 """ 

539 return response, metadata 

540 

541 def pre_pause_queue( 

542 self, 

543 request: cloudtasks.PauseQueueRequest, 

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

545 ) -> Tuple[cloudtasks.PauseQueueRequest, Sequence[Tuple[str, Union[str, bytes]]]]: 

546 """Pre-rpc interceptor for pause_queue 

547 

548 Override in a subclass to manipulate the request or metadata 

549 before they are sent to the CloudTasks server. 

550 """ 

551 return request, metadata 

552 

553 def post_pause_queue(self, response: queue.Queue) -> queue.Queue: 

554 """Post-rpc interceptor for pause_queue 

555 

556 DEPRECATED. Please use the `post_pause_queue_with_metadata` 

557 interceptor instead. 

558 

559 Override in a subclass to read or manipulate the response 

560 after it is returned by the CloudTasks server but before 

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

562 before the `post_pause_queue_with_metadata` interceptor. 

563 """ 

564 return response 

565 

566 def post_pause_queue_with_metadata( 

567 self, response: queue.Queue, metadata: Sequence[Tuple[str, Union[str, bytes]]] 

568 ) -> Tuple[queue.Queue, Sequence[Tuple[str, Union[str, bytes]]]]: 

569 """Post-rpc interceptor for pause_queue 

570 

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

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

573 

574 We recommend only using this `post_pause_queue_with_metadata` 

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

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

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

578 `post_pause_queue` will be passed to 

579 `post_pause_queue_with_metadata`. 

580 """ 

581 return response, metadata 

582 

583 def pre_purge_queue( 

584 self, 

585 request: cloudtasks.PurgeQueueRequest, 

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

587 ) -> Tuple[cloudtasks.PurgeQueueRequest, Sequence[Tuple[str, Union[str, bytes]]]]: 

588 """Pre-rpc interceptor for purge_queue 

589 

590 Override in a subclass to manipulate the request or metadata 

591 before they are sent to the CloudTasks server. 

592 """ 

593 return request, metadata 

594 

595 def post_purge_queue(self, response: queue.Queue) -> queue.Queue: 

596 """Post-rpc interceptor for purge_queue 

597 

598 DEPRECATED. Please use the `post_purge_queue_with_metadata` 

599 interceptor instead. 

600 

601 Override in a subclass to read or manipulate the response 

602 after it is returned by the CloudTasks server but before 

603 it is returned to user code. This `post_purge_queue` interceptor runs 

604 before the `post_purge_queue_with_metadata` interceptor. 

605 """ 

606 return response 

607 

608 def post_purge_queue_with_metadata( 

609 self, response: queue.Queue, metadata: Sequence[Tuple[str, Union[str, bytes]]] 

610 ) -> Tuple[queue.Queue, Sequence[Tuple[str, Union[str, bytes]]]]: 

611 """Post-rpc interceptor for purge_queue 

612 

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

614 is returned by the CloudTasks server but before it is returned to user code. 

615 

616 We recommend only using this `post_purge_queue_with_metadata` 

617 interceptor in new development instead of the `post_purge_queue` interceptor. 

618 When both interceptors are used, this `post_purge_queue_with_metadata` interceptor runs after the 

619 `post_purge_queue` interceptor. The (possibly modified) response returned by 

620 `post_purge_queue` will be passed to 

621 `post_purge_queue_with_metadata`. 

622 """ 

623 return response, metadata 

624 

625 def pre_resume_queue( 

626 self, 

627 request: cloudtasks.ResumeQueueRequest, 

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

629 ) -> Tuple[cloudtasks.ResumeQueueRequest, Sequence[Tuple[str, Union[str, bytes]]]]: 

630 """Pre-rpc interceptor for resume_queue 

631 

632 Override in a subclass to manipulate the request or metadata 

633 before they are sent to the CloudTasks server. 

634 """ 

635 return request, metadata 

636 

637 def post_resume_queue(self, response: queue.Queue) -> queue.Queue: 

638 """Post-rpc interceptor for resume_queue 

639 

640 DEPRECATED. Please use the `post_resume_queue_with_metadata` 

641 interceptor instead. 

642 

643 Override in a subclass to read or manipulate the response 

644 after it is returned by the CloudTasks server but before 

645 it is returned to user code. This `post_resume_queue` interceptor runs 

646 before the `post_resume_queue_with_metadata` interceptor. 

647 """ 

648 return response 

649 

650 def post_resume_queue_with_metadata( 

651 self, response: queue.Queue, metadata: Sequence[Tuple[str, Union[str, bytes]]] 

652 ) -> Tuple[queue.Queue, Sequence[Tuple[str, Union[str, bytes]]]]: 

653 """Post-rpc interceptor for resume_queue 

654 

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

656 is returned by the CloudTasks server but before it is returned to user code. 

657 

658 We recommend only using this `post_resume_queue_with_metadata` 

659 interceptor in new development instead of the `post_resume_queue` interceptor. 

660 When both interceptors are used, this `post_resume_queue_with_metadata` interceptor runs after the 

661 `post_resume_queue` interceptor. The (possibly modified) response returned by 

662 `post_resume_queue` will be passed to 

663 `post_resume_queue_with_metadata`. 

664 """ 

665 return response, metadata 

666 

667 def pre_run_task( 

668 self, 

669 request: cloudtasks.RunTaskRequest, 

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

671 ) -> Tuple[cloudtasks.RunTaskRequest, Sequence[Tuple[str, Union[str, bytes]]]]: 

672 """Pre-rpc interceptor for run_task 

673 

674 Override in a subclass to manipulate the request or metadata 

675 before they are sent to the CloudTasks server. 

676 """ 

677 return request, metadata 

678 

679 def post_run_task(self, response: task.Task) -> task.Task: 

680 """Post-rpc interceptor for run_task 

681 

682 DEPRECATED. Please use the `post_run_task_with_metadata` 

683 interceptor instead. 

684 

685 Override in a subclass to read or manipulate the response 

686 after it is returned by the CloudTasks server but before 

687 it is returned to user code. This `post_run_task` interceptor runs 

688 before the `post_run_task_with_metadata` interceptor. 

689 """ 

690 return response 

691 

692 def post_run_task_with_metadata( 

693 self, response: task.Task, metadata: Sequence[Tuple[str, Union[str, bytes]]] 

694 ) -> Tuple[task.Task, Sequence[Tuple[str, Union[str, bytes]]]]: 

695 """Post-rpc interceptor for run_task 

696 

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

698 is returned by the CloudTasks server but before it is returned to user code. 

699 

700 We recommend only using this `post_run_task_with_metadata` 

701 interceptor in new development instead of the `post_run_task` interceptor. 

702 When both interceptors are used, this `post_run_task_with_metadata` interceptor runs after the 

703 `post_run_task` interceptor. The (possibly modified) response returned by 

704 `post_run_task` will be passed to 

705 `post_run_task_with_metadata`. 

706 """ 

707 return response, metadata 

708 

709 def pre_set_iam_policy( 

710 self, 

711 request: iam_policy_pb2.SetIamPolicyRequest, 

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

713 ) -> Tuple[ 

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

715 ]: 

716 """Pre-rpc interceptor for set_iam_policy 

717 

718 Override in a subclass to manipulate the request or metadata 

719 before they are sent to the CloudTasks server. 

720 """ 

721 return request, metadata 

722 

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

724 """Post-rpc interceptor for set_iam_policy 

725 

726 DEPRECATED. Please use the `post_set_iam_policy_with_metadata` 

727 interceptor instead. 

728 

729 Override in a subclass to read or manipulate the response 

730 after it is returned by the CloudTasks server but before 

731 it is returned to user code. This `post_set_iam_policy` interceptor runs 

732 before the `post_set_iam_policy_with_metadata` interceptor. 

733 """ 

734 return response 

735 

736 def post_set_iam_policy_with_metadata( 

737 self, 

738 response: policy_pb2.Policy, 

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

740 ) -> Tuple[policy_pb2.Policy, Sequence[Tuple[str, Union[str, bytes]]]]: 

741 """Post-rpc interceptor for set_iam_policy 

742 

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

744 is returned by the CloudTasks server but before it is returned to user code. 

745 

746 We recommend only using this `post_set_iam_policy_with_metadata` 

747 interceptor in new development instead of the `post_set_iam_policy` interceptor. 

748 When both interceptors are used, this `post_set_iam_policy_with_metadata` interceptor runs after the 

749 `post_set_iam_policy` interceptor. The (possibly modified) response returned by 

750 `post_set_iam_policy` will be passed to 

751 `post_set_iam_policy_with_metadata`. 

752 """ 

753 return response, metadata 

754 

755 def pre_test_iam_permissions( 

756 self, 

757 request: iam_policy_pb2.TestIamPermissionsRequest, 

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

759 ) -> Tuple[ 

760 iam_policy_pb2.TestIamPermissionsRequest, 

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

762 ]: 

763 """Pre-rpc interceptor for test_iam_permissions 

764 

765 Override in a subclass to manipulate the request or metadata 

766 before they are sent to the CloudTasks server. 

767 """ 

768 return request, metadata 

769 

770 def post_test_iam_permissions( 

771 self, response: iam_policy_pb2.TestIamPermissionsResponse 

772 ) -> iam_policy_pb2.TestIamPermissionsResponse: 

773 """Post-rpc interceptor for test_iam_permissions 

774 

775 DEPRECATED. Please use the `post_test_iam_permissions_with_metadata` 

776 interceptor instead. 

777 

778 Override in a subclass to read or manipulate the response 

779 after it is returned by the CloudTasks server but before 

780 it is returned to user code. This `post_test_iam_permissions` interceptor runs 

781 before the `post_test_iam_permissions_with_metadata` interceptor. 

782 """ 

783 return response 

784 

785 def post_test_iam_permissions_with_metadata( 

786 self, 

787 response: iam_policy_pb2.TestIamPermissionsResponse, 

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

789 ) -> Tuple[ 

790 iam_policy_pb2.TestIamPermissionsResponse, 

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

792 ]: 

793 """Post-rpc interceptor for test_iam_permissions 

794 

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

796 is returned by the CloudTasks server but before it is returned to user code. 

797 

798 We recommend only using this `post_test_iam_permissions_with_metadata` 

799 interceptor in new development instead of the `post_test_iam_permissions` interceptor. 

800 When both interceptors are used, this `post_test_iam_permissions_with_metadata` interceptor runs after the 

801 `post_test_iam_permissions` interceptor. The (possibly modified) response returned by 

802 `post_test_iam_permissions` will be passed to 

803 `post_test_iam_permissions_with_metadata`. 

804 """ 

805 return response, metadata 

806 

807 def pre_update_queue( 

808 self, 

809 request: cloudtasks.UpdateQueueRequest, 

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

811 ) -> Tuple[cloudtasks.UpdateQueueRequest, Sequence[Tuple[str, Union[str, bytes]]]]: 

812 """Pre-rpc interceptor for update_queue 

813 

814 Override in a subclass to manipulate the request or metadata 

815 before they are sent to the CloudTasks server. 

816 """ 

817 return request, metadata 

818 

819 def post_update_queue(self, response: gct_queue.Queue) -> gct_queue.Queue: 

820 """Post-rpc interceptor for update_queue 

821 

822 DEPRECATED. Please use the `post_update_queue_with_metadata` 

823 interceptor instead. 

824 

825 Override in a subclass to read or manipulate the response 

826 after it is returned by the CloudTasks server but before 

827 it is returned to user code. This `post_update_queue` interceptor runs 

828 before the `post_update_queue_with_metadata` interceptor. 

829 """ 

830 return response 

831 

832 def post_update_queue_with_metadata( 

833 self, 

834 response: gct_queue.Queue, 

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

836 ) -> Tuple[gct_queue.Queue, Sequence[Tuple[str, Union[str, bytes]]]]: 

837 """Post-rpc interceptor for update_queue 

838 

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

840 is returned by the CloudTasks server but before it is returned to user code. 

841 

842 We recommend only using this `post_update_queue_with_metadata` 

843 interceptor in new development instead of the `post_update_queue` interceptor. 

844 When both interceptors are used, this `post_update_queue_with_metadata` interceptor runs after the 

845 `post_update_queue` interceptor. The (possibly modified) response returned by 

846 `post_update_queue` will be passed to 

847 `post_update_queue_with_metadata`. 

848 """ 

849 return response, metadata 

850 

851 def pre_get_location( 

852 self, 

853 request: locations_pb2.GetLocationRequest, 

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

855 ) -> Tuple[ 

856 locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] 

857 ]: 

858 """Pre-rpc interceptor for get_location 

859 

860 Override in a subclass to manipulate the request or metadata 

861 before they are sent to the CloudTasks server. 

862 """ 

863 return request, metadata 

864 

865 def post_get_location( 

866 self, response: locations_pb2.Location 

867 ) -> locations_pb2.Location: 

868 """Post-rpc interceptor for get_location 

869 

870 Override in a subclass to manipulate the response 

871 after it is returned by the CloudTasks server but before 

872 it is returned to user code. 

873 """ 

874 return response 

875 

876 def pre_list_locations( 

877 self, 

878 request: locations_pb2.ListLocationsRequest, 

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

880 ) -> Tuple[ 

881 locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] 

882 ]: 

883 """Pre-rpc interceptor for list_locations 

884 

885 Override in a subclass to manipulate the request or metadata 

886 before they are sent to the CloudTasks server. 

887 """ 

888 return request, metadata 

889 

890 def post_list_locations( 

891 self, response: locations_pb2.ListLocationsResponse 

892 ) -> locations_pb2.ListLocationsResponse: 

893 """Post-rpc interceptor for list_locations 

894 

895 Override in a subclass to manipulate the response 

896 after it is returned by the CloudTasks server but before 

897 it is returned to user code. 

898 """ 

899 return response 

900 

901 

902@dataclasses.dataclass 

903class CloudTasksRestStub: 

904 _session: AuthorizedSession 

905 _host: str 

906 _interceptor: CloudTasksRestInterceptor 

907 

908 

909class CloudTasksRestTransport(_BaseCloudTasksRestTransport): 

910 """REST backend synchronous transport for CloudTasks. 

911 

912 Cloud Tasks allows developers to manage the execution of 

913 background work in their applications. 

914 

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

916 primary client can load the underlying transport implementation 

917 and call it. 

918 

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

920 """ 

921 

922 def __init__( 

923 self, 

924 *, 

925 host: str = "cloudtasks.googleapis.com", 

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

927 credentials_file: Optional[str] = None, 

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

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

930 quota_project_id: Optional[str] = None, 

931 client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, 

932 always_use_jwt_access: Optional[bool] = False, 

933 url_scheme: str = "https", 

934 interceptor: Optional[CloudTasksRestInterceptor] = None, 

935 api_audience: Optional[str] = None, 

936 ) -> None: 

937 """Instantiate the transport. 

938 

939 Args: 

940 host (Optional[str]): 

941 The hostname to connect to (default: 'cloudtasks.googleapis.com'). 

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

943 authorization credentials to attach to requests. These 

944 credentials identify the application to the service; if none 

945 are specified, the client will attempt to ascertain the 

946 credentials from the environment. 

947 

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

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

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

951 removed in the next major version of this library. 

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

953 ignored if ``channel`` is provided. 

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

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

956 if ``channel`` is provided. 

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

958 and quota. 

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

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

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

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

963 your own client library. 

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

965 be used for service account credentials. 

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

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

968 "http" can be specified. 

969 """ 

970 # Run the base constructor 

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

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

973 # credentials object 

974 super().__init__( 

975 host=host, 

976 credentials=credentials, 

977 client_info=client_info, 

978 always_use_jwt_access=always_use_jwt_access, 

979 url_scheme=url_scheme, 

980 api_audience=api_audience, 

981 ) 

982 self._session = AuthorizedSession( 

983 self._credentials, default_host=self.DEFAULT_HOST 

984 ) 

985 if client_cert_source_for_mtls: 

986 self._session.configure_mtls_channel(client_cert_source_for_mtls) 

987 self._interceptor = interceptor or CloudTasksRestInterceptor() 

988 self._prep_wrapped_messages(client_info) 

989 

990 class _CreateQueue( 

991 _BaseCloudTasksRestTransport._BaseCreateQueue, CloudTasksRestStub 

992 ): 

993 def __hash__(self): 

994 return hash("CloudTasksRestTransport.CreateQueue") 

995 

996 @staticmethod 

997 def _get_response( 

998 host, 

999 metadata, 

1000 query_params, 

1001 session, 

1002 timeout, 

1003 transcoded_request, 

1004 body=None, 

1005 ): 

1006 uri = transcoded_request["uri"] 

1007 method = transcoded_request["method"] 

1008 headers = dict(metadata) 

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

1010 response = getattr(session, method)( 

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

1012 timeout=timeout, 

1013 headers=headers, 

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

1015 data=body, 

1016 ) 

1017 return response 

1018 

1019 def __call__( 

1020 self, 

1021 request: cloudtasks.CreateQueueRequest, 

1022 *, 

1023 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1024 timeout: Optional[float] = None, 

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

1026 ) -> gct_queue.Queue: 

1027 r"""Call the create queue method over HTTP. 

1028 

1029 Args: 

1030 request (~.cloudtasks.CreateQueueRequest): 

1031 The request object. Request message for 

1032 [CreateQueue][google.cloud.tasks.v2.CloudTasks.CreateQueue]. 

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

1034 should be retried. 

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

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

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

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

1039 be of type `bytes`. 

1040 

1041 Returns: 

1042 ~.gct_queue.Queue: 

1043 A queue is a container of related 

1044 tasks. Queues are configured to manage 

1045 how those tasks are dispatched. 

1046 Configurable properties include rate 

1047 limits, retry options, queue types, and 

1048 others. 

1049 

1050 """ 

1051 

1052 http_options = ( 

1053 _BaseCloudTasksRestTransport._BaseCreateQueue._get_http_options() 

1054 ) 

1055 

1056 request, metadata = self._interceptor.pre_create_queue(request, metadata) 

1057 transcoded_request = ( 

1058 _BaseCloudTasksRestTransport._BaseCreateQueue._get_transcoded_request( 

1059 http_options, request 

1060 ) 

1061 ) 

1062 

1063 body = _BaseCloudTasksRestTransport._BaseCreateQueue._get_request_body_json( 

1064 transcoded_request 

1065 ) 

1066 

1067 # Jsonify the query params 

1068 query_params = ( 

1069 _BaseCloudTasksRestTransport._BaseCreateQueue._get_query_params_json( 

1070 transcoded_request 

1071 ) 

1072 ) 

1073 

1074 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1075 logging.DEBUG 

1076 ): # pragma: NO COVER 

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

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

1079 ) 

1080 method = transcoded_request["method"] 

1081 try: 

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

1083 except: 

1084 request_payload = None 

1085 http_request = { 

1086 "payload": request_payload, 

1087 "requestMethod": method, 

1088 "requestUrl": request_url, 

1089 "headers": dict(metadata), 

1090 } 

1091 _LOGGER.debug( 

1092 f"Sending request for google.cloud.tasks_v2.CloudTasksClient.CreateQueue", 

1093 extra={ 

1094 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

1095 "rpcName": "CreateQueue", 

1096 "httpRequest": http_request, 

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

1098 }, 

1099 ) 

1100 

1101 # Send the request 

1102 response = CloudTasksRestTransport._CreateQueue._get_response( 

1103 self._host, 

1104 metadata, 

1105 query_params, 

1106 self._session, 

1107 timeout, 

1108 transcoded_request, 

1109 body, 

1110 ) 

1111 

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

1113 # subclass. 

1114 if response.status_code >= 400: 

1115 raise core_exceptions.from_http_response(response) 

1116 

1117 # Return the response 

1118 resp = gct_queue.Queue() 

1119 pb_resp = gct_queue.Queue.pb(resp) 

1120 

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

1122 

1123 resp = self._interceptor.post_create_queue(resp) 

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

1125 resp, _ = self._interceptor.post_create_queue_with_metadata( 

1126 resp, response_metadata 

1127 ) 

1128 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1129 logging.DEBUG 

1130 ): # pragma: NO COVER 

1131 try: 

1132 response_payload = gct_queue.Queue.to_json(response) 

1133 except: 

1134 response_payload = None 

1135 http_response = { 

1136 "payload": response_payload, 

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

1138 "status": response.status_code, 

1139 } 

1140 _LOGGER.debug( 

1141 "Received response for google.cloud.tasks_v2.CloudTasksClient.create_queue", 

1142 extra={ 

1143 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

1144 "rpcName": "CreateQueue", 

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

1146 "httpResponse": http_response, 

1147 }, 

1148 ) 

1149 return resp 

1150 

1151 class _CreateTask(_BaseCloudTasksRestTransport._BaseCreateTask, CloudTasksRestStub): 

1152 def __hash__(self): 

1153 return hash("CloudTasksRestTransport.CreateTask") 

1154 

1155 @staticmethod 

1156 def _get_response( 

1157 host, 

1158 metadata, 

1159 query_params, 

1160 session, 

1161 timeout, 

1162 transcoded_request, 

1163 body=None, 

1164 ): 

1165 uri = transcoded_request["uri"] 

1166 method = transcoded_request["method"] 

1167 headers = dict(metadata) 

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

1169 response = getattr(session, method)( 

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

1171 timeout=timeout, 

1172 headers=headers, 

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

1174 data=body, 

1175 ) 

1176 return response 

1177 

1178 def __call__( 

1179 self, 

1180 request: cloudtasks.CreateTaskRequest, 

1181 *, 

1182 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1183 timeout: Optional[float] = None, 

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

1185 ) -> gct_task.Task: 

1186 r"""Call the create task method over HTTP. 

1187 

1188 Args: 

1189 request (~.cloudtasks.CreateTaskRequest): 

1190 The request object. Request message for 

1191 [CreateTask][google.cloud.tasks.v2.CloudTasks.CreateTask]. 

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

1193 should be retried. 

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

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

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

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

1198 be of type `bytes`. 

1199 

1200 Returns: 

1201 ~.gct_task.Task: 

1202 A unit of scheduled work. 

1203 """ 

1204 

1205 http_options = ( 

1206 _BaseCloudTasksRestTransport._BaseCreateTask._get_http_options() 

1207 ) 

1208 

1209 request, metadata = self._interceptor.pre_create_task(request, metadata) 

1210 transcoded_request = ( 

1211 _BaseCloudTasksRestTransport._BaseCreateTask._get_transcoded_request( 

1212 http_options, request 

1213 ) 

1214 ) 

1215 

1216 body = _BaseCloudTasksRestTransport._BaseCreateTask._get_request_body_json( 

1217 transcoded_request 

1218 ) 

1219 

1220 # Jsonify the query params 

1221 query_params = ( 

1222 _BaseCloudTasksRestTransport._BaseCreateTask._get_query_params_json( 

1223 transcoded_request 

1224 ) 

1225 ) 

1226 

1227 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1228 logging.DEBUG 

1229 ): # pragma: NO COVER 

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

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

1232 ) 

1233 method = transcoded_request["method"] 

1234 try: 

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

1236 except: 

1237 request_payload = None 

1238 http_request = { 

1239 "payload": request_payload, 

1240 "requestMethod": method, 

1241 "requestUrl": request_url, 

1242 "headers": dict(metadata), 

1243 } 

1244 _LOGGER.debug( 

1245 f"Sending request for google.cloud.tasks_v2.CloudTasksClient.CreateTask", 

1246 extra={ 

1247 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

1248 "rpcName": "CreateTask", 

1249 "httpRequest": http_request, 

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

1251 }, 

1252 ) 

1253 

1254 # Send the request 

1255 response = CloudTasksRestTransport._CreateTask._get_response( 

1256 self._host, 

1257 metadata, 

1258 query_params, 

1259 self._session, 

1260 timeout, 

1261 transcoded_request, 

1262 body, 

1263 ) 

1264 

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

1266 # subclass. 

1267 if response.status_code >= 400: 

1268 raise core_exceptions.from_http_response(response) 

1269 

1270 # Return the response 

1271 resp = gct_task.Task() 

1272 pb_resp = gct_task.Task.pb(resp) 

1273 

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

1275 

1276 resp = self._interceptor.post_create_task(resp) 

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

1278 resp, _ = self._interceptor.post_create_task_with_metadata( 

1279 resp, response_metadata 

1280 ) 

1281 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1282 logging.DEBUG 

1283 ): # pragma: NO COVER 

1284 try: 

1285 response_payload = gct_task.Task.to_json(response) 

1286 except: 

1287 response_payload = None 

1288 http_response = { 

1289 "payload": response_payload, 

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

1291 "status": response.status_code, 

1292 } 

1293 _LOGGER.debug( 

1294 "Received response for google.cloud.tasks_v2.CloudTasksClient.create_task", 

1295 extra={ 

1296 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

1297 "rpcName": "CreateTask", 

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

1299 "httpResponse": http_response, 

1300 }, 

1301 ) 

1302 return resp 

1303 

1304 class _DeleteQueue( 

1305 _BaseCloudTasksRestTransport._BaseDeleteQueue, CloudTasksRestStub 

1306 ): 

1307 def __hash__(self): 

1308 return hash("CloudTasksRestTransport.DeleteQueue") 

1309 

1310 @staticmethod 

1311 def _get_response( 

1312 host, 

1313 metadata, 

1314 query_params, 

1315 session, 

1316 timeout, 

1317 transcoded_request, 

1318 body=None, 

1319 ): 

1320 uri = transcoded_request["uri"] 

1321 method = transcoded_request["method"] 

1322 headers = dict(metadata) 

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

1324 response = getattr(session, method)( 

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

1326 timeout=timeout, 

1327 headers=headers, 

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

1329 ) 

1330 return response 

1331 

1332 def __call__( 

1333 self, 

1334 request: cloudtasks.DeleteQueueRequest, 

1335 *, 

1336 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1337 timeout: Optional[float] = None, 

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

1339 ): 

1340 r"""Call the delete queue method over HTTP. 

1341 

1342 Args: 

1343 request (~.cloudtasks.DeleteQueueRequest): 

1344 The request object. Request message for 

1345 [DeleteQueue][google.cloud.tasks.v2.CloudTasks.DeleteQueue]. 

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

1347 should be retried. 

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

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

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

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

1352 be of type `bytes`. 

1353 """ 

1354 

1355 http_options = ( 

1356 _BaseCloudTasksRestTransport._BaseDeleteQueue._get_http_options() 

1357 ) 

1358 

1359 request, metadata = self._interceptor.pre_delete_queue(request, metadata) 

1360 transcoded_request = ( 

1361 _BaseCloudTasksRestTransport._BaseDeleteQueue._get_transcoded_request( 

1362 http_options, request 

1363 ) 

1364 ) 

1365 

1366 # Jsonify the query params 

1367 query_params = ( 

1368 _BaseCloudTasksRestTransport._BaseDeleteQueue._get_query_params_json( 

1369 transcoded_request 

1370 ) 

1371 ) 

1372 

1373 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1374 logging.DEBUG 

1375 ): # pragma: NO COVER 

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

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

1378 ) 

1379 method = transcoded_request["method"] 

1380 try: 

1381 request_payload = json_format.MessageToJson(request) 

1382 except: 

1383 request_payload = None 

1384 http_request = { 

1385 "payload": request_payload, 

1386 "requestMethod": method, 

1387 "requestUrl": request_url, 

1388 "headers": dict(metadata), 

1389 } 

1390 _LOGGER.debug( 

1391 f"Sending request for google.cloud.tasks_v2.CloudTasksClient.DeleteQueue", 

1392 extra={ 

1393 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

1394 "rpcName": "DeleteQueue", 

1395 "httpRequest": http_request, 

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

1397 }, 

1398 ) 

1399 

1400 # Send the request 

1401 response = CloudTasksRestTransport._DeleteQueue._get_response( 

1402 self._host, 

1403 metadata, 

1404 query_params, 

1405 self._session, 

1406 timeout, 

1407 transcoded_request, 

1408 ) 

1409 

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

1411 # subclass. 

1412 if response.status_code >= 400: 

1413 raise core_exceptions.from_http_response(response) 

1414 

1415 class _DeleteTask(_BaseCloudTasksRestTransport._BaseDeleteTask, CloudTasksRestStub): 

1416 def __hash__(self): 

1417 return hash("CloudTasksRestTransport.DeleteTask") 

1418 

1419 @staticmethod 

1420 def _get_response( 

1421 host, 

1422 metadata, 

1423 query_params, 

1424 session, 

1425 timeout, 

1426 transcoded_request, 

1427 body=None, 

1428 ): 

1429 uri = transcoded_request["uri"] 

1430 method = transcoded_request["method"] 

1431 headers = dict(metadata) 

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

1433 response = getattr(session, method)( 

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

1435 timeout=timeout, 

1436 headers=headers, 

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

1438 ) 

1439 return response 

1440 

1441 def __call__( 

1442 self, 

1443 request: cloudtasks.DeleteTaskRequest, 

1444 *, 

1445 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1446 timeout: Optional[float] = None, 

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

1448 ): 

1449 r"""Call the delete task method over HTTP. 

1450 

1451 Args: 

1452 request (~.cloudtasks.DeleteTaskRequest): 

1453 The request object. Request message for deleting a task using 

1454 [DeleteTask][google.cloud.tasks.v2.CloudTasks.DeleteTask]. 

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

1456 should be retried. 

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

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

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

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

1461 be of type `bytes`. 

1462 """ 

1463 

1464 http_options = ( 

1465 _BaseCloudTasksRestTransport._BaseDeleteTask._get_http_options() 

1466 ) 

1467 

1468 request, metadata = self._interceptor.pre_delete_task(request, metadata) 

1469 transcoded_request = ( 

1470 _BaseCloudTasksRestTransport._BaseDeleteTask._get_transcoded_request( 

1471 http_options, request 

1472 ) 

1473 ) 

1474 

1475 # Jsonify the query params 

1476 query_params = ( 

1477 _BaseCloudTasksRestTransport._BaseDeleteTask._get_query_params_json( 

1478 transcoded_request 

1479 ) 

1480 ) 

1481 

1482 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1483 logging.DEBUG 

1484 ): # pragma: NO COVER 

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

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

1487 ) 

1488 method = transcoded_request["method"] 

1489 try: 

1490 request_payload = json_format.MessageToJson(request) 

1491 except: 

1492 request_payload = None 

1493 http_request = { 

1494 "payload": request_payload, 

1495 "requestMethod": method, 

1496 "requestUrl": request_url, 

1497 "headers": dict(metadata), 

1498 } 

1499 _LOGGER.debug( 

1500 f"Sending request for google.cloud.tasks_v2.CloudTasksClient.DeleteTask", 

1501 extra={ 

1502 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

1503 "rpcName": "DeleteTask", 

1504 "httpRequest": http_request, 

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

1506 }, 

1507 ) 

1508 

1509 # Send the request 

1510 response = CloudTasksRestTransport._DeleteTask._get_response( 

1511 self._host, 

1512 metadata, 

1513 query_params, 

1514 self._session, 

1515 timeout, 

1516 transcoded_request, 

1517 ) 

1518 

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

1520 # subclass. 

1521 if response.status_code >= 400: 

1522 raise core_exceptions.from_http_response(response) 

1523 

1524 class _GetIamPolicy( 

1525 _BaseCloudTasksRestTransport._BaseGetIamPolicy, CloudTasksRestStub 

1526 ): 

1527 def __hash__(self): 

1528 return hash("CloudTasksRestTransport.GetIamPolicy") 

1529 

1530 @staticmethod 

1531 def _get_response( 

1532 host, 

1533 metadata, 

1534 query_params, 

1535 session, 

1536 timeout, 

1537 transcoded_request, 

1538 body=None, 

1539 ): 

1540 uri = transcoded_request["uri"] 

1541 method = transcoded_request["method"] 

1542 headers = dict(metadata) 

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

1544 response = getattr(session, method)( 

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

1546 timeout=timeout, 

1547 headers=headers, 

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

1549 data=body, 

1550 ) 

1551 return response 

1552 

1553 def __call__( 

1554 self, 

1555 request: iam_policy_pb2.GetIamPolicyRequest, 

1556 *, 

1557 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1558 timeout: Optional[float] = None, 

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

1560 ) -> policy_pb2.Policy: 

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

1562 

1563 Args: 

1564 request (~.iam_policy_pb2.GetIamPolicyRequest): 

1565 The request object. Request message for ``GetIamPolicy`` method. 

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

1567 should be retried. 

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

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

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

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

1572 be of type `bytes`. 

1573 

1574 Returns: 

1575 ~.policy_pb2.Policy: 

1576 An Identity and Access Management (IAM) policy, which 

1577 specifies access controls for Google Cloud resources. 

1578 

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

1580 ``binding`` binds one or more ``members``, or 

1581 principals, to a single ``role``. Principals can be user 

1582 accounts, service accounts, Google groups, and domains 

1583 (such as G Suite). A ``role`` is a named list of 

1584 permissions; each ``role`` can be an IAM predefined role 

1585 or a user-created custom role. 

1586 

1587 For some types of Google Cloud resources, a ``binding`` 

1588 can also specify a ``condition``, which is a logical 

1589 expression that allows access to a resource only if the 

1590 expression evaluates to ``true``. A condition can add 

1591 constraints based on attributes of the request, the 

1592 resource, or both. To learn which resources support 

1593 conditions in their IAM policies, see the `IAM 

1594 documentation <https://cloud.google.com/iam/help/conditions/resource-policies>`__. 

1595 

1596 **JSON example:** 

1597 

1598 :: 

1599 

1600 { 

1601 "bindings": [ 

1602 { 

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

1604 "members": [ 

1605 "user:mike@example.com", 

1606 "group:admins@example.com", 

1607 "domain:google.com", 

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

1609 ] 

1610 }, 

1611 { 

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

1613 "members": [ 

1614 "user:eve@example.com" 

1615 ], 

1616 "condition": { 

1617 "title": "expirable access", 

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

1619 "expression": "request.time < 

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

1621 } 

1622 } 

1623 ], 

1624 "etag": "BwWWja0YfJA=", 

1625 "version": 3 

1626 } 

1627 

1628 **YAML example:** 

1629 

1630 :: 

1631 

1632 bindings: 

1633 - members: 

1634 - user:mike@example.com 

1635 - group:admins@example.com 

1636 - domain:google.com 

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

1638 role: roles/resourcemanager.organizationAdmin 

1639 - members: 

1640 - user:eve@example.com 

1641 role: roles/resourcemanager.organizationViewer 

1642 condition: 

1643 title: expirable access 

1644 description: Does not grant access after Sep 2020 

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

1646 etag: BwWWja0YfJA= 

1647 version: 3 

1648 

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

1650 documentation <https://cloud.google.com/iam/docs/>`__. 

1651 

1652 """ 

1653 

1654 http_options = ( 

1655 _BaseCloudTasksRestTransport._BaseGetIamPolicy._get_http_options() 

1656 ) 

1657 

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

1659 transcoded_request = ( 

1660 _BaseCloudTasksRestTransport._BaseGetIamPolicy._get_transcoded_request( 

1661 http_options, request 

1662 ) 

1663 ) 

1664 

1665 body = ( 

1666 _BaseCloudTasksRestTransport._BaseGetIamPolicy._get_request_body_json( 

1667 transcoded_request 

1668 ) 

1669 ) 

1670 

1671 # Jsonify the query params 

1672 query_params = ( 

1673 _BaseCloudTasksRestTransport._BaseGetIamPolicy._get_query_params_json( 

1674 transcoded_request 

1675 ) 

1676 ) 

1677 

1678 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1679 logging.DEBUG 

1680 ): # pragma: NO COVER 

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

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

1683 ) 

1684 method = transcoded_request["method"] 

1685 try: 

1686 request_payload = json_format.MessageToJson(request) 

1687 except: 

1688 request_payload = None 

1689 http_request = { 

1690 "payload": request_payload, 

1691 "requestMethod": method, 

1692 "requestUrl": request_url, 

1693 "headers": dict(metadata), 

1694 } 

1695 _LOGGER.debug( 

1696 f"Sending request for google.cloud.tasks_v2.CloudTasksClient.GetIamPolicy", 

1697 extra={ 

1698 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

1699 "rpcName": "GetIamPolicy", 

1700 "httpRequest": http_request, 

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

1702 }, 

1703 ) 

1704 

1705 # Send the request 

1706 response = CloudTasksRestTransport._GetIamPolicy._get_response( 

1707 self._host, 

1708 metadata, 

1709 query_params, 

1710 self._session, 

1711 timeout, 

1712 transcoded_request, 

1713 body, 

1714 ) 

1715 

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

1717 # subclass. 

1718 if response.status_code >= 400: 

1719 raise core_exceptions.from_http_response(response) 

1720 

1721 # Return the response 

1722 resp = policy_pb2.Policy() 

1723 pb_resp = resp 

1724 

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

1726 

1727 resp = self._interceptor.post_get_iam_policy(resp) 

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

1729 resp, _ = self._interceptor.post_get_iam_policy_with_metadata( 

1730 resp, response_metadata 

1731 ) 

1732 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1733 logging.DEBUG 

1734 ): # pragma: NO COVER 

1735 try: 

1736 response_payload = json_format.MessageToJson(resp) 

1737 except: 

1738 response_payload = None 

1739 http_response = { 

1740 "payload": response_payload, 

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

1742 "status": response.status_code, 

1743 } 

1744 _LOGGER.debug( 

1745 "Received response for google.cloud.tasks_v2.CloudTasksClient.get_iam_policy", 

1746 extra={ 

1747 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

1748 "rpcName": "GetIamPolicy", 

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

1750 "httpResponse": http_response, 

1751 }, 

1752 ) 

1753 return resp 

1754 

1755 class _GetQueue(_BaseCloudTasksRestTransport._BaseGetQueue, CloudTasksRestStub): 

1756 def __hash__(self): 

1757 return hash("CloudTasksRestTransport.GetQueue") 

1758 

1759 @staticmethod 

1760 def _get_response( 

1761 host, 

1762 metadata, 

1763 query_params, 

1764 session, 

1765 timeout, 

1766 transcoded_request, 

1767 body=None, 

1768 ): 

1769 uri = transcoded_request["uri"] 

1770 method = transcoded_request["method"] 

1771 headers = dict(metadata) 

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

1773 response = getattr(session, method)( 

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

1775 timeout=timeout, 

1776 headers=headers, 

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

1778 ) 

1779 return response 

1780 

1781 def __call__( 

1782 self, 

1783 request: cloudtasks.GetQueueRequest, 

1784 *, 

1785 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1786 timeout: Optional[float] = None, 

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

1788 ) -> queue.Queue: 

1789 r"""Call the get queue method over HTTP. 

1790 

1791 Args: 

1792 request (~.cloudtasks.GetQueueRequest): 

1793 The request object. Request message for 

1794 [GetQueue][google.cloud.tasks.v2.CloudTasks.GetQueue]. 

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

1796 should be retried. 

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

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

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

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

1801 be of type `bytes`. 

1802 

1803 Returns: 

1804 ~.queue.Queue: 

1805 A queue is a container of related 

1806 tasks. Queues are configured to manage 

1807 how those tasks are dispatched. 

1808 Configurable properties include rate 

1809 limits, retry options, queue types, and 

1810 others. 

1811 

1812 """ 

1813 

1814 http_options = ( 

1815 _BaseCloudTasksRestTransport._BaseGetQueue._get_http_options() 

1816 ) 

1817 

1818 request, metadata = self._interceptor.pre_get_queue(request, metadata) 

1819 transcoded_request = ( 

1820 _BaseCloudTasksRestTransport._BaseGetQueue._get_transcoded_request( 

1821 http_options, request 

1822 ) 

1823 ) 

1824 

1825 # Jsonify the query params 

1826 query_params = ( 

1827 _BaseCloudTasksRestTransport._BaseGetQueue._get_query_params_json( 

1828 transcoded_request 

1829 ) 

1830 ) 

1831 

1832 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1833 logging.DEBUG 

1834 ): # pragma: NO COVER 

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

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

1837 ) 

1838 method = transcoded_request["method"] 

1839 try: 

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

1841 except: 

1842 request_payload = None 

1843 http_request = { 

1844 "payload": request_payload, 

1845 "requestMethod": method, 

1846 "requestUrl": request_url, 

1847 "headers": dict(metadata), 

1848 } 

1849 _LOGGER.debug( 

1850 f"Sending request for google.cloud.tasks_v2.CloudTasksClient.GetQueue", 

1851 extra={ 

1852 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

1853 "rpcName": "GetQueue", 

1854 "httpRequest": http_request, 

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

1856 }, 

1857 ) 

1858 

1859 # Send the request 

1860 response = CloudTasksRestTransport._GetQueue._get_response( 

1861 self._host, 

1862 metadata, 

1863 query_params, 

1864 self._session, 

1865 timeout, 

1866 transcoded_request, 

1867 ) 

1868 

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

1870 # subclass. 

1871 if response.status_code >= 400: 

1872 raise core_exceptions.from_http_response(response) 

1873 

1874 # Return the response 

1875 resp = queue.Queue() 

1876 pb_resp = queue.Queue.pb(resp) 

1877 

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

1879 

1880 resp = self._interceptor.post_get_queue(resp) 

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

1882 resp, _ = self._interceptor.post_get_queue_with_metadata( 

1883 resp, response_metadata 

1884 ) 

1885 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1886 logging.DEBUG 

1887 ): # pragma: NO COVER 

1888 try: 

1889 response_payload = queue.Queue.to_json(response) 

1890 except: 

1891 response_payload = None 

1892 http_response = { 

1893 "payload": response_payload, 

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

1895 "status": response.status_code, 

1896 } 

1897 _LOGGER.debug( 

1898 "Received response for google.cloud.tasks_v2.CloudTasksClient.get_queue", 

1899 extra={ 

1900 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

1901 "rpcName": "GetQueue", 

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

1903 "httpResponse": http_response, 

1904 }, 

1905 ) 

1906 return resp 

1907 

1908 class _GetTask(_BaseCloudTasksRestTransport._BaseGetTask, CloudTasksRestStub): 

1909 def __hash__(self): 

1910 return hash("CloudTasksRestTransport.GetTask") 

1911 

1912 @staticmethod 

1913 def _get_response( 

1914 host, 

1915 metadata, 

1916 query_params, 

1917 session, 

1918 timeout, 

1919 transcoded_request, 

1920 body=None, 

1921 ): 

1922 uri = transcoded_request["uri"] 

1923 method = transcoded_request["method"] 

1924 headers = dict(metadata) 

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

1926 response = getattr(session, method)( 

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

1928 timeout=timeout, 

1929 headers=headers, 

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

1931 ) 

1932 return response 

1933 

1934 def __call__( 

1935 self, 

1936 request: cloudtasks.GetTaskRequest, 

1937 *, 

1938 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

1939 timeout: Optional[float] = None, 

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

1941 ) -> task.Task: 

1942 r"""Call the get task method over HTTP. 

1943 

1944 Args: 

1945 request (~.cloudtasks.GetTaskRequest): 

1946 The request object. Request message for getting a task using 

1947 [GetTask][google.cloud.tasks.v2.CloudTasks.GetTask]. 

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

1949 should be retried. 

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

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

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

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

1954 be of type `bytes`. 

1955 

1956 Returns: 

1957 ~.task.Task: 

1958 A unit of scheduled work. 

1959 """ 

1960 

1961 http_options = _BaseCloudTasksRestTransport._BaseGetTask._get_http_options() 

1962 

1963 request, metadata = self._interceptor.pre_get_task(request, metadata) 

1964 transcoded_request = ( 

1965 _BaseCloudTasksRestTransport._BaseGetTask._get_transcoded_request( 

1966 http_options, request 

1967 ) 

1968 ) 

1969 

1970 # Jsonify the query params 

1971 query_params = ( 

1972 _BaseCloudTasksRestTransport._BaseGetTask._get_query_params_json( 

1973 transcoded_request 

1974 ) 

1975 ) 

1976 

1977 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

1978 logging.DEBUG 

1979 ): # pragma: NO COVER 

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

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

1982 ) 

1983 method = transcoded_request["method"] 

1984 try: 

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

1986 except: 

1987 request_payload = None 

1988 http_request = { 

1989 "payload": request_payload, 

1990 "requestMethod": method, 

1991 "requestUrl": request_url, 

1992 "headers": dict(metadata), 

1993 } 

1994 _LOGGER.debug( 

1995 f"Sending request for google.cloud.tasks_v2.CloudTasksClient.GetTask", 

1996 extra={ 

1997 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

1998 "rpcName": "GetTask", 

1999 "httpRequest": http_request, 

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

2001 }, 

2002 ) 

2003 

2004 # Send the request 

2005 response = CloudTasksRestTransport._GetTask._get_response( 

2006 self._host, 

2007 metadata, 

2008 query_params, 

2009 self._session, 

2010 timeout, 

2011 transcoded_request, 

2012 ) 

2013 

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

2015 # subclass. 

2016 if response.status_code >= 400: 

2017 raise core_exceptions.from_http_response(response) 

2018 

2019 # Return the response 

2020 resp = task.Task() 

2021 pb_resp = task.Task.pb(resp) 

2022 

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

2024 

2025 resp = self._interceptor.post_get_task(resp) 

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

2027 resp, _ = self._interceptor.post_get_task_with_metadata( 

2028 resp, response_metadata 

2029 ) 

2030 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

2031 logging.DEBUG 

2032 ): # pragma: NO COVER 

2033 try: 

2034 response_payload = task.Task.to_json(response) 

2035 except: 

2036 response_payload = None 

2037 http_response = { 

2038 "payload": response_payload, 

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

2040 "status": response.status_code, 

2041 } 

2042 _LOGGER.debug( 

2043 "Received response for google.cloud.tasks_v2.CloudTasksClient.get_task", 

2044 extra={ 

2045 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

2046 "rpcName": "GetTask", 

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

2048 "httpResponse": http_response, 

2049 }, 

2050 ) 

2051 return resp 

2052 

2053 class _ListQueues(_BaseCloudTasksRestTransport._BaseListQueues, CloudTasksRestStub): 

2054 def __hash__(self): 

2055 return hash("CloudTasksRestTransport.ListQueues") 

2056 

2057 @staticmethod 

2058 def _get_response( 

2059 host, 

2060 metadata, 

2061 query_params, 

2062 session, 

2063 timeout, 

2064 transcoded_request, 

2065 body=None, 

2066 ): 

2067 uri = transcoded_request["uri"] 

2068 method = transcoded_request["method"] 

2069 headers = dict(metadata) 

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

2071 response = getattr(session, method)( 

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

2073 timeout=timeout, 

2074 headers=headers, 

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

2076 ) 

2077 return response 

2078 

2079 def __call__( 

2080 self, 

2081 request: cloudtasks.ListQueuesRequest, 

2082 *, 

2083 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

2084 timeout: Optional[float] = None, 

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

2086 ) -> cloudtasks.ListQueuesResponse: 

2087 r"""Call the list queues method over HTTP. 

2088 

2089 Args: 

2090 request (~.cloudtasks.ListQueuesRequest): 

2091 The request object. Request message for 

2092 [ListQueues][google.cloud.tasks.v2.CloudTasks.ListQueues]. 

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

2094 should be retried. 

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

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

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

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

2099 be of type `bytes`. 

2100 

2101 Returns: 

2102 ~.cloudtasks.ListQueuesResponse: 

2103 Response message for 

2104 [ListQueues][google.cloud.tasks.v2.CloudTasks.ListQueues]. 

2105 

2106 """ 

2107 

2108 http_options = ( 

2109 _BaseCloudTasksRestTransport._BaseListQueues._get_http_options() 

2110 ) 

2111 

2112 request, metadata = self._interceptor.pre_list_queues(request, metadata) 

2113 transcoded_request = ( 

2114 _BaseCloudTasksRestTransport._BaseListQueues._get_transcoded_request( 

2115 http_options, request 

2116 ) 

2117 ) 

2118 

2119 # Jsonify the query params 

2120 query_params = ( 

2121 _BaseCloudTasksRestTransport._BaseListQueues._get_query_params_json( 

2122 transcoded_request 

2123 ) 

2124 ) 

2125 

2126 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

2127 logging.DEBUG 

2128 ): # pragma: NO COVER 

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

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

2131 ) 

2132 method = transcoded_request["method"] 

2133 try: 

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

2135 except: 

2136 request_payload = None 

2137 http_request = { 

2138 "payload": request_payload, 

2139 "requestMethod": method, 

2140 "requestUrl": request_url, 

2141 "headers": dict(metadata), 

2142 } 

2143 _LOGGER.debug( 

2144 f"Sending request for google.cloud.tasks_v2.CloudTasksClient.ListQueues", 

2145 extra={ 

2146 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

2147 "rpcName": "ListQueues", 

2148 "httpRequest": http_request, 

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

2150 }, 

2151 ) 

2152 

2153 # Send the request 

2154 response = CloudTasksRestTransport._ListQueues._get_response( 

2155 self._host, 

2156 metadata, 

2157 query_params, 

2158 self._session, 

2159 timeout, 

2160 transcoded_request, 

2161 ) 

2162 

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

2164 # subclass. 

2165 if response.status_code >= 400: 

2166 raise core_exceptions.from_http_response(response) 

2167 

2168 # Return the response 

2169 resp = cloudtasks.ListQueuesResponse() 

2170 pb_resp = cloudtasks.ListQueuesResponse.pb(resp) 

2171 

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

2173 

2174 resp = self._interceptor.post_list_queues(resp) 

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

2176 resp, _ = self._interceptor.post_list_queues_with_metadata( 

2177 resp, response_metadata 

2178 ) 

2179 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

2180 logging.DEBUG 

2181 ): # pragma: NO COVER 

2182 try: 

2183 response_payload = cloudtasks.ListQueuesResponse.to_json(response) 

2184 except: 

2185 response_payload = None 

2186 http_response = { 

2187 "payload": response_payload, 

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

2189 "status": response.status_code, 

2190 } 

2191 _LOGGER.debug( 

2192 "Received response for google.cloud.tasks_v2.CloudTasksClient.list_queues", 

2193 extra={ 

2194 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

2195 "rpcName": "ListQueues", 

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

2197 "httpResponse": http_response, 

2198 }, 

2199 ) 

2200 return resp 

2201 

2202 class _ListTasks(_BaseCloudTasksRestTransport._BaseListTasks, CloudTasksRestStub): 

2203 def __hash__(self): 

2204 return hash("CloudTasksRestTransport.ListTasks") 

2205 

2206 @staticmethod 

2207 def _get_response( 

2208 host, 

2209 metadata, 

2210 query_params, 

2211 session, 

2212 timeout, 

2213 transcoded_request, 

2214 body=None, 

2215 ): 

2216 uri = transcoded_request["uri"] 

2217 method = transcoded_request["method"] 

2218 headers = dict(metadata) 

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

2220 response = getattr(session, method)( 

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

2222 timeout=timeout, 

2223 headers=headers, 

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

2225 ) 

2226 return response 

2227 

2228 def __call__( 

2229 self, 

2230 request: cloudtasks.ListTasksRequest, 

2231 *, 

2232 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

2233 timeout: Optional[float] = None, 

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

2235 ) -> cloudtasks.ListTasksResponse: 

2236 r"""Call the list tasks method over HTTP. 

2237 

2238 Args: 

2239 request (~.cloudtasks.ListTasksRequest): 

2240 The request object. Request message for listing tasks using 

2241 [ListTasks][google.cloud.tasks.v2.CloudTasks.ListTasks]. 

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

2243 should be retried. 

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

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

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

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

2248 be of type `bytes`. 

2249 

2250 Returns: 

2251 ~.cloudtasks.ListTasksResponse: 

2252 Response message for listing tasks using 

2253 [ListTasks][google.cloud.tasks.v2.CloudTasks.ListTasks]. 

2254 

2255 """ 

2256 

2257 http_options = ( 

2258 _BaseCloudTasksRestTransport._BaseListTasks._get_http_options() 

2259 ) 

2260 

2261 request, metadata = self._interceptor.pre_list_tasks(request, metadata) 

2262 transcoded_request = ( 

2263 _BaseCloudTasksRestTransport._BaseListTasks._get_transcoded_request( 

2264 http_options, request 

2265 ) 

2266 ) 

2267 

2268 # Jsonify the query params 

2269 query_params = ( 

2270 _BaseCloudTasksRestTransport._BaseListTasks._get_query_params_json( 

2271 transcoded_request 

2272 ) 

2273 ) 

2274 

2275 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

2276 logging.DEBUG 

2277 ): # pragma: NO COVER 

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

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

2280 ) 

2281 method = transcoded_request["method"] 

2282 try: 

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

2284 except: 

2285 request_payload = None 

2286 http_request = { 

2287 "payload": request_payload, 

2288 "requestMethod": method, 

2289 "requestUrl": request_url, 

2290 "headers": dict(metadata), 

2291 } 

2292 _LOGGER.debug( 

2293 f"Sending request for google.cloud.tasks_v2.CloudTasksClient.ListTasks", 

2294 extra={ 

2295 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

2296 "rpcName": "ListTasks", 

2297 "httpRequest": http_request, 

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

2299 }, 

2300 ) 

2301 

2302 # Send the request 

2303 response = CloudTasksRestTransport._ListTasks._get_response( 

2304 self._host, 

2305 metadata, 

2306 query_params, 

2307 self._session, 

2308 timeout, 

2309 transcoded_request, 

2310 ) 

2311 

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

2313 # subclass. 

2314 if response.status_code >= 400: 

2315 raise core_exceptions.from_http_response(response) 

2316 

2317 # Return the response 

2318 resp = cloudtasks.ListTasksResponse() 

2319 pb_resp = cloudtasks.ListTasksResponse.pb(resp) 

2320 

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

2322 

2323 resp = self._interceptor.post_list_tasks(resp) 

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

2325 resp, _ = self._interceptor.post_list_tasks_with_metadata( 

2326 resp, response_metadata 

2327 ) 

2328 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

2329 logging.DEBUG 

2330 ): # pragma: NO COVER 

2331 try: 

2332 response_payload = cloudtasks.ListTasksResponse.to_json(response) 

2333 except: 

2334 response_payload = None 

2335 http_response = { 

2336 "payload": response_payload, 

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

2338 "status": response.status_code, 

2339 } 

2340 _LOGGER.debug( 

2341 "Received response for google.cloud.tasks_v2.CloudTasksClient.list_tasks", 

2342 extra={ 

2343 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

2344 "rpcName": "ListTasks", 

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

2346 "httpResponse": http_response, 

2347 }, 

2348 ) 

2349 return resp 

2350 

2351 class _PauseQueue(_BaseCloudTasksRestTransport._BasePauseQueue, CloudTasksRestStub): 

2352 def __hash__(self): 

2353 return hash("CloudTasksRestTransport.PauseQueue") 

2354 

2355 @staticmethod 

2356 def _get_response( 

2357 host, 

2358 metadata, 

2359 query_params, 

2360 session, 

2361 timeout, 

2362 transcoded_request, 

2363 body=None, 

2364 ): 

2365 uri = transcoded_request["uri"] 

2366 method = transcoded_request["method"] 

2367 headers = dict(metadata) 

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

2369 response = getattr(session, method)( 

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

2371 timeout=timeout, 

2372 headers=headers, 

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

2374 data=body, 

2375 ) 

2376 return response 

2377 

2378 def __call__( 

2379 self, 

2380 request: cloudtasks.PauseQueueRequest, 

2381 *, 

2382 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

2383 timeout: Optional[float] = None, 

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

2385 ) -> queue.Queue: 

2386 r"""Call the pause queue method over HTTP. 

2387 

2388 Args: 

2389 request (~.cloudtasks.PauseQueueRequest): 

2390 The request object. Request message for 

2391 [PauseQueue][google.cloud.tasks.v2.CloudTasks.PauseQueue]. 

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

2393 should be retried. 

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

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

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

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

2398 be of type `bytes`. 

2399 

2400 Returns: 

2401 ~.queue.Queue: 

2402 A queue is a container of related 

2403 tasks. Queues are configured to manage 

2404 how those tasks are dispatched. 

2405 Configurable properties include rate 

2406 limits, retry options, queue types, and 

2407 others. 

2408 

2409 """ 

2410 

2411 http_options = ( 

2412 _BaseCloudTasksRestTransport._BasePauseQueue._get_http_options() 

2413 ) 

2414 

2415 request, metadata = self._interceptor.pre_pause_queue(request, metadata) 

2416 transcoded_request = ( 

2417 _BaseCloudTasksRestTransport._BasePauseQueue._get_transcoded_request( 

2418 http_options, request 

2419 ) 

2420 ) 

2421 

2422 body = _BaseCloudTasksRestTransport._BasePauseQueue._get_request_body_json( 

2423 transcoded_request 

2424 ) 

2425 

2426 # Jsonify the query params 

2427 query_params = ( 

2428 _BaseCloudTasksRestTransport._BasePauseQueue._get_query_params_json( 

2429 transcoded_request 

2430 ) 

2431 ) 

2432 

2433 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

2434 logging.DEBUG 

2435 ): # pragma: NO COVER 

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

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

2438 ) 

2439 method = transcoded_request["method"] 

2440 try: 

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

2442 except: 

2443 request_payload = None 

2444 http_request = { 

2445 "payload": request_payload, 

2446 "requestMethod": method, 

2447 "requestUrl": request_url, 

2448 "headers": dict(metadata), 

2449 } 

2450 _LOGGER.debug( 

2451 f"Sending request for google.cloud.tasks_v2.CloudTasksClient.PauseQueue", 

2452 extra={ 

2453 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

2454 "rpcName": "PauseQueue", 

2455 "httpRequest": http_request, 

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

2457 }, 

2458 ) 

2459 

2460 # Send the request 

2461 response = CloudTasksRestTransport._PauseQueue._get_response( 

2462 self._host, 

2463 metadata, 

2464 query_params, 

2465 self._session, 

2466 timeout, 

2467 transcoded_request, 

2468 body, 

2469 ) 

2470 

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

2472 # subclass. 

2473 if response.status_code >= 400: 

2474 raise core_exceptions.from_http_response(response) 

2475 

2476 # Return the response 

2477 resp = queue.Queue() 

2478 pb_resp = queue.Queue.pb(resp) 

2479 

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

2481 

2482 resp = self._interceptor.post_pause_queue(resp) 

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

2484 resp, _ = self._interceptor.post_pause_queue_with_metadata( 

2485 resp, response_metadata 

2486 ) 

2487 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

2488 logging.DEBUG 

2489 ): # pragma: NO COVER 

2490 try: 

2491 response_payload = queue.Queue.to_json(response) 

2492 except: 

2493 response_payload = None 

2494 http_response = { 

2495 "payload": response_payload, 

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

2497 "status": response.status_code, 

2498 } 

2499 _LOGGER.debug( 

2500 "Received response for google.cloud.tasks_v2.CloudTasksClient.pause_queue", 

2501 extra={ 

2502 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

2503 "rpcName": "PauseQueue", 

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

2505 "httpResponse": http_response, 

2506 }, 

2507 ) 

2508 return resp 

2509 

2510 class _PurgeQueue(_BaseCloudTasksRestTransport._BasePurgeQueue, CloudTasksRestStub): 

2511 def __hash__(self): 

2512 return hash("CloudTasksRestTransport.PurgeQueue") 

2513 

2514 @staticmethod 

2515 def _get_response( 

2516 host, 

2517 metadata, 

2518 query_params, 

2519 session, 

2520 timeout, 

2521 transcoded_request, 

2522 body=None, 

2523 ): 

2524 uri = transcoded_request["uri"] 

2525 method = transcoded_request["method"] 

2526 headers = dict(metadata) 

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

2528 response = getattr(session, method)( 

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

2530 timeout=timeout, 

2531 headers=headers, 

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

2533 data=body, 

2534 ) 

2535 return response 

2536 

2537 def __call__( 

2538 self, 

2539 request: cloudtasks.PurgeQueueRequest, 

2540 *, 

2541 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

2542 timeout: Optional[float] = None, 

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

2544 ) -> queue.Queue: 

2545 r"""Call the purge queue method over HTTP. 

2546 

2547 Args: 

2548 request (~.cloudtasks.PurgeQueueRequest): 

2549 The request object. Request message for 

2550 [PurgeQueue][google.cloud.tasks.v2.CloudTasks.PurgeQueue]. 

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

2552 should be retried. 

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

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

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

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

2557 be of type `bytes`. 

2558 

2559 Returns: 

2560 ~.queue.Queue: 

2561 A queue is a container of related 

2562 tasks. Queues are configured to manage 

2563 how those tasks are dispatched. 

2564 Configurable properties include rate 

2565 limits, retry options, queue types, and 

2566 others. 

2567 

2568 """ 

2569 

2570 http_options = ( 

2571 _BaseCloudTasksRestTransport._BasePurgeQueue._get_http_options() 

2572 ) 

2573 

2574 request, metadata = self._interceptor.pre_purge_queue(request, metadata) 

2575 transcoded_request = ( 

2576 _BaseCloudTasksRestTransport._BasePurgeQueue._get_transcoded_request( 

2577 http_options, request 

2578 ) 

2579 ) 

2580 

2581 body = _BaseCloudTasksRestTransport._BasePurgeQueue._get_request_body_json( 

2582 transcoded_request 

2583 ) 

2584 

2585 # Jsonify the query params 

2586 query_params = ( 

2587 _BaseCloudTasksRestTransport._BasePurgeQueue._get_query_params_json( 

2588 transcoded_request 

2589 ) 

2590 ) 

2591 

2592 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

2593 logging.DEBUG 

2594 ): # pragma: NO COVER 

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

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

2597 ) 

2598 method = transcoded_request["method"] 

2599 try: 

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

2601 except: 

2602 request_payload = None 

2603 http_request = { 

2604 "payload": request_payload, 

2605 "requestMethod": method, 

2606 "requestUrl": request_url, 

2607 "headers": dict(metadata), 

2608 } 

2609 _LOGGER.debug( 

2610 f"Sending request for google.cloud.tasks_v2.CloudTasksClient.PurgeQueue", 

2611 extra={ 

2612 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

2613 "rpcName": "PurgeQueue", 

2614 "httpRequest": http_request, 

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

2616 }, 

2617 ) 

2618 

2619 # Send the request 

2620 response = CloudTasksRestTransport._PurgeQueue._get_response( 

2621 self._host, 

2622 metadata, 

2623 query_params, 

2624 self._session, 

2625 timeout, 

2626 transcoded_request, 

2627 body, 

2628 ) 

2629 

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

2631 # subclass. 

2632 if response.status_code >= 400: 

2633 raise core_exceptions.from_http_response(response) 

2634 

2635 # Return the response 

2636 resp = queue.Queue() 

2637 pb_resp = queue.Queue.pb(resp) 

2638 

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

2640 

2641 resp = self._interceptor.post_purge_queue(resp) 

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

2643 resp, _ = self._interceptor.post_purge_queue_with_metadata( 

2644 resp, response_metadata 

2645 ) 

2646 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

2647 logging.DEBUG 

2648 ): # pragma: NO COVER 

2649 try: 

2650 response_payload = queue.Queue.to_json(response) 

2651 except: 

2652 response_payload = None 

2653 http_response = { 

2654 "payload": response_payload, 

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

2656 "status": response.status_code, 

2657 } 

2658 _LOGGER.debug( 

2659 "Received response for google.cloud.tasks_v2.CloudTasksClient.purge_queue", 

2660 extra={ 

2661 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

2662 "rpcName": "PurgeQueue", 

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

2664 "httpResponse": http_response, 

2665 }, 

2666 ) 

2667 return resp 

2668 

2669 class _ResumeQueue( 

2670 _BaseCloudTasksRestTransport._BaseResumeQueue, CloudTasksRestStub 

2671 ): 

2672 def __hash__(self): 

2673 return hash("CloudTasksRestTransport.ResumeQueue") 

2674 

2675 @staticmethod 

2676 def _get_response( 

2677 host, 

2678 metadata, 

2679 query_params, 

2680 session, 

2681 timeout, 

2682 transcoded_request, 

2683 body=None, 

2684 ): 

2685 uri = transcoded_request["uri"] 

2686 method = transcoded_request["method"] 

2687 headers = dict(metadata) 

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

2689 response = getattr(session, method)( 

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

2691 timeout=timeout, 

2692 headers=headers, 

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

2694 data=body, 

2695 ) 

2696 return response 

2697 

2698 def __call__( 

2699 self, 

2700 request: cloudtasks.ResumeQueueRequest, 

2701 *, 

2702 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

2703 timeout: Optional[float] = None, 

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

2705 ) -> queue.Queue: 

2706 r"""Call the resume queue method over HTTP. 

2707 

2708 Args: 

2709 request (~.cloudtasks.ResumeQueueRequest): 

2710 The request object. Request message for 

2711 [ResumeQueue][google.cloud.tasks.v2.CloudTasks.ResumeQueue]. 

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

2713 should be retried. 

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

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

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

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

2718 be of type `bytes`. 

2719 

2720 Returns: 

2721 ~.queue.Queue: 

2722 A queue is a container of related 

2723 tasks. Queues are configured to manage 

2724 how those tasks are dispatched. 

2725 Configurable properties include rate 

2726 limits, retry options, queue types, and 

2727 others. 

2728 

2729 """ 

2730 

2731 http_options = ( 

2732 _BaseCloudTasksRestTransport._BaseResumeQueue._get_http_options() 

2733 ) 

2734 

2735 request, metadata = self._interceptor.pre_resume_queue(request, metadata) 

2736 transcoded_request = ( 

2737 _BaseCloudTasksRestTransport._BaseResumeQueue._get_transcoded_request( 

2738 http_options, request 

2739 ) 

2740 ) 

2741 

2742 body = _BaseCloudTasksRestTransport._BaseResumeQueue._get_request_body_json( 

2743 transcoded_request 

2744 ) 

2745 

2746 # Jsonify the query params 

2747 query_params = ( 

2748 _BaseCloudTasksRestTransport._BaseResumeQueue._get_query_params_json( 

2749 transcoded_request 

2750 ) 

2751 ) 

2752 

2753 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

2754 logging.DEBUG 

2755 ): # pragma: NO COVER 

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

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

2758 ) 

2759 method = transcoded_request["method"] 

2760 try: 

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

2762 except: 

2763 request_payload = None 

2764 http_request = { 

2765 "payload": request_payload, 

2766 "requestMethod": method, 

2767 "requestUrl": request_url, 

2768 "headers": dict(metadata), 

2769 } 

2770 _LOGGER.debug( 

2771 f"Sending request for google.cloud.tasks_v2.CloudTasksClient.ResumeQueue", 

2772 extra={ 

2773 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

2774 "rpcName": "ResumeQueue", 

2775 "httpRequest": http_request, 

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

2777 }, 

2778 ) 

2779 

2780 # Send the request 

2781 response = CloudTasksRestTransport._ResumeQueue._get_response( 

2782 self._host, 

2783 metadata, 

2784 query_params, 

2785 self._session, 

2786 timeout, 

2787 transcoded_request, 

2788 body, 

2789 ) 

2790 

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

2792 # subclass. 

2793 if response.status_code >= 400: 

2794 raise core_exceptions.from_http_response(response) 

2795 

2796 # Return the response 

2797 resp = queue.Queue() 

2798 pb_resp = queue.Queue.pb(resp) 

2799 

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

2801 

2802 resp = self._interceptor.post_resume_queue(resp) 

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

2804 resp, _ = self._interceptor.post_resume_queue_with_metadata( 

2805 resp, response_metadata 

2806 ) 

2807 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

2808 logging.DEBUG 

2809 ): # pragma: NO COVER 

2810 try: 

2811 response_payload = queue.Queue.to_json(response) 

2812 except: 

2813 response_payload = None 

2814 http_response = { 

2815 "payload": response_payload, 

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

2817 "status": response.status_code, 

2818 } 

2819 _LOGGER.debug( 

2820 "Received response for google.cloud.tasks_v2.CloudTasksClient.resume_queue", 

2821 extra={ 

2822 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

2823 "rpcName": "ResumeQueue", 

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

2825 "httpResponse": http_response, 

2826 }, 

2827 ) 

2828 return resp 

2829 

2830 class _RunTask(_BaseCloudTasksRestTransport._BaseRunTask, CloudTasksRestStub): 

2831 def __hash__(self): 

2832 return hash("CloudTasksRestTransport.RunTask") 

2833 

2834 @staticmethod 

2835 def _get_response( 

2836 host, 

2837 metadata, 

2838 query_params, 

2839 session, 

2840 timeout, 

2841 transcoded_request, 

2842 body=None, 

2843 ): 

2844 uri = transcoded_request["uri"] 

2845 method = transcoded_request["method"] 

2846 headers = dict(metadata) 

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

2848 response = getattr(session, method)( 

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

2850 timeout=timeout, 

2851 headers=headers, 

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

2853 data=body, 

2854 ) 

2855 return response 

2856 

2857 def __call__( 

2858 self, 

2859 request: cloudtasks.RunTaskRequest, 

2860 *, 

2861 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

2862 timeout: Optional[float] = None, 

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

2864 ) -> task.Task: 

2865 r"""Call the run task method over HTTP. 

2866 

2867 Args: 

2868 request (~.cloudtasks.RunTaskRequest): 

2869 The request object. Request message for forcing a task to run now using 

2870 [RunTask][google.cloud.tasks.v2.CloudTasks.RunTask]. 

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

2872 should be retried. 

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

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

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

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

2877 be of type `bytes`. 

2878 

2879 Returns: 

2880 ~.task.Task: 

2881 A unit of scheduled work. 

2882 """ 

2883 

2884 http_options = _BaseCloudTasksRestTransport._BaseRunTask._get_http_options() 

2885 

2886 request, metadata = self._interceptor.pre_run_task(request, metadata) 

2887 transcoded_request = ( 

2888 _BaseCloudTasksRestTransport._BaseRunTask._get_transcoded_request( 

2889 http_options, request 

2890 ) 

2891 ) 

2892 

2893 body = _BaseCloudTasksRestTransport._BaseRunTask._get_request_body_json( 

2894 transcoded_request 

2895 ) 

2896 

2897 # Jsonify the query params 

2898 query_params = ( 

2899 _BaseCloudTasksRestTransport._BaseRunTask._get_query_params_json( 

2900 transcoded_request 

2901 ) 

2902 ) 

2903 

2904 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

2905 logging.DEBUG 

2906 ): # pragma: NO COVER 

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

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

2909 ) 

2910 method = transcoded_request["method"] 

2911 try: 

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

2913 except: 

2914 request_payload = None 

2915 http_request = { 

2916 "payload": request_payload, 

2917 "requestMethod": method, 

2918 "requestUrl": request_url, 

2919 "headers": dict(metadata), 

2920 } 

2921 _LOGGER.debug( 

2922 f"Sending request for google.cloud.tasks_v2.CloudTasksClient.RunTask", 

2923 extra={ 

2924 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

2925 "rpcName": "RunTask", 

2926 "httpRequest": http_request, 

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

2928 }, 

2929 ) 

2930 

2931 # Send the request 

2932 response = CloudTasksRestTransport._RunTask._get_response( 

2933 self._host, 

2934 metadata, 

2935 query_params, 

2936 self._session, 

2937 timeout, 

2938 transcoded_request, 

2939 body, 

2940 ) 

2941 

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

2943 # subclass. 

2944 if response.status_code >= 400: 

2945 raise core_exceptions.from_http_response(response) 

2946 

2947 # Return the response 

2948 resp = task.Task() 

2949 pb_resp = task.Task.pb(resp) 

2950 

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

2952 

2953 resp = self._interceptor.post_run_task(resp) 

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

2955 resp, _ = self._interceptor.post_run_task_with_metadata( 

2956 resp, response_metadata 

2957 ) 

2958 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

2959 logging.DEBUG 

2960 ): # pragma: NO COVER 

2961 try: 

2962 response_payload = task.Task.to_json(response) 

2963 except: 

2964 response_payload = None 

2965 http_response = { 

2966 "payload": response_payload, 

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

2968 "status": response.status_code, 

2969 } 

2970 _LOGGER.debug( 

2971 "Received response for google.cloud.tasks_v2.CloudTasksClient.run_task", 

2972 extra={ 

2973 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

2974 "rpcName": "RunTask", 

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

2976 "httpResponse": http_response, 

2977 }, 

2978 ) 

2979 return resp 

2980 

2981 class _SetIamPolicy( 

2982 _BaseCloudTasksRestTransport._BaseSetIamPolicy, CloudTasksRestStub 

2983 ): 

2984 def __hash__(self): 

2985 return hash("CloudTasksRestTransport.SetIamPolicy") 

2986 

2987 @staticmethod 

2988 def _get_response( 

2989 host, 

2990 metadata, 

2991 query_params, 

2992 session, 

2993 timeout, 

2994 transcoded_request, 

2995 body=None, 

2996 ): 

2997 uri = transcoded_request["uri"] 

2998 method = transcoded_request["method"] 

2999 headers = dict(metadata) 

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

3001 response = getattr(session, method)( 

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

3003 timeout=timeout, 

3004 headers=headers, 

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

3006 data=body, 

3007 ) 

3008 return response 

3009 

3010 def __call__( 

3011 self, 

3012 request: iam_policy_pb2.SetIamPolicyRequest, 

3013 *, 

3014 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3015 timeout: Optional[float] = None, 

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

3017 ) -> policy_pb2.Policy: 

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

3019 

3020 Args: 

3021 request (~.iam_policy_pb2.SetIamPolicyRequest): 

3022 The request object. Request message for ``SetIamPolicy`` method. 

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

3024 should be retried. 

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

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

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

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

3029 be of type `bytes`. 

3030 

3031 Returns: 

3032 ~.policy_pb2.Policy: 

3033 An Identity and Access Management (IAM) policy, which 

3034 specifies access controls for Google Cloud resources. 

3035 

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

3037 ``binding`` binds one or more ``members``, or 

3038 principals, to a single ``role``. Principals can be user 

3039 accounts, service accounts, Google groups, and domains 

3040 (such as G Suite). A ``role`` is a named list of 

3041 permissions; each ``role`` can be an IAM predefined role 

3042 or a user-created custom role. 

3043 

3044 For some types of Google Cloud resources, a ``binding`` 

3045 can also specify a ``condition``, which is a logical 

3046 expression that allows access to a resource only if the 

3047 expression evaluates to ``true``. A condition can add 

3048 constraints based on attributes of the request, the 

3049 resource, or both. To learn which resources support 

3050 conditions in their IAM policies, see the `IAM 

3051 documentation <https://cloud.google.com/iam/help/conditions/resource-policies>`__. 

3052 

3053 **JSON example:** 

3054 

3055 :: 

3056 

3057 { 

3058 "bindings": [ 

3059 { 

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

3061 "members": [ 

3062 "user:mike@example.com", 

3063 "group:admins@example.com", 

3064 "domain:google.com", 

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

3066 ] 

3067 }, 

3068 { 

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

3070 "members": [ 

3071 "user:eve@example.com" 

3072 ], 

3073 "condition": { 

3074 "title": "expirable access", 

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

3076 "expression": "request.time < 

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

3078 } 

3079 } 

3080 ], 

3081 "etag": "BwWWja0YfJA=", 

3082 "version": 3 

3083 } 

3084 

3085 **YAML example:** 

3086 

3087 :: 

3088 

3089 bindings: 

3090 - members: 

3091 - user:mike@example.com 

3092 - group:admins@example.com 

3093 - domain:google.com 

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

3095 role: roles/resourcemanager.organizationAdmin 

3096 - members: 

3097 - user:eve@example.com 

3098 role: roles/resourcemanager.organizationViewer 

3099 condition: 

3100 title: expirable access 

3101 description: Does not grant access after Sep 2020 

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

3103 etag: BwWWja0YfJA= 

3104 version: 3 

3105 

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

3107 documentation <https://cloud.google.com/iam/docs/>`__. 

3108 

3109 """ 

3110 

3111 http_options = ( 

3112 _BaseCloudTasksRestTransport._BaseSetIamPolicy._get_http_options() 

3113 ) 

3114 

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

3116 transcoded_request = ( 

3117 _BaseCloudTasksRestTransport._BaseSetIamPolicy._get_transcoded_request( 

3118 http_options, request 

3119 ) 

3120 ) 

3121 

3122 body = ( 

3123 _BaseCloudTasksRestTransport._BaseSetIamPolicy._get_request_body_json( 

3124 transcoded_request 

3125 ) 

3126 ) 

3127 

3128 # Jsonify the query params 

3129 query_params = ( 

3130 _BaseCloudTasksRestTransport._BaseSetIamPolicy._get_query_params_json( 

3131 transcoded_request 

3132 ) 

3133 ) 

3134 

3135 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

3136 logging.DEBUG 

3137 ): # pragma: NO COVER 

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

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

3140 ) 

3141 method = transcoded_request["method"] 

3142 try: 

3143 request_payload = json_format.MessageToJson(request) 

3144 except: 

3145 request_payload = None 

3146 http_request = { 

3147 "payload": request_payload, 

3148 "requestMethod": method, 

3149 "requestUrl": request_url, 

3150 "headers": dict(metadata), 

3151 } 

3152 _LOGGER.debug( 

3153 f"Sending request for google.cloud.tasks_v2.CloudTasksClient.SetIamPolicy", 

3154 extra={ 

3155 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

3156 "rpcName": "SetIamPolicy", 

3157 "httpRequest": http_request, 

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

3159 }, 

3160 ) 

3161 

3162 # Send the request 

3163 response = CloudTasksRestTransport._SetIamPolicy._get_response( 

3164 self._host, 

3165 metadata, 

3166 query_params, 

3167 self._session, 

3168 timeout, 

3169 transcoded_request, 

3170 body, 

3171 ) 

3172 

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

3174 # subclass. 

3175 if response.status_code >= 400: 

3176 raise core_exceptions.from_http_response(response) 

3177 

3178 # Return the response 

3179 resp = policy_pb2.Policy() 

3180 pb_resp = resp 

3181 

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

3183 

3184 resp = self._interceptor.post_set_iam_policy(resp) 

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

3186 resp, _ = self._interceptor.post_set_iam_policy_with_metadata( 

3187 resp, response_metadata 

3188 ) 

3189 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

3190 logging.DEBUG 

3191 ): # pragma: NO COVER 

3192 try: 

3193 response_payload = json_format.MessageToJson(resp) 

3194 except: 

3195 response_payload = None 

3196 http_response = { 

3197 "payload": response_payload, 

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

3199 "status": response.status_code, 

3200 } 

3201 _LOGGER.debug( 

3202 "Received response for google.cloud.tasks_v2.CloudTasksClient.set_iam_policy", 

3203 extra={ 

3204 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

3205 "rpcName": "SetIamPolicy", 

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

3207 "httpResponse": http_response, 

3208 }, 

3209 ) 

3210 return resp 

3211 

3212 class _TestIamPermissions( 

3213 _BaseCloudTasksRestTransport._BaseTestIamPermissions, CloudTasksRestStub 

3214 ): 

3215 def __hash__(self): 

3216 return hash("CloudTasksRestTransport.TestIamPermissions") 

3217 

3218 @staticmethod 

3219 def _get_response( 

3220 host, 

3221 metadata, 

3222 query_params, 

3223 session, 

3224 timeout, 

3225 transcoded_request, 

3226 body=None, 

3227 ): 

3228 uri = transcoded_request["uri"] 

3229 method = transcoded_request["method"] 

3230 headers = dict(metadata) 

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

3232 response = getattr(session, method)( 

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

3234 timeout=timeout, 

3235 headers=headers, 

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

3237 data=body, 

3238 ) 

3239 return response 

3240 

3241 def __call__( 

3242 self, 

3243 request: iam_policy_pb2.TestIamPermissionsRequest, 

3244 *, 

3245 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3246 timeout: Optional[float] = None, 

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

3248 ) -> iam_policy_pb2.TestIamPermissionsResponse: 

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

3250 

3251 Args: 

3252 request (~.iam_policy_pb2.TestIamPermissionsRequest): 

3253 The request object. Request message for ``TestIamPermissions`` method. 

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

3255 should be retried. 

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

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

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

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

3260 be of type `bytes`. 

3261 

3262 Returns: 

3263 ~.iam_policy_pb2.TestIamPermissionsResponse: 

3264 Response message for ``TestIamPermissions`` method. 

3265 """ 

3266 

3267 http_options = ( 

3268 _BaseCloudTasksRestTransport._BaseTestIamPermissions._get_http_options() 

3269 ) 

3270 

3271 request, metadata = self._interceptor.pre_test_iam_permissions( 

3272 request, metadata 

3273 ) 

3274 transcoded_request = _BaseCloudTasksRestTransport._BaseTestIamPermissions._get_transcoded_request( 

3275 http_options, request 

3276 ) 

3277 

3278 body = _BaseCloudTasksRestTransport._BaseTestIamPermissions._get_request_body_json( 

3279 transcoded_request 

3280 ) 

3281 

3282 # Jsonify the query params 

3283 query_params = _BaseCloudTasksRestTransport._BaseTestIamPermissions._get_query_params_json( 

3284 transcoded_request 

3285 ) 

3286 

3287 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

3288 logging.DEBUG 

3289 ): # pragma: NO COVER 

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

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

3292 ) 

3293 method = transcoded_request["method"] 

3294 try: 

3295 request_payload = json_format.MessageToJson(request) 

3296 except: 

3297 request_payload = None 

3298 http_request = { 

3299 "payload": request_payload, 

3300 "requestMethod": method, 

3301 "requestUrl": request_url, 

3302 "headers": dict(metadata), 

3303 } 

3304 _LOGGER.debug( 

3305 f"Sending request for google.cloud.tasks_v2.CloudTasksClient.TestIamPermissions", 

3306 extra={ 

3307 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

3308 "rpcName": "TestIamPermissions", 

3309 "httpRequest": http_request, 

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

3311 }, 

3312 ) 

3313 

3314 # Send the request 

3315 response = CloudTasksRestTransport._TestIamPermissions._get_response( 

3316 self._host, 

3317 metadata, 

3318 query_params, 

3319 self._session, 

3320 timeout, 

3321 transcoded_request, 

3322 body, 

3323 ) 

3324 

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

3326 # subclass. 

3327 if response.status_code >= 400: 

3328 raise core_exceptions.from_http_response(response) 

3329 

3330 # Return the response 

3331 resp = iam_policy_pb2.TestIamPermissionsResponse() 

3332 pb_resp = resp 

3333 

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

3335 

3336 resp = self._interceptor.post_test_iam_permissions(resp) 

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

3338 resp, _ = self._interceptor.post_test_iam_permissions_with_metadata( 

3339 resp, response_metadata 

3340 ) 

3341 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

3342 logging.DEBUG 

3343 ): # pragma: NO COVER 

3344 try: 

3345 response_payload = json_format.MessageToJson(resp) 

3346 except: 

3347 response_payload = None 

3348 http_response = { 

3349 "payload": response_payload, 

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

3351 "status": response.status_code, 

3352 } 

3353 _LOGGER.debug( 

3354 "Received response for google.cloud.tasks_v2.CloudTasksClient.test_iam_permissions", 

3355 extra={ 

3356 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

3357 "rpcName": "TestIamPermissions", 

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

3359 "httpResponse": http_response, 

3360 }, 

3361 ) 

3362 return resp 

3363 

3364 class _UpdateQueue( 

3365 _BaseCloudTasksRestTransport._BaseUpdateQueue, CloudTasksRestStub 

3366 ): 

3367 def __hash__(self): 

3368 return hash("CloudTasksRestTransport.UpdateQueue") 

3369 

3370 @staticmethod 

3371 def _get_response( 

3372 host, 

3373 metadata, 

3374 query_params, 

3375 session, 

3376 timeout, 

3377 transcoded_request, 

3378 body=None, 

3379 ): 

3380 uri = transcoded_request["uri"] 

3381 method = transcoded_request["method"] 

3382 headers = dict(metadata) 

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

3384 response = getattr(session, method)( 

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

3386 timeout=timeout, 

3387 headers=headers, 

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

3389 data=body, 

3390 ) 

3391 return response 

3392 

3393 def __call__( 

3394 self, 

3395 request: cloudtasks.UpdateQueueRequest, 

3396 *, 

3397 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3398 timeout: Optional[float] = None, 

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

3400 ) -> gct_queue.Queue: 

3401 r"""Call the update queue method over HTTP. 

3402 

3403 Args: 

3404 request (~.cloudtasks.UpdateQueueRequest): 

3405 The request object. Request message for 

3406 [UpdateQueue][google.cloud.tasks.v2.CloudTasks.UpdateQueue]. 

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

3408 should be retried. 

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

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

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

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

3413 be of type `bytes`. 

3414 

3415 Returns: 

3416 ~.gct_queue.Queue: 

3417 A queue is a container of related 

3418 tasks. Queues are configured to manage 

3419 how those tasks are dispatched. 

3420 Configurable properties include rate 

3421 limits, retry options, queue types, and 

3422 others. 

3423 

3424 """ 

3425 

3426 http_options = ( 

3427 _BaseCloudTasksRestTransport._BaseUpdateQueue._get_http_options() 

3428 ) 

3429 

3430 request, metadata = self._interceptor.pre_update_queue(request, metadata) 

3431 transcoded_request = ( 

3432 _BaseCloudTasksRestTransport._BaseUpdateQueue._get_transcoded_request( 

3433 http_options, request 

3434 ) 

3435 ) 

3436 

3437 body = _BaseCloudTasksRestTransport._BaseUpdateQueue._get_request_body_json( 

3438 transcoded_request 

3439 ) 

3440 

3441 # Jsonify the query params 

3442 query_params = ( 

3443 _BaseCloudTasksRestTransport._BaseUpdateQueue._get_query_params_json( 

3444 transcoded_request 

3445 ) 

3446 ) 

3447 

3448 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

3449 logging.DEBUG 

3450 ): # pragma: NO COVER 

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

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

3453 ) 

3454 method = transcoded_request["method"] 

3455 try: 

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

3457 except: 

3458 request_payload = None 

3459 http_request = { 

3460 "payload": request_payload, 

3461 "requestMethod": method, 

3462 "requestUrl": request_url, 

3463 "headers": dict(metadata), 

3464 } 

3465 _LOGGER.debug( 

3466 f"Sending request for google.cloud.tasks_v2.CloudTasksClient.UpdateQueue", 

3467 extra={ 

3468 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

3469 "rpcName": "UpdateQueue", 

3470 "httpRequest": http_request, 

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

3472 }, 

3473 ) 

3474 

3475 # Send the request 

3476 response = CloudTasksRestTransport._UpdateQueue._get_response( 

3477 self._host, 

3478 metadata, 

3479 query_params, 

3480 self._session, 

3481 timeout, 

3482 transcoded_request, 

3483 body, 

3484 ) 

3485 

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

3487 # subclass. 

3488 if response.status_code >= 400: 

3489 raise core_exceptions.from_http_response(response) 

3490 

3491 # Return the response 

3492 resp = gct_queue.Queue() 

3493 pb_resp = gct_queue.Queue.pb(resp) 

3494 

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

3496 

3497 resp = self._interceptor.post_update_queue(resp) 

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

3499 resp, _ = self._interceptor.post_update_queue_with_metadata( 

3500 resp, response_metadata 

3501 ) 

3502 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

3503 logging.DEBUG 

3504 ): # pragma: NO COVER 

3505 try: 

3506 response_payload = gct_queue.Queue.to_json(response) 

3507 except: 

3508 response_payload = None 

3509 http_response = { 

3510 "payload": response_payload, 

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

3512 "status": response.status_code, 

3513 } 

3514 _LOGGER.debug( 

3515 "Received response for google.cloud.tasks_v2.CloudTasksClient.update_queue", 

3516 extra={ 

3517 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

3518 "rpcName": "UpdateQueue", 

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

3520 "httpResponse": http_response, 

3521 }, 

3522 ) 

3523 return resp 

3524 

3525 @property 

3526 def create_queue( 

3527 self, 

3528 ) -> Callable[[cloudtasks.CreateQueueRequest], gct_queue.Queue]: 

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

3530 # In C++ this would require a dynamic_cast 

3531 return self._CreateQueue(self._session, self._host, self._interceptor) # type: ignore 

3532 

3533 @property 

3534 def create_task(self) -> Callable[[cloudtasks.CreateTaskRequest], gct_task.Task]: 

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

3536 # In C++ this would require a dynamic_cast 

3537 return self._CreateTask(self._session, self._host, self._interceptor) # type: ignore 

3538 

3539 @property 

3540 def delete_queue( 

3541 self, 

3542 ) -> Callable[[cloudtasks.DeleteQueueRequest], empty_pb2.Empty]: 

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

3544 # In C++ this would require a dynamic_cast 

3545 return self._DeleteQueue(self._session, self._host, self._interceptor) # type: ignore 

3546 

3547 @property 

3548 def delete_task(self) -> Callable[[cloudtasks.DeleteTaskRequest], empty_pb2.Empty]: 

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

3550 # In C++ this would require a dynamic_cast 

3551 return self._DeleteTask(self._session, self._host, self._interceptor) # type: ignore 

3552 

3553 @property 

3554 def get_iam_policy( 

3555 self, 

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

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

3558 # In C++ this would require a dynamic_cast 

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

3560 

3561 @property 

3562 def get_queue(self) -> Callable[[cloudtasks.GetQueueRequest], queue.Queue]: 

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

3564 # In C++ this would require a dynamic_cast 

3565 return self._GetQueue(self._session, self._host, self._interceptor) # type: ignore 

3566 

3567 @property 

3568 def get_task(self) -> Callable[[cloudtasks.GetTaskRequest], task.Task]: 

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

3570 # In C++ this would require a dynamic_cast 

3571 return self._GetTask(self._session, self._host, self._interceptor) # type: ignore 

3572 

3573 @property 

3574 def list_queues( 

3575 self, 

3576 ) -> Callable[[cloudtasks.ListQueuesRequest], cloudtasks.ListQueuesResponse]: 

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

3578 # In C++ this would require a dynamic_cast 

3579 return self._ListQueues(self._session, self._host, self._interceptor) # type: ignore 

3580 

3581 @property 

3582 def list_tasks( 

3583 self, 

3584 ) -> Callable[[cloudtasks.ListTasksRequest], cloudtasks.ListTasksResponse]: 

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

3586 # In C++ this would require a dynamic_cast 

3587 return self._ListTasks(self._session, self._host, self._interceptor) # type: ignore 

3588 

3589 @property 

3590 def pause_queue(self) -> Callable[[cloudtasks.PauseQueueRequest], queue.Queue]: 

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

3592 # In C++ this would require a dynamic_cast 

3593 return self._PauseQueue(self._session, self._host, self._interceptor) # type: ignore 

3594 

3595 @property 

3596 def purge_queue(self) -> Callable[[cloudtasks.PurgeQueueRequest], queue.Queue]: 

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

3598 # In C++ this would require a dynamic_cast 

3599 return self._PurgeQueue(self._session, self._host, self._interceptor) # type: ignore 

3600 

3601 @property 

3602 def resume_queue(self) -> Callable[[cloudtasks.ResumeQueueRequest], queue.Queue]: 

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

3604 # In C++ this would require a dynamic_cast 

3605 return self._ResumeQueue(self._session, self._host, self._interceptor) # type: ignore 

3606 

3607 @property 

3608 def run_task(self) -> Callable[[cloudtasks.RunTaskRequest], task.Task]: 

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

3610 # In C++ this would require a dynamic_cast 

3611 return self._RunTask(self._session, self._host, self._interceptor) # type: ignore 

3612 

3613 @property 

3614 def set_iam_policy( 

3615 self, 

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

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

3618 # In C++ this would require a dynamic_cast 

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

3620 

3621 @property 

3622 def test_iam_permissions( 

3623 self, 

3624 ) -> Callable[ 

3625 [iam_policy_pb2.TestIamPermissionsRequest], 

3626 iam_policy_pb2.TestIamPermissionsResponse, 

3627 ]: 

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

3629 # In C++ this would require a dynamic_cast 

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

3631 

3632 @property 

3633 def update_queue( 

3634 self, 

3635 ) -> Callable[[cloudtasks.UpdateQueueRequest], gct_queue.Queue]: 

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

3637 # In C++ this would require a dynamic_cast 

3638 return self._UpdateQueue(self._session, self._host, self._interceptor) # type: ignore 

3639 

3640 @property 

3641 def get_location(self): 

3642 return self._GetLocation(self._session, self._host, self._interceptor) # type: ignore 

3643 

3644 class _GetLocation( 

3645 _BaseCloudTasksRestTransport._BaseGetLocation, CloudTasksRestStub 

3646 ): 

3647 def __hash__(self): 

3648 return hash("CloudTasksRestTransport.GetLocation") 

3649 

3650 @staticmethod 

3651 def _get_response( 

3652 host, 

3653 metadata, 

3654 query_params, 

3655 session, 

3656 timeout, 

3657 transcoded_request, 

3658 body=None, 

3659 ): 

3660 uri = transcoded_request["uri"] 

3661 method = transcoded_request["method"] 

3662 headers = dict(metadata) 

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

3664 response = getattr(session, method)( 

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

3666 timeout=timeout, 

3667 headers=headers, 

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

3669 ) 

3670 return response 

3671 

3672 def __call__( 

3673 self, 

3674 request: locations_pb2.GetLocationRequest, 

3675 *, 

3676 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3677 timeout: Optional[float] = None, 

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

3679 ) -> locations_pb2.Location: 

3680 r"""Call the get location method over HTTP. 

3681 

3682 Args: 

3683 request (locations_pb2.GetLocationRequest): 

3684 The request object for GetLocation method. 

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

3686 should be retried. 

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

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

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

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

3691 be of type `bytes`. 

3692 

3693 Returns: 

3694 locations_pb2.Location: Response from GetLocation method. 

3695 """ 

3696 

3697 http_options = ( 

3698 _BaseCloudTasksRestTransport._BaseGetLocation._get_http_options() 

3699 ) 

3700 

3701 request, metadata = self._interceptor.pre_get_location(request, metadata) 

3702 transcoded_request = ( 

3703 _BaseCloudTasksRestTransport._BaseGetLocation._get_transcoded_request( 

3704 http_options, request 

3705 ) 

3706 ) 

3707 

3708 # Jsonify the query params 

3709 query_params = ( 

3710 _BaseCloudTasksRestTransport._BaseGetLocation._get_query_params_json( 

3711 transcoded_request 

3712 ) 

3713 ) 

3714 

3715 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

3716 logging.DEBUG 

3717 ): # pragma: NO COVER 

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

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

3720 ) 

3721 method = transcoded_request["method"] 

3722 try: 

3723 request_payload = json_format.MessageToJson(request) 

3724 except: 

3725 request_payload = None 

3726 http_request = { 

3727 "payload": request_payload, 

3728 "requestMethod": method, 

3729 "requestUrl": request_url, 

3730 "headers": dict(metadata), 

3731 } 

3732 _LOGGER.debug( 

3733 f"Sending request for google.cloud.tasks_v2.CloudTasksClient.GetLocation", 

3734 extra={ 

3735 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

3736 "rpcName": "GetLocation", 

3737 "httpRequest": http_request, 

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

3739 }, 

3740 ) 

3741 

3742 # Send the request 

3743 response = CloudTasksRestTransport._GetLocation._get_response( 

3744 self._host, 

3745 metadata, 

3746 query_params, 

3747 self._session, 

3748 timeout, 

3749 transcoded_request, 

3750 ) 

3751 

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

3753 # subclass. 

3754 if response.status_code >= 400: 

3755 raise core_exceptions.from_http_response(response) 

3756 

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

3758 resp = locations_pb2.Location() 

3759 resp = json_format.Parse(content, resp) 

3760 resp = self._interceptor.post_get_location(resp) 

3761 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

3762 logging.DEBUG 

3763 ): # pragma: NO COVER 

3764 try: 

3765 response_payload = json_format.MessageToJson(resp) 

3766 except: 

3767 response_payload = None 

3768 http_response = { 

3769 "payload": response_payload, 

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

3771 "status": response.status_code, 

3772 } 

3773 _LOGGER.debug( 

3774 "Received response for google.cloud.tasks_v2.CloudTasksAsyncClient.GetLocation", 

3775 extra={ 

3776 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

3777 "rpcName": "GetLocation", 

3778 "httpResponse": http_response, 

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

3780 }, 

3781 ) 

3782 return resp 

3783 

3784 @property 

3785 def list_locations(self): 

3786 return self._ListLocations(self._session, self._host, self._interceptor) # type: ignore 

3787 

3788 class _ListLocations( 

3789 _BaseCloudTasksRestTransport._BaseListLocations, CloudTasksRestStub 

3790 ): 

3791 def __hash__(self): 

3792 return hash("CloudTasksRestTransport.ListLocations") 

3793 

3794 @staticmethod 

3795 def _get_response( 

3796 host, 

3797 metadata, 

3798 query_params, 

3799 session, 

3800 timeout, 

3801 transcoded_request, 

3802 body=None, 

3803 ): 

3804 uri = transcoded_request["uri"] 

3805 method = transcoded_request["method"] 

3806 headers = dict(metadata) 

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

3808 response = getattr(session, method)( 

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

3810 timeout=timeout, 

3811 headers=headers, 

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

3813 ) 

3814 return response 

3815 

3816 def __call__( 

3817 self, 

3818 request: locations_pb2.ListLocationsRequest, 

3819 *, 

3820 retry: OptionalRetry = gapic_v1.method.DEFAULT, 

3821 timeout: Optional[float] = None, 

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

3823 ) -> locations_pb2.ListLocationsResponse: 

3824 r"""Call the list locations method over HTTP. 

3825 

3826 Args: 

3827 request (locations_pb2.ListLocationsRequest): 

3828 The request object for ListLocations method. 

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

3830 should be retried. 

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

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

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

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

3835 be of type `bytes`. 

3836 

3837 Returns: 

3838 locations_pb2.ListLocationsResponse: Response from ListLocations method. 

3839 """ 

3840 

3841 http_options = ( 

3842 _BaseCloudTasksRestTransport._BaseListLocations._get_http_options() 

3843 ) 

3844 

3845 request, metadata = self._interceptor.pre_list_locations(request, metadata) 

3846 transcoded_request = ( 

3847 _BaseCloudTasksRestTransport._BaseListLocations._get_transcoded_request( 

3848 http_options, request 

3849 ) 

3850 ) 

3851 

3852 # Jsonify the query params 

3853 query_params = ( 

3854 _BaseCloudTasksRestTransport._BaseListLocations._get_query_params_json( 

3855 transcoded_request 

3856 ) 

3857 ) 

3858 

3859 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

3860 logging.DEBUG 

3861 ): # pragma: NO COVER 

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

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

3864 ) 

3865 method = transcoded_request["method"] 

3866 try: 

3867 request_payload = json_format.MessageToJson(request) 

3868 except: 

3869 request_payload = None 

3870 http_request = { 

3871 "payload": request_payload, 

3872 "requestMethod": method, 

3873 "requestUrl": request_url, 

3874 "headers": dict(metadata), 

3875 } 

3876 _LOGGER.debug( 

3877 f"Sending request for google.cloud.tasks_v2.CloudTasksClient.ListLocations", 

3878 extra={ 

3879 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

3880 "rpcName": "ListLocations", 

3881 "httpRequest": http_request, 

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

3883 }, 

3884 ) 

3885 

3886 # Send the request 

3887 response = CloudTasksRestTransport._ListLocations._get_response( 

3888 self._host, 

3889 metadata, 

3890 query_params, 

3891 self._session, 

3892 timeout, 

3893 transcoded_request, 

3894 ) 

3895 

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

3897 # subclass. 

3898 if response.status_code >= 400: 

3899 raise core_exceptions.from_http_response(response) 

3900 

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

3902 resp = locations_pb2.ListLocationsResponse() 

3903 resp = json_format.Parse(content, resp) 

3904 resp = self._interceptor.post_list_locations(resp) 

3905 if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( 

3906 logging.DEBUG 

3907 ): # pragma: NO COVER 

3908 try: 

3909 response_payload = json_format.MessageToJson(resp) 

3910 except: 

3911 response_payload = None 

3912 http_response = { 

3913 "payload": response_payload, 

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

3915 "status": response.status_code, 

3916 } 

3917 _LOGGER.debug( 

3918 "Received response for google.cloud.tasks_v2.CloudTasksAsyncClient.ListLocations", 

3919 extra={ 

3920 "serviceName": "google.cloud.tasks.v2.CloudTasks", 

3921 "rpcName": "ListLocations", 

3922 "httpResponse": http_response, 

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

3924 }, 

3925 ) 

3926 return resp 

3927 

3928 @property 

3929 def kind(self) -> str: 

3930 return "rest" 

3931 

3932 def close(self): 

3933 self._session.close() 

3934 

3935 

3936__all__ = ("CloudTasksRestTransport",)