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,1709 @@
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
+ import dataclasses
17
+ import json # type: ignore
18
+ import logging
19
+ from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
20
+ import warnings
21
+
22
+ from google.api_core import exceptions as core_exceptions
23
+ from google.api_core import gapic_v1, rest_helpers, rest_streaming
24
+ from google.api_core import retry as retries
25
+ from google.auth import credentials as ga_credentials # type: ignore
26
+ from google.auth.transport.requests import AuthorizedSession # type: ignore
27
+ from google.protobuf import empty_pb2 # type: ignore
28
+ from google.protobuf import json_format
29
+ from requests import __version__ as requests_version
30
+
31
+ from google.cloud.video.transcoder_v1.types import resources, services
32
+
33
+ from .base import DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO
34
+ from .rest_base import _BaseTranscoderServiceRestTransport
35
+
36
+ try:
37
+ OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
38
+ except AttributeError: # pragma: NO COVER
39
+ OptionalRetry = Union[retries.Retry, object, None] # type: ignore
40
+
41
+ try:
42
+ from google.api_core import client_logging # type: ignore
43
+
44
+ CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
45
+ except ImportError: # pragma: NO COVER
46
+ CLIENT_LOGGING_SUPPORTED = False
47
+
48
+ _LOGGER = logging.getLogger(__name__)
49
+
50
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
51
+ gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version,
52
+ grpc_version=None,
53
+ rest_version=f"requests@{requests_version}",
54
+ )
55
+
56
+
57
+ class TranscoderServiceRestInterceptor:
58
+ """Interceptor for TranscoderService.
59
+
60
+ Interceptors are used to manipulate requests, request metadata, and responses
61
+ in arbitrary ways.
62
+ Example use cases include:
63
+ * Logging
64
+ * Verifying requests according to service or custom semantics
65
+ * Stripping extraneous information from responses
66
+
67
+ These use cases and more can be enabled by injecting an
68
+ instance of a custom subclass when constructing the TranscoderServiceRestTransport.
69
+
70
+ .. code-block:: python
71
+ class MyCustomTranscoderServiceInterceptor(TranscoderServiceRestInterceptor):
72
+ def pre_create_job(self, request, metadata):
73
+ logging.log(f"Received request: {request}")
74
+ return request, metadata
75
+
76
+ def post_create_job(self, response):
77
+ logging.log(f"Received response: {response}")
78
+ return response
79
+
80
+ def pre_create_job_template(self, request, metadata):
81
+ logging.log(f"Received request: {request}")
82
+ return request, metadata
83
+
84
+ def post_create_job_template(self, response):
85
+ logging.log(f"Received response: {response}")
86
+ return response
87
+
88
+ def pre_delete_job(self, request, metadata):
89
+ logging.log(f"Received request: {request}")
90
+ return request, metadata
91
+
92
+ def pre_delete_job_template(self, request, metadata):
93
+ logging.log(f"Received request: {request}")
94
+ return request, metadata
95
+
96
+ def pre_get_job(self, request, metadata):
97
+ logging.log(f"Received request: {request}")
98
+ return request, metadata
99
+
100
+ def post_get_job(self, response):
101
+ logging.log(f"Received response: {response}")
102
+ return response
103
+
104
+ def pre_get_job_template(self, request, metadata):
105
+ logging.log(f"Received request: {request}")
106
+ return request, metadata
107
+
108
+ def post_get_job_template(self, response):
109
+ logging.log(f"Received response: {response}")
110
+ return response
111
+
112
+ def pre_list_jobs(self, request, metadata):
113
+ logging.log(f"Received request: {request}")
114
+ return request, metadata
115
+
116
+ def post_list_jobs(self, response):
117
+ logging.log(f"Received response: {response}")
118
+ return response
119
+
120
+ def pre_list_job_templates(self, request, metadata):
121
+ logging.log(f"Received request: {request}")
122
+ return request, metadata
123
+
124
+ def post_list_job_templates(self, response):
125
+ logging.log(f"Received response: {response}")
126
+ return response
127
+
128
+ transport = TranscoderServiceRestTransport(interceptor=MyCustomTranscoderServiceInterceptor())
129
+ client = TranscoderServiceClient(transport=transport)
130
+
131
+
132
+ """
133
+
134
+ def pre_create_job(
135
+ self,
136
+ request: services.CreateJobRequest,
137
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
138
+ ) -> Tuple[services.CreateJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]:
139
+ """Pre-rpc interceptor for create_job
140
+
141
+ Override in a subclass to manipulate the request or metadata
142
+ before they are sent to the TranscoderService server.
143
+ """
144
+ return request, metadata
145
+
146
+ def post_create_job(self, response: resources.Job) -> resources.Job:
147
+ """Post-rpc interceptor for create_job
148
+
149
+ DEPRECATED. Please use the `post_create_job_with_metadata`
150
+ interceptor instead.
151
+
152
+ Override in a subclass to read or manipulate the response
153
+ after it is returned by the TranscoderService server but before
154
+ it is returned to user code. This `post_create_job` interceptor runs
155
+ before the `post_create_job_with_metadata` interceptor.
156
+ """
157
+ return response
158
+
159
+ def post_create_job_with_metadata(
160
+ self, response: resources.Job, metadata: Sequence[Tuple[str, Union[str, bytes]]]
161
+ ) -> Tuple[resources.Job, Sequence[Tuple[str, Union[str, bytes]]]]:
162
+ """Post-rpc interceptor for create_job
163
+
164
+ Override in a subclass to read or manipulate the response or metadata after it
165
+ is returned by the TranscoderService server but before it is returned to user code.
166
+
167
+ We recommend only using this `post_create_job_with_metadata`
168
+ interceptor in new development instead of the `post_create_job` interceptor.
169
+ When both interceptors are used, this `post_create_job_with_metadata` interceptor runs after the
170
+ `post_create_job` interceptor. The (possibly modified) response returned by
171
+ `post_create_job` will be passed to
172
+ `post_create_job_with_metadata`.
173
+ """
174
+ return response, metadata
175
+
176
+ def pre_create_job_template(
177
+ self,
178
+ request: services.CreateJobTemplateRequest,
179
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
180
+ ) -> Tuple[
181
+ services.CreateJobTemplateRequest, Sequence[Tuple[str, Union[str, bytes]]]
182
+ ]:
183
+ """Pre-rpc interceptor for create_job_template
184
+
185
+ Override in a subclass to manipulate the request or metadata
186
+ before they are sent to the TranscoderService server.
187
+ """
188
+ return request, metadata
189
+
190
+ def post_create_job_template(
191
+ self, response: resources.JobTemplate
192
+ ) -> resources.JobTemplate:
193
+ """Post-rpc interceptor for create_job_template
194
+
195
+ DEPRECATED. Please use the `post_create_job_template_with_metadata`
196
+ interceptor instead.
197
+
198
+ Override in a subclass to read or manipulate the response
199
+ after it is returned by the TranscoderService server but before
200
+ it is returned to user code. This `post_create_job_template` interceptor runs
201
+ before the `post_create_job_template_with_metadata` interceptor.
202
+ """
203
+ return response
204
+
205
+ def post_create_job_template_with_metadata(
206
+ self,
207
+ response: resources.JobTemplate,
208
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
209
+ ) -> Tuple[resources.JobTemplate, Sequence[Tuple[str, Union[str, bytes]]]]:
210
+ """Post-rpc interceptor for create_job_template
211
+
212
+ Override in a subclass to read or manipulate the response or metadata after it
213
+ is returned by the TranscoderService server but before it is returned to user code.
214
+
215
+ We recommend only using this `post_create_job_template_with_metadata`
216
+ interceptor in new development instead of the `post_create_job_template` interceptor.
217
+ When both interceptors are used, this `post_create_job_template_with_metadata` interceptor runs after the
218
+ `post_create_job_template` interceptor. The (possibly modified) response returned by
219
+ `post_create_job_template` will be passed to
220
+ `post_create_job_template_with_metadata`.
221
+ """
222
+ return response, metadata
223
+
224
+ def pre_delete_job(
225
+ self,
226
+ request: services.DeleteJobRequest,
227
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
228
+ ) -> Tuple[services.DeleteJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]:
229
+ """Pre-rpc interceptor for delete_job
230
+
231
+ Override in a subclass to manipulate the request or metadata
232
+ before they are sent to the TranscoderService server.
233
+ """
234
+ return request, metadata
235
+
236
+ def pre_delete_job_template(
237
+ self,
238
+ request: services.DeleteJobTemplateRequest,
239
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
240
+ ) -> Tuple[
241
+ services.DeleteJobTemplateRequest, Sequence[Tuple[str, Union[str, bytes]]]
242
+ ]:
243
+ """Pre-rpc interceptor for delete_job_template
244
+
245
+ Override in a subclass to manipulate the request or metadata
246
+ before they are sent to the TranscoderService server.
247
+ """
248
+ return request, metadata
249
+
250
+ def pre_get_job(
251
+ self,
252
+ request: services.GetJobRequest,
253
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
254
+ ) -> Tuple[services.GetJobRequest, Sequence[Tuple[str, Union[str, bytes]]]]:
255
+ """Pre-rpc interceptor for get_job
256
+
257
+ Override in a subclass to manipulate the request or metadata
258
+ before they are sent to the TranscoderService server.
259
+ """
260
+ return request, metadata
261
+
262
+ def post_get_job(self, response: resources.Job) -> resources.Job:
263
+ """Post-rpc interceptor for get_job
264
+
265
+ DEPRECATED. Please use the `post_get_job_with_metadata`
266
+ interceptor instead.
267
+
268
+ Override in a subclass to read or manipulate the response
269
+ after it is returned by the TranscoderService server but before
270
+ it is returned to user code. This `post_get_job` interceptor runs
271
+ before the `post_get_job_with_metadata` interceptor.
272
+ """
273
+ return response
274
+
275
+ def post_get_job_with_metadata(
276
+ self, response: resources.Job, metadata: Sequence[Tuple[str, Union[str, bytes]]]
277
+ ) -> Tuple[resources.Job, Sequence[Tuple[str, Union[str, bytes]]]]:
278
+ """Post-rpc interceptor for get_job
279
+
280
+ Override in a subclass to read or manipulate the response or metadata after it
281
+ is returned by the TranscoderService server but before it is returned to user code.
282
+
283
+ We recommend only using this `post_get_job_with_metadata`
284
+ interceptor in new development instead of the `post_get_job` interceptor.
285
+ When both interceptors are used, this `post_get_job_with_metadata` interceptor runs after the
286
+ `post_get_job` interceptor. The (possibly modified) response returned by
287
+ `post_get_job` will be passed to
288
+ `post_get_job_with_metadata`.
289
+ """
290
+ return response, metadata
291
+
292
+ def pre_get_job_template(
293
+ self,
294
+ request: services.GetJobTemplateRequest,
295
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
296
+ ) -> Tuple[services.GetJobTemplateRequest, Sequence[Tuple[str, Union[str, bytes]]]]:
297
+ """Pre-rpc interceptor for get_job_template
298
+
299
+ Override in a subclass to manipulate the request or metadata
300
+ before they are sent to the TranscoderService server.
301
+ """
302
+ return request, metadata
303
+
304
+ def post_get_job_template(
305
+ self, response: resources.JobTemplate
306
+ ) -> resources.JobTemplate:
307
+ """Post-rpc interceptor for get_job_template
308
+
309
+ DEPRECATED. Please use the `post_get_job_template_with_metadata`
310
+ interceptor instead.
311
+
312
+ Override in a subclass to read or manipulate the response
313
+ after it is returned by the TranscoderService server but before
314
+ it is returned to user code. This `post_get_job_template` interceptor runs
315
+ before the `post_get_job_template_with_metadata` interceptor.
316
+ """
317
+ return response
318
+
319
+ def post_get_job_template_with_metadata(
320
+ self,
321
+ response: resources.JobTemplate,
322
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
323
+ ) -> Tuple[resources.JobTemplate, Sequence[Tuple[str, Union[str, bytes]]]]:
324
+ """Post-rpc interceptor for get_job_template
325
+
326
+ Override in a subclass to read or manipulate the response or metadata after it
327
+ is returned by the TranscoderService server but before it is returned to user code.
328
+
329
+ We recommend only using this `post_get_job_template_with_metadata`
330
+ interceptor in new development instead of the `post_get_job_template` interceptor.
331
+ When both interceptors are used, this `post_get_job_template_with_metadata` interceptor runs after the
332
+ `post_get_job_template` interceptor. The (possibly modified) response returned by
333
+ `post_get_job_template` will be passed to
334
+ `post_get_job_template_with_metadata`.
335
+ """
336
+ return response, metadata
337
+
338
+ def pre_list_jobs(
339
+ self,
340
+ request: services.ListJobsRequest,
341
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
342
+ ) -> Tuple[services.ListJobsRequest, Sequence[Tuple[str, Union[str, bytes]]]]:
343
+ """Pre-rpc interceptor for list_jobs
344
+
345
+ Override in a subclass to manipulate the request or metadata
346
+ before they are sent to the TranscoderService server.
347
+ """
348
+ return request, metadata
349
+
350
+ def post_list_jobs(
351
+ self, response: services.ListJobsResponse
352
+ ) -> services.ListJobsResponse:
353
+ """Post-rpc interceptor for list_jobs
354
+
355
+ DEPRECATED. Please use the `post_list_jobs_with_metadata`
356
+ interceptor instead.
357
+
358
+ Override in a subclass to read or manipulate the response
359
+ after it is returned by the TranscoderService server but before
360
+ it is returned to user code. This `post_list_jobs` interceptor runs
361
+ before the `post_list_jobs_with_metadata` interceptor.
362
+ """
363
+ return response
364
+
365
+ def post_list_jobs_with_metadata(
366
+ self,
367
+ response: services.ListJobsResponse,
368
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
369
+ ) -> Tuple[services.ListJobsResponse, Sequence[Tuple[str, Union[str, bytes]]]]:
370
+ """Post-rpc interceptor for list_jobs
371
+
372
+ Override in a subclass to read or manipulate the response or metadata after it
373
+ is returned by the TranscoderService server but before it is returned to user code.
374
+
375
+ We recommend only using this `post_list_jobs_with_metadata`
376
+ interceptor in new development instead of the `post_list_jobs` interceptor.
377
+ When both interceptors are used, this `post_list_jobs_with_metadata` interceptor runs after the
378
+ `post_list_jobs` interceptor. The (possibly modified) response returned by
379
+ `post_list_jobs` will be passed to
380
+ `post_list_jobs_with_metadata`.
381
+ """
382
+ return response, metadata
383
+
384
+ def pre_list_job_templates(
385
+ self,
386
+ request: services.ListJobTemplatesRequest,
387
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
388
+ ) -> Tuple[
389
+ services.ListJobTemplatesRequest, Sequence[Tuple[str, Union[str, bytes]]]
390
+ ]:
391
+ """Pre-rpc interceptor for list_job_templates
392
+
393
+ Override in a subclass to manipulate the request or metadata
394
+ before they are sent to the TranscoderService server.
395
+ """
396
+ return request, metadata
397
+
398
+ def post_list_job_templates(
399
+ self, response: services.ListJobTemplatesResponse
400
+ ) -> services.ListJobTemplatesResponse:
401
+ """Post-rpc interceptor for list_job_templates
402
+
403
+ DEPRECATED. Please use the `post_list_job_templates_with_metadata`
404
+ interceptor instead.
405
+
406
+ Override in a subclass to read or manipulate the response
407
+ after it is returned by the TranscoderService server but before
408
+ it is returned to user code. This `post_list_job_templates` interceptor runs
409
+ before the `post_list_job_templates_with_metadata` interceptor.
410
+ """
411
+ return response
412
+
413
+ def post_list_job_templates_with_metadata(
414
+ self,
415
+ response: services.ListJobTemplatesResponse,
416
+ metadata: Sequence[Tuple[str, Union[str, bytes]]],
417
+ ) -> Tuple[
418
+ services.ListJobTemplatesResponse, Sequence[Tuple[str, Union[str, bytes]]]
419
+ ]:
420
+ """Post-rpc interceptor for list_job_templates
421
+
422
+ Override in a subclass to read or manipulate the response or metadata after it
423
+ is returned by the TranscoderService server but before it is returned to user code.
424
+
425
+ We recommend only using this `post_list_job_templates_with_metadata`
426
+ interceptor in new development instead of the `post_list_job_templates` interceptor.
427
+ When both interceptors are used, this `post_list_job_templates_with_metadata` interceptor runs after the
428
+ `post_list_job_templates` interceptor. The (possibly modified) response returned by
429
+ `post_list_job_templates` will be passed to
430
+ `post_list_job_templates_with_metadata`.
431
+ """
432
+ return response, metadata
433
+
434
+
435
+ @dataclasses.dataclass
436
+ class TranscoderServiceRestStub:
437
+ _session: AuthorizedSession
438
+ _host: str
439
+ _interceptor: TranscoderServiceRestInterceptor
440
+
441
+
442
+ class TranscoderServiceRestTransport(_BaseTranscoderServiceRestTransport):
443
+ """REST backend synchronous transport for TranscoderService.
444
+
445
+ Using the Transcoder API, you can queue asynchronous jobs for
446
+ transcoding media into various output formats. Output formats
447
+ may include different streaming standards such as HTTP Live
448
+ Streaming (HLS) and Dynamic Adaptive Streaming over HTTP (DASH).
449
+ You can also customize jobs using advanced features such as
450
+ Digital Rights Management (DRM), audio equalization, content
451
+ concatenation, and digital ad-stitch ready content generation.
452
+
453
+ This class defines the same methods as the primary client, so the
454
+ primary client can load the underlying transport implementation
455
+ and call it.
456
+
457
+ It sends JSON representations of protocol buffers over HTTP/1.1
458
+ """
459
+
460
+ def __init__(
461
+ self,
462
+ *,
463
+ host: str = "transcoder.googleapis.com",
464
+ credentials: Optional[ga_credentials.Credentials] = None,
465
+ credentials_file: Optional[str] = None,
466
+ scopes: Optional[Sequence[str]] = None,
467
+ client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
468
+ quota_project_id: Optional[str] = None,
469
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
470
+ always_use_jwt_access: Optional[bool] = False,
471
+ url_scheme: str = "https",
472
+ interceptor: Optional[TranscoderServiceRestInterceptor] = None,
473
+ api_audience: Optional[str] = None,
474
+ ) -> None:
475
+ """Instantiate the transport.
476
+
477
+ Args:
478
+ host (Optional[str]):
479
+ The hostname to connect to (default: 'transcoder.googleapis.com').
480
+ credentials (Optional[google.auth.credentials.Credentials]): The
481
+ authorization credentials to attach to requests. These
482
+ credentials identify the application to the service; if none
483
+ are specified, the client will attempt to ascertain the
484
+ credentials from the environment.
485
+
486
+ credentials_file (Optional[str]): A file with credentials that can
487
+ be loaded with :func:`google.auth.load_credentials_from_file`.
488
+ This argument is ignored if ``channel`` is provided.
489
+ scopes (Optional(Sequence[str])): A list of scopes. This argument is
490
+ ignored if ``channel`` is provided.
491
+ client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client
492
+ certificate to configure mutual TLS HTTP channel. It is ignored
493
+ if ``channel`` is provided.
494
+ quota_project_id (Optional[str]): An optional project to use for billing
495
+ and quota.
496
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
497
+ The client info used to send a user-agent string along with
498
+ API requests. If ``None``, then default info will be used.
499
+ Generally, you only need to set this if you are developing
500
+ your own client library.
501
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
502
+ be used for service account credentials.
503
+ url_scheme: the protocol scheme for the API endpoint. Normally
504
+ "https", but for testing or local servers,
505
+ "http" can be specified.
506
+ """
507
+ # Run the base constructor
508
+ # TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc.
509
+ # TODO: When custom host (api_endpoint) is set, `scopes` must *also* be set on the
510
+ # credentials object
511
+ super().__init__(
512
+ host=host,
513
+ credentials=credentials,
514
+ client_info=client_info,
515
+ always_use_jwt_access=always_use_jwt_access,
516
+ url_scheme=url_scheme,
517
+ api_audience=api_audience,
518
+ )
519
+ self._session = AuthorizedSession(
520
+ self._credentials, default_host=self.DEFAULT_HOST
521
+ )
522
+ if client_cert_source_for_mtls:
523
+ self._session.configure_mtls_channel(client_cert_source_for_mtls)
524
+ self._interceptor = interceptor or TranscoderServiceRestInterceptor()
525
+ self._prep_wrapped_messages(client_info)
526
+
527
+ class _CreateJob(
528
+ _BaseTranscoderServiceRestTransport._BaseCreateJob, TranscoderServiceRestStub
529
+ ):
530
+ def __hash__(self):
531
+ return hash("TranscoderServiceRestTransport.CreateJob")
532
+
533
+ @staticmethod
534
+ def _get_response(
535
+ host,
536
+ metadata,
537
+ query_params,
538
+ session,
539
+ timeout,
540
+ transcoded_request,
541
+ body=None,
542
+ ):
543
+ uri = transcoded_request["uri"]
544
+ method = transcoded_request["method"]
545
+ headers = dict(metadata)
546
+ headers["Content-Type"] = "application/json"
547
+ response = getattr(session, method)(
548
+ "{host}{uri}".format(host=host, uri=uri),
549
+ timeout=timeout,
550
+ headers=headers,
551
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
552
+ data=body,
553
+ )
554
+ return response
555
+
556
+ def __call__(
557
+ self,
558
+ request: services.CreateJobRequest,
559
+ *,
560
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
561
+ timeout: Optional[float] = None,
562
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
563
+ ) -> resources.Job:
564
+ r"""Call the create job method over HTTP.
565
+
566
+ Args:
567
+ request (~.services.CreateJobRequest):
568
+ The request object. Request message for ``TranscoderService.CreateJob``.
569
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
570
+ should be retried.
571
+ timeout (float): The timeout for this request.
572
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
573
+ sent along with the request as metadata. Normally, each value must be of type `str`,
574
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
575
+ be of type `bytes`.
576
+
577
+ Returns:
578
+ ~.resources.Job:
579
+ Transcoding job resource.
580
+ """
581
+
582
+ http_options = (
583
+ _BaseTranscoderServiceRestTransport._BaseCreateJob._get_http_options()
584
+ )
585
+
586
+ request, metadata = self._interceptor.pre_create_job(request, metadata)
587
+ transcoded_request = _BaseTranscoderServiceRestTransport._BaseCreateJob._get_transcoded_request(
588
+ http_options, request
589
+ )
590
+
591
+ body = _BaseTranscoderServiceRestTransport._BaseCreateJob._get_request_body_json(
592
+ transcoded_request
593
+ )
594
+
595
+ # Jsonify the query params
596
+ query_params = _BaseTranscoderServiceRestTransport._BaseCreateJob._get_query_params_json(
597
+ transcoded_request
598
+ )
599
+
600
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
601
+ logging.DEBUG
602
+ ): # pragma: NO COVER
603
+ request_url = "{host}{uri}".format(
604
+ host=self._host, uri=transcoded_request["uri"]
605
+ )
606
+ method = transcoded_request["method"]
607
+ try:
608
+ request_payload = type(request).to_json(request)
609
+ except:
610
+ request_payload = None
611
+ http_request = {
612
+ "payload": request_payload,
613
+ "requestMethod": method,
614
+ "requestUrl": request_url,
615
+ "headers": dict(metadata),
616
+ }
617
+ _LOGGER.debug(
618
+ f"Sending request for google.cloud.video.transcoder_v1.TranscoderServiceClient.CreateJob",
619
+ extra={
620
+ "serviceName": "google.cloud.video.transcoder.v1.TranscoderService",
621
+ "rpcName": "CreateJob",
622
+ "httpRequest": http_request,
623
+ "metadata": http_request["headers"],
624
+ },
625
+ )
626
+
627
+ # Send the request
628
+ response = TranscoderServiceRestTransport._CreateJob._get_response(
629
+ self._host,
630
+ metadata,
631
+ query_params,
632
+ self._session,
633
+ timeout,
634
+ transcoded_request,
635
+ body,
636
+ )
637
+
638
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
639
+ # subclass.
640
+ if response.status_code >= 400:
641
+ raise core_exceptions.from_http_response(response)
642
+
643
+ # Return the response
644
+ resp = resources.Job()
645
+ pb_resp = resources.Job.pb(resp)
646
+
647
+ json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
648
+
649
+ resp = self._interceptor.post_create_job(resp)
650
+ response_metadata = [(k, str(v)) for k, v in response.headers.items()]
651
+ resp, _ = self._interceptor.post_create_job_with_metadata(
652
+ resp, response_metadata
653
+ )
654
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
655
+ logging.DEBUG
656
+ ): # pragma: NO COVER
657
+ try:
658
+ response_payload = resources.Job.to_json(response)
659
+ except:
660
+ response_payload = None
661
+ http_response = {
662
+ "payload": response_payload,
663
+ "headers": dict(response.headers),
664
+ "status": response.status_code,
665
+ }
666
+ _LOGGER.debug(
667
+ "Received response for google.cloud.video.transcoder_v1.TranscoderServiceClient.create_job",
668
+ extra={
669
+ "serviceName": "google.cloud.video.transcoder.v1.TranscoderService",
670
+ "rpcName": "CreateJob",
671
+ "metadata": http_response["headers"],
672
+ "httpResponse": http_response,
673
+ },
674
+ )
675
+ return resp
676
+
677
+ class _CreateJobTemplate(
678
+ _BaseTranscoderServiceRestTransport._BaseCreateJobTemplate,
679
+ TranscoderServiceRestStub,
680
+ ):
681
+ def __hash__(self):
682
+ return hash("TranscoderServiceRestTransport.CreateJobTemplate")
683
+
684
+ @staticmethod
685
+ def _get_response(
686
+ host,
687
+ metadata,
688
+ query_params,
689
+ session,
690
+ timeout,
691
+ transcoded_request,
692
+ body=None,
693
+ ):
694
+ uri = transcoded_request["uri"]
695
+ method = transcoded_request["method"]
696
+ headers = dict(metadata)
697
+ headers["Content-Type"] = "application/json"
698
+ response = getattr(session, method)(
699
+ "{host}{uri}".format(host=host, uri=uri),
700
+ timeout=timeout,
701
+ headers=headers,
702
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
703
+ data=body,
704
+ )
705
+ return response
706
+
707
+ def __call__(
708
+ self,
709
+ request: services.CreateJobTemplateRequest,
710
+ *,
711
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
712
+ timeout: Optional[float] = None,
713
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
714
+ ) -> resources.JobTemplate:
715
+ r"""Call the create job template method over HTTP.
716
+
717
+ Args:
718
+ request (~.services.CreateJobTemplateRequest):
719
+ The request object. Request message for
720
+ ``TranscoderService.CreateJobTemplate``.
721
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
722
+ should be retried.
723
+ timeout (float): The timeout for this request.
724
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
725
+ sent along with the request as metadata. Normally, each value must be of type `str`,
726
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
727
+ be of type `bytes`.
728
+
729
+ Returns:
730
+ ~.resources.JobTemplate:
731
+ Transcoding job template resource.
732
+ """
733
+
734
+ http_options = (
735
+ _BaseTranscoderServiceRestTransport._BaseCreateJobTemplate._get_http_options()
736
+ )
737
+
738
+ request, metadata = self._interceptor.pre_create_job_template(
739
+ request, metadata
740
+ )
741
+ transcoded_request = _BaseTranscoderServiceRestTransport._BaseCreateJobTemplate._get_transcoded_request(
742
+ http_options, request
743
+ )
744
+
745
+ body = _BaseTranscoderServiceRestTransport._BaseCreateJobTemplate._get_request_body_json(
746
+ transcoded_request
747
+ )
748
+
749
+ # Jsonify the query params
750
+ query_params = _BaseTranscoderServiceRestTransport._BaseCreateJobTemplate._get_query_params_json(
751
+ transcoded_request
752
+ )
753
+
754
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
755
+ logging.DEBUG
756
+ ): # pragma: NO COVER
757
+ request_url = "{host}{uri}".format(
758
+ host=self._host, uri=transcoded_request["uri"]
759
+ )
760
+ method = transcoded_request["method"]
761
+ try:
762
+ request_payload = type(request).to_json(request)
763
+ except:
764
+ request_payload = None
765
+ http_request = {
766
+ "payload": request_payload,
767
+ "requestMethod": method,
768
+ "requestUrl": request_url,
769
+ "headers": dict(metadata),
770
+ }
771
+ _LOGGER.debug(
772
+ f"Sending request for google.cloud.video.transcoder_v1.TranscoderServiceClient.CreateJobTemplate",
773
+ extra={
774
+ "serviceName": "google.cloud.video.transcoder.v1.TranscoderService",
775
+ "rpcName": "CreateJobTemplate",
776
+ "httpRequest": http_request,
777
+ "metadata": http_request["headers"],
778
+ },
779
+ )
780
+
781
+ # Send the request
782
+ response = TranscoderServiceRestTransport._CreateJobTemplate._get_response(
783
+ self._host,
784
+ metadata,
785
+ query_params,
786
+ self._session,
787
+ timeout,
788
+ transcoded_request,
789
+ body,
790
+ )
791
+
792
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
793
+ # subclass.
794
+ if response.status_code >= 400:
795
+ raise core_exceptions.from_http_response(response)
796
+
797
+ # Return the response
798
+ resp = resources.JobTemplate()
799
+ pb_resp = resources.JobTemplate.pb(resp)
800
+
801
+ json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
802
+
803
+ resp = self._interceptor.post_create_job_template(resp)
804
+ response_metadata = [(k, str(v)) for k, v in response.headers.items()]
805
+ resp, _ = self._interceptor.post_create_job_template_with_metadata(
806
+ resp, response_metadata
807
+ )
808
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
809
+ logging.DEBUG
810
+ ): # pragma: NO COVER
811
+ try:
812
+ response_payload = resources.JobTemplate.to_json(response)
813
+ except:
814
+ response_payload = None
815
+ http_response = {
816
+ "payload": response_payload,
817
+ "headers": dict(response.headers),
818
+ "status": response.status_code,
819
+ }
820
+ _LOGGER.debug(
821
+ "Received response for google.cloud.video.transcoder_v1.TranscoderServiceClient.create_job_template",
822
+ extra={
823
+ "serviceName": "google.cloud.video.transcoder.v1.TranscoderService",
824
+ "rpcName": "CreateJobTemplate",
825
+ "metadata": http_response["headers"],
826
+ "httpResponse": http_response,
827
+ },
828
+ )
829
+ return resp
830
+
831
+ class _DeleteJob(
832
+ _BaseTranscoderServiceRestTransport._BaseDeleteJob, TranscoderServiceRestStub
833
+ ):
834
+ def __hash__(self):
835
+ return hash("TranscoderServiceRestTransport.DeleteJob")
836
+
837
+ @staticmethod
838
+ def _get_response(
839
+ host,
840
+ metadata,
841
+ query_params,
842
+ session,
843
+ timeout,
844
+ transcoded_request,
845
+ body=None,
846
+ ):
847
+ uri = transcoded_request["uri"]
848
+ method = transcoded_request["method"]
849
+ headers = dict(metadata)
850
+ headers["Content-Type"] = "application/json"
851
+ response = getattr(session, method)(
852
+ "{host}{uri}".format(host=host, uri=uri),
853
+ timeout=timeout,
854
+ headers=headers,
855
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
856
+ )
857
+ return response
858
+
859
+ def __call__(
860
+ self,
861
+ request: services.DeleteJobRequest,
862
+ *,
863
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
864
+ timeout: Optional[float] = None,
865
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
866
+ ):
867
+ r"""Call the delete job method over HTTP.
868
+
869
+ Args:
870
+ request (~.services.DeleteJobRequest):
871
+ The request object. Request message for ``TranscoderService.DeleteJob``.
872
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
873
+ should be retried.
874
+ timeout (float): The timeout for this request.
875
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
876
+ sent along with the request as metadata. Normally, each value must be of type `str`,
877
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
878
+ be of type `bytes`.
879
+ """
880
+
881
+ http_options = (
882
+ _BaseTranscoderServiceRestTransport._BaseDeleteJob._get_http_options()
883
+ )
884
+
885
+ request, metadata = self._interceptor.pre_delete_job(request, metadata)
886
+ transcoded_request = _BaseTranscoderServiceRestTransport._BaseDeleteJob._get_transcoded_request(
887
+ http_options, request
888
+ )
889
+
890
+ # Jsonify the query params
891
+ query_params = _BaseTranscoderServiceRestTransport._BaseDeleteJob._get_query_params_json(
892
+ transcoded_request
893
+ )
894
+
895
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
896
+ logging.DEBUG
897
+ ): # pragma: NO COVER
898
+ request_url = "{host}{uri}".format(
899
+ host=self._host, uri=transcoded_request["uri"]
900
+ )
901
+ method = transcoded_request["method"]
902
+ try:
903
+ request_payload = json_format.MessageToJson(request)
904
+ except:
905
+ request_payload = None
906
+ http_request = {
907
+ "payload": request_payload,
908
+ "requestMethod": method,
909
+ "requestUrl": request_url,
910
+ "headers": dict(metadata),
911
+ }
912
+ _LOGGER.debug(
913
+ f"Sending request for google.cloud.video.transcoder_v1.TranscoderServiceClient.DeleteJob",
914
+ extra={
915
+ "serviceName": "google.cloud.video.transcoder.v1.TranscoderService",
916
+ "rpcName": "DeleteJob",
917
+ "httpRequest": http_request,
918
+ "metadata": http_request["headers"],
919
+ },
920
+ )
921
+
922
+ # Send the request
923
+ response = TranscoderServiceRestTransport._DeleteJob._get_response(
924
+ self._host,
925
+ metadata,
926
+ query_params,
927
+ self._session,
928
+ timeout,
929
+ transcoded_request,
930
+ )
931
+
932
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
933
+ # subclass.
934
+ if response.status_code >= 400:
935
+ raise core_exceptions.from_http_response(response)
936
+
937
+ class _DeleteJobTemplate(
938
+ _BaseTranscoderServiceRestTransport._BaseDeleteJobTemplate,
939
+ TranscoderServiceRestStub,
940
+ ):
941
+ def __hash__(self):
942
+ return hash("TranscoderServiceRestTransport.DeleteJobTemplate")
943
+
944
+ @staticmethod
945
+ def _get_response(
946
+ host,
947
+ metadata,
948
+ query_params,
949
+ session,
950
+ timeout,
951
+ transcoded_request,
952
+ body=None,
953
+ ):
954
+ uri = transcoded_request["uri"]
955
+ method = transcoded_request["method"]
956
+ headers = dict(metadata)
957
+ headers["Content-Type"] = "application/json"
958
+ response = getattr(session, method)(
959
+ "{host}{uri}".format(host=host, uri=uri),
960
+ timeout=timeout,
961
+ headers=headers,
962
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
963
+ )
964
+ return response
965
+
966
+ def __call__(
967
+ self,
968
+ request: services.DeleteJobTemplateRequest,
969
+ *,
970
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
971
+ timeout: Optional[float] = None,
972
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
973
+ ):
974
+ r"""Call the delete job template method over HTTP.
975
+
976
+ Args:
977
+ request (~.services.DeleteJobTemplateRequest):
978
+ The request object. Request message for
979
+ ``TranscoderService.DeleteJobTemplate``.
980
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
981
+ should be retried.
982
+ timeout (float): The timeout for this request.
983
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
984
+ sent along with the request as metadata. Normally, each value must be of type `str`,
985
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
986
+ be of type `bytes`.
987
+ """
988
+
989
+ http_options = (
990
+ _BaseTranscoderServiceRestTransport._BaseDeleteJobTemplate._get_http_options()
991
+ )
992
+
993
+ request, metadata = self._interceptor.pre_delete_job_template(
994
+ request, metadata
995
+ )
996
+ transcoded_request = _BaseTranscoderServiceRestTransport._BaseDeleteJobTemplate._get_transcoded_request(
997
+ http_options, request
998
+ )
999
+
1000
+ # Jsonify the query params
1001
+ query_params = _BaseTranscoderServiceRestTransport._BaseDeleteJobTemplate._get_query_params_json(
1002
+ transcoded_request
1003
+ )
1004
+
1005
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1006
+ logging.DEBUG
1007
+ ): # pragma: NO COVER
1008
+ request_url = "{host}{uri}".format(
1009
+ host=self._host, uri=transcoded_request["uri"]
1010
+ )
1011
+ method = transcoded_request["method"]
1012
+ try:
1013
+ request_payload = json_format.MessageToJson(request)
1014
+ except:
1015
+ request_payload = None
1016
+ http_request = {
1017
+ "payload": request_payload,
1018
+ "requestMethod": method,
1019
+ "requestUrl": request_url,
1020
+ "headers": dict(metadata),
1021
+ }
1022
+ _LOGGER.debug(
1023
+ f"Sending request for google.cloud.video.transcoder_v1.TranscoderServiceClient.DeleteJobTemplate",
1024
+ extra={
1025
+ "serviceName": "google.cloud.video.transcoder.v1.TranscoderService",
1026
+ "rpcName": "DeleteJobTemplate",
1027
+ "httpRequest": http_request,
1028
+ "metadata": http_request["headers"],
1029
+ },
1030
+ )
1031
+
1032
+ # Send the request
1033
+ response = TranscoderServiceRestTransport._DeleteJobTemplate._get_response(
1034
+ self._host,
1035
+ metadata,
1036
+ query_params,
1037
+ self._session,
1038
+ timeout,
1039
+ transcoded_request,
1040
+ )
1041
+
1042
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1043
+ # subclass.
1044
+ if response.status_code >= 400:
1045
+ raise core_exceptions.from_http_response(response)
1046
+
1047
+ class _GetJob(
1048
+ _BaseTranscoderServiceRestTransport._BaseGetJob, TranscoderServiceRestStub
1049
+ ):
1050
+ def __hash__(self):
1051
+ return hash("TranscoderServiceRestTransport.GetJob")
1052
+
1053
+ @staticmethod
1054
+ def _get_response(
1055
+ host,
1056
+ metadata,
1057
+ query_params,
1058
+ session,
1059
+ timeout,
1060
+ transcoded_request,
1061
+ body=None,
1062
+ ):
1063
+ uri = transcoded_request["uri"]
1064
+ method = transcoded_request["method"]
1065
+ headers = dict(metadata)
1066
+ headers["Content-Type"] = "application/json"
1067
+ response = getattr(session, method)(
1068
+ "{host}{uri}".format(host=host, uri=uri),
1069
+ timeout=timeout,
1070
+ headers=headers,
1071
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1072
+ )
1073
+ return response
1074
+
1075
+ def __call__(
1076
+ self,
1077
+ request: services.GetJobRequest,
1078
+ *,
1079
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1080
+ timeout: Optional[float] = None,
1081
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1082
+ ) -> resources.Job:
1083
+ r"""Call the get job method over HTTP.
1084
+
1085
+ Args:
1086
+ request (~.services.GetJobRequest):
1087
+ The request object. Request message for ``TranscoderService.GetJob``.
1088
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1089
+ should be retried.
1090
+ timeout (float): The timeout for this request.
1091
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1092
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1093
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1094
+ be of type `bytes`.
1095
+
1096
+ Returns:
1097
+ ~.resources.Job:
1098
+ Transcoding job resource.
1099
+ """
1100
+
1101
+ http_options = (
1102
+ _BaseTranscoderServiceRestTransport._BaseGetJob._get_http_options()
1103
+ )
1104
+
1105
+ request, metadata = self._interceptor.pre_get_job(request, metadata)
1106
+ transcoded_request = (
1107
+ _BaseTranscoderServiceRestTransport._BaseGetJob._get_transcoded_request(
1108
+ http_options, request
1109
+ )
1110
+ )
1111
+
1112
+ # Jsonify the query params
1113
+ query_params = (
1114
+ _BaseTranscoderServiceRestTransport._BaseGetJob._get_query_params_json(
1115
+ transcoded_request
1116
+ )
1117
+ )
1118
+
1119
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1120
+ logging.DEBUG
1121
+ ): # pragma: NO COVER
1122
+ request_url = "{host}{uri}".format(
1123
+ host=self._host, uri=transcoded_request["uri"]
1124
+ )
1125
+ method = transcoded_request["method"]
1126
+ try:
1127
+ request_payload = type(request).to_json(request)
1128
+ except:
1129
+ request_payload = None
1130
+ http_request = {
1131
+ "payload": request_payload,
1132
+ "requestMethod": method,
1133
+ "requestUrl": request_url,
1134
+ "headers": dict(metadata),
1135
+ }
1136
+ _LOGGER.debug(
1137
+ f"Sending request for google.cloud.video.transcoder_v1.TranscoderServiceClient.GetJob",
1138
+ extra={
1139
+ "serviceName": "google.cloud.video.transcoder.v1.TranscoderService",
1140
+ "rpcName": "GetJob",
1141
+ "httpRequest": http_request,
1142
+ "metadata": http_request["headers"],
1143
+ },
1144
+ )
1145
+
1146
+ # Send the request
1147
+ response = TranscoderServiceRestTransport._GetJob._get_response(
1148
+ self._host,
1149
+ metadata,
1150
+ query_params,
1151
+ self._session,
1152
+ timeout,
1153
+ transcoded_request,
1154
+ )
1155
+
1156
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1157
+ # subclass.
1158
+ if response.status_code >= 400:
1159
+ raise core_exceptions.from_http_response(response)
1160
+
1161
+ # Return the response
1162
+ resp = resources.Job()
1163
+ pb_resp = resources.Job.pb(resp)
1164
+
1165
+ json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
1166
+
1167
+ resp = self._interceptor.post_get_job(resp)
1168
+ response_metadata = [(k, str(v)) for k, v in response.headers.items()]
1169
+ resp, _ = self._interceptor.post_get_job_with_metadata(
1170
+ resp, response_metadata
1171
+ )
1172
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1173
+ logging.DEBUG
1174
+ ): # pragma: NO COVER
1175
+ try:
1176
+ response_payload = resources.Job.to_json(response)
1177
+ except:
1178
+ response_payload = None
1179
+ http_response = {
1180
+ "payload": response_payload,
1181
+ "headers": dict(response.headers),
1182
+ "status": response.status_code,
1183
+ }
1184
+ _LOGGER.debug(
1185
+ "Received response for google.cloud.video.transcoder_v1.TranscoderServiceClient.get_job",
1186
+ extra={
1187
+ "serviceName": "google.cloud.video.transcoder.v1.TranscoderService",
1188
+ "rpcName": "GetJob",
1189
+ "metadata": http_response["headers"],
1190
+ "httpResponse": http_response,
1191
+ },
1192
+ )
1193
+ return resp
1194
+
1195
+ class _GetJobTemplate(
1196
+ _BaseTranscoderServiceRestTransport._BaseGetJobTemplate,
1197
+ TranscoderServiceRestStub,
1198
+ ):
1199
+ def __hash__(self):
1200
+ return hash("TranscoderServiceRestTransport.GetJobTemplate")
1201
+
1202
+ @staticmethod
1203
+ def _get_response(
1204
+ host,
1205
+ metadata,
1206
+ query_params,
1207
+ session,
1208
+ timeout,
1209
+ transcoded_request,
1210
+ body=None,
1211
+ ):
1212
+ uri = transcoded_request["uri"]
1213
+ method = transcoded_request["method"]
1214
+ headers = dict(metadata)
1215
+ headers["Content-Type"] = "application/json"
1216
+ response = getattr(session, method)(
1217
+ "{host}{uri}".format(host=host, uri=uri),
1218
+ timeout=timeout,
1219
+ headers=headers,
1220
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1221
+ )
1222
+ return response
1223
+
1224
+ def __call__(
1225
+ self,
1226
+ request: services.GetJobTemplateRequest,
1227
+ *,
1228
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1229
+ timeout: Optional[float] = None,
1230
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1231
+ ) -> resources.JobTemplate:
1232
+ r"""Call the get job template method over HTTP.
1233
+
1234
+ Args:
1235
+ request (~.services.GetJobTemplateRequest):
1236
+ The request object. Request message for
1237
+ ``TranscoderService.GetJobTemplate``.
1238
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1239
+ should be retried.
1240
+ timeout (float): The timeout for this request.
1241
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1242
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1243
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1244
+ be of type `bytes`.
1245
+
1246
+ Returns:
1247
+ ~.resources.JobTemplate:
1248
+ Transcoding job template resource.
1249
+ """
1250
+
1251
+ http_options = (
1252
+ _BaseTranscoderServiceRestTransport._BaseGetJobTemplate._get_http_options()
1253
+ )
1254
+
1255
+ request, metadata = self._interceptor.pre_get_job_template(
1256
+ request, metadata
1257
+ )
1258
+ transcoded_request = _BaseTranscoderServiceRestTransport._BaseGetJobTemplate._get_transcoded_request(
1259
+ http_options, request
1260
+ )
1261
+
1262
+ # Jsonify the query params
1263
+ query_params = _BaseTranscoderServiceRestTransport._BaseGetJobTemplate._get_query_params_json(
1264
+ transcoded_request
1265
+ )
1266
+
1267
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1268
+ logging.DEBUG
1269
+ ): # pragma: NO COVER
1270
+ request_url = "{host}{uri}".format(
1271
+ host=self._host, uri=transcoded_request["uri"]
1272
+ )
1273
+ method = transcoded_request["method"]
1274
+ try:
1275
+ request_payload = type(request).to_json(request)
1276
+ except:
1277
+ request_payload = None
1278
+ http_request = {
1279
+ "payload": request_payload,
1280
+ "requestMethod": method,
1281
+ "requestUrl": request_url,
1282
+ "headers": dict(metadata),
1283
+ }
1284
+ _LOGGER.debug(
1285
+ f"Sending request for google.cloud.video.transcoder_v1.TranscoderServiceClient.GetJobTemplate",
1286
+ extra={
1287
+ "serviceName": "google.cloud.video.transcoder.v1.TranscoderService",
1288
+ "rpcName": "GetJobTemplate",
1289
+ "httpRequest": http_request,
1290
+ "metadata": http_request["headers"],
1291
+ },
1292
+ )
1293
+
1294
+ # Send the request
1295
+ response = TranscoderServiceRestTransport._GetJobTemplate._get_response(
1296
+ self._host,
1297
+ metadata,
1298
+ query_params,
1299
+ self._session,
1300
+ timeout,
1301
+ transcoded_request,
1302
+ )
1303
+
1304
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1305
+ # subclass.
1306
+ if response.status_code >= 400:
1307
+ raise core_exceptions.from_http_response(response)
1308
+
1309
+ # Return the response
1310
+ resp = resources.JobTemplate()
1311
+ pb_resp = resources.JobTemplate.pb(resp)
1312
+
1313
+ json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
1314
+
1315
+ resp = self._interceptor.post_get_job_template(resp)
1316
+ response_metadata = [(k, str(v)) for k, v in response.headers.items()]
1317
+ resp, _ = self._interceptor.post_get_job_template_with_metadata(
1318
+ resp, response_metadata
1319
+ )
1320
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1321
+ logging.DEBUG
1322
+ ): # pragma: NO COVER
1323
+ try:
1324
+ response_payload = resources.JobTemplate.to_json(response)
1325
+ except:
1326
+ response_payload = None
1327
+ http_response = {
1328
+ "payload": response_payload,
1329
+ "headers": dict(response.headers),
1330
+ "status": response.status_code,
1331
+ }
1332
+ _LOGGER.debug(
1333
+ "Received response for google.cloud.video.transcoder_v1.TranscoderServiceClient.get_job_template",
1334
+ extra={
1335
+ "serviceName": "google.cloud.video.transcoder.v1.TranscoderService",
1336
+ "rpcName": "GetJobTemplate",
1337
+ "metadata": http_response["headers"],
1338
+ "httpResponse": http_response,
1339
+ },
1340
+ )
1341
+ return resp
1342
+
1343
+ class _ListJobs(
1344
+ _BaseTranscoderServiceRestTransport._BaseListJobs, TranscoderServiceRestStub
1345
+ ):
1346
+ def __hash__(self):
1347
+ return hash("TranscoderServiceRestTransport.ListJobs")
1348
+
1349
+ @staticmethod
1350
+ def _get_response(
1351
+ host,
1352
+ metadata,
1353
+ query_params,
1354
+ session,
1355
+ timeout,
1356
+ transcoded_request,
1357
+ body=None,
1358
+ ):
1359
+ uri = transcoded_request["uri"]
1360
+ method = transcoded_request["method"]
1361
+ headers = dict(metadata)
1362
+ headers["Content-Type"] = "application/json"
1363
+ response = getattr(session, method)(
1364
+ "{host}{uri}".format(host=host, uri=uri),
1365
+ timeout=timeout,
1366
+ headers=headers,
1367
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1368
+ )
1369
+ return response
1370
+
1371
+ def __call__(
1372
+ self,
1373
+ request: services.ListJobsRequest,
1374
+ *,
1375
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1376
+ timeout: Optional[float] = None,
1377
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1378
+ ) -> services.ListJobsResponse:
1379
+ r"""Call the list jobs method over HTTP.
1380
+
1381
+ Args:
1382
+ request (~.services.ListJobsRequest):
1383
+ The request object. Request message for ``TranscoderService.ListJobs``. The
1384
+ parent location from which to retrieve the collection of
1385
+ jobs.
1386
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1387
+ should be retried.
1388
+ timeout (float): The timeout for this request.
1389
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1390
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1391
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1392
+ be of type `bytes`.
1393
+
1394
+ Returns:
1395
+ ~.services.ListJobsResponse:
1396
+ Response message for ``TranscoderService.ListJobs``.
1397
+ """
1398
+
1399
+ http_options = (
1400
+ _BaseTranscoderServiceRestTransport._BaseListJobs._get_http_options()
1401
+ )
1402
+
1403
+ request, metadata = self._interceptor.pre_list_jobs(request, metadata)
1404
+ transcoded_request = _BaseTranscoderServiceRestTransport._BaseListJobs._get_transcoded_request(
1405
+ http_options, request
1406
+ )
1407
+
1408
+ # Jsonify the query params
1409
+ query_params = _BaseTranscoderServiceRestTransport._BaseListJobs._get_query_params_json(
1410
+ transcoded_request
1411
+ )
1412
+
1413
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1414
+ logging.DEBUG
1415
+ ): # pragma: NO COVER
1416
+ request_url = "{host}{uri}".format(
1417
+ host=self._host, uri=transcoded_request["uri"]
1418
+ )
1419
+ method = transcoded_request["method"]
1420
+ try:
1421
+ request_payload = type(request).to_json(request)
1422
+ except:
1423
+ request_payload = None
1424
+ http_request = {
1425
+ "payload": request_payload,
1426
+ "requestMethod": method,
1427
+ "requestUrl": request_url,
1428
+ "headers": dict(metadata),
1429
+ }
1430
+ _LOGGER.debug(
1431
+ f"Sending request for google.cloud.video.transcoder_v1.TranscoderServiceClient.ListJobs",
1432
+ extra={
1433
+ "serviceName": "google.cloud.video.transcoder.v1.TranscoderService",
1434
+ "rpcName": "ListJobs",
1435
+ "httpRequest": http_request,
1436
+ "metadata": http_request["headers"],
1437
+ },
1438
+ )
1439
+
1440
+ # Send the request
1441
+ response = TranscoderServiceRestTransport._ListJobs._get_response(
1442
+ self._host,
1443
+ metadata,
1444
+ query_params,
1445
+ self._session,
1446
+ timeout,
1447
+ transcoded_request,
1448
+ )
1449
+
1450
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1451
+ # subclass.
1452
+ if response.status_code >= 400:
1453
+ raise core_exceptions.from_http_response(response)
1454
+
1455
+ # Return the response
1456
+ resp = services.ListJobsResponse()
1457
+ pb_resp = services.ListJobsResponse.pb(resp)
1458
+
1459
+ json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
1460
+
1461
+ resp = self._interceptor.post_list_jobs(resp)
1462
+ response_metadata = [(k, str(v)) for k, v in response.headers.items()]
1463
+ resp, _ = self._interceptor.post_list_jobs_with_metadata(
1464
+ resp, response_metadata
1465
+ )
1466
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1467
+ logging.DEBUG
1468
+ ): # pragma: NO COVER
1469
+ try:
1470
+ response_payload = services.ListJobsResponse.to_json(response)
1471
+ except:
1472
+ response_payload = None
1473
+ http_response = {
1474
+ "payload": response_payload,
1475
+ "headers": dict(response.headers),
1476
+ "status": response.status_code,
1477
+ }
1478
+ _LOGGER.debug(
1479
+ "Received response for google.cloud.video.transcoder_v1.TranscoderServiceClient.list_jobs",
1480
+ extra={
1481
+ "serviceName": "google.cloud.video.transcoder.v1.TranscoderService",
1482
+ "rpcName": "ListJobs",
1483
+ "metadata": http_response["headers"],
1484
+ "httpResponse": http_response,
1485
+ },
1486
+ )
1487
+ return resp
1488
+
1489
+ class _ListJobTemplates(
1490
+ _BaseTranscoderServiceRestTransport._BaseListJobTemplates,
1491
+ TranscoderServiceRestStub,
1492
+ ):
1493
+ def __hash__(self):
1494
+ return hash("TranscoderServiceRestTransport.ListJobTemplates")
1495
+
1496
+ @staticmethod
1497
+ def _get_response(
1498
+ host,
1499
+ metadata,
1500
+ query_params,
1501
+ session,
1502
+ timeout,
1503
+ transcoded_request,
1504
+ body=None,
1505
+ ):
1506
+ uri = transcoded_request["uri"]
1507
+ method = transcoded_request["method"]
1508
+ headers = dict(metadata)
1509
+ headers["Content-Type"] = "application/json"
1510
+ response = getattr(session, method)(
1511
+ "{host}{uri}".format(host=host, uri=uri),
1512
+ timeout=timeout,
1513
+ headers=headers,
1514
+ params=rest_helpers.flatten_query_params(query_params, strict=True),
1515
+ )
1516
+ return response
1517
+
1518
+ def __call__(
1519
+ self,
1520
+ request: services.ListJobTemplatesRequest,
1521
+ *,
1522
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
1523
+ timeout: Optional[float] = None,
1524
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1525
+ ) -> services.ListJobTemplatesResponse:
1526
+ r"""Call the list job templates method over HTTP.
1527
+
1528
+ Args:
1529
+ request (~.services.ListJobTemplatesRequest):
1530
+ The request object. Request message for
1531
+ ``TranscoderService.ListJobTemplates``.
1532
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
1533
+ should be retried.
1534
+ timeout (float): The timeout for this request.
1535
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1536
+ sent along with the request as metadata. Normally, each value must be of type `str`,
1537
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
1538
+ be of type `bytes`.
1539
+
1540
+ Returns:
1541
+ ~.services.ListJobTemplatesResponse:
1542
+ Response message for
1543
+ ``TranscoderService.ListJobTemplates``.
1544
+
1545
+ """
1546
+
1547
+ http_options = (
1548
+ _BaseTranscoderServiceRestTransport._BaseListJobTemplates._get_http_options()
1549
+ )
1550
+
1551
+ request, metadata = self._interceptor.pre_list_job_templates(
1552
+ request, metadata
1553
+ )
1554
+ transcoded_request = _BaseTranscoderServiceRestTransport._BaseListJobTemplates._get_transcoded_request(
1555
+ http_options, request
1556
+ )
1557
+
1558
+ # Jsonify the query params
1559
+ query_params = _BaseTranscoderServiceRestTransport._BaseListJobTemplates._get_query_params_json(
1560
+ transcoded_request
1561
+ )
1562
+
1563
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1564
+ logging.DEBUG
1565
+ ): # pragma: NO COVER
1566
+ request_url = "{host}{uri}".format(
1567
+ host=self._host, uri=transcoded_request["uri"]
1568
+ )
1569
+ method = transcoded_request["method"]
1570
+ try:
1571
+ request_payload = type(request).to_json(request)
1572
+ except:
1573
+ request_payload = None
1574
+ http_request = {
1575
+ "payload": request_payload,
1576
+ "requestMethod": method,
1577
+ "requestUrl": request_url,
1578
+ "headers": dict(metadata),
1579
+ }
1580
+ _LOGGER.debug(
1581
+ f"Sending request for google.cloud.video.transcoder_v1.TranscoderServiceClient.ListJobTemplates",
1582
+ extra={
1583
+ "serviceName": "google.cloud.video.transcoder.v1.TranscoderService",
1584
+ "rpcName": "ListJobTemplates",
1585
+ "httpRequest": http_request,
1586
+ "metadata": http_request["headers"],
1587
+ },
1588
+ )
1589
+
1590
+ # Send the request
1591
+ response = TranscoderServiceRestTransport._ListJobTemplates._get_response(
1592
+ self._host,
1593
+ metadata,
1594
+ query_params,
1595
+ self._session,
1596
+ timeout,
1597
+ transcoded_request,
1598
+ )
1599
+
1600
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
1601
+ # subclass.
1602
+ if response.status_code >= 400:
1603
+ raise core_exceptions.from_http_response(response)
1604
+
1605
+ # Return the response
1606
+ resp = services.ListJobTemplatesResponse()
1607
+ pb_resp = services.ListJobTemplatesResponse.pb(resp)
1608
+
1609
+ json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
1610
+
1611
+ resp = self._interceptor.post_list_job_templates(resp)
1612
+ response_metadata = [(k, str(v)) for k, v in response.headers.items()]
1613
+ resp, _ = self._interceptor.post_list_job_templates_with_metadata(
1614
+ resp, response_metadata
1615
+ )
1616
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
1617
+ logging.DEBUG
1618
+ ): # pragma: NO COVER
1619
+ try:
1620
+ response_payload = services.ListJobTemplatesResponse.to_json(
1621
+ response
1622
+ )
1623
+ except:
1624
+ response_payload = None
1625
+ http_response = {
1626
+ "payload": response_payload,
1627
+ "headers": dict(response.headers),
1628
+ "status": response.status_code,
1629
+ }
1630
+ _LOGGER.debug(
1631
+ "Received response for google.cloud.video.transcoder_v1.TranscoderServiceClient.list_job_templates",
1632
+ extra={
1633
+ "serviceName": "google.cloud.video.transcoder.v1.TranscoderService",
1634
+ "rpcName": "ListJobTemplates",
1635
+ "metadata": http_response["headers"],
1636
+ "httpResponse": http_response,
1637
+ },
1638
+ )
1639
+ return resp
1640
+
1641
+ @property
1642
+ def create_job(self) -> Callable[[services.CreateJobRequest], resources.Job]:
1643
+ # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
1644
+ # In C++ this would require a dynamic_cast
1645
+ return self._CreateJob(self._session, self._host, self._interceptor) # type: ignore
1646
+
1647
+ @property
1648
+ def create_job_template(
1649
+ self,
1650
+ ) -> Callable[[services.CreateJobTemplateRequest], resources.JobTemplate]:
1651
+ # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
1652
+ # In C++ this would require a dynamic_cast
1653
+ return self._CreateJobTemplate(self._session, self._host, self._interceptor) # type: ignore
1654
+
1655
+ @property
1656
+ def delete_job(self) -> Callable[[services.DeleteJobRequest], empty_pb2.Empty]:
1657
+ # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
1658
+ # In C++ this would require a dynamic_cast
1659
+ return self._DeleteJob(self._session, self._host, self._interceptor) # type: ignore
1660
+
1661
+ @property
1662
+ def delete_job_template(
1663
+ self,
1664
+ ) -> Callable[[services.DeleteJobTemplateRequest], empty_pb2.Empty]:
1665
+ # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
1666
+ # In C++ this would require a dynamic_cast
1667
+ return self._DeleteJobTemplate(self._session, self._host, self._interceptor) # type: ignore
1668
+
1669
+ @property
1670
+ def get_job(self) -> Callable[[services.GetJobRequest], resources.Job]:
1671
+ # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
1672
+ # In C++ this would require a dynamic_cast
1673
+ return self._GetJob(self._session, self._host, self._interceptor) # type: ignore
1674
+
1675
+ @property
1676
+ def get_job_template(
1677
+ self,
1678
+ ) -> Callable[[services.GetJobTemplateRequest], resources.JobTemplate]:
1679
+ # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
1680
+ # In C++ this would require a dynamic_cast
1681
+ return self._GetJobTemplate(self._session, self._host, self._interceptor) # type: ignore
1682
+
1683
+ @property
1684
+ def list_jobs(
1685
+ self,
1686
+ ) -> Callable[[services.ListJobsRequest], services.ListJobsResponse]:
1687
+ # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
1688
+ # In C++ this would require a dynamic_cast
1689
+ return self._ListJobs(self._session, self._host, self._interceptor) # type: ignore
1690
+
1691
+ @property
1692
+ def list_job_templates(
1693
+ self,
1694
+ ) -> Callable[
1695
+ [services.ListJobTemplatesRequest], services.ListJobTemplatesResponse
1696
+ ]:
1697
+ # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
1698
+ # In C++ this would require a dynamic_cast
1699
+ return self._ListJobTemplates(self._session, self._host, self._interceptor) # type: ignore
1700
+
1701
+ @property
1702
+ def kind(self) -> str:
1703
+ return "rest"
1704
+
1705
+ def close(self):
1706
+ self._session.close()
1707
+
1708
+
1709
+ __all__ = ("TranscoderServiceRestTransport",)