Skip to main content

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