google_cloud_videointelligence_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 Cloud Video Intelligence API.
20///
21/// # Example
22/// ```
23/// # use google_cloud_videointelligence_v1::client::VideoIntelligenceService;
24/// use google_cloud_lro::Poller;
25/// async fn sample(
26/// ) -> anyhow::Result<()> {
27/// let client = VideoIntelligenceService::builder().build().await?;
28/// let response = client.annotate_video()
29/// /* set fields */
30/// .poller().until_done().await?;
31/// println!("response {:?}", response);
32/// Ok(())
33/// }
34/// ```
35///
36/// # Service Description
37///
38/// Service that implements the Video Intelligence API.
39///
40/// # Configuration
41///
42/// To configure `VideoIntelligenceService` use the `with_*` methods in the type returned
43/// by [builder()][VideoIntelligenceService::builder]. The default configuration should
44/// work for most applications. Common configuration changes include
45///
46/// * [with_endpoint()]: by default this client uses the global default endpoint
47/// (`https://videointelligence.googleapis.com`). Applications using regional
48/// endpoints or running in restricted networks (e.g. a network configured
49/// with [Private Google Access with VPC Service Controls]) may want to
50/// override this default.
51/// * [with_credentials()]: by default this client uses
52/// [Application Default Credentials]. Applications using custom
53/// authentication may need to override this default.
54///
55/// [with_endpoint()]: super::builder::video_intelligence_service::ClientBuilder::with_endpoint
56/// [with_credentials()]: super::builder::video_intelligence_service::ClientBuilder::with_credentials
57/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
58/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
59///
60/// # Pooling and Cloning
61///
62/// `VideoIntelligenceService` holds a connection pool internally, it is advised to
63/// create one and reuse it. You do not need to wrap `VideoIntelligenceService` in
64/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
65/// already uses an `Arc` internally.
66#[derive(Clone, Debug)]
67pub struct VideoIntelligenceService {
68 inner: std::sync::Arc<dyn super::stub::dynamic::VideoIntelligenceService>,
69}
70
71impl VideoIntelligenceService {
72 /// Returns a builder for [VideoIntelligenceService].
73 ///
74 /// ```
75 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
76 /// # use google_cloud_videointelligence_v1::client::VideoIntelligenceService;
77 /// let client = VideoIntelligenceService::builder().build().await?;
78 /// # Ok(()) }
79 /// ```
80 pub fn builder() -> super::builder::video_intelligence_service::ClientBuilder {
81 crate::new_client_builder(super::builder::video_intelligence_service::client::Factory)
82 }
83
84 /// Creates a new client from the provided stub.
85 ///
86 /// The most common case for calling this function is in tests mocking the
87 /// client's behavior.
88 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
89 where
90 T: super::stub::VideoIntelligenceService + 'static,
91 {
92 Self { inner: stub.into() }
93 }
94
95 pub(crate) async fn new(
96 config: gaxi::options::ClientConfig,
97 ) -> crate::ClientBuilderResult<Self> {
98 let inner = Self::build_inner(config).await?;
99 Ok(Self { inner })
100 }
101
102 async fn build_inner(
103 conf: gaxi::options::ClientConfig,
104 ) -> crate::ClientBuilderResult<
105 std::sync::Arc<dyn super::stub::dynamic::VideoIntelligenceService>,
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::VideoIntelligenceService> {
116 super::transport::VideoIntelligenceService::new(conf).await
117 }
118
119 async fn build_with_tracing(
120 conf: gaxi::options::ClientConfig,
121 ) -> crate::ClientBuilderResult<impl super::stub::VideoIntelligenceService> {
122 Self::build_transport(conf)
123 .await
124 .map(super::tracing::VideoIntelligenceService::new)
125 }
126
127 /// Performs asynchronous video annotation. Progress and results can be
128 /// retrieved through the `google.longrunning.Operations` interface.
129 /// `Operation.metadata` contains `AnnotateVideoProgress` (progress).
130 /// `Operation.response` contains `AnnotateVideoResponse` (results).
131 ///
132 /// # Long running operations
133 ///
134 /// This method is used to start, and/or poll a [long-running Operation].
135 /// The [Working with long-running operations] chapter in the [user guide]
136 /// covers these operations in detail.
137 ///
138 /// [long-running operation]: https://google.aip.dev/151
139 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
140 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
141 ///
142 /// # Example
143 /// ```
144 /// # use google_cloud_videointelligence_v1::client::VideoIntelligenceService;
145 /// use google_cloud_lro::Poller;
146 /// use google_cloud_videointelligence_v1::Result;
147 /// async fn sample(
148 /// client: &VideoIntelligenceService
149 /// ) -> Result<()> {
150 /// let response = client.annotate_video()
151 /// /* set fields */
152 /// .poller().until_done().await?;
153 /// println!("response {:?}", response);
154 /// Ok(())
155 /// }
156 /// ```
157 pub fn annotate_video(&self) -> super::builder::video_intelligence_service::AnnotateVideo {
158 super::builder::video_intelligence_service::AnnotateVideo::new(self.inner.clone())
159 }
160
161 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
162 ///
163 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
164 ///
165 /// # Example
166 /// ```
167 /// # use google_cloud_videointelligence_v1::client::VideoIntelligenceService;
168 /// use google_cloud_gax::paginator::ItemPaginator as _;
169 /// use google_cloud_videointelligence_v1::Result;
170 /// async fn sample(
171 /// client: &VideoIntelligenceService
172 /// ) -> Result<()> {
173 /// let mut list = client.list_operations()
174 /// /* set fields */
175 /// .by_item();
176 /// while let Some(item) = list.next().await.transpose()? {
177 /// println!("{:?}", item);
178 /// }
179 /// Ok(())
180 /// }
181 /// ```
182 pub fn list_operations(&self) -> super::builder::video_intelligence_service::ListOperations {
183 super::builder::video_intelligence_service::ListOperations::new(self.inner.clone())
184 }
185
186 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
187 ///
188 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
189 ///
190 /// # Example
191 /// ```
192 /// # use google_cloud_videointelligence_v1::client::VideoIntelligenceService;
193 /// use google_cloud_videointelligence_v1::Result;
194 /// async fn sample(
195 /// client: &VideoIntelligenceService
196 /// ) -> Result<()> {
197 /// let response = client.get_operation()
198 /// /* set fields */
199 /// .send().await?;
200 /// println!("response {:?}", response);
201 /// Ok(())
202 /// }
203 /// ```
204 pub fn get_operation(&self) -> super::builder::video_intelligence_service::GetOperation {
205 super::builder::video_intelligence_service::GetOperation::new(self.inner.clone())
206 }
207
208 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
209 ///
210 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
211 ///
212 /// # Example
213 /// ```
214 /// # use google_cloud_videointelligence_v1::client::VideoIntelligenceService;
215 /// use google_cloud_videointelligence_v1::Result;
216 /// async fn sample(
217 /// client: &VideoIntelligenceService
218 /// ) -> Result<()> {
219 /// client.delete_operation()
220 /// /* set fields */
221 /// .send().await?;
222 /// Ok(())
223 /// }
224 /// ```
225 pub fn delete_operation(&self) -> super::builder::video_intelligence_service::DeleteOperation {
226 super::builder::video_intelligence_service::DeleteOperation::new(self.inner.clone())
227 }
228
229 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
230 ///
231 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
232 ///
233 /// # Example
234 /// ```
235 /// # use google_cloud_videointelligence_v1::client::VideoIntelligenceService;
236 /// use google_cloud_videointelligence_v1::Result;
237 /// async fn sample(
238 /// client: &VideoIntelligenceService
239 /// ) -> Result<()> {
240 /// client.cancel_operation()
241 /// /* set fields */
242 /// .send().await?;
243 /// Ok(())
244 /// }
245 /// ```
246 pub fn cancel_operation(&self) -> super::builder::video_intelligence_service::CancelOperation {
247 super::builder::video_intelligence_service::CancelOperation::new(self.inner.clone())
248 }
249}