google-cloud-video-transcoder 1.15.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. google/cloud/video/transcoder/__init__.py +93 -0
  2. google/cloud/video/transcoder/gapic_version.py +16 -0
  3. google/cloud/video/transcoder/py.typed +2 -0
  4. google/cloud/video/transcoder_v1/__init__.py +91 -0
  5. google/cloud/video/transcoder_v1/gapic_metadata.json +148 -0
  6. google/cloud/video/transcoder_v1/gapic_version.py +16 -0
  7. google/cloud/video/transcoder_v1/py.typed +2 -0
  8. google/cloud/video/transcoder_v1/services/__init__.py +15 -0
  9. google/cloud/video/transcoder_v1/services/transcoder_service/__init__.py +22 -0
  10. google/cloud/video/transcoder_v1/services/transcoder_service/async_client.py +1242 -0
  11. google/cloud/video/transcoder_v1/services/transcoder_service/client.py +1669 -0
  12. google/cloud/video/transcoder_v1/services/transcoder_service/pagers.py +353 -0
  13. google/cloud/video/transcoder_v1/services/transcoder_service/transports/__init__.py +36 -0
  14. google/cloud/video/transcoder_v1/services/transcoder_service/transports/base.py +260 -0
  15. google/cloud/video/transcoder_v1/services/transcoder_service/transports/grpc.py +542 -0
  16. google/cloud/video/transcoder_v1/services/transcoder_service/transports/grpc_asyncio.py +605 -0
  17. google/cloud/video/transcoder_v1/services/transcoder_service/transports/rest.py +1709 -0
  18. google/cloud/video/transcoder_v1/services/transcoder_service/transports/rest_base.py +490 -0
  19. google/cloud/video/transcoder_v1/types/__init__.py +80 -0
  20. google/cloud/video/transcoder_v1/types/resources.py +2534 -0
  21. google/cloud/video/transcoder_v1/types/services.py +326 -0
  22. google_cloud_video_transcoder-1.15.1.dist-info/LICENSE +202 -0
  23. google_cloud_video_transcoder-1.15.1.dist-info/METADATA +228 -0
  24. google_cloud_video_transcoder-1.15.1.dist-info/RECORD +26 -0
  25. google_cloud_video_transcoder-1.15.1.dist-info/WHEEL +5 -0
  26. google_cloud_video_transcoder-1.15.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1669 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2024 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ from collections import OrderedDict
17
+ from http import HTTPStatus
18
+ import json
19
+ import logging as std_logging
20
+ import os
21
+ import re
22
+ from typing import (
23
+ Callable,
24
+ Dict,
25
+ Mapping,
26
+ MutableMapping,
27
+ MutableSequence,
28
+ Optional,
29
+ Sequence,
30
+ Tuple,
31
+ Type,
32
+ Union,
33
+ cast,
34
+ )
35
+ import warnings
36
+
37
+ from google.api_core import client_options as client_options_lib
38
+ from google.api_core import exceptions as core_exceptions
39
+ from google.api_core import gapic_v1
40
+ from google.api_core import retry as retries
41
+ from google.auth import credentials as ga_credentials # type: ignore
42
+ from google.auth.exceptions import MutualTLSChannelError # type: ignore
43
+ from google.auth.transport import mtls # type: ignore
44
+ from google.auth.transport.grpc import SslCredentials # type: ignore
45
+ from google.oauth2 import service_account # type: ignore
46
+
47
+ from google.cloud.video.transcoder_v1 import gapic_version as package_version
48
+
49
+ try:
50
+ OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
51
+ except AttributeError: # pragma: NO COVER
52
+ OptionalRetry = Union[retries.Retry, object, None] # type: ignore
53
+
54
+ try:
55
+ from google.api_core import client_logging # type: ignore
56
+
57
+ CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
58
+ except ImportError: # pragma: NO COVER
59
+ CLIENT_LOGGING_SUPPORTED = False
60
+
61
+ _LOGGER = std_logging.getLogger(__name__)
62
+
63
+ from google.protobuf import timestamp_pb2 # type: ignore
64
+ from google.rpc import status_pb2 # type: ignore
65
+
66
+ from google.cloud.video.transcoder_v1.services.transcoder_service import pagers
67
+ from google.cloud.video.transcoder_v1.types import resources, services
68
+
69
+ from .transports.base import DEFAULT_CLIENT_INFO, TranscoderServiceTransport
70
+ from .transports.grpc import TranscoderServiceGrpcTransport
71
+ from .transports.grpc_asyncio import TranscoderServiceGrpcAsyncIOTransport
72
+ from .transports.rest import TranscoderServiceRestTransport
73
+
74
+
75
+ class TranscoderServiceClientMeta(type):
76
+ """Metaclass for the TranscoderService client.
77
+
78
+ This provides class-level methods for building and retrieving
79
+ support objects (e.g. transport) without polluting the client instance
80
+ objects.
81
+ """
82
+
83
+ _transport_registry = (
84
+ OrderedDict()
85
+ ) # type: Dict[str, Type[TranscoderServiceTransport]]
86
+ _transport_registry["grpc"] = TranscoderServiceGrpcTransport
87
+ _transport_registry["grpc_asyncio"] = TranscoderServiceGrpcAsyncIOTransport
88
+ _transport_registry["rest"] = TranscoderServiceRestTransport
89
+
90
+ def get_transport_class(
91
+ cls,
92
+ label: Optional[str] = None,
93
+ ) -> Type[TranscoderServiceTransport]:
94
+ """Returns an appropriate transport class.
95
+
96
+ Args:
97
+ label: The name of the desired transport. If none is
98
+ provided, then the first transport in the registry is used.
99
+
100
+ Returns:
101
+ The transport class to use.
102
+ """
103
+ # If a specific transport is requested, return that one.
104
+ if label:
105
+ return cls._transport_registry[label]
106
+
107
+ # No transport is requested; return the default (that is, the first one
108
+ # in the dictionary).
109
+ return next(iter(cls._transport_registry.values()))
110
+
111
+
112
+ class TranscoderServiceClient(metaclass=TranscoderServiceClientMeta):
113
+ """Using the Transcoder API, you can queue asynchronous jobs for
114
+ transcoding media into various output formats. Output formats
115
+ may include different streaming standards such as HTTP Live
116
+ Streaming (HLS) and Dynamic Adaptive Streaming over HTTP (DASH).
117
+ You can also customize jobs using advanced features such as
118
+ Digital Rights Management (DRM), audio equalization, content
119
+ concatenation, and digital ad-stitch ready content generation.
120
+ """
121
+
122
+ @staticmethod
123
+ def _get_default_mtls_endpoint(api_endpoint):
124
+ """Converts api endpoint to mTLS endpoint.
125
+
126
+ Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
127
+ "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
128
+ Args:
129
+ api_endpoint (Optional[str]): the api endpoint to convert.
130
+ Returns:
131
+ str: converted mTLS api endpoint.
132
+ """
133
+ if not api_endpoint:
134
+ return api_endpoint
135
+
136
+ mtls_endpoint_re = re.compile(
137
+ r"(?P<name>[^.]+)(?P<mtls>\.mtls)?(?P<sandbox>\.sandbox)?(?P<googledomain>\.googleapis\.com)?"
138
+ )
139
+
140
+ m = mtls_endpoint_re.match(api_endpoint)
141
+ name, mtls, sandbox, googledomain = m.groups()
142
+ if mtls or not googledomain:
143
+ return api_endpoint
144
+
145
+ if sandbox:
146
+ return api_endpoint.replace(
147
+ "sandbox.googleapis.com", "mtls.sandbox.googleapis.com"
148
+ )
149
+
150
+ return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com")
151
+
152
+ # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
153
+ DEFAULT_ENDPOINT = "transcoder.googleapis.com"
154
+ DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore
155
+ DEFAULT_ENDPOINT
156
+ )
157
+
158
+ _DEFAULT_ENDPOINT_TEMPLATE = "transcoder.{UNIVERSE_DOMAIN}"
159
+ _DEFAULT_UNIVERSE = "googleapis.com"
160
+
161
+ @classmethod
162
+ def from_service_account_info(cls, info: dict, *args, **kwargs):
163
+ """Creates an instance of this client using the provided credentials
164
+ info.
165
+
166
+ Args:
167
+ info (dict): The service account private key info.
168
+ args: Additional arguments to pass to the constructor.
169
+ kwargs: Additional arguments to pass to the constructor.
170
+
171
+ Returns:
172
+ TranscoderServiceClient: The constructed client.
173
+ """
174
+ credentials = service_account.Credentials.from_service_account_info(info)
175
+ kwargs["credentials"] = credentials
176
+ return cls(*args, **kwargs)
177
+
178
+ @classmethod
179
+ def from_service_account_file(cls, filename: str, *args, **kwargs):
180
+ """Creates an instance of this client using the provided credentials
181
+ file.
182
+
183
+ Args:
184
+ filename (str): The path to the service account private key json
185
+ file.
186
+ args: Additional arguments to pass to the constructor.
187
+ kwargs: Additional arguments to pass to the constructor.
188
+
189
+ Returns:
190
+ TranscoderServiceClient: The constructed client.
191
+ """
192
+ credentials = service_account.Credentials.from_service_account_file(filename)
193
+ kwargs["credentials"] = credentials
194
+ return cls(*args, **kwargs)
195
+
196
+ from_service_account_json = from_service_account_file
197
+
198
+ @property
199
+ def transport(self) -> TranscoderServiceTransport:
200
+ """Returns the transport used by the client instance.
201
+
202
+ Returns:
203
+ TranscoderServiceTransport: The transport used by the client
204
+ instance.
205
+ """
206
+ return self._transport
207
+
208
+ @staticmethod
209
+ def job_path(
210
+ project: str,
211
+ location: str,
212
+ job: str,
213
+ ) -> str:
214
+ """Returns a fully-qualified job string."""
215
+ return "projects/{project}/locations/{location}/jobs/{job}".format(
216
+ project=project,
217
+ location=location,
218
+ job=job,
219
+ )
220
+
221
+ @staticmethod
222
+ def parse_job_path(path: str) -> Dict[str, str]:
223
+ """Parses a job path into its component segments."""
224
+ m = re.match(
225
+ r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/jobs/(?P<job>.+?)$",
226
+ path,
227
+ )
228
+ return m.groupdict() if m else {}
229
+
230
+ @staticmethod
231
+ def job_template_path(
232
+ project: str,
233
+ location: str,
234
+ job_template: str,
235
+ ) -> str:
236
+ """Returns a fully-qualified job_template string."""
237
+ return "projects/{project}/locations/{location}/jobTemplates/{job_template}".format(
238
+ project=project,
239
+ location=location,
240
+ job_template=job_template,
241
+ )
242
+
243
+ @staticmethod
244
+ def parse_job_template_path(path: str) -> Dict[str, str]:
245
+ """Parses a job_template path into its component segments."""
246
+ m = re.match(
247
+ r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/jobTemplates/(?P<job_template>.+?)$",
248
+ path,
249
+ )
250
+ return m.groupdict() if m else {}
251
+
252
+ @staticmethod
253
+ def common_billing_account_path(
254
+ billing_account: str,
255
+ ) -> str:
256
+ """Returns a fully-qualified billing_account string."""
257
+ return "billingAccounts/{billing_account}".format(
258
+ billing_account=billing_account,
259
+ )
260
+
261
+ @staticmethod
262
+ def parse_common_billing_account_path(path: str) -> Dict[str, str]:
263
+ """Parse a billing_account path into its component segments."""
264
+ m = re.match(r"^billingAccounts/(?P<billing_account>.+?)$", path)
265
+ return m.groupdict() if m else {}
266
+
267
+ @staticmethod
268
+ def common_folder_path(
269
+ folder: str,
270
+ ) -> str:
271
+ """Returns a fully-qualified folder string."""
272
+ return "folders/{folder}".format(
273
+ folder=folder,
274
+ )
275
+
276
+ @staticmethod
277
+ def parse_common_folder_path(path: str) -> Dict[str, str]:
278
+ """Parse a folder path into its component segments."""
279
+ m = re.match(r"^folders/(?P<folder>.+?)$", path)
280
+ return m.groupdict() if m else {}
281
+
282
+ @staticmethod
283
+ def common_organization_path(
284
+ organization: str,
285
+ ) -> str:
286
+ """Returns a fully-qualified organization string."""
287
+ return "organizations/{organization}".format(
288
+ organization=organization,
289
+ )
290
+
291
+ @staticmethod
292
+ def parse_common_organization_path(path: str) -> Dict[str, str]:
293
+ """Parse a organization path into its component segments."""
294
+ m = re.match(r"^organizations/(?P<organization>.+?)$", path)
295
+ return m.groupdict() if m else {}
296
+
297
+ @staticmethod
298
+ def common_project_path(
299
+ project: str,
300
+ ) -> str:
301
+ """Returns a fully-qualified project string."""
302
+ return "projects/{project}".format(
303
+ project=project,
304
+ )
305
+
306
+ @staticmethod
307
+ def parse_common_project_path(path: str) -> Dict[str, str]:
308
+ """Parse a project path into its component segments."""
309
+ m = re.match(r"^projects/(?P<project>.+?)$", path)
310
+ return m.groupdict() if m else {}
311
+
312
+ @staticmethod
313
+ def common_location_path(
314
+ project: str,
315
+ location: str,
316
+ ) -> str:
317
+ """Returns a fully-qualified location string."""
318
+ return "projects/{project}/locations/{location}".format(
319
+ project=project,
320
+ location=location,
321
+ )
322
+
323
+ @staticmethod
324
+ def parse_common_location_path(path: str) -> Dict[str, str]:
325
+ """Parse a location path into its component segments."""
326
+ m = re.match(r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)$", path)
327
+ return m.groupdict() if m else {}
328
+
329
+ @classmethod
330
+ def get_mtls_endpoint_and_cert_source(
331
+ cls, client_options: Optional[client_options_lib.ClientOptions] = None
332
+ ):
333
+ """Deprecated. Return the API endpoint and client cert source for mutual TLS.
334
+
335
+ The client cert source is determined in the following order:
336
+ (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the
337
+ client cert source is None.
338
+ (2) if `client_options.client_cert_source` is provided, use the provided one; if the
339
+ default client cert source exists, use the default one; otherwise the client cert
340
+ source is None.
341
+
342
+ The API endpoint is determined in the following order:
343
+ (1) if `client_options.api_endpoint` if provided, use the provided one.
344
+ (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the
345
+ default mTLS endpoint; if the environment variable is "never", use the default API
346
+ endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
347
+ use the default API endpoint.
348
+
349
+ More details can be found at https://google.aip.dev/auth/4114.
350
+
351
+ Args:
352
+ client_options (google.api_core.client_options.ClientOptions): Custom options for the
353
+ client. Only the `api_endpoint` and `client_cert_source` properties may be used
354
+ in this method.
355
+
356
+ Returns:
357
+ Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the
358
+ client cert source to use.
359
+
360
+ Raises:
361
+ google.auth.exceptions.MutualTLSChannelError: If any errors happen.
362
+ """
363
+
364
+ warnings.warn(
365
+ "get_mtls_endpoint_and_cert_source is deprecated. Use the api_endpoint property instead.",
366
+ DeprecationWarning,
367
+ )
368
+ if client_options is None:
369
+ client_options = client_options_lib.ClientOptions()
370
+ use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")
371
+ use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto")
372
+ if use_client_cert not in ("true", "false"):
373
+ raise ValueError(
374
+ "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
375
+ )
376
+ if use_mtls_endpoint not in ("auto", "never", "always"):
377
+ raise MutualTLSChannelError(
378
+ "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
379
+ )
380
+
381
+ # Figure out the client cert source to use.
382
+ client_cert_source = None
383
+ if use_client_cert == "true":
384
+ if client_options.client_cert_source:
385
+ client_cert_source = client_options.client_cert_source
386
+ elif mtls.has_default_client_cert_source():
387
+ client_cert_source = mtls.default_client_cert_source()
388
+
389
+ # Figure out which api endpoint to use.
390
+ if client_options.api_endpoint is not None:
391
+ api_endpoint = client_options.api_endpoint
392
+ elif use_mtls_endpoint == "always" or (
393
+ use_mtls_endpoint == "auto" and client_cert_source
394
+ ):
395
+ api_endpoint = cls.DEFAULT_MTLS_ENDPOINT
396
+ else:
397
+ api_endpoint = cls.DEFAULT_ENDPOINT
398
+
399
+ return api_endpoint, client_cert_source
400
+
401
+ @staticmethod
402
+ def _read_environment_variables():
403
+ """Returns the environment variables used by the client.
404
+
405
+ Returns:
406
+ Tuple[bool, str, str]: returns the GOOGLE_API_USE_CLIENT_CERTIFICATE,
407
+ GOOGLE_API_USE_MTLS_ENDPOINT, and GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variables.
408
+
409
+ Raises:
410
+ ValueError: If GOOGLE_API_USE_CLIENT_CERTIFICATE is not
411
+ any of ["true", "false"].
412
+ google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT
413
+ is not any of ["auto", "never", "always"].
414
+ """
415
+ use_client_cert = os.getenv(
416
+ "GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"
417
+ ).lower()
418
+ use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower()
419
+ universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN")
420
+ if use_client_cert not in ("true", "false"):
421
+ raise ValueError(
422
+ "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
423
+ )
424
+ if use_mtls_endpoint not in ("auto", "never", "always"):
425
+ raise MutualTLSChannelError(
426
+ "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
427
+ )
428
+ return use_client_cert == "true", use_mtls_endpoint, universe_domain_env
429
+
430
+ @staticmethod
431
+ def _get_client_cert_source(provided_cert_source, use_cert_flag):
432
+ """Return the client cert source to be used by the client.
433
+
434
+ Args:
435
+ provided_cert_source (bytes): The client certificate source provided.
436
+ use_cert_flag (bool): A flag indicating whether to use the client certificate.
437
+
438
+ Returns:
439
+ bytes or None: The client cert source to be used by the client.
440
+ """
441
+ client_cert_source = None
442
+ if use_cert_flag:
443
+ if provided_cert_source:
444
+ client_cert_source = provided_cert_source
445
+ elif mtls.has_default_client_cert_source():
446
+ client_cert_source = mtls.default_client_cert_source()
447
+ return client_cert_source
448
+
449
+ @staticmethod
450
+ def _get_api_endpoint(
451
+ api_override, client_cert_source, universe_domain, use_mtls_endpoint
452
+ ):
453
+ """Return the API endpoint used by the client.
454
+
455
+ Args:
456
+ api_override (str): The API endpoint override. If specified, this is always
457
+ the return value of this function and the other arguments are not used.
458
+ client_cert_source (bytes): The client certificate source used by the client.
459
+ universe_domain (str): The universe domain used by the client.
460
+ use_mtls_endpoint (str): How to use the mTLS endpoint, which depends also on the other parameters.
461
+ Possible values are "always", "auto", or "never".
462
+
463
+ Returns:
464
+ str: The API endpoint to be used by the client.
465
+ """
466
+ if api_override is not None:
467
+ api_endpoint = api_override
468
+ elif use_mtls_endpoint == "always" or (
469
+ use_mtls_endpoint == "auto" and client_cert_source
470
+ ):
471
+ _default_universe = TranscoderServiceClient._DEFAULT_UNIVERSE
472
+ if universe_domain != _default_universe:
473
+ raise MutualTLSChannelError(
474
+ f"mTLS is not supported in any universe other than {_default_universe}."
475
+ )
476
+ api_endpoint = TranscoderServiceClient.DEFAULT_MTLS_ENDPOINT
477
+ else:
478
+ api_endpoint = TranscoderServiceClient._DEFAULT_ENDPOINT_TEMPLATE.format(
479
+ UNIVERSE_DOMAIN=universe_domain
480
+ )
481
+ return api_endpoint
482
+
483
+ @staticmethod
484
+ def _get_universe_domain(
485
+ client_universe_domain: Optional[str], universe_domain_env: Optional[str]
486
+ ) -> str:
487
+ """Return the universe domain used by the client.
488
+
489
+ Args:
490
+ client_universe_domain (Optional[str]): The universe domain configured via the client options.
491
+ universe_domain_env (Optional[str]): The universe domain configured via the "GOOGLE_CLOUD_UNIVERSE_DOMAIN" environment variable.
492
+
493
+ Returns:
494
+ str: The universe domain to be used by the client.
495
+
496
+ Raises:
497
+ ValueError: If the universe domain is an empty string.
498
+ """
499
+ universe_domain = TranscoderServiceClient._DEFAULT_UNIVERSE
500
+ if client_universe_domain is not None:
501
+ universe_domain = client_universe_domain
502
+ elif universe_domain_env is not None:
503
+ universe_domain = universe_domain_env
504
+ if len(universe_domain.strip()) == 0:
505
+ raise ValueError("Universe Domain cannot be an empty string.")
506
+ return universe_domain
507
+
508
+ def _validate_universe_domain(self):
509
+ """Validates client's and credentials' universe domains are consistent.
510
+
511
+ Returns:
512
+ bool: True iff the configured universe domain is valid.
513
+
514
+ Raises:
515
+ ValueError: If the configured universe domain is not valid.
516
+ """
517
+
518
+ # NOTE (b/349488459): universe validation is disabled until further notice.
519
+ return True
520
+
521
+ def _add_cred_info_for_auth_errors(
522
+ self, error: core_exceptions.GoogleAPICallError
523
+ ) -> None:
524
+ """Adds credential info string to error details for 401/403/404 errors.
525
+
526
+ Args:
527
+ error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info.
528
+ """
529
+ if error.code not in [
530
+ HTTPStatus.UNAUTHORIZED,
531
+ HTTPStatus.FORBIDDEN,
532
+ HTTPStatus.NOT_FOUND,
533
+ ]:
534
+ return
535
+
536
+ cred = self._transport._credentials
537
+
538
+ # get_cred_info is only available in google-auth>=2.35.0
539
+ if not hasattr(cred, "get_cred_info"):
540
+ return
541
+
542
+ # ignore the type check since pypy test fails when get_cred_info
543
+ # is not available
544
+ cred_info = cred.get_cred_info() # type: ignore
545
+ if cred_info and hasattr(error._details, "append"):
546
+ error._details.append(json.dumps(cred_info))
547
+
548
+ @property
549
+ def api_endpoint(self):
550
+ """Return the API endpoint used by the client instance.
551
+
552
+ Returns:
553
+ str: The API endpoint used by the client instance.
554
+ """
555
+ return self._api_endpoint
556
+
557
+ @property
558
+ def universe_domain(self) -> str:
559
+ """Return the universe domain used by the client instance.
560
+
561
+ Returns:
562
+ str: The universe domain used by the client instance.
563
+ """
564
+ return self._universe_domain
565
+
566
+ def __init__(
567
+ self,
568
+ *,
569
+ credentials: Optional[ga_credentials.Credentials] = None,
570
+ transport: Optional[
571
+ Union[
572
+ str,
573
+ TranscoderServiceTransport,
574
+ Callable[..., TranscoderServiceTransport],
575
+ ]
576
+ ] = None,
577
+ client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,
578
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
579
+ ) -> None:
580
+ """Instantiates the transcoder service client.
581
+
582
+ Args:
583
+ credentials (Optional[google.auth.credentials.Credentials]): The
584
+ authorization credentials to attach to requests. These
585
+ credentials identify the application to the service; if none
586
+ are specified, the client will attempt to ascertain the
587
+ credentials from the environment.
588
+ transport (Optional[Union[str,TranscoderServiceTransport,Callable[..., TranscoderServiceTransport]]]):
589
+ The transport to use, or a Callable that constructs and returns a new transport.
590
+ If a Callable is given, it will be called with the same set of initialization
591
+ arguments as used in the TranscoderServiceTransport constructor.
592
+ If set to None, a transport is chosen automatically.
593
+ client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
594
+ Custom options for the client.
595
+
596
+ 1. The ``api_endpoint`` property can be used to override the
597
+ default endpoint provided by the client when ``transport`` is
598
+ not explicitly provided. Only if this property is not set and
599
+ ``transport`` was not explicitly provided, the endpoint is
600
+ determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
601
+ variable, which have one of the following values:
602
+ "always" (always use the default mTLS endpoint), "never" (always
603
+ use the default regular endpoint) and "auto" (auto-switch to the
604
+ default mTLS endpoint if client certificate is present; this is
605
+ the default value).
606
+
607
+ 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
608
+ is "true", then the ``client_cert_source`` property can be used
609
+ to provide a client certificate for mTLS transport. If
610
+ not provided, the default SSL client certificate will be used if
611
+ present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
612
+ set, no client certificate will be used.
613
+
614
+ 3. The ``universe_domain`` property can be used to override the
615
+ default "googleapis.com" universe. Note that the ``api_endpoint``
616
+ property still takes precedence; and ``universe_domain`` is
617
+ currently not supported for mTLS.
618
+
619
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
620
+ The client info used to send a user-agent string along with
621
+ API requests. If ``None``, then default info will be used.
622
+ Generally, you only need to set this if you're developing
623
+ your own client library.
624
+
625
+ Raises:
626
+ google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
627
+ creation failed for any reason.
628
+ """
629
+ self._client_options = client_options
630
+ if isinstance(self._client_options, dict):
631
+ self._client_options = client_options_lib.from_dict(self._client_options)
632
+ if self._client_options is None:
633
+ self._client_options = client_options_lib.ClientOptions()
634
+ self._client_options = cast(
635
+ client_options_lib.ClientOptions, self._client_options
636
+ )
637
+
638
+ universe_domain_opt = getattr(self._client_options, "universe_domain", None)
639
+
640
+ (
641
+ self._use_client_cert,
642
+ self._use_mtls_endpoint,
643
+ self._universe_domain_env,
644
+ ) = TranscoderServiceClient._read_environment_variables()
645
+ self._client_cert_source = TranscoderServiceClient._get_client_cert_source(
646
+ self._client_options.client_cert_source, self._use_client_cert
647
+ )
648
+ self._universe_domain = TranscoderServiceClient._get_universe_domain(
649
+ universe_domain_opt, self._universe_domain_env
650
+ )
651
+ self._api_endpoint = None # updated below, depending on `transport`
652
+
653
+ # Initialize the universe domain validation.
654
+ self._is_universe_domain_valid = False
655
+
656
+ if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER
657
+ # Setup logging.
658
+ client_logging.initialize_logging()
659
+
660
+ api_key_value = getattr(self._client_options, "api_key", None)
661
+ if api_key_value and credentials:
662
+ raise ValueError(
663
+ "client_options.api_key and credentials are mutually exclusive"
664
+ )
665
+
666
+ # Save or instantiate the transport.
667
+ # Ordinarily, we provide the transport, but allowing a custom transport
668
+ # instance provides an extensibility point for unusual situations.
669
+ transport_provided = isinstance(transport, TranscoderServiceTransport)
670
+ if transport_provided:
671
+ # transport is a TranscoderServiceTransport instance.
672
+ if credentials or self._client_options.credentials_file or api_key_value:
673
+ raise ValueError(
674
+ "When providing a transport instance, "
675
+ "provide its credentials directly."
676
+ )
677
+ if self._client_options.scopes:
678
+ raise ValueError(
679
+ "When providing a transport instance, provide its scopes "
680
+ "directly."
681
+ )
682
+ self._transport = cast(TranscoderServiceTransport, transport)
683
+ self._api_endpoint = self._transport.host
684
+
685
+ self._api_endpoint = (
686
+ self._api_endpoint
687
+ or TranscoderServiceClient._get_api_endpoint(
688
+ self._client_options.api_endpoint,
689
+ self._client_cert_source,
690
+ self._universe_domain,
691
+ self._use_mtls_endpoint,
692
+ )
693
+ )
694
+
695
+ if not transport_provided:
696
+ import google.auth._default # type: ignore
697
+
698
+ if api_key_value and hasattr(
699
+ google.auth._default, "get_api_key_credentials"
700
+ ):
701
+ credentials = google.auth._default.get_api_key_credentials(
702
+ api_key_value
703
+ )
704
+
705
+ transport_init: Union[
706
+ Type[TranscoderServiceTransport],
707
+ Callable[..., TranscoderServiceTransport],
708
+ ] = (
709
+ TranscoderServiceClient.get_transport_class(transport)
710
+ if isinstance(transport, str) or transport is None
711
+ else cast(Callable[..., TranscoderServiceTransport], transport)
712
+ )
713
+ # initialize with the provided callable or the passed in class
714
+ self._transport = transport_init(
715
+ credentials=credentials,
716
+ credentials_file=self._client_options.credentials_file,
717
+ host=self._api_endpoint,
718
+ scopes=self._client_options.scopes,
719
+ client_cert_source_for_mtls=self._client_cert_source,
720
+ quota_project_id=self._client_options.quota_project_id,
721
+ client_info=client_info,
722
+ always_use_jwt_access=True,
723
+ api_audience=self._client_options.api_audience,
724
+ )
725
+
726
+ if "async" not in str(self._transport):
727
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
728
+ std_logging.DEBUG
729
+ ): # pragma: NO COVER
730
+ _LOGGER.debug(
731
+ "Created client `google.cloud.video.transcoder_v1.TranscoderServiceClient`.",
732
+ extra={
733
+ "serviceName": "google.cloud.video.transcoder.v1.TranscoderService",
734
+ "universeDomain": getattr(
735
+ self._transport._credentials, "universe_domain", ""
736
+ ),
737
+ "credentialsType": f"{type(self._transport._credentials).__module__}.{type(self._transport._credentials).__qualname__}",
738
+ "credentialsInfo": getattr(
739
+ self.transport._credentials, "get_cred_info", lambda: None
740
+ )(),
741
+ }
742
+ if hasattr(self._transport, "_credentials")
743
+ else {
744
+ "serviceName": "google.cloud.video.transcoder.v1.TranscoderService",
745
+ "credentialsType": None,
746
+ },
747
+ )
748
+
749
+ def create_job(
750
+ self,
751
+ request: Optional[Union[services.CreateJobRequest, dict]] = None,
752
+ *,
753
+ parent: Optional[str] = None,
754
+ job: Optional[resources.Job] = None,
755
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
756
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
757
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
758
+ ) -> resources.Job:
759
+ r"""Creates a job in the specified region.
760
+
761
+ .. code-block:: python
762
+
763
+ # This snippet has been automatically generated and should be regarded as a
764
+ # code template only.
765
+ # It will require modifications to work:
766
+ # - It may require correct/in-range values for request initialization.
767
+ # - It may require specifying regional endpoints when creating the service
768
+ # client as shown in:
769
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
770
+ from google.cloud.video import transcoder_v1
771
+
772
+ def sample_create_job():
773
+ # Create a client
774
+ client = transcoder_v1.TranscoderServiceClient()
775
+
776
+ # Initialize request argument(s)
777
+ job = transcoder_v1.Job()
778
+ job.template_id = "template_id_value"
779
+
780
+ request = transcoder_v1.CreateJobRequest(
781
+ parent="parent_value",
782
+ job=job,
783
+ )
784
+
785
+ # Make the request
786
+ response = client.create_job(request=request)
787
+
788
+ # Handle the response
789
+ print(response)
790
+
791
+ Args:
792
+ request (Union[google.cloud.video.transcoder_v1.types.CreateJobRequest, dict]):
793
+ The request object. Request message for ``TranscoderService.CreateJob``.
794
+ parent (str):
795
+ Required. The parent location to create and process this
796
+ job. Format: ``projects/{project}/locations/{location}``
797
+
798
+ This corresponds to the ``parent`` field
799
+ on the ``request`` instance; if ``request`` is provided, this
800
+ should not be set.
801
+ job (google.cloud.video.transcoder_v1.types.Job):
802
+ Required. Parameters for creating
803
+ transcoding job.
804
+
805
+ This corresponds to the ``job`` field
806
+ on the ``request`` instance; if ``request`` is provided, this
807
+ should not be set.
808
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
809
+ should be retried.
810
+ timeout (float): The timeout for this request.
811
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
812
+ sent along with the request as metadata. Normally, each value must be of type `str`,
813
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
814
+ be of type `bytes`.
815
+
816
+ Returns:
817
+ google.cloud.video.transcoder_v1.types.Job:
818
+ Transcoding job resource.
819
+ """
820
+ # Create or coerce a protobuf request object.
821
+ # - Quick check: If we got a request object, we should *not* have
822
+ # gotten any keyword arguments that map to the request.
823
+ flattened_params = [parent, job]
824
+ has_flattened_params = (
825
+ len([param for param in flattened_params if param is not None]) > 0
826
+ )
827
+ if request is not None and has_flattened_params:
828
+ raise ValueError(
829
+ "If the `request` argument is set, then none of "
830
+ "the individual field arguments should be set."
831
+ )
832
+
833
+ # - Use the request object if provided (there's no risk of modifying the input as
834
+ # there are no flattened fields), or create one.
835
+ if not isinstance(request, services.CreateJobRequest):
836
+ request = services.CreateJobRequest(request)
837
+ # If we have keyword arguments corresponding to fields on the
838
+ # request, apply these.
839
+ if parent is not None:
840
+ request.parent = parent
841
+ if job is not None:
842
+ request.job = job
843
+
844
+ # Wrap the RPC method; this adds retry and timeout information,
845
+ # and friendly error handling.
846
+ rpc = self._transport._wrapped_methods[self._transport.create_job]
847
+
848
+ # Certain fields should be provided within the metadata header;
849
+ # add these here.
850
+ metadata = tuple(metadata) + (
851
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
852
+ )
853
+
854
+ # Validate the universe domain.
855
+ self._validate_universe_domain()
856
+
857
+ # Send the request.
858
+ response = rpc(
859
+ request,
860
+ retry=retry,
861
+ timeout=timeout,
862
+ metadata=metadata,
863
+ )
864
+
865
+ # Done; return the response.
866
+ return response
867
+
868
+ def list_jobs(
869
+ self,
870
+ request: Optional[Union[services.ListJobsRequest, dict]] = None,
871
+ *,
872
+ parent: Optional[str] = None,
873
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
874
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
875
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
876
+ ) -> pagers.ListJobsPager:
877
+ r"""Lists jobs in the specified region.
878
+
879
+ .. code-block:: python
880
+
881
+ # This snippet has been automatically generated and should be regarded as a
882
+ # code template only.
883
+ # It will require modifications to work:
884
+ # - It may require correct/in-range values for request initialization.
885
+ # - It may require specifying regional endpoints when creating the service
886
+ # client as shown in:
887
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
888
+ from google.cloud.video import transcoder_v1
889
+
890
+ def sample_list_jobs():
891
+ # Create a client
892
+ client = transcoder_v1.TranscoderServiceClient()
893
+
894
+ # Initialize request argument(s)
895
+ request = transcoder_v1.ListJobsRequest(
896
+ parent="parent_value",
897
+ )
898
+
899
+ # Make the request
900
+ page_result = client.list_jobs(request=request)
901
+
902
+ # Handle the response
903
+ for response in page_result:
904
+ print(response)
905
+
906
+ Args:
907
+ request (Union[google.cloud.video.transcoder_v1.types.ListJobsRequest, dict]):
908
+ The request object. Request message for ``TranscoderService.ListJobs``. The
909
+ parent location from which to retrieve the collection of
910
+ jobs.
911
+ parent (str):
912
+ Required. Format:
913
+ ``projects/{project}/locations/{location}``
914
+
915
+ This corresponds to the ``parent`` field
916
+ on the ``request`` instance; if ``request`` is provided, this
917
+ should not be set.
918
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
919
+ should be retried.
920
+ timeout (float): The timeout for this request.
921
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
922
+ sent along with the request as metadata. Normally, each value must be of type `str`,
923
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
924
+ be of type `bytes`.
925
+
926
+ Returns:
927
+ google.cloud.video.transcoder_v1.services.transcoder_service.pagers.ListJobsPager:
928
+ Response message for TranscoderService.ListJobs.
929
+
930
+ Iterating over this object will yield results and
931
+ resolve additional pages automatically.
932
+
933
+ """
934
+ # Create or coerce a protobuf request object.
935
+ # - Quick check: If we got a request object, we should *not* have
936
+ # gotten any keyword arguments that map to the request.
937
+ flattened_params = [parent]
938
+ has_flattened_params = (
939
+ len([param for param in flattened_params if param is not None]) > 0
940
+ )
941
+ if request is not None and has_flattened_params:
942
+ raise ValueError(
943
+ "If the `request` argument is set, then none of "
944
+ "the individual field arguments should be set."
945
+ )
946
+
947
+ # - Use the request object if provided (there's no risk of modifying the input as
948
+ # there are no flattened fields), or create one.
949
+ if not isinstance(request, services.ListJobsRequest):
950
+ request = services.ListJobsRequest(request)
951
+ # If we have keyword arguments corresponding to fields on the
952
+ # request, apply these.
953
+ if parent is not None:
954
+ request.parent = parent
955
+
956
+ # Wrap the RPC method; this adds retry and timeout information,
957
+ # and friendly error handling.
958
+ rpc = self._transport._wrapped_methods[self._transport.list_jobs]
959
+
960
+ # Certain fields should be provided within the metadata header;
961
+ # add these here.
962
+ metadata = tuple(metadata) + (
963
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
964
+ )
965
+
966
+ # Validate the universe domain.
967
+ self._validate_universe_domain()
968
+
969
+ # Send the request.
970
+ response = rpc(
971
+ request,
972
+ retry=retry,
973
+ timeout=timeout,
974
+ metadata=metadata,
975
+ )
976
+
977
+ # This method is paged; wrap the response in a pager, which provides
978
+ # an `__iter__` convenience method.
979
+ response = pagers.ListJobsPager(
980
+ method=rpc,
981
+ request=request,
982
+ response=response,
983
+ retry=retry,
984
+ timeout=timeout,
985
+ metadata=metadata,
986
+ )
987
+
988
+ # Done; return the response.
989
+ return response
990
+
991
+ def get_job(
992
+ self,
993
+ request: Optional[Union[services.GetJobRequest, dict]] = None,
994
+ *,
995
+ name: Optional[str] = None,
996
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
997
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
998
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
999
+ ) -> resources.Job:
1000
+ r"""Returns the job data.
1001
+
1002
+ .. code-block:: python
1003
+
1004
+ # This snippet has been automatically generated and should be regarded as a
1005
+ # code template only.
1006
+ # It will require modifications to work:
1007
+ # - It may require correct/in-range values for request initialization.
1008
+ # - It may require specifying regional endpoints when creating the service
1009
+ # client as shown in:
1010
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1011
+ from google.cloud.video import transcoder_v1
1012
+
1013
+ def sample_get_job():
1014
+ # Create a client
1015
+ client = transcoder_v1.TranscoderServiceClient()
1016
+
1017
+ # Initialize request argument(s)
1018
+ request = transcoder_v1.GetJobRequest(
1019
+ name="name_value",
1020
+ )
1021
+
1022
+ # Make the request
1023
+ response = client.get_job(request=request)
1024
+
1025
+ # Handle the response
1026
+ print(response)
1027
+
1028
+ Args:
1029
+ request (Union[google.cloud.video.transcoder_v1.types.GetJobRequest, dict]):
1030
+ The request object. Request message for ``TranscoderService.GetJob``.
1031
+ name (str):
1032
+ Required. The name of the job to retrieve. Format:
1033
+ ``projects/{project}/locations/{location}/jobs/{job}``
1034
+
1035
+ This corresponds to the ``name`` field
1036
+ on the ``request`` instance; if ``request`` is provided, this
1037
+ should not be set.
1038
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1039
+ should be retried.
1040
+ timeout (float): The timeout for this request.
1041
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1042
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1043
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1044
+ be of type `bytes`.
1045
+
1046
+ Returns:
1047
+ google.cloud.video.transcoder_v1.types.Job:
1048
+ Transcoding job resource.
1049
+ """
1050
+ # Create or coerce a protobuf request object.
1051
+ # - Quick check: If we got a request object, we should *not* have
1052
+ # gotten any keyword arguments that map to the request.
1053
+ flattened_params = [name]
1054
+ has_flattened_params = (
1055
+ len([param for param in flattened_params if param is not None]) > 0
1056
+ )
1057
+ if request is not None and has_flattened_params:
1058
+ raise ValueError(
1059
+ "If the `request` argument is set, then none of "
1060
+ "the individual field arguments should be set."
1061
+ )
1062
+
1063
+ # - Use the request object if provided (there's no risk of modifying the input as
1064
+ # there are no flattened fields), or create one.
1065
+ if not isinstance(request, services.GetJobRequest):
1066
+ request = services.GetJobRequest(request)
1067
+ # If we have keyword arguments corresponding to fields on the
1068
+ # request, apply these.
1069
+ if name is not None:
1070
+ request.name = name
1071
+
1072
+ # Wrap the RPC method; this adds retry and timeout information,
1073
+ # and friendly error handling.
1074
+ rpc = self._transport._wrapped_methods[self._transport.get_job]
1075
+
1076
+ # Certain fields should be provided within the metadata header;
1077
+ # add these here.
1078
+ metadata = tuple(metadata) + (
1079
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1080
+ )
1081
+
1082
+ # Validate the universe domain.
1083
+ self._validate_universe_domain()
1084
+
1085
+ # Send the request.
1086
+ response = rpc(
1087
+ request,
1088
+ retry=retry,
1089
+ timeout=timeout,
1090
+ metadata=metadata,
1091
+ )
1092
+
1093
+ # Done; return the response.
1094
+ return response
1095
+
1096
+ def delete_job(
1097
+ self,
1098
+ request: Optional[Union[services.DeleteJobRequest, dict]] = None,
1099
+ *,
1100
+ name: Optional[str] = None,
1101
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1102
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1103
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1104
+ ) -> None:
1105
+ r"""Deletes a job.
1106
+
1107
+ .. code-block:: python
1108
+
1109
+ # This snippet has been automatically generated and should be regarded as a
1110
+ # code template only.
1111
+ # It will require modifications to work:
1112
+ # - It may require correct/in-range values for request initialization.
1113
+ # - It may require specifying regional endpoints when creating the service
1114
+ # client as shown in:
1115
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1116
+ from google.cloud.video import transcoder_v1
1117
+
1118
+ def sample_delete_job():
1119
+ # Create a client
1120
+ client = transcoder_v1.TranscoderServiceClient()
1121
+
1122
+ # Initialize request argument(s)
1123
+ request = transcoder_v1.DeleteJobRequest(
1124
+ name="name_value",
1125
+ )
1126
+
1127
+ # Make the request
1128
+ client.delete_job(request=request)
1129
+
1130
+ Args:
1131
+ request (Union[google.cloud.video.transcoder_v1.types.DeleteJobRequest, dict]):
1132
+ The request object. Request message for ``TranscoderService.DeleteJob``.
1133
+ name (str):
1134
+ Required. The name of the job to delete. Format:
1135
+ ``projects/{project}/locations/{location}/jobs/{job}``
1136
+
1137
+ This corresponds to the ``name`` field
1138
+ on the ``request`` instance; if ``request`` is provided, this
1139
+ should not be set.
1140
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1141
+ should be retried.
1142
+ timeout (float): The timeout for this request.
1143
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1144
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1145
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1146
+ be of type `bytes`.
1147
+ """
1148
+ # Create or coerce a protobuf request object.
1149
+ # - Quick check: If we got a request object, we should *not* have
1150
+ # gotten any keyword arguments that map to the request.
1151
+ flattened_params = [name]
1152
+ has_flattened_params = (
1153
+ len([param for param in flattened_params if param is not None]) > 0
1154
+ )
1155
+ if request is not None and has_flattened_params:
1156
+ raise ValueError(
1157
+ "If the `request` argument is set, then none of "
1158
+ "the individual field arguments should be set."
1159
+ )
1160
+
1161
+ # - Use the request object if provided (there's no risk of modifying the input as
1162
+ # there are no flattened fields), or create one.
1163
+ if not isinstance(request, services.DeleteJobRequest):
1164
+ request = services.DeleteJobRequest(request)
1165
+ # If we have keyword arguments corresponding to fields on the
1166
+ # request, apply these.
1167
+ if name is not None:
1168
+ request.name = name
1169
+
1170
+ # Wrap the RPC method; this adds retry and timeout information,
1171
+ # and friendly error handling.
1172
+ rpc = self._transport._wrapped_methods[self._transport.delete_job]
1173
+
1174
+ # Certain fields should be provided within the metadata header;
1175
+ # add these here.
1176
+ metadata = tuple(metadata) + (
1177
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1178
+ )
1179
+
1180
+ # Validate the universe domain.
1181
+ self._validate_universe_domain()
1182
+
1183
+ # Send the request.
1184
+ rpc(
1185
+ request,
1186
+ retry=retry,
1187
+ timeout=timeout,
1188
+ metadata=metadata,
1189
+ )
1190
+
1191
+ def create_job_template(
1192
+ self,
1193
+ request: Optional[Union[services.CreateJobTemplateRequest, dict]] = None,
1194
+ *,
1195
+ parent: Optional[str] = None,
1196
+ job_template: Optional[resources.JobTemplate] = None,
1197
+ job_template_id: Optional[str] = None,
1198
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1199
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1200
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1201
+ ) -> resources.JobTemplate:
1202
+ r"""Creates a job template in the specified region.
1203
+
1204
+ .. code-block:: python
1205
+
1206
+ # This snippet has been automatically generated and should be regarded as a
1207
+ # code template only.
1208
+ # It will require modifications to work:
1209
+ # - It may require correct/in-range values for request initialization.
1210
+ # - It may require specifying regional endpoints when creating the service
1211
+ # client as shown in:
1212
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1213
+ from google.cloud.video import transcoder_v1
1214
+
1215
+ def sample_create_job_template():
1216
+ # Create a client
1217
+ client = transcoder_v1.TranscoderServiceClient()
1218
+
1219
+ # Initialize request argument(s)
1220
+ request = transcoder_v1.CreateJobTemplateRequest(
1221
+ parent="parent_value",
1222
+ job_template_id="job_template_id_value",
1223
+ )
1224
+
1225
+ # Make the request
1226
+ response = client.create_job_template(request=request)
1227
+
1228
+ # Handle the response
1229
+ print(response)
1230
+
1231
+ Args:
1232
+ request (Union[google.cloud.video.transcoder_v1.types.CreateJobTemplateRequest, dict]):
1233
+ The request object. Request message for
1234
+ ``TranscoderService.CreateJobTemplate``.
1235
+ parent (str):
1236
+ Required. The parent location to create this job
1237
+ template. Format:
1238
+ ``projects/{project}/locations/{location}``
1239
+
1240
+ This corresponds to the ``parent`` field
1241
+ on the ``request`` instance; if ``request`` is provided, this
1242
+ should not be set.
1243
+ job_template (google.cloud.video.transcoder_v1.types.JobTemplate):
1244
+ Required. Parameters for creating job
1245
+ template.
1246
+
1247
+ This corresponds to the ``job_template`` field
1248
+ on the ``request`` instance; if ``request`` is provided, this
1249
+ should not be set.
1250
+ job_template_id (str):
1251
+ Required. The ID to use for the job template, which will
1252
+ become the final component of the job template's
1253
+ resource name.
1254
+
1255
+ This value should be 4-63 characters, and valid
1256
+ characters must match the regular expression
1257
+ ``[a-zA-Z][a-zA-Z0-9_-]*``.
1258
+
1259
+ This corresponds to the ``job_template_id`` field
1260
+ on the ``request`` instance; if ``request`` is provided, this
1261
+ should not be set.
1262
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1263
+ should be retried.
1264
+ timeout (float): The timeout for this request.
1265
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1266
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1267
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1268
+ be of type `bytes`.
1269
+
1270
+ Returns:
1271
+ google.cloud.video.transcoder_v1.types.JobTemplate:
1272
+ Transcoding job template resource.
1273
+ """
1274
+ # Create or coerce a protobuf request object.
1275
+ # - Quick check: If we got a request object, we should *not* have
1276
+ # gotten any keyword arguments that map to the request.
1277
+ flattened_params = [parent, job_template, job_template_id]
1278
+ has_flattened_params = (
1279
+ len([param for param in flattened_params if param is not None]) > 0
1280
+ )
1281
+ if request is not None and has_flattened_params:
1282
+ raise ValueError(
1283
+ "If the `request` argument is set, then none of "
1284
+ "the individual field arguments should be set."
1285
+ )
1286
+
1287
+ # - Use the request object if provided (there's no risk of modifying the input as
1288
+ # there are no flattened fields), or create one.
1289
+ if not isinstance(request, services.CreateJobTemplateRequest):
1290
+ request = services.CreateJobTemplateRequest(request)
1291
+ # If we have keyword arguments corresponding to fields on the
1292
+ # request, apply these.
1293
+ if parent is not None:
1294
+ request.parent = parent
1295
+ if job_template is not None:
1296
+ request.job_template = job_template
1297
+ if job_template_id is not None:
1298
+ request.job_template_id = job_template_id
1299
+
1300
+ # Wrap the RPC method; this adds retry and timeout information,
1301
+ # and friendly error handling.
1302
+ rpc = self._transport._wrapped_methods[self._transport.create_job_template]
1303
+
1304
+ # Certain fields should be provided within the metadata header;
1305
+ # add these here.
1306
+ metadata = tuple(metadata) + (
1307
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
1308
+ )
1309
+
1310
+ # Validate the universe domain.
1311
+ self._validate_universe_domain()
1312
+
1313
+ # Send the request.
1314
+ response = rpc(
1315
+ request,
1316
+ retry=retry,
1317
+ timeout=timeout,
1318
+ metadata=metadata,
1319
+ )
1320
+
1321
+ # Done; return the response.
1322
+ return response
1323
+
1324
+ def list_job_templates(
1325
+ self,
1326
+ request: Optional[Union[services.ListJobTemplatesRequest, dict]] = None,
1327
+ *,
1328
+ parent: Optional[str] = None,
1329
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1330
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1331
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1332
+ ) -> pagers.ListJobTemplatesPager:
1333
+ r"""Lists job templates in the specified region.
1334
+
1335
+ .. code-block:: python
1336
+
1337
+ # This snippet has been automatically generated and should be regarded as a
1338
+ # code template only.
1339
+ # It will require modifications to work:
1340
+ # - It may require correct/in-range values for request initialization.
1341
+ # - It may require specifying regional endpoints when creating the service
1342
+ # client as shown in:
1343
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1344
+ from google.cloud.video import transcoder_v1
1345
+
1346
+ def sample_list_job_templates():
1347
+ # Create a client
1348
+ client = transcoder_v1.TranscoderServiceClient()
1349
+
1350
+ # Initialize request argument(s)
1351
+ request = transcoder_v1.ListJobTemplatesRequest(
1352
+ parent="parent_value",
1353
+ )
1354
+
1355
+ # Make the request
1356
+ page_result = client.list_job_templates(request=request)
1357
+
1358
+ # Handle the response
1359
+ for response in page_result:
1360
+ print(response)
1361
+
1362
+ Args:
1363
+ request (Union[google.cloud.video.transcoder_v1.types.ListJobTemplatesRequest, dict]):
1364
+ The request object. Request message for
1365
+ ``TranscoderService.ListJobTemplates``.
1366
+ parent (str):
1367
+ Required. The parent location from which to retrieve the
1368
+ collection of job templates. Format:
1369
+ ``projects/{project}/locations/{location}``
1370
+
1371
+ This corresponds to the ``parent`` field
1372
+ on the ``request`` instance; if ``request`` is provided, this
1373
+ should not be set.
1374
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1375
+ should be retried.
1376
+ timeout (float): The timeout for this request.
1377
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1378
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1379
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1380
+ be of type `bytes`.
1381
+
1382
+ Returns:
1383
+ google.cloud.video.transcoder_v1.services.transcoder_service.pagers.ListJobTemplatesPager:
1384
+ Response message for TranscoderService.ListJobTemplates.
1385
+
1386
+ Iterating over this object will yield results and
1387
+ resolve additional pages automatically.
1388
+
1389
+ """
1390
+ # Create or coerce a protobuf request object.
1391
+ # - Quick check: If we got a request object, we should *not* have
1392
+ # gotten any keyword arguments that map to the request.
1393
+ flattened_params = [parent]
1394
+ has_flattened_params = (
1395
+ len([param for param in flattened_params if param is not None]) > 0
1396
+ )
1397
+ if request is not None and has_flattened_params:
1398
+ raise ValueError(
1399
+ "If the `request` argument is set, then none of "
1400
+ "the individual field arguments should be set."
1401
+ )
1402
+
1403
+ # - Use the request object if provided (there's no risk of modifying the input as
1404
+ # there are no flattened fields), or create one.
1405
+ if not isinstance(request, services.ListJobTemplatesRequest):
1406
+ request = services.ListJobTemplatesRequest(request)
1407
+ # If we have keyword arguments corresponding to fields on the
1408
+ # request, apply these.
1409
+ if parent is not None:
1410
+ request.parent = parent
1411
+
1412
+ # Wrap the RPC method; this adds retry and timeout information,
1413
+ # and friendly error handling.
1414
+ rpc = self._transport._wrapped_methods[self._transport.list_job_templates]
1415
+
1416
+ # Certain fields should be provided within the metadata header;
1417
+ # add these here.
1418
+ metadata = tuple(metadata) + (
1419
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
1420
+ )
1421
+
1422
+ # Validate the universe domain.
1423
+ self._validate_universe_domain()
1424
+
1425
+ # Send the request.
1426
+ response = rpc(
1427
+ request,
1428
+ retry=retry,
1429
+ timeout=timeout,
1430
+ metadata=metadata,
1431
+ )
1432
+
1433
+ # This method is paged; wrap the response in a pager, which provides
1434
+ # an `__iter__` convenience method.
1435
+ response = pagers.ListJobTemplatesPager(
1436
+ method=rpc,
1437
+ request=request,
1438
+ response=response,
1439
+ retry=retry,
1440
+ timeout=timeout,
1441
+ metadata=metadata,
1442
+ )
1443
+
1444
+ # Done; return the response.
1445
+ return response
1446
+
1447
+ def get_job_template(
1448
+ self,
1449
+ request: Optional[Union[services.GetJobTemplateRequest, dict]] = None,
1450
+ *,
1451
+ name: Optional[str] = None,
1452
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1453
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1454
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1455
+ ) -> resources.JobTemplate:
1456
+ r"""Returns the job template data.
1457
+
1458
+ .. code-block:: python
1459
+
1460
+ # This snippet has been automatically generated and should be regarded as a
1461
+ # code template only.
1462
+ # It will require modifications to work:
1463
+ # - It may require correct/in-range values for request initialization.
1464
+ # - It may require specifying regional endpoints when creating the service
1465
+ # client as shown in:
1466
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1467
+ from google.cloud.video import transcoder_v1
1468
+
1469
+ def sample_get_job_template():
1470
+ # Create a client
1471
+ client = transcoder_v1.TranscoderServiceClient()
1472
+
1473
+ # Initialize request argument(s)
1474
+ request = transcoder_v1.GetJobTemplateRequest(
1475
+ name="name_value",
1476
+ )
1477
+
1478
+ # Make the request
1479
+ response = client.get_job_template(request=request)
1480
+
1481
+ # Handle the response
1482
+ print(response)
1483
+
1484
+ Args:
1485
+ request (Union[google.cloud.video.transcoder_v1.types.GetJobTemplateRequest, dict]):
1486
+ The request object. Request message for
1487
+ ``TranscoderService.GetJobTemplate``.
1488
+ name (str):
1489
+ Required. The name of the job template to retrieve.
1490
+ Format:
1491
+ ``projects/{project}/locations/{location}/jobTemplates/{job_template}``
1492
+
1493
+ This corresponds to the ``name`` field
1494
+ on the ``request`` instance; if ``request`` is provided, this
1495
+ should not be set.
1496
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1497
+ should be retried.
1498
+ timeout (float): The timeout for this request.
1499
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1500
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1501
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1502
+ be of type `bytes`.
1503
+
1504
+ Returns:
1505
+ google.cloud.video.transcoder_v1.types.JobTemplate:
1506
+ Transcoding job template resource.
1507
+ """
1508
+ # Create or coerce a protobuf request object.
1509
+ # - Quick check: If we got a request object, we should *not* have
1510
+ # gotten any keyword arguments that map to the request.
1511
+ flattened_params = [name]
1512
+ has_flattened_params = (
1513
+ len([param for param in flattened_params if param is not None]) > 0
1514
+ )
1515
+ if request is not None and has_flattened_params:
1516
+ raise ValueError(
1517
+ "If the `request` argument is set, then none of "
1518
+ "the individual field arguments should be set."
1519
+ )
1520
+
1521
+ # - Use the request object if provided (there's no risk of modifying the input as
1522
+ # there are no flattened fields), or create one.
1523
+ if not isinstance(request, services.GetJobTemplateRequest):
1524
+ request = services.GetJobTemplateRequest(request)
1525
+ # If we have keyword arguments corresponding to fields on the
1526
+ # request, apply these.
1527
+ if name is not None:
1528
+ request.name = name
1529
+
1530
+ # Wrap the RPC method; this adds retry and timeout information,
1531
+ # and friendly error handling.
1532
+ rpc = self._transport._wrapped_methods[self._transport.get_job_template]
1533
+
1534
+ # Certain fields should be provided within the metadata header;
1535
+ # add these here.
1536
+ metadata = tuple(metadata) + (
1537
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1538
+ )
1539
+
1540
+ # Validate the universe domain.
1541
+ self._validate_universe_domain()
1542
+
1543
+ # Send the request.
1544
+ response = rpc(
1545
+ request,
1546
+ retry=retry,
1547
+ timeout=timeout,
1548
+ metadata=metadata,
1549
+ )
1550
+
1551
+ # Done; return the response.
1552
+ return response
1553
+
1554
+ def delete_job_template(
1555
+ self,
1556
+ request: Optional[Union[services.DeleteJobTemplateRequest, dict]] = None,
1557
+ *,
1558
+ name: Optional[str] = None,
1559
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1560
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1561
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1562
+ ) -> None:
1563
+ r"""Deletes a job template.
1564
+
1565
+ .. code-block:: python
1566
+
1567
+ # This snippet has been automatically generated and should be regarded as a
1568
+ # code template only.
1569
+ # It will require modifications to work:
1570
+ # - It may require correct/in-range values for request initialization.
1571
+ # - It may require specifying regional endpoints when creating the service
1572
+ # client as shown in:
1573
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
1574
+ from google.cloud.video import transcoder_v1
1575
+
1576
+ def sample_delete_job_template():
1577
+ # Create a client
1578
+ client = transcoder_v1.TranscoderServiceClient()
1579
+
1580
+ # Initialize request argument(s)
1581
+ request = transcoder_v1.DeleteJobTemplateRequest(
1582
+ name="name_value",
1583
+ )
1584
+
1585
+ # Make the request
1586
+ client.delete_job_template(request=request)
1587
+
1588
+ Args:
1589
+ request (Union[google.cloud.video.transcoder_v1.types.DeleteJobTemplateRequest, dict]):
1590
+ The request object. Request message for
1591
+ ``TranscoderService.DeleteJobTemplate``.
1592
+ name (str):
1593
+ Required. The name of the job template to delete.
1594
+ ``projects/{project}/locations/{location}/jobTemplates/{job_template}``
1595
+
1596
+ This corresponds to the ``name`` field
1597
+ on the ``request`` instance; if ``request`` is provided, this
1598
+ should not be set.
1599
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1600
+ should be retried.
1601
+ timeout (float): The timeout for this request.
1602
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1603
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1604
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1605
+ be of type `bytes`.
1606
+ """
1607
+ # Create or coerce a protobuf request object.
1608
+ # - Quick check: If we got a request object, we should *not* have
1609
+ # gotten any keyword arguments that map to the request.
1610
+ flattened_params = [name]
1611
+ has_flattened_params = (
1612
+ len([param for param in flattened_params if param is not None]) > 0
1613
+ )
1614
+ if request is not None and has_flattened_params:
1615
+ raise ValueError(
1616
+ "If the `request` argument is set, then none of "
1617
+ "the individual field arguments should be set."
1618
+ )
1619
+
1620
+ # - Use the request object if provided (there's no risk of modifying the input as
1621
+ # there are no flattened fields), or create one.
1622
+ if not isinstance(request, services.DeleteJobTemplateRequest):
1623
+ request = services.DeleteJobTemplateRequest(request)
1624
+ # If we have keyword arguments corresponding to fields on the
1625
+ # request, apply these.
1626
+ if name is not None:
1627
+ request.name = name
1628
+
1629
+ # Wrap the RPC method; this adds retry and timeout information,
1630
+ # and friendly error handling.
1631
+ rpc = self._transport._wrapped_methods[self._transport.delete_job_template]
1632
+
1633
+ # Certain fields should be provided within the metadata header;
1634
+ # add these here.
1635
+ metadata = tuple(metadata) + (
1636
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1637
+ )
1638
+
1639
+ # Validate the universe domain.
1640
+ self._validate_universe_domain()
1641
+
1642
+ # Send the request.
1643
+ rpc(
1644
+ request,
1645
+ retry=retry,
1646
+ timeout=timeout,
1647
+ metadata=metadata,
1648
+ )
1649
+
1650
+ def __enter__(self) -> "TranscoderServiceClient":
1651
+ return self
1652
+
1653
+ def __exit__(self, type, value, traceback):
1654
+ """Releases underlying transport's resources.
1655
+
1656
+ .. warning::
1657
+ ONLY use as a context manager if the transport is NOT shared
1658
+ with other clients! Exiting the with block will CLOSE the transport
1659
+ and may cause errors in other clients!
1660
+ """
1661
+ self.transport.close()
1662
+
1663
+
1664
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
1665
+ gapic_version=package_version.__version__
1666
+ )
1667
+
1668
+
1669
+ __all__ = ("TranscoderServiceClient",)