google-cloud-beyondcorp-clientgateways 0.4.16__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. google/cloud/beyondcorp_clientgateways/__init__.py +47 -0
  2. google/cloud/beyondcorp_clientgateways/gapic_version.py +16 -0
  3. google/cloud/beyondcorp_clientgateways/py.typed +2 -0
  4. google/cloud/beyondcorp_clientgateways_v1/__init__.py +45 -0
  5. google/cloud/beyondcorp_clientgateways_v1/gapic_metadata.json +88 -0
  6. google/cloud/beyondcorp_clientgateways_v1/gapic_version.py +16 -0
  7. google/cloud/beyondcorp_clientgateways_v1/py.typed +2 -0
  8. google/cloud/beyondcorp_clientgateways_v1/services/__init__.py +15 -0
  9. google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/__init__.py +22 -0
  10. google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/async_client.py +1489 -0
  11. google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/client.py +1932 -0
  12. google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/pagers.py +201 -0
  13. google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/transports/__init__.py +41 -0
  14. google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/transports/base.py +347 -0
  15. google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/transports/grpc.py +663 -0
  16. google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/transports/grpc_asyncio.py +747 -0
  17. google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/transports/rest.py +2591 -0
  18. google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/transports/rest_base.py +592 -0
  19. google/cloud/beyondcorp_clientgateways_v1/types/__init__.py +34 -0
  20. google/cloud/beyondcorp_clientgateways_v1/types/client_gateways_service.py +381 -0
  21. google_cloud_beyondcorp_clientgateways-0.4.16.dist-info/LICENSE +202 -0
  22. google_cloud_beyondcorp_clientgateways-0.4.16.dist-info/METADATA +229 -0
  23. google_cloud_beyondcorp_clientgateways-0.4.16.dist-info/RECORD +25 -0
  24. google_cloud_beyondcorp_clientgateways-0.4.16.dist-info/WHEEL +5 -0
  25. google_cloud_beyondcorp_clientgateways-0.4.16.dist-info/top_level.txt +1 -0
@@ -0,0 +1,2591 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2024 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ import dataclasses
17
+ import json # type: ignore
18
+ import logging
19
+ from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
20
+ import warnings
21
+
22
+ from google.api_core import gapic_v1, operations_v1, rest_helpers, rest_streaming
23
+ from google.api_core import exceptions as core_exceptions
24
+ from google.api_core import retry as retries
25
+ from google.auth import credentials as ga_credentials # type: ignore
26
+ from google.auth.transport.requests import AuthorizedSession # type: ignore
27
+ from google.cloud.location import locations_pb2 # type: ignore
28
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
29
+ from google.iam.v1 import policy_pb2 # type: ignore
30
+ from google.longrunning import operations_pb2 # type: ignore
31
+ from google.protobuf import json_format
32
+ from requests import __version__ as requests_version
33
+
34
+ from google.cloud.beyondcorp_clientgateways_v1.types import client_gateways_service
35
+
36
+ from .base import DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO
37
+ from .rest_base import _BaseClientGatewaysServiceRestTransport
38
+
39
+ try:
40
+ OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
41
+ except AttributeError: # pragma: NO COVER
42
+ OptionalRetry = Union[retries.Retry, object, None] # type: ignore
43
+
44
+ try:
45
+ from google.api_core import client_logging # type: ignore
46
+
47
+ CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
48
+ except ImportError: # pragma: NO COVER
49
+ CLIENT_LOGGING_SUPPORTED = False
50
+
51
+ _LOGGER = logging.getLogger(__name__)
52
+
53
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
54
+ gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version,
55
+ grpc_version=None,
56
+ rest_version=f"requests@{requests_version}",
57
+ )
58
+
59
+
60
+ class ClientGatewaysServiceRestInterceptor:
61
+ """Interceptor for ClientGatewaysService.
62
+
63
+ Interceptors are used to manipulate requests, request metadata, and responses
64
+ in arbitrary ways.
65
+ Example use cases include:
66
+ * Logging
67
+ * Verifying requests according to service or custom semantics
68
+ * Stripping extraneous information from responses
69
+
70
+ These use cases and more can be enabled by injecting an
71
+ instance of a custom subclass when constructing the ClientGatewaysServiceRestTransport.
72
+
73
+ .. code-block:: python
74
+ class MyCustomClientGatewaysServiceInterceptor(ClientGatewaysServiceRestInterceptor):
75
+ def pre_create_client_gateway(self, request, metadata):
76
+ logging.log(f"Received request: {request}")
77
+ return request, metadata
78
+
79
+ def post_create_client_gateway(self, response):
80
+ logging.log(f"Received response: {response}")
81
+ return response
82
+
83
+ def pre_delete_client_gateway(self, request, metadata):
84
+ logging.log(f"Received request: {request}")
85
+ return request, metadata
86
+
87
+ def post_delete_client_gateway(self, response):
88
+ logging.log(f"Received response: {response}")
89
+ return response
90
+
91
+ def pre_get_client_gateway(self, request, metadata):
92
+ logging.log(f"Received request: {request}")
93
+ return request, metadata
94
+
95
+ def post_get_client_gateway(self, response):
96
+ logging.log(f"Received response: {response}")
97
+ return response
98
+
99
+ def pre_list_client_gateways(self, request, metadata):
100
+ logging.log(f"Received request: {request}")
101
+ return request, metadata
102
+
103
+ def post_list_client_gateways(self, response):
104
+ logging.log(f"Received response: {response}")
105
+ return response
106
+
107
+ transport = ClientGatewaysServiceRestTransport(interceptor=MyCustomClientGatewaysServiceInterceptor())
108
+ client = ClientGatewaysServiceClient(transport=transport)
109
+
110
+
111
+ """
112
+
113
+ def pre_create_client_gateway(
114
+ self,
115
+ request: client_gateways_service.CreateClientGatewayRequest,
116
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
117
+ ) -> Tuple[
118
+ client_gateways_service.CreateClientGatewayRequest,
119
+ Sequence[Tuple[str, Union[str, bytes]]],
120
+ ]:
121
+ """Pre-rpc interceptor for create_client_gateway
122
+
123
+ Override in a subclass to manipulate the request or metadata
124
+ before they are sent to the ClientGatewaysService server.
125
+ """
126
+ return request, metadata
127
+
128
+ def post_create_client_gateway(
129
+ self, response: operations_pb2.Operation
130
+ ) -> operations_pb2.Operation:
131
+ """Post-rpc interceptor for create_client_gateway
132
+
133
+ DEPRECATED. Please use the `post_create_client_gateway_with_metadata`
134
+ interceptor instead.
135
+
136
+ Override in a subclass to read or manipulate the response
137
+ after it is returned by the ClientGatewaysService server but before
138
+ it is returned to user code. This `post_create_client_gateway` interceptor runs
139
+ before the `post_create_client_gateway_with_metadata` interceptor.
140
+ """
141
+ return response
142
+
143
+ def post_create_client_gateway_with_metadata(
144
+ self,
145
+ response: operations_pb2.Operation,
146
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
147
+ ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]:
148
+ """Post-rpc interceptor for create_client_gateway
149
+
150
+ Override in a subclass to read or manipulate the response or metadata after it
151
+ is returned by the ClientGatewaysService server but before it is returned to user code.
152
+
153
+ We recommend only using this `post_create_client_gateway_with_metadata`
154
+ interceptor in new development instead of the `post_create_client_gateway` interceptor.
155
+ When both interceptors are used, this `post_create_client_gateway_with_metadata` interceptor runs after the
156
+ `post_create_client_gateway` interceptor. The (possibly modified) response returned by
157
+ `post_create_client_gateway` will be passed to
158
+ `post_create_client_gateway_with_metadata`.
159
+ """
160
+ return response, metadata
161
+
162
+ def pre_delete_client_gateway(
163
+ self,
164
+ request: client_gateways_service.DeleteClientGatewayRequest,
165
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
166
+ ) -> Tuple[
167
+ client_gateways_service.DeleteClientGatewayRequest,
168
+ Sequence[Tuple[str, Union[str, bytes]]],
169
+ ]:
170
+ """Pre-rpc interceptor for delete_client_gateway
171
+
172
+ Override in a subclass to manipulate the request or metadata
173
+ before they are sent to the ClientGatewaysService server.
174
+ """
175
+ return request, metadata
176
+
177
+ def post_delete_client_gateway(
178
+ self, response: operations_pb2.Operation
179
+ ) -> operations_pb2.Operation:
180
+ """Post-rpc interceptor for delete_client_gateway
181
+
182
+ DEPRECATED. Please use the `post_delete_client_gateway_with_metadata`
183
+ interceptor instead.
184
+
185
+ Override in a subclass to read or manipulate the response
186
+ after it is returned by the ClientGatewaysService server but before
187
+ it is returned to user code. This `post_delete_client_gateway` interceptor runs
188
+ before the `post_delete_client_gateway_with_metadata` interceptor.
189
+ """
190
+ return response
191
+
192
+ def post_delete_client_gateway_with_metadata(
193
+ self,
194
+ response: operations_pb2.Operation,
195
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
196
+ ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]:
197
+ """Post-rpc interceptor for delete_client_gateway
198
+
199
+ Override in a subclass to read or manipulate the response or metadata after it
200
+ is returned by the ClientGatewaysService server but before it is returned to user code.
201
+
202
+ We recommend only using this `post_delete_client_gateway_with_metadata`
203
+ interceptor in new development instead of the `post_delete_client_gateway` interceptor.
204
+ When both interceptors are used, this `post_delete_client_gateway_with_metadata` interceptor runs after the
205
+ `post_delete_client_gateway` interceptor. The (possibly modified) response returned by
206
+ `post_delete_client_gateway` will be passed to
207
+ `post_delete_client_gateway_with_metadata`.
208
+ """
209
+ return response, metadata
210
+
211
+ def pre_get_client_gateway(
212
+ self,
213
+ request: client_gateways_service.GetClientGatewayRequest,
214
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
215
+ ) -> Tuple[
216
+ client_gateways_service.GetClientGatewayRequest,
217
+ Sequence[Tuple[str, Union[str, bytes]]],
218
+ ]:
219
+ """Pre-rpc interceptor for get_client_gateway
220
+
221
+ Override in a subclass to manipulate the request or metadata
222
+ before they are sent to the ClientGatewaysService server.
223
+ """
224
+ return request, metadata
225
+
226
+ def post_get_client_gateway(
227
+ self, response: client_gateways_service.ClientGateway
228
+ ) -> client_gateways_service.ClientGateway:
229
+ """Post-rpc interceptor for get_client_gateway
230
+
231
+ DEPRECATED. Please use the `post_get_client_gateway_with_metadata`
232
+ interceptor instead.
233
+
234
+ Override in a subclass to read or manipulate the response
235
+ after it is returned by the ClientGatewaysService server but before
236
+ it is returned to user code. This `post_get_client_gateway` interceptor runs
237
+ before the `post_get_client_gateway_with_metadata` interceptor.
238
+ """
239
+ return response
240
+
241
+ def post_get_client_gateway_with_metadata(
242
+ self,
243
+ response: client_gateways_service.ClientGateway,
244
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
245
+ ) -> Tuple[
246
+ client_gateways_service.ClientGateway, Sequence[Tuple[str, Union[str, bytes]]]
247
+ ]:
248
+ """Post-rpc interceptor for get_client_gateway
249
+
250
+ Override in a subclass to read or manipulate the response or metadata after it
251
+ is returned by the ClientGatewaysService server but before it is returned to user code.
252
+
253
+ We recommend only using this `post_get_client_gateway_with_metadata`
254
+ interceptor in new development instead of the `post_get_client_gateway` interceptor.
255
+ When both interceptors are used, this `post_get_client_gateway_with_metadata` interceptor runs after the
256
+ `post_get_client_gateway` interceptor. The (possibly modified) response returned by
257
+ `post_get_client_gateway` will be passed to
258
+ `post_get_client_gateway_with_metadata`.
259
+ """
260
+ return response, metadata
261
+
262
+ def pre_list_client_gateways(
263
+ self,
264
+ request: client_gateways_service.ListClientGatewaysRequest,
265
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
266
+ ) -> Tuple[
267
+ client_gateways_service.ListClientGatewaysRequest,
268
+ Sequence[Tuple[str, Union[str, bytes]]],
269
+ ]:
270
+ """Pre-rpc interceptor for list_client_gateways
271
+
272
+ Override in a subclass to manipulate the request or metadata
273
+ before they are sent to the ClientGatewaysService server.
274
+ """
275
+ return request, metadata
276
+
277
+ def post_list_client_gateways(
278
+ self, response: client_gateways_service.ListClientGatewaysResponse
279
+ ) -> client_gateways_service.ListClientGatewaysResponse:
280
+ """Post-rpc interceptor for list_client_gateways
281
+
282
+ DEPRECATED. Please use the `post_list_client_gateways_with_metadata`
283
+ interceptor instead.
284
+
285
+ Override in a subclass to read or manipulate the response
286
+ after it is returned by the ClientGatewaysService server but before
287
+ it is returned to user code. This `post_list_client_gateways` interceptor runs
288
+ before the `post_list_client_gateways_with_metadata` interceptor.
289
+ """
290
+ return response
291
+
292
+ def post_list_client_gateways_with_metadata(
293
+ self,
294
+ response: client_gateways_service.ListClientGatewaysResponse,
295
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
296
+ ) -> Tuple[
297
+ client_gateways_service.ListClientGatewaysResponse,
298
+ Sequence[Tuple[str, Union[str, bytes]]],
299
+ ]:
300
+ """Post-rpc interceptor for list_client_gateways
301
+
302
+ Override in a subclass to read or manipulate the response or metadata after it
303
+ is returned by the ClientGatewaysService server but before it is returned to user code.
304
+
305
+ We recommend only using this `post_list_client_gateways_with_metadata`
306
+ interceptor in new development instead of the `post_list_client_gateways` interceptor.
307
+ When both interceptors are used, this `post_list_client_gateways_with_metadata` interceptor runs after the
308
+ `post_list_client_gateways` interceptor. The (possibly modified) response returned by
309
+ `post_list_client_gateways` will be passed to
310
+ `post_list_client_gateways_with_metadata`.
311
+ """
312
+ return response, metadata
313
+
314
+ def pre_get_location(
315
+ self,
316
+ request: locations_pb2.GetLocationRequest,
317
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
318
+ ) -> Tuple[
319
+ locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]]
320
+ ]:
321
+ """Pre-rpc interceptor for get_location
322
+
323
+ Override in a subclass to manipulate the request or metadata
324
+ before they are sent to the ClientGatewaysService server.
325
+ """
326
+ return request, metadata
327
+
328
+ def post_get_location(
329
+ self, response: locations_pb2.Location
330
+ ) -> locations_pb2.Location:
331
+ """Post-rpc interceptor for get_location
332
+
333
+ Override in a subclass to manipulate the response
334
+ after it is returned by the ClientGatewaysService server but before
335
+ it is returned to user code.
336
+ """
337
+ return response
338
+
339
+ def pre_list_locations(
340
+ self,
341
+ request: locations_pb2.ListLocationsRequest,
342
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
343
+ ) -> Tuple[
344
+ locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]]
345
+ ]:
346
+ """Pre-rpc interceptor for list_locations
347
+
348
+ Override in a subclass to manipulate the request or metadata
349
+ before they are sent to the ClientGatewaysService server.
350
+ """
351
+ return request, metadata
352
+
353
+ def post_list_locations(
354
+ self, response: locations_pb2.ListLocationsResponse
355
+ ) -> locations_pb2.ListLocationsResponse:
356
+ """Post-rpc interceptor for list_locations
357
+
358
+ Override in a subclass to manipulate the response
359
+ after it is returned by the ClientGatewaysService server but before
360
+ it is returned to user code.
361
+ """
362
+ return response
363
+
364
+ def pre_get_iam_policy(
365
+ self,
366
+ request: iam_policy_pb2.GetIamPolicyRequest,
367
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
368
+ ) -> Tuple[
369
+ iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]]
370
+ ]:
371
+ """Pre-rpc interceptor for get_iam_policy
372
+
373
+ Override in a subclass to manipulate the request or metadata
374
+ before they are sent to the ClientGatewaysService server.
375
+ """
376
+ return request, metadata
377
+
378
+ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy:
379
+ """Post-rpc interceptor for get_iam_policy
380
+
381
+ Override in a subclass to manipulate the response
382
+ after it is returned by the ClientGatewaysService server but before
383
+ it is returned to user code.
384
+ """
385
+ return response
386
+
387
+ def pre_set_iam_policy(
388
+ self,
389
+ request: iam_policy_pb2.SetIamPolicyRequest,
390
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
391
+ ) -> Tuple[
392
+ iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]]
393
+ ]:
394
+ """Pre-rpc interceptor for set_iam_policy
395
+
396
+ Override in a subclass to manipulate the request or metadata
397
+ before they are sent to the ClientGatewaysService server.
398
+ """
399
+ return request, metadata
400
+
401
+ def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy:
402
+ """Post-rpc interceptor for set_iam_policy
403
+
404
+ Override in a subclass to manipulate the response
405
+ after it is returned by the ClientGatewaysService server but before
406
+ it is returned to user code.
407
+ """
408
+ return response
409
+
410
+ def pre_test_iam_permissions(
411
+ self,
412
+ request: iam_policy_pb2.TestIamPermissionsRequest,
413
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
414
+ ) -> Tuple[
415
+ iam_policy_pb2.TestIamPermissionsRequest,
416
+ Sequence[Tuple[str, Union[str, bytes]]],
417
+ ]:
418
+ """Pre-rpc interceptor for test_iam_permissions
419
+
420
+ Override in a subclass to manipulate the request or metadata
421
+ before they are sent to the ClientGatewaysService server.
422
+ """
423
+ return request, metadata
424
+
425
+ def post_test_iam_permissions(
426
+ self, response: iam_policy_pb2.TestIamPermissionsResponse
427
+ ) -> iam_policy_pb2.TestIamPermissionsResponse:
428
+ """Post-rpc interceptor for test_iam_permissions
429
+
430
+ Override in a subclass to manipulate the response
431
+ after it is returned by the ClientGatewaysService server but before
432
+ it is returned to user code.
433
+ """
434
+ return response
435
+
436
+ def pre_cancel_operation(
437
+ self,
438
+ request: operations_pb2.CancelOperationRequest,
439
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
440
+ ) -> Tuple[
441
+ operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]]
442
+ ]:
443
+ """Pre-rpc interceptor for cancel_operation
444
+
445
+ Override in a subclass to manipulate the request or metadata
446
+ before they are sent to the ClientGatewaysService server.
447
+ """
448
+ return request, metadata
449
+
450
+ def post_cancel_operation(self, response: None) -> None:
451
+ """Post-rpc interceptor for cancel_operation
452
+
453
+ Override in a subclass to manipulate the response
454
+ after it is returned by the ClientGatewaysService server but before
455
+ it is returned to user code.
456
+ """
457
+ return response
458
+
459
+ def pre_delete_operation(
460
+ self,
461
+ request: operations_pb2.DeleteOperationRequest,
462
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
463
+ ) -> Tuple[
464
+ operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, Union[str, bytes]]]
465
+ ]:
466
+ """Pre-rpc interceptor for delete_operation
467
+
468
+ Override in a subclass to manipulate the request or metadata
469
+ before they are sent to the ClientGatewaysService server.
470
+ """
471
+ return request, metadata
472
+
473
+ def post_delete_operation(self, response: None) -> None:
474
+ """Post-rpc interceptor for delete_operation
475
+
476
+ Override in a subclass to manipulate the response
477
+ after it is returned by the ClientGatewaysService server but before
478
+ it is returned to user code.
479
+ """
480
+ return response
481
+
482
+ def pre_get_operation(
483
+ self,
484
+ request: operations_pb2.GetOperationRequest,
485
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
486
+ ) -> Tuple[
487
+ operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]]
488
+ ]:
489
+ """Pre-rpc interceptor for get_operation
490
+
491
+ Override in a subclass to manipulate the request or metadata
492
+ before they are sent to the ClientGatewaysService server.
493
+ """
494
+ return request, metadata
495
+
496
+ def post_get_operation(
497
+ self, response: operations_pb2.Operation
498
+ ) -> operations_pb2.Operation:
499
+ """Post-rpc interceptor for get_operation
500
+
501
+ Override in a subclass to manipulate the response
502
+ after it is returned by the ClientGatewaysService server but before
503
+ it is returned to user code.
504
+ """
505
+ return response
506
+
507
+ def pre_list_operations(
508
+ self,
509
+ request: operations_pb2.ListOperationsRequest,
510
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
511
+ ) -> Tuple[
512
+ operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]]
513
+ ]:
514
+ """Pre-rpc interceptor for list_operations
515
+
516
+ Override in a subclass to manipulate the request or metadata
517
+ before they are sent to the ClientGatewaysService server.
518
+ """
519
+ return request, metadata
520
+
521
+ def post_list_operations(
522
+ self, response: operations_pb2.ListOperationsResponse
523
+ ) -> operations_pb2.ListOperationsResponse:
524
+ """Post-rpc interceptor for list_operations
525
+
526
+ Override in a subclass to manipulate the response
527
+ after it is returned by the ClientGatewaysService server but before
528
+ it is returned to user code.
529
+ """
530
+ return response
531
+
532
+
533
+ @dataclasses.dataclass
534
+ class ClientGatewaysServiceRestStub:
535
+ _session: AuthorizedSession
536
+ _host: str
537
+ _interceptor: ClientGatewaysServiceRestInterceptor
538
+
539
+
540
+ class ClientGatewaysServiceRestTransport(_BaseClientGatewaysServiceRestTransport):
541
+ """REST backend synchronous transport for ClientGatewaysService.
542
+
543
+ API Overview:
544
+
545
+ The ``beyondcorp.googleapis.com`` service implements the Google
546
+ Cloud BeyondCorp API.
547
+
548
+ Data Model:
549
+
550
+ The ClientGatewaysService exposes the following resources:
551
+
552
+ - Client Gateways, named as follows:
553
+ ``projects/{project_id}/locations/{location_id}/clientGateways/{client_gateway_id}``.
554
+
555
+ This class defines the same methods as the primary client, so the
556
+ primary client can load the underlying transport implementation
557
+ and call it.
558
+
559
+ It sends JSON representations of protocol buffers over HTTP/1.1
560
+ """
561
+
562
+ def __init__(
563
+ self,
564
+ *,
565
+ host: str = "beyondcorp.googleapis.com",
566
+ credentials: Optional[ga_credentials.Credentials] = None,
567
+ credentials_file: Optional[str] = None,
568
+ scopes: Optional[Sequence[str]] = None,
569
+ client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
570
+ quota_project_id: Optional[str] = None,
571
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
572
+ always_use_jwt_access: Optional[bool] = False,
573
+ url_scheme: str = "https",
574
+ interceptor: Optional[ClientGatewaysServiceRestInterceptor] = None,
575
+ api_audience: Optional[str] = None,
576
+ ) -> None:
577
+ """Instantiate the transport.
578
+
579
+ Args:
580
+ host (Optional[str]):
581
+ The hostname to connect to (default: 'beyondcorp.googleapis.com').
582
+ credentials (Optional[google.auth.credentials.Credentials]): The
583
+ authorization credentials to attach to requests. These
584
+ credentials identify the application to the service; if none
585
+ are specified, the client will attempt to ascertain the
586
+ credentials from the environment.
587
+
588
+ credentials_file (Optional[str]): A file with credentials that can
589
+ be loaded with :func:`google.auth.load_credentials_from_file`.
590
+ This argument is ignored if ``channel`` is provided.
591
+ scopes (Optional(Sequence[str])): A list of scopes. This argument is
592
+ ignored if ``channel`` is provided.
593
+ client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client
594
+ certificate to configure mutual TLS HTTP channel. It is ignored
595
+ if ``channel`` is provided.
596
+ quota_project_id (Optional[str]): An optional project to use for billing
597
+ and quota.
598
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
599
+ The client info used to send a user-agent string along with
600
+ API requests. If ``None``, then default info will be used.
601
+ Generally, you only need to set this if you are developing
602
+ your own client library.
603
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
604
+ be used for service account credentials.
605
+ url_scheme: the protocol scheme for the API endpoint. Normally
606
+ "https", but for testing or local servers,
607
+ "http" can be specified.
608
+ """
609
+ # Run the base constructor
610
+ # TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc.
611
+ # TODO: When custom host (api_endpoint) is set, `scopes` must *also* be set on the
612
+ # credentials object
613
+ super().__init__(
614
+ host=host,
615
+ credentials=credentials,
616
+ client_info=client_info,
617
+ always_use_jwt_access=always_use_jwt_access,
618
+ url_scheme=url_scheme,
619
+ api_audience=api_audience,
620
+ )
621
+ self._session = AuthorizedSession(
622
+ self._credentials, default_host=self.DEFAULT_HOST
623
+ )
624
+ self._operations_client: Optional[operations_v1.AbstractOperationsClient] = None
625
+ if client_cert_source_for_mtls:
626
+ self._session.configure_mtls_channel(client_cert_source_for_mtls)
627
+ self._interceptor = interceptor or ClientGatewaysServiceRestInterceptor()
628
+ self._prep_wrapped_messages(client_info)
629
+
630
+ @property
631
+ def operations_client(self) -> operations_v1.AbstractOperationsClient:
632
+ """Create the client designed to process long-running operations.
633
+
634
+ This property caches on the instance; repeated calls return the same
635
+ client.
636
+ """
637
+ # Only create a new client if we do not already have one.
638
+ if self._operations_client is None:
639
+ http_options: Dict[str, List[Dict[str, str]]] = {
640
+ "google.longrunning.Operations.CancelOperation": [
641
+ {
642
+ "method": "post",
643
+ "uri": "/v1/{name=projects/*/locations/*/operations/*}:cancel",
644
+ "body": "*",
645
+ },
646
+ ],
647
+ "google.longrunning.Operations.DeleteOperation": [
648
+ {
649
+ "method": "delete",
650
+ "uri": "/v1/{name=projects/*/locations/*/operations/*}",
651
+ },
652
+ ],
653
+ "google.longrunning.Operations.GetOperation": [
654
+ {
655
+ "method": "get",
656
+ "uri": "/v1/{name=projects/*/locations/*/operations/*}",
657
+ },
658
+ ],
659
+ "google.longrunning.Operations.ListOperations": [
660
+ {
661
+ "method": "get",
662
+ "uri": "/v1/{name=projects/*/locations/*}/operations",
663
+ },
664
+ ],
665
+ }
666
+
667
+ rest_transport = operations_v1.OperationsRestTransport(
668
+ host=self._host,
669
+ # use the credentials which are saved
670
+ credentials=self._credentials,
671
+ scopes=self._scopes,
672
+ http_options=http_options,
673
+ path_prefix="v1",
674
+ )
675
+
676
+ self._operations_client = operations_v1.AbstractOperationsClient(
677
+ transport=rest_transport
678
+ )
679
+
680
+ # Return the client from cache.
681
+ return self._operations_client
682
+
683
+ class _CreateClientGateway(
684
+ _BaseClientGatewaysServiceRestTransport._BaseCreateClientGateway,
685
+ ClientGatewaysServiceRestStub,
686
+ ):
687
+ def __hash__(self):
688
+ return hash("ClientGatewaysServiceRestTransport.CreateClientGateway")
689
+
690
+ @staticmethod
691
+ def _get_response(
692
+ host,
693
+ metadata,
694
+ query_params,
695
+ session,
696
+ timeout,
697
+ transcoded_request,
698
+ body=None,
699
+ ):
700
+ uri = transcoded_request["uri"]
701
+ method = transcoded_request["method"]
702
+ headers = dict(metadata)
703
+ headers["Content-Type"] = "application/json"
704
+ response = getattr(session, method)(
705
+ "{host}{uri}".format(host=host, uri=uri),
706
+ timeout=timeout,
707
+ headers=headers,
708
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
709
+ data=body,
710
+ )
711
+ return response
712
+
713
+ def __call__(
714
+ self,
715
+ request: client_gateways_service.CreateClientGatewayRequest,
716
+ *,
717
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
718
+ timeout: Optional[float] = None,
719
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
720
+ ) -> operations_pb2.Operation:
721
+ r"""Call the create client gateway method over HTTP.
722
+
723
+ Args:
724
+ request (~.client_gateways_service.CreateClientGatewayRequest):
725
+ The request object. Message for creating a ClientGateway.
726
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
727
+ should be retried.
728
+ timeout (float): The timeout for this request.
729
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
730
+ sent along with the request as metadata. Normally, each value must be of type `str`,
731
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
732
+ be of type `bytes`.
733
+
734
+ Returns:
735
+ ~.operations_pb2.Operation:
736
+ This resource represents a
737
+ long-running operation that is the
738
+ result of a network API call.
739
+
740
+ """
741
+
742
+ http_options = (
743
+ _BaseClientGatewaysServiceRestTransport._BaseCreateClientGateway._get_http_options()
744
+ )
745
+
746
+ request, metadata = self._interceptor.pre_create_client_gateway(
747
+ request, metadata
748
+ )
749
+ transcoded_request = _BaseClientGatewaysServiceRestTransport._BaseCreateClientGateway._get_transcoded_request(
750
+ http_options, request
751
+ )
752
+
753
+ body = _BaseClientGatewaysServiceRestTransport._BaseCreateClientGateway._get_request_body_json(
754
+ transcoded_request
755
+ )
756
+
757
+ # Jsonify the query params
758
+ query_params = _BaseClientGatewaysServiceRestTransport._BaseCreateClientGateway._get_query_params_json(
759
+ transcoded_request
760
+ )
761
+
762
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
763
+ logging.DEBUG
764
+ ): # pragma: NO COVER
765
+ request_url = "{host}{uri}".format(
766
+ host=self._host, uri=transcoded_request["uri"]
767
+ )
768
+ method = transcoded_request["method"]
769
+ try:
770
+ request_payload = json_format.MessageToJson(request)
771
+ except:
772
+ request_payload = None
773
+ http_request = {
774
+ "payload": request_payload,
775
+ "requestMethod": method,
776
+ "requestUrl": request_url,
777
+ "headers": dict(metadata),
778
+ }
779
+ _LOGGER.debug(
780
+ f"Sending request for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.CreateClientGateway",
781
+ extra={
782
+ "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService",
783
+ "rpcName": "CreateClientGateway",
784
+ "httpRequest": http_request,
785
+ "metadata": http_request["headers"],
786
+ },
787
+ )
788
+
789
+ # Send the request
790
+ response = (
791
+ ClientGatewaysServiceRestTransport._CreateClientGateway._get_response(
792
+ self._host,
793
+ metadata,
794
+ query_params,
795
+ self._session,
796
+ timeout,
797
+ transcoded_request,
798
+ body,
799
+ )
800
+ )
801
+
802
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
803
+ # subclass.
804
+ if response.status_code >= 400:
805
+ raise core_exceptions.from_http_response(response)
806
+
807
+ # Return the response
808
+ resp = operations_pb2.Operation()
809
+ json_format.Parse(response.content, resp, ignore_unknown_fields=True)
810
+
811
+ resp = self._interceptor.post_create_client_gateway(resp)
812
+ response_metadata = [(k, str(v)) for k, v in response.headers.items()]
813
+ resp, _ = self._interceptor.post_create_client_gateway_with_metadata(
814
+ resp, response_metadata
815
+ )
816
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
817
+ logging.DEBUG
818
+ ): # pragma: NO COVER
819
+ try:
820
+ response_payload = json_format.MessageToJson(resp)
821
+ except:
822
+ response_payload = None
823
+ http_response = {
824
+ "payload": response_payload,
825
+ "headers": dict(response.headers),
826
+ "status": response.status_code,
827
+ }
828
+ _LOGGER.debug(
829
+ "Received response for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.create_client_gateway",
830
+ extra={
831
+ "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService",
832
+ "rpcName": "CreateClientGateway",
833
+ "metadata": http_response["headers"],
834
+ "httpResponse": http_response,
835
+ },
836
+ )
837
+ return resp
838
+
839
+ class _DeleteClientGateway(
840
+ _BaseClientGatewaysServiceRestTransport._BaseDeleteClientGateway,
841
+ ClientGatewaysServiceRestStub,
842
+ ):
843
+ def __hash__(self):
844
+ return hash("ClientGatewaysServiceRestTransport.DeleteClientGateway")
845
+
846
+ @staticmethod
847
+ def _get_response(
848
+ host,
849
+ metadata,
850
+ query_params,
851
+ session,
852
+ timeout,
853
+ transcoded_request,
854
+ body=None,
855
+ ):
856
+ uri = transcoded_request["uri"]
857
+ method = transcoded_request["method"]
858
+ headers = dict(metadata)
859
+ headers["Content-Type"] = "application/json"
860
+ response = getattr(session, method)(
861
+ "{host}{uri}".format(host=host, uri=uri),
862
+ timeout=timeout,
863
+ headers=headers,
864
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
865
+ )
866
+ return response
867
+
868
+ def __call__(
869
+ self,
870
+ request: client_gateways_service.DeleteClientGatewayRequest,
871
+ *,
872
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
873
+ timeout: Optional[float] = None,
874
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
875
+ ) -> operations_pb2.Operation:
876
+ r"""Call the delete client gateway method over HTTP.
877
+
878
+ Args:
879
+ request (~.client_gateways_service.DeleteClientGatewayRequest):
880
+ The request object. Message for deleting a ClientGateway
881
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
882
+ should be retried.
883
+ timeout (float): The timeout for this request.
884
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
885
+ sent along with the request as metadata. Normally, each value must be of type `str`,
886
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
887
+ be of type `bytes`.
888
+
889
+ Returns:
890
+ ~.operations_pb2.Operation:
891
+ This resource represents a
892
+ long-running operation that is the
893
+ result of a network API call.
894
+
895
+ """
896
+
897
+ http_options = (
898
+ _BaseClientGatewaysServiceRestTransport._BaseDeleteClientGateway._get_http_options()
899
+ )
900
+
901
+ request, metadata = self._interceptor.pre_delete_client_gateway(
902
+ request, metadata
903
+ )
904
+ transcoded_request = _BaseClientGatewaysServiceRestTransport._BaseDeleteClientGateway._get_transcoded_request(
905
+ http_options, request
906
+ )
907
+
908
+ # Jsonify the query params
909
+ query_params = _BaseClientGatewaysServiceRestTransport._BaseDeleteClientGateway._get_query_params_json(
910
+ transcoded_request
911
+ )
912
+
913
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
914
+ logging.DEBUG
915
+ ): # pragma: NO COVER
916
+ request_url = "{host}{uri}".format(
917
+ host=self._host, uri=transcoded_request["uri"]
918
+ )
919
+ method = transcoded_request["method"]
920
+ try:
921
+ request_payload = json_format.MessageToJson(request)
922
+ except:
923
+ request_payload = None
924
+ http_request = {
925
+ "payload": request_payload,
926
+ "requestMethod": method,
927
+ "requestUrl": request_url,
928
+ "headers": dict(metadata),
929
+ }
930
+ _LOGGER.debug(
931
+ f"Sending request for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.DeleteClientGateway",
932
+ extra={
933
+ "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService",
934
+ "rpcName": "DeleteClientGateway",
935
+ "httpRequest": http_request,
936
+ "metadata": http_request["headers"],
937
+ },
938
+ )
939
+
940
+ # Send the request
941
+ response = (
942
+ ClientGatewaysServiceRestTransport._DeleteClientGateway._get_response(
943
+ self._host,
944
+ metadata,
945
+ query_params,
946
+ self._session,
947
+ timeout,
948
+ transcoded_request,
949
+ )
950
+ )
951
+
952
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
953
+ # subclass.
954
+ if response.status_code >= 400:
955
+ raise core_exceptions.from_http_response(response)
956
+
957
+ # Return the response
958
+ resp = operations_pb2.Operation()
959
+ json_format.Parse(response.content, resp, ignore_unknown_fields=True)
960
+
961
+ resp = self._interceptor.post_delete_client_gateway(resp)
962
+ response_metadata = [(k, str(v)) for k, v in response.headers.items()]
963
+ resp, _ = self._interceptor.post_delete_client_gateway_with_metadata(
964
+ resp, response_metadata
965
+ )
966
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
967
+ logging.DEBUG
968
+ ): # pragma: NO COVER
969
+ try:
970
+ response_payload = json_format.MessageToJson(resp)
971
+ except:
972
+ response_payload = None
973
+ http_response = {
974
+ "payload": response_payload,
975
+ "headers": dict(response.headers),
976
+ "status": response.status_code,
977
+ }
978
+ _LOGGER.debug(
979
+ "Received response for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.delete_client_gateway",
980
+ extra={
981
+ "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService",
982
+ "rpcName": "DeleteClientGateway",
983
+ "metadata": http_response["headers"],
984
+ "httpResponse": http_response,
985
+ },
986
+ )
987
+ return resp
988
+
989
+ class _GetClientGateway(
990
+ _BaseClientGatewaysServiceRestTransport._BaseGetClientGateway,
991
+ ClientGatewaysServiceRestStub,
992
+ ):
993
+ def __hash__(self):
994
+ return hash("ClientGatewaysServiceRestTransport.GetClientGateway")
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
+ )
1016
+ return response
1017
+
1018
+ def __call__(
1019
+ self,
1020
+ request: client_gateways_service.GetClientGatewayRequest,
1021
+ *,
1022
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1023
+ timeout: Optional[float] = None,
1024
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1025
+ ) -> client_gateways_service.ClientGateway:
1026
+ r"""Call the get client gateway method over HTTP.
1027
+
1028
+ Args:
1029
+ request (~.client_gateways_service.GetClientGatewayRequest):
1030
+ The request object. Message for getting a ClientGateway.
1031
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1032
+ should be retried.
1033
+ timeout (float): The timeout for this request.
1034
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1035
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1036
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1037
+ be of type `bytes`.
1038
+
1039
+ Returns:
1040
+ ~.client_gateways_service.ClientGateway:
1041
+ Message describing ClientGateway
1042
+ object.
1043
+
1044
+ """
1045
+
1046
+ http_options = (
1047
+ _BaseClientGatewaysServiceRestTransport._BaseGetClientGateway._get_http_options()
1048
+ )
1049
+
1050
+ request, metadata = self._interceptor.pre_get_client_gateway(
1051
+ request, metadata
1052
+ )
1053
+ transcoded_request = _BaseClientGatewaysServiceRestTransport._BaseGetClientGateway._get_transcoded_request(
1054
+ http_options, request
1055
+ )
1056
+
1057
+ # Jsonify the query params
1058
+ query_params = _BaseClientGatewaysServiceRestTransport._BaseGetClientGateway._get_query_params_json(
1059
+ transcoded_request
1060
+ )
1061
+
1062
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1063
+ logging.DEBUG
1064
+ ): # pragma: NO COVER
1065
+ request_url = "{host}{uri}".format(
1066
+ host=self._host, uri=transcoded_request["uri"]
1067
+ )
1068
+ method = transcoded_request["method"]
1069
+ try:
1070
+ request_payload = type(request).to_json(request)
1071
+ except:
1072
+ request_payload = None
1073
+ http_request = {
1074
+ "payload": request_payload,
1075
+ "requestMethod": method,
1076
+ "requestUrl": request_url,
1077
+ "headers": dict(metadata),
1078
+ }
1079
+ _LOGGER.debug(
1080
+ f"Sending request for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.GetClientGateway",
1081
+ extra={
1082
+ "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService",
1083
+ "rpcName": "GetClientGateway",
1084
+ "httpRequest": http_request,
1085
+ "metadata": http_request["headers"],
1086
+ },
1087
+ )
1088
+
1089
+ # Send the request
1090
+ response = (
1091
+ ClientGatewaysServiceRestTransport._GetClientGateway._get_response(
1092
+ self._host,
1093
+ metadata,
1094
+ query_params,
1095
+ self._session,
1096
+ timeout,
1097
+ transcoded_request,
1098
+ )
1099
+ )
1100
+
1101
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1102
+ # subclass.
1103
+ if response.status_code >= 400:
1104
+ raise core_exceptions.from_http_response(response)
1105
+
1106
+ # Return the response
1107
+ resp = client_gateways_service.ClientGateway()
1108
+ pb_resp = client_gateways_service.ClientGateway.pb(resp)
1109
+
1110
+ json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
1111
+
1112
+ resp = self._interceptor.post_get_client_gateway(resp)
1113
+ response_metadata = [(k, str(v)) for k, v in response.headers.items()]
1114
+ resp, _ = self._interceptor.post_get_client_gateway_with_metadata(
1115
+ resp, response_metadata
1116
+ )
1117
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1118
+ logging.DEBUG
1119
+ ): # pragma: NO COVER
1120
+ try:
1121
+ response_payload = client_gateways_service.ClientGateway.to_json(
1122
+ response
1123
+ )
1124
+ except:
1125
+ response_payload = None
1126
+ http_response = {
1127
+ "payload": response_payload,
1128
+ "headers": dict(response.headers),
1129
+ "status": response.status_code,
1130
+ }
1131
+ _LOGGER.debug(
1132
+ "Received response for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.get_client_gateway",
1133
+ extra={
1134
+ "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService",
1135
+ "rpcName": "GetClientGateway",
1136
+ "metadata": http_response["headers"],
1137
+ "httpResponse": http_response,
1138
+ },
1139
+ )
1140
+ return resp
1141
+
1142
+ class _ListClientGateways(
1143
+ _BaseClientGatewaysServiceRestTransport._BaseListClientGateways,
1144
+ ClientGatewaysServiceRestStub,
1145
+ ):
1146
+ def __hash__(self):
1147
+ return hash("ClientGatewaysServiceRestTransport.ListClientGateways")
1148
+
1149
+ @staticmethod
1150
+ def _get_response(
1151
+ host,
1152
+ metadata,
1153
+ query_params,
1154
+ session,
1155
+ timeout,
1156
+ transcoded_request,
1157
+ body=None,
1158
+ ):
1159
+ uri = transcoded_request["uri"]
1160
+ method = transcoded_request["method"]
1161
+ headers = dict(metadata)
1162
+ headers["Content-Type"] = "application/json"
1163
+ response = getattr(session, method)(
1164
+ "{host}{uri}".format(host=host, uri=uri),
1165
+ timeout=timeout,
1166
+ headers=headers,
1167
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1168
+ )
1169
+ return response
1170
+
1171
+ def __call__(
1172
+ self,
1173
+ request: client_gateways_service.ListClientGatewaysRequest,
1174
+ *,
1175
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1176
+ timeout: Optional[float] = None,
1177
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1178
+ ) -> client_gateways_service.ListClientGatewaysResponse:
1179
+ r"""Call the list client gateways method over HTTP.
1180
+
1181
+ Args:
1182
+ request (~.client_gateways_service.ListClientGatewaysRequest):
1183
+ The request object. Message for requesting list of
1184
+ ClientGateways.
1185
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1186
+ should be retried.
1187
+ timeout (float): The timeout for this request.
1188
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1189
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1190
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1191
+ be of type `bytes`.
1192
+
1193
+ Returns:
1194
+ ~.client_gateways_service.ListClientGatewaysResponse:
1195
+ Message for response to listing
1196
+ ClientGateways.
1197
+
1198
+ """
1199
+
1200
+ http_options = (
1201
+ _BaseClientGatewaysServiceRestTransport._BaseListClientGateways._get_http_options()
1202
+ )
1203
+
1204
+ request, metadata = self._interceptor.pre_list_client_gateways(
1205
+ request, metadata
1206
+ )
1207
+ transcoded_request = _BaseClientGatewaysServiceRestTransport._BaseListClientGateways._get_transcoded_request(
1208
+ http_options, request
1209
+ )
1210
+
1211
+ # Jsonify the query params
1212
+ query_params = _BaseClientGatewaysServiceRestTransport._BaseListClientGateways._get_query_params_json(
1213
+ transcoded_request
1214
+ )
1215
+
1216
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1217
+ logging.DEBUG
1218
+ ): # pragma: NO COVER
1219
+ request_url = "{host}{uri}".format(
1220
+ host=self._host, uri=transcoded_request["uri"]
1221
+ )
1222
+ method = transcoded_request["method"]
1223
+ try:
1224
+ request_payload = type(request).to_json(request)
1225
+ except:
1226
+ request_payload = None
1227
+ http_request = {
1228
+ "payload": request_payload,
1229
+ "requestMethod": method,
1230
+ "requestUrl": request_url,
1231
+ "headers": dict(metadata),
1232
+ }
1233
+ _LOGGER.debug(
1234
+ f"Sending request for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.ListClientGateways",
1235
+ extra={
1236
+ "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService",
1237
+ "rpcName": "ListClientGateways",
1238
+ "httpRequest": http_request,
1239
+ "metadata": http_request["headers"],
1240
+ },
1241
+ )
1242
+
1243
+ # Send the request
1244
+ response = (
1245
+ ClientGatewaysServiceRestTransport._ListClientGateways._get_response(
1246
+ self._host,
1247
+ metadata,
1248
+ query_params,
1249
+ self._session,
1250
+ timeout,
1251
+ transcoded_request,
1252
+ )
1253
+ )
1254
+
1255
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1256
+ # subclass.
1257
+ if response.status_code >= 400:
1258
+ raise core_exceptions.from_http_response(response)
1259
+
1260
+ # Return the response
1261
+ resp = client_gateways_service.ListClientGatewaysResponse()
1262
+ pb_resp = client_gateways_service.ListClientGatewaysResponse.pb(resp)
1263
+
1264
+ json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
1265
+
1266
+ resp = self._interceptor.post_list_client_gateways(resp)
1267
+ response_metadata = [(k, str(v)) for k, v in response.headers.items()]
1268
+ resp, _ = self._interceptor.post_list_client_gateways_with_metadata(
1269
+ resp, response_metadata
1270
+ )
1271
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1272
+ logging.DEBUG
1273
+ ): # pragma: NO COVER
1274
+ try:
1275
+ response_payload = (
1276
+ client_gateways_service.ListClientGatewaysResponse.to_json(
1277
+ response
1278
+ )
1279
+ )
1280
+ except:
1281
+ response_payload = None
1282
+ http_response = {
1283
+ "payload": response_payload,
1284
+ "headers": dict(response.headers),
1285
+ "status": response.status_code,
1286
+ }
1287
+ _LOGGER.debug(
1288
+ "Received response for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.list_client_gateways",
1289
+ extra={
1290
+ "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService",
1291
+ "rpcName": "ListClientGateways",
1292
+ "metadata": http_response["headers"],
1293
+ "httpResponse": http_response,
1294
+ },
1295
+ )
1296
+ return resp
1297
+
1298
+ @property
1299
+ def create_client_gateway(
1300
+ self,
1301
+ ) -> Callable[
1302
+ [client_gateways_service.CreateClientGatewayRequest], operations_pb2.Operation
1303
+ ]:
1304
+ # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
1305
+ # In C++ this would require a dynamic_cast
1306
+ return self._CreateClientGateway(self._session, self._host, self._interceptor) # type: ignore
1307
+
1308
+ @property
1309
+ def delete_client_gateway(
1310
+ self,
1311
+ ) -> Callable[
1312
+ [client_gateways_service.DeleteClientGatewayRequest], operations_pb2.Operation
1313
+ ]:
1314
+ # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
1315
+ # In C++ this would require a dynamic_cast
1316
+ return self._DeleteClientGateway(self._session, self._host, self._interceptor) # type: ignore
1317
+
1318
+ @property
1319
+ def get_client_gateway(
1320
+ self,
1321
+ ) -> Callable[
1322
+ [client_gateways_service.GetClientGatewayRequest],
1323
+ client_gateways_service.ClientGateway,
1324
+ ]:
1325
+ # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
1326
+ # In C++ this would require a dynamic_cast
1327
+ return self._GetClientGateway(self._session, self._host, self._interceptor) # type: ignore
1328
+
1329
+ @property
1330
+ def list_client_gateways(
1331
+ self,
1332
+ ) -> Callable[
1333
+ [client_gateways_service.ListClientGatewaysRequest],
1334
+ client_gateways_service.ListClientGatewaysResponse,
1335
+ ]:
1336
+ # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
1337
+ # In C++ this would require a dynamic_cast
1338
+ return self._ListClientGateways(self._session, self._host, self._interceptor) # type: ignore
1339
+
1340
+ @property
1341
+ def get_location(self):
1342
+ return self._GetLocation(self._session, self._host, self._interceptor) # type: ignore
1343
+
1344
+ class _GetLocation(
1345
+ _BaseClientGatewaysServiceRestTransport._BaseGetLocation,
1346
+ ClientGatewaysServiceRestStub,
1347
+ ):
1348
+ def __hash__(self):
1349
+ return hash("ClientGatewaysServiceRestTransport.GetLocation")
1350
+
1351
+ @staticmethod
1352
+ def _get_response(
1353
+ host,
1354
+ metadata,
1355
+ query_params,
1356
+ session,
1357
+ timeout,
1358
+ transcoded_request,
1359
+ body=None,
1360
+ ):
1361
+ uri = transcoded_request["uri"]
1362
+ method = transcoded_request["method"]
1363
+ headers = dict(metadata)
1364
+ headers["Content-Type"] = "application/json"
1365
+ response = getattr(session, method)(
1366
+ "{host}{uri}".format(host=host, uri=uri),
1367
+ timeout=timeout,
1368
+ headers=headers,
1369
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1370
+ )
1371
+ return response
1372
+
1373
+ def __call__(
1374
+ self,
1375
+ request: locations_pb2.GetLocationRequest,
1376
+ *,
1377
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1378
+ timeout: Optional[float] = None,
1379
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1380
+ ) -> locations_pb2.Location:
1381
+ r"""Call the get location method over HTTP.
1382
+
1383
+ Args:
1384
+ request (locations_pb2.GetLocationRequest):
1385
+ The request object for GetLocation method.
1386
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1387
+ should be retried.
1388
+ timeout (float): The timeout for this request.
1389
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1390
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1391
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1392
+ be of type `bytes`.
1393
+
1394
+ Returns:
1395
+ locations_pb2.Location: Response from GetLocation method.
1396
+ """
1397
+
1398
+ http_options = (
1399
+ _BaseClientGatewaysServiceRestTransport._BaseGetLocation._get_http_options()
1400
+ )
1401
+
1402
+ request, metadata = self._interceptor.pre_get_location(request, metadata)
1403
+ transcoded_request = _BaseClientGatewaysServiceRestTransport._BaseGetLocation._get_transcoded_request(
1404
+ http_options, request
1405
+ )
1406
+
1407
+ # Jsonify the query params
1408
+ query_params = _BaseClientGatewaysServiceRestTransport._BaseGetLocation._get_query_params_json(
1409
+ transcoded_request
1410
+ )
1411
+
1412
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1413
+ logging.DEBUG
1414
+ ): # pragma: NO COVER
1415
+ request_url = "{host}{uri}".format(
1416
+ host=self._host, uri=transcoded_request["uri"]
1417
+ )
1418
+ method = transcoded_request["method"]
1419
+ try:
1420
+ request_payload = json_format.MessageToJson(request)
1421
+ except:
1422
+ request_payload = None
1423
+ http_request = {
1424
+ "payload": request_payload,
1425
+ "requestMethod": method,
1426
+ "requestUrl": request_url,
1427
+ "headers": dict(metadata),
1428
+ }
1429
+ _LOGGER.debug(
1430
+ f"Sending request for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.GetLocation",
1431
+ extra={
1432
+ "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService",
1433
+ "rpcName": "GetLocation",
1434
+ "httpRequest": http_request,
1435
+ "metadata": http_request["headers"],
1436
+ },
1437
+ )
1438
+
1439
+ # Send the request
1440
+ response = ClientGatewaysServiceRestTransport._GetLocation._get_response(
1441
+ self._host,
1442
+ metadata,
1443
+ query_params,
1444
+ self._session,
1445
+ timeout,
1446
+ transcoded_request,
1447
+ )
1448
+
1449
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1450
+ # subclass.
1451
+ if response.status_code >= 400:
1452
+ raise core_exceptions.from_http_response(response)
1453
+
1454
+ content = response.content.decode("utf-8")
1455
+ resp = locations_pb2.Location()
1456
+ resp = json_format.Parse(content, resp)
1457
+ resp = self._interceptor.post_get_location(resp)
1458
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1459
+ logging.DEBUG
1460
+ ): # pragma: NO COVER
1461
+ try:
1462
+ response_payload = json_format.MessageToJson(resp)
1463
+ except:
1464
+ response_payload = None
1465
+ http_response = {
1466
+ "payload": response_payload,
1467
+ "headers": dict(response.headers),
1468
+ "status": response.status_code,
1469
+ }
1470
+ _LOGGER.debug(
1471
+ "Received response for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceAsyncClient.GetLocation",
1472
+ extra={
1473
+ "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService",
1474
+ "rpcName": "GetLocation",
1475
+ "httpResponse": http_response,
1476
+ "metadata": http_response["headers"],
1477
+ },
1478
+ )
1479
+ return resp
1480
+
1481
+ @property
1482
+ def list_locations(self):
1483
+ return self._ListLocations(self._session, self._host, self._interceptor) # type: ignore
1484
+
1485
+ class _ListLocations(
1486
+ _BaseClientGatewaysServiceRestTransport._BaseListLocations,
1487
+ ClientGatewaysServiceRestStub,
1488
+ ):
1489
+ def __hash__(self):
1490
+ return hash("ClientGatewaysServiceRestTransport.ListLocations")
1491
+
1492
+ @staticmethod
1493
+ def _get_response(
1494
+ host,
1495
+ metadata,
1496
+ query_params,
1497
+ session,
1498
+ timeout,
1499
+ transcoded_request,
1500
+ body=None,
1501
+ ):
1502
+ uri = transcoded_request["uri"]
1503
+ method = transcoded_request["method"]
1504
+ headers = dict(metadata)
1505
+ headers["Content-Type"] = "application/json"
1506
+ response = getattr(session, method)(
1507
+ "{host}{uri}".format(host=host, uri=uri),
1508
+ timeout=timeout,
1509
+ headers=headers,
1510
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1511
+ )
1512
+ return response
1513
+
1514
+ def __call__(
1515
+ self,
1516
+ request: locations_pb2.ListLocationsRequest,
1517
+ *,
1518
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1519
+ timeout: Optional[float] = None,
1520
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1521
+ ) -> locations_pb2.ListLocationsResponse:
1522
+ r"""Call the list locations method over HTTP.
1523
+
1524
+ Args:
1525
+ request (locations_pb2.ListLocationsRequest):
1526
+ The request object for ListLocations method.
1527
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1528
+ should be retried.
1529
+ timeout (float): The timeout for this request.
1530
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1531
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1532
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1533
+ be of type `bytes`.
1534
+
1535
+ Returns:
1536
+ locations_pb2.ListLocationsResponse: Response from ListLocations method.
1537
+ """
1538
+
1539
+ http_options = (
1540
+ _BaseClientGatewaysServiceRestTransport._BaseListLocations._get_http_options()
1541
+ )
1542
+
1543
+ request, metadata = self._interceptor.pre_list_locations(request, metadata)
1544
+ transcoded_request = _BaseClientGatewaysServiceRestTransport._BaseListLocations._get_transcoded_request(
1545
+ http_options, request
1546
+ )
1547
+
1548
+ # Jsonify the query params
1549
+ query_params = _BaseClientGatewaysServiceRestTransport._BaseListLocations._get_query_params_json(
1550
+ transcoded_request
1551
+ )
1552
+
1553
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1554
+ logging.DEBUG
1555
+ ): # pragma: NO COVER
1556
+ request_url = "{host}{uri}".format(
1557
+ host=self._host, uri=transcoded_request["uri"]
1558
+ )
1559
+ method = transcoded_request["method"]
1560
+ try:
1561
+ request_payload = json_format.MessageToJson(request)
1562
+ except:
1563
+ request_payload = None
1564
+ http_request = {
1565
+ "payload": request_payload,
1566
+ "requestMethod": method,
1567
+ "requestUrl": request_url,
1568
+ "headers": dict(metadata),
1569
+ }
1570
+ _LOGGER.debug(
1571
+ f"Sending request for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.ListLocations",
1572
+ extra={
1573
+ "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService",
1574
+ "rpcName": "ListLocations",
1575
+ "httpRequest": http_request,
1576
+ "metadata": http_request["headers"],
1577
+ },
1578
+ )
1579
+
1580
+ # Send the request
1581
+ response = ClientGatewaysServiceRestTransport._ListLocations._get_response(
1582
+ self._host,
1583
+ metadata,
1584
+ query_params,
1585
+ self._session,
1586
+ timeout,
1587
+ transcoded_request,
1588
+ )
1589
+
1590
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1591
+ # subclass.
1592
+ if response.status_code >= 400:
1593
+ raise core_exceptions.from_http_response(response)
1594
+
1595
+ content = response.content.decode("utf-8")
1596
+ resp = locations_pb2.ListLocationsResponse()
1597
+ resp = json_format.Parse(content, resp)
1598
+ resp = self._interceptor.post_list_locations(resp)
1599
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1600
+ logging.DEBUG
1601
+ ): # pragma: NO COVER
1602
+ try:
1603
+ response_payload = json_format.MessageToJson(resp)
1604
+ except:
1605
+ response_payload = None
1606
+ http_response = {
1607
+ "payload": response_payload,
1608
+ "headers": dict(response.headers),
1609
+ "status": response.status_code,
1610
+ }
1611
+ _LOGGER.debug(
1612
+ "Received response for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceAsyncClient.ListLocations",
1613
+ extra={
1614
+ "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService",
1615
+ "rpcName": "ListLocations",
1616
+ "httpResponse": http_response,
1617
+ "metadata": http_response["headers"],
1618
+ },
1619
+ )
1620
+ return resp
1621
+
1622
+ @property
1623
+ def get_iam_policy(self):
1624
+ return self._GetIamPolicy(self._session, self._host, self._interceptor) # type: ignore
1625
+
1626
+ class _GetIamPolicy(
1627
+ _BaseClientGatewaysServiceRestTransport._BaseGetIamPolicy,
1628
+ ClientGatewaysServiceRestStub,
1629
+ ):
1630
+ def __hash__(self):
1631
+ return hash("ClientGatewaysServiceRestTransport.GetIamPolicy")
1632
+
1633
+ @staticmethod
1634
+ def _get_response(
1635
+ host,
1636
+ metadata,
1637
+ query_params,
1638
+ session,
1639
+ timeout,
1640
+ transcoded_request,
1641
+ body=None,
1642
+ ):
1643
+ uri = transcoded_request["uri"]
1644
+ method = transcoded_request["method"]
1645
+ headers = dict(metadata)
1646
+ headers["Content-Type"] = "application/json"
1647
+ response = getattr(session, method)(
1648
+ "{host}{uri}".format(host=host, uri=uri),
1649
+ timeout=timeout,
1650
+ headers=headers,
1651
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1652
+ )
1653
+ return response
1654
+
1655
+ def __call__(
1656
+ self,
1657
+ request: iam_policy_pb2.GetIamPolicyRequest,
1658
+ *,
1659
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1660
+ timeout: Optional[float] = None,
1661
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1662
+ ) -> policy_pb2.Policy:
1663
+ r"""Call the get iam policy method over HTTP.
1664
+
1665
+ Args:
1666
+ request (iam_policy_pb2.GetIamPolicyRequest):
1667
+ The request object for GetIamPolicy method.
1668
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1669
+ should be retried.
1670
+ timeout (float): The timeout for this request.
1671
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1672
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1673
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1674
+ be of type `bytes`.
1675
+
1676
+ Returns:
1677
+ policy_pb2.Policy: Response from GetIamPolicy method.
1678
+ """
1679
+
1680
+ http_options = (
1681
+ _BaseClientGatewaysServiceRestTransport._BaseGetIamPolicy._get_http_options()
1682
+ )
1683
+
1684
+ request, metadata = self._interceptor.pre_get_iam_policy(request, metadata)
1685
+ transcoded_request = _BaseClientGatewaysServiceRestTransport._BaseGetIamPolicy._get_transcoded_request(
1686
+ http_options, request
1687
+ )
1688
+
1689
+ # Jsonify the query params
1690
+ query_params = _BaseClientGatewaysServiceRestTransport._BaseGetIamPolicy._get_query_params_json(
1691
+ transcoded_request
1692
+ )
1693
+
1694
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1695
+ logging.DEBUG
1696
+ ): # pragma: NO COVER
1697
+ request_url = "{host}{uri}".format(
1698
+ host=self._host, uri=transcoded_request["uri"]
1699
+ )
1700
+ method = transcoded_request["method"]
1701
+ try:
1702
+ request_payload = json_format.MessageToJson(request)
1703
+ except:
1704
+ request_payload = None
1705
+ http_request = {
1706
+ "payload": request_payload,
1707
+ "requestMethod": method,
1708
+ "requestUrl": request_url,
1709
+ "headers": dict(metadata),
1710
+ }
1711
+ _LOGGER.debug(
1712
+ f"Sending request for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.GetIamPolicy",
1713
+ extra={
1714
+ "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService",
1715
+ "rpcName": "GetIamPolicy",
1716
+ "httpRequest": http_request,
1717
+ "metadata": http_request["headers"],
1718
+ },
1719
+ )
1720
+
1721
+ # Send the request
1722
+ response = ClientGatewaysServiceRestTransport._GetIamPolicy._get_response(
1723
+ self._host,
1724
+ metadata,
1725
+ query_params,
1726
+ self._session,
1727
+ timeout,
1728
+ transcoded_request,
1729
+ )
1730
+
1731
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1732
+ # subclass.
1733
+ if response.status_code >= 400:
1734
+ raise core_exceptions.from_http_response(response)
1735
+
1736
+ content = response.content.decode("utf-8")
1737
+ resp = policy_pb2.Policy()
1738
+ resp = json_format.Parse(content, resp)
1739
+ resp = self._interceptor.post_get_iam_policy(resp)
1740
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1741
+ logging.DEBUG
1742
+ ): # pragma: NO COVER
1743
+ try:
1744
+ response_payload = json_format.MessageToJson(resp)
1745
+ except:
1746
+ response_payload = None
1747
+ http_response = {
1748
+ "payload": response_payload,
1749
+ "headers": dict(response.headers),
1750
+ "status": response.status_code,
1751
+ }
1752
+ _LOGGER.debug(
1753
+ "Received response for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceAsyncClient.GetIamPolicy",
1754
+ extra={
1755
+ "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService",
1756
+ "rpcName": "GetIamPolicy",
1757
+ "httpResponse": http_response,
1758
+ "metadata": http_response["headers"],
1759
+ },
1760
+ )
1761
+ return resp
1762
+
1763
+ @property
1764
+ def set_iam_policy(self):
1765
+ return self._SetIamPolicy(self._session, self._host, self._interceptor) # type: ignore
1766
+
1767
+ class _SetIamPolicy(
1768
+ _BaseClientGatewaysServiceRestTransport._BaseSetIamPolicy,
1769
+ ClientGatewaysServiceRestStub,
1770
+ ):
1771
+ def __hash__(self):
1772
+ return hash("ClientGatewaysServiceRestTransport.SetIamPolicy")
1773
+
1774
+ @staticmethod
1775
+ def _get_response(
1776
+ host,
1777
+ metadata,
1778
+ query_params,
1779
+ session,
1780
+ timeout,
1781
+ transcoded_request,
1782
+ body=None,
1783
+ ):
1784
+ uri = transcoded_request["uri"]
1785
+ method = transcoded_request["method"]
1786
+ headers = dict(metadata)
1787
+ headers["Content-Type"] = "application/json"
1788
+ response = getattr(session, method)(
1789
+ "{host}{uri}".format(host=host, uri=uri),
1790
+ timeout=timeout,
1791
+ headers=headers,
1792
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1793
+ data=body,
1794
+ )
1795
+ return response
1796
+
1797
+ def __call__(
1798
+ self,
1799
+ request: iam_policy_pb2.SetIamPolicyRequest,
1800
+ *,
1801
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1802
+ timeout: Optional[float] = None,
1803
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1804
+ ) -> policy_pb2.Policy:
1805
+ r"""Call the set iam policy method over HTTP.
1806
+
1807
+ Args:
1808
+ request (iam_policy_pb2.SetIamPolicyRequest):
1809
+ The request object for SetIamPolicy method.
1810
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1811
+ should be retried.
1812
+ timeout (float): The timeout for this request.
1813
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1814
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1815
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1816
+ be of type `bytes`.
1817
+
1818
+ Returns:
1819
+ policy_pb2.Policy: Response from SetIamPolicy method.
1820
+ """
1821
+
1822
+ http_options = (
1823
+ _BaseClientGatewaysServiceRestTransport._BaseSetIamPolicy._get_http_options()
1824
+ )
1825
+
1826
+ request, metadata = self._interceptor.pre_set_iam_policy(request, metadata)
1827
+ transcoded_request = _BaseClientGatewaysServiceRestTransport._BaseSetIamPolicy._get_transcoded_request(
1828
+ http_options, request
1829
+ )
1830
+
1831
+ body = _BaseClientGatewaysServiceRestTransport._BaseSetIamPolicy._get_request_body_json(
1832
+ transcoded_request
1833
+ )
1834
+
1835
+ # Jsonify the query params
1836
+ query_params = _BaseClientGatewaysServiceRestTransport._BaseSetIamPolicy._get_query_params_json(
1837
+ transcoded_request
1838
+ )
1839
+
1840
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1841
+ logging.DEBUG
1842
+ ): # pragma: NO COVER
1843
+ request_url = "{host}{uri}".format(
1844
+ host=self._host, uri=transcoded_request["uri"]
1845
+ )
1846
+ method = transcoded_request["method"]
1847
+ try:
1848
+ request_payload = json_format.MessageToJson(request)
1849
+ except:
1850
+ request_payload = None
1851
+ http_request = {
1852
+ "payload": request_payload,
1853
+ "requestMethod": method,
1854
+ "requestUrl": request_url,
1855
+ "headers": dict(metadata),
1856
+ }
1857
+ _LOGGER.debug(
1858
+ f"Sending request for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.SetIamPolicy",
1859
+ extra={
1860
+ "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService",
1861
+ "rpcName": "SetIamPolicy",
1862
+ "httpRequest": http_request,
1863
+ "metadata": http_request["headers"],
1864
+ },
1865
+ )
1866
+
1867
+ # Send the request
1868
+ response = ClientGatewaysServiceRestTransport._SetIamPolicy._get_response(
1869
+ self._host,
1870
+ metadata,
1871
+ query_params,
1872
+ self._session,
1873
+ timeout,
1874
+ transcoded_request,
1875
+ body,
1876
+ )
1877
+
1878
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1879
+ # subclass.
1880
+ if response.status_code >= 400:
1881
+ raise core_exceptions.from_http_response(response)
1882
+
1883
+ content = response.content.decode("utf-8")
1884
+ resp = policy_pb2.Policy()
1885
+ resp = json_format.Parse(content, resp)
1886
+ resp = self._interceptor.post_set_iam_policy(resp)
1887
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1888
+ logging.DEBUG
1889
+ ): # pragma: NO COVER
1890
+ try:
1891
+ response_payload = json_format.MessageToJson(resp)
1892
+ except:
1893
+ response_payload = None
1894
+ http_response = {
1895
+ "payload": response_payload,
1896
+ "headers": dict(response.headers),
1897
+ "status": response.status_code,
1898
+ }
1899
+ _LOGGER.debug(
1900
+ "Received response for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceAsyncClient.SetIamPolicy",
1901
+ extra={
1902
+ "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService",
1903
+ "rpcName": "SetIamPolicy",
1904
+ "httpResponse": http_response,
1905
+ "metadata": http_response["headers"],
1906
+ },
1907
+ )
1908
+ return resp
1909
+
1910
+ @property
1911
+ def test_iam_permissions(self):
1912
+ return self._TestIamPermissions(self._session, self._host, self._interceptor) # type: ignore
1913
+
1914
+ class _TestIamPermissions(
1915
+ _BaseClientGatewaysServiceRestTransport._BaseTestIamPermissions,
1916
+ ClientGatewaysServiceRestStub,
1917
+ ):
1918
+ def __hash__(self):
1919
+ return hash("ClientGatewaysServiceRestTransport.TestIamPermissions")
1920
+
1921
+ @staticmethod
1922
+ def _get_response(
1923
+ host,
1924
+ metadata,
1925
+ query_params,
1926
+ session,
1927
+ timeout,
1928
+ transcoded_request,
1929
+ body=None,
1930
+ ):
1931
+ uri = transcoded_request["uri"]
1932
+ method = transcoded_request["method"]
1933
+ headers = dict(metadata)
1934
+ headers["Content-Type"] = "application/json"
1935
+ response = getattr(session, method)(
1936
+ "{host}{uri}".format(host=host, uri=uri),
1937
+ timeout=timeout,
1938
+ headers=headers,
1939
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1940
+ data=body,
1941
+ )
1942
+ return response
1943
+
1944
+ def __call__(
1945
+ self,
1946
+ request: iam_policy_pb2.TestIamPermissionsRequest,
1947
+ *,
1948
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1949
+ timeout: Optional[float] = None,
1950
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1951
+ ) -> iam_policy_pb2.TestIamPermissionsResponse:
1952
+ r"""Call the test iam permissions method over HTTP.
1953
+
1954
+ Args:
1955
+ request (iam_policy_pb2.TestIamPermissionsRequest):
1956
+ The request object for TestIamPermissions method.
1957
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1958
+ should be retried.
1959
+ timeout (float): The timeout for this request.
1960
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1961
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1962
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1963
+ be of type `bytes`.
1964
+
1965
+ Returns:
1966
+ iam_policy_pb2.TestIamPermissionsResponse: Response from TestIamPermissions method.
1967
+ """
1968
+
1969
+ http_options = (
1970
+ _BaseClientGatewaysServiceRestTransport._BaseTestIamPermissions._get_http_options()
1971
+ )
1972
+
1973
+ request, metadata = self._interceptor.pre_test_iam_permissions(
1974
+ request, metadata
1975
+ )
1976
+ transcoded_request = _BaseClientGatewaysServiceRestTransport._BaseTestIamPermissions._get_transcoded_request(
1977
+ http_options, request
1978
+ )
1979
+
1980
+ body = _BaseClientGatewaysServiceRestTransport._BaseTestIamPermissions._get_request_body_json(
1981
+ transcoded_request
1982
+ )
1983
+
1984
+ # Jsonify the query params
1985
+ query_params = _BaseClientGatewaysServiceRestTransport._BaseTestIamPermissions._get_query_params_json(
1986
+ transcoded_request
1987
+ )
1988
+
1989
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1990
+ logging.DEBUG
1991
+ ): # pragma: NO COVER
1992
+ request_url = "{host}{uri}".format(
1993
+ host=self._host, uri=transcoded_request["uri"]
1994
+ )
1995
+ method = transcoded_request["method"]
1996
+ try:
1997
+ request_payload = json_format.MessageToJson(request)
1998
+ except:
1999
+ request_payload = None
2000
+ http_request = {
2001
+ "payload": request_payload,
2002
+ "requestMethod": method,
2003
+ "requestUrl": request_url,
2004
+ "headers": dict(metadata),
2005
+ }
2006
+ _LOGGER.debug(
2007
+ f"Sending request for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.TestIamPermissions",
2008
+ extra={
2009
+ "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService",
2010
+ "rpcName": "TestIamPermissions",
2011
+ "httpRequest": http_request,
2012
+ "metadata": http_request["headers"],
2013
+ },
2014
+ )
2015
+
2016
+ # Send the request
2017
+ response = (
2018
+ ClientGatewaysServiceRestTransport._TestIamPermissions._get_response(
2019
+ self._host,
2020
+ metadata,
2021
+ query_params,
2022
+ self._session,
2023
+ timeout,
2024
+ transcoded_request,
2025
+ body,
2026
+ )
2027
+ )
2028
+
2029
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
2030
+ # subclass.
2031
+ if response.status_code >= 400:
2032
+ raise core_exceptions.from_http_response(response)
2033
+
2034
+ content = response.content.decode("utf-8")
2035
+ resp = iam_policy_pb2.TestIamPermissionsResponse()
2036
+ resp = json_format.Parse(content, resp)
2037
+ resp = self._interceptor.post_test_iam_permissions(resp)
2038
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
2039
+ logging.DEBUG
2040
+ ): # pragma: NO COVER
2041
+ try:
2042
+ response_payload = json_format.MessageToJson(resp)
2043
+ except:
2044
+ response_payload = None
2045
+ http_response = {
2046
+ "payload": response_payload,
2047
+ "headers": dict(response.headers),
2048
+ "status": response.status_code,
2049
+ }
2050
+ _LOGGER.debug(
2051
+ "Received response for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceAsyncClient.TestIamPermissions",
2052
+ extra={
2053
+ "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService",
2054
+ "rpcName": "TestIamPermissions",
2055
+ "httpResponse": http_response,
2056
+ "metadata": http_response["headers"],
2057
+ },
2058
+ )
2059
+ return resp
2060
+
2061
+ @property
2062
+ def cancel_operation(self):
2063
+ return self._CancelOperation(self._session, self._host, self._interceptor) # type: ignore
2064
+
2065
+ class _CancelOperation(
2066
+ _BaseClientGatewaysServiceRestTransport._BaseCancelOperation,
2067
+ ClientGatewaysServiceRestStub,
2068
+ ):
2069
+ def __hash__(self):
2070
+ return hash("ClientGatewaysServiceRestTransport.CancelOperation")
2071
+
2072
+ @staticmethod
2073
+ def _get_response(
2074
+ host,
2075
+ metadata,
2076
+ query_params,
2077
+ session,
2078
+ timeout,
2079
+ transcoded_request,
2080
+ body=None,
2081
+ ):
2082
+ uri = transcoded_request["uri"]
2083
+ method = transcoded_request["method"]
2084
+ headers = dict(metadata)
2085
+ headers["Content-Type"] = "application/json"
2086
+ response = getattr(session, method)(
2087
+ "{host}{uri}".format(host=host, uri=uri),
2088
+ timeout=timeout,
2089
+ headers=headers,
2090
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
2091
+ data=body,
2092
+ )
2093
+ return response
2094
+
2095
+ def __call__(
2096
+ self,
2097
+ request: operations_pb2.CancelOperationRequest,
2098
+ *,
2099
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2100
+ timeout: Optional[float] = None,
2101
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2102
+ ) -> None:
2103
+ r"""Call the cancel operation method over HTTP.
2104
+
2105
+ Args:
2106
+ request (operations_pb2.CancelOperationRequest):
2107
+ The request object for CancelOperation method.
2108
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
2109
+ should be retried.
2110
+ timeout (float): The timeout for this request.
2111
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2112
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2113
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2114
+ be of type `bytes`.
2115
+ """
2116
+
2117
+ http_options = (
2118
+ _BaseClientGatewaysServiceRestTransport._BaseCancelOperation._get_http_options()
2119
+ )
2120
+
2121
+ request, metadata = self._interceptor.pre_cancel_operation(
2122
+ request, metadata
2123
+ )
2124
+ transcoded_request = _BaseClientGatewaysServiceRestTransport._BaseCancelOperation._get_transcoded_request(
2125
+ http_options, request
2126
+ )
2127
+
2128
+ body = _BaseClientGatewaysServiceRestTransport._BaseCancelOperation._get_request_body_json(
2129
+ transcoded_request
2130
+ )
2131
+
2132
+ # Jsonify the query params
2133
+ query_params = _BaseClientGatewaysServiceRestTransport._BaseCancelOperation._get_query_params_json(
2134
+ transcoded_request
2135
+ )
2136
+
2137
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
2138
+ logging.DEBUG
2139
+ ): # pragma: NO COVER
2140
+ request_url = "{host}{uri}".format(
2141
+ host=self._host, uri=transcoded_request["uri"]
2142
+ )
2143
+ method = transcoded_request["method"]
2144
+ try:
2145
+ request_payload = json_format.MessageToJson(request)
2146
+ except:
2147
+ request_payload = None
2148
+ http_request = {
2149
+ "payload": request_payload,
2150
+ "requestMethod": method,
2151
+ "requestUrl": request_url,
2152
+ "headers": dict(metadata),
2153
+ }
2154
+ _LOGGER.debug(
2155
+ f"Sending request for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.CancelOperation",
2156
+ extra={
2157
+ "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService",
2158
+ "rpcName": "CancelOperation",
2159
+ "httpRequest": http_request,
2160
+ "metadata": http_request["headers"],
2161
+ },
2162
+ )
2163
+
2164
+ # Send the request
2165
+ response = (
2166
+ ClientGatewaysServiceRestTransport._CancelOperation._get_response(
2167
+ self._host,
2168
+ metadata,
2169
+ query_params,
2170
+ self._session,
2171
+ timeout,
2172
+ transcoded_request,
2173
+ body,
2174
+ )
2175
+ )
2176
+
2177
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
2178
+ # subclass.
2179
+ if response.status_code >= 400:
2180
+ raise core_exceptions.from_http_response(response)
2181
+
2182
+ return self._interceptor.post_cancel_operation(None)
2183
+
2184
+ @property
2185
+ def delete_operation(self):
2186
+ return self._DeleteOperation(self._session, self._host, self._interceptor) # type: ignore
2187
+
2188
+ class _DeleteOperation(
2189
+ _BaseClientGatewaysServiceRestTransport._BaseDeleteOperation,
2190
+ ClientGatewaysServiceRestStub,
2191
+ ):
2192
+ def __hash__(self):
2193
+ return hash("ClientGatewaysServiceRestTransport.DeleteOperation")
2194
+
2195
+ @staticmethod
2196
+ def _get_response(
2197
+ host,
2198
+ metadata,
2199
+ query_params,
2200
+ session,
2201
+ timeout,
2202
+ transcoded_request,
2203
+ body=None,
2204
+ ):
2205
+ uri = transcoded_request["uri"]
2206
+ method = transcoded_request["method"]
2207
+ headers = dict(metadata)
2208
+ headers["Content-Type"] = "application/json"
2209
+ response = getattr(session, method)(
2210
+ "{host}{uri}".format(host=host, uri=uri),
2211
+ timeout=timeout,
2212
+ headers=headers,
2213
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
2214
+ )
2215
+ return response
2216
+
2217
+ def __call__(
2218
+ self,
2219
+ request: operations_pb2.DeleteOperationRequest,
2220
+ *,
2221
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2222
+ timeout: Optional[float] = None,
2223
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2224
+ ) -> None:
2225
+ r"""Call the delete operation method over HTTP.
2226
+
2227
+ Args:
2228
+ request (operations_pb2.DeleteOperationRequest):
2229
+ The request object for DeleteOperation method.
2230
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
2231
+ should be retried.
2232
+ timeout (float): The timeout for this request.
2233
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2234
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2235
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2236
+ be of type `bytes`.
2237
+ """
2238
+
2239
+ http_options = (
2240
+ _BaseClientGatewaysServiceRestTransport._BaseDeleteOperation._get_http_options()
2241
+ )
2242
+
2243
+ request, metadata = self._interceptor.pre_delete_operation(
2244
+ request, metadata
2245
+ )
2246
+ transcoded_request = _BaseClientGatewaysServiceRestTransport._BaseDeleteOperation._get_transcoded_request(
2247
+ http_options, request
2248
+ )
2249
+
2250
+ # Jsonify the query params
2251
+ query_params = _BaseClientGatewaysServiceRestTransport._BaseDeleteOperation._get_query_params_json(
2252
+ transcoded_request
2253
+ )
2254
+
2255
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
2256
+ logging.DEBUG
2257
+ ): # pragma: NO COVER
2258
+ request_url = "{host}{uri}".format(
2259
+ host=self._host, uri=transcoded_request["uri"]
2260
+ )
2261
+ method = transcoded_request["method"]
2262
+ try:
2263
+ request_payload = json_format.MessageToJson(request)
2264
+ except:
2265
+ request_payload = None
2266
+ http_request = {
2267
+ "payload": request_payload,
2268
+ "requestMethod": method,
2269
+ "requestUrl": request_url,
2270
+ "headers": dict(metadata),
2271
+ }
2272
+ _LOGGER.debug(
2273
+ f"Sending request for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.DeleteOperation",
2274
+ extra={
2275
+ "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService",
2276
+ "rpcName": "DeleteOperation",
2277
+ "httpRequest": http_request,
2278
+ "metadata": http_request["headers"],
2279
+ },
2280
+ )
2281
+
2282
+ # Send the request
2283
+ response = (
2284
+ ClientGatewaysServiceRestTransport._DeleteOperation._get_response(
2285
+ self._host,
2286
+ metadata,
2287
+ query_params,
2288
+ self._session,
2289
+ timeout,
2290
+ transcoded_request,
2291
+ )
2292
+ )
2293
+
2294
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
2295
+ # subclass.
2296
+ if response.status_code >= 400:
2297
+ raise core_exceptions.from_http_response(response)
2298
+
2299
+ return self._interceptor.post_delete_operation(None)
2300
+
2301
+ @property
2302
+ def get_operation(self):
2303
+ return self._GetOperation(self._session, self._host, self._interceptor) # type: ignore
2304
+
2305
+ class _GetOperation(
2306
+ _BaseClientGatewaysServiceRestTransport._BaseGetOperation,
2307
+ ClientGatewaysServiceRestStub,
2308
+ ):
2309
+ def __hash__(self):
2310
+ return hash("ClientGatewaysServiceRestTransport.GetOperation")
2311
+
2312
+ @staticmethod
2313
+ def _get_response(
2314
+ host,
2315
+ metadata,
2316
+ query_params,
2317
+ session,
2318
+ timeout,
2319
+ transcoded_request,
2320
+ body=None,
2321
+ ):
2322
+ uri = transcoded_request["uri"]
2323
+ method = transcoded_request["method"]
2324
+ headers = dict(metadata)
2325
+ headers["Content-Type"] = "application/json"
2326
+ response = getattr(session, method)(
2327
+ "{host}{uri}".format(host=host, uri=uri),
2328
+ timeout=timeout,
2329
+ headers=headers,
2330
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
2331
+ )
2332
+ return response
2333
+
2334
+ def __call__(
2335
+ self,
2336
+ request: operations_pb2.GetOperationRequest,
2337
+ *,
2338
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2339
+ timeout: Optional[float] = None,
2340
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2341
+ ) -> operations_pb2.Operation:
2342
+ r"""Call the get operation method over HTTP.
2343
+
2344
+ Args:
2345
+ request (operations_pb2.GetOperationRequest):
2346
+ The request object for GetOperation method.
2347
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
2348
+ should be retried.
2349
+ timeout (float): The timeout for this request.
2350
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2351
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2352
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2353
+ be of type `bytes`.
2354
+
2355
+ Returns:
2356
+ operations_pb2.Operation: Response from GetOperation method.
2357
+ """
2358
+
2359
+ http_options = (
2360
+ _BaseClientGatewaysServiceRestTransport._BaseGetOperation._get_http_options()
2361
+ )
2362
+
2363
+ request, metadata = self._interceptor.pre_get_operation(request, metadata)
2364
+ transcoded_request = _BaseClientGatewaysServiceRestTransport._BaseGetOperation._get_transcoded_request(
2365
+ http_options, request
2366
+ )
2367
+
2368
+ # Jsonify the query params
2369
+ query_params = _BaseClientGatewaysServiceRestTransport._BaseGetOperation._get_query_params_json(
2370
+ transcoded_request
2371
+ )
2372
+
2373
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
2374
+ logging.DEBUG
2375
+ ): # pragma: NO COVER
2376
+ request_url = "{host}{uri}".format(
2377
+ host=self._host, uri=transcoded_request["uri"]
2378
+ )
2379
+ method = transcoded_request["method"]
2380
+ try:
2381
+ request_payload = json_format.MessageToJson(request)
2382
+ except:
2383
+ request_payload = None
2384
+ http_request = {
2385
+ "payload": request_payload,
2386
+ "requestMethod": method,
2387
+ "requestUrl": request_url,
2388
+ "headers": dict(metadata),
2389
+ }
2390
+ _LOGGER.debug(
2391
+ f"Sending request for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.GetOperation",
2392
+ extra={
2393
+ "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService",
2394
+ "rpcName": "GetOperation",
2395
+ "httpRequest": http_request,
2396
+ "metadata": http_request["headers"],
2397
+ },
2398
+ )
2399
+
2400
+ # Send the request
2401
+ response = ClientGatewaysServiceRestTransport._GetOperation._get_response(
2402
+ self._host,
2403
+ metadata,
2404
+ query_params,
2405
+ self._session,
2406
+ timeout,
2407
+ transcoded_request,
2408
+ )
2409
+
2410
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
2411
+ # subclass.
2412
+ if response.status_code >= 400:
2413
+ raise core_exceptions.from_http_response(response)
2414
+
2415
+ content = response.content.decode("utf-8")
2416
+ resp = operations_pb2.Operation()
2417
+ resp = json_format.Parse(content, resp)
2418
+ resp = self._interceptor.post_get_operation(resp)
2419
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
2420
+ logging.DEBUG
2421
+ ): # pragma: NO COVER
2422
+ try:
2423
+ response_payload = json_format.MessageToJson(resp)
2424
+ except:
2425
+ response_payload = None
2426
+ http_response = {
2427
+ "payload": response_payload,
2428
+ "headers": dict(response.headers),
2429
+ "status": response.status_code,
2430
+ }
2431
+ _LOGGER.debug(
2432
+ "Received response for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceAsyncClient.GetOperation",
2433
+ extra={
2434
+ "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService",
2435
+ "rpcName": "GetOperation",
2436
+ "httpResponse": http_response,
2437
+ "metadata": http_response["headers"],
2438
+ },
2439
+ )
2440
+ return resp
2441
+
2442
+ @property
2443
+ def list_operations(self):
2444
+ return self._ListOperations(self._session, self._host, self._interceptor) # type: ignore
2445
+
2446
+ class _ListOperations(
2447
+ _BaseClientGatewaysServiceRestTransport._BaseListOperations,
2448
+ ClientGatewaysServiceRestStub,
2449
+ ):
2450
+ def __hash__(self):
2451
+ return hash("ClientGatewaysServiceRestTransport.ListOperations")
2452
+
2453
+ @staticmethod
2454
+ def _get_response(
2455
+ host,
2456
+ metadata,
2457
+ query_params,
2458
+ session,
2459
+ timeout,
2460
+ transcoded_request,
2461
+ body=None,
2462
+ ):
2463
+ uri = transcoded_request["uri"]
2464
+ method = transcoded_request["method"]
2465
+ headers = dict(metadata)
2466
+ headers["Content-Type"] = "application/json"
2467
+ response = getattr(session, method)(
2468
+ "{host}{uri}".format(host=host, uri=uri),
2469
+ timeout=timeout,
2470
+ headers=headers,
2471
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
2472
+ )
2473
+ return response
2474
+
2475
+ def __call__(
2476
+ self,
2477
+ request: operations_pb2.ListOperationsRequest,
2478
+ *,
2479
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
2480
+ timeout: Optional[float] = None,
2481
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
2482
+ ) -> operations_pb2.ListOperationsResponse:
2483
+ r"""Call the list operations method over HTTP.
2484
+
2485
+ Args:
2486
+ request (operations_pb2.ListOperationsRequest):
2487
+ The request object for ListOperations method.
2488
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
2489
+ should be retried.
2490
+ timeout (float): The timeout for this request.
2491
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
2492
+ sent along with the request as metadata. Normally, each value must be of type `str`,
2493
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
2494
+ be of type `bytes`.
2495
+
2496
+ Returns:
2497
+ operations_pb2.ListOperationsResponse: Response from ListOperations method.
2498
+ """
2499
+
2500
+ http_options = (
2501
+ _BaseClientGatewaysServiceRestTransport._BaseListOperations._get_http_options()
2502
+ )
2503
+
2504
+ request, metadata = self._interceptor.pre_list_operations(request, metadata)
2505
+ transcoded_request = _BaseClientGatewaysServiceRestTransport._BaseListOperations._get_transcoded_request(
2506
+ http_options, request
2507
+ )
2508
+
2509
+ # Jsonify the query params
2510
+ query_params = _BaseClientGatewaysServiceRestTransport._BaseListOperations._get_query_params_json(
2511
+ transcoded_request
2512
+ )
2513
+
2514
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
2515
+ logging.DEBUG
2516
+ ): # pragma: NO COVER
2517
+ request_url = "{host}{uri}".format(
2518
+ host=self._host, uri=transcoded_request["uri"]
2519
+ )
2520
+ method = transcoded_request["method"]
2521
+ try:
2522
+ request_payload = json_format.MessageToJson(request)
2523
+ except:
2524
+ request_payload = None
2525
+ http_request = {
2526
+ "payload": request_payload,
2527
+ "requestMethod": method,
2528
+ "requestUrl": request_url,
2529
+ "headers": dict(metadata),
2530
+ }
2531
+ _LOGGER.debug(
2532
+ f"Sending request for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.ListOperations",
2533
+ extra={
2534
+ "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService",
2535
+ "rpcName": "ListOperations",
2536
+ "httpRequest": http_request,
2537
+ "metadata": http_request["headers"],
2538
+ },
2539
+ )
2540
+
2541
+ # Send the request
2542
+ response = ClientGatewaysServiceRestTransport._ListOperations._get_response(
2543
+ self._host,
2544
+ metadata,
2545
+ query_params,
2546
+ self._session,
2547
+ timeout,
2548
+ transcoded_request,
2549
+ )
2550
+
2551
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
2552
+ # subclass.
2553
+ if response.status_code >= 400:
2554
+ raise core_exceptions.from_http_response(response)
2555
+
2556
+ content = response.content.decode("utf-8")
2557
+ resp = operations_pb2.ListOperationsResponse()
2558
+ resp = json_format.Parse(content, resp)
2559
+ resp = self._interceptor.post_list_operations(resp)
2560
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
2561
+ logging.DEBUG
2562
+ ): # pragma: NO COVER
2563
+ try:
2564
+ response_payload = json_format.MessageToJson(resp)
2565
+ except:
2566
+ response_payload = None
2567
+ http_response = {
2568
+ "payload": response_payload,
2569
+ "headers": dict(response.headers),
2570
+ "status": response.status_code,
2571
+ }
2572
+ _LOGGER.debug(
2573
+ "Received response for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceAsyncClient.ListOperations",
2574
+ extra={
2575
+ "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService",
2576
+ "rpcName": "ListOperations",
2577
+ "httpResponse": http_response,
2578
+ "metadata": http_response["headers"],
2579
+ },
2580
+ )
2581
+ return resp
2582
+
2583
+ @property
2584
+ def kind(self) -> str:
2585
+ return "rest"
2586
+
2587
+ def close(self):
2588
+ self._session.close()
2589
+
2590
+
2591
+ __all__ = ("ClientGatewaysServiceRestTransport",)