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() -> Result<(), Box<dyn std::error::Error>> {
26/// let client = VideoIntelligenceService::builder().build().await?;
27/// let response = client.annotate_video()
28/// /* set fields */
29/// .poller().until_done().await?;
30/// println!("response {:?}", response);
31/// # Ok(()) }
32/// ```
33///
34/// # Service Description
35///
36/// Service that implements the Video Intelligence API.
37///
38/// # Configuration
39///
40/// To configure `VideoIntelligenceService` use the `with_*` methods in the type returned
41/// by [builder()][VideoIntelligenceService::builder]. The default configuration should
42/// work for most applications. Common configuration changes include
43///
44/// * [with_endpoint()]: by default this client uses the global default endpoint
45/// (`https://videointelligence.googleapis.com`). Applications using regional
46/// endpoints or running in restricted networks (e.g. a network configured
47// with [Private Google Access with VPC Service Controls]) may want to
48/// override this default.
49/// * [with_credentials()]: by default this client uses
50/// [Application Default Credentials]. Applications using custom
51/// authentication may need to override this default.
52///
53/// [with_endpoint()]: super::builder::video_intelligence_service::ClientBuilder::with_endpoint
54/// [with_credentials()]: super::builder::video_intelligence_service::ClientBuilder::with_credentials
55/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
56/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
57///
58/// # Pooling and Cloning
59///
60/// `VideoIntelligenceService` holds a connection pool internally, it is advised to
61/// create one and reuse it. You do not need to wrap `VideoIntelligenceService` in
62/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
63/// already uses an `Arc` internally.
64#[derive(Clone, Debug)]
65pub struct VideoIntelligenceService {
66 inner: std::sync::Arc<dyn super::stub::dynamic::VideoIntelligenceService>,
67}
68
69impl VideoIntelligenceService {
70 /// Returns a builder for [VideoIntelligenceService].
71 ///
72 /// ```
73 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
74 /// # use google_cloud_videointelligence_v1::client::VideoIntelligenceService;
75 /// let client = VideoIntelligenceService::builder().build().await?;
76 /// # Ok(()) }
77 /// ```
78 pub fn builder() -> super::builder::video_intelligence_service::ClientBuilder {
79 crate::new_client_builder(super::builder::video_intelligence_service::client::Factory)
80 }
81
82 /// Creates a new client from the provided stub.
83 ///
84 /// The most common case for calling this function is in tests mocking the
85 /// client's behavior.
86 pub fn from_stub<T>(stub: T) -> Self
87 where
88 T: super::stub::VideoIntelligenceService + 'static,
89 {
90 Self {
91 inner: std::sync::Arc::new(stub),
92 }
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}