google-cloud-devicestreaming 0.2.0__tar.gz → 0.4.0__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.2.0/google_cloud_devicestreaming.egg-info → google_cloud_devicestreaming-0.4.0}/PKG-INFO +6 -8
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/README.rst +2 -2
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/google/cloud/devicestreaming/gapic_version.py +1 -1
- google_cloud_devicestreaming-0.4.0/google/cloud/devicestreaming_v1/__init__.py +172 -0
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/google/cloud/devicestreaming_v1/gapic_version.py +1 -1
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/google/cloud/devicestreaming_v1/services/direct_access_service/async_client.py +17 -9
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/google/cloud/devicestreaming_v1/services/direct_access_service/client.py +53 -36
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/google/cloud/devicestreaming_v1/services/direct_access_service/pagers.py +2 -2
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/google/cloud/devicestreaming_v1/services/direct_access_service/transports/__init__.py +1 -3
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/google/cloud/devicestreaming_v1/services/direct_access_service/transports/base.py +16 -7
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/google/cloud/devicestreaming_v1/services/direct_access_service/transports/grpc.py +12 -8
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/google/cloud/devicestreaming_v1/services/direct_access_service/transports/grpc_asyncio.py +11 -7
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/google/cloud/devicestreaming_v1/services/direct_access_service/transports/rest.py +15 -19
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/google/cloud/devicestreaming_v1/services/direct_access_service/transports/rest_base.py +1 -1
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/google/cloud/devicestreaming_v1/types/adb_service.py +1 -0
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/google/cloud/devicestreaming_v1/types/service.py +4 -3
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0/google_cloud_devicestreaming.egg-info}/PKG-INFO +6 -8
- google_cloud_devicestreaming-0.4.0/google_cloud_devicestreaming.egg-info/requires.txt +11 -0
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/setup.py +3 -5
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/tests/unit/gapic/devicestreaming_v1/test_direct_access_service.py +381 -157
- google_cloud_devicestreaming-0.2.0/google/cloud/devicestreaming_v1/__init__.py +0 -67
- google_cloud_devicestreaming-0.2.0/google_cloud_devicestreaming.egg-info/requires.txt +0 -11
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/LICENSE +0 -0
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/MANIFEST.in +0 -0
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/google/cloud/devicestreaming/__init__.py +0 -0
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/google/cloud/devicestreaming/py.typed +0 -0
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/google/cloud/devicestreaming_v1/gapic_metadata.json +0 -0
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/google/cloud/devicestreaming_v1/py.typed +0 -0
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/google/cloud/devicestreaming_v1/services/__init__.py +0 -0
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/google/cloud/devicestreaming_v1/services/direct_access_service/__init__.py +0 -0
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/google/cloud/devicestreaming_v1/types/__init__.py +0 -0
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/google_cloud_devicestreaming.egg-info/SOURCES.txt +0 -0
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/google_cloud_devicestreaming.egg-info/dependency_links.txt +0 -0
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/google_cloud_devicestreaming.egg-info/not-zip-safe +0 -0
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/google_cloud_devicestreaming.egg-info/top_level.txt +0 -0
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/setup.cfg +0 -0
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/tests/__init__.py +0 -0
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/tests/unit/__init__.py +0 -0
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/tests/unit/gapic/__init__.py +0 -0
- {google_cloud_devicestreaming-0.2.0 → google_cloud_devicestreaming-0.4.0}/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.
|
|
3
|
+
Version: 0.4.0
|
|
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
|
|
@@ -12,8 +12,6 @@ Classifier: Intended Audience :: Developers
|
|
|
12
12
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
13
|
Classifier: Programming Language :: Python
|
|
14
14
|
Classifier: Programming Language :: Python :: 3
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
17
15
|
Classifier: Programming Language :: Python :: 3.9
|
|
18
16
|
Classifier: Programming Language :: Python :: 3.10
|
|
19
17
|
Classifier: Programming Language :: Python :: 3.11
|
|
@@ -22,15 +20,15 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
22
20
|
Classifier: Programming Language :: Python :: 3.14
|
|
23
21
|
Classifier: Operating System :: OS Independent
|
|
24
22
|
Classifier: Topic :: Internet
|
|
25
|
-
Requires-Python: >=3.
|
|
23
|
+
Requires-Python: >=3.9
|
|
26
24
|
License-File: LICENSE
|
|
27
|
-
Requires-Dist: google-api-core[grpc]
|
|
25
|
+
Requires-Dist: google-api-core[grpc]<3.0.0,>=2.11.0
|
|
28
26
|
Requires-Dist: google-auth!=2.24.0,!=2.25.0,<3.0.0,>=2.14.1
|
|
29
27
|
Requires-Dist: grpcio<2.0.0,>=1.33.2
|
|
30
28
|
Requires-Dist: grpcio<2.0.0,>=1.75.1; python_version >= "3.14"
|
|
31
29
|
Requires-Dist: proto-plus<2.0.0,>=1.22.3
|
|
32
30
|
Requires-Dist: proto-plus<2.0.0,>=1.25.0; python_version >= "3.13"
|
|
33
|
-
Requires-Dist: protobuf
|
|
31
|
+
Requires-Dist: protobuf<8.0.0,>=4.25.8
|
|
34
32
|
Dynamic: author
|
|
35
33
|
Dynamic: author-email
|
|
36
34
|
Dynamic: classifier
|
|
@@ -106,14 +104,14 @@ Supported Python Versions
|
|
|
106
104
|
Our client libraries are compatible with all current `active`_ and `maintenance`_ versions of
|
|
107
105
|
Python.
|
|
108
106
|
|
|
109
|
-
Python >= 3.
|
|
107
|
+
Python >= 3.9, including 3.14
|
|
110
108
|
|
|
111
109
|
.. _active: https://devguide.python.org/devcycle/#in-development-main-branch
|
|
112
110
|
.. _maintenance: https://devguide.python.org/devcycle/#maintenance-branches
|
|
113
111
|
|
|
114
112
|
Unsupported Python Versions
|
|
115
113
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
116
|
-
Python <= 3.
|
|
114
|
+
Python <= 3.8
|
|
117
115
|
|
|
118
116
|
If you are using an `end-of-life`_
|
|
119
117
|
version of Python, we recommend that you update as soon as possible to an actively supported version.
|
|
@@ -61,14 +61,14 @@ Supported Python Versions
|
|
|
61
61
|
Our client libraries are compatible with all current `active`_ and `maintenance`_ versions of
|
|
62
62
|
Python.
|
|
63
63
|
|
|
64
|
-
Python >= 3.
|
|
64
|
+
Python >= 3.9, including 3.14
|
|
65
65
|
|
|
66
66
|
.. _active: https://devguide.python.org/devcycle/#in-development-main-branch
|
|
67
67
|
.. _maintenance: https://devguide.python.org/devcycle/#maintenance-branches
|
|
68
68
|
|
|
69
69
|
Unsupported Python Versions
|
|
70
70
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
71
|
-
Python <= 3.
|
|
71
|
+
Python <= 3.8
|
|
72
72
|
|
|
73
73
|
If you are using an `end-of-life`_
|
|
74
74
|
version of Python, we recommend that you update as soon as possible to an actively supported version.
|
|
@@ -0,0 +1,172 @@
|
|
|
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 sys
|
|
17
|
+
|
|
18
|
+
import google.api_core as api_core
|
|
19
|
+
|
|
20
|
+
from google.cloud.devicestreaming_v1 import gapic_version as package_version
|
|
21
|
+
|
|
22
|
+
__version__ = package_version.__version__
|
|
23
|
+
|
|
24
|
+
if sys.version_info >= (3, 8): # pragma: NO COVER
|
|
25
|
+
from importlib import metadata
|
|
26
|
+
else: # pragma: NO COVER
|
|
27
|
+
# TODO(https://github.com/googleapis/python-api-core/issues/835): Remove
|
|
28
|
+
# this code path once we drop support for Python 3.7
|
|
29
|
+
import importlib_metadata as metadata
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
from .services.direct_access_service import (
|
|
33
|
+
DirectAccessServiceAsyncClient,
|
|
34
|
+
DirectAccessServiceClient,
|
|
35
|
+
)
|
|
36
|
+
from .types.adb_service import (
|
|
37
|
+
AdbMessage,
|
|
38
|
+
Close,
|
|
39
|
+
DeviceMessage,
|
|
40
|
+
Fail,
|
|
41
|
+
Okay,
|
|
42
|
+
Open,
|
|
43
|
+
StatusUpdate,
|
|
44
|
+
StreamData,
|
|
45
|
+
StreamStatus,
|
|
46
|
+
)
|
|
47
|
+
from .types.service import (
|
|
48
|
+
AndroidDevice,
|
|
49
|
+
CancelDeviceSessionRequest,
|
|
50
|
+
CreateDeviceSessionRequest,
|
|
51
|
+
DeviceSession,
|
|
52
|
+
GetDeviceSessionRequest,
|
|
53
|
+
ListDeviceSessionsRequest,
|
|
54
|
+
ListDeviceSessionsResponse,
|
|
55
|
+
UpdateDeviceSessionRequest,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
if hasattr(api_core, "check_python_version") and hasattr(
|
|
59
|
+
api_core, "check_dependency_versions"
|
|
60
|
+
): # pragma: NO COVER
|
|
61
|
+
api_core.check_python_version("google.cloud.devicestreaming_v1") # type: ignore
|
|
62
|
+
api_core.check_dependency_versions("google.cloud.devicestreaming_v1") # type: ignore
|
|
63
|
+
else: # pragma: NO COVER
|
|
64
|
+
# An older version of api_core is installed which does not define the
|
|
65
|
+
# functions above. We do equivalent checks manually.
|
|
66
|
+
try:
|
|
67
|
+
import sys
|
|
68
|
+
import warnings
|
|
69
|
+
|
|
70
|
+
_py_version_str = sys.version.split()[0]
|
|
71
|
+
_package_label = "google.cloud.devicestreaming_v1"
|
|
72
|
+
if sys.version_info < (3, 9):
|
|
73
|
+
warnings.warn(
|
|
74
|
+
"You are using a non-supported Python version "
|
|
75
|
+
+ f"({_py_version_str}). Google will not post any further "
|
|
76
|
+
+ f"updates to {_package_label} supporting this Python version. "
|
|
77
|
+
+ "Please upgrade to the latest Python version, or at "
|
|
78
|
+
+ f"least to Python 3.9, and then update {_package_label}.",
|
|
79
|
+
FutureWarning,
|
|
80
|
+
)
|
|
81
|
+
if sys.version_info[:2] == (3, 9):
|
|
82
|
+
warnings.warn(
|
|
83
|
+
f"You are using a Python version ({_py_version_str}) "
|
|
84
|
+
+ f"which Google will stop supporting in {_package_label} in "
|
|
85
|
+
+ "January 2026. Please "
|
|
86
|
+
+ "upgrade to the latest Python version, or at "
|
|
87
|
+
+ "least to Python 3.10, before then, and "
|
|
88
|
+
+ f"then update {_package_label}.",
|
|
89
|
+
FutureWarning,
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
def parse_version_to_tuple(version_string: str):
|
|
93
|
+
"""Safely converts a semantic version string to a comparable tuple of integers.
|
|
94
|
+
Example: "4.25.8" -> (4, 25, 8)
|
|
95
|
+
Ignores non-numeric parts and handles common version formats.
|
|
96
|
+
Args:
|
|
97
|
+
version_string: Version string in the format "x.y.z" or "x.y.z<suffix>"
|
|
98
|
+
Returns:
|
|
99
|
+
Tuple of integers for the parsed version string.
|
|
100
|
+
"""
|
|
101
|
+
parts = []
|
|
102
|
+
for part in version_string.split("."):
|
|
103
|
+
try:
|
|
104
|
+
parts.append(int(part))
|
|
105
|
+
except ValueError:
|
|
106
|
+
# If it's a non-numeric part (e.g., '1.0.0b1' -> 'b1'), stop here.
|
|
107
|
+
# This is a simplification compared to 'packaging.parse_version', but sufficient
|
|
108
|
+
# for comparing strictly numeric semantic versions.
|
|
109
|
+
break
|
|
110
|
+
return tuple(parts)
|
|
111
|
+
|
|
112
|
+
def _get_version(dependency_name):
|
|
113
|
+
try:
|
|
114
|
+
version_string: str = metadata.version(dependency_name)
|
|
115
|
+
parsed_version = parse_version_to_tuple(version_string)
|
|
116
|
+
return (parsed_version, version_string)
|
|
117
|
+
except Exception:
|
|
118
|
+
# Catch exceptions from metadata.version() (e.g., PackageNotFoundError)
|
|
119
|
+
# or errors during parse_version_to_tuple
|
|
120
|
+
return (None, "--")
|
|
121
|
+
|
|
122
|
+
_dependency_package = "google.protobuf"
|
|
123
|
+
_next_supported_version = "4.25.8"
|
|
124
|
+
_next_supported_version_tuple = (4, 25, 8)
|
|
125
|
+
_recommendation = " (we recommend 6.x)"
|
|
126
|
+
(_version_used, _version_used_string) = _get_version(_dependency_package)
|
|
127
|
+
if _version_used and _version_used < _next_supported_version_tuple:
|
|
128
|
+
warnings.warn(
|
|
129
|
+
f"Package {_package_label} depends on "
|
|
130
|
+
+ f"{_dependency_package}, currently installed at version "
|
|
131
|
+
+ f"{_version_used_string}. Future updates to "
|
|
132
|
+
+ f"{_package_label} will require {_dependency_package} at "
|
|
133
|
+
+ f"version {_next_supported_version} or higher{_recommendation}."
|
|
134
|
+
+ " Please ensure "
|
|
135
|
+
+ "that either (a) your Python environment doesn't pin the "
|
|
136
|
+
+ f"version of {_dependency_package}, so that updates to "
|
|
137
|
+
+ f"{_package_label} can require the higher version, or "
|
|
138
|
+
+ "(b) you manually update your Python environment to use at "
|
|
139
|
+
+ f"least version {_next_supported_version} of "
|
|
140
|
+
+ f"{_dependency_package}.",
|
|
141
|
+
FutureWarning,
|
|
142
|
+
)
|
|
143
|
+
except Exception:
|
|
144
|
+
warnings.warn(
|
|
145
|
+
"Could not determine the version of Python "
|
|
146
|
+
+ "currently being used. To continue receiving "
|
|
147
|
+
+ "updates for {_package_label}, ensure you are "
|
|
148
|
+
+ "using a supported version of Python; see "
|
|
149
|
+
+ "https://devguide.python.org/versions/"
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
__all__ = (
|
|
153
|
+
"DirectAccessServiceAsyncClient",
|
|
154
|
+
"AdbMessage",
|
|
155
|
+
"AndroidDevice",
|
|
156
|
+
"CancelDeviceSessionRequest",
|
|
157
|
+
"Close",
|
|
158
|
+
"CreateDeviceSessionRequest",
|
|
159
|
+
"DeviceMessage",
|
|
160
|
+
"DeviceSession",
|
|
161
|
+
"DirectAccessServiceClient",
|
|
162
|
+
"Fail",
|
|
163
|
+
"GetDeviceSessionRequest",
|
|
164
|
+
"ListDeviceSessionsRequest",
|
|
165
|
+
"ListDeviceSessionsResponse",
|
|
166
|
+
"Okay",
|
|
167
|
+
"Open",
|
|
168
|
+
"StatusUpdate",
|
|
169
|
+
"StreamData",
|
|
170
|
+
"StreamStatus",
|
|
171
|
+
"UpdateDeviceSessionRequest",
|
|
172
|
+
)
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
#
|
|
16
|
-
from collections import OrderedDict
|
|
17
16
|
import logging as std_logging
|
|
18
17
|
import re
|
|
18
|
+
from collections import OrderedDict
|
|
19
19
|
from typing import (
|
|
20
20
|
AsyncIterable,
|
|
21
21
|
AsyncIterator,
|
|
@@ -32,13 +32,13 @@ from typing import (
|
|
|
32
32
|
Union,
|
|
33
33
|
)
|
|
34
34
|
|
|
35
|
+
import google.protobuf
|
|
35
36
|
from google.api_core import exceptions as core_exceptions
|
|
36
37
|
from google.api_core import gapic_v1
|
|
37
38
|
from google.api_core import retry_async as retries
|
|
38
39
|
from google.api_core.client_options import ClientOptions
|
|
39
40
|
from google.auth import credentials as ga_credentials # type: ignore
|
|
40
41
|
from google.oauth2 import service_account # type: ignore
|
|
41
|
-
import google.protobuf
|
|
42
42
|
|
|
43
43
|
from google.cloud.devicestreaming_v1 import gapic_version as package_version
|
|
44
44
|
|
|
@@ -47,9 +47,9 @@ try:
|
|
|
47
47
|
except AttributeError: # pragma: NO COVER
|
|
48
48
|
OptionalRetry = Union[retries.AsyncRetry, object, None] # type: ignore
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
import google.protobuf.duration_pb2 as duration_pb2 # type: ignore
|
|
51
|
+
import google.protobuf.field_mask_pb2 as field_mask_pb2 # type: ignore
|
|
52
|
+
import google.protobuf.timestamp_pb2 as timestamp_pb2 # type: ignore
|
|
53
53
|
|
|
54
54
|
from google.cloud.devicestreaming_v1.services.direct_access_service import pagers
|
|
55
55
|
from google.cloud.devicestreaming_v1.types import adb_service, service
|
|
@@ -133,7 +133,10 @@ class DirectAccessServiceAsyncClient:
|
|
|
133
133
|
Returns:
|
|
134
134
|
DirectAccessServiceAsyncClient: The constructed client.
|
|
135
135
|
"""
|
|
136
|
-
|
|
136
|
+
sa_info_func = (
|
|
137
|
+
DirectAccessServiceClient.from_service_account_info.__func__ # type: ignore
|
|
138
|
+
)
|
|
139
|
+
return sa_info_func(DirectAccessServiceAsyncClient, info, *args, **kwargs)
|
|
137
140
|
|
|
138
141
|
@classmethod
|
|
139
142
|
def from_service_account_file(cls, filename: str, *args, **kwargs):
|
|
@@ -149,7 +152,10 @@ class DirectAccessServiceAsyncClient:
|
|
|
149
152
|
Returns:
|
|
150
153
|
DirectAccessServiceAsyncClient: The constructed client.
|
|
151
154
|
"""
|
|
152
|
-
|
|
155
|
+
sa_file_func = (
|
|
156
|
+
DirectAccessServiceClient.from_service_account_file.__func__ # type: ignore
|
|
157
|
+
)
|
|
158
|
+
return sa_file_func(DirectAccessServiceAsyncClient, filename, *args, **kwargs)
|
|
153
159
|
|
|
154
160
|
from_service_account_json = from_service_account_file
|
|
155
161
|
|
|
@@ -187,7 +193,9 @@ class DirectAccessServiceAsyncClient:
|
|
|
187
193
|
Raises:
|
|
188
194
|
google.auth.exceptions.MutualTLSChannelError: If any errors happen.
|
|
189
195
|
"""
|
|
190
|
-
return DirectAccessServiceClient.get_mtls_endpoint_and_cert_source(
|
|
196
|
+
return DirectAccessServiceClient.get_mtls_endpoint_and_cert_source(
|
|
197
|
+
client_options
|
|
198
|
+
) # type: ignore
|
|
191
199
|
|
|
192
200
|
@property
|
|
193
201
|
def transport(self) -> DirectAccessServiceTransport:
|
|
@@ -199,7 +207,7 @@ class DirectAccessServiceAsyncClient:
|
|
|
199
207
|
return self._client.transport
|
|
200
208
|
|
|
201
209
|
@property
|
|
202
|
-
def api_endpoint(self):
|
|
210
|
+
def api_endpoint(self) -> str:
|
|
203
211
|
"""Return the API endpoint used by the client instance.
|
|
204
212
|
|
|
205
213
|
Returns:
|
|
@@ -13,12 +13,13 @@
|
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
#
|
|
16
|
-
from collections import OrderedDict
|
|
17
|
-
from http import HTTPStatus
|
|
18
16
|
import json
|
|
19
17
|
import logging as std_logging
|
|
20
18
|
import os
|
|
21
19
|
import re
|
|
20
|
+
import warnings
|
|
21
|
+
from collections import OrderedDict
|
|
22
|
+
from http import HTTPStatus
|
|
22
23
|
from typing import (
|
|
23
24
|
Callable,
|
|
24
25
|
Dict,
|
|
@@ -34,8 +35,8 @@ from typing import (
|
|
|
34
35
|
Union,
|
|
35
36
|
cast,
|
|
36
37
|
)
|
|
37
|
-
import warnings
|
|
38
38
|
|
|
39
|
+
import google.protobuf
|
|
39
40
|
from google.api_core import client_options as client_options_lib
|
|
40
41
|
from google.api_core import exceptions as core_exceptions
|
|
41
42
|
from google.api_core import gapic_v1
|
|
@@ -45,7 +46,6 @@ from google.auth.exceptions import MutualTLSChannelError # type: ignore
|
|
|
45
46
|
from google.auth.transport import mtls # type: ignore
|
|
46
47
|
from google.auth.transport.grpc import SslCredentials # type: ignore
|
|
47
48
|
from google.oauth2 import service_account # type: ignore
|
|
48
|
-
import google.protobuf
|
|
49
49
|
|
|
50
50
|
from google.cloud.devicestreaming_v1 import gapic_version as package_version
|
|
51
51
|
|
|
@@ -63,9 +63,9 @@ except ImportError: # pragma: NO COVER
|
|
|
63
63
|
|
|
64
64
|
_LOGGER = std_logging.getLogger(__name__)
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
import google.protobuf.duration_pb2 as duration_pb2 # type: ignore
|
|
67
|
+
import google.protobuf.field_mask_pb2 as field_mask_pb2 # type: ignore
|
|
68
|
+
import google.protobuf.timestamp_pb2 as timestamp_pb2 # type: ignore
|
|
69
69
|
|
|
70
70
|
from google.cloud.devicestreaming_v1.services.direct_access_service import pagers
|
|
71
71
|
from google.cloud.devicestreaming_v1.types import adb_service, service
|
|
@@ -84,9 +84,7 @@ class DirectAccessServiceClientMeta(type):
|
|
|
84
84
|
objects.
|
|
85
85
|
"""
|
|
86
86
|
|
|
87
|
-
_transport_registry = (
|
|
88
|
-
OrderedDict()
|
|
89
|
-
) # type: Dict[str, Type[DirectAccessServiceTransport]]
|
|
87
|
+
_transport_registry = OrderedDict() # type: Dict[str, Type[DirectAccessServiceTransport]]
|
|
90
88
|
_transport_registry["grpc"] = DirectAccessServiceGrpcTransport
|
|
91
89
|
_transport_registry["grpc_asyncio"] = DirectAccessServiceGrpcAsyncIOTransport
|
|
92
90
|
_transport_registry["rest"] = DirectAccessServiceRestTransport
|
|
@@ -128,7 +126,7 @@ class DirectAccessServiceClient(metaclass=DirectAccessServiceClientMeta):
|
|
|
128
126
|
"""
|
|
129
127
|
|
|
130
128
|
@staticmethod
|
|
131
|
-
def _get_default_mtls_endpoint(api_endpoint):
|
|
129
|
+
def _get_default_mtls_endpoint(api_endpoint) -> Optional[str]:
|
|
132
130
|
"""Converts api endpoint to mTLS endpoint.
|
|
133
131
|
|
|
134
132
|
Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
|
|
@@ -136,7 +134,7 @@ class DirectAccessServiceClient(metaclass=DirectAccessServiceClientMeta):
|
|
|
136
134
|
Args:
|
|
137
135
|
api_endpoint (Optional[str]): the api endpoint to convert.
|
|
138
136
|
Returns:
|
|
139
|
-
str: converted mTLS api endpoint.
|
|
137
|
+
Optional[str]: converted mTLS api endpoint.
|
|
140
138
|
"""
|
|
141
139
|
if not api_endpoint:
|
|
142
140
|
return api_endpoint
|
|
@@ -146,6 +144,10 @@ class DirectAccessServiceClient(metaclass=DirectAccessServiceClientMeta):
|
|
|
146
144
|
)
|
|
147
145
|
|
|
148
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
|
+
|
|
149
151
|
name, mtls, sandbox, googledomain = m.groups()
|
|
150
152
|
if mtls or not googledomain:
|
|
151
153
|
return api_endpoint
|
|
@@ -166,6 +168,34 @@ class DirectAccessServiceClient(metaclass=DirectAccessServiceClientMeta):
|
|
|
166
168
|
_DEFAULT_ENDPOINT_TEMPLATE = "devicestreaming.{UNIVERSE_DOMAIN}"
|
|
167
169
|
_DEFAULT_UNIVERSE = "googleapis.com"
|
|
168
170
|
|
|
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
|
+
|
|
169
199
|
@classmethod
|
|
170
200
|
def from_service_account_info(cls, info: dict, *args, **kwargs):
|
|
171
201
|
"""Creates an instance of this client using the provided credentials
|
|
@@ -350,12 +380,8 @@ class DirectAccessServiceClient(metaclass=DirectAccessServiceClientMeta):
|
|
|
350
380
|
)
|
|
351
381
|
if client_options is None:
|
|
352
382
|
client_options = client_options_lib.ClientOptions()
|
|
353
|
-
use_client_cert =
|
|
383
|
+
use_client_cert = DirectAccessServiceClient._use_client_cert_effective()
|
|
354
384
|
use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto")
|
|
355
|
-
if use_client_cert not in ("true", "false"):
|
|
356
|
-
raise ValueError(
|
|
357
|
-
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
|
|
358
|
-
)
|
|
359
385
|
if use_mtls_endpoint not in ("auto", "never", "always"):
|
|
360
386
|
raise MutualTLSChannelError(
|
|
361
387
|
"Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
|
|
@@ -363,7 +389,7 @@ class DirectAccessServiceClient(metaclass=DirectAccessServiceClientMeta):
|
|
|
363
389
|
|
|
364
390
|
# Figure out the client cert source to use.
|
|
365
391
|
client_cert_source = None
|
|
366
|
-
if use_client_cert
|
|
392
|
+
if use_client_cert:
|
|
367
393
|
if client_options.client_cert_source:
|
|
368
394
|
client_cert_source = client_options.client_cert_source
|
|
369
395
|
elif mtls.has_default_client_cert_source():
|
|
@@ -395,20 +421,14 @@ class DirectAccessServiceClient(metaclass=DirectAccessServiceClientMeta):
|
|
|
395
421
|
google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT
|
|
396
422
|
is not any of ["auto", "never", "always"].
|
|
397
423
|
"""
|
|
398
|
-
use_client_cert =
|
|
399
|
-
"GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
|
|
400
|
-
).lower()
|
|
424
|
+
use_client_cert = DirectAccessServiceClient._use_client_cert_effective()
|
|
401
425
|
use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower()
|
|
402
426
|
universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN")
|
|
403
|
-
if use_client_cert not in ("true", "false"):
|
|
404
|
-
raise ValueError(
|
|
405
|
-
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
|
|
406
|
-
)
|
|
407
427
|
if use_mtls_endpoint not in ("auto", "never", "always"):
|
|
408
428
|
raise MutualTLSChannelError(
|
|
409
429
|
"Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
|
|
410
430
|
)
|
|
411
|
-
return use_client_cert
|
|
431
|
+
return use_client_cert, use_mtls_endpoint, universe_domain_env
|
|
412
432
|
|
|
413
433
|
@staticmethod
|
|
414
434
|
def _get_client_cert_source(provided_cert_source, use_cert_flag):
|
|
@@ -432,7 +452,7 @@ class DirectAccessServiceClient(metaclass=DirectAccessServiceClientMeta):
|
|
|
432
452
|
@staticmethod
|
|
433
453
|
def _get_api_endpoint(
|
|
434
454
|
api_override, client_cert_source, universe_domain, use_mtls_endpoint
|
|
435
|
-
):
|
|
455
|
+
) -> str:
|
|
436
456
|
"""Return the API endpoint used by the client.
|
|
437
457
|
|
|
438
458
|
Args:
|
|
@@ -529,7 +549,7 @@ class DirectAccessServiceClient(metaclass=DirectAccessServiceClientMeta):
|
|
|
529
549
|
error._details.append(json.dumps(cred_info))
|
|
530
550
|
|
|
531
551
|
@property
|
|
532
|
-
def api_endpoint(self):
|
|
552
|
+
def api_endpoint(self) -> str:
|
|
533
553
|
"""Return the API endpoint used by the client instance.
|
|
534
554
|
|
|
535
555
|
Returns:
|
|
@@ -620,18 +640,16 @@ class DirectAccessServiceClient(metaclass=DirectAccessServiceClientMeta):
|
|
|
620
640
|
|
|
621
641
|
universe_domain_opt = getattr(self._client_options, "universe_domain", None)
|
|
622
642
|
|
|
623
|
-
(
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
self._universe_domain_env,
|
|
627
|
-
) = DirectAccessServiceClient._read_environment_variables()
|
|
643
|
+
self._use_client_cert, self._use_mtls_endpoint, self._universe_domain_env = (
|
|
644
|
+
DirectAccessServiceClient._read_environment_variables()
|
|
645
|
+
)
|
|
628
646
|
self._client_cert_source = DirectAccessServiceClient._get_client_cert_source(
|
|
629
647
|
self._client_options.client_cert_source, self._use_client_cert
|
|
630
648
|
)
|
|
631
649
|
self._universe_domain = DirectAccessServiceClient._get_universe_domain(
|
|
632
650
|
universe_domain_opt, self._universe_domain_env
|
|
633
651
|
)
|
|
634
|
-
self._api_endpoint =
|
|
652
|
+
self._api_endpoint: str = "" # updated below, depending on `transport`
|
|
635
653
|
|
|
636
654
|
# Initialize the universe domain validation.
|
|
637
655
|
self._is_universe_domain_valid = False
|
|
@@ -659,8 +677,7 @@ class DirectAccessServiceClient(metaclass=DirectAccessServiceClientMeta):
|
|
|
659
677
|
)
|
|
660
678
|
if self._client_options.scopes:
|
|
661
679
|
raise ValueError(
|
|
662
|
-
"When providing a transport instance, provide its scopes "
|
|
663
|
-
"directly."
|
|
680
|
+
"When providing a transport instance, provide its scopes directly."
|
|
664
681
|
)
|
|
665
682
|
self._transport = cast(DirectAccessServiceTransport, transport)
|
|
666
683
|
self._api_endpoint = self._transport.host
|
|
@@ -67,7 +67,7 @@ class ListDeviceSessionsPager:
|
|
|
67
67
|
*,
|
|
68
68
|
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
69
69
|
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
70
|
-
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
|
|
70
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
71
71
|
):
|
|
72
72
|
"""Instantiate the pager.
|
|
73
73
|
|
|
@@ -143,7 +143,7 @@ class ListDeviceSessionsAsyncPager:
|
|
|
143
143
|
*,
|
|
144
144
|
retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT,
|
|
145
145
|
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
146
|
-
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
|
|
146
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
147
147
|
):
|
|
148
148
|
"""Instantiates the pager.
|
|
149
149
|
|
|
@@ -22,9 +22,7 @@ from .grpc_asyncio import DirectAccessServiceGrpcAsyncIOTransport
|
|
|
22
22
|
from .rest import DirectAccessServiceRestInterceptor, DirectAccessServiceRestTransport
|
|
23
23
|
|
|
24
24
|
# Compile a registry of transports.
|
|
25
|
-
_transport_registry = (
|
|
26
|
-
OrderedDict()
|
|
27
|
-
) # type: Dict[str, Type[DirectAccessServiceTransport]]
|
|
25
|
+
_transport_registry = OrderedDict() # type: Dict[str, Type[DirectAccessServiceTransport]]
|
|
28
26
|
_transport_registry["grpc"] = DirectAccessServiceGrpcTransport
|
|
29
27
|
_transport_registry["grpc_asyncio"] = DirectAccessServiceGrpcAsyncIOTransport
|
|
30
28
|
_transport_registry["rest"] = DirectAccessServiceRestTransport
|
|
@@ -17,14 +17,14 @@ import abc
|
|
|
17
17
|
from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
|
|
18
18
|
|
|
19
19
|
import google.api_core
|
|
20
|
+
import google.auth # type: ignore
|
|
21
|
+
import google.protobuf
|
|
22
|
+
import google.protobuf.empty_pb2 as empty_pb2 # type: ignore
|
|
20
23
|
from google.api_core import exceptions as core_exceptions
|
|
21
24
|
from google.api_core import gapic_v1
|
|
22
25
|
from google.api_core import retry as retries
|
|
23
|
-
import google.auth # type: ignore
|
|
24
26
|
from google.auth import credentials as ga_credentials # type: ignore
|
|
25
27
|
from google.oauth2 import service_account # type: ignore
|
|
26
|
-
import google.protobuf
|
|
27
|
-
from google.protobuf import empty_pb2 # type: ignore
|
|
28
28
|
|
|
29
29
|
from google.cloud.devicestreaming_v1 import gapic_version as package_version
|
|
30
30
|
from google.cloud.devicestreaming_v1.types import adb_service, service
|
|
@@ -81,10 +81,12 @@ class DirectAccessServiceTransport(abc.ABC):
|
|
|
81
81
|
your own client library.
|
|
82
82
|
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
|
|
83
83
|
be used for service account credentials.
|
|
84
|
+
api_audience (Optional[str]): The intended audience for the API calls
|
|
85
|
+
to the service that will be set when using certain 3rd party
|
|
86
|
+
authentication flows. Audience is typically a resource identifier.
|
|
87
|
+
If not set, the host value will be used as a default.
|
|
84
88
|
"""
|
|
85
89
|
|
|
86
|
-
scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES}
|
|
87
|
-
|
|
88
90
|
# Save the scopes.
|
|
89
91
|
self._scopes = scopes
|
|
90
92
|
if not hasattr(self, "_ignore_credentials"):
|
|
@@ -99,11 +101,16 @@ class DirectAccessServiceTransport(abc.ABC):
|
|
|
99
101
|
|
|
100
102
|
if credentials_file is not None:
|
|
101
103
|
credentials, _ = google.auth.load_credentials_from_file(
|
|
102
|
-
credentials_file,
|
|
104
|
+
credentials_file,
|
|
105
|
+
scopes=scopes,
|
|
106
|
+
quota_project_id=quota_project_id,
|
|
107
|
+
default_scopes=self.AUTH_SCOPES,
|
|
103
108
|
)
|
|
104
109
|
elif credentials is None and not self._ignore_credentials:
|
|
105
110
|
credentials, _ = google.auth.default(
|
|
106
|
-
|
|
111
|
+
scopes=scopes,
|
|
112
|
+
quota_project_id=quota_project_id,
|
|
113
|
+
default_scopes=self.AUTH_SCOPES,
|
|
107
114
|
)
|
|
108
115
|
# Don't apply audience if the credentials file passed from user.
|
|
109
116
|
if hasattr(credentials, "with_gdch_audience"):
|
|
@@ -127,6 +134,8 @@ class DirectAccessServiceTransport(abc.ABC):
|
|
|
127
134
|
host += ":443"
|
|
128
135
|
self._host = host
|
|
129
136
|
|
|
137
|
+
self._wrapped_methods: Dict[Callable, Callable] = {}
|
|
138
|
+
|
|
130
139
|
@property
|
|
131
140
|
def host(self):
|
|
132
141
|
return self._host
|