google_cloud_documentai_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 Document AI API.
20///
21/// # Example
22/// ```
23/// # use google_cloud_documentai_v1::client::DocumentProcessorService;
24/// use google_cloud_gax::paginator::ItemPaginator as _;
25/// async fn sample(
26/// project_id: &str,
27/// location_id: &str,
28/// ) -> anyhow::Result<()> {
29/// let client = DocumentProcessorService::builder().build().await?;
30/// let mut list = client.list_processor_types()
31/// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
32/// .by_item();
33/// while let Some(item) = list.next().await.transpose()? {
34/// println!("{:?}", item);
35/// }
36/// Ok(())
37/// }
38/// ```
39///
40/// # Service Description
41///
42/// Service to call Document AI to process documents according to the
43/// processor's definition. Processors are built using state-of-the-art Google
44/// AI such as natural language, computer vision, and translation to extract
45/// structured information from unstructured or semi-structured documents.
46///
47/// # Configuration
48///
49/// To configure `DocumentProcessorService` use the `with_*` methods in the type returned
50/// by [builder()][DocumentProcessorService::builder]. The default configuration should
51/// work for most applications. Common configuration changes include
52///
53/// * [with_endpoint()]: by default this client uses the global default endpoint
54/// (`https://documentai.googleapis.com`). Applications using regional
55/// endpoints or running in restricted networks (e.g. a network configured
56// with [Private Google Access with VPC Service Controls]) may want to
57/// override this default.
58/// * [with_credentials()]: by default this client uses
59/// [Application Default Credentials]. Applications using custom
60/// authentication may need to override this default.
61///
62/// [with_endpoint()]: super::builder::document_processor_service::ClientBuilder::with_endpoint
63/// [with_credentials()]: super::builder::document_processor_service::ClientBuilder::with_credentials
64/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
65/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
66///
67/// # Pooling and Cloning
68///
69/// `DocumentProcessorService` holds a connection pool internally, it is advised to
70/// create one and reuse it. You do not need to wrap `DocumentProcessorService` in
71/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
72/// already uses an `Arc` internally.
73#[derive(Clone, Debug)]
74pub struct DocumentProcessorService {
75 inner: std::sync::Arc<dyn super::stub::dynamic::DocumentProcessorService>,
76}
77
78impl DocumentProcessorService {
79 /// Returns a builder for [DocumentProcessorService].
80 ///
81 /// ```
82 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
83 /// # use google_cloud_documentai_v1::client::DocumentProcessorService;
84 /// let client = DocumentProcessorService::builder().build().await?;
85 /// # Ok(()) }
86 /// ```
87 pub fn builder() -> super::builder::document_processor_service::ClientBuilder {
88 crate::new_client_builder(super::builder::document_processor_service::client::Factory)
89 }
90
91 /// Creates a new client from the provided stub.
92 ///
93 /// The most common case for calling this function is in tests mocking the
94 /// client's behavior.
95 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
96 where
97 T: super::stub::DocumentProcessorService + 'static,
98 {
99 Self { inner: stub.into() }
100 }
101
102 pub(crate) async fn new(
103 config: gaxi::options::ClientConfig,
104 ) -> crate::ClientBuilderResult<Self> {
105 let inner = Self::build_inner(config).await?;
106 Ok(Self { inner })
107 }
108
109 async fn build_inner(
110 conf: gaxi::options::ClientConfig,
111 ) -> crate::ClientBuilderResult<
112 std::sync::Arc<dyn super::stub::dynamic::DocumentProcessorService>,
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::DocumentProcessorService> {
123 super::transport::DocumentProcessorService::new(conf).await
124 }
125
126 async fn build_with_tracing(
127 conf: gaxi::options::ClientConfig,
128 ) -> crate::ClientBuilderResult<impl super::stub::DocumentProcessorService> {
129 Self::build_transport(conf)
130 .await
131 .map(super::tracing::DocumentProcessorService::new)
132 }
133
134 /// Processes a single document.
135 ///
136 /// # Example
137 /// ```
138 /// # use google_cloud_documentai_v1::client::DocumentProcessorService;
139 /// use google_cloud_documentai_v1::Result;
140 /// async fn sample(
141 /// client: &DocumentProcessorService
142 /// ) -> Result<()> {
143 /// let response = client.process_document()
144 /// /* set fields */
145 /// .send().await?;
146 /// println!("response {:?}", response);
147 /// Ok(())
148 /// }
149 /// ```
150 pub fn process_document(&self) -> super::builder::document_processor_service::ProcessDocument {
151 super::builder::document_processor_service::ProcessDocument::new(self.inner.clone())
152 }
153
154 /// LRO endpoint to batch process many documents. The output is written
155 /// to Cloud Storage as JSON in the [Document] format.
156 ///
157 /// # Long running operations
158 ///
159 /// This method is used to start, and/or poll a [long-running Operation].
160 /// The [Working with long-running operations] chapter in the [user guide]
161 /// covers these operations in detail.
162 ///
163 /// [long-running operation]: https://google.aip.dev/151
164 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
165 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
166 ///
167 /// # Example
168 /// ```
169 /// # use google_cloud_documentai_v1::client::DocumentProcessorService;
170 /// use google_cloud_lro::Poller;
171 /// use google_cloud_documentai_v1::Result;
172 /// async fn sample(
173 /// client: &DocumentProcessorService
174 /// ) -> Result<()> {
175 /// let response = client.batch_process_documents()
176 /// /* set fields */
177 /// .poller().until_done().await?;
178 /// println!("response {:?}", response);
179 /// Ok(())
180 /// }
181 /// ```
182 pub fn batch_process_documents(
183 &self,
184 ) -> super::builder::document_processor_service::BatchProcessDocuments {
185 super::builder::document_processor_service::BatchProcessDocuments::new(self.inner.clone())
186 }
187
188 /// Fetches processor types. Note that we don't use
189 /// [ListProcessorTypes][google.cloud.documentai.v1.DocumentProcessorService.ListProcessorTypes]
190 /// here, because it isn't paginated.
191 ///
192 /// [google.cloud.documentai.v1.DocumentProcessorService.ListProcessorTypes]: crate::client::DocumentProcessorService::list_processor_types
193 ///
194 /// # Example
195 /// ```
196 /// # use google_cloud_documentai_v1::client::DocumentProcessorService;
197 /// use google_cloud_documentai_v1::Result;
198 /// async fn sample(
199 /// client: &DocumentProcessorService
200 /// ) -> Result<()> {
201 /// let response = client.fetch_processor_types()
202 /// /* set fields */
203 /// .send().await?;
204 /// println!("response {:?}", response);
205 /// Ok(())
206 /// }
207 /// ```
208 pub fn fetch_processor_types(
209 &self,
210 ) -> super::builder::document_processor_service::FetchProcessorTypes {
211 super::builder::document_processor_service::FetchProcessorTypes::new(self.inner.clone())
212 }
213
214 /// Lists the processor types that exist.
215 ///
216 /// # Example
217 /// ```
218 /// # use google_cloud_documentai_v1::client::DocumentProcessorService;
219 /// use google_cloud_gax::paginator::ItemPaginator as _;
220 /// use google_cloud_documentai_v1::Result;
221 /// async fn sample(
222 /// client: &DocumentProcessorService, project_id: &str, location_id: &str
223 /// ) -> Result<()> {
224 /// let mut list = client.list_processor_types()
225 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
226 /// .by_item();
227 /// while let Some(item) = list.next().await.transpose()? {
228 /// println!("{:?}", item);
229 /// }
230 /// Ok(())
231 /// }
232 /// ```
233 pub fn list_processor_types(
234 &self,
235 ) -> super::builder::document_processor_service::ListProcessorTypes {
236 super::builder::document_processor_service::ListProcessorTypes::new(self.inner.clone())
237 }
238
239 /// Gets a processor type detail.
240 ///
241 /// # Example
242 /// ```
243 /// # use google_cloud_documentai_v1::client::DocumentProcessorService;
244 /// use google_cloud_documentai_v1::Result;
245 /// async fn sample(
246 /// client: &DocumentProcessorService, project_id: &str, location_id: &str, processor_type_id: &str
247 /// ) -> Result<()> {
248 /// let response = client.get_processor_type()
249 /// .set_name(format!("projects/{project_id}/locations/{location_id}/processorTypes/{processor_type_id}"))
250 /// .send().await?;
251 /// println!("response {:?}", response);
252 /// Ok(())
253 /// }
254 /// ```
255 pub fn get_processor_type(
256 &self,
257 ) -> super::builder::document_processor_service::GetProcessorType {
258 super::builder::document_processor_service::GetProcessorType::new(self.inner.clone())
259 }
260
261 /// Lists all processors which belong to this project.
262 ///
263 /// # Example
264 /// ```
265 /// # use google_cloud_documentai_v1::client::DocumentProcessorService;
266 /// use google_cloud_gax::paginator::ItemPaginator as _;
267 /// use google_cloud_documentai_v1::Result;
268 /// async fn sample(
269 /// client: &DocumentProcessorService, project_id: &str, location_id: &str
270 /// ) -> Result<()> {
271 /// let mut list = client.list_processors()
272 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
273 /// .by_item();
274 /// while let Some(item) = list.next().await.transpose()? {
275 /// println!("{:?}", item);
276 /// }
277 /// Ok(())
278 /// }
279 /// ```
280 pub fn list_processors(&self) -> super::builder::document_processor_service::ListProcessors {
281 super::builder::document_processor_service::ListProcessors::new(self.inner.clone())
282 }
283
284 /// Gets a processor detail.
285 ///
286 /// # Example
287 /// ```
288 /// # use google_cloud_documentai_v1::client::DocumentProcessorService;
289 /// use google_cloud_documentai_v1::Result;
290 /// async fn sample(
291 /// client: &DocumentProcessorService, project_id: &str, location_id: &str, processor_id: &str
292 /// ) -> Result<()> {
293 /// let response = client.get_processor()
294 /// .set_name(format!("projects/{project_id}/locations/{location_id}/processors/{processor_id}"))
295 /// .send().await?;
296 /// println!("response {:?}", response);
297 /// Ok(())
298 /// }
299 /// ```
300 pub fn get_processor(&self) -> super::builder::document_processor_service::GetProcessor {
301 super::builder::document_processor_service::GetProcessor::new(self.inner.clone())
302 }
303
304 /// Trains a new processor version.
305 /// Operation metadata is returned as
306 /// [TrainProcessorVersionMetadata][google.cloud.documentai.v1.TrainProcessorVersionMetadata].
307 ///
308 /// [google.cloud.documentai.v1.TrainProcessorVersionMetadata]: crate::model::TrainProcessorVersionMetadata
309 ///
310 /// # Long running operations
311 ///
312 /// This method is used to start, and/or poll a [long-running Operation].
313 /// The [Working with long-running operations] chapter in the [user guide]
314 /// covers these operations in detail.
315 ///
316 /// [long-running operation]: https://google.aip.dev/151
317 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
318 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
319 ///
320 /// # Example
321 /// ```
322 /// # use google_cloud_documentai_v1::client::DocumentProcessorService;
323 /// use google_cloud_lro::Poller;
324 /// use google_cloud_documentai_v1::Result;
325 /// async fn sample(
326 /// client: &DocumentProcessorService
327 /// ) -> Result<()> {
328 /// let response = client.train_processor_version()
329 /// /* set fields */
330 /// .poller().until_done().await?;
331 /// println!("response {:?}", response);
332 /// Ok(())
333 /// }
334 /// ```
335 pub fn train_processor_version(
336 &self,
337 ) -> super::builder::document_processor_service::TrainProcessorVersion {
338 super::builder::document_processor_service::TrainProcessorVersion::new(self.inner.clone())
339 }
340
341 /// Gets a processor version detail.
342 ///
343 /// # Example
344 /// ```
345 /// # use google_cloud_documentai_v1::client::DocumentProcessorService;
346 /// use google_cloud_documentai_v1::Result;
347 /// async fn sample(
348 /// client: &DocumentProcessorService, project_id: &str, location_id: &str, processor_id: &str, processor_version_id: &str
349 /// ) -> Result<()> {
350 /// let response = client.get_processor_version()
351 /// .set_name(format!("projects/{project_id}/locations/{location_id}/processors/{processor_id}/processorVersions/{processor_version_id}"))
352 /// .send().await?;
353 /// println!("response {:?}", response);
354 /// Ok(())
355 /// }
356 /// ```
357 pub fn get_processor_version(
358 &self,
359 ) -> super::builder::document_processor_service::GetProcessorVersion {
360 super::builder::document_processor_service::GetProcessorVersion::new(self.inner.clone())
361 }
362
363 /// Lists all versions of a processor.
364 ///
365 /// # Example
366 /// ```
367 /// # use google_cloud_documentai_v1::client::DocumentProcessorService;
368 /// use google_cloud_gax::paginator::ItemPaginator as _;
369 /// use google_cloud_documentai_v1::Result;
370 /// async fn sample(
371 /// client: &DocumentProcessorService, project_id: &str, location_id: &str, processor_id: &str
372 /// ) -> Result<()> {
373 /// let mut list = client.list_processor_versions()
374 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/processors/{processor_id}"))
375 /// .by_item();
376 /// while let Some(item) = list.next().await.transpose()? {
377 /// println!("{:?}", item);
378 /// }
379 /// Ok(())
380 /// }
381 /// ```
382 pub fn list_processor_versions(
383 &self,
384 ) -> super::builder::document_processor_service::ListProcessorVersions {
385 super::builder::document_processor_service::ListProcessorVersions::new(self.inner.clone())
386 }
387
388 /// Deletes the processor version, all artifacts under the processor version
389 /// will be deleted.
390 ///
391 /// # Long running operations
392 ///
393 /// This method is used to start, and/or poll a [long-running Operation].
394 /// The [Working with long-running operations] chapter in the [user guide]
395 /// covers these operations in detail.
396 ///
397 /// [long-running operation]: https://google.aip.dev/151
398 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
399 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
400 ///
401 /// # Example
402 /// ```
403 /// # use google_cloud_documentai_v1::client::DocumentProcessorService;
404 /// use google_cloud_lro::Poller;
405 /// use google_cloud_documentai_v1::Result;
406 /// async fn sample(
407 /// client: &DocumentProcessorService, project_id: &str, location_id: &str, processor_id: &str, processor_version_id: &str
408 /// ) -> Result<()> {
409 /// client.delete_processor_version()
410 /// .set_name(format!("projects/{project_id}/locations/{location_id}/processors/{processor_id}/processorVersions/{processor_version_id}"))
411 /// .poller().until_done().await?;
412 /// Ok(())
413 /// }
414 /// ```
415 pub fn delete_processor_version(
416 &self,
417 ) -> super::builder::document_processor_service::DeleteProcessorVersion {
418 super::builder::document_processor_service::DeleteProcessorVersion::new(self.inner.clone())
419 }
420
421 /// Deploys the processor version.
422 ///
423 /// # Long running operations
424 ///
425 /// This method is used to start, and/or poll a [long-running Operation].
426 /// The [Working with long-running operations] chapter in the [user guide]
427 /// covers these operations in detail.
428 ///
429 /// [long-running operation]: https://google.aip.dev/151
430 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
431 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
432 ///
433 /// # Example
434 /// ```
435 /// # use google_cloud_documentai_v1::client::DocumentProcessorService;
436 /// use google_cloud_lro::Poller;
437 /// use google_cloud_documentai_v1::Result;
438 /// async fn sample(
439 /// client: &DocumentProcessorService
440 /// ) -> Result<()> {
441 /// let response = client.deploy_processor_version()
442 /// /* set fields */
443 /// .poller().until_done().await?;
444 /// println!("response {:?}", response);
445 /// Ok(())
446 /// }
447 /// ```
448 pub fn deploy_processor_version(
449 &self,
450 ) -> super::builder::document_processor_service::DeployProcessorVersion {
451 super::builder::document_processor_service::DeployProcessorVersion::new(self.inner.clone())
452 }
453
454 /// Undeploys the processor version.
455 ///
456 /// # Long running operations
457 ///
458 /// This method is used to start, and/or poll a [long-running Operation].
459 /// The [Working with long-running operations] chapter in the [user guide]
460 /// covers these operations in detail.
461 ///
462 /// [long-running operation]: https://google.aip.dev/151
463 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
464 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
465 ///
466 /// # Example
467 /// ```
468 /// # use google_cloud_documentai_v1::client::DocumentProcessorService;
469 /// use google_cloud_lro::Poller;
470 /// use google_cloud_documentai_v1::Result;
471 /// async fn sample(
472 /// client: &DocumentProcessorService
473 /// ) -> Result<()> {
474 /// let response = client.undeploy_processor_version()
475 /// /* set fields */
476 /// .poller().until_done().await?;
477 /// println!("response {:?}", response);
478 /// Ok(())
479 /// }
480 /// ```
481 pub fn undeploy_processor_version(
482 &self,
483 ) -> super::builder::document_processor_service::UndeployProcessorVersion {
484 super::builder::document_processor_service::UndeployProcessorVersion::new(
485 self.inner.clone(),
486 )
487 }
488
489 /// Creates a processor from the
490 /// [ProcessorType][google.cloud.documentai.v1.ProcessorType] provided. The
491 /// processor will be at `ENABLED` state by default after its creation. Note
492 /// that this method requires the `documentai.processors.create` permission on
493 /// the project, which is highly privileged. A user or service account with
494 /// this permission can create new processors that can interact with any gcs
495 /// bucket in your project.
496 ///
497 /// [google.cloud.documentai.v1.ProcessorType]: crate::model::ProcessorType
498 ///
499 /// # Example
500 /// ```
501 /// # use google_cloud_documentai_v1::client::DocumentProcessorService;
502 /// use google_cloud_documentai_v1::model::Processor;
503 /// use google_cloud_documentai_v1::Result;
504 /// async fn sample(
505 /// client: &DocumentProcessorService, project_id: &str, location_id: &str
506 /// ) -> Result<()> {
507 /// let response = client.create_processor()
508 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
509 /// .set_processor(
510 /// Processor::new()/* set fields */
511 /// )
512 /// .send().await?;
513 /// println!("response {:?}", response);
514 /// Ok(())
515 /// }
516 /// ```
517 pub fn create_processor(&self) -> super::builder::document_processor_service::CreateProcessor {
518 super::builder::document_processor_service::CreateProcessor::new(self.inner.clone())
519 }
520
521 /// Deletes the processor, unloads all deployed model artifacts if it was
522 /// enabled and then deletes all artifacts associated with this processor.
523 ///
524 /// # Long running operations
525 ///
526 /// This method is used to start, and/or poll a [long-running Operation].
527 /// The [Working with long-running operations] chapter in the [user guide]
528 /// covers these operations in detail.
529 ///
530 /// [long-running operation]: https://google.aip.dev/151
531 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
532 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
533 ///
534 /// # Example
535 /// ```
536 /// # use google_cloud_documentai_v1::client::DocumentProcessorService;
537 /// use google_cloud_lro::Poller;
538 /// use google_cloud_documentai_v1::Result;
539 /// async fn sample(
540 /// client: &DocumentProcessorService, project_id: &str, location_id: &str, processor_id: &str
541 /// ) -> Result<()> {
542 /// client.delete_processor()
543 /// .set_name(format!("projects/{project_id}/locations/{location_id}/processors/{processor_id}"))
544 /// .poller().until_done().await?;
545 /// Ok(())
546 /// }
547 /// ```
548 pub fn delete_processor(&self) -> super::builder::document_processor_service::DeleteProcessor {
549 super::builder::document_processor_service::DeleteProcessor::new(self.inner.clone())
550 }
551
552 /// Enables a processor
553 ///
554 /// # Long running operations
555 ///
556 /// This method is used to start, and/or poll a [long-running Operation].
557 /// The [Working with long-running operations] chapter in the [user guide]
558 /// covers these operations in detail.
559 ///
560 /// [long-running operation]: https://google.aip.dev/151
561 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
562 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
563 ///
564 /// # Example
565 /// ```
566 /// # use google_cloud_documentai_v1::client::DocumentProcessorService;
567 /// use google_cloud_lro::Poller;
568 /// use google_cloud_documentai_v1::Result;
569 /// async fn sample(
570 /// client: &DocumentProcessorService
571 /// ) -> Result<()> {
572 /// let response = client.enable_processor()
573 /// /* set fields */
574 /// .poller().until_done().await?;
575 /// println!("response {:?}", response);
576 /// Ok(())
577 /// }
578 /// ```
579 pub fn enable_processor(&self) -> super::builder::document_processor_service::EnableProcessor {
580 super::builder::document_processor_service::EnableProcessor::new(self.inner.clone())
581 }
582
583 /// Disables a processor
584 ///
585 /// # Long running operations
586 ///
587 /// This method is used to start, and/or poll a [long-running Operation].
588 /// The [Working with long-running operations] chapter in the [user guide]
589 /// covers these operations in detail.
590 ///
591 /// [long-running operation]: https://google.aip.dev/151
592 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
593 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
594 ///
595 /// # Example
596 /// ```
597 /// # use google_cloud_documentai_v1::client::DocumentProcessorService;
598 /// use google_cloud_lro::Poller;
599 /// use google_cloud_documentai_v1::Result;
600 /// async fn sample(
601 /// client: &DocumentProcessorService
602 /// ) -> Result<()> {
603 /// let response = client.disable_processor()
604 /// /* set fields */
605 /// .poller().until_done().await?;
606 /// println!("response {:?}", response);
607 /// Ok(())
608 /// }
609 /// ```
610 pub fn disable_processor(
611 &self,
612 ) -> super::builder::document_processor_service::DisableProcessor {
613 super::builder::document_processor_service::DisableProcessor::new(self.inner.clone())
614 }
615
616 /// Set the default (active) version of a
617 /// [Processor][google.cloud.documentai.v1.Processor] that will be used in
618 /// [ProcessDocument][google.cloud.documentai.v1.DocumentProcessorService.ProcessDocument]
619 /// and
620 /// [BatchProcessDocuments][google.cloud.documentai.v1.DocumentProcessorService.BatchProcessDocuments].
621 ///
622 /// [google.cloud.documentai.v1.DocumentProcessorService.BatchProcessDocuments]: crate::client::DocumentProcessorService::batch_process_documents
623 /// [google.cloud.documentai.v1.DocumentProcessorService.ProcessDocument]: crate::client::DocumentProcessorService::process_document
624 /// [google.cloud.documentai.v1.Processor]: crate::model::Processor
625 ///
626 /// # Long running operations
627 ///
628 /// This method is used to start, and/or poll a [long-running Operation].
629 /// The [Working with long-running operations] chapter in the [user guide]
630 /// covers these operations in detail.
631 ///
632 /// [long-running operation]: https://google.aip.dev/151
633 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
634 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
635 ///
636 /// # Example
637 /// ```
638 /// # use google_cloud_documentai_v1::client::DocumentProcessorService;
639 /// use google_cloud_lro::Poller;
640 /// use google_cloud_documentai_v1::Result;
641 /// async fn sample(
642 /// client: &DocumentProcessorService
643 /// ) -> Result<()> {
644 /// let response = client.set_default_processor_version()
645 /// /* set fields */
646 /// .poller().until_done().await?;
647 /// println!("response {:?}", response);
648 /// Ok(())
649 /// }
650 /// ```
651 pub fn set_default_processor_version(
652 &self,
653 ) -> super::builder::document_processor_service::SetDefaultProcessorVersion {
654 super::builder::document_processor_service::SetDefaultProcessorVersion::new(
655 self.inner.clone(),
656 )
657 }
658
659 /// Send a document for Human Review. The input document should be processed by
660 /// the specified processor.
661 ///
662 /// # Long running operations
663 ///
664 /// This method is used to start, and/or poll a [long-running Operation].
665 /// The [Working with long-running operations] chapter in the [user guide]
666 /// covers these operations in detail.
667 ///
668 /// [long-running operation]: https://google.aip.dev/151
669 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
670 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
671 ///
672 /// # Example
673 /// ```
674 /// # use google_cloud_documentai_v1::client::DocumentProcessorService;
675 /// use google_cloud_lro::Poller;
676 /// use google_cloud_documentai_v1::Result;
677 /// async fn sample(
678 /// client: &DocumentProcessorService
679 /// ) -> Result<()> {
680 /// let response = client.review_document()
681 /// /* set fields */
682 /// .poller().until_done().await?;
683 /// println!("response {:?}", response);
684 /// Ok(())
685 /// }
686 /// ```
687 pub fn review_document(&self) -> super::builder::document_processor_service::ReviewDocument {
688 super::builder::document_processor_service::ReviewDocument::new(self.inner.clone())
689 }
690
691 /// Evaluates a ProcessorVersion against annotated documents, producing an
692 /// Evaluation.
693 ///
694 /// # Long running operations
695 ///
696 /// This method is used to start, and/or poll a [long-running Operation].
697 /// The [Working with long-running operations] chapter in the [user guide]
698 /// covers these operations in detail.
699 ///
700 /// [long-running operation]: https://google.aip.dev/151
701 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
702 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
703 ///
704 /// # Example
705 /// ```
706 /// # use google_cloud_documentai_v1::client::DocumentProcessorService;
707 /// use google_cloud_lro::Poller;
708 /// use google_cloud_documentai_v1::Result;
709 /// async fn sample(
710 /// client: &DocumentProcessorService
711 /// ) -> Result<()> {
712 /// let response = client.evaluate_processor_version()
713 /// /* set fields */
714 /// .poller().until_done().await?;
715 /// println!("response {:?}", response);
716 /// Ok(())
717 /// }
718 /// ```
719 pub fn evaluate_processor_version(
720 &self,
721 ) -> super::builder::document_processor_service::EvaluateProcessorVersion {
722 super::builder::document_processor_service::EvaluateProcessorVersion::new(
723 self.inner.clone(),
724 )
725 }
726
727 /// Retrieves a specific evaluation.
728 ///
729 /// # Example
730 /// ```
731 /// # use google_cloud_documentai_v1::client::DocumentProcessorService;
732 /// use google_cloud_documentai_v1::Result;
733 /// async fn sample(
734 /// client: &DocumentProcessorService, project_id: &str, location_id: &str, processor_id: &str, processor_version_id: &str, evaluation_id: &str
735 /// ) -> Result<()> {
736 /// let response = client.get_evaluation()
737 /// .set_name(format!("projects/{project_id}/locations/{location_id}/processors/{processor_id}/processorVersions/{processor_version_id}/evaluations/{evaluation_id}"))
738 /// .send().await?;
739 /// println!("response {:?}", response);
740 /// Ok(())
741 /// }
742 /// ```
743 pub fn get_evaluation(&self) -> super::builder::document_processor_service::GetEvaluation {
744 super::builder::document_processor_service::GetEvaluation::new(self.inner.clone())
745 }
746
747 /// Retrieves a set of evaluations for a given processor version.
748 ///
749 /// # Example
750 /// ```
751 /// # use google_cloud_documentai_v1::client::DocumentProcessorService;
752 /// use google_cloud_gax::paginator::ItemPaginator as _;
753 /// use google_cloud_documentai_v1::Result;
754 /// async fn sample(
755 /// client: &DocumentProcessorService, project_id: &str, location_id: &str, processor_id: &str, processor_version_id: &str
756 /// ) -> Result<()> {
757 /// let mut list = client.list_evaluations()
758 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/processors/{processor_id}/processorVersions/{processor_version_id}"))
759 /// .by_item();
760 /// while let Some(item) = list.next().await.transpose()? {
761 /// println!("{:?}", item);
762 /// }
763 /// Ok(())
764 /// }
765 /// ```
766 pub fn list_evaluations(&self) -> super::builder::document_processor_service::ListEvaluations {
767 super::builder::document_processor_service::ListEvaluations::new(self.inner.clone())
768 }
769
770 /// Lists information about the supported locations for this service.
771 ///
772 /// # Example
773 /// ```
774 /// # use google_cloud_documentai_v1::client::DocumentProcessorService;
775 /// use google_cloud_gax::paginator::ItemPaginator as _;
776 /// use google_cloud_documentai_v1::Result;
777 /// async fn sample(
778 /// client: &DocumentProcessorService
779 /// ) -> Result<()> {
780 /// let mut list = client.list_locations()
781 /// /* set fields */
782 /// .by_item();
783 /// while let Some(item) = list.next().await.transpose()? {
784 /// println!("{:?}", item);
785 /// }
786 /// Ok(())
787 /// }
788 /// ```
789 pub fn list_locations(&self) -> super::builder::document_processor_service::ListLocations {
790 super::builder::document_processor_service::ListLocations::new(self.inner.clone())
791 }
792
793 /// Gets information about a location.
794 ///
795 /// # Example
796 /// ```
797 /// # use google_cloud_documentai_v1::client::DocumentProcessorService;
798 /// use google_cloud_documentai_v1::Result;
799 /// async fn sample(
800 /// client: &DocumentProcessorService
801 /// ) -> Result<()> {
802 /// let response = client.get_location()
803 /// /* set fields */
804 /// .send().await?;
805 /// println!("response {:?}", response);
806 /// Ok(())
807 /// }
808 /// ```
809 pub fn get_location(&self) -> super::builder::document_processor_service::GetLocation {
810 super::builder::document_processor_service::GetLocation::new(self.inner.clone())
811 }
812
813 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
814 ///
815 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
816 ///
817 /// # Example
818 /// ```
819 /// # use google_cloud_documentai_v1::client::DocumentProcessorService;
820 /// use google_cloud_gax::paginator::ItemPaginator as _;
821 /// use google_cloud_documentai_v1::Result;
822 /// async fn sample(
823 /// client: &DocumentProcessorService
824 /// ) -> Result<()> {
825 /// let mut list = client.list_operations()
826 /// /* set fields */
827 /// .by_item();
828 /// while let Some(item) = list.next().await.transpose()? {
829 /// println!("{:?}", item);
830 /// }
831 /// Ok(())
832 /// }
833 /// ```
834 pub fn list_operations(&self) -> super::builder::document_processor_service::ListOperations {
835 super::builder::document_processor_service::ListOperations::new(self.inner.clone())
836 }
837
838 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
839 ///
840 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
841 ///
842 /// # Example
843 /// ```
844 /// # use google_cloud_documentai_v1::client::DocumentProcessorService;
845 /// use google_cloud_documentai_v1::Result;
846 /// async fn sample(
847 /// client: &DocumentProcessorService
848 /// ) -> Result<()> {
849 /// let response = client.get_operation()
850 /// /* set fields */
851 /// .send().await?;
852 /// println!("response {:?}", response);
853 /// Ok(())
854 /// }
855 /// ```
856 pub fn get_operation(&self) -> super::builder::document_processor_service::GetOperation {
857 super::builder::document_processor_service::GetOperation::new(self.inner.clone())
858 }
859
860 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
861 ///
862 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
863 ///
864 /// # Example
865 /// ```
866 /// # use google_cloud_documentai_v1::client::DocumentProcessorService;
867 /// use google_cloud_documentai_v1::Result;
868 /// async fn sample(
869 /// client: &DocumentProcessorService
870 /// ) -> Result<()> {
871 /// client.cancel_operation()
872 /// /* set fields */
873 /// .send().await?;
874 /// Ok(())
875 /// }
876 /// ```
877 pub fn cancel_operation(&self) -> super::builder::document_processor_service::CancelOperation {
878 super::builder::document_processor_service::CancelOperation::new(self.inner.clone())
879 }
880}