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