google-cloud-devicestreaming 0.1.0__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.
- google/cloud/devicestreaming/__init__.py +69 -0
- google/cloud/devicestreaming/gapic_version.py +16 -0
- google/cloud/devicestreaming/py.typed +2 -0
- google/cloud/devicestreaming_v1/__init__.py +67 -0
- google/cloud/devicestreaming_v1/gapic_metadata.json +118 -0
- google/cloud/devicestreaming_v1/gapic_version.py +16 -0
- google/cloud/devicestreaming_v1/py.typed +2 -0
- google/cloud/devicestreaming_v1/services/__init__.py +15 -0
- google/cloud/devicestreaming_v1/services/direct_access_service/__init__.py +22 -0
- google/cloud/devicestreaming_v1/services/direct_access_service/async_client.py +1001 -0
- google/cloud/devicestreaming_v1/services/direct_access_service/client.py +1410 -0
- google/cloud/devicestreaming_v1/services/direct_access_service/pagers.py +197 -0
- google/cloud/devicestreaming_v1/services/direct_access_service/transports/__init__.py +38 -0
- google/cloud/devicestreaming_v1/services/direct_access_service/transports/base.py +262 -0
- google/cloud/devicestreaming_v1/services/direct_access_service/transports/grpc.py +512 -0
- google/cloud/devicestreaming_v1/services/direct_access_service/transports/grpc_asyncio.py +592 -0
- google/cloud/devicestreaming_v1/services/direct_access_service/transports/rest.py +1234 -0
- google/cloud/devicestreaming_v1/services/direct_access_service/transports/rest_base.py +361 -0
- google/cloud/devicestreaming_v1/types/__init__.py +56 -0
- google/cloud/devicestreaming_v1/types/adb_service.py +317 -0
- google/cloud/devicestreaming_v1/types/service.py +410 -0
- google_cloud_devicestreaming-0.1.0.dist-info/LICENSE +202 -0
- google_cloud_devicestreaming-0.1.0.dist-info/METADATA +228 -0
- google_cloud_devicestreaming-0.1.0.dist-info/RECORD +26 -0
- google_cloud_devicestreaming-0.1.0.dist-info/WHEEL +5 -0
- google_cloud_devicestreaming-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,1234 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright 2025 Google LLC
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#
|
|
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 exceptions as core_exceptions
|
|
23
|
+
from google.api_core import gapic_v1, rest_helpers, rest_streaming
|
|
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.protobuf import empty_pb2 # type: ignore
|
|
28
|
+
from google.protobuf import json_format
|
|
29
|
+
from requests import __version__ as requests_version
|
|
30
|
+
|
|
31
|
+
from google.cloud.devicestreaming_v1.types import adb_service, service
|
|
32
|
+
|
|
33
|
+
from .base import DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO
|
|
34
|
+
from .rest_base import _BaseDirectAccessServiceRestTransport
|
|
35
|
+
|
|
36
|
+
try:
|
|
37
|
+
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
|
|
38
|
+
except AttributeError: # pragma: NO COVER
|
|
39
|
+
OptionalRetry = Union[retries.Retry, object, None] # type: ignore
|
|
40
|
+
|
|
41
|
+
try:
|
|
42
|
+
from google.api_core import client_logging # type: ignore
|
|
43
|
+
|
|
44
|
+
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
|
|
45
|
+
except ImportError: # pragma: NO COVER
|
|
46
|
+
CLIENT_LOGGING_SUPPORTED = False
|
|
47
|
+
|
|
48
|
+
_LOGGER = logging.getLogger(__name__)
|
|
49
|
+
|
|
50
|
+
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
|
|
51
|
+
gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version,
|
|
52
|
+
grpc_version=None,
|
|
53
|
+
rest_version=f"requests@{requests_version}",
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class DirectAccessServiceRestInterceptor:
|
|
58
|
+
"""Interceptor for DirectAccessService.
|
|
59
|
+
|
|
60
|
+
Interceptors are used to manipulate requests, request metadata, and responses
|
|
61
|
+
in arbitrary ways.
|
|
62
|
+
Example use cases include:
|
|
63
|
+
* Logging
|
|
64
|
+
* Verifying requests according to service or custom semantics
|
|
65
|
+
* Stripping extraneous information from responses
|
|
66
|
+
|
|
67
|
+
These use cases and more can be enabled by injecting an
|
|
68
|
+
instance of a custom subclass when constructing the DirectAccessServiceRestTransport.
|
|
69
|
+
|
|
70
|
+
.. code-block:: python
|
|
71
|
+
class MyCustomDirectAccessServiceInterceptor(DirectAccessServiceRestInterceptor):
|
|
72
|
+
def pre_cancel_device_session(self, request, metadata):
|
|
73
|
+
logging.log(f"Received request: {request}")
|
|
74
|
+
return request, metadata
|
|
75
|
+
|
|
76
|
+
def pre_create_device_session(self, request, metadata):
|
|
77
|
+
logging.log(f"Received request: {request}")
|
|
78
|
+
return request, metadata
|
|
79
|
+
|
|
80
|
+
def post_create_device_session(self, response):
|
|
81
|
+
logging.log(f"Received response: {response}")
|
|
82
|
+
return response
|
|
83
|
+
|
|
84
|
+
def pre_get_device_session(self, request, metadata):
|
|
85
|
+
logging.log(f"Received request: {request}")
|
|
86
|
+
return request, metadata
|
|
87
|
+
|
|
88
|
+
def post_get_device_session(self, response):
|
|
89
|
+
logging.log(f"Received response: {response}")
|
|
90
|
+
return response
|
|
91
|
+
|
|
92
|
+
def pre_list_device_sessions(self, request, metadata):
|
|
93
|
+
logging.log(f"Received request: {request}")
|
|
94
|
+
return request, metadata
|
|
95
|
+
|
|
96
|
+
def post_list_device_sessions(self, response):
|
|
97
|
+
logging.log(f"Received response: {response}")
|
|
98
|
+
return response
|
|
99
|
+
|
|
100
|
+
def pre_update_device_session(self, request, metadata):
|
|
101
|
+
logging.log(f"Received request: {request}")
|
|
102
|
+
return request, metadata
|
|
103
|
+
|
|
104
|
+
def post_update_device_session(self, response):
|
|
105
|
+
logging.log(f"Received response: {response}")
|
|
106
|
+
return response
|
|
107
|
+
|
|
108
|
+
transport = DirectAccessServiceRestTransport(interceptor=MyCustomDirectAccessServiceInterceptor())
|
|
109
|
+
client = DirectAccessServiceClient(transport=transport)
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
"""
|
|
113
|
+
|
|
114
|
+
def pre_cancel_device_session(
|
|
115
|
+
self,
|
|
116
|
+
request: service.CancelDeviceSessionRequest,
|
|
117
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
118
|
+
) -> Tuple[
|
|
119
|
+
service.CancelDeviceSessionRequest, Sequence[Tuple[str, Union[str, bytes]]]
|
|
120
|
+
]:
|
|
121
|
+
"""Pre-rpc interceptor for cancel_device_session
|
|
122
|
+
|
|
123
|
+
Override in a subclass to manipulate the request or metadata
|
|
124
|
+
before they are sent to the DirectAccessService server.
|
|
125
|
+
"""
|
|
126
|
+
return request, metadata
|
|
127
|
+
|
|
128
|
+
def pre_create_device_session(
|
|
129
|
+
self,
|
|
130
|
+
request: service.CreateDeviceSessionRequest,
|
|
131
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
132
|
+
) -> Tuple[
|
|
133
|
+
service.CreateDeviceSessionRequest, Sequence[Tuple[str, Union[str, bytes]]]
|
|
134
|
+
]:
|
|
135
|
+
"""Pre-rpc interceptor for create_device_session
|
|
136
|
+
|
|
137
|
+
Override in a subclass to manipulate the request or metadata
|
|
138
|
+
before they are sent to the DirectAccessService server.
|
|
139
|
+
"""
|
|
140
|
+
return request, metadata
|
|
141
|
+
|
|
142
|
+
def post_create_device_session(
|
|
143
|
+
self, response: service.DeviceSession
|
|
144
|
+
) -> service.DeviceSession:
|
|
145
|
+
"""Post-rpc interceptor for create_device_session
|
|
146
|
+
|
|
147
|
+
DEPRECATED. Please use the `post_create_device_session_with_metadata`
|
|
148
|
+
interceptor instead.
|
|
149
|
+
|
|
150
|
+
Override in a subclass to read or manipulate the response
|
|
151
|
+
after it is returned by the DirectAccessService server but before
|
|
152
|
+
it is returned to user code. This `post_create_device_session` interceptor runs
|
|
153
|
+
before the `post_create_device_session_with_metadata` interceptor.
|
|
154
|
+
"""
|
|
155
|
+
return response
|
|
156
|
+
|
|
157
|
+
def post_create_device_session_with_metadata(
|
|
158
|
+
self,
|
|
159
|
+
response: service.DeviceSession,
|
|
160
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
161
|
+
) -> Tuple[service.DeviceSession, Sequence[Tuple[str, Union[str, bytes]]]]:
|
|
162
|
+
"""Post-rpc interceptor for create_device_session
|
|
163
|
+
|
|
164
|
+
Override in a subclass to read or manipulate the response or metadata after it
|
|
165
|
+
is returned by the DirectAccessService server but before it is returned to user code.
|
|
166
|
+
|
|
167
|
+
We recommend only using this `post_create_device_session_with_metadata`
|
|
168
|
+
interceptor in new development instead of the `post_create_device_session` interceptor.
|
|
169
|
+
When both interceptors are used, this `post_create_device_session_with_metadata` interceptor runs after the
|
|
170
|
+
`post_create_device_session` interceptor. The (possibly modified) response returned by
|
|
171
|
+
`post_create_device_session` will be passed to
|
|
172
|
+
`post_create_device_session_with_metadata`.
|
|
173
|
+
"""
|
|
174
|
+
return response, metadata
|
|
175
|
+
|
|
176
|
+
def pre_get_device_session(
|
|
177
|
+
self,
|
|
178
|
+
request: service.GetDeviceSessionRequest,
|
|
179
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
180
|
+
) -> Tuple[
|
|
181
|
+
service.GetDeviceSessionRequest, Sequence[Tuple[str, Union[str, bytes]]]
|
|
182
|
+
]:
|
|
183
|
+
"""Pre-rpc interceptor for get_device_session
|
|
184
|
+
|
|
185
|
+
Override in a subclass to manipulate the request or metadata
|
|
186
|
+
before they are sent to the DirectAccessService server.
|
|
187
|
+
"""
|
|
188
|
+
return request, metadata
|
|
189
|
+
|
|
190
|
+
def post_get_device_session(
|
|
191
|
+
self, response: service.DeviceSession
|
|
192
|
+
) -> service.DeviceSession:
|
|
193
|
+
"""Post-rpc interceptor for get_device_session
|
|
194
|
+
|
|
195
|
+
DEPRECATED. Please use the `post_get_device_session_with_metadata`
|
|
196
|
+
interceptor instead.
|
|
197
|
+
|
|
198
|
+
Override in a subclass to read or manipulate the response
|
|
199
|
+
after it is returned by the DirectAccessService server but before
|
|
200
|
+
it is returned to user code. This `post_get_device_session` interceptor runs
|
|
201
|
+
before the `post_get_device_session_with_metadata` interceptor.
|
|
202
|
+
"""
|
|
203
|
+
return response
|
|
204
|
+
|
|
205
|
+
def post_get_device_session_with_metadata(
|
|
206
|
+
self,
|
|
207
|
+
response: service.DeviceSession,
|
|
208
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
209
|
+
) -> Tuple[service.DeviceSession, Sequence[Tuple[str, Union[str, bytes]]]]:
|
|
210
|
+
"""Post-rpc interceptor for get_device_session
|
|
211
|
+
|
|
212
|
+
Override in a subclass to read or manipulate the response or metadata after it
|
|
213
|
+
is returned by the DirectAccessService server but before it is returned to user code.
|
|
214
|
+
|
|
215
|
+
We recommend only using this `post_get_device_session_with_metadata`
|
|
216
|
+
interceptor in new development instead of the `post_get_device_session` interceptor.
|
|
217
|
+
When both interceptors are used, this `post_get_device_session_with_metadata` interceptor runs after the
|
|
218
|
+
`post_get_device_session` interceptor. The (possibly modified) response returned by
|
|
219
|
+
`post_get_device_session` will be passed to
|
|
220
|
+
`post_get_device_session_with_metadata`.
|
|
221
|
+
"""
|
|
222
|
+
return response, metadata
|
|
223
|
+
|
|
224
|
+
def pre_list_device_sessions(
|
|
225
|
+
self,
|
|
226
|
+
request: service.ListDeviceSessionsRequest,
|
|
227
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
228
|
+
) -> Tuple[
|
|
229
|
+
service.ListDeviceSessionsRequest, Sequence[Tuple[str, Union[str, bytes]]]
|
|
230
|
+
]:
|
|
231
|
+
"""Pre-rpc interceptor for list_device_sessions
|
|
232
|
+
|
|
233
|
+
Override in a subclass to manipulate the request or metadata
|
|
234
|
+
before they are sent to the DirectAccessService server.
|
|
235
|
+
"""
|
|
236
|
+
return request, metadata
|
|
237
|
+
|
|
238
|
+
def post_list_device_sessions(
|
|
239
|
+
self, response: service.ListDeviceSessionsResponse
|
|
240
|
+
) -> service.ListDeviceSessionsResponse:
|
|
241
|
+
"""Post-rpc interceptor for list_device_sessions
|
|
242
|
+
|
|
243
|
+
DEPRECATED. Please use the `post_list_device_sessions_with_metadata`
|
|
244
|
+
interceptor instead.
|
|
245
|
+
|
|
246
|
+
Override in a subclass to read or manipulate the response
|
|
247
|
+
after it is returned by the DirectAccessService server but before
|
|
248
|
+
it is returned to user code. This `post_list_device_sessions` interceptor runs
|
|
249
|
+
before the `post_list_device_sessions_with_metadata` interceptor.
|
|
250
|
+
"""
|
|
251
|
+
return response
|
|
252
|
+
|
|
253
|
+
def post_list_device_sessions_with_metadata(
|
|
254
|
+
self,
|
|
255
|
+
response: service.ListDeviceSessionsResponse,
|
|
256
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
257
|
+
) -> Tuple[
|
|
258
|
+
service.ListDeviceSessionsResponse, Sequence[Tuple[str, Union[str, bytes]]]
|
|
259
|
+
]:
|
|
260
|
+
"""Post-rpc interceptor for list_device_sessions
|
|
261
|
+
|
|
262
|
+
Override in a subclass to read or manipulate the response or metadata after it
|
|
263
|
+
is returned by the DirectAccessService server but before it is returned to user code.
|
|
264
|
+
|
|
265
|
+
We recommend only using this `post_list_device_sessions_with_metadata`
|
|
266
|
+
interceptor in new development instead of the `post_list_device_sessions` interceptor.
|
|
267
|
+
When both interceptors are used, this `post_list_device_sessions_with_metadata` interceptor runs after the
|
|
268
|
+
`post_list_device_sessions` interceptor. The (possibly modified) response returned by
|
|
269
|
+
`post_list_device_sessions` will be passed to
|
|
270
|
+
`post_list_device_sessions_with_metadata`.
|
|
271
|
+
"""
|
|
272
|
+
return response, metadata
|
|
273
|
+
|
|
274
|
+
def pre_update_device_session(
|
|
275
|
+
self,
|
|
276
|
+
request: service.UpdateDeviceSessionRequest,
|
|
277
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
278
|
+
) -> Tuple[
|
|
279
|
+
service.UpdateDeviceSessionRequest, Sequence[Tuple[str, Union[str, bytes]]]
|
|
280
|
+
]:
|
|
281
|
+
"""Pre-rpc interceptor for update_device_session
|
|
282
|
+
|
|
283
|
+
Override in a subclass to manipulate the request or metadata
|
|
284
|
+
before they are sent to the DirectAccessService server.
|
|
285
|
+
"""
|
|
286
|
+
return request, metadata
|
|
287
|
+
|
|
288
|
+
def post_update_device_session(
|
|
289
|
+
self, response: service.DeviceSession
|
|
290
|
+
) -> service.DeviceSession:
|
|
291
|
+
"""Post-rpc interceptor for update_device_session
|
|
292
|
+
|
|
293
|
+
DEPRECATED. Please use the `post_update_device_session_with_metadata`
|
|
294
|
+
interceptor instead.
|
|
295
|
+
|
|
296
|
+
Override in a subclass to read or manipulate the response
|
|
297
|
+
after it is returned by the DirectAccessService server but before
|
|
298
|
+
it is returned to user code. This `post_update_device_session` interceptor runs
|
|
299
|
+
before the `post_update_device_session_with_metadata` interceptor.
|
|
300
|
+
"""
|
|
301
|
+
return response
|
|
302
|
+
|
|
303
|
+
def post_update_device_session_with_metadata(
|
|
304
|
+
self,
|
|
305
|
+
response: service.DeviceSession,
|
|
306
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
307
|
+
) -> Tuple[service.DeviceSession, Sequence[Tuple[str, Union[str, bytes]]]]:
|
|
308
|
+
"""Post-rpc interceptor for update_device_session
|
|
309
|
+
|
|
310
|
+
Override in a subclass to read or manipulate the response or metadata after it
|
|
311
|
+
is returned by the DirectAccessService server but before it is returned to user code.
|
|
312
|
+
|
|
313
|
+
We recommend only using this `post_update_device_session_with_metadata`
|
|
314
|
+
interceptor in new development instead of the `post_update_device_session` interceptor.
|
|
315
|
+
When both interceptors are used, this `post_update_device_session_with_metadata` interceptor runs after the
|
|
316
|
+
`post_update_device_session` interceptor. The (possibly modified) response returned by
|
|
317
|
+
`post_update_device_session` will be passed to
|
|
318
|
+
`post_update_device_session_with_metadata`.
|
|
319
|
+
"""
|
|
320
|
+
return response, metadata
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
@dataclasses.dataclass
|
|
324
|
+
class DirectAccessServiceRestStub:
|
|
325
|
+
_session: AuthorizedSession
|
|
326
|
+
_host: str
|
|
327
|
+
_interceptor: DirectAccessServiceRestInterceptor
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
class DirectAccessServiceRestTransport(_BaseDirectAccessServiceRestTransport):
|
|
331
|
+
"""REST backend synchronous transport for DirectAccessService.
|
|
332
|
+
|
|
333
|
+
A service for allocating Android devices and interacting with
|
|
334
|
+
the live-allocated devices.
|
|
335
|
+
|
|
336
|
+
Each Session will wait for available capacity, at a higher
|
|
337
|
+
priority over Test Execution. When allocated, the session will
|
|
338
|
+
be exposed through a stream for integration.
|
|
339
|
+
|
|
340
|
+
DirectAccessService is currently available as a preview to
|
|
341
|
+
select developers. You can register today on behalf of you and
|
|
342
|
+
your team at
|
|
343
|
+
https://developer.android.com/studio/preview/android-device-streaming
|
|
344
|
+
|
|
345
|
+
This class defines the same methods as the primary client, so the
|
|
346
|
+
primary client can load the underlying transport implementation
|
|
347
|
+
and call it.
|
|
348
|
+
|
|
349
|
+
It sends JSON representations of protocol buffers over HTTP/1.1
|
|
350
|
+
"""
|
|
351
|
+
|
|
352
|
+
def __init__(
|
|
353
|
+
self,
|
|
354
|
+
*,
|
|
355
|
+
host: str = "devicestreaming.googleapis.com",
|
|
356
|
+
credentials: Optional[ga_credentials.Credentials] = None,
|
|
357
|
+
credentials_file: Optional[str] = None,
|
|
358
|
+
scopes: Optional[Sequence[str]] = None,
|
|
359
|
+
client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
|
|
360
|
+
quota_project_id: Optional[str] = None,
|
|
361
|
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
|
362
|
+
always_use_jwt_access: Optional[bool] = False,
|
|
363
|
+
url_scheme: str = "https",
|
|
364
|
+
interceptor: Optional[DirectAccessServiceRestInterceptor] = None,
|
|
365
|
+
api_audience: Optional[str] = None,
|
|
366
|
+
) -> None:
|
|
367
|
+
"""Instantiate the transport.
|
|
368
|
+
|
|
369
|
+
Args:
|
|
370
|
+
host (Optional[str]):
|
|
371
|
+
The hostname to connect to (default: 'devicestreaming.googleapis.com').
|
|
372
|
+
credentials (Optional[google.auth.credentials.Credentials]): The
|
|
373
|
+
authorization credentials to attach to requests. These
|
|
374
|
+
credentials identify the application to the service; if none
|
|
375
|
+
are specified, the client will attempt to ascertain the
|
|
376
|
+
credentials from the environment.
|
|
377
|
+
|
|
378
|
+
credentials_file (Optional[str]): A file with credentials that can
|
|
379
|
+
be loaded with :func:`google.auth.load_credentials_from_file`.
|
|
380
|
+
This argument is ignored if ``channel`` is provided.
|
|
381
|
+
scopes (Optional(Sequence[str])): A list of scopes. This argument is
|
|
382
|
+
ignored if ``channel`` is provided.
|
|
383
|
+
client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client
|
|
384
|
+
certificate to configure mutual TLS HTTP channel. It is ignored
|
|
385
|
+
if ``channel`` is provided.
|
|
386
|
+
quota_project_id (Optional[str]): An optional project to use for billing
|
|
387
|
+
and quota.
|
|
388
|
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
|
389
|
+
The client info used to send a user-agent string along with
|
|
390
|
+
API requests. If ``None``, then default info will be used.
|
|
391
|
+
Generally, you only need to set this if you are developing
|
|
392
|
+
your own client library.
|
|
393
|
+
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
|
|
394
|
+
be used for service account credentials.
|
|
395
|
+
url_scheme: the protocol scheme for the API endpoint. Normally
|
|
396
|
+
"https", but for testing or local servers,
|
|
397
|
+
"http" can be specified.
|
|
398
|
+
"""
|
|
399
|
+
# Run the base constructor
|
|
400
|
+
# TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc.
|
|
401
|
+
# TODO: When custom host (api_endpoint) is set, `scopes` must *also* be set on the
|
|
402
|
+
# credentials object
|
|
403
|
+
super().__init__(
|
|
404
|
+
host=host,
|
|
405
|
+
credentials=credentials,
|
|
406
|
+
client_info=client_info,
|
|
407
|
+
always_use_jwt_access=always_use_jwt_access,
|
|
408
|
+
url_scheme=url_scheme,
|
|
409
|
+
api_audience=api_audience,
|
|
410
|
+
)
|
|
411
|
+
self._session = AuthorizedSession(
|
|
412
|
+
self._credentials, default_host=self.DEFAULT_HOST
|
|
413
|
+
)
|
|
414
|
+
if client_cert_source_for_mtls:
|
|
415
|
+
self._session.configure_mtls_channel(client_cert_source_for_mtls)
|
|
416
|
+
self._interceptor = interceptor or DirectAccessServiceRestInterceptor()
|
|
417
|
+
self._prep_wrapped_messages(client_info)
|
|
418
|
+
|
|
419
|
+
class _AdbConnect(
|
|
420
|
+
_BaseDirectAccessServiceRestTransport._BaseAdbConnect,
|
|
421
|
+
DirectAccessServiceRestStub,
|
|
422
|
+
):
|
|
423
|
+
def __hash__(self):
|
|
424
|
+
return hash("DirectAccessServiceRestTransport.AdbConnect")
|
|
425
|
+
|
|
426
|
+
def __call__(
|
|
427
|
+
self,
|
|
428
|
+
request: adb_service.AdbMessage,
|
|
429
|
+
*,
|
|
430
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
431
|
+
timeout: Optional[float] = None,
|
|
432
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
433
|
+
) -> rest_streaming.ResponseIterator:
|
|
434
|
+
raise NotImplementedError(
|
|
435
|
+
"Method AdbConnect is not available over REST transport"
|
|
436
|
+
)
|
|
437
|
+
|
|
438
|
+
class _CancelDeviceSession(
|
|
439
|
+
_BaseDirectAccessServiceRestTransport._BaseCancelDeviceSession,
|
|
440
|
+
DirectAccessServiceRestStub,
|
|
441
|
+
):
|
|
442
|
+
def __hash__(self):
|
|
443
|
+
return hash("DirectAccessServiceRestTransport.CancelDeviceSession")
|
|
444
|
+
|
|
445
|
+
@staticmethod
|
|
446
|
+
def _get_response(
|
|
447
|
+
host,
|
|
448
|
+
metadata,
|
|
449
|
+
query_params,
|
|
450
|
+
session,
|
|
451
|
+
timeout,
|
|
452
|
+
transcoded_request,
|
|
453
|
+
body=None,
|
|
454
|
+
):
|
|
455
|
+
uri = transcoded_request["uri"]
|
|
456
|
+
method = transcoded_request["method"]
|
|
457
|
+
headers = dict(metadata)
|
|
458
|
+
headers["Content-Type"] = "application/json"
|
|
459
|
+
response = getattr(session, method)(
|
|
460
|
+
"{host}{uri}".format(host=host, uri=uri),
|
|
461
|
+
timeout=timeout,
|
|
462
|
+
headers=headers,
|
|
463
|
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
|
464
|
+
data=body,
|
|
465
|
+
)
|
|
466
|
+
return response
|
|
467
|
+
|
|
468
|
+
def __call__(
|
|
469
|
+
self,
|
|
470
|
+
request: service.CancelDeviceSessionRequest,
|
|
471
|
+
*,
|
|
472
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
473
|
+
timeout: Optional[float] = None,
|
|
474
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
475
|
+
):
|
|
476
|
+
r"""Call the cancel device session method over HTTP.
|
|
477
|
+
|
|
478
|
+
Args:
|
|
479
|
+
request (~.service.CancelDeviceSessionRequest):
|
|
480
|
+
The request object. Request message for
|
|
481
|
+
DirectAccessService.CancelDeviceSession.
|
|
482
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
483
|
+
should be retried.
|
|
484
|
+
timeout (float): The timeout for this request.
|
|
485
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
486
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
487
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
488
|
+
be of type `bytes`.
|
|
489
|
+
"""
|
|
490
|
+
|
|
491
|
+
http_options = (
|
|
492
|
+
_BaseDirectAccessServiceRestTransport._BaseCancelDeviceSession._get_http_options()
|
|
493
|
+
)
|
|
494
|
+
|
|
495
|
+
request, metadata = self._interceptor.pre_cancel_device_session(
|
|
496
|
+
request, metadata
|
|
497
|
+
)
|
|
498
|
+
transcoded_request = _BaseDirectAccessServiceRestTransport._BaseCancelDeviceSession._get_transcoded_request(
|
|
499
|
+
http_options, request
|
|
500
|
+
)
|
|
501
|
+
|
|
502
|
+
body = _BaseDirectAccessServiceRestTransport._BaseCancelDeviceSession._get_request_body_json(
|
|
503
|
+
transcoded_request
|
|
504
|
+
)
|
|
505
|
+
|
|
506
|
+
# Jsonify the query params
|
|
507
|
+
query_params = _BaseDirectAccessServiceRestTransport._BaseCancelDeviceSession._get_query_params_json(
|
|
508
|
+
transcoded_request
|
|
509
|
+
)
|
|
510
|
+
|
|
511
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
512
|
+
logging.DEBUG
|
|
513
|
+
): # pragma: NO COVER
|
|
514
|
+
request_url = "{host}{uri}".format(
|
|
515
|
+
host=self._host, uri=transcoded_request["uri"]
|
|
516
|
+
)
|
|
517
|
+
method = transcoded_request["method"]
|
|
518
|
+
try:
|
|
519
|
+
request_payload = json_format.MessageToJson(request)
|
|
520
|
+
except:
|
|
521
|
+
request_payload = None
|
|
522
|
+
http_request = {
|
|
523
|
+
"payload": request_payload,
|
|
524
|
+
"requestMethod": method,
|
|
525
|
+
"requestUrl": request_url,
|
|
526
|
+
"headers": dict(metadata),
|
|
527
|
+
}
|
|
528
|
+
_LOGGER.debug(
|
|
529
|
+
f"Sending request for google.cloud.devicestreaming_v1.DirectAccessServiceClient.CancelDeviceSession",
|
|
530
|
+
extra={
|
|
531
|
+
"serviceName": "google.cloud.devicestreaming.v1.DirectAccessService",
|
|
532
|
+
"rpcName": "CancelDeviceSession",
|
|
533
|
+
"httpRequest": http_request,
|
|
534
|
+
"metadata": http_request["headers"],
|
|
535
|
+
},
|
|
536
|
+
)
|
|
537
|
+
|
|
538
|
+
# Send the request
|
|
539
|
+
response = (
|
|
540
|
+
DirectAccessServiceRestTransport._CancelDeviceSession._get_response(
|
|
541
|
+
self._host,
|
|
542
|
+
metadata,
|
|
543
|
+
query_params,
|
|
544
|
+
self._session,
|
|
545
|
+
timeout,
|
|
546
|
+
transcoded_request,
|
|
547
|
+
body,
|
|
548
|
+
)
|
|
549
|
+
)
|
|
550
|
+
|
|
551
|
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
|
552
|
+
# subclass.
|
|
553
|
+
if response.status_code >= 400:
|
|
554
|
+
raise core_exceptions.from_http_response(response)
|
|
555
|
+
|
|
556
|
+
class _CreateDeviceSession(
|
|
557
|
+
_BaseDirectAccessServiceRestTransport._BaseCreateDeviceSession,
|
|
558
|
+
DirectAccessServiceRestStub,
|
|
559
|
+
):
|
|
560
|
+
def __hash__(self):
|
|
561
|
+
return hash("DirectAccessServiceRestTransport.CreateDeviceSession")
|
|
562
|
+
|
|
563
|
+
@staticmethod
|
|
564
|
+
def _get_response(
|
|
565
|
+
host,
|
|
566
|
+
metadata,
|
|
567
|
+
query_params,
|
|
568
|
+
session,
|
|
569
|
+
timeout,
|
|
570
|
+
transcoded_request,
|
|
571
|
+
body=None,
|
|
572
|
+
):
|
|
573
|
+
uri = transcoded_request["uri"]
|
|
574
|
+
method = transcoded_request["method"]
|
|
575
|
+
headers = dict(metadata)
|
|
576
|
+
headers["Content-Type"] = "application/json"
|
|
577
|
+
response = getattr(session, method)(
|
|
578
|
+
"{host}{uri}".format(host=host, uri=uri),
|
|
579
|
+
timeout=timeout,
|
|
580
|
+
headers=headers,
|
|
581
|
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
|
582
|
+
data=body,
|
|
583
|
+
)
|
|
584
|
+
return response
|
|
585
|
+
|
|
586
|
+
def __call__(
|
|
587
|
+
self,
|
|
588
|
+
request: service.CreateDeviceSessionRequest,
|
|
589
|
+
*,
|
|
590
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
591
|
+
timeout: Optional[float] = None,
|
|
592
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
593
|
+
) -> service.DeviceSession:
|
|
594
|
+
r"""Call the create device session method over HTTP.
|
|
595
|
+
|
|
596
|
+
Args:
|
|
597
|
+
request (~.service.CreateDeviceSessionRequest):
|
|
598
|
+
The request object. Request message for
|
|
599
|
+
DirectAccessService.CreateDeviceSession.
|
|
600
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
601
|
+
should be retried.
|
|
602
|
+
timeout (float): The timeout for this request.
|
|
603
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
604
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
605
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
606
|
+
be of type `bytes`.
|
|
607
|
+
|
|
608
|
+
Returns:
|
|
609
|
+
~.service.DeviceSession:
|
|
610
|
+
Protobuf message describing the
|
|
611
|
+
device message, used from several RPCs.
|
|
612
|
+
|
|
613
|
+
"""
|
|
614
|
+
|
|
615
|
+
http_options = (
|
|
616
|
+
_BaseDirectAccessServiceRestTransport._BaseCreateDeviceSession._get_http_options()
|
|
617
|
+
)
|
|
618
|
+
|
|
619
|
+
request, metadata = self._interceptor.pre_create_device_session(
|
|
620
|
+
request, metadata
|
|
621
|
+
)
|
|
622
|
+
transcoded_request = _BaseDirectAccessServiceRestTransport._BaseCreateDeviceSession._get_transcoded_request(
|
|
623
|
+
http_options, request
|
|
624
|
+
)
|
|
625
|
+
|
|
626
|
+
body = _BaseDirectAccessServiceRestTransport._BaseCreateDeviceSession._get_request_body_json(
|
|
627
|
+
transcoded_request
|
|
628
|
+
)
|
|
629
|
+
|
|
630
|
+
# Jsonify the query params
|
|
631
|
+
query_params = _BaseDirectAccessServiceRestTransport._BaseCreateDeviceSession._get_query_params_json(
|
|
632
|
+
transcoded_request
|
|
633
|
+
)
|
|
634
|
+
|
|
635
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
636
|
+
logging.DEBUG
|
|
637
|
+
): # pragma: NO COVER
|
|
638
|
+
request_url = "{host}{uri}".format(
|
|
639
|
+
host=self._host, uri=transcoded_request["uri"]
|
|
640
|
+
)
|
|
641
|
+
method = transcoded_request["method"]
|
|
642
|
+
try:
|
|
643
|
+
request_payload = type(request).to_json(request)
|
|
644
|
+
except:
|
|
645
|
+
request_payload = None
|
|
646
|
+
http_request = {
|
|
647
|
+
"payload": request_payload,
|
|
648
|
+
"requestMethod": method,
|
|
649
|
+
"requestUrl": request_url,
|
|
650
|
+
"headers": dict(metadata),
|
|
651
|
+
}
|
|
652
|
+
_LOGGER.debug(
|
|
653
|
+
f"Sending request for google.cloud.devicestreaming_v1.DirectAccessServiceClient.CreateDeviceSession",
|
|
654
|
+
extra={
|
|
655
|
+
"serviceName": "google.cloud.devicestreaming.v1.DirectAccessService",
|
|
656
|
+
"rpcName": "CreateDeviceSession",
|
|
657
|
+
"httpRequest": http_request,
|
|
658
|
+
"metadata": http_request["headers"],
|
|
659
|
+
},
|
|
660
|
+
)
|
|
661
|
+
|
|
662
|
+
# Send the request
|
|
663
|
+
response = (
|
|
664
|
+
DirectAccessServiceRestTransport._CreateDeviceSession._get_response(
|
|
665
|
+
self._host,
|
|
666
|
+
metadata,
|
|
667
|
+
query_params,
|
|
668
|
+
self._session,
|
|
669
|
+
timeout,
|
|
670
|
+
transcoded_request,
|
|
671
|
+
body,
|
|
672
|
+
)
|
|
673
|
+
)
|
|
674
|
+
|
|
675
|
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
|
676
|
+
# subclass.
|
|
677
|
+
if response.status_code >= 400:
|
|
678
|
+
raise core_exceptions.from_http_response(response)
|
|
679
|
+
|
|
680
|
+
# Return the response
|
|
681
|
+
resp = service.DeviceSession()
|
|
682
|
+
pb_resp = service.DeviceSession.pb(resp)
|
|
683
|
+
|
|
684
|
+
json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
|
|
685
|
+
|
|
686
|
+
resp = self._interceptor.post_create_device_session(resp)
|
|
687
|
+
response_metadata = [(k, str(v)) for k, v in response.headers.items()]
|
|
688
|
+
resp, _ = self._interceptor.post_create_device_session_with_metadata(
|
|
689
|
+
resp, response_metadata
|
|
690
|
+
)
|
|
691
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
692
|
+
logging.DEBUG
|
|
693
|
+
): # pragma: NO COVER
|
|
694
|
+
try:
|
|
695
|
+
response_payload = service.DeviceSession.to_json(response)
|
|
696
|
+
except:
|
|
697
|
+
response_payload = None
|
|
698
|
+
http_response = {
|
|
699
|
+
"payload": response_payload,
|
|
700
|
+
"headers": dict(response.headers),
|
|
701
|
+
"status": response.status_code,
|
|
702
|
+
}
|
|
703
|
+
_LOGGER.debug(
|
|
704
|
+
"Received response for google.cloud.devicestreaming_v1.DirectAccessServiceClient.create_device_session",
|
|
705
|
+
extra={
|
|
706
|
+
"serviceName": "google.cloud.devicestreaming.v1.DirectAccessService",
|
|
707
|
+
"rpcName": "CreateDeviceSession",
|
|
708
|
+
"metadata": http_response["headers"],
|
|
709
|
+
"httpResponse": http_response,
|
|
710
|
+
},
|
|
711
|
+
)
|
|
712
|
+
return resp
|
|
713
|
+
|
|
714
|
+
class _GetDeviceSession(
|
|
715
|
+
_BaseDirectAccessServiceRestTransport._BaseGetDeviceSession,
|
|
716
|
+
DirectAccessServiceRestStub,
|
|
717
|
+
):
|
|
718
|
+
def __hash__(self):
|
|
719
|
+
return hash("DirectAccessServiceRestTransport.GetDeviceSession")
|
|
720
|
+
|
|
721
|
+
@staticmethod
|
|
722
|
+
def _get_response(
|
|
723
|
+
host,
|
|
724
|
+
metadata,
|
|
725
|
+
query_params,
|
|
726
|
+
session,
|
|
727
|
+
timeout,
|
|
728
|
+
transcoded_request,
|
|
729
|
+
body=None,
|
|
730
|
+
):
|
|
731
|
+
uri = transcoded_request["uri"]
|
|
732
|
+
method = transcoded_request["method"]
|
|
733
|
+
headers = dict(metadata)
|
|
734
|
+
headers["Content-Type"] = "application/json"
|
|
735
|
+
response = getattr(session, method)(
|
|
736
|
+
"{host}{uri}".format(host=host, uri=uri),
|
|
737
|
+
timeout=timeout,
|
|
738
|
+
headers=headers,
|
|
739
|
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
|
740
|
+
)
|
|
741
|
+
return response
|
|
742
|
+
|
|
743
|
+
def __call__(
|
|
744
|
+
self,
|
|
745
|
+
request: service.GetDeviceSessionRequest,
|
|
746
|
+
*,
|
|
747
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
748
|
+
timeout: Optional[float] = None,
|
|
749
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
750
|
+
) -> service.DeviceSession:
|
|
751
|
+
r"""Call the get device session method over HTTP.
|
|
752
|
+
|
|
753
|
+
Args:
|
|
754
|
+
request (~.service.GetDeviceSessionRequest):
|
|
755
|
+
The request object. Request message for
|
|
756
|
+
DirectAccessService.GetDeviceSession.
|
|
757
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
758
|
+
should be retried.
|
|
759
|
+
timeout (float): The timeout for this request.
|
|
760
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
761
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
762
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
763
|
+
be of type `bytes`.
|
|
764
|
+
|
|
765
|
+
Returns:
|
|
766
|
+
~.service.DeviceSession:
|
|
767
|
+
Protobuf message describing the
|
|
768
|
+
device message, used from several RPCs.
|
|
769
|
+
|
|
770
|
+
"""
|
|
771
|
+
|
|
772
|
+
http_options = (
|
|
773
|
+
_BaseDirectAccessServiceRestTransport._BaseGetDeviceSession._get_http_options()
|
|
774
|
+
)
|
|
775
|
+
|
|
776
|
+
request, metadata = self._interceptor.pre_get_device_session(
|
|
777
|
+
request, metadata
|
|
778
|
+
)
|
|
779
|
+
transcoded_request = _BaseDirectAccessServiceRestTransport._BaseGetDeviceSession._get_transcoded_request(
|
|
780
|
+
http_options, request
|
|
781
|
+
)
|
|
782
|
+
|
|
783
|
+
# Jsonify the query params
|
|
784
|
+
query_params = _BaseDirectAccessServiceRestTransport._BaseGetDeviceSession._get_query_params_json(
|
|
785
|
+
transcoded_request
|
|
786
|
+
)
|
|
787
|
+
|
|
788
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
789
|
+
logging.DEBUG
|
|
790
|
+
): # pragma: NO COVER
|
|
791
|
+
request_url = "{host}{uri}".format(
|
|
792
|
+
host=self._host, uri=transcoded_request["uri"]
|
|
793
|
+
)
|
|
794
|
+
method = transcoded_request["method"]
|
|
795
|
+
try:
|
|
796
|
+
request_payload = type(request).to_json(request)
|
|
797
|
+
except:
|
|
798
|
+
request_payload = None
|
|
799
|
+
http_request = {
|
|
800
|
+
"payload": request_payload,
|
|
801
|
+
"requestMethod": method,
|
|
802
|
+
"requestUrl": request_url,
|
|
803
|
+
"headers": dict(metadata),
|
|
804
|
+
}
|
|
805
|
+
_LOGGER.debug(
|
|
806
|
+
f"Sending request for google.cloud.devicestreaming_v1.DirectAccessServiceClient.GetDeviceSession",
|
|
807
|
+
extra={
|
|
808
|
+
"serviceName": "google.cloud.devicestreaming.v1.DirectAccessService",
|
|
809
|
+
"rpcName": "GetDeviceSession",
|
|
810
|
+
"httpRequest": http_request,
|
|
811
|
+
"metadata": http_request["headers"],
|
|
812
|
+
},
|
|
813
|
+
)
|
|
814
|
+
|
|
815
|
+
# Send the request
|
|
816
|
+
response = DirectAccessServiceRestTransport._GetDeviceSession._get_response(
|
|
817
|
+
self._host,
|
|
818
|
+
metadata,
|
|
819
|
+
query_params,
|
|
820
|
+
self._session,
|
|
821
|
+
timeout,
|
|
822
|
+
transcoded_request,
|
|
823
|
+
)
|
|
824
|
+
|
|
825
|
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
|
826
|
+
# subclass.
|
|
827
|
+
if response.status_code >= 400:
|
|
828
|
+
raise core_exceptions.from_http_response(response)
|
|
829
|
+
|
|
830
|
+
# Return the response
|
|
831
|
+
resp = service.DeviceSession()
|
|
832
|
+
pb_resp = service.DeviceSession.pb(resp)
|
|
833
|
+
|
|
834
|
+
json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
|
|
835
|
+
|
|
836
|
+
resp = self._interceptor.post_get_device_session(resp)
|
|
837
|
+
response_metadata = [(k, str(v)) for k, v in response.headers.items()]
|
|
838
|
+
resp, _ = self._interceptor.post_get_device_session_with_metadata(
|
|
839
|
+
resp, response_metadata
|
|
840
|
+
)
|
|
841
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
842
|
+
logging.DEBUG
|
|
843
|
+
): # pragma: NO COVER
|
|
844
|
+
try:
|
|
845
|
+
response_payload = service.DeviceSession.to_json(response)
|
|
846
|
+
except:
|
|
847
|
+
response_payload = None
|
|
848
|
+
http_response = {
|
|
849
|
+
"payload": response_payload,
|
|
850
|
+
"headers": dict(response.headers),
|
|
851
|
+
"status": response.status_code,
|
|
852
|
+
}
|
|
853
|
+
_LOGGER.debug(
|
|
854
|
+
"Received response for google.cloud.devicestreaming_v1.DirectAccessServiceClient.get_device_session",
|
|
855
|
+
extra={
|
|
856
|
+
"serviceName": "google.cloud.devicestreaming.v1.DirectAccessService",
|
|
857
|
+
"rpcName": "GetDeviceSession",
|
|
858
|
+
"metadata": http_response["headers"],
|
|
859
|
+
"httpResponse": http_response,
|
|
860
|
+
},
|
|
861
|
+
)
|
|
862
|
+
return resp
|
|
863
|
+
|
|
864
|
+
class _ListDeviceSessions(
|
|
865
|
+
_BaseDirectAccessServiceRestTransport._BaseListDeviceSessions,
|
|
866
|
+
DirectAccessServiceRestStub,
|
|
867
|
+
):
|
|
868
|
+
def __hash__(self):
|
|
869
|
+
return hash("DirectAccessServiceRestTransport.ListDeviceSessions")
|
|
870
|
+
|
|
871
|
+
@staticmethod
|
|
872
|
+
def _get_response(
|
|
873
|
+
host,
|
|
874
|
+
metadata,
|
|
875
|
+
query_params,
|
|
876
|
+
session,
|
|
877
|
+
timeout,
|
|
878
|
+
transcoded_request,
|
|
879
|
+
body=None,
|
|
880
|
+
):
|
|
881
|
+
uri = transcoded_request["uri"]
|
|
882
|
+
method = transcoded_request["method"]
|
|
883
|
+
headers = dict(metadata)
|
|
884
|
+
headers["Content-Type"] = "application/json"
|
|
885
|
+
response = getattr(session, method)(
|
|
886
|
+
"{host}{uri}".format(host=host, uri=uri),
|
|
887
|
+
timeout=timeout,
|
|
888
|
+
headers=headers,
|
|
889
|
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
|
890
|
+
)
|
|
891
|
+
return response
|
|
892
|
+
|
|
893
|
+
def __call__(
|
|
894
|
+
self,
|
|
895
|
+
request: service.ListDeviceSessionsRequest,
|
|
896
|
+
*,
|
|
897
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
898
|
+
timeout: Optional[float] = None,
|
|
899
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
900
|
+
) -> service.ListDeviceSessionsResponse:
|
|
901
|
+
r"""Call the list device sessions method over HTTP.
|
|
902
|
+
|
|
903
|
+
Args:
|
|
904
|
+
request (~.service.ListDeviceSessionsRequest):
|
|
905
|
+
The request object. Request message for
|
|
906
|
+
DirectAccessService.ListDeviceSessions.
|
|
907
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
908
|
+
should be retried.
|
|
909
|
+
timeout (float): The timeout for this request.
|
|
910
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
911
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
912
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
913
|
+
be of type `bytes`.
|
|
914
|
+
|
|
915
|
+
Returns:
|
|
916
|
+
~.service.ListDeviceSessionsResponse:
|
|
917
|
+
Response message for
|
|
918
|
+
DirectAccessService.ListDeviceSessions.
|
|
919
|
+
|
|
920
|
+
"""
|
|
921
|
+
|
|
922
|
+
http_options = (
|
|
923
|
+
_BaseDirectAccessServiceRestTransport._BaseListDeviceSessions._get_http_options()
|
|
924
|
+
)
|
|
925
|
+
|
|
926
|
+
request, metadata = self._interceptor.pre_list_device_sessions(
|
|
927
|
+
request, metadata
|
|
928
|
+
)
|
|
929
|
+
transcoded_request = _BaseDirectAccessServiceRestTransport._BaseListDeviceSessions._get_transcoded_request(
|
|
930
|
+
http_options, request
|
|
931
|
+
)
|
|
932
|
+
|
|
933
|
+
# Jsonify the query params
|
|
934
|
+
query_params = _BaseDirectAccessServiceRestTransport._BaseListDeviceSessions._get_query_params_json(
|
|
935
|
+
transcoded_request
|
|
936
|
+
)
|
|
937
|
+
|
|
938
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
939
|
+
logging.DEBUG
|
|
940
|
+
): # pragma: NO COVER
|
|
941
|
+
request_url = "{host}{uri}".format(
|
|
942
|
+
host=self._host, uri=transcoded_request["uri"]
|
|
943
|
+
)
|
|
944
|
+
method = transcoded_request["method"]
|
|
945
|
+
try:
|
|
946
|
+
request_payload = type(request).to_json(request)
|
|
947
|
+
except:
|
|
948
|
+
request_payload = None
|
|
949
|
+
http_request = {
|
|
950
|
+
"payload": request_payload,
|
|
951
|
+
"requestMethod": method,
|
|
952
|
+
"requestUrl": request_url,
|
|
953
|
+
"headers": dict(metadata),
|
|
954
|
+
}
|
|
955
|
+
_LOGGER.debug(
|
|
956
|
+
f"Sending request for google.cloud.devicestreaming_v1.DirectAccessServiceClient.ListDeviceSessions",
|
|
957
|
+
extra={
|
|
958
|
+
"serviceName": "google.cloud.devicestreaming.v1.DirectAccessService",
|
|
959
|
+
"rpcName": "ListDeviceSessions",
|
|
960
|
+
"httpRequest": http_request,
|
|
961
|
+
"metadata": http_request["headers"],
|
|
962
|
+
},
|
|
963
|
+
)
|
|
964
|
+
|
|
965
|
+
# Send the request
|
|
966
|
+
response = (
|
|
967
|
+
DirectAccessServiceRestTransport._ListDeviceSessions._get_response(
|
|
968
|
+
self._host,
|
|
969
|
+
metadata,
|
|
970
|
+
query_params,
|
|
971
|
+
self._session,
|
|
972
|
+
timeout,
|
|
973
|
+
transcoded_request,
|
|
974
|
+
)
|
|
975
|
+
)
|
|
976
|
+
|
|
977
|
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
|
978
|
+
# subclass.
|
|
979
|
+
if response.status_code >= 400:
|
|
980
|
+
raise core_exceptions.from_http_response(response)
|
|
981
|
+
|
|
982
|
+
# Return the response
|
|
983
|
+
resp = service.ListDeviceSessionsResponse()
|
|
984
|
+
pb_resp = service.ListDeviceSessionsResponse.pb(resp)
|
|
985
|
+
|
|
986
|
+
json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
|
|
987
|
+
|
|
988
|
+
resp = self._interceptor.post_list_device_sessions(resp)
|
|
989
|
+
response_metadata = [(k, str(v)) for k, v in response.headers.items()]
|
|
990
|
+
resp, _ = self._interceptor.post_list_device_sessions_with_metadata(
|
|
991
|
+
resp, response_metadata
|
|
992
|
+
)
|
|
993
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
994
|
+
logging.DEBUG
|
|
995
|
+
): # pragma: NO COVER
|
|
996
|
+
try:
|
|
997
|
+
response_payload = service.ListDeviceSessionsResponse.to_json(
|
|
998
|
+
response
|
|
999
|
+
)
|
|
1000
|
+
except:
|
|
1001
|
+
response_payload = None
|
|
1002
|
+
http_response = {
|
|
1003
|
+
"payload": response_payload,
|
|
1004
|
+
"headers": dict(response.headers),
|
|
1005
|
+
"status": response.status_code,
|
|
1006
|
+
}
|
|
1007
|
+
_LOGGER.debug(
|
|
1008
|
+
"Received response for google.cloud.devicestreaming_v1.DirectAccessServiceClient.list_device_sessions",
|
|
1009
|
+
extra={
|
|
1010
|
+
"serviceName": "google.cloud.devicestreaming.v1.DirectAccessService",
|
|
1011
|
+
"rpcName": "ListDeviceSessions",
|
|
1012
|
+
"metadata": http_response["headers"],
|
|
1013
|
+
"httpResponse": http_response,
|
|
1014
|
+
},
|
|
1015
|
+
)
|
|
1016
|
+
return resp
|
|
1017
|
+
|
|
1018
|
+
class _UpdateDeviceSession(
|
|
1019
|
+
_BaseDirectAccessServiceRestTransport._BaseUpdateDeviceSession,
|
|
1020
|
+
DirectAccessServiceRestStub,
|
|
1021
|
+
):
|
|
1022
|
+
def __hash__(self):
|
|
1023
|
+
return hash("DirectAccessServiceRestTransport.UpdateDeviceSession")
|
|
1024
|
+
|
|
1025
|
+
@staticmethod
|
|
1026
|
+
def _get_response(
|
|
1027
|
+
host,
|
|
1028
|
+
metadata,
|
|
1029
|
+
query_params,
|
|
1030
|
+
session,
|
|
1031
|
+
timeout,
|
|
1032
|
+
transcoded_request,
|
|
1033
|
+
body=None,
|
|
1034
|
+
):
|
|
1035
|
+
uri = transcoded_request["uri"]
|
|
1036
|
+
method = transcoded_request["method"]
|
|
1037
|
+
headers = dict(metadata)
|
|
1038
|
+
headers["Content-Type"] = "application/json"
|
|
1039
|
+
response = getattr(session, method)(
|
|
1040
|
+
"{host}{uri}".format(host=host, uri=uri),
|
|
1041
|
+
timeout=timeout,
|
|
1042
|
+
headers=headers,
|
|
1043
|
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
|
1044
|
+
data=body,
|
|
1045
|
+
)
|
|
1046
|
+
return response
|
|
1047
|
+
|
|
1048
|
+
def __call__(
|
|
1049
|
+
self,
|
|
1050
|
+
request: service.UpdateDeviceSessionRequest,
|
|
1051
|
+
*,
|
|
1052
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
1053
|
+
timeout: Optional[float] = None,
|
|
1054
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
1055
|
+
) -> service.DeviceSession:
|
|
1056
|
+
r"""Call the update device session method over HTTP.
|
|
1057
|
+
|
|
1058
|
+
Args:
|
|
1059
|
+
request (~.service.UpdateDeviceSessionRequest):
|
|
1060
|
+
The request object. Request message for
|
|
1061
|
+
DirectAccessService.UpdateDeviceSession.
|
|
1062
|
+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
1063
|
+
should be retried.
|
|
1064
|
+
timeout (float): The timeout for this request.
|
|
1065
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
1066
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
1067
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
1068
|
+
be of type `bytes`.
|
|
1069
|
+
|
|
1070
|
+
Returns:
|
|
1071
|
+
~.service.DeviceSession:
|
|
1072
|
+
Protobuf message describing the
|
|
1073
|
+
device message, used from several RPCs.
|
|
1074
|
+
|
|
1075
|
+
"""
|
|
1076
|
+
|
|
1077
|
+
http_options = (
|
|
1078
|
+
_BaseDirectAccessServiceRestTransport._BaseUpdateDeviceSession._get_http_options()
|
|
1079
|
+
)
|
|
1080
|
+
|
|
1081
|
+
request, metadata = self._interceptor.pre_update_device_session(
|
|
1082
|
+
request, metadata
|
|
1083
|
+
)
|
|
1084
|
+
transcoded_request = _BaseDirectAccessServiceRestTransport._BaseUpdateDeviceSession._get_transcoded_request(
|
|
1085
|
+
http_options, request
|
|
1086
|
+
)
|
|
1087
|
+
|
|
1088
|
+
body = _BaseDirectAccessServiceRestTransport._BaseUpdateDeviceSession._get_request_body_json(
|
|
1089
|
+
transcoded_request
|
|
1090
|
+
)
|
|
1091
|
+
|
|
1092
|
+
# Jsonify the query params
|
|
1093
|
+
query_params = _BaseDirectAccessServiceRestTransport._BaseUpdateDeviceSession._get_query_params_json(
|
|
1094
|
+
transcoded_request
|
|
1095
|
+
)
|
|
1096
|
+
|
|
1097
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
1098
|
+
logging.DEBUG
|
|
1099
|
+
): # pragma: NO COVER
|
|
1100
|
+
request_url = "{host}{uri}".format(
|
|
1101
|
+
host=self._host, uri=transcoded_request["uri"]
|
|
1102
|
+
)
|
|
1103
|
+
method = transcoded_request["method"]
|
|
1104
|
+
try:
|
|
1105
|
+
request_payload = type(request).to_json(request)
|
|
1106
|
+
except:
|
|
1107
|
+
request_payload = None
|
|
1108
|
+
http_request = {
|
|
1109
|
+
"payload": request_payload,
|
|
1110
|
+
"requestMethod": method,
|
|
1111
|
+
"requestUrl": request_url,
|
|
1112
|
+
"headers": dict(metadata),
|
|
1113
|
+
}
|
|
1114
|
+
_LOGGER.debug(
|
|
1115
|
+
f"Sending request for google.cloud.devicestreaming_v1.DirectAccessServiceClient.UpdateDeviceSession",
|
|
1116
|
+
extra={
|
|
1117
|
+
"serviceName": "google.cloud.devicestreaming.v1.DirectAccessService",
|
|
1118
|
+
"rpcName": "UpdateDeviceSession",
|
|
1119
|
+
"httpRequest": http_request,
|
|
1120
|
+
"metadata": http_request["headers"],
|
|
1121
|
+
},
|
|
1122
|
+
)
|
|
1123
|
+
|
|
1124
|
+
# Send the request
|
|
1125
|
+
response = (
|
|
1126
|
+
DirectAccessServiceRestTransport._UpdateDeviceSession._get_response(
|
|
1127
|
+
self._host,
|
|
1128
|
+
metadata,
|
|
1129
|
+
query_params,
|
|
1130
|
+
self._session,
|
|
1131
|
+
timeout,
|
|
1132
|
+
transcoded_request,
|
|
1133
|
+
body,
|
|
1134
|
+
)
|
|
1135
|
+
)
|
|
1136
|
+
|
|
1137
|
+
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
|
1138
|
+
# subclass.
|
|
1139
|
+
if response.status_code >= 400:
|
|
1140
|
+
raise core_exceptions.from_http_response(response)
|
|
1141
|
+
|
|
1142
|
+
# Return the response
|
|
1143
|
+
resp = service.DeviceSession()
|
|
1144
|
+
pb_resp = service.DeviceSession.pb(resp)
|
|
1145
|
+
|
|
1146
|
+
json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
|
|
1147
|
+
|
|
1148
|
+
resp = self._interceptor.post_update_device_session(resp)
|
|
1149
|
+
response_metadata = [(k, str(v)) for k, v in response.headers.items()]
|
|
1150
|
+
resp, _ = self._interceptor.post_update_device_session_with_metadata(
|
|
1151
|
+
resp, response_metadata
|
|
1152
|
+
)
|
|
1153
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
1154
|
+
logging.DEBUG
|
|
1155
|
+
): # pragma: NO COVER
|
|
1156
|
+
try:
|
|
1157
|
+
response_payload = service.DeviceSession.to_json(response)
|
|
1158
|
+
except:
|
|
1159
|
+
response_payload = None
|
|
1160
|
+
http_response = {
|
|
1161
|
+
"payload": response_payload,
|
|
1162
|
+
"headers": dict(response.headers),
|
|
1163
|
+
"status": response.status_code,
|
|
1164
|
+
}
|
|
1165
|
+
_LOGGER.debug(
|
|
1166
|
+
"Received response for google.cloud.devicestreaming_v1.DirectAccessServiceClient.update_device_session",
|
|
1167
|
+
extra={
|
|
1168
|
+
"serviceName": "google.cloud.devicestreaming.v1.DirectAccessService",
|
|
1169
|
+
"rpcName": "UpdateDeviceSession",
|
|
1170
|
+
"metadata": http_response["headers"],
|
|
1171
|
+
"httpResponse": http_response,
|
|
1172
|
+
},
|
|
1173
|
+
)
|
|
1174
|
+
return resp
|
|
1175
|
+
|
|
1176
|
+
@property
|
|
1177
|
+
def adb_connect(
|
|
1178
|
+
self,
|
|
1179
|
+
) -> Callable[[adb_service.AdbMessage], adb_service.DeviceMessage]:
|
|
1180
|
+
# The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
|
|
1181
|
+
# In C++ this would require a dynamic_cast
|
|
1182
|
+
return self._AdbConnect(self._session, self._host, self._interceptor) # type: ignore
|
|
1183
|
+
|
|
1184
|
+
@property
|
|
1185
|
+
def cancel_device_session(
|
|
1186
|
+
self,
|
|
1187
|
+
) -> Callable[[service.CancelDeviceSessionRequest], empty_pb2.Empty]:
|
|
1188
|
+
# The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
|
|
1189
|
+
# In C++ this would require a dynamic_cast
|
|
1190
|
+
return self._CancelDeviceSession(self._session, self._host, self._interceptor) # type: ignore
|
|
1191
|
+
|
|
1192
|
+
@property
|
|
1193
|
+
def create_device_session(
|
|
1194
|
+
self,
|
|
1195
|
+
) -> Callable[[service.CreateDeviceSessionRequest], service.DeviceSession]:
|
|
1196
|
+
# The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
|
|
1197
|
+
# In C++ this would require a dynamic_cast
|
|
1198
|
+
return self._CreateDeviceSession(self._session, self._host, self._interceptor) # type: ignore
|
|
1199
|
+
|
|
1200
|
+
@property
|
|
1201
|
+
def get_device_session(
|
|
1202
|
+
self,
|
|
1203
|
+
) -> Callable[[service.GetDeviceSessionRequest], service.DeviceSession]:
|
|
1204
|
+
# The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
|
|
1205
|
+
# In C++ this would require a dynamic_cast
|
|
1206
|
+
return self._GetDeviceSession(self._session, self._host, self._interceptor) # type: ignore
|
|
1207
|
+
|
|
1208
|
+
@property
|
|
1209
|
+
def list_device_sessions(
|
|
1210
|
+
self,
|
|
1211
|
+
) -> Callable[
|
|
1212
|
+
[service.ListDeviceSessionsRequest], service.ListDeviceSessionsResponse
|
|
1213
|
+
]:
|
|
1214
|
+
# The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
|
|
1215
|
+
# In C++ this would require a dynamic_cast
|
|
1216
|
+
return self._ListDeviceSessions(self._session, self._host, self._interceptor) # type: ignore
|
|
1217
|
+
|
|
1218
|
+
@property
|
|
1219
|
+
def update_device_session(
|
|
1220
|
+
self,
|
|
1221
|
+
) -> Callable[[service.UpdateDeviceSessionRequest], service.DeviceSession]:
|
|
1222
|
+
# The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
|
|
1223
|
+
# In C++ this would require a dynamic_cast
|
|
1224
|
+
return self._UpdateDeviceSession(self._session, self._host, self._interceptor) # type: ignore
|
|
1225
|
+
|
|
1226
|
+
@property
|
|
1227
|
+
def kind(self) -> str:
|
|
1228
|
+
return "rest"
|
|
1229
|
+
|
|
1230
|
+
def close(self):
|
|
1231
|
+
self._session.close()
|
|
1232
|
+
|
|
1233
|
+
|
|
1234
|
+
__all__ = ("DirectAccessServiceRestTransport",)
|