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/// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
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/// # 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 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
75 /// # use google_cloud_video_transcoder_v1::client::TranscoderService;
76 /// let client = TranscoderService::builder().build().await?;
77 /// # Ok(()) }
78 /// ```
79 pub fn builder() -> super::builder::transcoder_service::ClientBuilder {
80 crate::new_client_builder(super::builder::transcoder_service::client::Factory)
81 }
82
83 /// Creates a new client from the provided stub.
84 ///
85 /// The most common case for calling this function is in tests mocking the
86 /// client's behavior.
87 pub fn from_stub<T>(stub: T) -> Self
88 where
89 T: super::stub::TranscoderService + 'static,
90 {
91 Self {
92 inner: std::sync::Arc::new(stub),
93 }
94 }
95
96 pub(crate) async fn new(
97 config: gaxi::options::ClientConfig,
98 ) -> crate::ClientBuilderResult<Self> {
99 let inner = Self::build_inner(config).await?;
100 Ok(Self { inner })
101 }
102
103 async fn build_inner(
104 conf: gaxi::options::ClientConfig,
105 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::TranscoderService>>
106 {
107 if gaxi::options::tracing_enabled(&conf) {
108 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
109 }
110 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
111 }
112
113 async fn build_transport(
114 conf: gaxi::options::ClientConfig,
115 ) -> crate::ClientBuilderResult<impl super::stub::TranscoderService> {
116 super::transport::TranscoderService::new(conf).await
117 }
118
119 async fn build_with_tracing(
120 conf: gaxi::options::ClientConfig,
121 ) -> crate::ClientBuilderResult<impl super::stub::TranscoderService> {
122 Self::build_transport(conf)
123 .await
124 .map(super::tracing::TranscoderService::new)
125 }
126
127 /// Creates a job in the specified region.
128 pub fn create_job(&self) -> super::builder::transcoder_service::CreateJob {
129 super::builder::transcoder_service::CreateJob::new(self.inner.clone())
130 }
131
132 /// Lists jobs in the specified region.
133 pub fn list_jobs(&self) -> super::builder::transcoder_service::ListJobs {
134 super::builder::transcoder_service::ListJobs::new(self.inner.clone())
135 }
136
137 /// Returns the job data.
138 pub fn get_job(&self) -> super::builder::transcoder_service::GetJob {
139 super::builder::transcoder_service::GetJob::new(self.inner.clone())
140 }
141
142 /// Deletes a job.
143 pub fn delete_job(&self) -> super::builder::transcoder_service::DeleteJob {
144 super::builder::transcoder_service::DeleteJob::new(self.inner.clone())
145 }
146
147 /// Creates a job template in the specified region.
148 pub fn create_job_template(&self) -> super::builder::transcoder_service::CreateJobTemplate {
149 super::builder::transcoder_service::CreateJobTemplate::new(self.inner.clone())
150 }
151
152 /// Lists job templates in the specified region.
153 pub fn list_job_templates(&self) -> super::builder::transcoder_service::ListJobTemplates {
154 super::builder::transcoder_service::ListJobTemplates::new(self.inner.clone())
155 }
156
157 /// Returns the job template data.
158 pub fn get_job_template(&self) -> super::builder::transcoder_service::GetJobTemplate {
159 super::builder::transcoder_service::GetJobTemplate::new(self.inner.clone())
160 }
161
162 /// Deletes a job template.
163 pub fn delete_job_template(&self) -> super::builder::transcoder_service::DeleteJobTemplate {
164 super::builder::transcoder_service::DeleteJobTemplate::new(self.inner.clone())
165 }
166}