google_cloud_video_transcoder_v1/client.rs
1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16#![allow(rustdoc::redundant_explicit_links)]
17#![allow(rustdoc::broken_intra_doc_links)]
18
19/// Implements a client for the Transcoder API.
20///
21/// # Example
22/// ```
23/// # tokio_test::block_on(async {
24/// # use google_cloud_video_transcoder_v1::client::TranscoderService;
25/// let client = TranscoderService::builder().build().await?;
26/// // use `client` to make requests to the Transcoder API.
27/// # gax::client_builder::Result::<()>::Ok(()) });
28/// ```
29///
30/// # Service Description
31///
32/// Using the Transcoder API, you can queue asynchronous jobs for transcoding
33/// media into various output formats. Output formats may include different
34/// streaming standards such as HTTP Live Streaming (HLS) and Dynamic Adaptive
35/// Streaming over HTTP (DASH). You can also customize jobs using advanced
36/// features such as Digital Rights Management (DRM), audio equalization, content
37/// concatenation, and digital ad-stitch ready content generation.
38///
39/// # Configuration
40///
41/// To configure `TranscoderService` use the `with_*` methods in the type returned
42/// by [builder()][TranscoderService::builder]. The default configuration should
43/// work for most applications. Common configuration changes include
44///
45/// * [with_endpoint()]: by default this client uses the global default endpoint
46/// (`https://transcoder.googleapis.com`). Applications using regional
47/// endpoints or running in restricted networks (e.g. a network configured
48// with [Private Google Access with VPC Service Controls]) may want to
49/// override this default.
50/// * [with_credentials()]: by default this client uses
51/// [Application Default Credentials]. Applications using custom
52/// authentication may need to override this default.
53///
54/// [with_endpoint()]: super::builder::transcoder_service::ClientBuilder::with_endpoint
55/// [with_credentials()]: super::builder::transcoder_service::ClientBuilder::credentials
56/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
57/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
58///
59/// # Pooling and Cloning
60///
61/// `TranscoderService` holds a connection pool internally, it is advised to
62/// create one and the reuse it. You do not need to wrap `TranscoderService` in
63/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
64/// already uses an `Arc` internally.
65#[derive(Clone, Debug)]
66pub struct TranscoderService {
67 inner: std::sync::Arc<dyn super::stub::dynamic::TranscoderService>,
68}
69
70impl TranscoderService {
71 /// Returns a builder for [TranscoderService].
72 ///
73 /// ```
74 /// # tokio_test::block_on(async {
75 /// # use google_cloud_video_transcoder_v1::client::TranscoderService;
76 /// let client = TranscoderService::builder().build().await?;
77 /// # gax::client_builder::Result::<()>::Ok(()) });
78 /// ```
79 pub fn builder() -> super::builder::transcoder_service::ClientBuilder {
80 gax::client_builder::internal::new_builder(
81 super::builder::transcoder_service::client::Factory,
82 )
83 }
84
85 /// Creates a new client from the provided stub.
86 ///
87 /// The most common case for calling this function is in tests mocking the
88 /// client's behavior.
89 pub fn from_stub<T>(stub: T) -> Self
90 where
91 T: super::stub::TranscoderService + 'static,
92 {
93 Self {
94 inner: std::sync::Arc::new(stub),
95 }
96 }
97
98 pub(crate) async fn new(
99 config: gaxi::options::ClientConfig,
100 ) -> gax::client_builder::Result<Self> {
101 let inner = Self::build_inner(config).await?;
102 Ok(Self { inner })
103 }
104
105 async fn build_inner(
106 conf: gaxi::options::ClientConfig,
107 ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::TranscoderService>>
108 {
109 if gaxi::options::tracing_enabled(&conf) {
110 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
111 }
112 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
113 }
114
115 async fn build_transport(
116 conf: gaxi::options::ClientConfig,
117 ) -> gax::client_builder::Result<impl super::stub::TranscoderService> {
118 super::transport::TranscoderService::new(conf).await
119 }
120
121 async fn build_with_tracing(
122 conf: gaxi::options::ClientConfig,
123 ) -> gax::client_builder::Result<impl super::stub::TranscoderService> {
124 Self::build_transport(conf)
125 .await
126 .map(super::tracing::TranscoderService::new)
127 }
128
129 /// Creates a job in the specified region.
130 pub fn create_job(&self) -> super::builder::transcoder_service::CreateJob {
131 super::builder::transcoder_service::CreateJob::new(self.inner.clone())
132 }
133
134 /// Lists jobs in the specified region.
135 pub fn list_jobs(&self) -> super::builder::transcoder_service::ListJobs {
136 super::builder::transcoder_service::ListJobs::new(self.inner.clone())
137 }
138
139 /// Returns the job data.
140 pub fn get_job(&self) -> super::builder::transcoder_service::GetJob {
141 super::builder::transcoder_service::GetJob::new(self.inner.clone())
142 }
143
144 /// Deletes a job.
145 pub fn delete_job(&self) -> super::builder::transcoder_service::DeleteJob {
146 super::builder::transcoder_service::DeleteJob::new(self.inner.clone())
147 }
148
149 /// Creates a job template in the specified region.
150 pub fn create_job_template(&self) -> super::builder::transcoder_service::CreateJobTemplate {
151 super::builder::transcoder_service::CreateJobTemplate::new(self.inner.clone())
152 }
153
154 /// Lists job templates in the specified region.
155 pub fn list_job_templates(&self) -> super::builder::transcoder_service::ListJobTemplates {
156 super::builder::transcoder_service::ListJobTemplates::new(self.inner.clone())
157 }
158
159 /// Returns the job template data.
160 pub fn get_job_template(&self) -> super::builder::transcoder_service::GetJobTemplate {
161 super::builder::transcoder_service::GetJobTemplate::new(self.inner.clone())
162 }
163
164 /// Deletes a job template.
165 pub fn delete_job_template(&self) -> super::builder::transcoder_service::DeleteJobTemplate {
166 super::builder::transcoder_service::DeleteJobTemplate::new(self.inner.clone())
167 }
168}