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() -> Result<(), Box<dyn std::error::Error>> {
26///     let client = TranscoderService::builder().build().await?;
27///     let parent = "parent_value";
28///     let mut list = client.list_jobs()
29///         .set_parent(parent)
30///         .by_item();
31///     while let Some(item) = list.next().await.transpose()? {
32///         println!("{:?}", item);
33///     }
34/// # Ok(()) }
35/// ```
36///
37/// # Service Description
38///
39/// Using the Transcoder API, you can queue asynchronous jobs for transcoding
40/// media into various output formats. Output formats may include different
41/// streaming standards such as HTTP Live Streaming (HLS) and Dynamic Adaptive
42/// Streaming over HTTP (DASH). You can also customize jobs using advanced
43/// features such as Digital Rights Management (DRM), audio equalization, content
44/// concatenation, and digital ad-stitch ready content generation.
45///
46/// # Configuration
47///
48/// To configure `TranscoderService` use the `with_*` methods in the type returned
49/// by [builder()][TranscoderService::builder]. The default configuration should
50/// work for most applications. Common configuration changes include
51///
52/// * [with_endpoint()]: by default this client uses the global default endpoint
53///   (`https://transcoder.googleapis.com`). Applications using regional
54///   endpoints or running in restricted networks (e.g. a network configured
55//    with [Private Google Access with VPC Service Controls]) may want to
56///   override this default.
57/// * [with_credentials()]: by default this client uses
58///   [Application Default Credentials]. Applications using custom
59///   authentication may need to override this default.
60///
61/// [with_endpoint()]: super::builder::transcoder_service::ClientBuilder::with_endpoint
62/// [with_credentials()]: super::builder::transcoder_service::ClientBuilder::with_credentials
63/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
64/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
65///
66/// # Pooling and Cloning
67///
68/// `TranscoderService` holds a connection pool internally, it is advised to
69/// create one and reuse it. You do not need to wrap `TranscoderService` in
70/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
71/// already uses an `Arc` internally.
72#[derive(Clone, Debug)]
73pub struct TranscoderService {
74    inner: std::sync::Arc<dyn super::stub::dynamic::TranscoderService>,
75}
76
77impl TranscoderService {
78    /// Returns a builder for [TranscoderService].
79    ///
80    /// ```
81    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
82    /// # use google_cloud_video_transcoder_v1::client::TranscoderService;
83    /// let client = TranscoderService::builder().build().await?;
84    /// # Ok(()) }
85    /// ```
86    pub fn builder() -> super::builder::transcoder_service::ClientBuilder {
87        crate::new_client_builder(super::builder::transcoder_service::client::Factory)
88    }
89
90    /// Creates a new client from the provided stub.
91    ///
92    /// The most common case for calling this function is in tests mocking the
93    /// client's behavior.
94    pub fn from_stub<T>(stub: T) -> Self
95    where
96        T: super::stub::TranscoderService + 'static,
97    {
98        Self {
99            inner: std::sync::Arc::new(stub),
100        }
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, name: &str
189    /// ) -> Result<()> {
190    ///     let response = client.get_job()
191    ///         .set_name(name)
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, name: &str
209    /// ) -> Result<()> {
210    ///     client.delete_job()
211    ///         .set_name(name)
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, name: &str
275    /// ) -> Result<()> {
276    ///     let response = client.get_job_template()
277    ///         .set_name(name)
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, name: &str
295    /// ) -> Result<()> {
296    ///     client.delete_job_template()
297    ///         .set_name(name)
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}