Skip to main content

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