google-cloud-devicestreaming 0.5.0__tar.gz → 0.5.1__tar.gz
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-0.5.0/google_cloud_devicestreaming.egg-info → google_cloud_devicestreaming-0.5.1}/PKG-INFO +4 -5
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/google/cloud/devicestreaming/__init__.py +2 -0
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/google/cloud/devicestreaming/gapic_version.py +1 -1
- google_cloud_devicestreaming-0.5.1/google/cloud/devicestreaming_v1/__init__.py +86 -0
- google_cloud_devicestreaming-0.5.1/google/cloud/devicestreaming_v1/_compat.py +262 -0
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/google/cloud/devicestreaming_v1/gapic_version.py +1 -1
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/google/cloud/devicestreaming_v1/services/direct_access_service/async_client.py +1 -3
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/google/cloud/devicestreaming_v1/services/direct_access_service/client.py +24 -163
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/google/cloud/devicestreaming_v1/services/direct_access_service/transports/base.py +1 -3
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/google/cloud/devicestreaming_v1/services/direct_access_service/transports/rest.py +47 -54
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/google/cloud/devicestreaming_v1/services/direct_access_service/transports/rest_base.py +0 -182
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/google/cloud/devicestreaming_v1/types/__init__.py +2 -0
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/google/cloud/devicestreaming_v1/types/service.py +33 -1
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1/google_cloud_devicestreaming.egg-info}/PKG-INFO +4 -5
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/google_cloud_devicestreaming.egg-info/SOURCES.txt +2 -0
- google_cloud_devicestreaming-0.5.1/google_cloud_devicestreaming.egg-info/requires.txt +8 -0
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/setup.py +7 -5
- google_cloud_devicestreaming-0.5.1/tests/unit/gapic/devicestreaming_v1/test_compat.py +429 -0
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/tests/unit/gapic/devicestreaming_v1/test_direct_access_service.py +84 -411
- google_cloud_devicestreaming-0.5.0/google/cloud/devicestreaming_v1/__init__.py +0 -155
- google_cloud_devicestreaming-0.5.0/google_cloud_devicestreaming.egg-info/requires.txt +0 -11
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/LICENSE +0 -0
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/MANIFEST.in +0 -0
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/README.rst +0 -0
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/google/cloud/devicestreaming/py.typed +0 -0
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/google/cloud/devicestreaming_v1/gapic_metadata.json +0 -0
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/google/cloud/devicestreaming_v1/py.typed +0 -0
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/google/cloud/devicestreaming_v1/services/__init__.py +0 -0
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/google/cloud/devicestreaming_v1/services/direct_access_service/__init__.py +0 -0
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/google/cloud/devicestreaming_v1/services/direct_access_service/pagers.py +0 -0
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/google/cloud/devicestreaming_v1/services/direct_access_service/transports/__init__.py +0 -0
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/google/cloud/devicestreaming_v1/services/direct_access_service/transports/grpc.py +0 -0
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/google/cloud/devicestreaming_v1/services/direct_access_service/transports/grpc_asyncio.py +0 -0
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/google/cloud/devicestreaming_v1/types/adb_service.py +0 -0
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/google_cloud_devicestreaming.egg-info/dependency_links.txt +0 -0
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/google_cloud_devicestreaming.egg-info/not-zip-safe +0 -0
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/google_cloud_devicestreaming.egg-info/top_level.txt +0 -0
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/setup.cfg +0 -0
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/tests/__init__.py +0 -0
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/tests/unit/__init__.py +0 -0
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/tests/unit/gapic/__init__.py +0 -0
- {google_cloud_devicestreaming-0.5.0 → google_cloud_devicestreaming-0.5.1}/tests/unit/gapic/devicestreaming_v1/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: google-cloud-devicestreaming
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.1
|
|
4
4
|
Summary: Google Cloud Devicestreaming API client library
|
|
5
5
|
Home-page: https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-devicestreaming
|
|
6
6
|
Author: Google LLC
|
|
@@ -21,13 +21,12 @@ Classifier: Operating System :: OS Independent
|
|
|
21
21
|
Classifier: Topic :: Internet
|
|
22
22
|
Requires-Python: >=3.10
|
|
23
23
|
License-File: LICENSE
|
|
24
|
-
Requires-Dist: google-api-core[grpc]<3.0.0,>=2.
|
|
24
|
+
Requires-Dist: google-api-core[grpc]<3.0.0,>=2.28.0
|
|
25
25
|
Requires-Dist: google-auth!=2.24.0,!=2.25.0,<3.0.0,>=2.14.1
|
|
26
26
|
Requires-Dist: grpcio<2.0.0,>=1.59.0
|
|
27
27
|
Requires-Dist: grpcio<2.0.0,>=1.75.1; python_version >= "3.14"
|
|
28
|
-
Requires-Dist: proto-plus<2.0.0,>=1.
|
|
29
|
-
Requires-Dist:
|
|
30
|
-
Requires-Dist: protobuf<8.0.0,>=4.25.8
|
|
28
|
+
Requires-Dist: proto-plus<2.0.0,>=1.26.1
|
|
29
|
+
Requires-Dist: protobuf<8.0.0,>=6.33.5
|
|
31
30
|
Dynamic: author
|
|
32
31
|
Dynamic: author-email
|
|
33
32
|
Dynamic: classifier
|
|
@@ -38,6 +38,7 @@ from google.cloud.devicestreaming_v1.types.adb_service import (
|
|
|
38
38
|
from google.cloud.devicestreaming_v1.types.service import (
|
|
39
39
|
AndroidDevice,
|
|
40
40
|
CancelDeviceSessionRequest,
|
|
41
|
+
ClientInfo,
|
|
41
42
|
CreateDeviceSessionRequest,
|
|
42
43
|
DeviceSession,
|
|
43
44
|
GetDeviceSessionRequest,
|
|
@@ -60,6 +61,7 @@ __all__ = (
|
|
|
60
61
|
"StreamStatus",
|
|
61
62
|
"AndroidDevice",
|
|
62
63
|
"CancelDeviceSessionRequest",
|
|
64
|
+
"ClientInfo",
|
|
63
65
|
"CreateDeviceSessionRequest",
|
|
64
66
|
"DeviceSession",
|
|
65
67
|
"GetDeviceSessionRequest",
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright 2026 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 google.api_core as api_core
|
|
17
|
+
|
|
18
|
+
from google.cloud.devicestreaming_v1 import gapic_version as package_version
|
|
19
|
+
|
|
20
|
+
__version__ = package_version.__version__
|
|
21
|
+
|
|
22
|
+
# PEP 0810: Explicit Lazy Imports
|
|
23
|
+
# Python 3.15+ natively intercepts and defers these imports.
|
|
24
|
+
# Developers can disable this behavior and force eager imports.
|
|
25
|
+
# For more information, see:
|
|
26
|
+
# https://docs.python.org/3.15/library/sys.html#sys.set_lazy_imports_filter
|
|
27
|
+
# Older Python versions safely ignore this variable.
|
|
28
|
+
__lazy_modules__ = {
|
|
29
|
+
"google.cloud.devicestreaming_v1.services.direct_access_service",
|
|
30
|
+
"google.cloud.devicestreaming_v1.types.adb_service",
|
|
31
|
+
"google.cloud.devicestreaming_v1.types.service",
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
from .services.direct_access_service import (
|
|
36
|
+
DirectAccessServiceAsyncClient,
|
|
37
|
+
DirectAccessServiceClient,
|
|
38
|
+
)
|
|
39
|
+
from .types.adb_service import (
|
|
40
|
+
AdbMessage,
|
|
41
|
+
Close,
|
|
42
|
+
DeviceMessage,
|
|
43
|
+
Fail,
|
|
44
|
+
Okay,
|
|
45
|
+
Open,
|
|
46
|
+
StatusUpdate,
|
|
47
|
+
StreamData,
|
|
48
|
+
StreamStatus,
|
|
49
|
+
)
|
|
50
|
+
from .types.service import (
|
|
51
|
+
AndroidDevice,
|
|
52
|
+
CancelDeviceSessionRequest,
|
|
53
|
+
ClientInfo,
|
|
54
|
+
CreateDeviceSessionRequest,
|
|
55
|
+
DeviceSession,
|
|
56
|
+
GetDeviceSessionRequest,
|
|
57
|
+
ListDeviceSessionsRequest,
|
|
58
|
+
ListDeviceSessionsResponse,
|
|
59
|
+
UpdateDeviceSessionRequest,
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
__all__ = (
|
|
63
|
+
"DirectAccessServiceAsyncClient",
|
|
64
|
+
"AdbMessage",
|
|
65
|
+
"AndroidDevice",
|
|
66
|
+
"CancelDeviceSessionRequest",
|
|
67
|
+
"ClientInfo",
|
|
68
|
+
"Close",
|
|
69
|
+
"CreateDeviceSessionRequest",
|
|
70
|
+
"DeviceMessage",
|
|
71
|
+
"DeviceSession",
|
|
72
|
+
"DirectAccessServiceClient",
|
|
73
|
+
"Fail",
|
|
74
|
+
"GetDeviceSessionRequest",
|
|
75
|
+
"ListDeviceSessionsRequest",
|
|
76
|
+
"ListDeviceSessionsResponse",
|
|
77
|
+
"Okay",
|
|
78
|
+
"Open",
|
|
79
|
+
"StatusUpdate",
|
|
80
|
+
"StreamData",
|
|
81
|
+
"StreamStatus",
|
|
82
|
+
"UpdateDeviceSessionRequest",
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
api_core.check_python_version("google.cloud.devicestreaming_v1")
|
|
86
|
+
api_core.check_dependency_versions("google.cloud.devicestreaming_v1")
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright 2026 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
|
+
"""A compatibility module for older versions of google-api-core."""
|
|
17
|
+
|
|
18
|
+
import json
|
|
19
|
+
import os
|
|
20
|
+
from typing import Any, Dict, List, Optional, Tuple
|
|
21
|
+
from urllib.parse import urlparse, urlunparse
|
|
22
|
+
|
|
23
|
+
from google.api_core import path_template
|
|
24
|
+
from google.api_core.universe import EmptyUniverseError
|
|
25
|
+
from google.auth.exceptions import MutualTLSChannelError
|
|
26
|
+
from google.protobuf import json_format
|
|
27
|
+
|
|
28
|
+
try:
|
|
29
|
+
# note: `#type: ignore` is added because the return type for `should_use_client_cert`
|
|
30
|
+
# is different than that of the fallback implementation below. This will be removed once
|
|
31
|
+
# we bump the minimum supported version of google-auth.
|
|
32
|
+
from google.auth.transport.mtls import should_use_client_cert # type: ignore
|
|
33
|
+
except ImportError: # pragma: NO COVER
|
|
34
|
+
|
|
35
|
+
def should_use_client_cert():
|
|
36
|
+
"""Returns whether client certificate should be used for mTLS."""
|
|
37
|
+
use_client_cert = os.getenv(
|
|
38
|
+
"GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
|
|
39
|
+
).lower()
|
|
40
|
+
if use_client_cert not in ("true", "false"):
|
|
41
|
+
raise ValueError(
|
|
42
|
+
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be"
|
|
43
|
+
" either `true` or `false`"
|
|
44
|
+
)
|
|
45
|
+
return use_client_cert == "true"
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def read_environment_variables():
|
|
49
|
+
"""Returns the environment variables used by the client.
|
|
50
|
+
|
|
51
|
+
Returns:
|
|
52
|
+
Tuple[bool, str, str]: returns the GOOGLE_API_USE_CLIENT_CERTIFICATE,
|
|
53
|
+
GOOGLE_API_USE_MTLS_ENDPOINT, and GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variables.
|
|
54
|
+
|
|
55
|
+
Raises:
|
|
56
|
+
ValueError: If GOOGLE_API_USE_CLIENT_CERTIFICATE is not
|
|
57
|
+
any of ["true", "false"].
|
|
58
|
+
google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT
|
|
59
|
+
is not any of ["auto", "never", "always"].
|
|
60
|
+
"""
|
|
61
|
+
use_client_cert = should_use_client_cert()
|
|
62
|
+
use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower()
|
|
63
|
+
universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN")
|
|
64
|
+
if use_mtls_endpoint not in ("auto", "never", "always"):
|
|
65
|
+
raise MutualTLSChannelError(
|
|
66
|
+
"Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`,"
|
|
67
|
+
" `auto` or `always`"
|
|
68
|
+
)
|
|
69
|
+
return use_client_cert, use_mtls_endpoint, universe_domain_env
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
DEFAULT_UNIVERSE = "googleapis.com"
|
|
73
|
+
|
|
74
|
+
try:
|
|
75
|
+
from google.api_core.universe import get_default_mtls_endpoint
|
|
76
|
+
except ImportError: # pragma: NO COVER
|
|
77
|
+
|
|
78
|
+
def get_default_mtls_endpoint(api_endpoint: Optional[str]) -> Optional[str]:
|
|
79
|
+
"""Converts api endpoint to mTLS endpoint.
|
|
80
|
+
|
|
81
|
+
Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
|
|
82
|
+
"*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
|
|
83
|
+
Other URLs (including those that do not match these domain suffixes or
|
|
84
|
+
already contain '.mtls.') are passed through as-is.
|
|
85
|
+
|
|
86
|
+
Args:
|
|
87
|
+
api_endpoint (Optional[str]): the api endpoint to convert.
|
|
88
|
+
|
|
89
|
+
Returns:
|
|
90
|
+
Optional[str]: converted mTLS api endpoint.
|
|
91
|
+
"""
|
|
92
|
+
if not api_endpoint or ".mtls." in api_endpoint.lower():
|
|
93
|
+
return api_endpoint
|
|
94
|
+
|
|
95
|
+
has_scheme = "://" in api_endpoint
|
|
96
|
+
if not has_scheme:
|
|
97
|
+
parsed = urlparse("//" + api_endpoint)
|
|
98
|
+
else:
|
|
99
|
+
parsed = urlparse(api_endpoint)
|
|
100
|
+
|
|
101
|
+
host = parsed.hostname
|
|
102
|
+
if not host:
|
|
103
|
+
return api_endpoint
|
|
104
|
+
|
|
105
|
+
port = f":{parsed.port}" if parsed.port else ""
|
|
106
|
+
|
|
107
|
+
lowered_host = host.lower()
|
|
108
|
+
suffix_sandbox = ".sandbox.googleapis.com"
|
|
109
|
+
suffix_google = ".googleapis.com"
|
|
110
|
+
if lowered_host.endswith(suffix_sandbox):
|
|
111
|
+
new_host = host[: -len(suffix_sandbox)] + ".mtls.sandbox.googleapis.com"
|
|
112
|
+
elif lowered_host.endswith(suffix_google):
|
|
113
|
+
new_host = host[: -len(suffix_google)] + ".mtls.googleapis.com"
|
|
114
|
+
else:
|
|
115
|
+
return api_endpoint
|
|
116
|
+
|
|
117
|
+
netloc = new_host + port
|
|
118
|
+
new_parsed = parsed._replace(netloc=netloc)
|
|
119
|
+
|
|
120
|
+
if not has_scheme:
|
|
121
|
+
return urlunparse(new_parsed)[2:]
|
|
122
|
+
else:
|
|
123
|
+
return urlunparse(new_parsed)
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
try:
|
|
127
|
+
from google.api_core.universe import get_api_endpoint
|
|
128
|
+
except ImportError: # pragma: NO COVER
|
|
129
|
+
|
|
130
|
+
def get_api_endpoint(
|
|
131
|
+
api_override: Optional[str],
|
|
132
|
+
universe_domain: str,
|
|
133
|
+
default_universe: str,
|
|
134
|
+
default_mtls_endpoint: Optional[str],
|
|
135
|
+
default_endpoint_template: str,
|
|
136
|
+
use_mtls: bool,
|
|
137
|
+
) -> str:
|
|
138
|
+
"""Return the API endpoint used by the client.
|
|
139
|
+
|
|
140
|
+
Args:
|
|
141
|
+
api_override (Optional[str]): The API endpoint override. If specified,
|
|
142
|
+
this is always returned.
|
|
143
|
+
universe_domain (str): The universe domain used by the client.
|
|
144
|
+
default_universe (str): The default universe domain.
|
|
145
|
+
default_mtls_endpoint (Optional[str]): The default mTLS endpoint.
|
|
146
|
+
default_endpoint_template (str): The default endpoint template containing
|
|
147
|
+
a placeholder `{UNIVERSE_DOMAIN}`.
|
|
148
|
+
use_mtls (bool): Whether to use the mTLS endpoint.
|
|
149
|
+
|
|
150
|
+
Returns:
|
|
151
|
+
str: The API endpoint to be used by the client.
|
|
152
|
+
|
|
153
|
+
Raises:
|
|
154
|
+
google.auth.exceptions.MutualTLSChannelError: If mTLS is requested but
|
|
155
|
+
not supported in the configured universe domain.
|
|
156
|
+
ValueError: If mTLS is requested but no mTLS endpoint is available.
|
|
157
|
+
"""
|
|
158
|
+
if api_override is not None:
|
|
159
|
+
return api_override
|
|
160
|
+
|
|
161
|
+
if use_mtls:
|
|
162
|
+
if universe_domain.lower() != default_universe.lower():
|
|
163
|
+
raise MutualTLSChannelError(
|
|
164
|
+
f"mTLS is not supported in any universe other than {default_universe}."
|
|
165
|
+
)
|
|
166
|
+
if not default_mtls_endpoint:
|
|
167
|
+
raise ValueError("mTLS endpoint is not available.")
|
|
168
|
+
return default_mtls_endpoint
|
|
169
|
+
else:
|
|
170
|
+
return default_endpoint_template.format(UNIVERSE_DOMAIN=universe_domain)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
try:
|
|
174
|
+
from google.api_core.universe import get_universe_domain
|
|
175
|
+
except ImportError: # pragma: NO COVER
|
|
176
|
+
|
|
177
|
+
def get_universe_domain(
|
|
178
|
+
*potential_universes: Optional[str],
|
|
179
|
+
default_universe: str,
|
|
180
|
+
) -> str:
|
|
181
|
+
"""Return the universe domain used by the client.
|
|
182
|
+
|
|
183
|
+
Args:
|
|
184
|
+
*potential_universes (Optional[str]): Potential universe domains in order of preference.
|
|
185
|
+
default_universe (str): The default universe domain.
|
|
186
|
+
|
|
187
|
+
Returns:
|
|
188
|
+
str: The universe domain to be used by the client.
|
|
189
|
+
|
|
190
|
+
Raises:
|
|
191
|
+
EmptyUniverseError: If the resolved universe domain is an empty string.
|
|
192
|
+
"""
|
|
193
|
+
resolved = next(
|
|
194
|
+
(x.strip() for x in potential_universes if x is not None),
|
|
195
|
+
default_universe,
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
if not resolved:
|
|
199
|
+
raise EmptyUniverseError()
|
|
200
|
+
return resolved
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
try:
|
|
204
|
+
from google.api_core.rest_helpers import transcode_request # type: ignore
|
|
205
|
+
except ImportError: # pragma: NO COVER
|
|
206
|
+
|
|
207
|
+
def transcode_request(
|
|
208
|
+
http_options: List[Dict[str, str]],
|
|
209
|
+
request: Any,
|
|
210
|
+
required_fields_default_values: Optional[Dict[str, Any]] = None,
|
|
211
|
+
rest_numeric_enums: bool = False,
|
|
212
|
+
) -> Tuple[Dict[str, Any], Optional[str], Dict[str, Any]]:
|
|
213
|
+
"""Transcodes a request into HTTP method, URI, body, and query parameters.
|
|
214
|
+
|
|
215
|
+
Args:
|
|
216
|
+
http_options (List[Dict[str, str]]): List of HTTP transcoding rules.
|
|
217
|
+
request (Any): The protobuf or proto-plus request message.
|
|
218
|
+
required_fields_default_values (Optional[Dict[str, Any]]): Dictionary
|
|
219
|
+
of required fields default values to merge into query parameters if missing.
|
|
220
|
+
rest_numeric_enums (bool): Whether to encode enums as integers.
|
|
221
|
+
|
|
222
|
+
Returns:
|
|
223
|
+
Tuple[Dict[str, Any], Optional[str], Dict[str, Any]]: A tuple containing:
|
|
224
|
+
- The raw transcoded request dictionary (containing keys like 'uri', 'method').
|
|
225
|
+
- The serialized request body JSON string, or None if no body.
|
|
226
|
+
- The query parameters dictionary.
|
|
227
|
+
"""
|
|
228
|
+
if request is None:
|
|
229
|
+
raise TypeError("request cannot be None")
|
|
230
|
+
|
|
231
|
+
# Convert proto-plus message to its underlying protobuf message if needed
|
|
232
|
+
pb_request = getattr(request, "_pb", request)
|
|
233
|
+
|
|
234
|
+
transcoded_request = path_template.transcode(http_options, pb_request)
|
|
235
|
+
|
|
236
|
+
body_json = None
|
|
237
|
+
if transcoded_request.get("body") is not None:
|
|
238
|
+
body_json = json_format.MessageToJson(
|
|
239
|
+
transcoded_request["body"],
|
|
240
|
+
use_integers_for_enums=rest_numeric_enums,
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
query_params_json = {}
|
|
244
|
+
if transcoded_request.get("query_params") is not None:
|
|
245
|
+
query_params_json = json.loads(
|
|
246
|
+
json_format.MessageToJson(
|
|
247
|
+
transcoded_request["query_params"],
|
|
248
|
+
use_integers_for_enums=rest_numeric_enums,
|
|
249
|
+
)
|
|
250
|
+
)
|
|
251
|
+
|
|
252
|
+
# If required_fields_default_values is provided, we merge default values for missing
|
|
253
|
+
# required fields into the query parameters.
|
|
254
|
+
if required_fields_default_values:
|
|
255
|
+
for k, v in required_fields_default_values.items():
|
|
256
|
+
if k not in query_params_json:
|
|
257
|
+
query_params_json[k] = v
|
|
258
|
+
|
|
259
|
+
if rest_numeric_enums:
|
|
260
|
+
query_params_json["$alt"] = "json;enum-encoding=int"
|
|
261
|
+
|
|
262
|
+
return transcoded_request, body_json, query_params_json
|
|
@@ -1005,9 +1005,7 @@ class DirectAccessServiceAsyncClient:
|
|
|
1005
1005
|
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
|
|
1006
1006
|
gapic_version=package_version.__version__
|
|
1007
1007
|
)
|
|
1008
|
-
|
|
1009
|
-
if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
|
|
1010
|
-
DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
|
|
1008
|
+
DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
|
|
1011
1009
|
|
|
1012
1010
|
|
|
1013
1011
|
__all__ = ("DirectAccessServiceAsyncClient",)
|
|
@@ -48,6 +48,13 @@ from google.auth.transport.grpc import SslCredentials # type: ignore
|
|
|
48
48
|
from google.oauth2 import service_account # type: ignore
|
|
49
49
|
|
|
50
50
|
from google.cloud.devicestreaming_v1 import gapic_version as package_version
|
|
51
|
+
from google.cloud.devicestreaming_v1._compat import (
|
|
52
|
+
get_api_endpoint,
|
|
53
|
+
get_default_mtls_endpoint,
|
|
54
|
+
get_universe_domain,
|
|
55
|
+
read_environment_variables,
|
|
56
|
+
should_use_client_cert,
|
|
57
|
+
)
|
|
51
58
|
|
|
52
59
|
try:
|
|
53
60
|
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
|
|
@@ -125,77 +132,13 @@ class DirectAccessServiceClient(metaclass=DirectAccessServiceClientMeta):
|
|
|
125
132
|
https://developer.android.com/studio/preview/android-device-streaming
|
|
126
133
|
"""
|
|
127
134
|
|
|
128
|
-
@staticmethod
|
|
129
|
-
def _get_default_mtls_endpoint(api_endpoint) -> Optional[str]:
|
|
130
|
-
"""Converts api endpoint to mTLS endpoint.
|
|
131
|
-
|
|
132
|
-
Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
|
|
133
|
-
"*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
|
|
134
|
-
Args:
|
|
135
|
-
api_endpoint (Optional[str]): the api endpoint to convert.
|
|
136
|
-
Returns:
|
|
137
|
-
Optional[str]: converted mTLS api endpoint.
|
|
138
|
-
"""
|
|
139
|
-
if not api_endpoint:
|
|
140
|
-
return api_endpoint
|
|
141
|
-
|
|
142
|
-
mtls_endpoint_re = re.compile(
|
|
143
|
-
r"(?P<name>[^.]+)(?P<mtls>\.mtls)?(?P<sandbox>\.sandbox)?(?P<googledomain>\.googleapis\.com)?"
|
|
144
|
-
)
|
|
145
|
-
|
|
146
|
-
m = mtls_endpoint_re.match(api_endpoint)
|
|
147
|
-
if m is None:
|
|
148
|
-
# Could not parse api_endpoint; return as-is.
|
|
149
|
-
return api_endpoint
|
|
150
|
-
|
|
151
|
-
name, mtls, sandbox, googledomain = m.groups()
|
|
152
|
-
if mtls or not googledomain:
|
|
153
|
-
return api_endpoint
|
|
154
|
-
|
|
155
|
-
if sandbox:
|
|
156
|
-
return api_endpoint.replace(
|
|
157
|
-
"sandbox.googleapis.com", "mtls.sandbox.googleapis.com"
|
|
158
|
-
)
|
|
159
|
-
|
|
160
|
-
return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com")
|
|
161
|
-
|
|
162
135
|
# Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
|
|
163
136
|
DEFAULT_ENDPOINT = "devicestreaming.googleapis.com"
|
|
164
|
-
DEFAULT_MTLS_ENDPOINT =
|
|
165
|
-
DEFAULT_ENDPOINT
|
|
166
|
-
)
|
|
137
|
+
DEFAULT_MTLS_ENDPOINT = get_default_mtls_endpoint(DEFAULT_ENDPOINT)
|
|
167
138
|
|
|
168
139
|
_DEFAULT_ENDPOINT_TEMPLATE = "devicestreaming.{UNIVERSE_DOMAIN}"
|
|
169
140
|
_DEFAULT_UNIVERSE = "googleapis.com"
|
|
170
141
|
|
|
171
|
-
@staticmethod
|
|
172
|
-
def _use_client_cert_effective():
|
|
173
|
-
"""Returns whether client certificate should be used for mTLS if the
|
|
174
|
-
google-auth version supports should_use_client_cert automatic mTLS enablement.
|
|
175
|
-
|
|
176
|
-
Alternatively, read from the GOOGLE_API_USE_CLIENT_CERTIFICATE env var.
|
|
177
|
-
|
|
178
|
-
Returns:
|
|
179
|
-
bool: whether client certificate should be used for mTLS
|
|
180
|
-
Raises:
|
|
181
|
-
ValueError: (If using a version of google-auth without should_use_client_cert and
|
|
182
|
-
GOOGLE_API_USE_CLIENT_CERTIFICATE is set to an unexpected value.)
|
|
183
|
-
"""
|
|
184
|
-
# check if google-auth version supports should_use_client_cert for automatic mTLS enablement
|
|
185
|
-
if hasattr(mtls, "should_use_client_cert"): # pragma: NO COVER
|
|
186
|
-
return mtls.should_use_client_cert()
|
|
187
|
-
else: # pragma: NO COVER
|
|
188
|
-
# if unsupported, fallback to reading from env var
|
|
189
|
-
use_client_cert_str = os.getenv(
|
|
190
|
-
"GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
|
|
191
|
-
).lower()
|
|
192
|
-
if use_client_cert_str not in ("true", "false"):
|
|
193
|
-
raise ValueError(
|
|
194
|
-
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be"
|
|
195
|
-
" either `true` or `false`"
|
|
196
|
-
)
|
|
197
|
-
return use_client_cert_str == "true"
|
|
198
|
-
|
|
199
142
|
@classmethod
|
|
200
143
|
def from_service_account_info(cls, info: dict, *args, **kwargs):
|
|
201
144
|
"""Creates an instance of this client using the provided credentials
|
|
@@ -380,7 +323,7 @@ class DirectAccessServiceClient(metaclass=DirectAccessServiceClientMeta):
|
|
|
380
323
|
)
|
|
381
324
|
if client_options is None:
|
|
382
325
|
client_options = client_options_lib.ClientOptions()
|
|
383
|
-
use_client_cert =
|
|
326
|
+
use_client_cert = should_use_client_cert()
|
|
384
327
|
use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto")
|
|
385
328
|
if use_mtls_endpoint not in ("auto", "never", "always"):
|
|
386
329
|
raise MutualTLSChannelError(
|
|
@@ -401,35 +344,12 @@ class DirectAccessServiceClient(metaclass=DirectAccessServiceClientMeta):
|
|
|
401
344
|
elif use_mtls_endpoint == "always" or (
|
|
402
345
|
use_mtls_endpoint == "auto" and client_cert_source
|
|
403
346
|
):
|
|
404
|
-
api_endpoint = cls.DEFAULT_MTLS_ENDPOINT
|
|
347
|
+
api_endpoint = cls.DEFAULT_MTLS_ENDPOINT # type: ignore
|
|
405
348
|
else:
|
|
406
349
|
api_endpoint = cls.DEFAULT_ENDPOINT
|
|
407
350
|
|
|
408
351
|
return api_endpoint, client_cert_source
|
|
409
352
|
|
|
410
|
-
@staticmethod
|
|
411
|
-
def _read_environment_variables():
|
|
412
|
-
"""Returns the environment variables used by the client.
|
|
413
|
-
|
|
414
|
-
Returns:
|
|
415
|
-
Tuple[bool, str, str]: returns the GOOGLE_API_USE_CLIENT_CERTIFICATE,
|
|
416
|
-
GOOGLE_API_USE_MTLS_ENDPOINT, and GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variables.
|
|
417
|
-
|
|
418
|
-
Raises:
|
|
419
|
-
ValueError: If GOOGLE_API_USE_CLIENT_CERTIFICATE is not
|
|
420
|
-
any of ["true", "false"].
|
|
421
|
-
google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT
|
|
422
|
-
is not any of ["auto", "never", "always"].
|
|
423
|
-
"""
|
|
424
|
-
use_client_cert = DirectAccessServiceClient._use_client_cert_effective()
|
|
425
|
-
use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower()
|
|
426
|
-
universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN")
|
|
427
|
-
if use_mtls_endpoint not in ("auto", "never", "always"):
|
|
428
|
-
raise MutualTLSChannelError(
|
|
429
|
-
"Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
|
|
430
|
-
)
|
|
431
|
-
return use_client_cert, use_mtls_endpoint, universe_domain_env
|
|
432
|
-
|
|
433
353
|
@staticmethod
|
|
434
354
|
def _get_client_cert_source(provided_cert_source, use_cert_flag):
|
|
435
355
|
"""Return the client cert source to be used by the client.
|
|
@@ -449,65 +369,6 @@ class DirectAccessServiceClient(metaclass=DirectAccessServiceClientMeta):
|
|
|
449
369
|
client_cert_source = mtls.default_client_cert_source()
|
|
450
370
|
return client_cert_source
|
|
451
371
|
|
|
452
|
-
@staticmethod
|
|
453
|
-
def _get_api_endpoint(
|
|
454
|
-
api_override, client_cert_source, universe_domain, use_mtls_endpoint
|
|
455
|
-
) -> str:
|
|
456
|
-
"""Return the API endpoint used by the client.
|
|
457
|
-
|
|
458
|
-
Args:
|
|
459
|
-
api_override (str): The API endpoint override. If specified, this is always
|
|
460
|
-
the return value of this function and the other arguments are not used.
|
|
461
|
-
client_cert_source (bytes): The client certificate source used by the client.
|
|
462
|
-
universe_domain (str): The universe domain used by the client.
|
|
463
|
-
use_mtls_endpoint (str): How to use the mTLS endpoint, which depends also on the other parameters.
|
|
464
|
-
Possible values are "always", "auto", or "never".
|
|
465
|
-
|
|
466
|
-
Returns:
|
|
467
|
-
str: The API endpoint to be used by the client.
|
|
468
|
-
"""
|
|
469
|
-
if api_override is not None:
|
|
470
|
-
api_endpoint = api_override
|
|
471
|
-
elif use_mtls_endpoint == "always" or (
|
|
472
|
-
use_mtls_endpoint == "auto" and client_cert_source
|
|
473
|
-
):
|
|
474
|
-
_default_universe = DirectAccessServiceClient._DEFAULT_UNIVERSE
|
|
475
|
-
if universe_domain != _default_universe:
|
|
476
|
-
raise MutualTLSChannelError(
|
|
477
|
-
f"mTLS is not supported in any universe other than {_default_universe}."
|
|
478
|
-
)
|
|
479
|
-
api_endpoint = DirectAccessServiceClient.DEFAULT_MTLS_ENDPOINT
|
|
480
|
-
else:
|
|
481
|
-
api_endpoint = DirectAccessServiceClient._DEFAULT_ENDPOINT_TEMPLATE.format(
|
|
482
|
-
UNIVERSE_DOMAIN=universe_domain
|
|
483
|
-
)
|
|
484
|
-
return api_endpoint
|
|
485
|
-
|
|
486
|
-
@staticmethod
|
|
487
|
-
def _get_universe_domain(
|
|
488
|
-
client_universe_domain: Optional[str], universe_domain_env: Optional[str]
|
|
489
|
-
) -> str:
|
|
490
|
-
"""Return the universe domain used by the client.
|
|
491
|
-
|
|
492
|
-
Args:
|
|
493
|
-
client_universe_domain (Optional[str]): The universe domain configured via the client options.
|
|
494
|
-
universe_domain_env (Optional[str]): The universe domain configured via the "GOOGLE_CLOUD_UNIVERSE_DOMAIN" environment variable.
|
|
495
|
-
|
|
496
|
-
Returns:
|
|
497
|
-
str: The universe domain to be used by the client.
|
|
498
|
-
|
|
499
|
-
Raises:
|
|
500
|
-
ValueError: If the universe domain is an empty string.
|
|
501
|
-
"""
|
|
502
|
-
universe_domain = DirectAccessServiceClient._DEFAULT_UNIVERSE
|
|
503
|
-
if client_universe_domain is not None:
|
|
504
|
-
universe_domain = client_universe_domain
|
|
505
|
-
elif universe_domain_env is not None:
|
|
506
|
-
universe_domain = universe_domain_env
|
|
507
|
-
if len(universe_domain.strip()) == 0:
|
|
508
|
-
raise ValueError("Universe Domain cannot be an empty string.")
|
|
509
|
-
return universe_domain
|
|
510
|
-
|
|
511
372
|
def _validate_universe_domain(self):
|
|
512
373
|
"""Validates client's and credentials' universe domains are consistent.
|
|
513
374
|
|
|
@@ -641,13 +502,15 @@ class DirectAccessServiceClient(metaclass=DirectAccessServiceClientMeta):
|
|
|
641
502
|
universe_domain_opt = getattr(self._client_options, "universe_domain", None)
|
|
642
503
|
|
|
643
504
|
self._use_client_cert, self._use_mtls_endpoint, self._universe_domain_env = (
|
|
644
|
-
|
|
505
|
+
read_environment_variables()
|
|
645
506
|
)
|
|
646
507
|
self._client_cert_source = DirectAccessServiceClient._get_client_cert_source(
|
|
647
508
|
self._client_options.client_cert_source, self._use_client_cert
|
|
648
509
|
)
|
|
649
|
-
self._universe_domain =
|
|
650
|
-
universe_domain_opt,
|
|
510
|
+
self._universe_domain = get_universe_domain(
|
|
511
|
+
universe_domain_opt,
|
|
512
|
+
self._universe_domain_env,
|
|
513
|
+
default_universe=DirectAccessServiceClient._DEFAULT_UNIVERSE,
|
|
651
514
|
)
|
|
652
515
|
self._api_endpoint: str = "" # updated below, depending on `transport`
|
|
653
516
|
|
|
@@ -682,14 +545,14 @@ class DirectAccessServiceClient(metaclass=DirectAccessServiceClientMeta):
|
|
|
682
545
|
self._transport = cast(DirectAccessServiceTransport, transport)
|
|
683
546
|
self._api_endpoint = self._transport.host
|
|
684
547
|
|
|
685
|
-
self._api_endpoint = (
|
|
686
|
-
self.
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
)
|
|
548
|
+
self._api_endpoint = self._api_endpoint or get_api_endpoint(
|
|
549
|
+
api_override=self._client_options.api_endpoint,
|
|
550
|
+
universe_domain=self._universe_domain,
|
|
551
|
+
default_universe=DirectAccessServiceClient._DEFAULT_UNIVERSE,
|
|
552
|
+
default_mtls_endpoint=DirectAccessServiceClient.DEFAULT_MTLS_ENDPOINT,
|
|
553
|
+
default_endpoint_template=DirectAccessServiceClient._DEFAULT_ENDPOINT_TEMPLATE,
|
|
554
|
+
use_mtls=self._use_mtls_endpoint == "always"
|
|
555
|
+
or (self._use_mtls_endpoint == "auto" and self._client_cert_source),
|
|
693
556
|
)
|
|
694
557
|
|
|
695
558
|
if not transport_provided:
|
|
@@ -1423,8 +1286,6 @@ class DirectAccessServiceClient(metaclass=DirectAccessServiceClientMeta):
|
|
|
1423
1286
|
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
|
|
1424
1287
|
gapic_version=package_version.__version__
|
|
1425
1288
|
)
|
|
1426
|
-
|
|
1427
|
-
if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
|
|
1428
|
-
DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
|
|
1289
|
+
DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
|
|
1429
1290
|
|
|
1430
1291
|
__all__ = ("DirectAccessServiceClient",)
|
|
@@ -32,9 +32,7 @@ from google.cloud.devicestreaming_v1.types import adb_service, service
|
|
|
32
32
|
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
|
|
33
33
|
gapic_version=package_version.__version__
|
|
34
34
|
)
|
|
35
|
-
|
|
36
|
-
if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
|
|
37
|
-
DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
|
|
35
|
+
DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
|
|
38
36
|
|
|
39
37
|
|
|
40
38
|
class DirectAccessServiceTransport(abc.ABC):
|