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::bare_urls)]
17#![allow(rustdoc::broken_intra_doc_links)]
18#![allow(rustdoc::invalid_html_tags)]
19#![allow(rustdoc::redundant_explicit_links)]
20
21/// Implements a client for the Transcoder API.
22///
23/// # Example
24/// ```
25/// # use google_cloud_video_transcoder_v1::client::TranscoderService;
26/// use google_cloud_gax::paginator::ItemPaginator as _;
27/// async fn sample(
28/// parent: &str,
29/// ) -> anyhow::Result<()> {
30/// let client = TranscoderService::builder().build().await?;
31/// let mut list = client.list_jobs()
32/// .set_parent(parent)
33/// .by_item();
34/// while let Some(item) = list.next().await.transpose()? {
35/// println!("{:?}", item);
36/// }
37/// Ok(())
38/// }
39/// ```
40///
41/// # Service Description
42///
43/// Using the Transcoder API, you can queue asynchronous jobs for transcoding
44/// media into various output formats. Output formats may include different
45/// streaming standards such as HTTP Live Streaming (HLS) and Dynamic Adaptive
46/// Streaming over HTTP (DASH). You can also customize jobs using advanced
47/// features such as Digital Rights Management (DRM), audio equalization, content
48/// concatenation, and digital ad-stitch ready content generation.
49///
50/// # Configuration
51///
52/// To configure `TranscoderService` use the `with_*` methods in the type returned
53/// by [builder()][TranscoderService::builder]. The default configuration should
54/// work for most applications. Common configuration changes include
55///
56/// * [with_endpoint()]: by default this client uses the global default endpoint
57/// (`https://transcoder.googleapis.com`). Applications using regional
58/// endpoints or running in restricted networks (e.g. a network configured
59/// with [Private Google Access with VPC Service Controls]) may want to
60/// override this default.
61/// * [with_credentials()]: by default this client uses
62/// [Application Default Credentials]. Applications using custom
63/// authentication may need to override this default.
64///
65/// [with_endpoint()]: super::builder::transcoder_service::ClientBuilder::with_endpoint
66/// [with_credentials()]: super::builder::transcoder_service::ClientBuilder::with_credentials
67/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
68/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
69///
70/// # Pooling and Cloning
71///
72/// `TranscoderService` holds a connection pool internally, it is advised to
73/// create one and reuse it. You do not need to wrap `TranscoderService` in
74/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
75/// already uses an `Arc` internally.
76#[derive(Clone, Debug)]
77pub struct TranscoderService {
78 inner: std::sync::Arc<dyn super::stub::dynamic::TranscoderService>,
79}
80
81impl TranscoderService {
82 /// Returns a builder for [TranscoderService].
83 ///
84 /// ```
85 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
86 /// # use google_cloud_video_transcoder_v1::client::TranscoderService;
87 /// let client = TranscoderService::builder().build().await?;
88 /// # Ok(()) }
89 /// ```
90 pub fn builder() -> super::builder::transcoder_service::ClientBuilder {
91 crate::new_client_builder(super::builder::transcoder_service::client::Factory)
92 }
93
94 /// Creates a new client from the provided stub.
95 ///
96 /// The most common case for calling this function is in tests mocking the
97 /// client's behavior.
98 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
99 where
100 T: super::stub::TranscoderService + 'static,
101 {
102 Self { inner: stub.into() }
103 }
104
105 pub(crate) async fn new(
106 config: gaxi::options::ClientConfig,
107 ) -> crate::ClientBuilderResult<Self> {
108 let inner = Self::build_inner(config).await?;
109 Ok(Self { inner })
110 }
111
112 async fn build_inner(
113 conf: gaxi::options::ClientConfig,
114 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::TranscoderService>>
115 {
116 if gaxi::options::tracing_enabled(&conf) {
117 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
118 }
119 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
120 }
121
122 async fn build_transport(
123 conf: gaxi::options::ClientConfig,
124 ) -> crate::ClientBuilderResult<impl super::stub::TranscoderService> {
125 super::transport::TranscoderService::new(conf).await
126 }
127
128 async fn build_with_tracing(
129 conf: gaxi::options::ClientConfig,
130 ) -> crate::ClientBuilderResult<impl super::stub::TranscoderService> {
131 Self::build_transport(conf)
132 .await
133 .map(super::tracing::TranscoderService::new)
134 }
135
136 /// Creates a job in the specified region.
137 ///
138 /// # Example
139 /// ```
140 /// # use google_cloud_video_transcoder_v1::client::TranscoderService;
141 /// use google_cloud_video_transcoder_v1::model::Job;
142 /// use google_cloud_video_transcoder_v1::Result;
143 /// async fn sample(
144 /// client: &TranscoderService, parent: &str
145 /// ) -> Result<()> {
146 /// let response = client.create_job()
147 /// .set_parent(parent)
148 /// .set_job(
149 /// Job::new()/* set fields */
150 /// )
151 /// .send().await?;
152 /// println!("response {:?}", response);
153 /// Ok(())
154 /// }
155 /// ```
156 pub fn create_job(&self) -> super::builder::transcoder_service::CreateJob {
157 super::builder::transcoder_service::CreateJob::new(self.inner.clone())
158 }
159
160 /// Lists jobs in the specified region.
161 ///
162 /// # Example
163 /// ```
164 /// # use google_cloud_video_transcoder_v1::client::TranscoderService;
165 /// use google_cloud_gax::paginator::ItemPaginator as _;
166 /// use google_cloud_video_transcoder_v1::Result;
167 /// async fn sample(
168 /// client: &TranscoderService, parent: &str
169 /// ) -> Result<()> {
170 /// let mut list = client.list_jobs()
171 /// .set_parent(parent)
172 /// .by_item();
173 /// while let Some(item) = list.next().await.transpose()? {
174 /// println!("{:?}", item);
175 /// }
176 /// Ok(())
177 /// }
178 /// ```
179 pub fn list_jobs(&self) -> super::builder::transcoder_service::ListJobs {
180 super::builder::transcoder_service::ListJobs::new(self.inner.clone())
181 }
182
183 /// Returns the job data.
184 ///
185 /// # Example
186 /// ```
187 /// # use google_cloud_video_transcoder_v1::client::TranscoderService;
188 /// use google_cloud_video_transcoder_v1::Result;
189 /// async fn sample(
190 /// client: &TranscoderService, project_id: &str, location_id: &str, job_id: &str
191 /// ) -> Result<()> {
192 /// let response = client.get_job()
193 /// .set_name(format!("projects/{project_id}/locations/{location_id}/jobs/{job_id}"))
194 /// .send().await?;
195 /// println!("response {:?}", response);
196 /// Ok(())
197 /// }
198 /// ```
199 pub fn get_job(&self) -> super::builder::transcoder_service::GetJob {
200 super::builder::transcoder_service::GetJob::new(self.inner.clone())
201 }
202
203 /// Deletes a job.
204 ///
205 /// # Example
206 /// ```
207 /// # use google_cloud_video_transcoder_v1::client::TranscoderService;
208 /// use google_cloud_video_transcoder_v1::Result;
209 /// async fn sample(
210 /// client: &TranscoderService, project_id: &str, location_id: &str, job_id: &str
211 /// ) -> Result<()> {
212 /// client.delete_job()
213 /// .set_name(format!("projects/{project_id}/locations/{location_id}/jobs/{job_id}"))
214 /// .send().await?;
215 /// Ok(())
216 /// }
217 /// ```
218 pub fn delete_job(&self) -> super::builder::transcoder_service::DeleteJob {
219 super::builder::transcoder_service::DeleteJob::new(self.inner.clone())
220 }
221
222 /// Creates a job template in the specified region.
223 ///
224 /// # Example
225 /// ```
226 /// # use google_cloud_video_transcoder_v1::client::TranscoderService;
227 /// use google_cloud_video_transcoder_v1::model::JobTemplate;
228 /// use google_cloud_video_transcoder_v1::Result;
229 /// async fn sample(
230 /// client: &TranscoderService, parent: &str
231 /// ) -> Result<()> {
232 /// let response = client.create_job_template()
233 /// .set_parent(parent)
234 /// .set_job_template(
235 /// JobTemplate::new()/* set fields */
236 /// )
237 /// .send().await?;
238 /// println!("response {:?}", response);
239 /// Ok(())
240 /// }
241 /// ```
242 pub fn create_job_template(&self) -> super::builder::transcoder_service::CreateJobTemplate {
243 super::builder::transcoder_service::CreateJobTemplate::new(self.inner.clone())
244 }
245
246 /// Lists job templates in the specified region.
247 ///
248 /// # Example
249 /// ```
250 /// # use google_cloud_video_transcoder_v1::client::TranscoderService;
251 /// use google_cloud_gax::paginator::ItemPaginator as _;
252 /// use google_cloud_video_transcoder_v1::Result;
253 /// async fn sample(
254 /// client: &TranscoderService, parent: &str
255 /// ) -> Result<()> {
256 /// let mut list = client.list_job_templates()
257 /// .set_parent(parent)
258 /// .by_item();
259 /// while let Some(item) = list.next().await.transpose()? {
260 /// println!("{:?}", item);
261 /// }
262 /// Ok(())
263 /// }
264 /// ```
265 pub fn list_job_templates(&self) -> super::builder::transcoder_service::ListJobTemplates {
266 super::builder::transcoder_service::ListJobTemplates::new(self.inner.clone())
267 }
268
269 /// Returns the job template data.
270 ///
271 /// # Example
272 /// ```
273 /// # use google_cloud_video_transcoder_v1::client::TranscoderService;
274 /// use google_cloud_video_transcoder_v1::Result;
275 /// async fn sample(
276 /// client: &TranscoderService, project_id: &str, location_id: &str, job_template_id: &str
277 /// ) -> Result<()> {
278 /// let response = client.get_job_template()
279 /// .set_name(format!("projects/{project_id}/locations/{location_id}/jobTemplates/{job_template_id}"))
280 /// .send().await?;
281 /// println!("response {:?}", response);
282 /// Ok(())
283 /// }
284 /// ```
285 pub fn get_job_template(&self) -> super::builder::transcoder_service::GetJobTemplate {
286 super::builder::transcoder_service::GetJobTemplate::new(self.inner.clone())
287 }
288
289 /// Deletes a job template.
290 ///
291 /// # Example
292 /// ```
293 /// # use google_cloud_video_transcoder_v1::client::TranscoderService;
294 /// use google_cloud_video_transcoder_v1::Result;
295 /// async fn sample(
296 /// client: &TranscoderService, project_id: &str, location_id: &str, job_template_id: &str
297 /// ) -> Result<()> {
298 /// client.delete_job_template()
299 /// .set_name(format!("projects/{project_id}/locations/{location_id}/jobTemplates/{job_template_id}"))
300 /// .send().await?;
301 /// Ok(())
302 /// }
303 /// ```
304 pub fn delete_job_template(&self) -> super::builder::transcoder_service::DeleteJobTemplate {
305 super::builder::transcoder_service::DeleteJobTemplate::new(self.inner.clone())
306 }
307}