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.
Files changed (26) hide show
  1. google/cloud/devicestreaming/__init__.py +69 -0
  2. google/cloud/devicestreaming/gapic_version.py +16 -0
  3. google/cloud/devicestreaming/py.typed +2 -0
  4. google/cloud/devicestreaming_v1/__init__.py +67 -0
  5. google/cloud/devicestreaming_v1/gapic_metadata.json +118 -0
  6. google/cloud/devicestreaming_v1/gapic_version.py +16 -0
  7. google/cloud/devicestreaming_v1/py.typed +2 -0
  8. google/cloud/devicestreaming_v1/services/__init__.py +15 -0
  9. google/cloud/devicestreaming_v1/services/direct_access_service/__init__.py +22 -0
  10. google/cloud/devicestreaming_v1/services/direct_access_service/async_client.py +1001 -0
  11. google/cloud/devicestreaming_v1/services/direct_access_service/client.py +1410 -0
  12. google/cloud/devicestreaming_v1/services/direct_access_service/pagers.py +197 -0
  13. google/cloud/devicestreaming_v1/services/direct_access_service/transports/__init__.py +38 -0
  14. google/cloud/devicestreaming_v1/services/direct_access_service/transports/base.py +262 -0
  15. google/cloud/devicestreaming_v1/services/direct_access_service/transports/grpc.py +512 -0
  16. google/cloud/devicestreaming_v1/services/direct_access_service/transports/grpc_asyncio.py +592 -0
  17. google/cloud/devicestreaming_v1/services/direct_access_service/transports/rest.py +1234 -0
  18. google/cloud/devicestreaming_v1/services/direct_access_service/transports/rest_base.py +361 -0
  19. google/cloud/devicestreaming_v1/types/__init__.py +56 -0
  20. google/cloud/devicestreaming_v1/types/adb_service.py +317 -0
  21. google/cloud/devicestreaming_v1/types/service.py +410 -0
  22. google_cloud_devicestreaming-0.1.0.dist-info/LICENSE +202 -0
  23. google_cloud_devicestreaming-0.1.0.dist-info/METADATA +228 -0
  24. google_cloud_devicestreaming-0.1.0.dist-info/RECORD +26 -0
  25. google_cloud_devicestreaming-0.1.0.dist-info/WHEEL +5 -0
  26. google_cloud_devicestreaming-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,592 @@
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 inspect
17
+ import json
18
+ import logging as std_logging
19
+ import pickle
20
+ from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union
21
+ import warnings
22
+
23
+ from google.api_core import exceptions as core_exceptions
24
+ from google.api_core import gapic_v1, grpc_helpers_async
25
+ from google.api_core import retry_async as retries
26
+ from google.auth import credentials as ga_credentials # type: ignore
27
+ from google.auth.transport.grpc import SslCredentials # type: ignore
28
+ from google.protobuf import empty_pb2 # type: ignore
29
+ from google.protobuf.json_format import MessageToJson
30
+ import google.protobuf.message
31
+ import grpc # type: ignore
32
+ from grpc.experimental import aio # type: ignore
33
+ import proto # type: ignore
34
+
35
+ from google.cloud.devicestreaming_v1.types import adb_service, service
36
+
37
+ from .base import DEFAULT_CLIENT_INFO, DirectAccessServiceTransport
38
+ from .grpc import DirectAccessServiceGrpcTransport
39
+
40
+ try:
41
+ from google.api_core import client_logging # type: ignore
42
+
43
+ CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
44
+ except ImportError: # pragma: NO COVER
45
+ CLIENT_LOGGING_SUPPORTED = False
46
+
47
+ _LOGGER = std_logging.getLogger(__name__)
48
+
49
+
50
+ class _LoggingClientAIOInterceptor(
51
+ grpc.aio.UnaryUnaryClientInterceptor
52
+ ): # pragma: NO COVER
53
+ async def intercept_unary_unary(self, continuation, client_call_details, request):
54
+ logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
55
+ std_logging.DEBUG
56
+ )
57
+ if logging_enabled: # pragma: NO COVER
58
+ request_metadata = client_call_details.metadata
59
+ if isinstance(request, proto.Message):
60
+ request_payload = type(request).to_json(request)
61
+ elif isinstance(request, google.protobuf.message.Message):
62
+ request_payload = MessageToJson(request)
63
+ else:
64
+ request_payload = f"{type(request).__name__}: {pickle.dumps(request)}"
65
+
66
+ request_metadata = {
67
+ key: value.decode("utf-8") if isinstance(value, bytes) else value
68
+ for key, value in request_metadata
69
+ }
70
+ grpc_request = {
71
+ "payload": request_payload,
72
+ "requestMethod": "grpc",
73
+ "metadata": dict(request_metadata),
74
+ }
75
+ _LOGGER.debug(
76
+ f"Sending request for {client_call_details.method}",
77
+ extra={
78
+ "serviceName": "google.cloud.devicestreaming.v1.DirectAccessService",
79
+ "rpcName": str(client_call_details.method),
80
+ "request": grpc_request,
81
+ "metadata": grpc_request["metadata"],
82
+ },
83
+ )
84
+ response = await continuation(client_call_details, request)
85
+ if logging_enabled: # pragma: NO COVER
86
+ response_metadata = await response.trailing_metadata()
87
+ # Convert gRPC metadata `<class 'grpc.aio._metadata.Metadata'>` to list of tuples
88
+ metadata = (
89
+ dict([(k, str(v)) for k, v in response_metadata])
90
+ if response_metadata
91
+ else None
92
+ )
93
+ result = await response
94
+ if isinstance(result, proto.Message):
95
+ response_payload = type(result).to_json(result)
96
+ elif isinstance(result, google.protobuf.message.Message):
97
+ response_payload = MessageToJson(result)
98
+ else:
99
+ response_payload = f"{type(result).__name__}: {pickle.dumps(result)}"
100
+ grpc_response = {
101
+ "payload": response_payload,
102
+ "metadata": metadata,
103
+ "status": "OK",
104
+ }
105
+ _LOGGER.debug(
106
+ f"Received response to rpc {client_call_details.method}.",
107
+ extra={
108
+ "serviceName": "google.cloud.devicestreaming.v1.DirectAccessService",
109
+ "rpcName": str(client_call_details.method),
110
+ "response": grpc_response,
111
+ "metadata": grpc_response["metadata"],
112
+ },
113
+ )
114
+ return response
115
+
116
+
117
+ class DirectAccessServiceGrpcAsyncIOTransport(DirectAccessServiceTransport):
118
+ """gRPC AsyncIO backend transport for DirectAccessService.
119
+
120
+ A service for allocating Android devices and interacting with
121
+ the live-allocated devices.
122
+
123
+ Each Session will wait for available capacity, at a higher
124
+ priority over Test Execution. When allocated, the session will
125
+ be exposed through a stream for integration.
126
+
127
+ DirectAccessService is currently available as a preview to
128
+ select developers. You can register today on behalf of you and
129
+ your team at
130
+ https://developer.android.com/studio/preview/android-device-streaming
131
+
132
+ This class defines the same methods as the primary client, so the
133
+ primary client can load the underlying transport implementation
134
+ and call it.
135
+
136
+ It sends protocol buffers over the wire using gRPC (which is built on
137
+ top of HTTP/2); the ``grpcio`` package must be installed.
138
+ """
139
+
140
+ _grpc_channel: aio.Channel
141
+ _stubs: Dict[str, Callable] = {}
142
+
143
+ @classmethod
144
+ def create_channel(
145
+ cls,
146
+ host: str = "devicestreaming.googleapis.com",
147
+ credentials: Optional[ga_credentials.Credentials] = None,
148
+ credentials_file: Optional[str] = None,
149
+ scopes: Optional[Sequence[str]] = None,
150
+ quota_project_id: Optional[str] = None,
151
+ **kwargs,
152
+ ) -> aio.Channel:
153
+ """Create and return a gRPC AsyncIO channel object.
154
+ Args:
155
+ host (Optional[str]): The host for the channel to use.
156
+ credentials (Optional[~.Credentials]): The
157
+ authorization credentials to attach to requests. These
158
+ credentials identify this application to the service. If
159
+ none are specified, the client will attempt to ascertain
160
+ the credentials from the environment.
161
+ credentials_file (Optional[str]): A file with credentials that can
162
+ be loaded with :func:`google.auth.load_credentials_from_file`.
163
+ scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
164
+ service. These are only used when credentials are not specified and
165
+ are passed to :func:`google.auth.default`.
166
+ quota_project_id (Optional[str]): An optional project to use for billing
167
+ and quota.
168
+ kwargs (Optional[dict]): Keyword arguments, which are passed to the
169
+ channel creation.
170
+ Returns:
171
+ aio.Channel: A gRPC AsyncIO channel object.
172
+ """
173
+
174
+ return grpc_helpers_async.create_channel(
175
+ host,
176
+ credentials=credentials,
177
+ credentials_file=credentials_file,
178
+ quota_project_id=quota_project_id,
179
+ default_scopes=cls.AUTH_SCOPES,
180
+ scopes=scopes,
181
+ default_host=cls.DEFAULT_HOST,
182
+ **kwargs,
183
+ )
184
+
185
+ def __init__(
186
+ self,
187
+ *,
188
+ host: str = "devicestreaming.googleapis.com",
189
+ credentials: Optional[ga_credentials.Credentials] = None,
190
+ credentials_file: Optional[str] = None,
191
+ scopes: Optional[Sequence[str]] = None,
192
+ channel: Optional[Union[aio.Channel, Callable[..., aio.Channel]]] = None,
193
+ api_mtls_endpoint: Optional[str] = None,
194
+ client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
195
+ ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None,
196
+ client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
197
+ quota_project_id: Optional[str] = None,
198
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
199
+ always_use_jwt_access: Optional[bool] = False,
200
+ api_audience: Optional[str] = None,
201
+ ) -> None:
202
+ """Instantiate the transport.
203
+
204
+ Args:
205
+ host (Optional[str]):
206
+ The hostname to connect to (default: 'devicestreaming.googleapis.com').
207
+ credentials (Optional[google.auth.credentials.Credentials]): The
208
+ authorization credentials to attach to requests. These
209
+ credentials identify the application to the service; if none
210
+ are specified, the client will attempt to ascertain the
211
+ credentials from the environment.
212
+ This argument is ignored if a ``channel`` instance is provided.
213
+ credentials_file (Optional[str]): A file with credentials that can
214
+ be loaded with :func:`google.auth.load_credentials_from_file`.
215
+ This argument is ignored if a ``channel`` instance is provided.
216
+ scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
217
+ service. These are only used when credentials are not specified and
218
+ are passed to :func:`google.auth.default`.
219
+ channel (Optional[Union[aio.Channel, Callable[..., aio.Channel]]]):
220
+ A ``Channel`` instance through which to make calls, or a Callable
221
+ that constructs and returns one. If set to None, ``self.create_channel``
222
+ is used to create the channel. If a Callable is given, it will be called
223
+ with the same arguments as used in ``self.create_channel``.
224
+ api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
225
+ If provided, it overrides the ``host`` argument and tries to create
226
+ a mutual TLS channel with client SSL credentials from
227
+ ``client_cert_source`` or application default SSL credentials.
228
+ client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
229
+ Deprecated. A callback to provide client SSL certificate bytes and
230
+ private key bytes, both in PEM format. It is ignored if
231
+ ``api_mtls_endpoint`` is None.
232
+ ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
233
+ for the grpc channel. It is ignored if a ``channel`` instance is provided.
234
+ client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]):
235
+ A callback to provide client certificate bytes and private key bytes,
236
+ both in PEM format. It is used to configure a mutual TLS channel. It is
237
+ ignored if a ``channel`` instance or ``ssl_channel_credentials`` is provided.
238
+ quota_project_id (Optional[str]): An optional project to use for billing
239
+ and quota.
240
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
241
+ The client info used to send a user-agent string along with
242
+ API requests. If ``None``, then default info will be used.
243
+ Generally, you only need to set this if you're developing
244
+ your own client library.
245
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
246
+ be used for service account credentials.
247
+
248
+ Raises:
249
+ google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
250
+ creation failed for any reason.
251
+ google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
252
+ and ``credentials_file`` are passed.
253
+ """
254
+ self._grpc_channel = None
255
+ self._ssl_channel_credentials = ssl_channel_credentials
256
+ self._stubs: Dict[str, Callable] = {}
257
+
258
+ if api_mtls_endpoint:
259
+ warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
260
+ if client_cert_source:
261
+ warnings.warn("client_cert_source is deprecated", DeprecationWarning)
262
+
263
+ if isinstance(channel, aio.Channel):
264
+ # Ignore credentials if a channel was passed.
265
+ credentials = None
266
+ self._ignore_credentials = True
267
+ # If a channel was explicitly provided, set it.
268
+ self._grpc_channel = channel
269
+ self._ssl_channel_credentials = None
270
+ else:
271
+ if api_mtls_endpoint:
272
+ host = api_mtls_endpoint
273
+
274
+ # Create SSL credentials with client_cert_source or application
275
+ # default SSL credentials.
276
+ if client_cert_source:
277
+ cert, key = client_cert_source()
278
+ self._ssl_channel_credentials = grpc.ssl_channel_credentials(
279
+ certificate_chain=cert, private_key=key
280
+ )
281
+ else:
282
+ self._ssl_channel_credentials = SslCredentials().ssl_credentials
283
+
284
+ else:
285
+ if client_cert_source_for_mtls and not ssl_channel_credentials:
286
+ cert, key = client_cert_source_for_mtls()
287
+ self._ssl_channel_credentials = grpc.ssl_channel_credentials(
288
+ certificate_chain=cert, private_key=key
289
+ )
290
+
291
+ # The base transport sets the host, credentials and scopes
292
+ super().__init__(
293
+ host=host,
294
+ credentials=credentials,
295
+ credentials_file=credentials_file,
296
+ scopes=scopes,
297
+ quota_project_id=quota_project_id,
298
+ client_info=client_info,
299
+ always_use_jwt_access=always_use_jwt_access,
300
+ api_audience=api_audience,
301
+ )
302
+
303
+ if not self._grpc_channel:
304
+ # initialize with the provided callable or the default channel
305
+ channel_init = channel or type(self).create_channel
306
+ self._grpc_channel = channel_init(
307
+ self._host,
308
+ # use the credentials which are saved
309
+ credentials=self._credentials,
310
+ # Set ``credentials_file`` to ``None`` here as
311
+ # the credentials that we saved earlier should be used.
312
+ credentials_file=None,
313
+ scopes=self._scopes,
314
+ ssl_credentials=self._ssl_channel_credentials,
315
+ quota_project_id=quota_project_id,
316
+ options=[
317
+ ("grpc.max_send_message_length", -1),
318
+ ("grpc.max_receive_message_length", -1),
319
+ ],
320
+ )
321
+
322
+ self._interceptor = _LoggingClientAIOInterceptor()
323
+ self._grpc_channel._unary_unary_interceptors.append(self._interceptor)
324
+ self._logged_channel = self._grpc_channel
325
+ self._wrap_with_kind = (
326
+ "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters
327
+ )
328
+ # Wrap messages. This must be done after self._logged_channel exists
329
+ self._prep_wrapped_messages(client_info)
330
+
331
+ @property
332
+ def grpc_channel(self) -> aio.Channel:
333
+ """Create the channel designed to connect to this service.
334
+
335
+ This property caches on the instance; repeated calls return
336
+ the same channel.
337
+ """
338
+ # Return the channel from cache.
339
+ return self._grpc_channel
340
+
341
+ @property
342
+ def create_device_session(
343
+ self,
344
+ ) -> Callable[
345
+ [service.CreateDeviceSessionRequest], Awaitable[service.DeviceSession]
346
+ ]:
347
+ r"""Return a callable for the create device session method over gRPC.
348
+
349
+ Creates a DeviceSession.
350
+
351
+ Returns:
352
+ Callable[[~.CreateDeviceSessionRequest],
353
+ Awaitable[~.DeviceSession]]:
354
+ A function that, when called, will call the underlying RPC
355
+ on the server.
356
+ """
357
+ # Generate a "stub function" on-the-fly which will actually make
358
+ # the request.
359
+ # gRPC handles serialization and deserialization, so we just need
360
+ # to pass in the functions for each.
361
+ if "create_device_session" not in self._stubs:
362
+ self._stubs["create_device_session"] = self._logged_channel.unary_unary(
363
+ "/google.cloud.devicestreaming.v1.DirectAccessService/CreateDeviceSession",
364
+ request_serializer=service.CreateDeviceSessionRequest.serialize,
365
+ response_deserializer=service.DeviceSession.deserialize,
366
+ )
367
+ return self._stubs["create_device_session"]
368
+
369
+ @property
370
+ def list_device_sessions(
371
+ self,
372
+ ) -> Callable[
373
+ [service.ListDeviceSessionsRequest],
374
+ Awaitable[service.ListDeviceSessionsResponse],
375
+ ]:
376
+ r"""Return a callable for the list device sessions method over gRPC.
377
+
378
+ Lists DeviceSessions owned by the project user.
379
+
380
+ Returns:
381
+ Callable[[~.ListDeviceSessionsRequest],
382
+ Awaitable[~.ListDeviceSessionsResponse]]:
383
+ A function that, when called, will call the underlying RPC
384
+ on the server.
385
+ """
386
+ # Generate a "stub function" on-the-fly which will actually make
387
+ # the request.
388
+ # gRPC handles serialization and deserialization, so we just need
389
+ # to pass in the functions for each.
390
+ if "list_device_sessions" not in self._stubs:
391
+ self._stubs["list_device_sessions"] = self._logged_channel.unary_unary(
392
+ "/google.cloud.devicestreaming.v1.DirectAccessService/ListDeviceSessions",
393
+ request_serializer=service.ListDeviceSessionsRequest.serialize,
394
+ response_deserializer=service.ListDeviceSessionsResponse.deserialize,
395
+ )
396
+ return self._stubs["list_device_sessions"]
397
+
398
+ @property
399
+ def get_device_session(
400
+ self,
401
+ ) -> Callable[[service.GetDeviceSessionRequest], Awaitable[service.DeviceSession]]:
402
+ r"""Return a callable for the get device session method over gRPC.
403
+
404
+ Gets a DeviceSession, which documents the allocation
405
+ status and whether the device is allocated. Clients
406
+ making requests from this API must poll
407
+ GetDeviceSession.
408
+
409
+ Returns:
410
+ Callable[[~.GetDeviceSessionRequest],
411
+ Awaitable[~.DeviceSession]]:
412
+ A function that, when called, will call the underlying RPC
413
+ on the server.
414
+ """
415
+ # Generate a "stub function" on-the-fly which will actually make
416
+ # the request.
417
+ # gRPC handles serialization and deserialization, so we just need
418
+ # to pass in the functions for each.
419
+ if "get_device_session" not in self._stubs:
420
+ self._stubs["get_device_session"] = self._logged_channel.unary_unary(
421
+ "/google.cloud.devicestreaming.v1.DirectAccessService/GetDeviceSession",
422
+ request_serializer=service.GetDeviceSessionRequest.serialize,
423
+ response_deserializer=service.DeviceSession.deserialize,
424
+ )
425
+ return self._stubs["get_device_session"]
426
+
427
+ @property
428
+ def cancel_device_session(
429
+ self,
430
+ ) -> Callable[[service.CancelDeviceSessionRequest], Awaitable[empty_pb2.Empty]]:
431
+ r"""Return a callable for the cancel device session method over gRPC.
432
+
433
+ Cancel a DeviceSession.
434
+ This RPC changes the DeviceSession to state FINISHED and
435
+ terminates all connections.
436
+ Canceled sessions are not deleted and can be retrieved
437
+ or listed by the user until they expire based on the 28
438
+ day deletion policy.
439
+
440
+ Returns:
441
+ Callable[[~.CancelDeviceSessionRequest],
442
+ Awaitable[~.Empty]]:
443
+ A function that, when called, will call the underlying RPC
444
+ on the server.
445
+ """
446
+ # Generate a "stub function" on-the-fly which will actually make
447
+ # the request.
448
+ # gRPC handles serialization and deserialization, so we just need
449
+ # to pass in the functions for each.
450
+ if "cancel_device_session" not in self._stubs:
451
+ self._stubs["cancel_device_session"] = self._logged_channel.unary_unary(
452
+ "/google.cloud.devicestreaming.v1.DirectAccessService/CancelDeviceSession",
453
+ request_serializer=service.CancelDeviceSessionRequest.serialize,
454
+ response_deserializer=empty_pb2.Empty.FromString,
455
+ )
456
+ return self._stubs["cancel_device_session"]
457
+
458
+ @property
459
+ def update_device_session(
460
+ self,
461
+ ) -> Callable[
462
+ [service.UpdateDeviceSessionRequest], Awaitable[service.DeviceSession]
463
+ ]:
464
+ r"""Return a callable for the update device session method over gRPC.
465
+
466
+ Updates the current DeviceSession to the fields described by the
467
+ update_mask.
468
+
469
+ Returns:
470
+ Callable[[~.UpdateDeviceSessionRequest],
471
+ Awaitable[~.DeviceSession]]:
472
+ A function that, when called, will call the underlying RPC
473
+ on the server.
474
+ """
475
+ # Generate a "stub function" on-the-fly which will actually make
476
+ # the request.
477
+ # gRPC handles serialization and deserialization, so we just need
478
+ # to pass in the functions for each.
479
+ if "update_device_session" not in self._stubs:
480
+ self._stubs["update_device_session"] = self._logged_channel.unary_unary(
481
+ "/google.cloud.devicestreaming.v1.DirectAccessService/UpdateDeviceSession",
482
+ request_serializer=service.UpdateDeviceSessionRequest.serialize,
483
+ response_deserializer=service.DeviceSession.deserialize,
484
+ )
485
+ return self._stubs["update_device_session"]
486
+
487
+ @property
488
+ def adb_connect(
489
+ self,
490
+ ) -> Callable[[adb_service.AdbMessage], Awaitable[adb_service.DeviceMessage]]:
491
+ r"""Return a callable for the adb connect method over gRPC.
492
+
493
+ Exposes an ADB connection if the device supports ADB.
494
+ gRPC headers are used to authenticate the Connect RPC,
495
+ as well as associate to a particular DeviceSession.
496
+ In particular, the user must specify the
497
+ "X-Omnilab-Session-Name" header.
498
+
499
+ Returns:
500
+ Callable[[~.AdbMessage],
501
+ Awaitable[~.DeviceMessage]]:
502
+ A function that, when called, will call the underlying RPC
503
+ on the server.
504
+ """
505
+ # Generate a "stub function" on-the-fly which will actually make
506
+ # the request.
507
+ # gRPC handles serialization and deserialization, so we just need
508
+ # to pass in the functions for each.
509
+ if "adb_connect" not in self._stubs:
510
+ self._stubs["adb_connect"] = self._logged_channel.stream_stream(
511
+ "/google.cloud.devicestreaming.v1.DirectAccessService/AdbConnect",
512
+ request_serializer=adb_service.AdbMessage.serialize,
513
+ response_deserializer=adb_service.DeviceMessage.deserialize,
514
+ )
515
+ return self._stubs["adb_connect"]
516
+
517
+ def _prep_wrapped_messages(self, client_info):
518
+ """Precompute the wrapped methods, overriding the base class method to use async wrappers."""
519
+ self._wrapped_methods = {
520
+ self.create_device_session: self._wrap_method(
521
+ self.create_device_session,
522
+ default_timeout=20.0,
523
+ client_info=client_info,
524
+ ),
525
+ self.list_device_sessions: self._wrap_method(
526
+ self.list_device_sessions,
527
+ default_retry=retries.AsyncRetry(
528
+ initial=1.0,
529
+ maximum=10.0,
530
+ multiplier=1.3,
531
+ predicate=retries.if_exception_type(
532
+ core_exceptions.ServiceUnavailable,
533
+ ),
534
+ deadline=20.0,
535
+ ),
536
+ default_timeout=20.0,
537
+ client_info=client_info,
538
+ ),
539
+ self.get_device_session: self._wrap_method(
540
+ self.get_device_session,
541
+ default_retry=retries.AsyncRetry(
542
+ initial=1.0,
543
+ maximum=10.0,
544
+ multiplier=1.3,
545
+ predicate=retries.if_exception_type(
546
+ core_exceptions.ServiceUnavailable,
547
+ ),
548
+ deadline=20.0,
549
+ ),
550
+ default_timeout=20.0,
551
+ client_info=client_info,
552
+ ),
553
+ self.cancel_device_session: self._wrap_method(
554
+ self.cancel_device_session,
555
+ default_retry=retries.AsyncRetry(
556
+ initial=1.0,
557
+ maximum=10.0,
558
+ multiplier=1.3,
559
+ predicate=retries.if_exception_type(
560
+ core_exceptions.ServiceUnavailable,
561
+ ),
562
+ deadline=20.0,
563
+ ),
564
+ default_timeout=20.0,
565
+ client_info=client_info,
566
+ ),
567
+ self.update_device_session: self._wrap_method(
568
+ self.update_device_session,
569
+ default_timeout=20.0,
570
+ client_info=client_info,
571
+ ),
572
+ self.adb_connect: self._wrap_method(
573
+ self.adb_connect,
574
+ default_timeout=1800.0,
575
+ client_info=client_info,
576
+ ),
577
+ }
578
+
579
+ def _wrap_method(self, func, *args, **kwargs):
580
+ if self._wrap_with_kind: # pragma: NO COVER
581
+ kwargs["kind"] = self.kind
582
+ return gapic_v1.method_async.wrap_method(func, *args, **kwargs)
583
+
584
+ def close(self):
585
+ return self._logged_channel.close()
586
+
587
+ @property
588
+ def kind(self) -> str:
589
+ return "grpc_asyncio"
590
+
591
+
592
+ __all__ = ("DirectAccessServiceGrpcAsyncIOTransport",)