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,1001 @@
|
|
|
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
|
+
from collections import OrderedDict
|
|
17
|
+
import logging as std_logging
|
|
18
|
+
import re
|
|
19
|
+
from typing import (
|
|
20
|
+
AsyncIterable,
|
|
21
|
+
AsyncIterator,
|
|
22
|
+
Awaitable,
|
|
23
|
+
Callable,
|
|
24
|
+
Dict,
|
|
25
|
+
Mapping,
|
|
26
|
+
MutableMapping,
|
|
27
|
+
MutableSequence,
|
|
28
|
+
Optional,
|
|
29
|
+
Sequence,
|
|
30
|
+
Tuple,
|
|
31
|
+
Type,
|
|
32
|
+
Union,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
from google.api_core import exceptions as core_exceptions
|
|
36
|
+
from google.api_core import gapic_v1
|
|
37
|
+
from google.api_core import retry_async as retries
|
|
38
|
+
from google.api_core.client_options import ClientOptions
|
|
39
|
+
from google.auth import credentials as ga_credentials # type: ignore
|
|
40
|
+
from google.oauth2 import service_account # type: ignore
|
|
41
|
+
|
|
42
|
+
from google.cloud.devicestreaming_v1 import gapic_version as package_version
|
|
43
|
+
|
|
44
|
+
try:
|
|
45
|
+
OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault, None]
|
|
46
|
+
except AttributeError: # pragma: NO COVER
|
|
47
|
+
OptionalRetry = Union[retries.AsyncRetry, object, None] # type: ignore
|
|
48
|
+
|
|
49
|
+
from google.protobuf import duration_pb2 # type: ignore
|
|
50
|
+
from google.protobuf import field_mask_pb2 # type: ignore
|
|
51
|
+
from google.protobuf import timestamp_pb2 # type: ignore
|
|
52
|
+
|
|
53
|
+
from google.cloud.devicestreaming_v1.services.direct_access_service import pagers
|
|
54
|
+
from google.cloud.devicestreaming_v1.types import adb_service, service
|
|
55
|
+
|
|
56
|
+
from .client import DirectAccessServiceClient
|
|
57
|
+
from .transports.base import DEFAULT_CLIENT_INFO, DirectAccessServiceTransport
|
|
58
|
+
from .transports.grpc_asyncio import DirectAccessServiceGrpcAsyncIOTransport
|
|
59
|
+
|
|
60
|
+
try:
|
|
61
|
+
from google.api_core import client_logging # type: ignore
|
|
62
|
+
|
|
63
|
+
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
|
|
64
|
+
except ImportError: # pragma: NO COVER
|
|
65
|
+
CLIENT_LOGGING_SUPPORTED = False
|
|
66
|
+
|
|
67
|
+
_LOGGER = std_logging.getLogger(__name__)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class DirectAccessServiceAsyncClient:
|
|
71
|
+
"""A service for allocating Android devices and interacting with
|
|
72
|
+
the live-allocated devices.
|
|
73
|
+
|
|
74
|
+
Each Session will wait for available capacity, at a higher
|
|
75
|
+
priority over Test Execution. When allocated, the session will
|
|
76
|
+
be exposed through a stream for integration.
|
|
77
|
+
|
|
78
|
+
DirectAccessService is currently available as a preview to
|
|
79
|
+
select developers. You can register today on behalf of you and
|
|
80
|
+
your team at
|
|
81
|
+
https://developer.android.com/studio/preview/android-device-streaming
|
|
82
|
+
"""
|
|
83
|
+
|
|
84
|
+
_client: DirectAccessServiceClient
|
|
85
|
+
|
|
86
|
+
# Copy defaults from the synchronous client for use here.
|
|
87
|
+
# Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
|
|
88
|
+
DEFAULT_ENDPOINT = DirectAccessServiceClient.DEFAULT_ENDPOINT
|
|
89
|
+
DEFAULT_MTLS_ENDPOINT = DirectAccessServiceClient.DEFAULT_MTLS_ENDPOINT
|
|
90
|
+
_DEFAULT_ENDPOINT_TEMPLATE = DirectAccessServiceClient._DEFAULT_ENDPOINT_TEMPLATE
|
|
91
|
+
_DEFAULT_UNIVERSE = DirectAccessServiceClient._DEFAULT_UNIVERSE
|
|
92
|
+
|
|
93
|
+
device_session_path = staticmethod(DirectAccessServiceClient.device_session_path)
|
|
94
|
+
parse_device_session_path = staticmethod(
|
|
95
|
+
DirectAccessServiceClient.parse_device_session_path
|
|
96
|
+
)
|
|
97
|
+
common_billing_account_path = staticmethod(
|
|
98
|
+
DirectAccessServiceClient.common_billing_account_path
|
|
99
|
+
)
|
|
100
|
+
parse_common_billing_account_path = staticmethod(
|
|
101
|
+
DirectAccessServiceClient.parse_common_billing_account_path
|
|
102
|
+
)
|
|
103
|
+
common_folder_path = staticmethod(DirectAccessServiceClient.common_folder_path)
|
|
104
|
+
parse_common_folder_path = staticmethod(
|
|
105
|
+
DirectAccessServiceClient.parse_common_folder_path
|
|
106
|
+
)
|
|
107
|
+
common_organization_path = staticmethod(
|
|
108
|
+
DirectAccessServiceClient.common_organization_path
|
|
109
|
+
)
|
|
110
|
+
parse_common_organization_path = staticmethod(
|
|
111
|
+
DirectAccessServiceClient.parse_common_organization_path
|
|
112
|
+
)
|
|
113
|
+
common_project_path = staticmethod(DirectAccessServiceClient.common_project_path)
|
|
114
|
+
parse_common_project_path = staticmethod(
|
|
115
|
+
DirectAccessServiceClient.parse_common_project_path
|
|
116
|
+
)
|
|
117
|
+
common_location_path = staticmethod(DirectAccessServiceClient.common_location_path)
|
|
118
|
+
parse_common_location_path = staticmethod(
|
|
119
|
+
DirectAccessServiceClient.parse_common_location_path
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
@classmethod
|
|
123
|
+
def from_service_account_info(cls, info: dict, *args, **kwargs):
|
|
124
|
+
"""Creates an instance of this client using the provided credentials
|
|
125
|
+
info.
|
|
126
|
+
|
|
127
|
+
Args:
|
|
128
|
+
info (dict): The service account private key info.
|
|
129
|
+
args: Additional arguments to pass to the constructor.
|
|
130
|
+
kwargs: Additional arguments to pass to the constructor.
|
|
131
|
+
|
|
132
|
+
Returns:
|
|
133
|
+
DirectAccessServiceAsyncClient: The constructed client.
|
|
134
|
+
"""
|
|
135
|
+
return DirectAccessServiceClient.from_service_account_info.__func__(DirectAccessServiceAsyncClient, info, *args, **kwargs) # type: ignore
|
|
136
|
+
|
|
137
|
+
@classmethod
|
|
138
|
+
def from_service_account_file(cls, filename: str, *args, **kwargs):
|
|
139
|
+
"""Creates an instance of this client using the provided credentials
|
|
140
|
+
file.
|
|
141
|
+
|
|
142
|
+
Args:
|
|
143
|
+
filename (str): The path to the service account private key json
|
|
144
|
+
file.
|
|
145
|
+
args: Additional arguments to pass to the constructor.
|
|
146
|
+
kwargs: Additional arguments to pass to the constructor.
|
|
147
|
+
|
|
148
|
+
Returns:
|
|
149
|
+
DirectAccessServiceAsyncClient: The constructed client.
|
|
150
|
+
"""
|
|
151
|
+
return DirectAccessServiceClient.from_service_account_file.__func__(DirectAccessServiceAsyncClient, filename, *args, **kwargs) # type: ignore
|
|
152
|
+
|
|
153
|
+
from_service_account_json = from_service_account_file
|
|
154
|
+
|
|
155
|
+
@classmethod
|
|
156
|
+
def get_mtls_endpoint_and_cert_source(
|
|
157
|
+
cls, client_options: Optional[ClientOptions] = None
|
|
158
|
+
):
|
|
159
|
+
"""Return the API endpoint and client cert source for mutual TLS.
|
|
160
|
+
|
|
161
|
+
The client cert source is determined in the following order:
|
|
162
|
+
(1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the
|
|
163
|
+
client cert source is None.
|
|
164
|
+
(2) if `client_options.client_cert_source` is provided, use the provided one; if the
|
|
165
|
+
default client cert source exists, use the default one; otherwise the client cert
|
|
166
|
+
source is None.
|
|
167
|
+
|
|
168
|
+
The API endpoint is determined in the following order:
|
|
169
|
+
(1) if `client_options.api_endpoint` if provided, use the provided one.
|
|
170
|
+
(2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the
|
|
171
|
+
default mTLS endpoint; if the environment variable is "never", use the default API
|
|
172
|
+
endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
|
|
173
|
+
use the default API endpoint.
|
|
174
|
+
|
|
175
|
+
More details can be found at https://google.aip.dev/auth/4114.
|
|
176
|
+
|
|
177
|
+
Args:
|
|
178
|
+
client_options (google.api_core.client_options.ClientOptions): Custom options for the
|
|
179
|
+
client. Only the `api_endpoint` and `client_cert_source` properties may be used
|
|
180
|
+
in this method.
|
|
181
|
+
|
|
182
|
+
Returns:
|
|
183
|
+
Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the
|
|
184
|
+
client cert source to use.
|
|
185
|
+
|
|
186
|
+
Raises:
|
|
187
|
+
google.auth.exceptions.MutualTLSChannelError: If any errors happen.
|
|
188
|
+
"""
|
|
189
|
+
return DirectAccessServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore
|
|
190
|
+
|
|
191
|
+
@property
|
|
192
|
+
def transport(self) -> DirectAccessServiceTransport:
|
|
193
|
+
"""Returns the transport used by the client instance.
|
|
194
|
+
|
|
195
|
+
Returns:
|
|
196
|
+
DirectAccessServiceTransport: The transport used by the client instance.
|
|
197
|
+
"""
|
|
198
|
+
return self._client.transport
|
|
199
|
+
|
|
200
|
+
@property
|
|
201
|
+
def api_endpoint(self):
|
|
202
|
+
"""Return the API endpoint used by the client instance.
|
|
203
|
+
|
|
204
|
+
Returns:
|
|
205
|
+
str: The API endpoint used by the client instance.
|
|
206
|
+
"""
|
|
207
|
+
return self._client._api_endpoint
|
|
208
|
+
|
|
209
|
+
@property
|
|
210
|
+
def universe_domain(self) -> str:
|
|
211
|
+
"""Return the universe domain used by the client instance.
|
|
212
|
+
|
|
213
|
+
Returns:
|
|
214
|
+
str: The universe domain used
|
|
215
|
+
by the client instance.
|
|
216
|
+
"""
|
|
217
|
+
return self._client._universe_domain
|
|
218
|
+
|
|
219
|
+
get_transport_class = DirectAccessServiceClient.get_transport_class
|
|
220
|
+
|
|
221
|
+
def __init__(
|
|
222
|
+
self,
|
|
223
|
+
*,
|
|
224
|
+
credentials: Optional[ga_credentials.Credentials] = None,
|
|
225
|
+
transport: Optional[
|
|
226
|
+
Union[
|
|
227
|
+
str,
|
|
228
|
+
DirectAccessServiceTransport,
|
|
229
|
+
Callable[..., DirectAccessServiceTransport],
|
|
230
|
+
]
|
|
231
|
+
] = "grpc_asyncio",
|
|
232
|
+
client_options: Optional[ClientOptions] = None,
|
|
233
|
+
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
|
|
234
|
+
) -> None:
|
|
235
|
+
"""Instantiates the direct access service async client.
|
|
236
|
+
|
|
237
|
+
Args:
|
|
238
|
+
credentials (Optional[google.auth.credentials.Credentials]): The
|
|
239
|
+
authorization credentials to attach to requests. These
|
|
240
|
+
credentials identify the application to the service; if none
|
|
241
|
+
are specified, the client will attempt to ascertain the
|
|
242
|
+
credentials from the environment.
|
|
243
|
+
transport (Optional[Union[str,DirectAccessServiceTransport,Callable[..., DirectAccessServiceTransport]]]):
|
|
244
|
+
The transport to use, or a Callable that constructs and returns a new transport to use.
|
|
245
|
+
If a Callable is given, it will be called with the same set of initialization
|
|
246
|
+
arguments as used in the DirectAccessServiceTransport constructor.
|
|
247
|
+
If set to None, a transport is chosen automatically.
|
|
248
|
+
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
|
|
249
|
+
Custom options for the client.
|
|
250
|
+
|
|
251
|
+
1. The ``api_endpoint`` property can be used to override the
|
|
252
|
+
default endpoint provided by the client when ``transport`` is
|
|
253
|
+
not explicitly provided. Only if this property is not set and
|
|
254
|
+
``transport`` was not explicitly provided, the endpoint is
|
|
255
|
+
determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
|
|
256
|
+
variable, which have one of the following values:
|
|
257
|
+
"always" (always use the default mTLS endpoint), "never" (always
|
|
258
|
+
use the default regular endpoint) and "auto" (auto-switch to the
|
|
259
|
+
default mTLS endpoint if client certificate is present; this is
|
|
260
|
+
the default value).
|
|
261
|
+
|
|
262
|
+
2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
|
|
263
|
+
is "true", then the ``client_cert_source`` property can be used
|
|
264
|
+
to provide a client certificate for mTLS transport. If
|
|
265
|
+
not provided, the default SSL client certificate will be used if
|
|
266
|
+
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
|
|
267
|
+
set, no client certificate will be used.
|
|
268
|
+
|
|
269
|
+
3. The ``universe_domain`` property can be used to override the
|
|
270
|
+
default "googleapis.com" universe. Note that ``api_endpoint``
|
|
271
|
+
property still takes precedence; and ``universe_domain`` is
|
|
272
|
+
currently not supported for mTLS.
|
|
273
|
+
|
|
274
|
+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
|
|
275
|
+
The client info used to send a user-agent string along with
|
|
276
|
+
API requests. If ``None``, then default info will be used.
|
|
277
|
+
Generally, you only need to set this if you're developing
|
|
278
|
+
your own client library.
|
|
279
|
+
|
|
280
|
+
Raises:
|
|
281
|
+
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
|
|
282
|
+
creation failed for any reason.
|
|
283
|
+
"""
|
|
284
|
+
self._client = DirectAccessServiceClient(
|
|
285
|
+
credentials=credentials,
|
|
286
|
+
transport=transport,
|
|
287
|
+
client_options=client_options,
|
|
288
|
+
client_info=client_info,
|
|
289
|
+
)
|
|
290
|
+
|
|
291
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
292
|
+
std_logging.DEBUG
|
|
293
|
+
): # pragma: NO COVER
|
|
294
|
+
_LOGGER.debug(
|
|
295
|
+
"Created client `google.cloud.devicestreaming_v1.DirectAccessServiceAsyncClient`.",
|
|
296
|
+
extra={
|
|
297
|
+
"serviceName": "google.cloud.devicestreaming.v1.DirectAccessService",
|
|
298
|
+
"universeDomain": getattr(
|
|
299
|
+
self._client._transport._credentials, "universe_domain", ""
|
|
300
|
+
),
|
|
301
|
+
"credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}",
|
|
302
|
+
"credentialsInfo": getattr(
|
|
303
|
+
self.transport._credentials, "get_cred_info", lambda: None
|
|
304
|
+
)(),
|
|
305
|
+
}
|
|
306
|
+
if hasattr(self._client._transport, "_credentials")
|
|
307
|
+
else {
|
|
308
|
+
"serviceName": "google.cloud.devicestreaming.v1.DirectAccessService",
|
|
309
|
+
"credentialsType": None,
|
|
310
|
+
},
|
|
311
|
+
)
|
|
312
|
+
|
|
313
|
+
async def create_device_session(
|
|
314
|
+
self,
|
|
315
|
+
request: Optional[Union[service.CreateDeviceSessionRequest, dict]] = None,
|
|
316
|
+
*,
|
|
317
|
+
parent: Optional[str] = None,
|
|
318
|
+
device_session: Optional[service.DeviceSession] = None,
|
|
319
|
+
device_session_id: Optional[str] = None,
|
|
320
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
321
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
322
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
323
|
+
) -> service.DeviceSession:
|
|
324
|
+
r"""Creates a DeviceSession.
|
|
325
|
+
|
|
326
|
+
.. code-block:: python
|
|
327
|
+
|
|
328
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
329
|
+
# code template only.
|
|
330
|
+
# It will require modifications to work:
|
|
331
|
+
# - It may require correct/in-range values for request initialization.
|
|
332
|
+
# - It may require specifying regional endpoints when creating the service
|
|
333
|
+
# client as shown in:
|
|
334
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
335
|
+
from google.cloud import devicestreaming_v1
|
|
336
|
+
|
|
337
|
+
async def sample_create_device_session():
|
|
338
|
+
# Create a client
|
|
339
|
+
client = devicestreaming_v1.DirectAccessServiceAsyncClient()
|
|
340
|
+
|
|
341
|
+
# Initialize request argument(s)
|
|
342
|
+
device_session = devicestreaming_v1.DeviceSession()
|
|
343
|
+
device_session.android_device.android_model_id = "android_model_id_value"
|
|
344
|
+
device_session.android_device.android_version_id = "android_version_id_value"
|
|
345
|
+
|
|
346
|
+
request = devicestreaming_v1.CreateDeviceSessionRequest(
|
|
347
|
+
parent="parent_value",
|
|
348
|
+
device_session=device_session,
|
|
349
|
+
)
|
|
350
|
+
|
|
351
|
+
# Make the request
|
|
352
|
+
response = await client.create_device_session(request=request)
|
|
353
|
+
|
|
354
|
+
# Handle the response
|
|
355
|
+
print(response)
|
|
356
|
+
|
|
357
|
+
Args:
|
|
358
|
+
request (Optional[Union[google.cloud.devicestreaming_v1.types.CreateDeviceSessionRequest, dict]]):
|
|
359
|
+
The request object. Request message for
|
|
360
|
+
DirectAccessService.CreateDeviceSession.
|
|
361
|
+
parent (:class:`str`):
|
|
362
|
+
Required. The Compute Engine project under which this
|
|
363
|
+
device will be allocated. "projects/{project_id}"
|
|
364
|
+
|
|
365
|
+
This corresponds to the ``parent`` field
|
|
366
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
367
|
+
should not be set.
|
|
368
|
+
device_session (:class:`google.cloud.devicestreaming_v1.types.DeviceSession`):
|
|
369
|
+
Required. A DeviceSession to create.
|
|
370
|
+
This corresponds to the ``device_session`` field
|
|
371
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
372
|
+
should not be set.
|
|
373
|
+
device_session_id (:class:`str`):
|
|
374
|
+
Optional. The ID to use for the DeviceSession, which
|
|
375
|
+
will become the final component of the DeviceSession's
|
|
376
|
+
resource name.
|
|
377
|
+
|
|
378
|
+
This value should be 4-63 characters, and valid
|
|
379
|
+
characters are /[a-z][0-9]-/.
|
|
380
|
+
|
|
381
|
+
This corresponds to the ``device_session_id`` field
|
|
382
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
383
|
+
should not be set.
|
|
384
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
385
|
+
should be retried.
|
|
386
|
+
timeout (float): The timeout for this request.
|
|
387
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
388
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
389
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
390
|
+
be of type `bytes`.
|
|
391
|
+
|
|
392
|
+
Returns:
|
|
393
|
+
google.cloud.devicestreaming_v1.types.DeviceSession:
|
|
394
|
+
Protobuf message describing the
|
|
395
|
+
device message, used from several RPCs.
|
|
396
|
+
|
|
397
|
+
"""
|
|
398
|
+
# Create or coerce a protobuf request object.
|
|
399
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
400
|
+
# gotten any keyword arguments that map to the request.
|
|
401
|
+
flattened_params = [parent, device_session, device_session_id]
|
|
402
|
+
has_flattened_params = (
|
|
403
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
404
|
+
)
|
|
405
|
+
if request is not None and has_flattened_params:
|
|
406
|
+
raise ValueError(
|
|
407
|
+
"If the `request` argument is set, then none of "
|
|
408
|
+
"the individual field arguments should be set."
|
|
409
|
+
)
|
|
410
|
+
|
|
411
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
412
|
+
# there are no flattened fields), or create one.
|
|
413
|
+
if not isinstance(request, service.CreateDeviceSessionRequest):
|
|
414
|
+
request = service.CreateDeviceSessionRequest(request)
|
|
415
|
+
|
|
416
|
+
# If we have keyword arguments corresponding to fields on the
|
|
417
|
+
# request, apply these.
|
|
418
|
+
if parent is not None:
|
|
419
|
+
request.parent = parent
|
|
420
|
+
if device_session is not None:
|
|
421
|
+
request.device_session = device_session
|
|
422
|
+
if device_session_id is not None:
|
|
423
|
+
request.device_session_id = device_session_id
|
|
424
|
+
|
|
425
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
426
|
+
# and friendly error handling.
|
|
427
|
+
rpc = self._client._transport._wrapped_methods[
|
|
428
|
+
self._client._transport.create_device_session
|
|
429
|
+
]
|
|
430
|
+
|
|
431
|
+
# Certain fields should be provided within the metadata header;
|
|
432
|
+
# add these here.
|
|
433
|
+
metadata = tuple(metadata) + (
|
|
434
|
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
|
435
|
+
)
|
|
436
|
+
|
|
437
|
+
# Validate the universe domain.
|
|
438
|
+
self._client._validate_universe_domain()
|
|
439
|
+
|
|
440
|
+
# Send the request.
|
|
441
|
+
response = await rpc(
|
|
442
|
+
request,
|
|
443
|
+
retry=retry,
|
|
444
|
+
timeout=timeout,
|
|
445
|
+
metadata=metadata,
|
|
446
|
+
)
|
|
447
|
+
|
|
448
|
+
# Done; return the response.
|
|
449
|
+
return response
|
|
450
|
+
|
|
451
|
+
async def list_device_sessions(
|
|
452
|
+
self,
|
|
453
|
+
request: Optional[Union[service.ListDeviceSessionsRequest, dict]] = None,
|
|
454
|
+
*,
|
|
455
|
+
parent: Optional[str] = None,
|
|
456
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
457
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
458
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
459
|
+
) -> pagers.ListDeviceSessionsAsyncPager:
|
|
460
|
+
r"""Lists DeviceSessions owned by the project user.
|
|
461
|
+
|
|
462
|
+
.. code-block:: python
|
|
463
|
+
|
|
464
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
465
|
+
# code template only.
|
|
466
|
+
# It will require modifications to work:
|
|
467
|
+
# - It may require correct/in-range values for request initialization.
|
|
468
|
+
# - It may require specifying regional endpoints when creating the service
|
|
469
|
+
# client as shown in:
|
|
470
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
471
|
+
from google.cloud import devicestreaming_v1
|
|
472
|
+
|
|
473
|
+
async def sample_list_device_sessions():
|
|
474
|
+
# Create a client
|
|
475
|
+
client = devicestreaming_v1.DirectAccessServiceAsyncClient()
|
|
476
|
+
|
|
477
|
+
# Initialize request argument(s)
|
|
478
|
+
request = devicestreaming_v1.ListDeviceSessionsRequest(
|
|
479
|
+
parent="parent_value",
|
|
480
|
+
)
|
|
481
|
+
|
|
482
|
+
# Make the request
|
|
483
|
+
page_result = client.list_device_sessions(request=request)
|
|
484
|
+
|
|
485
|
+
# Handle the response
|
|
486
|
+
async for response in page_result:
|
|
487
|
+
print(response)
|
|
488
|
+
|
|
489
|
+
Args:
|
|
490
|
+
request (Optional[Union[google.cloud.devicestreaming_v1.types.ListDeviceSessionsRequest, dict]]):
|
|
491
|
+
The request object. Request message for
|
|
492
|
+
DirectAccessService.ListDeviceSessions.
|
|
493
|
+
parent (:class:`str`):
|
|
494
|
+
Required. The name of the parent to request, e.g.
|
|
495
|
+
"projects/{project_id}"
|
|
496
|
+
|
|
497
|
+
This corresponds to the ``parent`` field
|
|
498
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
499
|
+
should not be set.
|
|
500
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
501
|
+
should be retried.
|
|
502
|
+
timeout (float): The timeout for this request.
|
|
503
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
504
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
505
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
506
|
+
be of type `bytes`.
|
|
507
|
+
|
|
508
|
+
Returns:
|
|
509
|
+
google.cloud.devicestreaming_v1.services.direct_access_service.pagers.ListDeviceSessionsAsyncPager:
|
|
510
|
+
Response message for
|
|
511
|
+
DirectAccessService.ListDeviceSessions.
|
|
512
|
+
Iterating over this object will yield
|
|
513
|
+
results and resolve additional pages
|
|
514
|
+
automatically.
|
|
515
|
+
|
|
516
|
+
"""
|
|
517
|
+
# Create or coerce a protobuf request object.
|
|
518
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
519
|
+
# gotten any keyword arguments that map to the request.
|
|
520
|
+
flattened_params = [parent]
|
|
521
|
+
has_flattened_params = (
|
|
522
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
523
|
+
)
|
|
524
|
+
if request is not None and has_flattened_params:
|
|
525
|
+
raise ValueError(
|
|
526
|
+
"If the `request` argument is set, then none of "
|
|
527
|
+
"the individual field arguments should be set."
|
|
528
|
+
)
|
|
529
|
+
|
|
530
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
531
|
+
# there are no flattened fields), or create one.
|
|
532
|
+
if not isinstance(request, service.ListDeviceSessionsRequest):
|
|
533
|
+
request = service.ListDeviceSessionsRequest(request)
|
|
534
|
+
|
|
535
|
+
# If we have keyword arguments corresponding to fields on the
|
|
536
|
+
# request, apply these.
|
|
537
|
+
if parent is not None:
|
|
538
|
+
request.parent = parent
|
|
539
|
+
|
|
540
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
541
|
+
# and friendly error handling.
|
|
542
|
+
rpc = self._client._transport._wrapped_methods[
|
|
543
|
+
self._client._transport.list_device_sessions
|
|
544
|
+
]
|
|
545
|
+
|
|
546
|
+
# Certain fields should be provided within the metadata header;
|
|
547
|
+
# add these here.
|
|
548
|
+
metadata = tuple(metadata) + (
|
|
549
|
+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
|
|
550
|
+
)
|
|
551
|
+
|
|
552
|
+
# Validate the universe domain.
|
|
553
|
+
self._client._validate_universe_domain()
|
|
554
|
+
|
|
555
|
+
# Send the request.
|
|
556
|
+
response = await rpc(
|
|
557
|
+
request,
|
|
558
|
+
retry=retry,
|
|
559
|
+
timeout=timeout,
|
|
560
|
+
metadata=metadata,
|
|
561
|
+
)
|
|
562
|
+
|
|
563
|
+
# This method is paged; wrap the response in a pager, which provides
|
|
564
|
+
# an `__aiter__` convenience method.
|
|
565
|
+
response = pagers.ListDeviceSessionsAsyncPager(
|
|
566
|
+
method=rpc,
|
|
567
|
+
request=request,
|
|
568
|
+
response=response,
|
|
569
|
+
retry=retry,
|
|
570
|
+
timeout=timeout,
|
|
571
|
+
metadata=metadata,
|
|
572
|
+
)
|
|
573
|
+
|
|
574
|
+
# Done; return the response.
|
|
575
|
+
return response
|
|
576
|
+
|
|
577
|
+
async def get_device_session(
|
|
578
|
+
self,
|
|
579
|
+
request: Optional[Union[service.GetDeviceSessionRequest, dict]] = None,
|
|
580
|
+
*,
|
|
581
|
+
name: Optional[str] = None,
|
|
582
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
583
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
584
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
585
|
+
) -> service.DeviceSession:
|
|
586
|
+
r"""Gets a DeviceSession, which documents the allocation
|
|
587
|
+
status and whether the device is allocated. Clients
|
|
588
|
+
making requests from this API must poll
|
|
589
|
+
GetDeviceSession.
|
|
590
|
+
|
|
591
|
+
.. code-block:: python
|
|
592
|
+
|
|
593
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
594
|
+
# code template only.
|
|
595
|
+
# It will require modifications to work:
|
|
596
|
+
# - It may require correct/in-range values for request initialization.
|
|
597
|
+
# - It may require specifying regional endpoints when creating the service
|
|
598
|
+
# client as shown in:
|
|
599
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
600
|
+
from google.cloud import devicestreaming_v1
|
|
601
|
+
|
|
602
|
+
async def sample_get_device_session():
|
|
603
|
+
# Create a client
|
|
604
|
+
client = devicestreaming_v1.DirectAccessServiceAsyncClient()
|
|
605
|
+
|
|
606
|
+
# Initialize request argument(s)
|
|
607
|
+
request = devicestreaming_v1.GetDeviceSessionRequest(
|
|
608
|
+
name="name_value",
|
|
609
|
+
)
|
|
610
|
+
|
|
611
|
+
# Make the request
|
|
612
|
+
response = await client.get_device_session(request=request)
|
|
613
|
+
|
|
614
|
+
# Handle the response
|
|
615
|
+
print(response)
|
|
616
|
+
|
|
617
|
+
Args:
|
|
618
|
+
request (Optional[Union[google.cloud.devicestreaming_v1.types.GetDeviceSessionRequest, dict]]):
|
|
619
|
+
The request object. Request message for
|
|
620
|
+
DirectAccessService.GetDeviceSession.
|
|
621
|
+
name (:class:`str`):
|
|
622
|
+
Required. Name of the DeviceSession, e.g.
|
|
623
|
+
"projects/{project_id}/deviceSessions/{session_id}"
|
|
624
|
+
|
|
625
|
+
This corresponds to the ``name`` field
|
|
626
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
627
|
+
should not be set.
|
|
628
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
629
|
+
should be retried.
|
|
630
|
+
timeout (float): The timeout for this request.
|
|
631
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
632
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
633
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
634
|
+
be of type `bytes`.
|
|
635
|
+
|
|
636
|
+
Returns:
|
|
637
|
+
google.cloud.devicestreaming_v1.types.DeviceSession:
|
|
638
|
+
Protobuf message describing the
|
|
639
|
+
device message, used from several RPCs.
|
|
640
|
+
|
|
641
|
+
"""
|
|
642
|
+
# Create or coerce a protobuf request object.
|
|
643
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
644
|
+
# gotten any keyword arguments that map to the request.
|
|
645
|
+
flattened_params = [name]
|
|
646
|
+
has_flattened_params = (
|
|
647
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
648
|
+
)
|
|
649
|
+
if request is not None and has_flattened_params:
|
|
650
|
+
raise ValueError(
|
|
651
|
+
"If the `request` argument is set, then none of "
|
|
652
|
+
"the individual field arguments should be set."
|
|
653
|
+
)
|
|
654
|
+
|
|
655
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
656
|
+
# there are no flattened fields), or create one.
|
|
657
|
+
if not isinstance(request, service.GetDeviceSessionRequest):
|
|
658
|
+
request = service.GetDeviceSessionRequest(request)
|
|
659
|
+
|
|
660
|
+
# If we have keyword arguments corresponding to fields on the
|
|
661
|
+
# request, apply these.
|
|
662
|
+
if name is not None:
|
|
663
|
+
request.name = name
|
|
664
|
+
|
|
665
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
666
|
+
# and friendly error handling.
|
|
667
|
+
rpc = self._client._transport._wrapped_methods[
|
|
668
|
+
self._client._transport.get_device_session
|
|
669
|
+
]
|
|
670
|
+
|
|
671
|
+
# Certain fields should be provided within the metadata header;
|
|
672
|
+
# add these here.
|
|
673
|
+
metadata = tuple(metadata) + (
|
|
674
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
675
|
+
)
|
|
676
|
+
|
|
677
|
+
# Validate the universe domain.
|
|
678
|
+
self._client._validate_universe_domain()
|
|
679
|
+
|
|
680
|
+
# Send the request.
|
|
681
|
+
response = await rpc(
|
|
682
|
+
request,
|
|
683
|
+
retry=retry,
|
|
684
|
+
timeout=timeout,
|
|
685
|
+
metadata=metadata,
|
|
686
|
+
)
|
|
687
|
+
|
|
688
|
+
# Done; return the response.
|
|
689
|
+
return response
|
|
690
|
+
|
|
691
|
+
async def cancel_device_session(
|
|
692
|
+
self,
|
|
693
|
+
request: Optional[Union[service.CancelDeviceSessionRequest, dict]] = None,
|
|
694
|
+
*,
|
|
695
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
696
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
697
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
698
|
+
) -> None:
|
|
699
|
+
r"""Cancel a DeviceSession.
|
|
700
|
+
This RPC changes the DeviceSession to state FINISHED and
|
|
701
|
+
terminates all connections.
|
|
702
|
+
Canceled sessions are not deleted and can be retrieved
|
|
703
|
+
or listed by the user until they expire based on the 28
|
|
704
|
+
day deletion policy.
|
|
705
|
+
|
|
706
|
+
.. code-block:: python
|
|
707
|
+
|
|
708
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
709
|
+
# code template only.
|
|
710
|
+
# It will require modifications to work:
|
|
711
|
+
# - It may require correct/in-range values for request initialization.
|
|
712
|
+
# - It may require specifying regional endpoints when creating the service
|
|
713
|
+
# client as shown in:
|
|
714
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
715
|
+
from google.cloud import devicestreaming_v1
|
|
716
|
+
|
|
717
|
+
async def sample_cancel_device_session():
|
|
718
|
+
# Create a client
|
|
719
|
+
client = devicestreaming_v1.DirectAccessServiceAsyncClient()
|
|
720
|
+
|
|
721
|
+
# Initialize request argument(s)
|
|
722
|
+
request = devicestreaming_v1.CancelDeviceSessionRequest(
|
|
723
|
+
name="name_value",
|
|
724
|
+
)
|
|
725
|
+
|
|
726
|
+
# Make the request
|
|
727
|
+
await client.cancel_device_session(request=request)
|
|
728
|
+
|
|
729
|
+
Args:
|
|
730
|
+
request (Optional[Union[google.cloud.devicestreaming_v1.types.CancelDeviceSessionRequest, dict]]):
|
|
731
|
+
The request object. Request message for
|
|
732
|
+
DirectAccessService.CancelDeviceSession.
|
|
733
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
734
|
+
should be retried.
|
|
735
|
+
timeout (float): The timeout for this request.
|
|
736
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
737
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
738
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
739
|
+
be of type `bytes`.
|
|
740
|
+
"""
|
|
741
|
+
# Create or coerce a protobuf request object.
|
|
742
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
743
|
+
# there are no flattened fields), or create one.
|
|
744
|
+
if not isinstance(request, service.CancelDeviceSessionRequest):
|
|
745
|
+
request = service.CancelDeviceSessionRequest(request)
|
|
746
|
+
|
|
747
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
748
|
+
# and friendly error handling.
|
|
749
|
+
rpc = self._client._transport._wrapped_methods[
|
|
750
|
+
self._client._transport.cancel_device_session
|
|
751
|
+
]
|
|
752
|
+
|
|
753
|
+
# Certain fields should be provided within the metadata header;
|
|
754
|
+
# add these here.
|
|
755
|
+
metadata = tuple(metadata) + (
|
|
756
|
+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
|
|
757
|
+
)
|
|
758
|
+
|
|
759
|
+
# Validate the universe domain.
|
|
760
|
+
self._client._validate_universe_domain()
|
|
761
|
+
|
|
762
|
+
# Send the request.
|
|
763
|
+
await rpc(
|
|
764
|
+
request,
|
|
765
|
+
retry=retry,
|
|
766
|
+
timeout=timeout,
|
|
767
|
+
metadata=metadata,
|
|
768
|
+
)
|
|
769
|
+
|
|
770
|
+
async def update_device_session(
|
|
771
|
+
self,
|
|
772
|
+
request: Optional[Union[service.UpdateDeviceSessionRequest, dict]] = None,
|
|
773
|
+
*,
|
|
774
|
+
device_session: Optional[service.DeviceSession] = None,
|
|
775
|
+
update_mask: Optional[field_mask_pb2.FieldMask] = None,
|
|
776
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
777
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
778
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
779
|
+
) -> service.DeviceSession:
|
|
780
|
+
r"""Updates the current DeviceSession to the fields described by the
|
|
781
|
+
update_mask.
|
|
782
|
+
|
|
783
|
+
.. code-block:: python
|
|
784
|
+
|
|
785
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
786
|
+
# code template only.
|
|
787
|
+
# It will require modifications to work:
|
|
788
|
+
# - It may require correct/in-range values for request initialization.
|
|
789
|
+
# - It may require specifying regional endpoints when creating the service
|
|
790
|
+
# client as shown in:
|
|
791
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
792
|
+
from google.cloud import devicestreaming_v1
|
|
793
|
+
|
|
794
|
+
async def sample_update_device_session():
|
|
795
|
+
# Create a client
|
|
796
|
+
client = devicestreaming_v1.DirectAccessServiceAsyncClient()
|
|
797
|
+
|
|
798
|
+
# Initialize request argument(s)
|
|
799
|
+
device_session = devicestreaming_v1.DeviceSession()
|
|
800
|
+
device_session.android_device.android_model_id = "android_model_id_value"
|
|
801
|
+
device_session.android_device.android_version_id = "android_version_id_value"
|
|
802
|
+
|
|
803
|
+
request = devicestreaming_v1.UpdateDeviceSessionRequest(
|
|
804
|
+
device_session=device_session,
|
|
805
|
+
)
|
|
806
|
+
|
|
807
|
+
# Make the request
|
|
808
|
+
response = await client.update_device_session(request=request)
|
|
809
|
+
|
|
810
|
+
# Handle the response
|
|
811
|
+
print(response)
|
|
812
|
+
|
|
813
|
+
Args:
|
|
814
|
+
request (Optional[Union[google.cloud.devicestreaming_v1.types.UpdateDeviceSessionRequest, dict]]):
|
|
815
|
+
The request object. Request message for
|
|
816
|
+
DirectAccessService.UpdateDeviceSession.
|
|
817
|
+
device_session (:class:`google.cloud.devicestreaming_v1.types.DeviceSession`):
|
|
818
|
+
Required. DeviceSession to update. The DeviceSession's
|
|
819
|
+
``name`` field is used to identify the session to update
|
|
820
|
+
"projects/{project_id}/deviceSessions/{session_id}"
|
|
821
|
+
|
|
822
|
+
This corresponds to the ``device_session`` field
|
|
823
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
824
|
+
should not be set.
|
|
825
|
+
update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
|
|
826
|
+
Optional. The list of fields to
|
|
827
|
+
update.
|
|
828
|
+
|
|
829
|
+
This corresponds to the ``update_mask`` field
|
|
830
|
+
on the ``request`` instance; if ``request`` is provided, this
|
|
831
|
+
should not be set.
|
|
832
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
833
|
+
should be retried.
|
|
834
|
+
timeout (float): The timeout for this request.
|
|
835
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
836
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
837
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
838
|
+
be of type `bytes`.
|
|
839
|
+
|
|
840
|
+
Returns:
|
|
841
|
+
google.cloud.devicestreaming_v1.types.DeviceSession:
|
|
842
|
+
Protobuf message describing the
|
|
843
|
+
device message, used from several RPCs.
|
|
844
|
+
|
|
845
|
+
"""
|
|
846
|
+
# Create or coerce a protobuf request object.
|
|
847
|
+
# - Quick check: If we got a request object, we should *not* have
|
|
848
|
+
# gotten any keyword arguments that map to the request.
|
|
849
|
+
flattened_params = [device_session, update_mask]
|
|
850
|
+
has_flattened_params = (
|
|
851
|
+
len([param for param in flattened_params if param is not None]) > 0
|
|
852
|
+
)
|
|
853
|
+
if request is not None and has_flattened_params:
|
|
854
|
+
raise ValueError(
|
|
855
|
+
"If the `request` argument is set, then none of "
|
|
856
|
+
"the individual field arguments should be set."
|
|
857
|
+
)
|
|
858
|
+
|
|
859
|
+
# - Use the request object if provided (there's no risk of modifying the input as
|
|
860
|
+
# there are no flattened fields), or create one.
|
|
861
|
+
if not isinstance(request, service.UpdateDeviceSessionRequest):
|
|
862
|
+
request = service.UpdateDeviceSessionRequest(request)
|
|
863
|
+
|
|
864
|
+
# If we have keyword arguments corresponding to fields on the
|
|
865
|
+
# request, apply these.
|
|
866
|
+
if device_session is not None:
|
|
867
|
+
request.device_session = device_session
|
|
868
|
+
if update_mask is not None:
|
|
869
|
+
request.update_mask = update_mask
|
|
870
|
+
|
|
871
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
872
|
+
# and friendly error handling.
|
|
873
|
+
rpc = self._client._transport._wrapped_methods[
|
|
874
|
+
self._client._transport.update_device_session
|
|
875
|
+
]
|
|
876
|
+
|
|
877
|
+
# Certain fields should be provided within the metadata header;
|
|
878
|
+
# add these here.
|
|
879
|
+
metadata = tuple(metadata) + (
|
|
880
|
+
gapic_v1.routing_header.to_grpc_metadata(
|
|
881
|
+
(("device_session.name", request.device_session.name),)
|
|
882
|
+
),
|
|
883
|
+
)
|
|
884
|
+
|
|
885
|
+
# Validate the universe domain.
|
|
886
|
+
self._client._validate_universe_domain()
|
|
887
|
+
|
|
888
|
+
# Send the request.
|
|
889
|
+
response = await rpc(
|
|
890
|
+
request,
|
|
891
|
+
retry=retry,
|
|
892
|
+
timeout=timeout,
|
|
893
|
+
metadata=metadata,
|
|
894
|
+
)
|
|
895
|
+
|
|
896
|
+
# Done; return the response.
|
|
897
|
+
return response
|
|
898
|
+
|
|
899
|
+
def adb_connect(
|
|
900
|
+
self,
|
|
901
|
+
requests: Optional[AsyncIterator[adb_service.AdbMessage]] = None,
|
|
902
|
+
*,
|
|
903
|
+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
904
|
+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
905
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
906
|
+
) -> Awaitable[AsyncIterable[adb_service.DeviceMessage]]:
|
|
907
|
+
r"""Exposes an ADB connection if the device supports ADB.
|
|
908
|
+
gRPC headers are used to authenticate the Connect RPC,
|
|
909
|
+
as well as associate to a particular DeviceSession.
|
|
910
|
+
In particular, the user must specify the
|
|
911
|
+
"X-Omnilab-Session-Name" header.
|
|
912
|
+
|
|
913
|
+
.. code-block:: python
|
|
914
|
+
|
|
915
|
+
# This snippet has been automatically generated and should be regarded as a
|
|
916
|
+
# code template only.
|
|
917
|
+
# It will require modifications to work:
|
|
918
|
+
# - It may require correct/in-range values for request initialization.
|
|
919
|
+
# - It may require specifying regional endpoints when creating the service
|
|
920
|
+
# client as shown in:
|
|
921
|
+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
|
|
922
|
+
from google.cloud import devicestreaming_v1
|
|
923
|
+
|
|
924
|
+
async def sample_adb_connect():
|
|
925
|
+
# Create a client
|
|
926
|
+
client = devicestreaming_v1.DirectAccessServiceAsyncClient()
|
|
927
|
+
|
|
928
|
+
# Initialize request argument(s)
|
|
929
|
+
open_ = devicestreaming_v1.Open()
|
|
930
|
+
open_.stream_id = 952
|
|
931
|
+
|
|
932
|
+
request = devicestreaming_v1.AdbMessage(
|
|
933
|
+
open_=open_,
|
|
934
|
+
)
|
|
935
|
+
|
|
936
|
+
# This method expects an iterator which contains
|
|
937
|
+
# 'devicestreaming_v1.AdbMessage' objects
|
|
938
|
+
# Here we create a generator that yields a single `request` for
|
|
939
|
+
# demonstrative purposes.
|
|
940
|
+
requests = [request]
|
|
941
|
+
|
|
942
|
+
def request_generator():
|
|
943
|
+
for request in requests:
|
|
944
|
+
yield request
|
|
945
|
+
|
|
946
|
+
# Make the request
|
|
947
|
+
stream = await client.adb_connect(requests=request_generator())
|
|
948
|
+
|
|
949
|
+
# Handle the response
|
|
950
|
+
async for response in stream:
|
|
951
|
+
print(response)
|
|
952
|
+
|
|
953
|
+
Args:
|
|
954
|
+
requests (AsyncIterator[`google.cloud.devicestreaming_v1.types.AdbMessage`]):
|
|
955
|
+
The request object AsyncIterator. A message to an ADB server.
|
|
956
|
+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
957
|
+
should be retried.
|
|
958
|
+
timeout (float): The timeout for this request.
|
|
959
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
960
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
961
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
962
|
+
be of type `bytes`.
|
|
963
|
+
|
|
964
|
+
Returns:
|
|
965
|
+
AsyncIterable[google.cloud.devicestreaming_v1.types.DeviceMessage]:
|
|
966
|
+
A message returned from a device.
|
|
967
|
+
"""
|
|
968
|
+
|
|
969
|
+
# Wrap the RPC method; this adds retry and timeout information,
|
|
970
|
+
# and friendly error handling.
|
|
971
|
+
rpc = self._client._transport._wrapped_methods[
|
|
972
|
+
self._client._transport.adb_connect
|
|
973
|
+
]
|
|
974
|
+
|
|
975
|
+
# Validate the universe domain.
|
|
976
|
+
self._client._validate_universe_domain()
|
|
977
|
+
|
|
978
|
+
# Send the request.
|
|
979
|
+
response = rpc(
|
|
980
|
+
requests,
|
|
981
|
+
retry=retry,
|
|
982
|
+
timeout=timeout,
|
|
983
|
+
metadata=metadata,
|
|
984
|
+
)
|
|
985
|
+
|
|
986
|
+
# Done; return the response.
|
|
987
|
+
return response
|
|
988
|
+
|
|
989
|
+
async def __aenter__(self) -> "DirectAccessServiceAsyncClient":
|
|
990
|
+
return self
|
|
991
|
+
|
|
992
|
+
async def __aexit__(self, exc_type, exc, tb):
|
|
993
|
+
await self.transport.close()
|
|
994
|
+
|
|
995
|
+
|
|
996
|
+
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
|
|
997
|
+
gapic_version=package_version.__version__
|
|
998
|
+
)
|
|
999
|
+
|
|
1000
|
+
|
|
1001
|
+
__all__ = ("DirectAccessServiceAsyncClient",)
|