google-cloud-video-transcoder 1.18.0__tar.gz → 1.19.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.
Files changed (39) hide show
  1. {google_cloud_video_transcoder-1.18.0/google_cloud_video_transcoder.egg-info → google_cloud_video_transcoder-1.19.0}/PKG-INFO +1 -1
  2. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/google/cloud/video/transcoder/gapic_version.py +1 -1
  3. google_cloud_video_transcoder-1.19.0/google/cloud/video/transcoder_v1/__init__.py +199 -0
  4. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/google/cloud/video/transcoder_v1/gapic_version.py +1 -1
  5. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/google/cloud/video/transcoder_v1/services/transcoder_service/client.py +32 -14
  6. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0/google_cloud_video_transcoder.egg-info}/PKG-INFO +1 -1
  7. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/tests/unit/gapic/transcoder_v1/test_transcoder_service.py +226 -29
  8. google_cloud_video_transcoder-1.18.0/google/cloud/video/transcoder_v1/__init__.py +0 -95
  9. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/LICENSE +0 -0
  10. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/MANIFEST.in +0 -0
  11. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/README.rst +0 -0
  12. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/google/cloud/video/transcoder/__init__.py +0 -0
  13. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/google/cloud/video/transcoder/py.typed +0 -0
  14. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/google/cloud/video/transcoder_v1/gapic_metadata.json +0 -0
  15. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/google/cloud/video/transcoder_v1/py.typed +0 -0
  16. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/google/cloud/video/transcoder_v1/services/__init__.py +0 -0
  17. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/google/cloud/video/transcoder_v1/services/transcoder_service/__init__.py +0 -0
  18. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/google/cloud/video/transcoder_v1/services/transcoder_service/async_client.py +0 -0
  19. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/google/cloud/video/transcoder_v1/services/transcoder_service/pagers.py +0 -0
  20. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/google/cloud/video/transcoder_v1/services/transcoder_service/transports/__init__.py +0 -0
  21. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/google/cloud/video/transcoder_v1/services/transcoder_service/transports/base.py +0 -0
  22. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/google/cloud/video/transcoder_v1/services/transcoder_service/transports/grpc.py +0 -0
  23. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/google/cloud/video/transcoder_v1/services/transcoder_service/transports/grpc_asyncio.py +0 -0
  24. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/google/cloud/video/transcoder_v1/services/transcoder_service/transports/rest.py +0 -0
  25. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/google/cloud/video/transcoder_v1/services/transcoder_service/transports/rest_base.py +0 -0
  26. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/google/cloud/video/transcoder_v1/types/__init__.py +0 -0
  27. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/google/cloud/video/transcoder_v1/types/resources.py +0 -0
  28. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/google/cloud/video/transcoder_v1/types/services.py +0 -0
  29. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/google_cloud_video_transcoder.egg-info/SOURCES.txt +0 -0
  30. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/google_cloud_video_transcoder.egg-info/dependency_links.txt +0 -0
  31. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/google_cloud_video_transcoder.egg-info/not-zip-safe +0 -0
  32. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/google_cloud_video_transcoder.egg-info/requires.txt +0 -0
  33. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/google_cloud_video_transcoder.egg-info/top_level.txt +0 -0
  34. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/setup.cfg +0 -0
  35. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/setup.py +0 -0
  36. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/tests/__init__.py +0 -0
  37. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/tests/unit/__init__.py +0 -0
  38. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/tests/unit/gapic/__init__.py +0 -0
  39. {google_cloud_video_transcoder-1.18.0 → google_cloud_video_transcoder-1.19.0}/tests/unit/gapic/transcoder_v1/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: google-cloud-video-transcoder
3
- Version: 1.18.0
3
+ Version: 1.19.0
4
4
  Summary: Google Cloud Video Transcoder API client library
5
5
  Home-page: https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-video-transcoder
6
6
  Author: Google LLC
@@ -13,4 +13,4 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
  #
16
- __version__ = "1.18.0" # {x-release-please-version}
16
+ __version__ = "1.19.0" # {x-release-please-version}
@@ -0,0 +1,199 @@
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.video.transcoder_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
+ from .services.transcoder_service import (
32
+ TranscoderServiceAsyncClient,
33
+ TranscoderServiceClient,
34
+ )
35
+ from .types.resources import (
36
+ AdBreak,
37
+ AudioStream,
38
+ EditAtom,
39
+ ElementaryStream,
40
+ Encryption,
41
+ Input,
42
+ InputAttributes,
43
+ Job,
44
+ JobConfig,
45
+ JobTemplate,
46
+ Manifest,
47
+ MuxStream,
48
+ Output,
49
+ Overlay,
50
+ PreprocessingConfig,
51
+ PubsubDestination,
52
+ SegmentSettings,
53
+ SpriteSheet,
54
+ TextStream,
55
+ TrackDefinition,
56
+ VideoStream,
57
+ )
58
+ from .types.services import (
59
+ CreateJobRequest,
60
+ CreateJobTemplateRequest,
61
+ DeleteJobRequest,
62
+ DeleteJobTemplateRequest,
63
+ GetJobRequest,
64
+ GetJobTemplateRequest,
65
+ ListJobsRequest,
66
+ ListJobsResponse,
67
+ ListJobTemplatesRequest,
68
+ ListJobTemplatesResponse,
69
+ )
70
+
71
+ if hasattr(api_core, "check_python_version") and hasattr(
72
+ api_core, "check_dependency_versions"
73
+ ): # pragma: NO COVER
74
+ api_core.check_python_version("google.cloud.video.transcoder_v1") # type: ignore
75
+ api_core.check_dependency_versions("google.cloud.video.transcoder_v1") # type: ignore
76
+ else: # pragma: NO COVER
77
+ # An older version of api_core is installed which does not define the
78
+ # functions above. We do equivalent checks manually.
79
+ try:
80
+ import sys
81
+ import warnings
82
+
83
+ _py_version_str = sys.version.split()[0]
84
+ _package_label = "google.cloud.video.transcoder_v1"
85
+ if sys.version_info < (3, 9):
86
+ warnings.warn(
87
+ "You are using a non-supported Python version "
88
+ + f"({_py_version_str}). Google will not post any further "
89
+ + f"updates to {_package_label} supporting this Python version. "
90
+ + "Please upgrade to the latest Python version, or at "
91
+ + f"least to Python 3.9, and then update {_package_label}.",
92
+ FutureWarning,
93
+ )
94
+ if sys.version_info[:2] == (3, 9):
95
+ warnings.warn(
96
+ f"You are using a Python version ({_py_version_str}) "
97
+ + f"which Google will stop supporting in {_package_label} in "
98
+ + "January 2026. Please "
99
+ + "upgrade to the latest Python version, or at "
100
+ + "least to Python 3.10, before then, and "
101
+ + f"then update {_package_label}.",
102
+ FutureWarning,
103
+ )
104
+
105
+ def parse_version_to_tuple(version_string: str):
106
+ """Safely converts a semantic version string to a comparable tuple of integers.
107
+ Example: "4.25.8" -> (4, 25, 8)
108
+ Ignores non-numeric parts and handles common version formats.
109
+ Args:
110
+ version_string: Version string in the format "x.y.z" or "x.y.z<suffix>"
111
+ Returns:
112
+ Tuple of integers for the parsed version string.
113
+ """
114
+ parts = []
115
+ for part in version_string.split("."):
116
+ try:
117
+ parts.append(int(part))
118
+ except ValueError:
119
+ # If it's a non-numeric part (e.g., '1.0.0b1' -> 'b1'), stop here.
120
+ # This is a simplification compared to 'packaging.parse_version', but sufficient
121
+ # for comparing strictly numeric semantic versions.
122
+ break
123
+ return tuple(parts)
124
+
125
+ def _get_version(dependency_name):
126
+ try:
127
+ version_string: str = metadata.version(dependency_name)
128
+ parsed_version = parse_version_to_tuple(version_string)
129
+ return (parsed_version, version_string)
130
+ except Exception:
131
+ # Catch exceptions from metadata.version() (e.g., PackageNotFoundError)
132
+ # or errors during parse_version_to_tuple
133
+ return (None, "--")
134
+
135
+ _dependency_package = "google.protobuf"
136
+ _next_supported_version = "4.25.8"
137
+ _next_supported_version_tuple = (4, 25, 8)
138
+ _recommendation = " (we recommend 6.x)"
139
+ (_version_used, _version_used_string) = _get_version(_dependency_package)
140
+ if _version_used and _version_used < _next_supported_version_tuple:
141
+ warnings.warn(
142
+ f"Package {_package_label} depends on "
143
+ + f"{_dependency_package}, currently installed at version "
144
+ + f"{_version_used_string}. Future updates to "
145
+ + f"{_package_label} will require {_dependency_package} at "
146
+ + f"version {_next_supported_version} or higher{_recommendation}."
147
+ + " Please ensure "
148
+ + "that either (a) your Python environment doesn't pin the "
149
+ + f"version of {_dependency_package}, so that updates to "
150
+ + f"{_package_label} can require the higher version, or "
151
+ + "(b) you manually update your Python environment to use at "
152
+ + f"least version {_next_supported_version} of "
153
+ + f"{_dependency_package}.",
154
+ FutureWarning,
155
+ )
156
+ except Exception:
157
+ warnings.warn(
158
+ "Could not determine the version of Python "
159
+ + "currently being used. To continue receiving "
160
+ + "updates for {_package_label}, ensure you are "
161
+ + "using a supported version of Python; see "
162
+ + "https://devguide.python.org/versions/"
163
+ )
164
+
165
+ __all__ = (
166
+ "TranscoderServiceAsyncClient",
167
+ "AdBreak",
168
+ "AudioStream",
169
+ "CreateJobRequest",
170
+ "CreateJobTemplateRequest",
171
+ "DeleteJobRequest",
172
+ "DeleteJobTemplateRequest",
173
+ "EditAtom",
174
+ "ElementaryStream",
175
+ "Encryption",
176
+ "GetJobRequest",
177
+ "GetJobTemplateRequest",
178
+ "Input",
179
+ "InputAttributes",
180
+ "Job",
181
+ "JobConfig",
182
+ "JobTemplate",
183
+ "ListJobTemplatesRequest",
184
+ "ListJobTemplatesResponse",
185
+ "ListJobsRequest",
186
+ "ListJobsResponse",
187
+ "Manifest",
188
+ "MuxStream",
189
+ "Output",
190
+ "Overlay",
191
+ "PreprocessingConfig",
192
+ "PubsubDestination",
193
+ "SegmentSettings",
194
+ "SpriteSheet",
195
+ "TextStream",
196
+ "TrackDefinition",
197
+ "TranscoderServiceClient",
198
+ "VideoStream",
199
+ )
@@ -13,4 +13,4 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
  #
16
- __version__ = "1.18.0" # {x-release-please-version}
16
+ __version__ = "1.19.0" # {x-release-please-version}
@@ -159,6 +159,34 @@ class TranscoderServiceClient(metaclass=TranscoderServiceClientMeta):
159
159
  _DEFAULT_ENDPOINT_TEMPLATE = "transcoder.{UNIVERSE_DOMAIN}"
160
160
  _DEFAULT_UNIVERSE = "googleapis.com"
161
161
 
162
+ @staticmethod
163
+ def _use_client_cert_effective():
164
+ """Returns whether client certificate should be used for mTLS if the
165
+ google-auth version supports should_use_client_cert automatic mTLS enablement.
166
+
167
+ Alternatively, read from the GOOGLE_API_USE_CLIENT_CERTIFICATE env var.
168
+
169
+ Returns:
170
+ bool: whether client certificate should be used for mTLS
171
+ Raises:
172
+ ValueError: (If using a version of google-auth without should_use_client_cert and
173
+ GOOGLE_API_USE_CLIENT_CERTIFICATE is set to an unexpected value.)
174
+ """
175
+ # check if google-auth version supports should_use_client_cert for automatic mTLS enablement
176
+ if hasattr(mtls, "should_use_client_cert"): # pragma: NO COVER
177
+ return mtls.should_use_client_cert()
178
+ else: # pragma: NO COVER
179
+ # if unsupported, fallback to reading from env var
180
+ use_client_cert_str = os.getenv(
181
+ "GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
182
+ ).lower()
183
+ if use_client_cert_str not in ("true", "false"):
184
+ raise ValueError(
185
+ "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be"
186
+ " either `true` or `false`"
187
+ )
188
+ return use_client_cert_str == "true"
189
+
162
190
  @classmethod
163
191
  def from_service_account_info(cls, info: dict, *args, **kwargs):
164
192
  """Creates an instance of this client using the provided credentials
@@ -368,12 +396,8 @@ class TranscoderServiceClient(metaclass=TranscoderServiceClientMeta):
368
396
  )
369
397
  if client_options is None:
370
398
  client_options = client_options_lib.ClientOptions()
371
- use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")
399
+ use_client_cert = TranscoderServiceClient._use_client_cert_effective()
372
400
  use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto")
373
- if use_client_cert not in ("true", "false"):
374
- raise ValueError(
375
- "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
376
- )
377
401
  if use_mtls_endpoint not in ("auto", "never", "always"):
378
402
  raise MutualTLSChannelError(
379
403
  "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
@@ -381,7 +405,7 @@ class TranscoderServiceClient(metaclass=TranscoderServiceClientMeta):
381
405
 
382
406
  # Figure out the client cert source to use.
383
407
  client_cert_source = None
384
- if use_client_cert == "true":
408
+ if use_client_cert:
385
409
  if client_options.client_cert_source:
386
410
  client_cert_source = client_options.client_cert_source
387
411
  elif mtls.has_default_client_cert_source():
@@ -413,20 +437,14 @@ class TranscoderServiceClient(metaclass=TranscoderServiceClientMeta):
413
437
  google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT
414
438
  is not any of ["auto", "never", "always"].
415
439
  """
416
- use_client_cert = os.getenv(
417
- "GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
418
- ).lower()
440
+ use_client_cert = TranscoderServiceClient._use_client_cert_effective()
419
441
  use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower()
420
442
  universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN")
421
- if use_client_cert not in ("true", "false"):
422
- raise ValueError(
423
- "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
424
- )
425
443
  if use_mtls_endpoint not in ("auto", "never", "always"):
426
444
  raise MutualTLSChannelError(
427
445
  "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
428
446
  )
429
- return use_client_cert == "true", use_mtls_endpoint, universe_domain_env
447
+ return use_client_cert, use_mtls_endpoint, universe_domain_env
430
448
 
431
449
  @staticmethod
432
450
  def _get_client_cert_source(provided_cert_source, use_cert_flag):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: google-cloud-video-transcoder
3
- Version: 1.18.0
3
+ Version: 1.19.0
4
4
  Summary: Google Cloud Video Transcoder API client library
5
5
  Home-page: https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-video-transcoder
6
6
  Author: Google LLC
@@ -166,12 +166,19 @@ def test__read_environment_variables():
166
166
  with mock.patch.dict(
167
167
  os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}
168
168
  ):
169
- with pytest.raises(ValueError) as excinfo:
170
- TranscoderServiceClient._read_environment_variables()
171
- assert (
172
- str(excinfo.value)
173
- == "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
174
- )
169
+ if not hasattr(google.auth.transport.mtls, "should_use_client_cert"):
170
+ with pytest.raises(ValueError) as excinfo:
171
+ TranscoderServiceClient._read_environment_variables()
172
+ assert (
173
+ str(excinfo.value)
174
+ == "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
175
+ )
176
+ else:
177
+ assert TranscoderServiceClient._read_environment_variables() == (
178
+ False,
179
+ "auto",
180
+ None,
181
+ )
175
182
 
176
183
  with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}):
177
184
  assert TranscoderServiceClient._read_environment_variables() == (
@@ -210,6 +217,105 @@ def test__read_environment_variables():
210
217
  )
211
218
 
212
219
 
220
+ def test_use_client_cert_effective():
221
+ # Test case 1: Test when `should_use_client_cert` returns True.
222
+ # We mock the `should_use_client_cert` function to simulate a scenario where
223
+ # the google-auth library supports automatic mTLS and determines that a
224
+ # client certificate should be used.
225
+ if hasattr(google.auth.transport.mtls, "should_use_client_cert"):
226
+ with mock.patch(
227
+ "google.auth.transport.mtls.should_use_client_cert", return_value=True
228
+ ):
229
+ assert TranscoderServiceClient._use_client_cert_effective() is True
230
+
231
+ # Test case 2: Test when `should_use_client_cert` returns False.
232
+ # We mock the `should_use_client_cert` function to simulate a scenario where
233
+ # the google-auth library supports automatic mTLS and determines that a
234
+ # client certificate should NOT be used.
235
+ if hasattr(google.auth.transport.mtls, "should_use_client_cert"):
236
+ with mock.patch(
237
+ "google.auth.transport.mtls.should_use_client_cert", return_value=False
238
+ ):
239
+ assert TranscoderServiceClient._use_client_cert_effective() is False
240
+
241
+ # Test case 3: Test when `should_use_client_cert` is unavailable and the
242
+ # `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is set to "true".
243
+ if not hasattr(google.auth.transport.mtls, "should_use_client_cert"):
244
+ with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}):
245
+ assert TranscoderServiceClient._use_client_cert_effective() is True
246
+
247
+ # Test case 4: Test when `should_use_client_cert` is unavailable and the
248
+ # `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is set to "false".
249
+ if not hasattr(google.auth.transport.mtls, "should_use_client_cert"):
250
+ with mock.patch.dict(
251
+ os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}
252
+ ):
253
+ assert TranscoderServiceClient._use_client_cert_effective() is False
254
+
255
+ # Test case 5: Test when `should_use_client_cert` is unavailable and the
256
+ # `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is set to "True".
257
+ if not hasattr(google.auth.transport.mtls, "should_use_client_cert"):
258
+ with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "True"}):
259
+ assert TranscoderServiceClient._use_client_cert_effective() is True
260
+
261
+ # Test case 6: Test when `should_use_client_cert` is unavailable and the
262
+ # `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is set to "False".
263
+ if not hasattr(google.auth.transport.mtls, "should_use_client_cert"):
264
+ with mock.patch.dict(
265
+ os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "False"}
266
+ ):
267
+ assert TranscoderServiceClient._use_client_cert_effective() is False
268
+
269
+ # Test case 7: Test when `should_use_client_cert` is unavailable and the
270
+ # `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is set to "TRUE".
271
+ if not hasattr(google.auth.transport.mtls, "should_use_client_cert"):
272
+ with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "TRUE"}):
273
+ assert TranscoderServiceClient._use_client_cert_effective() is True
274
+
275
+ # Test case 8: Test when `should_use_client_cert` is unavailable and the
276
+ # `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is set to "FALSE".
277
+ if not hasattr(google.auth.transport.mtls, "should_use_client_cert"):
278
+ with mock.patch.dict(
279
+ os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "FALSE"}
280
+ ):
281
+ assert TranscoderServiceClient._use_client_cert_effective() is False
282
+
283
+ # Test case 9: Test when `should_use_client_cert` is unavailable and the
284
+ # `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not set.
285
+ # In this case, the method should return False, which is the default value.
286
+ if not hasattr(google.auth.transport.mtls, "should_use_client_cert"):
287
+ with mock.patch.dict(os.environ, clear=True):
288
+ assert TranscoderServiceClient._use_client_cert_effective() is False
289
+
290
+ # Test case 10: Test when `should_use_client_cert` is unavailable and the
291
+ # `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is set to an invalid value.
292
+ # The method should raise a ValueError as the environment variable must be either
293
+ # "true" or "false".
294
+ if not hasattr(google.auth.transport.mtls, "should_use_client_cert"):
295
+ with mock.patch.dict(
296
+ os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "unsupported"}
297
+ ):
298
+ with pytest.raises(ValueError):
299
+ TranscoderServiceClient._use_client_cert_effective()
300
+
301
+ # Test case 11: Test when `should_use_client_cert` is available and the
302
+ # `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is set to an invalid value.
303
+ # The method should return False as the environment variable is set to an invalid value.
304
+ if hasattr(google.auth.transport.mtls, "should_use_client_cert"):
305
+ with mock.patch.dict(
306
+ os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "unsupported"}
307
+ ):
308
+ assert TranscoderServiceClient._use_client_cert_effective() is False
309
+
310
+ # Test case 12: Test when `should_use_client_cert` is available and the
311
+ # `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is unset. Also,
312
+ # the GOOGLE_API_CONFIG environment variable is unset.
313
+ if hasattr(google.auth.transport.mtls, "should_use_client_cert"):
314
+ with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": ""}):
315
+ with mock.patch.dict(os.environ, {"GOOGLE_API_CERTIFICATE_CONFIG": ""}):
316
+ assert TranscoderServiceClient._use_client_cert_effective() is False
317
+
318
+
213
319
  def test__get_client_cert_source():
214
320
  mock_provided_cert_source = mock.Mock()
215
321
  mock_default_cert_source = mock.Mock()
@@ -583,17 +689,6 @@ def test_transcoder_service_client_client_options(
583
689
  == "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
584
690
  )
585
691
 
586
- # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value.
587
- with mock.patch.dict(
588
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}
589
- ):
590
- with pytest.raises(ValueError) as excinfo:
591
- client = client_class(transport=transport_name)
592
- assert (
593
- str(excinfo.value)
594
- == "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
595
- )
596
-
597
692
  # Check the case quota_project_id is provided
598
693
  options = client_options.ClientOptions(quota_project_id="octopus")
599
694
  with mock.patch.object(transport_class, "__init__") as patched:
@@ -829,6 +924,119 @@ def test_transcoder_service_client_get_mtls_endpoint_and_cert_source(client_clas
829
924
  assert api_endpoint == mock_api_endpoint
830
925
  assert cert_source is None
831
926
 
927
+ # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "Unsupported".
928
+ with mock.patch.dict(
929
+ os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}
930
+ ):
931
+ if hasattr(google.auth.transport.mtls, "should_use_client_cert"):
932
+ mock_client_cert_source = mock.Mock()
933
+ mock_api_endpoint = "foo"
934
+ options = client_options.ClientOptions(
935
+ client_cert_source=mock_client_cert_source,
936
+ api_endpoint=mock_api_endpoint,
937
+ )
938
+ api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(
939
+ options
940
+ )
941
+ assert api_endpoint == mock_api_endpoint
942
+ assert cert_source is None
943
+
944
+ # Test cases for mTLS enablement when GOOGLE_API_USE_CLIENT_CERTIFICATE is unset.
945
+ test_cases = [
946
+ (
947
+ # With workloads present in config, mTLS is enabled.
948
+ {
949
+ "version": 1,
950
+ "cert_configs": {
951
+ "workload": {
952
+ "cert_path": "path/to/cert/file",
953
+ "key_path": "path/to/key/file",
954
+ }
955
+ },
956
+ },
957
+ mock_client_cert_source,
958
+ ),
959
+ (
960
+ # With workloads not present in config, mTLS is disabled.
961
+ {
962
+ "version": 1,
963
+ "cert_configs": {},
964
+ },
965
+ None,
966
+ ),
967
+ ]
968
+ if hasattr(google.auth.transport.mtls, "should_use_client_cert"):
969
+ for config_data, expected_cert_source in test_cases:
970
+ env = os.environ.copy()
971
+ env.pop("GOOGLE_API_USE_CLIENT_CERTIFICATE", None)
972
+ with mock.patch.dict(os.environ, env, clear=True):
973
+ config_filename = "mock_certificate_config.json"
974
+ config_file_content = json.dumps(config_data)
975
+ m = mock.mock_open(read_data=config_file_content)
976
+ with mock.patch("builtins.open", m):
977
+ with mock.patch.dict(
978
+ os.environ, {"GOOGLE_API_CERTIFICATE_CONFIG": config_filename}
979
+ ):
980
+ mock_api_endpoint = "foo"
981
+ options = client_options.ClientOptions(
982
+ client_cert_source=mock_client_cert_source,
983
+ api_endpoint=mock_api_endpoint,
984
+ )
985
+ (
986
+ api_endpoint,
987
+ cert_source,
988
+ ) = client_class.get_mtls_endpoint_and_cert_source(options)
989
+ assert api_endpoint == mock_api_endpoint
990
+ assert cert_source is expected_cert_source
991
+
992
+ # Test cases for mTLS enablement when GOOGLE_API_USE_CLIENT_CERTIFICATE is unset(empty).
993
+ test_cases = [
994
+ (
995
+ # With workloads present in config, mTLS is enabled.
996
+ {
997
+ "version": 1,
998
+ "cert_configs": {
999
+ "workload": {
1000
+ "cert_path": "path/to/cert/file",
1001
+ "key_path": "path/to/key/file",
1002
+ }
1003
+ },
1004
+ },
1005
+ mock_client_cert_source,
1006
+ ),
1007
+ (
1008
+ # With workloads not present in config, mTLS is disabled.
1009
+ {
1010
+ "version": 1,
1011
+ "cert_configs": {},
1012
+ },
1013
+ None,
1014
+ ),
1015
+ ]
1016
+ if hasattr(google.auth.transport.mtls, "should_use_client_cert"):
1017
+ for config_data, expected_cert_source in test_cases:
1018
+ env = os.environ.copy()
1019
+ env.pop("GOOGLE_API_USE_CLIENT_CERTIFICATE", "")
1020
+ with mock.patch.dict(os.environ, env, clear=True):
1021
+ config_filename = "mock_certificate_config.json"
1022
+ config_file_content = json.dumps(config_data)
1023
+ m = mock.mock_open(read_data=config_file_content)
1024
+ with mock.patch("builtins.open", m):
1025
+ with mock.patch.dict(
1026
+ os.environ, {"GOOGLE_API_CERTIFICATE_CONFIG": config_filename}
1027
+ ):
1028
+ mock_api_endpoint = "foo"
1029
+ options = client_options.ClientOptions(
1030
+ client_cert_source=mock_client_cert_source,
1031
+ api_endpoint=mock_api_endpoint,
1032
+ )
1033
+ (
1034
+ api_endpoint,
1035
+ cert_source,
1036
+ ) = client_class.get_mtls_endpoint_and_cert_source(options)
1037
+ assert api_endpoint == mock_api_endpoint
1038
+ assert cert_source is expected_cert_source
1039
+
832
1040
  # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never".
833
1041
  with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}):
834
1042
  api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source()
@@ -879,18 +1087,6 @@ def test_transcoder_service_client_get_mtls_endpoint_and_cert_source(client_clas
879
1087
  == "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
880
1088
  )
881
1089
 
882
- # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value.
883
- with mock.patch.dict(
884
- os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}
885
- ):
886
- with pytest.raises(ValueError) as excinfo:
887
- client_class.get_mtls_endpoint_and_cert_source()
888
-
889
- assert (
890
- str(excinfo.value)
891
- == "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
892
- )
893
-
894
1090
 
895
1091
  @pytest.mark.parametrize(
896
1092
  "client_class", [TranscoderServiceClient, TranscoderServiceAsyncClient]
@@ -8618,6 +8814,7 @@ def test_transcoder_service_grpc_asyncio_transport_channel():
8618
8814
 
8619
8815
  # Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are
8620
8816
  # removed from grpc/grpc_asyncio transport constructor.
8817
+ @pytest.mark.filterwarnings("ignore::FutureWarning")
8621
8818
  @pytest.mark.parametrize(
8622
8819
  "transport_class",
8623
8820
  [
@@ -1,95 +0,0 @@
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 google.cloud.video.transcoder_v1 import gapic_version as package_version
17
-
18
- __version__ = package_version.__version__
19
-
20
-
21
- from .services.transcoder_service import (
22
- TranscoderServiceAsyncClient,
23
- TranscoderServiceClient,
24
- )
25
- from .types.resources import (
26
- AdBreak,
27
- AudioStream,
28
- EditAtom,
29
- ElementaryStream,
30
- Encryption,
31
- Input,
32
- InputAttributes,
33
- Job,
34
- JobConfig,
35
- JobTemplate,
36
- Manifest,
37
- MuxStream,
38
- Output,
39
- Overlay,
40
- PreprocessingConfig,
41
- PubsubDestination,
42
- SegmentSettings,
43
- SpriteSheet,
44
- TextStream,
45
- TrackDefinition,
46
- VideoStream,
47
- )
48
- from .types.services import (
49
- CreateJobRequest,
50
- CreateJobTemplateRequest,
51
- DeleteJobRequest,
52
- DeleteJobTemplateRequest,
53
- GetJobRequest,
54
- GetJobTemplateRequest,
55
- ListJobsRequest,
56
- ListJobsResponse,
57
- ListJobTemplatesRequest,
58
- ListJobTemplatesResponse,
59
- )
60
-
61
- __all__ = (
62
- "TranscoderServiceAsyncClient",
63
- "AdBreak",
64
- "AudioStream",
65
- "CreateJobRequest",
66
- "CreateJobTemplateRequest",
67
- "DeleteJobRequest",
68
- "DeleteJobTemplateRequest",
69
- "EditAtom",
70
- "ElementaryStream",
71
- "Encryption",
72
- "GetJobRequest",
73
- "GetJobTemplateRequest",
74
- "Input",
75
- "InputAttributes",
76
- "Job",
77
- "JobConfig",
78
- "JobTemplate",
79
- "ListJobTemplatesRequest",
80
- "ListJobTemplatesResponse",
81
- "ListJobsRequest",
82
- "ListJobsResponse",
83
- "Manifest",
84
- "MuxStream",
85
- "Output",
86
- "Overlay",
87
- "PreprocessingConfig",
88
- "PubsubDestination",
89
- "SegmentSettings",
90
- "SpriteSheet",
91
- "TextStream",
92
- "TrackDefinition",
93
- "TranscoderServiceClient",
94
- "VideoStream",
95
- )