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