google_documentai1_beta2/api.rs
1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16 /// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
17 CloudPlatform,
18}
19
20impl AsRef<str> for Scope {
21 fn as_ref(&self) -> &str {
22 match *self {
23 Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
24 }
25 }
26}
27
28#[allow(clippy::derivable_impls)]
29impl Default for Scope {
30 fn default() -> Scope {
31 Scope::CloudPlatform
32 }
33}
34
35// ########
36// HUB ###
37// ######
38
39/// Central instance to access all Document related resource activities
40///
41/// # Examples
42///
43/// Instantiate a new hub
44///
45/// ```test_harness,no_run
46/// extern crate hyper;
47/// extern crate hyper_rustls;
48/// extern crate google_documentai1_beta2 as documentai1_beta2;
49/// use documentai1_beta2::api::GoogleCloudDocumentaiV1beta2BatchProcessDocumentsRequest;
50/// use documentai1_beta2::{Result, Error};
51/// # async fn dox() {
52/// use documentai1_beta2::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
53///
54/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
55/// // `client_secret`, among other things.
56/// let secret: yup_oauth2::ApplicationSecret = Default::default();
57/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
58/// // unless you replace `None` with the desired Flow.
59/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
60/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
61/// // retrieve them from storage.
62/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
63/// .with_native_roots()
64/// .unwrap()
65/// .https_only()
66/// .enable_http2()
67/// .build();
68///
69/// let executor = hyper_util::rt::TokioExecutor::new();
70/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
71/// secret,
72/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
73/// yup_oauth2::client::CustomHyperClientBuilder::from(
74/// hyper_util::client::legacy::Client::builder(executor).build(connector),
75/// ),
76/// ).build().await.unwrap();
77///
78/// let client = hyper_util::client::legacy::Client::builder(
79/// hyper_util::rt::TokioExecutor::new()
80/// )
81/// .build(
82/// hyper_rustls::HttpsConnectorBuilder::new()
83/// .with_native_roots()
84/// .unwrap()
85/// .https_or_http()
86/// .enable_http2()
87/// .build()
88/// );
89/// let mut hub = Document::new(client, auth);
90/// // As the method needs a request, you would usually fill it with the desired information
91/// // into the respective structure. Some of the parts shown here might not be applicable !
92/// // Values shown here are possibly random and not representative !
93/// let mut req = GoogleCloudDocumentaiV1beta2BatchProcessDocumentsRequest::default();
94///
95/// // You can configure optional parameters by calling the respective setters at will, and
96/// // execute the final call using `doit()`.
97/// // Values shown here are possibly random and not representative !
98/// let result = hub.projects().documents_batch_process(req, "parent")
99/// .doit().await;
100///
101/// match result {
102/// Err(e) => match e {
103/// // The Error enum provides details about what exactly happened.
104/// // You can also just use its `Debug`, `Display` or `Error` traits
105/// Error::HttpError(_)
106/// |Error::Io(_)
107/// |Error::MissingAPIKey
108/// |Error::MissingToken(_)
109/// |Error::Cancelled
110/// |Error::UploadSizeLimitExceeded(_, _)
111/// |Error::Failure(_)
112/// |Error::BadRequest(_)
113/// |Error::FieldClash(_)
114/// |Error::JsonDecodeError(_, _) => println!("{}", e),
115/// },
116/// Ok(res) => println!("Success: {:?}", res),
117/// }
118/// # }
119/// ```
120#[derive(Clone)]
121pub struct Document<C> {
122 pub client: common::Client<C>,
123 pub auth: Box<dyn common::GetToken>,
124 _user_agent: String,
125 _base_url: String,
126 _root_url: String,
127}
128
129impl<C> common::Hub for Document<C> {}
130
131impl<'a, C> Document<C> {
132 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Document<C> {
133 Document {
134 client,
135 auth: Box::new(auth),
136 _user_agent: "google-api-rust-client/7.0.0".to_string(),
137 _base_url: "https://documentai.googleapis.com/".to_string(),
138 _root_url: "https://documentai.googleapis.com/".to_string(),
139 }
140 }
141
142 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
143 ProjectMethods { hub: self }
144 }
145
146 /// Set the user-agent header field to use in all requests to the server.
147 /// It defaults to `google-api-rust-client/7.0.0`.
148 ///
149 /// Returns the previously set user-agent.
150 pub fn user_agent(&mut self, agent_name: String) -> String {
151 std::mem::replace(&mut self._user_agent, agent_name)
152 }
153
154 /// Set the base url to use in all requests to the server.
155 /// It defaults to `https://documentai.googleapis.com/`.
156 ///
157 /// Returns the previously set base url.
158 pub fn base_url(&mut self, new_base_url: String) -> String {
159 std::mem::replace(&mut self._base_url, new_base_url)
160 }
161
162 /// Set the root url to use in all requests to the server.
163 /// It defaults to `https://documentai.googleapis.com/`.
164 ///
165 /// Returns the previously set root url.
166 pub fn root_url(&mut self, new_root_url: String) -> String {
167 std::mem::replace(&mut self._root_url, new_root_url)
168 }
169}
170
171// ############
172// SCHEMAS ###
173// ##########
174/// Parameters to control AutoML model prediction behavior.
175///
176/// This type is not used in any activity, and only used as *part* of another schema.
177///
178#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
179#[serde_with::serde_as]
180#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
181pub struct GoogleCloudDocumentaiV1beta2AutoMlParams {
182 /// Resource name of the AutoML model. Format: `projects/{project-id}/locations/{location-id}/models/{model-id}`.
183 pub model: Option<String>,
184}
185
186impl common::Part for GoogleCloudDocumentaiV1beta2AutoMlParams {}
187
188/// Encodes the detailed information of a barcode.
189///
190/// This type is not used in any activity, and only used as *part* of another schema.
191///
192#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
193#[serde_with::serde_as]
194#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
195pub struct GoogleCloudDocumentaiV1beta2Barcode {
196 /// Format of a barcode. The supported formats are: - `CODE_128`: Code 128 type. - `CODE_39`: Code 39 type. - `CODE_93`: Code 93 type. - `CODABAR`: Codabar type. - `DATA_MATRIX`: 2D Data Matrix type. - `ITF`: ITF type. - `EAN_13`: EAN-13 type. - `EAN_8`: EAN-8 type. - `QR_CODE`: 2D QR code type. - `UPC_A`: UPC-A type. - `UPC_E`: UPC-E type. - `PDF417`: PDF417 type. - `AZTEC`: 2D Aztec code type. - `DATABAR`: GS1 DataBar code type.
197 pub format: Option<String>,
198 /// Raw value encoded in the barcode. For example: `'MEBKM:TITLE:Google;URL:https://www.google.com;;'`.
199 #[serde(rename = "rawValue")]
200 pub raw_value: Option<String>,
201 /// Value format describes the format of the value that a barcode encodes. The supported formats are: - `CONTACT_INFO`: Contact information. - `EMAIL`: Email address. - `ISBN`: ISBN identifier. - `PHONE`: Phone number. - `PRODUCT`: Product. - `SMS`: SMS message. - `TEXT`: Text string. - `URL`: URL address. - `WIFI`: Wifi information. - `GEO`: Geo-localization. - `CALENDAR_EVENT`: Calendar event. - `DRIVER_LICENSE`: Driver's license.
202 #[serde(rename = "valueFormat")]
203 pub value_format: Option<String>,
204}
205
206impl common::Part for GoogleCloudDocumentaiV1beta2Barcode {}
207
208/// Request to batch process documents as an asynchronous operation. The output is written to Cloud Storage as JSON in the \[Document\] format.
209///
210/// # Activities
211///
212/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
213/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
214///
215/// * [documents batch process projects](ProjectDocumentBatchProcesCall) (request)
216/// * [locations documents batch process projects](ProjectLocationDocumentBatchProcesCall) (request)
217#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
218#[serde_with::serde_as]
219#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
220pub struct GoogleCloudDocumentaiV1beta2BatchProcessDocumentsRequest {
221 /// Required. Individual requests for each document.
222 pub requests: Option<Vec<GoogleCloudDocumentaiV1beta2ProcessDocumentRequest>>,
223}
224
225impl common::RequestValue for GoogleCloudDocumentaiV1beta2BatchProcessDocumentsRequest {}
226
227/// A bounding polygon for the detected image annotation.
228///
229/// This type is not used in any activity, and only used as *part* of another schema.
230///
231#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
232#[serde_with::serde_as]
233#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
234pub struct GoogleCloudDocumentaiV1beta2BoundingPoly {
235 /// The bounding polygon normalized vertices.
236 #[serde(rename = "normalizedVertices")]
237 pub normalized_vertices: Option<Vec<GoogleCloudDocumentaiV1beta2NormalizedVertex>>,
238 /// The bounding polygon vertices.
239 pub vertices: Option<Vec<GoogleCloudDocumentaiV1beta2Vertex>>,
240}
241
242impl common::Part for GoogleCloudDocumentaiV1beta2BoundingPoly {}
243
244/// Document represents the canonical document resource in Document AI. It is an interchange format that provides insights into documents and allows for collaboration between users and Document AI to iterate and optimize for quality.
245///
246/// # Activities
247///
248/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
249/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
250///
251/// * [documents process projects](ProjectDocumentProcesCall) (response)
252/// * [locations documents process projects](ProjectLocationDocumentProcesCall) (response)
253#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
254#[serde_with::serde_as]
255#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
256pub struct GoogleCloudDocumentaiV1beta2Document {
257 /// Document chunked based on chunking config.
258 #[serde(rename = "chunkedDocument")]
259 pub chunked_document: Option<GoogleCloudDocumentaiV1beta2DocumentChunkedDocument>,
260 /// Optional. Inline document content, represented as a stream of bytes. Note: As with all `bytes` fields, protobuffers use a pure binary representation, whereas JSON representations use base64.
261 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
262 pub content: Option<Vec<u8>>,
263 /// Parsed layout of the document.
264 #[serde(rename = "documentLayout")]
265 pub document_layout: Option<GoogleCloudDocumentaiV1beta2DocumentDocumentLayout>,
266 /// A list of entities detected on Document.text. For document shards, entities in this list may cross shard boundaries.
267 pub entities: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentEntity>>,
268 /// Placeholder. Relationship among Document.entities.
269 #[serde(rename = "entityRelations")]
270 pub entity_relations: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentEntityRelation>>,
271 /// Any error that occurred while processing this document.
272 pub error: Option<GoogleRpcStatus>,
273 /// Labels for this document.
274 pub labels: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentLabel>>,
275 /// An IANA published [media type (MIME type)](https://www.iana.org/assignments/media-types/media-types.xhtml).
276 #[serde(rename = "mimeType")]
277 pub mime_type: Option<String>,
278 /// Visual page layout for the Document.
279 pub pages: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentPage>>,
280 /// Placeholder. Revision history of this document.
281 pub revisions: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentRevision>>,
282 /// Information about the sharding if this document is sharded part of a larger document. If the document is not sharded, this message is not specified.
283 #[serde(rename = "shardInfo")]
284 pub shard_info: Option<GoogleCloudDocumentaiV1beta2DocumentShardInfo>,
285 /// Optional. UTF-8 encoded text in reading order from the document.
286 pub text: Option<String>,
287 /// Placeholder. A list of text corrections made to Document.text. This is usually used for annotating corrections to OCR mistakes. Text changes for a given revision may not overlap with each other.
288 #[serde(rename = "textChanges")]
289 pub text_changes: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentTextChange>>,
290 /// Styles for the Document.text.
291 #[serde(rename = "textStyles")]
292 pub text_styles: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentStyle>>,
293 /// Optional. Currently supports Google Cloud Storage URI of the form `gs://bucket_name/object_name`. Object versioning is not supported. For more information, refer to [Google Cloud Storage Request URIs](https://cloud.google.com/storage/docs/reference-uris).
294 pub uri: Option<String>,
295}
296
297impl common::ResponseResult for GoogleCloudDocumentaiV1beta2Document {}
298
299/// Represents the chunks that the document is divided into.
300///
301/// This type is not used in any activity, and only used as *part* of another schema.
302///
303#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
304#[serde_with::serde_as]
305#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
306pub struct GoogleCloudDocumentaiV1beta2DocumentChunkedDocument {
307 /// List of chunks.
308 pub chunks: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentChunkedDocumentChunk>>,
309}
310
311impl common::Part for GoogleCloudDocumentaiV1beta2DocumentChunkedDocument {}
312
313/// Represents a chunk.
314///
315/// This type is not used in any activity, and only used as *part* of another schema.
316///
317#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
318#[serde_with::serde_as]
319#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
320pub struct GoogleCloudDocumentaiV1beta2DocumentChunkedDocumentChunk {
321 /// ID of the chunk.
322 #[serde(rename = "chunkId")]
323 pub chunk_id: Option<String>,
324 /// Text content of the chunk.
325 pub content: Option<String>,
326 /// Page footers associated with the chunk.
327 #[serde(rename = "pageFooters")]
328 pub page_footers:
329 Option<Vec<GoogleCloudDocumentaiV1beta2DocumentChunkedDocumentChunkChunkPageFooter>>,
330 /// Page headers associated with the chunk.
331 #[serde(rename = "pageHeaders")]
332 pub page_headers:
333 Option<Vec<GoogleCloudDocumentaiV1beta2DocumentChunkedDocumentChunkChunkPageHeader>>,
334 /// Page span of the chunk.
335 #[serde(rename = "pageSpan")]
336 pub page_span: Option<GoogleCloudDocumentaiV1beta2DocumentChunkedDocumentChunkChunkPageSpan>,
337 /// Unused.
338 #[serde(rename = "sourceBlockIds")]
339 pub source_block_ids: Option<Vec<String>>,
340}
341
342impl common::Part for GoogleCloudDocumentaiV1beta2DocumentChunkedDocumentChunk {}
343
344/// Represents the page footer associated with the chunk.
345///
346/// This type is not used in any activity, and only used as *part* of another schema.
347///
348#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
349#[serde_with::serde_as]
350#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
351pub struct GoogleCloudDocumentaiV1beta2DocumentChunkedDocumentChunkChunkPageFooter {
352 /// Page span of the footer.
353 #[serde(rename = "pageSpan")]
354 pub page_span: Option<GoogleCloudDocumentaiV1beta2DocumentChunkedDocumentChunkChunkPageSpan>,
355 /// Footer in text format.
356 pub text: Option<String>,
357}
358
359impl common::Part for GoogleCloudDocumentaiV1beta2DocumentChunkedDocumentChunkChunkPageFooter {}
360
361/// Represents the page header associated with the chunk.
362///
363/// This type is not used in any activity, and only used as *part* of another schema.
364///
365#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
366#[serde_with::serde_as]
367#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
368pub struct GoogleCloudDocumentaiV1beta2DocumentChunkedDocumentChunkChunkPageHeader {
369 /// Page span of the header.
370 #[serde(rename = "pageSpan")]
371 pub page_span: Option<GoogleCloudDocumentaiV1beta2DocumentChunkedDocumentChunkChunkPageSpan>,
372 /// Header in text format.
373 pub text: Option<String>,
374}
375
376impl common::Part for GoogleCloudDocumentaiV1beta2DocumentChunkedDocumentChunkChunkPageHeader {}
377
378/// Represents where the chunk starts and ends in the document.
379///
380/// This type is not used in any activity, and only used as *part* of another schema.
381///
382#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
383#[serde_with::serde_as]
384#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
385pub struct GoogleCloudDocumentaiV1beta2DocumentChunkedDocumentChunkChunkPageSpan {
386 /// Page where chunk ends in the document.
387 #[serde(rename = "pageEnd")]
388 pub page_end: Option<i32>,
389 /// Page where chunk starts in the document.
390 #[serde(rename = "pageStart")]
391 pub page_start: Option<i32>,
392}
393
394impl common::Part for GoogleCloudDocumentaiV1beta2DocumentChunkedDocumentChunkChunkPageSpan {}
395
396/// Represents the parsed layout of a document as a collection of blocks that the document is divided into.
397///
398/// This type is not used in any activity, and only used as *part* of another schema.
399///
400#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
401#[serde_with::serde_as]
402#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
403pub struct GoogleCloudDocumentaiV1beta2DocumentDocumentLayout {
404 /// List of blocks in the document.
405 pub blocks: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentDocumentLayoutDocumentLayoutBlock>>,
406}
407
408impl common::Part for GoogleCloudDocumentaiV1beta2DocumentDocumentLayout {}
409
410/// Represents a block. A block could be one of the various types (text, table, list) supported.
411///
412/// This type is not used in any activity, and only used as *part* of another schema.
413///
414#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
415#[serde_with::serde_as]
416#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
417pub struct GoogleCloudDocumentaiV1beta2DocumentDocumentLayoutDocumentLayoutBlock {
418 /// ID of the block.
419 #[serde(rename = "blockId")]
420 pub block_id: Option<String>,
421 /// Block consisting of list content/structure.
422 #[serde(rename = "listBlock")]
423 pub list_block: Option<
424 GoogleCloudDocumentaiV1beta2DocumentDocumentLayoutDocumentLayoutBlockLayoutListBlock,
425 >,
426 /// Page span of the block.
427 #[serde(rename = "pageSpan")]
428 pub page_span:
429 Option<GoogleCloudDocumentaiV1beta2DocumentDocumentLayoutDocumentLayoutBlockLayoutPageSpan>,
430 /// Block consisting of table content/structure.
431 #[serde(rename = "tableBlock")]
432 pub table_block: Option<
433 GoogleCloudDocumentaiV1beta2DocumentDocumentLayoutDocumentLayoutBlockLayoutTableBlock,
434 >,
435 /// Block consisting of text content.
436 #[serde(rename = "textBlock")]
437 pub text_block: Option<
438 GoogleCloudDocumentaiV1beta2DocumentDocumentLayoutDocumentLayoutBlockLayoutTextBlock,
439 >,
440}
441
442impl common::Part for GoogleCloudDocumentaiV1beta2DocumentDocumentLayoutDocumentLayoutBlock {}
443
444/// Represents a list type block.
445///
446/// This type is not used in any activity, and only used as *part* of another schema.
447///
448#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
449#[serde_with::serde_as]
450#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
451pub struct GoogleCloudDocumentaiV1beta2DocumentDocumentLayoutDocumentLayoutBlockLayoutListBlock {
452 /// List entries that constitute a list block.
453 #[serde(rename = "listEntries")]
454 pub list_entries: Option<
455 Vec<GoogleCloudDocumentaiV1beta2DocumentDocumentLayoutDocumentLayoutBlockLayoutListEntry>,
456 >,
457 /// Type of the list_entries (if exist). Available options are `ordered` and `unordered`.
458 #[serde(rename = "type")]
459 pub type_: Option<String>,
460}
461
462impl common::Part
463 for GoogleCloudDocumentaiV1beta2DocumentDocumentLayoutDocumentLayoutBlockLayoutListBlock
464{
465}
466
467/// Represents an entry in the list.
468///
469/// This type is not used in any activity, and only used as *part* of another schema.
470///
471#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
472#[serde_with::serde_as]
473#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
474pub struct GoogleCloudDocumentaiV1beta2DocumentDocumentLayoutDocumentLayoutBlockLayoutListEntry {
475 /// A list entry is a list of blocks. Repeated blocks support further hierarchies and nested blocks.
476 pub blocks: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentDocumentLayoutDocumentLayoutBlock>>,
477}
478
479impl common::Part
480 for GoogleCloudDocumentaiV1beta2DocumentDocumentLayoutDocumentLayoutBlockLayoutListEntry
481{
482}
483
484/// Represents where the block starts and ends in the document.
485///
486/// This type is not used in any activity, and only used as *part* of another schema.
487///
488#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
489#[serde_with::serde_as]
490#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
491pub struct GoogleCloudDocumentaiV1beta2DocumentDocumentLayoutDocumentLayoutBlockLayoutPageSpan {
492 /// Page where block ends in the document.
493 #[serde(rename = "pageEnd")]
494 pub page_end: Option<i32>,
495 /// Page where block starts in the document.
496 #[serde(rename = "pageStart")]
497 pub page_start: Option<i32>,
498}
499
500impl common::Part
501 for GoogleCloudDocumentaiV1beta2DocumentDocumentLayoutDocumentLayoutBlockLayoutPageSpan
502{
503}
504
505/// Represents a table type block.
506///
507/// This type is not used in any activity, and only used as *part* of another schema.
508///
509#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
510#[serde_with::serde_as]
511#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
512pub struct GoogleCloudDocumentaiV1beta2DocumentDocumentLayoutDocumentLayoutBlockLayoutTableBlock {
513 /// Body rows containing main table content.
514 #[serde(rename = "bodyRows")]
515 pub body_rows: Option<
516 Vec<GoogleCloudDocumentaiV1beta2DocumentDocumentLayoutDocumentLayoutBlockLayoutTableRow>,
517 >,
518 /// Table caption/title.
519 pub caption: Option<String>,
520 /// Header rows at the top of the table.
521 #[serde(rename = "headerRows")]
522 pub header_rows: Option<
523 Vec<GoogleCloudDocumentaiV1beta2DocumentDocumentLayoutDocumentLayoutBlockLayoutTableRow>,
524 >,
525}
526
527impl common::Part
528 for GoogleCloudDocumentaiV1beta2DocumentDocumentLayoutDocumentLayoutBlockLayoutTableBlock
529{
530}
531
532/// Represents a cell in a table row.
533///
534/// This type is not used in any activity, and only used as *part* of another schema.
535///
536#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
537#[serde_with::serde_as]
538#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
539pub struct GoogleCloudDocumentaiV1beta2DocumentDocumentLayoutDocumentLayoutBlockLayoutTableCell {
540 /// A table cell is a list of blocks. Repeated blocks support further hierarchies and nested blocks.
541 pub blocks: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentDocumentLayoutDocumentLayoutBlock>>,
542 /// How many columns this cell spans.
543 #[serde(rename = "colSpan")]
544 pub col_span: Option<i32>,
545 /// How many rows this cell spans.
546 #[serde(rename = "rowSpan")]
547 pub row_span: Option<i32>,
548}
549
550impl common::Part
551 for GoogleCloudDocumentaiV1beta2DocumentDocumentLayoutDocumentLayoutBlockLayoutTableCell
552{
553}
554
555/// Represents a row in a table.
556///
557/// This type is not used in any activity, and only used as *part* of another schema.
558///
559#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
560#[serde_with::serde_as]
561#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
562pub struct GoogleCloudDocumentaiV1beta2DocumentDocumentLayoutDocumentLayoutBlockLayoutTableRow {
563 /// A table row is a list of table cells.
564 pub cells: Option<
565 Vec<GoogleCloudDocumentaiV1beta2DocumentDocumentLayoutDocumentLayoutBlockLayoutTableCell>,
566 >,
567}
568
569impl common::Part
570 for GoogleCloudDocumentaiV1beta2DocumentDocumentLayoutDocumentLayoutBlockLayoutTableRow
571{
572}
573
574/// Represents a text type block.
575///
576/// This type is not used in any activity, and only used as *part* of another schema.
577///
578#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
579#[serde_with::serde_as]
580#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
581pub struct GoogleCloudDocumentaiV1beta2DocumentDocumentLayoutDocumentLayoutBlockLayoutTextBlock {
582 /// A text block could further have child blocks. Repeated blocks support further hierarchies and nested blocks.
583 pub blocks: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentDocumentLayoutDocumentLayoutBlock>>,
584 /// Text content stored in the block.
585 pub text: Option<String>,
586 /// Type of the text in the block. Available options are: `paragraph`, `subtitle`, `heading-1`, `heading-2`, `heading-3`, `heading-4`, `heading-5`, `header`, `footer`.
587 #[serde(rename = "type")]
588 pub type_: Option<String>,
589}
590
591impl common::Part
592 for GoogleCloudDocumentaiV1beta2DocumentDocumentLayoutDocumentLayoutBlockLayoutTextBlock
593{
594}
595
596/// An entity that could be a phrase in the text or a property that belongs to the document. It is a known entity type, such as a person, an organization, or location.
597///
598/// This type is not used in any activity, and only used as *part* of another schema.
599///
600#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
601#[serde_with::serde_as]
602#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
603pub struct GoogleCloudDocumentaiV1beta2DocumentEntity {
604 /// Optional. Confidence of detected Schema entity. Range `[0, 1]`.
605 pub confidence: Option<f32>,
606 /// Optional. Canonical id. This will be a unique value in the entity list for this document.
607 pub id: Option<String>,
608 /// Optional. Deprecated. Use `id` field instead.
609 #[serde(rename = "mentionId")]
610 pub mention_id: Option<String>,
611 /// Optional. Text value of the entity e.g. `1600 Amphitheatre Pkwy`.
612 #[serde(rename = "mentionText")]
613 pub mention_text: Option<String>,
614 /// Optional. Normalized entity value. Absent if the extracted value could not be converted or the type (e.g. address) is not supported for certain parsers. This field is also only populated for certain supported document types.
615 #[serde(rename = "normalizedValue")]
616 pub normalized_value: Option<GoogleCloudDocumentaiV1beta2DocumentEntityNormalizedValue>,
617 /// Optional. Represents the provenance of this entity wrt. the location on the page where it was found.
618 #[serde(rename = "pageAnchor")]
619 pub page_anchor: Option<GoogleCloudDocumentaiV1beta2DocumentPageAnchor>,
620 /// Optional. Entities can be nested to form a hierarchical data structure representing the content in the document.
621 pub properties: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentEntity>>,
622 /// Optional. The history of this annotation.
623 pub provenance: Option<GoogleCloudDocumentaiV1beta2DocumentProvenance>,
624 /// Optional. Whether the entity will be redacted for de-identification purposes.
625 pub redacted: Option<bool>,
626 /// Optional. Provenance of the entity. Text anchor indexing into the Document.text.
627 #[serde(rename = "textAnchor")]
628 pub text_anchor: Option<GoogleCloudDocumentaiV1beta2DocumentTextAnchor>,
629 /// Required. Entity type from a schema e.g. `Address`.
630 #[serde(rename = "type")]
631 pub type_: Option<String>,
632}
633
634impl common::Part for GoogleCloudDocumentaiV1beta2DocumentEntity {}
635
636/// Parsed and normalized entity value.
637///
638/// This type is not used in any activity, and only used as *part* of another schema.
639///
640#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
641#[serde_with::serde_as]
642#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
643pub struct GoogleCloudDocumentaiV1beta2DocumentEntityNormalizedValue {
644 /// Postal address. See also: https://github.com/googleapis/googleapis/blob/master/google/type/postal_address.proto
645 #[serde(rename = "addressValue")]
646 pub address_value: Option<GoogleTypePostalAddress>,
647 /// Boolean value. Can be used for entities with binary values, or for checkboxes.
648 #[serde(rename = "booleanValue")]
649 pub boolean_value: Option<bool>,
650 /// Date value. Includes year, month, day. See also: https://github.com/googleapis/googleapis/blob/master/google/type/date.proto
651 #[serde(rename = "dateValue")]
652 pub date_value: Option<GoogleTypeDate>,
653 /// DateTime value. Includes date, time, and timezone. See also: https://github.com/googleapis/googleapis/blob/master/google/type/datetime.proto
654 #[serde(rename = "datetimeValue")]
655 pub datetime_value: Option<GoogleTypeDateTime>,
656 /// Float value.
657 #[serde(rename = "floatValue")]
658 pub float_value: Option<f32>,
659 /// Integer value.
660 #[serde(rename = "integerValue")]
661 pub integer_value: Option<i32>,
662 /// Money value. See also: https://github.com/googleapis/googleapis/blob/master/google/type/money.proto
663 #[serde(rename = "moneyValue")]
664 pub money_value: Option<GoogleTypeMoney>,
665 /// Optional. An optional field to store a normalized string. For some entity types, one of respective `structured_value` fields may also be populated. Also not all the types of `structured_value` will be normalized. For example, some processors may not generate `float` or `integer` normalized text by default. Below are sample formats mapped to structured values. - Money/Currency type (`money_value`) is in the ISO 4217 text format. - Date type (`date_value`) is in the ISO 8601 text format. - Datetime type (`datetime_value`) is in the ISO 8601 text format.
666 pub text: Option<String>,
667}
668
669impl common::Part for GoogleCloudDocumentaiV1beta2DocumentEntityNormalizedValue {}
670
671/// Relationship between Entities.
672///
673/// This type is not used in any activity, and only used as *part* of another schema.
674///
675#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
676#[serde_with::serde_as]
677#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
678pub struct GoogleCloudDocumentaiV1beta2DocumentEntityRelation {
679 /// Object entity id.
680 #[serde(rename = "objectId")]
681 pub object_id: Option<String>,
682 /// Relationship description.
683 pub relation: Option<String>,
684 /// Subject entity id.
685 #[serde(rename = "subjectId")]
686 pub subject_id: Option<String>,
687}
688
689impl common::Part for GoogleCloudDocumentaiV1beta2DocumentEntityRelation {}
690
691/// Label attaches schema information and/or other metadata to segments within a Document. Multiple Labels on a single field can denote either different labels, different instances of the same label created at different times, or some combination of both.
692///
693/// This type is not used in any activity, and only used as *part* of another schema.
694///
695#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
696#[serde_with::serde_as]
697#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
698pub struct GoogleCloudDocumentaiV1beta2DocumentLabel {
699 /// Label is generated AutoML model. This field stores the full resource name of the AutoML model. Format: `projects/{project-id}/locations/{location-id}/models/{model-id}`
700 #[serde(rename = "automlModel")]
701 pub automl_model: Option<String>,
702 /// Confidence score between 0 and 1 for label assignment.
703 pub confidence: Option<f32>,
704 /// Name of the label. When the label is generated from AutoML Text Classification model, this field represents the name of the category.
705 pub name: Option<String>,
706}
707
708impl common::Part for GoogleCloudDocumentaiV1beta2DocumentLabel {}
709
710/// A page in a Document.
711///
712/// This type is not used in any activity, and only used as *part* of another schema.
713///
714#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
715#[serde_with::serde_as]
716#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
717pub struct GoogleCloudDocumentaiV1beta2DocumentPage {
718 /// A list of visually detected text blocks on the page. A block has a set of lines (collected into paragraphs) that have a common line-spacing and orientation.
719 pub blocks: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentPageBlock>>,
720 /// A list of detected barcodes.
721 #[serde(rename = "detectedBarcodes")]
722 pub detected_barcodes: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentPageDetectedBarcode>>,
723 /// A list of detected languages together with confidence.
724 #[serde(rename = "detectedLanguages")]
725 pub detected_languages: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentPageDetectedLanguage>>,
726 /// Physical dimension of the page.
727 pub dimension: Option<GoogleCloudDocumentaiV1beta2DocumentPageDimension>,
728 /// A list of visually detected form fields on the page.
729 #[serde(rename = "formFields")]
730 pub form_fields: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentPageFormField>>,
731 /// Rendered image for this page. This image is preprocessed to remove any skew, rotation, and distortions such that the annotation bounding boxes can be upright and axis-aligned.
732 pub image: Option<GoogleCloudDocumentaiV1beta2DocumentPageImage>,
733 /// Image quality scores.
734 #[serde(rename = "imageQualityScores")]
735 pub image_quality_scores: Option<GoogleCloudDocumentaiV1beta2DocumentPageImageQualityScores>,
736 /// Layout for the page.
737 pub layout: Option<GoogleCloudDocumentaiV1beta2DocumentPageLayout>,
738 /// A list of visually detected text lines on the page. A collection of tokens that a human would perceive as a line.
739 pub lines: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentPageLine>>,
740 /// 1-based index for current Page in a parent Document. Useful when a page is taken out of a Document for individual processing.
741 #[serde(rename = "pageNumber")]
742 pub page_number: Option<i32>,
743 /// A list of visually detected text paragraphs on the page. A collection of lines that a human would perceive as a paragraph.
744 pub paragraphs: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentPageParagraph>>,
745 /// The history of this page.
746 pub provenance: Option<GoogleCloudDocumentaiV1beta2DocumentProvenance>,
747 /// A list of visually detected symbols on the page.
748 pub symbols: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentPageSymbol>>,
749 /// A list of visually detected tables on the page.
750 pub tables: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentPageTable>>,
751 /// A list of visually detected tokens on the page.
752 pub tokens: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentPageToken>>,
753 /// Transformation matrices that were applied to the original document image to produce Page.image.
754 pub transforms: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentPageMatrix>>,
755 /// A list of detected non-text visual elements e.g. checkbox, signature etc. on the page.
756 #[serde(rename = "visualElements")]
757 pub visual_elements: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentPageVisualElement>>,
758}
759
760impl common::Part for GoogleCloudDocumentaiV1beta2DocumentPage {}
761
762/// Referencing the visual context of the entity in the Document.pages. Page anchors can be cross-page, consist of multiple bounding polygons and optionally reference specific layout element types.
763///
764/// This type is not used in any activity, and only used as *part* of another schema.
765///
766#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
767#[serde_with::serde_as]
768#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
769pub struct GoogleCloudDocumentaiV1beta2DocumentPageAnchor {
770 /// One or more references to visual page elements
771 #[serde(rename = "pageRefs")]
772 pub page_refs: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentPageAnchorPageRef>>,
773}
774
775impl common::Part for GoogleCloudDocumentaiV1beta2DocumentPageAnchor {}
776
777/// Represents a weak reference to a page element within a document.
778///
779/// This type is not used in any activity, and only used as *part* of another schema.
780///
781#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
782#[serde_with::serde_as]
783#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
784pub struct GoogleCloudDocumentaiV1beta2DocumentPageAnchorPageRef {
785 /// Optional. Identifies the bounding polygon of a layout element on the page. If `layout_type` is set, the bounding polygon must be exactly the same to the layout element it's referring to.
786 #[serde(rename = "boundingPoly")]
787 pub bounding_poly: Option<GoogleCloudDocumentaiV1beta2BoundingPoly>,
788 /// Optional. Confidence of detected page element, if applicable. Range `[0, 1]`.
789 pub confidence: Option<f32>,
790 /// Optional. Deprecated. Use PageRef.bounding_poly instead.
791 #[serde(rename = "layoutId")]
792 pub layout_id: Option<String>,
793 /// Optional. The type of the layout element that is being referenced if any.
794 #[serde(rename = "layoutType")]
795 pub layout_type: Option<String>,
796 /// Required. Index into the Document.pages element, for example using `Document.pages` to locate the related page element. This field is skipped when its value is the default `0`. See https://developers.google.com/protocol-buffers/docs/proto3#json.
797 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
798 pub page: Option<i64>,
799}
800
801impl common::Part for GoogleCloudDocumentaiV1beta2DocumentPageAnchorPageRef {}
802
803/// A block has a set of lines (collected into paragraphs) that have a common line-spacing and orientation.
804///
805/// This type is not used in any activity, and only used as *part* of another schema.
806///
807#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
808#[serde_with::serde_as]
809#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
810pub struct GoogleCloudDocumentaiV1beta2DocumentPageBlock {
811 /// A list of detected languages together with confidence.
812 #[serde(rename = "detectedLanguages")]
813 pub detected_languages: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentPageDetectedLanguage>>,
814 /// Layout for Block.
815 pub layout: Option<GoogleCloudDocumentaiV1beta2DocumentPageLayout>,
816 /// The history of this annotation.
817 pub provenance: Option<GoogleCloudDocumentaiV1beta2DocumentProvenance>,
818}
819
820impl common::Part for GoogleCloudDocumentaiV1beta2DocumentPageBlock {}
821
822/// A detected barcode.
823///
824/// This type is not used in any activity, and only used as *part* of another schema.
825///
826#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
827#[serde_with::serde_as]
828#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
829pub struct GoogleCloudDocumentaiV1beta2DocumentPageDetectedBarcode {
830 /// Detailed barcode information of the DetectedBarcode.
831 pub barcode: Option<GoogleCloudDocumentaiV1beta2Barcode>,
832 /// Layout for DetectedBarcode.
833 pub layout: Option<GoogleCloudDocumentaiV1beta2DocumentPageLayout>,
834}
835
836impl common::Part for GoogleCloudDocumentaiV1beta2DocumentPageDetectedBarcode {}
837
838/// Detected language for a structural component.
839///
840/// This type is not used in any activity, and only used as *part* of another schema.
841///
842#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
843#[serde_with::serde_as]
844#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
845pub struct GoogleCloudDocumentaiV1beta2DocumentPageDetectedLanguage {
846 /// Confidence of detected language. Range `[0, 1]`.
847 pub confidence: Option<f32>,
848 /// The [BCP-47 language code](https://www.unicode.org/reports/tr35/#Unicode_locale_identifier), such as `en-US` or `sr-Latn`.
849 #[serde(rename = "languageCode")]
850 pub language_code: Option<String>,
851}
852
853impl common::Part for GoogleCloudDocumentaiV1beta2DocumentPageDetectedLanguage {}
854
855/// Dimension for the page.
856///
857/// This type is not used in any activity, and only used as *part* of another schema.
858///
859#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
860#[serde_with::serde_as]
861#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
862pub struct GoogleCloudDocumentaiV1beta2DocumentPageDimension {
863 /// Page height.
864 pub height: Option<f32>,
865 /// Dimension unit.
866 pub unit: Option<String>,
867 /// Page width.
868 pub width: Option<f32>,
869}
870
871impl common::Part for GoogleCloudDocumentaiV1beta2DocumentPageDimension {}
872
873/// A form field detected on the page.
874///
875/// This type is not used in any activity, and only used as *part* of another schema.
876///
877#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
878#[serde_with::serde_as]
879#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
880pub struct GoogleCloudDocumentaiV1beta2DocumentPageFormField {
881 /// Created for Labeling UI to export key text. If corrections were made to the text identified by the `field_name.text_anchor`, this field will contain the correction.
882 #[serde(rename = "correctedKeyText")]
883 pub corrected_key_text: Option<String>,
884 /// Created for Labeling UI to export value text. If corrections were made to the text identified by the `field_value.text_anchor`, this field will contain the correction.
885 #[serde(rename = "correctedValueText")]
886 pub corrected_value_text: Option<String>,
887 /// Layout for the FormField name. e.g. `Address`, `Email`, `Grand total`, `Phone number`, etc.
888 #[serde(rename = "fieldName")]
889 pub field_name: Option<GoogleCloudDocumentaiV1beta2DocumentPageLayout>,
890 /// Layout for the FormField value.
891 #[serde(rename = "fieldValue")]
892 pub field_value: Option<GoogleCloudDocumentaiV1beta2DocumentPageLayout>,
893 /// A list of detected languages for name together with confidence.
894 #[serde(rename = "nameDetectedLanguages")]
895 pub name_detected_languages:
896 Option<Vec<GoogleCloudDocumentaiV1beta2DocumentPageDetectedLanguage>>,
897 /// The history of this annotation.
898 pub provenance: Option<GoogleCloudDocumentaiV1beta2DocumentProvenance>,
899 /// A list of detected languages for value together with confidence.
900 #[serde(rename = "valueDetectedLanguages")]
901 pub value_detected_languages:
902 Option<Vec<GoogleCloudDocumentaiV1beta2DocumentPageDetectedLanguage>>,
903 /// If the value is non-textual, this field represents the type. Current valid values are: - blank (this indicates the `field_value` is normal text) - `unfilled_checkbox` - `filled_checkbox`
904 #[serde(rename = "valueType")]
905 pub value_type: Option<String>,
906}
907
908impl common::Part for GoogleCloudDocumentaiV1beta2DocumentPageFormField {}
909
910/// Rendered image contents for this page.
911///
912/// This type is not used in any activity, and only used as *part* of another schema.
913///
914#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
915#[serde_with::serde_as]
916#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
917pub struct GoogleCloudDocumentaiV1beta2DocumentPageImage {
918 /// Raw byte content of the image.
919 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
920 pub content: Option<Vec<u8>>,
921 /// Height of the image in pixels.
922 pub height: Option<i32>,
923 /// Encoding [media type (MIME type)](https://www.iana.org/assignments/media-types/media-types.xhtml) for the image.
924 #[serde(rename = "mimeType")]
925 pub mime_type: Option<String>,
926 /// Width of the image in pixels.
927 pub width: Option<i32>,
928}
929
930impl common::Part for GoogleCloudDocumentaiV1beta2DocumentPageImage {}
931
932/// Image quality scores for the page image.
933///
934/// This type is not used in any activity, and only used as *part* of another schema.
935///
936#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
937#[serde_with::serde_as]
938#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
939pub struct GoogleCloudDocumentaiV1beta2DocumentPageImageQualityScores {
940 /// A list of detected defects.
941 #[serde(rename = "detectedDefects")]
942 pub detected_defects:
943 Option<Vec<GoogleCloudDocumentaiV1beta2DocumentPageImageQualityScoresDetectedDefect>>,
944 /// The overall quality score. Range `[0, 1]` where `1` is perfect quality.
945 #[serde(rename = "qualityScore")]
946 pub quality_score: Option<f32>,
947}
948
949impl common::Part for GoogleCloudDocumentaiV1beta2DocumentPageImageQualityScores {}
950
951/// Image Quality Defects
952///
953/// This type is not used in any activity, and only used as *part* of another schema.
954///
955#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
956#[serde_with::serde_as]
957#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
958pub struct GoogleCloudDocumentaiV1beta2DocumentPageImageQualityScoresDetectedDefect {
959 /// Confidence of detected defect. Range `[0, 1]` where `1` indicates strong confidence that the defect exists.
960 pub confidence: Option<f32>,
961 /// Name of the defect type. Supported values are: - `quality/defect_blurry` - `quality/defect_noisy` - `quality/defect_dark` - `quality/defect_faint` - `quality/defect_text_too_small` - `quality/defect_document_cutoff` - `quality/defect_text_cutoff` - `quality/defect_glare`
962 #[serde(rename = "type")]
963 pub type_: Option<String>,
964}
965
966impl common::Part for GoogleCloudDocumentaiV1beta2DocumentPageImageQualityScoresDetectedDefect {}
967
968/// Visual element describing a layout unit on a page.
969///
970/// This type is not used in any activity, and only used as *part* of another schema.
971///
972#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
973#[serde_with::serde_as]
974#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
975pub struct GoogleCloudDocumentaiV1beta2DocumentPageLayout {
976 /// The bounding polygon for the Layout.
977 #[serde(rename = "boundingPoly")]
978 pub bounding_poly: Option<GoogleCloudDocumentaiV1beta2BoundingPoly>,
979 /// Confidence of the current Layout within context of the object this layout is for. e.g. confidence can be for a single token, a table, a visual element, etc. depending on context. Range `[0, 1]`.
980 pub confidence: Option<f32>,
981 /// Detected orientation for the Layout.
982 pub orientation: Option<String>,
983 /// Text anchor indexing into the Document.text.
984 #[serde(rename = "textAnchor")]
985 pub text_anchor: Option<GoogleCloudDocumentaiV1beta2DocumentTextAnchor>,
986}
987
988impl common::Part for GoogleCloudDocumentaiV1beta2DocumentPageLayout {}
989
990/// A collection of tokens that a human would perceive as a line. Does not cross column boundaries, can be horizontal, vertical, etc.
991///
992/// This type is not used in any activity, and only used as *part* of another schema.
993///
994#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
995#[serde_with::serde_as]
996#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
997pub struct GoogleCloudDocumentaiV1beta2DocumentPageLine {
998 /// A list of detected languages together with confidence.
999 #[serde(rename = "detectedLanguages")]
1000 pub detected_languages: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentPageDetectedLanguage>>,
1001 /// Layout for Line.
1002 pub layout: Option<GoogleCloudDocumentaiV1beta2DocumentPageLayout>,
1003 /// The history of this annotation.
1004 pub provenance: Option<GoogleCloudDocumentaiV1beta2DocumentProvenance>,
1005}
1006
1007impl common::Part for GoogleCloudDocumentaiV1beta2DocumentPageLine {}
1008
1009/// Representation for transformation matrix, intended to be compatible and used with OpenCV format for image manipulation.
1010///
1011/// This type is not used in any activity, and only used as *part* of another schema.
1012///
1013#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1014#[serde_with::serde_as]
1015#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1016pub struct GoogleCloudDocumentaiV1beta2DocumentPageMatrix {
1017 /// Number of columns in the matrix.
1018 pub cols: Option<i32>,
1019 /// The matrix data.
1020 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1021 pub data: Option<Vec<u8>>,
1022 /// Number of rows in the matrix.
1023 pub rows: Option<i32>,
1024 /// This encodes information about what data type the matrix uses. For example, 0 (CV_8U) is an unsigned 8-bit image. For the full list of OpenCV primitive data types, please refer to https://docs.opencv.org/4.3.0/d1/d1b/group__core__hal__interface.html
1025 #[serde(rename = "type")]
1026 pub type_: Option<i32>,
1027}
1028
1029impl common::Part for GoogleCloudDocumentaiV1beta2DocumentPageMatrix {}
1030
1031/// A collection of lines that a human would perceive as a paragraph.
1032///
1033/// This type is not used in any activity, and only used as *part* of another schema.
1034///
1035#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1036#[serde_with::serde_as]
1037#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1038pub struct GoogleCloudDocumentaiV1beta2DocumentPageParagraph {
1039 /// A list of detected languages together with confidence.
1040 #[serde(rename = "detectedLanguages")]
1041 pub detected_languages: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentPageDetectedLanguage>>,
1042 /// Layout for Paragraph.
1043 pub layout: Option<GoogleCloudDocumentaiV1beta2DocumentPageLayout>,
1044 /// The history of this annotation.
1045 pub provenance: Option<GoogleCloudDocumentaiV1beta2DocumentProvenance>,
1046}
1047
1048impl common::Part for GoogleCloudDocumentaiV1beta2DocumentPageParagraph {}
1049
1050/// A detected symbol.
1051///
1052/// This type is not used in any activity, and only used as *part* of another schema.
1053///
1054#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1055#[serde_with::serde_as]
1056#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1057pub struct GoogleCloudDocumentaiV1beta2DocumentPageSymbol {
1058 /// A list of detected languages together with confidence.
1059 #[serde(rename = "detectedLanguages")]
1060 pub detected_languages: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentPageDetectedLanguage>>,
1061 /// Layout for Symbol.
1062 pub layout: Option<GoogleCloudDocumentaiV1beta2DocumentPageLayout>,
1063}
1064
1065impl common::Part for GoogleCloudDocumentaiV1beta2DocumentPageSymbol {}
1066
1067/// A table representation similar to HTML table structure.
1068///
1069/// This type is not used in any activity, and only used as *part* of another schema.
1070///
1071#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1072#[serde_with::serde_as]
1073#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1074pub struct GoogleCloudDocumentaiV1beta2DocumentPageTable {
1075 /// Body rows of the table.
1076 #[serde(rename = "bodyRows")]
1077 pub body_rows: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentPageTableTableRow>>,
1078 /// A list of detected languages together with confidence.
1079 #[serde(rename = "detectedLanguages")]
1080 pub detected_languages: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentPageDetectedLanguage>>,
1081 /// Header rows of the table.
1082 #[serde(rename = "headerRows")]
1083 pub header_rows: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentPageTableTableRow>>,
1084 /// Layout for Table.
1085 pub layout: Option<GoogleCloudDocumentaiV1beta2DocumentPageLayout>,
1086 /// The history of this table.
1087 pub provenance: Option<GoogleCloudDocumentaiV1beta2DocumentProvenance>,
1088}
1089
1090impl common::Part for GoogleCloudDocumentaiV1beta2DocumentPageTable {}
1091
1092/// A cell representation inside the table.
1093///
1094/// This type is not used in any activity, and only used as *part* of another schema.
1095///
1096#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1097#[serde_with::serde_as]
1098#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1099pub struct GoogleCloudDocumentaiV1beta2DocumentPageTableTableCell {
1100 /// How many columns this cell spans.
1101 #[serde(rename = "colSpan")]
1102 pub col_span: Option<i32>,
1103 /// A list of detected languages together with confidence.
1104 #[serde(rename = "detectedLanguages")]
1105 pub detected_languages: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentPageDetectedLanguage>>,
1106 /// Layout for TableCell.
1107 pub layout: Option<GoogleCloudDocumentaiV1beta2DocumentPageLayout>,
1108 /// How many rows this cell spans.
1109 #[serde(rename = "rowSpan")]
1110 pub row_span: Option<i32>,
1111}
1112
1113impl common::Part for GoogleCloudDocumentaiV1beta2DocumentPageTableTableCell {}
1114
1115/// A row of table cells.
1116///
1117/// This type is not used in any activity, and only used as *part* of another schema.
1118///
1119#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1120#[serde_with::serde_as]
1121#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1122pub struct GoogleCloudDocumentaiV1beta2DocumentPageTableTableRow {
1123 /// Cells that make up this row.
1124 pub cells: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentPageTableTableCell>>,
1125}
1126
1127impl common::Part for GoogleCloudDocumentaiV1beta2DocumentPageTableTableRow {}
1128
1129/// A detected token.
1130///
1131/// This type is not used in any activity, and only used as *part* of another schema.
1132///
1133#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1134#[serde_with::serde_as]
1135#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1136pub struct GoogleCloudDocumentaiV1beta2DocumentPageToken {
1137 /// Detected break at the end of a Token.
1138 #[serde(rename = "detectedBreak")]
1139 pub detected_break: Option<GoogleCloudDocumentaiV1beta2DocumentPageTokenDetectedBreak>,
1140 /// A list of detected languages together with confidence.
1141 #[serde(rename = "detectedLanguages")]
1142 pub detected_languages: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentPageDetectedLanguage>>,
1143 /// Layout for Token.
1144 pub layout: Option<GoogleCloudDocumentaiV1beta2DocumentPageLayout>,
1145 /// The history of this annotation.
1146 pub provenance: Option<GoogleCloudDocumentaiV1beta2DocumentProvenance>,
1147 /// Text style attributes.
1148 #[serde(rename = "styleInfo")]
1149 pub style_info: Option<GoogleCloudDocumentaiV1beta2DocumentPageTokenStyleInfo>,
1150}
1151
1152impl common::Part for GoogleCloudDocumentaiV1beta2DocumentPageToken {}
1153
1154/// Detected break at the end of a Token.
1155///
1156/// This type is not used in any activity, and only used as *part* of another schema.
1157///
1158#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1159#[serde_with::serde_as]
1160#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1161pub struct GoogleCloudDocumentaiV1beta2DocumentPageTokenDetectedBreak {
1162 /// Detected break type.
1163 #[serde(rename = "type")]
1164 pub type_: Option<String>,
1165}
1166
1167impl common::Part for GoogleCloudDocumentaiV1beta2DocumentPageTokenDetectedBreak {}
1168
1169/// Font and other text style attributes.
1170///
1171/// This type is not used in any activity, and only used as *part* of another schema.
1172///
1173#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1174#[serde_with::serde_as]
1175#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1176pub struct GoogleCloudDocumentaiV1beta2DocumentPageTokenStyleInfo {
1177 /// Color of the background.
1178 #[serde(rename = "backgroundColor")]
1179 pub background_color: Option<GoogleTypeColor>,
1180 /// Whether the text is bold (equivalent to font_weight is at least `700`).
1181 pub bold: Option<bool>,
1182 /// Font size in points (`1` point is `¹⁄₇₂` inches).
1183 #[serde(rename = "fontSize")]
1184 pub font_size: Option<i32>,
1185 /// Name or style of the font.
1186 #[serde(rename = "fontType")]
1187 pub font_type: Option<String>,
1188 /// TrueType weight on a scale `100` (thin) to `1000` (ultra-heavy). Normal is `400`, bold is `700`.
1189 #[serde(rename = "fontWeight")]
1190 pub font_weight: Option<i32>,
1191 /// Whether the text is handwritten.
1192 pub handwritten: Option<bool>,
1193 /// Whether the text is italic.
1194 pub italic: Option<bool>,
1195 /// Letter spacing in points.
1196 #[serde(rename = "letterSpacing")]
1197 pub letter_spacing: Option<f64>,
1198 /// Font size in pixels, equal to _unrounded font_size_ * _resolution_ ÷ `72.0`.
1199 #[serde(rename = "pixelFontSize")]
1200 pub pixel_font_size: Option<f64>,
1201 /// Whether the text is in small caps. This feature is not supported yet.
1202 pub smallcaps: Option<bool>,
1203 /// Whether the text is strikethrough. This feature is not supported yet.
1204 pub strikeout: Option<bool>,
1205 /// Whether the text is a subscript. This feature is not supported yet.
1206 pub subscript: Option<bool>,
1207 /// Whether the text is a superscript. This feature is not supported yet.
1208 pub superscript: Option<bool>,
1209 /// Color of the text.
1210 #[serde(rename = "textColor")]
1211 pub text_color: Option<GoogleTypeColor>,
1212 /// Whether the text is underlined.
1213 pub underlined: Option<bool>,
1214}
1215
1216impl common::Part for GoogleCloudDocumentaiV1beta2DocumentPageTokenStyleInfo {}
1217
1218/// Detected non-text visual elements e.g. checkbox, signature etc. on the page.
1219///
1220/// This type is not used in any activity, and only used as *part* of another schema.
1221///
1222#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1223#[serde_with::serde_as]
1224#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1225pub struct GoogleCloudDocumentaiV1beta2DocumentPageVisualElement {
1226 /// A list of detected languages together with confidence.
1227 #[serde(rename = "detectedLanguages")]
1228 pub detected_languages: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentPageDetectedLanguage>>,
1229 /// Layout for VisualElement.
1230 pub layout: Option<GoogleCloudDocumentaiV1beta2DocumentPageLayout>,
1231 /// Type of the VisualElement.
1232 #[serde(rename = "type")]
1233 pub type_: Option<String>,
1234}
1235
1236impl common::Part for GoogleCloudDocumentaiV1beta2DocumentPageVisualElement {}
1237
1238/// Structure to identify provenance relationships between annotations in different revisions.
1239///
1240/// This type is not used in any activity, and only used as *part* of another schema.
1241///
1242#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1243#[serde_with::serde_as]
1244#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1245pub struct GoogleCloudDocumentaiV1beta2DocumentProvenance {
1246 /// The Id of this operation. Needs to be unique within the scope of the revision.
1247 pub id: Option<i32>,
1248 /// References to the original elements that are replaced.
1249 pub parents: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentProvenanceParent>>,
1250 /// The index of the revision that produced this element.
1251 pub revision: Option<i32>,
1252 /// The type of provenance operation.
1253 #[serde(rename = "type")]
1254 pub type_: Option<String>,
1255}
1256
1257impl common::Part for GoogleCloudDocumentaiV1beta2DocumentProvenance {}
1258
1259/// The parent element the current element is based on. Used for referencing/aligning, removal and replacement operations.
1260///
1261/// This type is not used in any activity, and only used as *part* of another schema.
1262///
1263#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1264#[serde_with::serde_as]
1265#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1266pub struct GoogleCloudDocumentaiV1beta2DocumentProvenanceParent {
1267 /// The id of the parent provenance.
1268 pub id: Option<i32>,
1269 /// The index of the parent item in the corresponding item list (eg. list of entities, properties within entities, etc.) in the parent revision.
1270 pub index: Option<i32>,
1271 /// The index of the index into current revision's parent_ids list.
1272 pub revision: Option<i32>,
1273}
1274
1275impl common::Part for GoogleCloudDocumentaiV1beta2DocumentProvenanceParent {}
1276
1277/// Contains past or forward revisions of this document.
1278///
1279/// This type is not used in any activity, and only used as *part* of another schema.
1280///
1281#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1282#[serde_with::serde_as]
1283#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1284pub struct GoogleCloudDocumentaiV1beta2DocumentRevision {
1285 /// If the change was made by a person specify the name or id of that person.
1286 pub agent: Option<String>,
1287 /// The time that the revision was created, internally generated by doc proto storage at the time of create.
1288 #[serde(rename = "createTime")]
1289 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1290 /// Human Review information of this revision.
1291 #[serde(rename = "humanReview")]
1292 pub human_review: Option<GoogleCloudDocumentaiV1beta2DocumentRevisionHumanReview>,
1293 /// Id of the revision, internally generated by doc proto storage. Unique within the context of the document.
1294 pub id: Option<String>,
1295 /// The revisions that this revision is based on. This can include one or more parent (when documents are merged.) This field represents the index into the `revisions` field.
1296 pub parent: Option<Vec<i32>>,
1297 /// The revisions that this revision is based on. Must include all the ids that have anything to do with this revision - eg. there are `provenance.parent.revision` fields that index into this field.
1298 #[serde(rename = "parentIds")]
1299 pub parent_ids: Option<Vec<String>>,
1300 /// If the annotation was made by processor identify the processor by its resource name.
1301 pub processor: Option<String>,
1302}
1303
1304impl common::Part for GoogleCloudDocumentaiV1beta2DocumentRevision {}
1305
1306/// Human Review information of the document.
1307///
1308/// This type is not used in any activity, and only used as *part* of another schema.
1309///
1310#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1311#[serde_with::serde_as]
1312#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1313pub struct GoogleCloudDocumentaiV1beta2DocumentRevisionHumanReview {
1314 /// Human review state. e.g. `requested`, `succeeded`, `rejected`.
1315 pub state: Option<String>,
1316 /// A message providing more details about the current state of processing. For example, the rejection reason when the state is `rejected`.
1317 #[serde(rename = "stateMessage")]
1318 pub state_message: Option<String>,
1319}
1320
1321impl common::Part for GoogleCloudDocumentaiV1beta2DocumentRevisionHumanReview {}
1322
1323/// For a large document, sharding may be performed to produce several document shards. Each document shard contains this field to detail which shard it is.
1324///
1325/// This type is not used in any activity, and only used as *part* of another schema.
1326///
1327#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1328#[serde_with::serde_as]
1329#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1330pub struct GoogleCloudDocumentaiV1beta2DocumentShardInfo {
1331 /// Total number of shards.
1332 #[serde(rename = "shardCount")]
1333 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1334 pub shard_count: Option<i64>,
1335 /// The 0-based index of this shard.
1336 #[serde(rename = "shardIndex")]
1337 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1338 pub shard_index: Option<i64>,
1339 /// The index of the first character in Document.text in the overall document global text.
1340 #[serde(rename = "textOffset")]
1341 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1342 pub text_offset: Option<i64>,
1343}
1344
1345impl common::Part for GoogleCloudDocumentaiV1beta2DocumentShardInfo {}
1346
1347/// Annotation for common text style attributes. This adheres to CSS conventions as much as possible.
1348///
1349/// This type is not used in any activity, and only used as *part* of another schema.
1350///
1351#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1352#[serde_with::serde_as]
1353#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1354pub struct GoogleCloudDocumentaiV1beta2DocumentStyle {
1355 /// Text background color.
1356 #[serde(rename = "backgroundColor")]
1357 pub background_color: Option<GoogleTypeColor>,
1358 /// Text color.
1359 pub color: Option<GoogleTypeColor>,
1360 /// Font family such as `Arial`, `Times New Roman`. https://www.w3schools.com/cssref/pr_font_font-family.asp
1361 #[serde(rename = "fontFamily")]
1362 pub font_family: Option<String>,
1363 /// Font size.
1364 #[serde(rename = "fontSize")]
1365 pub font_size: Option<GoogleCloudDocumentaiV1beta2DocumentStyleFontSize>,
1366 /// [Font weight](https://www.w3schools.com/cssref/pr_font_weight.asp). Possible values are `normal`, `bold`, `bolder`, and `lighter`.
1367 #[serde(rename = "fontWeight")]
1368 pub font_weight: Option<String>,
1369 /// Text anchor indexing into the Document.text.
1370 #[serde(rename = "textAnchor")]
1371 pub text_anchor: Option<GoogleCloudDocumentaiV1beta2DocumentTextAnchor>,
1372 /// [Text decoration](https://www.w3schools.com/cssref/pr_text_text-decoration.asp). Follows CSS standard.
1373 #[serde(rename = "textDecoration")]
1374 pub text_decoration: Option<String>,
1375 /// [Text style](https://www.w3schools.com/cssref/pr_font_font-style.asp). Possible values are `normal`, `italic`, and `oblique`.
1376 #[serde(rename = "textStyle")]
1377 pub text_style: Option<String>,
1378}
1379
1380impl common::Part for GoogleCloudDocumentaiV1beta2DocumentStyle {}
1381
1382/// Font size with unit.
1383///
1384/// This type is not used in any activity, and only used as *part* of another schema.
1385///
1386#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1387#[serde_with::serde_as]
1388#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1389pub struct GoogleCloudDocumentaiV1beta2DocumentStyleFontSize {
1390 /// Font size for the text.
1391 pub size: Option<f32>,
1392 /// Unit for the font size. Follows CSS naming (such as `in`, `px`, and `pt`).
1393 pub unit: Option<String>,
1394}
1395
1396impl common::Part for GoogleCloudDocumentaiV1beta2DocumentStyleFontSize {}
1397
1398/// Text reference indexing into the Document.text.
1399///
1400/// This type is not used in any activity, and only used as *part* of another schema.
1401///
1402#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1403#[serde_with::serde_as]
1404#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1405pub struct GoogleCloudDocumentaiV1beta2DocumentTextAnchor {
1406 /// Contains the content of the text span so that users do not have to look it up in the text_segments. It is always populated for formFields.
1407 pub content: Option<String>,
1408 /// The text segments from the Document.text.
1409 #[serde(rename = "textSegments")]
1410 pub text_segments: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentTextAnchorTextSegment>>,
1411}
1412
1413impl common::Part for GoogleCloudDocumentaiV1beta2DocumentTextAnchor {}
1414
1415/// A text segment in the Document.text. The indices may be out of bounds which indicate that the text extends into another document shard for large sharded documents. See ShardInfo.text_offset
1416///
1417/// This type is not used in any activity, and only used as *part* of another schema.
1418///
1419#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1420#[serde_with::serde_as]
1421#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1422pub struct GoogleCloudDocumentaiV1beta2DocumentTextAnchorTextSegment {
1423 /// TextSegment half open end UTF-8 char index in the Document.text.
1424 #[serde(rename = "endIndex")]
1425 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1426 pub end_index: Option<i64>,
1427 /// TextSegment start UTF-8 char index in the Document.text.
1428 #[serde(rename = "startIndex")]
1429 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1430 pub start_index: Option<i64>,
1431}
1432
1433impl common::Part for GoogleCloudDocumentaiV1beta2DocumentTextAnchorTextSegment {}
1434
1435/// This message is used for text changes aka. OCR corrections.
1436///
1437/// This type is not used in any activity, and only used as *part* of another schema.
1438///
1439#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1440#[serde_with::serde_as]
1441#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1442pub struct GoogleCloudDocumentaiV1beta2DocumentTextChange {
1443 /// The text that replaces the text identified in the `text_anchor`.
1444 #[serde(rename = "changedText")]
1445 pub changed_text: Option<String>,
1446 /// The history of this annotation.
1447 pub provenance: Option<Vec<GoogleCloudDocumentaiV1beta2DocumentProvenance>>,
1448 /// Provenance of the correction. Text anchor indexing into the Document.text. There can only be a single `TextAnchor.text_segments` element. If the start and end index of the text segment are the same, the text change is inserted before that index.
1449 #[serde(rename = "textAnchor")]
1450 pub text_anchor: Option<GoogleCloudDocumentaiV1beta2DocumentTextAnchor>,
1451}
1452
1453impl common::Part for GoogleCloudDocumentaiV1beta2DocumentTextChange {}
1454
1455/// Parameters to control entity extraction behavior.
1456///
1457/// This type is not used in any activity, and only used as *part* of another schema.
1458///
1459#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1460#[serde_with::serde_as]
1461#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1462pub struct GoogleCloudDocumentaiV1beta2EntityExtractionParams {
1463 /// Whether to enable entity extraction.
1464 pub enabled: Option<bool>,
1465 /// Model version of the entity extraction. Default is "builtin/stable". Specify "builtin/latest" for the latest model.
1466 #[serde(rename = "modelVersion")]
1467 pub model_version: Option<String>,
1468}
1469
1470impl common::Part for GoogleCloudDocumentaiV1beta2EntityExtractionParams {}
1471
1472/// Parameters to control form extraction behavior.
1473///
1474/// This type is not used in any activity, and only used as *part* of another schema.
1475///
1476#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1477#[serde_with::serde_as]
1478#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1479pub struct GoogleCloudDocumentaiV1beta2FormExtractionParams {
1480 /// Whether to enable form extraction.
1481 pub enabled: Option<bool>,
1482 /// Reserved for future use.
1483 #[serde(rename = "keyValuePairHints")]
1484 pub key_value_pair_hints: Option<Vec<GoogleCloudDocumentaiV1beta2KeyValuePairHint>>,
1485 /// Model version of the form extraction system. Default is "builtin/stable". Specify "builtin/latest" for the latest model. For custom form models, specify: "custom/{model_name}". Model name format is "bucket_name/path/to/modeldir" corresponding to "gs://bucket_name/path/to/modeldir" where annotated examples are stored.
1486 #[serde(rename = "modelVersion")]
1487 pub model_version: Option<String>,
1488}
1489
1490impl common::Part for GoogleCloudDocumentaiV1beta2FormExtractionParams {}
1491
1492/// The Google Cloud Storage location where the output file will be written to.
1493///
1494/// This type is not used in any activity, and only used as *part* of another schema.
1495///
1496#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1497#[serde_with::serde_as]
1498#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1499pub struct GoogleCloudDocumentaiV1beta2GcsDestination {
1500 /// no description provided
1501 pub uri: Option<String>,
1502}
1503
1504impl common::Part for GoogleCloudDocumentaiV1beta2GcsDestination {}
1505
1506/// The Google Cloud Storage location where the input file will be read from.
1507///
1508/// This type is not used in any activity, and only used as *part* of another schema.
1509///
1510#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1511#[serde_with::serde_as]
1512#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1513pub struct GoogleCloudDocumentaiV1beta2GcsSource {
1514 /// no description provided
1515 pub uri: Option<String>,
1516}
1517
1518impl common::Part for GoogleCloudDocumentaiV1beta2GcsSource {}
1519
1520/// The desired input location and metadata.
1521///
1522/// This type is not used in any activity, and only used as *part* of another schema.
1523///
1524#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1525#[serde_with::serde_as]
1526#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1527pub struct GoogleCloudDocumentaiV1beta2InputConfig {
1528 /// Content in bytes, represented as a stream of bytes. Note: As with all `bytes` fields, proto buffer messages use a pure binary representation, whereas JSON representations use base64. This field only works for synchronous ProcessDocument method.
1529 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1530 pub contents: Option<Vec<u8>>,
1531 /// The Google Cloud Storage location to read the input from. This must be a single file.
1532 #[serde(rename = "gcsSource")]
1533 pub gcs_source: Option<GoogleCloudDocumentaiV1beta2GcsSource>,
1534 /// Required. Mimetype of the input. Current supported mimetypes are application/pdf, image/tiff, and image/gif. In addition, application/json type is supported for requests with ProcessDocumentRequest.automl_params field set. The JSON file needs to be in Document format.
1535 #[serde(rename = "mimeType")]
1536 pub mime_type: Option<String>,
1537}
1538
1539impl common::Part for GoogleCloudDocumentaiV1beta2InputConfig {}
1540
1541/// Reserved for future use.
1542///
1543/// This type is not used in any activity, and only used as *part* of another schema.
1544///
1545#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1546#[serde_with::serde_as]
1547#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1548pub struct GoogleCloudDocumentaiV1beta2KeyValuePairHint {
1549 /// The key text for the hint.
1550 pub key: Option<String>,
1551 /// Type of the value. This is case-insensitive, and could be one of: ADDRESS, LOCATION, ORGANIZATION, PERSON, PHONE_NUMBER, ID, NUMBER, EMAIL, PRICE, TERMS, DATE, NAME. Types not in this list will be ignored.
1552 #[serde(rename = "valueTypes")]
1553 pub value_types: Option<Vec<String>>,
1554}
1555
1556impl common::Part for GoogleCloudDocumentaiV1beta2KeyValuePairHint {}
1557
1558/// A vertex represents a 2D point in the image. NOTE: the normalized vertex coordinates are relative to the original image and range from 0 to 1.
1559///
1560/// This type is not used in any activity, and only used as *part* of another schema.
1561///
1562#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1563#[serde_with::serde_as]
1564#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1565pub struct GoogleCloudDocumentaiV1beta2NormalizedVertex {
1566 /// X coordinate.
1567 pub x: Option<f32>,
1568 /// Y coordinate (starts from the top of the image).
1569 pub y: Option<f32>,
1570}
1571
1572impl common::Part for GoogleCloudDocumentaiV1beta2NormalizedVertex {}
1573
1574/// Parameters to control Optical Character Recognition (OCR) behavior.
1575///
1576/// This type is not used in any activity, and only used as *part* of another schema.
1577///
1578#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1579#[serde_with::serde_as]
1580#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1581pub struct GoogleCloudDocumentaiV1beta2OcrParams {
1582 /// List of languages to use for OCR. In most cases, an empty value yields the best results since it enables automatic language detection. For languages based on the Latin alphabet, setting `language_hints` is not needed. In rare cases, when the language of the text in the image is known, setting a hint will help get better results (although it will be a significant hindrance if the hint is wrong). Document processing returns an error if one or more of the specified languages is not one of the supported languages.
1583 #[serde(rename = "languageHints")]
1584 pub language_hints: Option<Vec<String>>,
1585}
1586
1587impl common::Part for GoogleCloudDocumentaiV1beta2OcrParams {}
1588
1589/// The desired output location and metadata.
1590///
1591/// This type is not used in any activity, and only used as *part* of another schema.
1592///
1593#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1594#[serde_with::serde_as]
1595#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1596pub struct GoogleCloudDocumentaiV1beta2OutputConfig {
1597 /// The Google Cloud Storage location to write the output to.
1598 #[serde(rename = "gcsDestination")]
1599 pub gcs_destination: Option<GoogleCloudDocumentaiV1beta2GcsDestination>,
1600 /// The max number of pages to include into each output Document shard JSON on Google Cloud Storage. The valid range is [1, 100]. If not specified, the default value is 20. For example, for one pdf file with 100 pages, 100 parsed pages will be produced. If `pages_per_shard` = 20, then 5 Document shard JSON files each containing 20 parsed pages will be written under the prefix OutputConfig.gcs_destination.uri and suffix pages-x-to-y.json where x and y are 1-indexed page numbers. Example GCS outputs with 157 pages and pages_per_shard = 50: pages-001-to-050.json pages-051-to-100.json pages-101-to-150.json pages-151-to-157.json
1601 #[serde(rename = "pagesPerShard")]
1602 pub pages_per_shard: Option<i32>,
1603}
1604
1605impl common::Part for GoogleCloudDocumentaiV1beta2OutputConfig {}
1606
1607/// Request to process one document.
1608///
1609/// # Activities
1610///
1611/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1612/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1613///
1614/// * [documents process projects](ProjectDocumentProcesCall) (request)
1615/// * [locations documents process projects](ProjectLocationDocumentProcesCall) (request)
1616#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1617#[serde_with::serde_as]
1618#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1619pub struct GoogleCloudDocumentaiV1beta2ProcessDocumentRequest {
1620 /// Controls AutoML model prediction behavior. AutoMlParams cannot be used together with other Params.
1621 #[serde(rename = "automlParams")]
1622 pub automl_params: Option<GoogleCloudDocumentaiV1beta2AutoMlParams>,
1623 /// Specifies a known document type for deeper structure detection. Valid values are currently "general" and "invoice". If not provided, "general"\ is used as default. If any other value is given, the request is rejected.
1624 #[serde(rename = "documentType")]
1625 pub document_type: Option<String>,
1626 /// Controls entity extraction behavior. If not specified, the system will decide reasonable defaults.
1627 #[serde(rename = "entityExtractionParams")]
1628 pub entity_extraction_params: Option<GoogleCloudDocumentaiV1beta2EntityExtractionParams>,
1629 /// Controls form extraction behavior. If not specified, the system will decide reasonable defaults.
1630 #[serde(rename = "formExtractionParams")]
1631 pub form_extraction_params: Option<GoogleCloudDocumentaiV1beta2FormExtractionParams>,
1632 /// Required. Information about the input file.
1633 #[serde(rename = "inputConfig")]
1634 pub input_config: Option<GoogleCloudDocumentaiV1beta2InputConfig>,
1635 /// Controls OCR behavior. If not specified, the system will decide reasonable defaults.
1636 #[serde(rename = "ocrParams")]
1637 pub ocr_params: Option<GoogleCloudDocumentaiV1beta2OcrParams>,
1638 /// The desired output location. This field is only needed in BatchProcessDocumentsRequest.
1639 #[serde(rename = "outputConfig")]
1640 pub output_config: Option<GoogleCloudDocumentaiV1beta2OutputConfig>,
1641 /// Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no location is specified, a region will be chosen automatically. This field is only populated when used in ProcessDocument method.
1642 pub parent: Option<String>,
1643 /// Controls table extraction behavior. If not specified, the system will decide reasonable defaults.
1644 #[serde(rename = "tableExtractionParams")]
1645 pub table_extraction_params: Option<GoogleCloudDocumentaiV1beta2TableExtractionParams>,
1646}
1647
1648impl common::RequestValue for GoogleCloudDocumentaiV1beta2ProcessDocumentRequest {}
1649
1650/// A hint for a table bounding box on the page for table parsing.
1651///
1652/// This type is not used in any activity, and only used as *part* of another schema.
1653///
1654#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1655#[serde_with::serde_as]
1656#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1657pub struct GoogleCloudDocumentaiV1beta2TableBoundHint {
1658 /// Bounding box hint for a table on this page. The coordinates must be normalized to [0,1] and the bounding box must be an axis-aligned rectangle.
1659 #[serde(rename = "boundingBox")]
1660 pub bounding_box: Option<GoogleCloudDocumentaiV1beta2BoundingPoly>,
1661 /// Optional. Page number for multi-paged inputs this hint applies to. If not provided, this hint will apply to all pages by default. This value is 1-based.
1662 #[serde(rename = "pageNumber")]
1663 pub page_number: Option<i32>,
1664}
1665
1666impl common::Part for GoogleCloudDocumentaiV1beta2TableBoundHint {}
1667
1668/// Parameters to control table extraction behavior.
1669///
1670/// This type is not used in any activity, and only used as *part* of another schema.
1671///
1672#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1673#[serde_with::serde_as]
1674#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1675pub struct GoogleCloudDocumentaiV1beta2TableExtractionParams {
1676 /// Whether to enable table extraction.
1677 pub enabled: Option<bool>,
1678 /// Optional. Reserved for future use.
1679 #[serde(rename = "headerHints")]
1680 pub header_hints: Option<Vec<String>>,
1681 /// Model version of the table extraction system. Default is "builtin/stable". Specify "builtin/latest" for the latest model.
1682 #[serde(rename = "modelVersion")]
1683 pub model_version: Option<String>,
1684 /// Optional. Table bounding box hints that can be provided to complex cases which our algorithm cannot locate the table(s) in.
1685 #[serde(rename = "tableBoundHints")]
1686 pub table_bound_hints: Option<Vec<GoogleCloudDocumentaiV1beta2TableBoundHint>>,
1687}
1688
1689impl common::Part for GoogleCloudDocumentaiV1beta2TableExtractionParams {}
1690
1691/// A vertex represents a 2D point in the image. NOTE: the vertex coordinates are in the same scale as the original image.
1692///
1693/// This type is not used in any activity, and only used as *part* of another schema.
1694///
1695#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1696#[serde_with::serde_as]
1697#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1698pub struct GoogleCloudDocumentaiV1beta2Vertex {
1699 /// X coordinate.
1700 pub x: Option<i32>,
1701 /// Y coordinate (starts from the top of the image).
1702 pub y: Option<i32>,
1703}
1704
1705impl common::Part for GoogleCloudDocumentaiV1beta2Vertex {}
1706
1707/// This resource represents a long-running operation that is the result of a network API call.
1708///
1709/// # Activities
1710///
1711/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1712/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1713///
1714/// * [documents batch process projects](ProjectDocumentBatchProcesCall) (response)
1715/// * [locations documents batch process projects](ProjectLocationDocumentBatchProcesCall) (response)
1716/// * [locations operations get projects](ProjectLocationOperationGetCall) (response)
1717/// * [operations get projects](ProjectOperationGetCall) (response)
1718#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1719#[serde_with::serde_as]
1720#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1721pub struct GoogleLongrunningOperation {
1722 /// If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available.
1723 pub done: Option<bool>,
1724 /// The error result of the operation in case of failure or cancellation.
1725 pub error: Option<GoogleRpcStatus>,
1726 /// Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any.
1727 pub metadata: Option<HashMap<String, serde_json::Value>>,
1728 /// The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`.
1729 pub name: Option<String>,
1730 /// The normal, successful response of the operation. If the original method returns no data on success, such as `Delete`, the response is `google.protobuf.Empty`. If the original method is standard `Get`/`Create`/`Update`, the response should be the resource. For other methods, the response should have the type `XxxResponse`, where `Xxx` is the original method name. For example, if the original method name is `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`.
1731 pub response: Option<HashMap<String, serde_json::Value>>,
1732}
1733
1734impl common::ResponseResult for GoogleLongrunningOperation {}
1735
1736/// The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).
1737///
1738/// This type is not used in any activity, and only used as *part* of another schema.
1739///
1740#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1741#[serde_with::serde_as]
1742#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1743pub struct GoogleRpcStatus {
1744 /// The status code, which should be an enum value of google.rpc.Code.
1745 pub code: Option<i32>,
1746 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
1747 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
1748 /// A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
1749 pub message: Option<String>,
1750}
1751
1752impl common::Part for GoogleRpcStatus {}
1753
1754/// Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to and from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of `java.awt.Color` in Java; it can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` method in iOS; and, with just a little work, it can be easily formatted into a CSS `rgba()` string in JavaScript. This reference page doesn't have information about the absolute color space that should be used to interpret the RGB value—for example, sRGB, Adobe RGB, DCI-P3, and BT.2020. By default, applications should assume the sRGB color space. When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most `1e-5`. Example (Java): import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... Example (iOS / Obj-C): // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } static Color* toProto(UIColor* color) { CGFloat red, green, blue, alpha; if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { return nil; } Color* result = [[Color alloc] init]; [result setRed:red]; [result setGreen:green]; [result setBlue:blue]; if (alpha <= 0.9999) { [result setAlpha:floatWrapperWithValue(alpha)]; } [result autorelease]; return result; } // ... Example (JavaScript): // ... var protoToCssColor = function(rgb_color) { var redFrac = rgb_color.red || 0.0; var greenFrac = rgb_color.green || 0.0; var blueFrac = rgb_color.blue || 0.0; var red = Math.floor(redFrac * 255); var green = Math.floor(greenFrac * 255); var blue = Math.floor(blueFrac * 255); if (!('alpha' in rgb_color)) { return rgbToCssColor(red, green, blue); } var alphaFrac = rgb_color.alpha.value || 0.0; var rgbParams = [red, green, blue].join(','); return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); }; var rgbToCssColor = function(red, green, blue) { var rgbNumber = new Number((red << 16) | (green << 8) | blue); var hexString = rgbNumber.toString(16); var missingZeros = 6 - hexString.length; var resultBuilder = ['#']; for (var i = 0; i < missingZeros; i++) { resultBuilder.push('0'); } resultBuilder.push(hexString); return resultBuilder.join(''); }; // ...
1755///
1756/// This type is not used in any activity, and only used as *part* of another schema.
1757///
1758#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1759#[serde_with::serde_as]
1760#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1761pub struct GoogleTypeColor {
1762 /// The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0).
1763 pub alpha: Option<f32>,
1764 /// The amount of blue in the color as a value in the interval [0, 1].
1765 pub blue: Option<f32>,
1766 /// The amount of green in the color as a value in the interval [0, 1].
1767 pub green: Option<f32>,
1768 /// The amount of red in the color as a value in the interval [0, 1].
1769 pub red: Option<f32>,
1770}
1771
1772impl common::Part for GoogleTypeColor {}
1773
1774/// Represents a whole or partial calendar date, such as a birthday. The time of day and time zone are either specified elsewhere or are insignificant. The date is relative to the Gregorian Calendar. This can represent one of the following: * A full date, with non-zero year, month, and day values. * A month and day, with a zero year (for example, an anniversary). * A year on its own, with a zero month and a zero day. * A year and month, with a zero day (for example, a credit card expiration date). Related types: * google.type.TimeOfDay * google.type.DateTime * google.protobuf.Timestamp
1775///
1776/// This type is not used in any activity, and only used as *part* of another schema.
1777///
1778#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1779#[serde_with::serde_as]
1780#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1781pub struct GoogleTypeDate {
1782 /// Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
1783 pub day: Option<i32>,
1784 /// Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
1785 pub month: Option<i32>,
1786 /// Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
1787 pub year: Option<i32>,
1788}
1789
1790impl common::Part for GoogleTypeDate {}
1791
1792/// Represents civil time (or occasionally physical time). This type can represent a civil time in one of a few possible ways: * When utc_offset is set and time_zone is unset: a civil time on a calendar day with a particular offset from UTC. * When time_zone is set and utc_offset is unset: a civil time on a calendar day in a particular time zone. * When neither time_zone nor utc_offset is set: a civil time on a calendar day in local time. The date is relative to the Proleptic Gregorian Calendar. If year, month, or day are 0, the DateTime is considered not to have a specific year, month, or day respectively. This type may also be used to represent a physical time if all the date and time fields are set and either case of the `time_offset` oneof is set. Consider using `Timestamp` message for physical time instead. If your use case also would like to store the user's timezone, that can be done in another field. This type is more flexible than some applications may want. Make sure to document and validate your application's limitations.
1793///
1794/// This type is not used in any activity, and only used as *part* of another schema.
1795///
1796#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1797#[serde_with::serde_as]
1798#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1799pub struct GoogleTypeDateTime {
1800 /// Optional. Day of month. Must be from 1 to 31 and valid for the year and month, or 0 if specifying a datetime without a day.
1801 pub day: Option<i32>,
1802 /// Optional. Hours of day in 24 hour format. Should be from 0 to 23, defaults to 0 (midnight). An API may choose to allow the value "24:00:00" for scenarios like business closing time.
1803 pub hours: Option<i32>,
1804 /// Optional. Minutes of hour of day. Must be from 0 to 59, defaults to 0.
1805 pub minutes: Option<i32>,
1806 /// Optional. Month of year. Must be from 1 to 12, or 0 if specifying a datetime without a month.
1807 pub month: Option<i32>,
1808 /// Optional. Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999, defaults to 0.
1809 pub nanos: Option<i32>,
1810 /// Optional. Seconds of minutes of the time. Must normally be from 0 to 59, defaults to 0. An API may allow the value 60 if it allows leap-seconds.
1811 pub seconds: Option<i32>,
1812 /// Time zone.
1813 #[serde(rename = "timeZone")]
1814 pub time_zone: Option<GoogleTypeTimeZone>,
1815 /// UTC offset. Must be whole seconds, between -18 hours and +18 hours. For example, a UTC offset of -4:00 would be represented as { seconds: -14400 }.
1816 #[serde(rename = "utcOffset")]
1817 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1818 pub utc_offset: Option<chrono::Duration>,
1819 /// Optional. Year of date. Must be from 1 to 9999, or 0 if specifying a datetime without a year.
1820 pub year: Option<i32>,
1821}
1822
1823impl common::Part for GoogleTypeDateTime {}
1824
1825/// Represents an amount of money with its currency type.
1826///
1827/// This type is not used in any activity, and only used as *part* of another schema.
1828///
1829#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1830#[serde_with::serde_as]
1831#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1832pub struct GoogleTypeMoney {
1833 /// The three-letter currency code defined in ISO 4217.
1834 #[serde(rename = "currencyCode")]
1835 pub currency_code: Option<String>,
1836 /// Number of nano (10^-9) units of the amount. The value must be between -999,999,999 and +999,999,999 inclusive. If `units` is positive, `nanos` must be positive or zero. If `units` is zero, `nanos` can be positive, zero, or negative. If `units` is negative, `nanos` must be negative or zero. For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000.
1837 pub nanos: Option<i32>,
1838 /// The whole units of the amount. For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar.
1839 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1840 pub units: Option<i64>,
1841}
1842
1843impl common::Part for GoogleTypeMoney {}
1844
1845/// Represents a postal address, e.g. for postal delivery or payments addresses. Given a postal address, a postal service can deliver items to a premise, P.O. Box or similar. It is not intended to model geographical locations (roads, towns, mountains). In typical usage an address would be created via user input or from importing existing data, depending on the type of process. Advice on address input / editing: - Use an internationalization-ready address widget such as https://github.com/google/libaddressinput) - Users should not be presented with UI elements for input or editing of fields outside countries where that field is used. For more guidance on how to use this schema, please see: https://support.google.com/business/answer/6397478
1846///
1847/// This type is not used in any activity, and only used as *part* of another schema.
1848///
1849#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1850#[serde_with::serde_as]
1851#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1852pub struct GoogleTypePostalAddress {
1853 /// Unstructured address lines describing the lower levels of an address. Because values in address_lines do not have type information and may sometimes contain multiple values in a single field (e.g. "Austin, TX"), it is important that the line order is clear. The order of address lines should be "envelope order" for the country/region of the address. In places where this can vary (e.g. Japan), address_language is used to make it explicit (e.g. "ja" for large-to-small ordering and "ja-Latn" or "en" for small-to-large). This way, the most specific line of an address can be selected based on the language. The minimum permitted structural representation of an address consists of a region_code with all remaining information placed in the address_lines. It would be possible to format such an address very approximately without geocoding, but no semantic reasoning could be made about any of the address components until it was at least partially resolved. Creating an address only containing a region_code and address_lines, and then geocoding is the recommended way to handle completely unstructured addresses (as opposed to guessing which parts of the address should be localities or administrative areas).
1854 #[serde(rename = "addressLines")]
1855 pub address_lines: Option<Vec<String>>,
1856 /// Optional. Highest administrative subdivision which is used for postal addresses of a country or region. For example, this can be a state, a province, an oblast, or a prefecture. Specifically, for Spain this is the province and not the autonomous community (e.g. "Barcelona" and not "Catalonia"). Many countries don't use an administrative area in postal addresses. E.g. in Switzerland this should be left unpopulated.
1857 #[serde(rename = "administrativeArea")]
1858 pub administrative_area: Option<String>,
1859 /// Optional. BCP-47 language code of the contents of this address (if known). This is often the UI language of the input form or is expected to match one of the languages used in the address' country/region, or their transliterated equivalents. This can affect formatting in certain countries, but is not critical to the correctness of the data and will never affect any validation or other non-formatting related operations. If this value is not known, it should be omitted (rather than specifying a possibly incorrect default). Examples: "zh-Hant", "ja", "ja-Latn", "en".
1860 #[serde(rename = "languageCode")]
1861 pub language_code: Option<String>,
1862 /// Optional. Generally refers to the city/town portion of the address. Examples: US city, IT comune, UK post town. In regions of the world where localities are not well defined or do not fit into this structure well, leave locality empty and use address_lines.
1863 pub locality: Option<String>,
1864 /// Optional. The name of the organization at the address.
1865 pub organization: Option<String>,
1866 /// Optional. Postal code of the address. Not all countries use or require postal codes to be present, but where they are used, they may trigger additional validation with other parts of the address (e.g. state/zip validation in the U.S.A.).
1867 #[serde(rename = "postalCode")]
1868 pub postal_code: Option<String>,
1869 /// Optional. The recipient at the address. This field may, under certain circumstances, contain multiline information. For example, it might contain "care of" information.
1870 pub recipients: Option<Vec<String>>,
1871 /// Required. CLDR region code of the country/region of the address. This is never inferred and it is up to the user to ensure the value is correct. See https://cldr.unicode.org/ and https://www.unicode.org/cldr/charts/30/supplemental/territory_information.html for details. Example: "CH" for Switzerland.
1872 #[serde(rename = "regionCode")]
1873 pub region_code: Option<String>,
1874 /// The schema revision of the `PostalAddress`. This must be set to 0, which is the latest revision. All new revisions **must** be backward compatible with old revisions.
1875 pub revision: Option<i32>,
1876 /// Optional. Additional, country-specific, sorting code. This is not used in most regions. Where it is used, the value is either a string like "CEDEX", optionally followed by a number (e.g. "CEDEX 7"), or just a number alone, representing the "sector code" (Jamaica), "delivery area indicator" (Malawi) or "post office indicator" (e.g. Côte d'Ivoire).
1877 #[serde(rename = "sortingCode")]
1878 pub sorting_code: Option<String>,
1879 /// Optional. Sublocality of the address. For example, this can be neighborhoods, boroughs, districts.
1880 pub sublocality: Option<String>,
1881}
1882
1883impl common::Part for GoogleTypePostalAddress {}
1884
1885/// Represents a time zone from the [IANA Time Zone Database](https://www.iana.org/time-zones).
1886///
1887/// This type is not used in any activity, and only used as *part* of another schema.
1888///
1889#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1890#[serde_with::serde_as]
1891#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1892pub struct GoogleTypeTimeZone {
1893 /// IANA Time Zone Database time zone, e.g. "America/New_York".
1894 pub id: Option<String>,
1895 /// Optional. IANA Time Zone Database version number, e.g. "2019a".
1896 pub version: Option<String>,
1897}
1898
1899impl common::Part for GoogleTypeTimeZone {}
1900
1901// ###################
1902// MethodBuilders ###
1903// #################
1904
1905/// A builder providing access to all methods supported on *project* resources.
1906/// It is not used directly, but through the [`Document`] hub.
1907///
1908/// # Example
1909///
1910/// Instantiate a resource builder
1911///
1912/// ```test_harness,no_run
1913/// extern crate hyper;
1914/// extern crate hyper_rustls;
1915/// extern crate google_documentai1_beta2 as documentai1_beta2;
1916///
1917/// # async fn dox() {
1918/// use documentai1_beta2::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1919///
1920/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1921/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1922/// .with_native_roots()
1923/// .unwrap()
1924/// .https_only()
1925/// .enable_http2()
1926/// .build();
1927///
1928/// let executor = hyper_util::rt::TokioExecutor::new();
1929/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1930/// secret,
1931/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1932/// yup_oauth2::client::CustomHyperClientBuilder::from(
1933/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1934/// ),
1935/// ).build().await.unwrap();
1936///
1937/// let client = hyper_util::client::legacy::Client::builder(
1938/// hyper_util::rt::TokioExecutor::new()
1939/// )
1940/// .build(
1941/// hyper_rustls::HttpsConnectorBuilder::new()
1942/// .with_native_roots()
1943/// .unwrap()
1944/// .https_or_http()
1945/// .enable_http2()
1946/// .build()
1947/// );
1948/// let mut hub = Document::new(client, auth);
1949/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1950/// // like `documents_batch_process(...)`, `documents_process(...)`, `locations_documents_batch_process(...)`, `locations_documents_process(...)`, `locations_operations_get(...)` and `operations_get(...)`
1951/// // to build up your call.
1952/// let rb = hub.projects();
1953/// # }
1954/// ```
1955pub struct ProjectMethods<'a, C>
1956where
1957 C: 'a,
1958{
1959 hub: &'a Document<C>,
1960}
1961
1962impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
1963
1964impl<'a, C> ProjectMethods<'a, C> {
1965 /// Create a builder to help you perform the following task:
1966 ///
1967 /// LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in the [Document] format.
1968 ///
1969 /// # Arguments
1970 ///
1971 /// * `request` - No description provided.
1972 /// * `parent` - Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no location is specified, a region will be chosen automatically.
1973 pub fn documents_batch_process(
1974 &self,
1975 request: GoogleCloudDocumentaiV1beta2BatchProcessDocumentsRequest,
1976 parent: &str,
1977 ) -> ProjectDocumentBatchProcesCall<'a, C> {
1978 ProjectDocumentBatchProcesCall {
1979 hub: self.hub,
1980 _request: request,
1981 _parent: parent.to_string(),
1982 _delegate: Default::default(),
1983 _additional_params: Default::default(),
1984 _scopes: Default::default(),
1985 }
1986 }
1987
1988 /// Create a builder to help you perform the following task:
1989 ///
1990 /// Processes a single document.
1991 ///
1992 /// # Arguments
1993 ///
1994 /// * `request` - No description provided.
1995 /// * `parent` - Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no location is specified, a region will be chosen automatically. This field is only populated when used in ProcessDocument method.
1996 pub fn documents_process(
1997 &self,
1998 request: GoogleCloudDocumentaiV1beta2ProcessDocumentRequest,
1999 parent: &str,
2000 ) -> ProjectDocumentProcesCall<'a, C> {
2001 ProjectDocumentProcesCall {
2002 hub: self.hub,
2003 _request: request,
2004 _parent: parent.to_string(),
2005 _delegate: Default::default(),
2006 _additional_params: Default::default(),
2007 _scopes: Default::default(),
2008 }
2009 }
2010
2011 /// Create a builder to help you perform the following task:
2012 ///
2013 /// LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in the [Document] format.
2014 ///
2015 /// # Arguments
2016 ///
2017 /// * `request` - No description provided.
2018 /// * `parent` - Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no location is specified, a region will be chosen automatically.
2019 pub fn locations_documents_batch_process(
2020 &self,
2021 request: GoogleCloudDocumentaiV1beta2BatchProcessDocumentsRequest,
2022 parent: &str,
2023 ) -> ProjectLocationDocumentBatchProcesCall<'a, C> {
2024 ProjectLocationDocumentBatchProcesCall {
2025 hub: self.hub,
2026 _request: request,
2027 _parent: parent.to_string(),
2028 _delegate: Default::default(),
2029 _additional_params: Default::default(),
2030 _scopes: Default::default(),
2031 }
2032 }
2033
2034 /// Create a builder to help you perform the following task:
2035 ///
2036 /// Processes a single document.
2037 ///
2038 /// # Arguments
2039 ///
2040 /// * `request` - No description provided.
2041 /// * `parent` - Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no location is specified, a region will be chosen automatically. This field is only populated when used in ProcessDocument method.
2042 pub fn locations_documents_process(
2043 &self,
2044 request: GoogleCloudDocumentaiV1beta2ProcessDocumentRequest,
2045 parent: &str,
2046 ) -> ProjectLocationDocumentProcesCall<'a, C> {
2047 ProjectLocationDocumentProcesCall {
2048 hub: self.hub,
2049 _request: request,
2050 _parent: parent.to_string(),
2051 _delegate: Default::default(),
2052 _additional_params: Default::default(),
2053 _scopes: Default::default(),
2054 }
2055 }
2056
2057 /// Create a builder to help you perform the following task:
2058 ///
2059 /// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
2060 ///
2061 /// # Arguments
2062 ///
2063 /// * `name` - The name of the operation resource.
2064 pub fn locations_operations_get(&self, name: &str) -> ProjectLocationOperationGetCall<'a, C> {
2065 ProjectLocationOperationGetCall {
2066 hub: self.hub,
2067 _name: name.to_string(),
2068 _delegate: Default::default(),
2069 _additional_params: Default::default(),
2070 _scopes: Default::default(),
2071 }
2072 }
2073
2074 /// Create a builder to help you perform the following task:
2075 ///
2076 /// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
2077 ///
2078 /// # Arguments
2079 ///
2080 /// * `name` - The name of the operation resource.
2081 pub fn operations_get(&self, name: &str) -> ProjectOperationGetCall<'a, C> {
2082 ProjectOperationGetCall {
2083 hub: self.hub,
2084 _name: name.to_string(),
2085 _delegate: Default::default(),
2086 _additional_params: Default::default(),
2087 _scopes: Default::default(),
2088 }
2089 }
2090}
2091
2092// ###################
2093// CallBuilders ###
2094// #################
2095
2096/// LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in the [Document] format.
2097///
2098/// A builder for the *documents.batchProcess* method supported by a *project* resource.
2099/// It is not used directly, but through a [`ProjectMethods`] instance.
2100///
2101/// # Example
2102///
2103/// Instantiate a resource method builder
2104///
2105/// ```test_harness,no_run
2106/// # extern crate hyper;
2107/// # extern crate hyper_rustls;
2108/// # extern crate google_documentai1_beta2 as documentai1_beta2;
2109/// use documentai1_beta2::api::GoogleCloudDocumentaiV1beta2BatchProcessDocumentsRequest;
2110/// # async fn dox() {
2111/// # use documentai1_beta2::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2112///
2113/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2114/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2115/// # .with_native_roots()
2116/// # .unwrap()
2117/// # .https_only()
2118/// # .enable_http2()
2119/// # .build();
2120///
2121/// # let executor = hyper_util::rt::TokioExecutor::new();
2122/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2123/// # secret,
2124/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2125/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2126/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2127/// # ),
2128/// # ).build().await.unwrap();
2129///
2130/// # let client = hyper_util::client::legacy::Client::builder(
2131/// # hyper_util::rt::TokioExecutor::new()
2132/// # )
2133/// # .build(
2134/// # hyper_rustls::HttpsConnectorBuilder::new()
2135/// # .with_native_roots()
2136/// # .unwrap()
2137/// # .https_or_http()
2138/// # .enable_http2()
2139/// # .build()
2140/// # );
2141/// # let mut hub = Document::new(client, auth);
2142/// // As the method needs a request, you would usually fill it with the desired information
2143/// // into the respective structure. Some of the parts shown here might not be applicable !
2144/// // Values shown here are possibly random and not representative !
2145/// let mut req = GoogleCloudDocumentaiV1beta2BatchProcessDocumentsRequest::default();
2146///
2147/// // You can configure optional parameters by calling the respective setters at will, and
2148/// // execute the final call using `doit()`.
2149/// // Values shown here are possibly random and not representative !
2150/// let result = hub.projects().documents_batch_process(req, "parent")
2151/// .doit().await;
2152/// # }
2153/// ```
2154pub struct ProjectDocumentBatchProcesCall<'a, C>
2155where
2156 C: 'a,
2157{
2158 hub: &'a Document<C>,
2159 _request: GoogleCloudDocumentaiV1beta2BatchProcessDocumentsRequest,
2160 _parent: String,
2161 _delegate: Option<&'a mut dyn common::Delegate>,
2162 _additional_params: HashMap<String, String>,
2163 _scopes: BTreeSet<String>,
2164}
2165
2166impl<'a, C> common::CallBuilder for ProjectDocumentBatchProcesCall<'a, C> {}
2167
2168impl<'a, C> ProjectDocumentBatchProcesCall<'a, C>
2169where
2170 C: common::Connector,
2171{
2172 /// Perform the operation you have build so far.
2173 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
2174 use std::borrow::Cow;
2175 use std::io::{Read, Seek};
2176
2177 use common::{url::Params, ToParts};
2178 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2179
2180 let mut dd = common::DefaultDelegate;
2181 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2182 dlg.begin(common::MethodInfo {
2183 id: "documentai.projects.documents.batchProcess",
2184 http_method: hyper::Method::POST,
2185 });
2186
2187 for &field in ["alt", "parent"].iter() {
2188 if self._additional_params.contains_key(field) {
2189 dlg.finished(false);
2190 return Err(common::Error::FieldClash(field));
2191 }
2192 }
2193
2194 let mut params = Params::with_capacity(4 + self._additional_params.len());
2195 params.push("parent", self._parent);
2196
2197 params.extend(self._additional_params.iter());
2198
2199 params.push("alt", "json");
2200 let mut url = self.hub._base_url.clone() + "v1beta2/{+parent}/documents:batchProcess";
2201 if self._scopes.is_empty() {
2202 self._scopes
2203 .insert(Scope::CloudPlatform.as_ref().to_string());
2204 }
2205
2206 #[allow(clippy::single_element_loop)]
2207 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2208 url = params.uri_replacement(url, param_name, find_this, true);
2209 }
2210 {
2211 let to_remove = ["parent"];
2212 params.remove_params(&to_remove);
2213 }
2214
2215 let url = params.parse_with_url(&url);
2216
2217 let mut json_mime_type = mime::APPLICATION_JSON;
2218 let mut request_value_reader = {
2219 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2220 common::remove_json_null_values(&mut value);
2221 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2222 serde_json::to_writer(&mut dst, &value).unwrap();
2223 dst
2224 };
2225 let request_size = request_value_reader
2226 .seek(std::io::SeekFrom::End(0))
2227 .unwrap();
2228 request_value_reader
2229 .seek(std::io::SeekFrom::Start(0))
2230 .unwrap();
2231
2232 loop {
2233 let token = match self
2234 .hub
2235 .auth
2236 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2237 .await
2238 {
2239 Ok(token) => token,
2240 Err(e) => match dlg.token(e) {
2241 Ok(token) => token,
2242 Err(e) => {
2243 dlg.finished(false);
2244 return Err(common::Error::MissingToken(e));
2245 }
2246 },
2247 };
2248 request_value_reader
2249 .seek(std::io::SeekFrom::Start(0))
2250 .unwrap();
2251 let mut req_result = {
2252 let client = &self.hub.client;
2253 dlg.pre_request();
2254 let mut req_builder = hyper::Request::builder()
2255 .method(hyper::Method::POST)
2256 .uri(url.as_str())
2257 .header(USER_AGENT, self.hub._user_agent.clone());
2258
2259 if let Some(token) = token.as_ref() {
2260 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2261 }
2262
2263 let request = req_builder
2264 .header(CONTENT_TYPE, json_mime_type.to_string())
2265 .header(CONTENT_LENGTH, request_size as u64)
2266 .body(common::to_body(
2267 request_value_reader.get_ref().clone().into(),
2268 ));
2269
2270 client.request(request.unwrap()).await
2271 };
2272
2273 match req_result {
2274 Err(err) => {
2275 if let common::Retry::After(d) = dlg.http_error(&err) {
2276 sleep(d).await;
2277 continue;
2278 }
2279 dlg.finished(false);
2280 return Err(common::Error::HttpError(err));
2281 }
2282 Ok(res) => {
2283 let (mut parts, body) = res.into_parts();
2284 let mut body = common::Body::new(body);
2285 if !parts.status.is_success() {
2286 let bytes = common::to_bytes(body).await.unwrap_or_default();
2287 let error = serde_json::from_str(&common::to_string(&bytes));
2288 let response = common::to_response(parts, bytes.into());
2289
2290 if let common::Retry::After(d) =
2291 dlg.http_failure(&response, error.as_ref().ok())
2292 {
2293 sleep(d).await;
2294 continue;
2295 }
2296
2297 dlg.finished(false);
2298
2299 return Err(match error {
2300 Ok(value) => common::Error::BadRequest(value),
2301 _ => common::Error::Failure(response),
2302 });
2303 }
2304 let response = {
2305 let bytes = common::to_bytes(body).await.unwrap_or_default();
2306 let encoded = common::to_string(&bytes);
2307 match serde_json::from_str(&encoded) {
2308 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2309 Err(error) => {
2310 dlg.response_json_decode_error(&encoded, &error);
2311 return Err(common::Error::JsonDecodeError(
2312 encoded.to_string(),
2313 error,
2314 ));
2315 }
2316 }
2317 };
2318
2319 dlg.finished(true);
2320 return Ok(response);
2321 }
2322 }
2323 }
2324 }
2325
2326 ///
2327 /// Sets the *request* property to the given value.
2328 ///
2329 /// Even though the property as already been set when instantiating this call,
2330 /// we provide this method for API completeness.
2331 pub fn request(
2332 mut self,
2333 new_value: GoogleCloudDocumentaiV1beta2BatchProcessDocumentsRequest,
2334 ) -> ProjectDocumentBatchProcesCall<'a, C> {
2335 self._request = new_value;
2336 self
2337 }
2338 /// Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no location is specified, a region will be chosen automatically.
2339 ///
2340 /// Sets the *parent* path property to the given value.
2341 ///
2342 /// Even though the property as already been set when instantiating this call,
2343 /// we provide this method for API completeness.
2344 pub fn parent(mut self, new_value: &str) -> ProjectDocumentBatchProcesCall<'a, C> {
2345 self._parent = new_value.to_string();
2346 self
2347 }
2348 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2349 /// while executing the actual API request.
2350 ///
2351 /// ````text
2352 /// It should be used to handle progress information, and to implement a certain level of resilience.
2353 /// ````
2354 ///
2355 /// Sets the *delegate* property to the given value.
2356 pub fn delegate(
2357 mut self,
2358 new_value: &'a mut dyn common::Delegate,
2359 ) -> ProjectDocumentBatchProcesCall<'a, C> {
2360 self._delegate = Some(new_value);
2361 self
2362 }
2363
2364 /// Set any additional parameter of the query string used in the request.
2365 /// It should be used to set parameters which are not yet available through their own
2366 /// setters.
2367 ///
2368 /// Please note that this method must not be used to set any of the known parameters
2369 /// which have their own setter method. If done anyway, the request will fail.
2370 ///
2371 /// # Additional Parameters
2372 ///
2373 /// * *$.xgafv* (query-string) - V1 error format.
2374 /// * *access_token* (query-string) - OAuth access token.
2375 /// * *alt* (query-string) - Data format for response.
2376 /// * *callback* (query-string) - JSONP
2377 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2378 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2379 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2380 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2381 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2382 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2383 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2384 pub fn param<T>(mut self, name: T, value: T) -> ProjectDocumentBatchProcesCall<'a, C>
2385 where
2386 T: AsRef<str>,
2387 {
2388 self._additional_params
2389 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2390 self
2391 }
2392
2393 /// Identifies the authorization scope for the method you are building.
2394 ///
2395 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2396 /// [`Scope::CloudPlatform`].
2397 ///
2398 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2399 /// tokens for more than one scope.
2400 ///
2401 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2402 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2403 /// sufficient, a read-write scope will do as well.
2404 pub fn add_scope<St>(mut self, scope: St) -> ProjectDocumentBatchProcesCall<'a, C>
2405 where
2406 St: AsRef<str>,
2407 {
2408 self._scopes.insert(String::from(scope.as_ref()));
2409 self
2410 }
2411 /// Identifies the authorization scope(s) for the method you are building.
2412 ///
2413 /// See [`Self::add_scope()`] for details.
2414 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDocumentBatchProcesCall<'a, C>
2415 where
2416 I: IntoIterator<Item = St>,
2417 St: AsRef<str>,
2418 {
2419 self._scopes
2420 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2421 self
2422 }
2423
2424 /// Removes all scopes, and no default scope will be used either.
2425 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2426 /// for details).
2427 pub fn clear_scopes(mut self) -> ProjectDocumentBatchProcesCall<'a, C> {
2428 self._scopes.clear();
2429 self
2430 }
2431}
2432
2433/// Processes a single document.
2434///
2435/// A builder for the *documents.process* method supported by a *project* resource.
2436/// It is not used directly, but through a [`ProjectMethods`] instance.
2437///
2438/// # Example
2439///
2440/// Instantiate a resource method builder
2441///
2442/// ```test_harness,no_run
2443/// # extern crate hyper;
2444/// # extern crate hyper_rustls;
2445/// # extern crate google_documentai1_beta2 as documentai1_beta2;
2446/// use documentai1_beta2::api::GoogleCloudDocumentaiV1beta2ProcessDocumentRequest;
2447/// # async fn dox() {
2448/// # use documentai1_beta2::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2449///
2450/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2451/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2452/// # .with_native_roots()
2453/// # .unwrap()
2454/// # .https_only()
2455/// # .enable_http2()
2456/// # .build();
2457///
2458/// # let executor = hyper_util::rt::TokioExecutor::new();
2459/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2460/// # secret,
2461/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2462/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2463/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2464/// # ),
2465/// # ).build().await.unwrap();
2466///
2467/// # let client = hyper_util::client::legacy::Client::builder(
2468/// # hyper_util::rt::TokioExecutor::new()
2469/// # )
2470/// # .build(
2471/// # hyper_rustls::HttpsConnectorBuilder::new()
2472/// # .with_native_roots()
2473/// # .unwrap()
2474/// # .https_or_http()
2475/// # .enable_http2()
2476/// # .build()
2477/// # );
2478/// # let mut hub = Document::new(client, auth);
2479/// // As the method needs a request, you would usually fill it with the desired information
2480/// // into the respective structure. Some of the parts shown here might not be applicable !
2481/// // Values shown here are possibly random and not representative !
2482/// let mut req = GoogleCloudDocumentaiV1beta2ProcessDocumentRequest::default();
2483///
2484/// // You can configure optional parameters by calling the respective setters at will, and
2485/// // execute the final call using `doit()`.
2486/// // Values shown here are possibly random and not representative !
2487/// let result = hub.projects().documents_process(req, "parent")
2488/// .doit().await;
2489/// # }
2490/// ```
2491pub struct ProjectDocumentProcesCall<'a, C>
2492where
2493 C: 'a,
2494{
2495 hub: &'a Document<C>,
2496 _request: GoogleCloudDocumentaiV1beta2ProcessDocumentRequest,
2497 _parent: String,
2498 _delegate: Option<&'a mut dyn common::Delegate>,
2499 _additional_params: HashMap<String, String>,
2500 _scopes: BTreeSet<String>,
2501}
2502
2503impl<'a, C> common::CallBuilder for ProjectDocumentProcesCall<'a, C> {}
2504
2505impl<'a, C> ProjectDocumentProcesCall<'a, C>
2506where
2507 C: common::Connector,
2508{
2509 /// Perform the operation you have build so far.
2510 pub async fn doit(
2511 mut self,
2512 ) -> common::Result<(common::Response, GoogleCloudDocumentaiV1beta2Document)> {
2513 use std::borrow::Cow;
2514 use std::io::{Read, Seek};
2515
2516 use common::{url::Params, ToParts};
2517 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2518
2519 let mut dd = common::DefaultDelegate;
2520 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2521 dlg.begin(common::MethodInfo {
2522 id: "documentai.projects.documents.process",
2523 http_method: hyper::Method::POST,
2524 });
2525
2526 for &field in ["alt", "parent"].iter() {
2527 if self._additional_params.contains_key(field) {
2528 dlg.finished(false);
2529 return Err(common::Error::FieldClash(field));
2530 }
2531 }
2532
2533 let mut params = Params::with_capacity(4 + self._additional_params.len());
2534 params.push("parent", self._parent);
2535
2536 params.extend(self._additional_params.iter());
2537
2538 params.push("alt", "json");
2539 let mut url = self.hub._base_url.clone() + "v1beta2/{+parent}/documents:process";
2540 if self._scopes.is_empty() {
2541 self._scopes
2542 .insert(Scope::CloudPlatform.as_ref().to_string());
2543 }
2544
2545 #[allow(clippy::single_element_loop)]
2546 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2547 url = params.uri_replacement(url, param_name, find_this, true);
2548 }
2549 {
2550 let to_remove = ["parent"];
2551 params.remove_params(&to_remove);
2552 }
2553
2554 let url = params.parse_with_url(&url);
2555
2556 let mut json_mime_type = mime::APPLICATION_JSON;
2557 let mut request_value_reader = {
2558 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2559 common::remove_json_null_values(&mut value);
2560 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2561 serde_json::to_writer(&mut dst, &value).unwrap();
2562 dst
2563 };
2564 let request_size = request_value_reader
2565 .seek(std::io::SeekFrom::End(0))
2566 .unwrap();
2567 request_value_reader
2568 .seek(std::io::SeekFrom::Start(0))
2569 .unwrap();
2570
2571 loop {
2572 let token = match self
2573 .hub
2574 .auth
2575 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2576 .await
2577 {
2578 Ok(token) => token,
2579 Err(e) => match dlg.token(e) {
2580 Ok(token) => token,
2581 Err(e) => {
2582 dlg.finished(false);
2583 return Err(common::Error::MissingToken(e));
2584 }
2585 },
2586 };
2587 request_value_reader
2588 .seek(std::io::SeekFrom::Start(0))
2589 .unwrap();
2590 let mut req_result = {
2591 let client = &self.hub.client;
2592 dlg.pre_request();
2593 let mut req_builder = hyper::Request::builder()
2594 .method(hyper::Method::POST)
2595 .uri(url.as_str())
2596 .header(USER_AGENT, self.hub._user_agent.clone());
2597
2598 if let Some(token) = token.as_ref() {
2599 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2600 }
2601
2602 let request = req_builder
2603 .header(CONTENT_TYPE, json_mime_type.to_string())
2604 .header(CONTENT_LENGTH, request_size as u64)
2605 .body(common::to_body(
2606 request_value_reader.get_ref().clone().into(),
2607 ));
2608
2609 client.request(request.unwrap()).await
2610 };
2611
2612 match req_result {
2613 Err(err) => {
2614 if let common::Retry::After(d) = dlg.http_error(&err) {
2615 sleep(d).await;
2616 continue;
2617 }
2618 dlg.finished(false);
2619 return Err(common::Error::HttpError(err));
2620 }
2621 Ok(res) => {
2622 let (mut parts, body) = res.into_parts();
2623 let mut body = common::Body::new(body);
2624 if !parts.status.is_success() {
2625 let bytes = common::to_bytes(body).await.unwrap_or_default();
2626 let error = serde_json::from_str(&common::to_string(&bytes));
2627 let response = common::to_response(parts, bytes.into());
2628
2629 if let common::Retry::After(d) =
2630 dlg.http_failure(&response, error.as_ref().ok())
2631 {
2632 sleep(d).await;
2633 continue;
2634 }
2635
2636 dlg.finished(false);
2637
2638 return Err(match error {
2639 Ok(value) => common::Error::BadRequest(value),
2640 _ => common::Error::Failure(response),
2641 });
2642 }
2643 let response = {
2644 let bytes = common::to_bytes(body).await.unwrap_or_default();
2645 let encoded = common::to_string(&bytes);
2646 match serde_json::from_str(&encoded) {
2647 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2648 Err(error) => {
2649 dlg.response_json_decode_error(&encoded, &error);
2650 return Err(common::Error::JsonDecodeError(
2651 encoded.to_string(),
2652 error,
2653 ));
2654 }
2655 }
2656 };
2657
2658 dlg.finished(true);
2659 return Ok(response);
2660 }
2661 }
2662 }
2663 }
2664
2665 ///
2666 /// Sets the *request* property to the given value.
2667 ///
2668 /// Even though the property as already been set when instantiating this call,
2669 /// we provide this method for API completeness.
2670 pub fn request(
2671 mut self,
2672 new_value: GoogleCloudDocumentaiV1beta2ProcessDocumentRequest,
2673 ) -> ProjectDocumentProcesCall<'a, C> {
2674 self._request = new_value;
2675 self
2676 }
2677 /// Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no location is specified, a region will be chosen automatically. This field is only populated when used in ProcessDocument method.
2678 ///
2679 /// Sets the *parent* path property to the given value.
2680 ///
2681 /// Even though the property as already been set when instantiating this call,
2682 /// we provide this method for API completeness.
2683 pub fn parent(mut self, new_value: &str) -> ProjectDocumentProcesCall<'a, C> {
2684 self._parent = new_value.to_string();
2685 self
2686 }
2687 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2688 /// while executing the actual API request.
2689 ///
2690 /// ````text
2691 /// It should be used to handle progress information, and to implement a certain level of resilience.
2692 /// ````
2693 ///
2694 /// Sets the *delegate* property to the given value.
2695 pub fn delegate(
2696 mut self,
2697 new_value: &'a mut dyn common::Delegate,
2698 ) -> ProjectDocumentProcesCall<'a, C> {
2699 self._delegate = Some(new_value);
2700 self
2701 }
2702
2703 /// Set any additional parameter of the query string used in the request.
2704 /// It should be used to set parameters which are not yet available through their own
2705 /// setters.
2706 ///
2707 /// Please note that this method must not be used to set any of the known parameters
2708 /// which have their own setter method. If done anyway, the request will fail.
2709 ///
2710 /// # Additional Parameters
2711 ///
2712 /// * *$.xgafv* (query-string) - V1 error format.
2713 /// * *access_token* (query-string) - OAuth access token.
2714 /// * *alt* (query-string) - Data format for response.
2715 /// * *callback* (query-string) - JSONP
2716 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2717 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2718 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2719 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2720 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2721 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2722 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2723 pub fn param<T>(mut self, name: T, value: T) -> ProjectDocumentProcesCall<'a, C>
2724 where
2725 T: AsRef<str>,
2726 {
2727 self._additional_params
2728 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2729 self
2730 }
2731
2732 /// Identifies the authorization scope for the method you are building.
2733 ///
2734 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2735 /// [`Scope::CloudPlatform`].
2736 ///
2737 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2738 /// tokens for more than one scope.
2739 ///
2740 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2741 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2742 /// sufficient, a read-write scope will do as well.
2743 pub fn add_scope<St>(mut self, scope: St) -> ProjectDocumentProcesCall<'a, C>
2744 where
2745 St: AsRef<str>,
2746 {
2747 self._scopes.insert(String::from(scope.as_ref()));
2748 self
2749 }
2750 /// Identifies the authorization scope(s) for the method you are building.
2751 ///
2752 /// See [`Self::add_scope()`] for details.
2753 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDocumentProcesCall<'a, C>
2754 where
2755 I: IntoIterator<Item = St>,
2756 St: AsRef<str>,
2757 {
2758 self._scopes
2759 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2760 self
2761 }
2762
2763 /// Removes all scopes, and no default scope will be used either.
2764 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2765 /// for details).
2766 pub fn clear_scopes(mut self) -> ProjectDocumentProcesCall<'a, C> {
2767 self._scopes.clear();
2768 self
2769 }
2770}
2771
2772/// LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in the [Document] format.
2773///
2774/// A builder for the *locations.documents.batchProcess* method supported by a *project* resource.
2775/// It is not used directly, but through a [`ProjectMethods`] instance.
2776///
2777/// # Example
2778///
2779/// Instantiate a resource method builder
2780///
2781/// ```test_harness,no_run
2782/// # extern crate hyper;
2783/// # extern crate hyper_rustls;
2784/// # extern crate google_documentai1_beta2 as documentai1_beta2;
2785/// use documentai1_beta2::api::GoogleCloudDocumentaiV1beta2BatchProcessDocumentsRequest;
2786/// # async fn dox() {
2787/// # use documentai1_beta2::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2788///
2789/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2790/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2791/// # .with_native_roots()
2792/// # .unwrap()
2793/// # .https_only()
2794/// # .enable_http2()
2795/// # .build();
2796///
2797/// # let executor = hyper_util::rt::TokioExecutor::new();
2798/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2799/// # secret,
2800/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2801/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2802/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2803/// # ),
2804/// # ).build().await.unwrap();
2805///
2806/// # let client = hyper_util::client::legacy::Client::builder(
2807/// # hyper_util::rt::TokioExecutor::new()
2808/// # )
2809/// # .build(
2810/// # hyper_rustls::HttpsConnectorBuilder::new()
2811/// # .with_native_roots()
2812/// # .unwrap()
2813/// # .https_or_http()
2814/// # .enable_http2()
2815/// # .build()
2816/// # );
2817/// # let mut hub = Document::new(client, auth);
2818/// // As the method needs a request, you would usually fill it with the desired information
2819/// // into the respective structure. Some of the parts shown here might not be applicable !
2820/// // Values shown here are possibly random and not representative !
2821/// let mut req = GoogleCloudDocumentaiV1beta2BatchProcessDocumentsRequest::default();
2822///
2823/// // You can configure optional parameters by calling the respective setters at will, and
2824/// // execute the final call using `doit()`.
2825/// // Values shown here are possibly random and not representative !
2826/// let result = hub.projects().locations_documents_batch_process(req, "parent")
2827/// .doit().await;
2828/// # }
2829/// ```
2830pub struct ProjectLocationDocumentBatchProcesCall<'a, C>
2831where
2832 C: 'a,
2833{
2834 hub: &'a Document<C>,
2835 _request: GoogleCloudDocumentaiV1beta2BatchProcessDocumentsRequest,
2836 _parent: String,
2837 _delegate: Option<&'a mut dyn common::Delegate>,
2838 _additional_params: HashMap<String, String>,
2839 _scopes: BTreeSet<String>,
2840}
2841
2842impl<'a, C> common::CallBuilder for ProjectLocationDocumentBatchProcesCall<'a, C> {}
2843
2844impl<'a, C> ProjectLocationDocumentBatchProcesCall<'a, C>
2845where
2846 C: common::Connector,
2847{
2848 /// Perform the operation you have build so far.
2849 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
2850 use std::borrow::Cow;
2851 use std::io::{Read, Seek};
2852
2853 use common::{url::Params, ToParts};
2854 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2855
2856 let mut dd = common::DefaultDelegate;
2857 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2858 dlg.begin(common::MethodInfo {
2859 id: "documentai.projects.locations.documents.batchProcess",
2860 http_method: hyper::Method::POST,
2861 });
2862
2863 for &field in ["alt", "parent"].iter() {
2864 if self._additional_params.contains_key(field) {
2865 dlg.finished(false);
2866 return Err(common::Error::FieldClash(field));
2867 }
2868 }
2869
2870 let mut params = Params::with_capacity(4 + self._additional_params.len());
2871 params.push("parent", self._parent);
2872
2873 params.extend(self._additional_params.iter());
2874
2875 params.push("alt", "json");
2876 let mut url = self.hub._base_url.clone() + "v1beta2/{+parent}/documents:batchProcess";
2877 if self._scopes.is_empty() {
2878 self._scopes
2879 .insert(Scope::CloudPlatform.as_ref().to_string());
2880 }
2881
2882 #[allow(clippy::single_element_loop)]
2883 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2884 url = params.uri_replacement(url, param_name, find_this, true);
2885 }
2886 {
2887 let to_remove = ["parent"];
2888 params.remove_params(&to_remove);
2889 }
2890
2891 let url = params.parse_with_url(&url);
2892
2893 let mut json_mime_type = mime::APPLICATION_JSON;
2894 let mut request_value_reader = {
2895 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2896 common::remove_json_null_values(&mut value);
2897 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2898 serde_json::to_writer(&mut dst, &value).unwrap();
2899 dst
2900 };
2901 let request_size = request_value_reader
2902 .seek(std::io::SeekFrom::End(0))
2903 .unwrap();
2904 request_value_reader
2905 .seek(std::io::SeekFrom::Start(0))
2906 .unwrap();
2907
2908 loop {
2909 let token = match self
2910 .hub
2911 .auth
2912 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2913 .await
2914 {
2915 Ok(token) => token,
2916 Err(e) => match dlg.token(e) {
2917 Ok(token) => token,
2918 Err(e) => {
2919 dlg.finished(false);
2920 return Err(common::Error::MissingToken(e));
2921 }
2922 },
2923 };
2924 request_value_reader
2925 .seek(std::io::SeekFrom::Start(0))
2926 .unwrap();
2927 let mut req_result = {
2928 let client = &self.hub.client;
2929 dlg.pre_request();
2930 let mut req_builder = hyper::Request::builder()
2931 .method(hyper::Method::POST)
2932 .uri(url.as_str())
2933 .header(USER_AGENT, self.hub._user_agent.clone());
2934
2935 if let Some(token) = token.as_ref() {
2936 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2937 }
2938
2939 let request = req_builder
2940 .header(CONTENT_TYPE, json_mime_type.to_string())
2941 .header(CONTENT_LENGTH, request_size as u64)
2942 .body(common::to_body(
2943 request_value_reader.get_ref().clone().into(),
2944 ));
2945
2946 client.request(request.unwrap()).await
2947 };
2948
2949 match req_result {
2950 Err(err) => {
2951 if let common::Retry::After(d) = dlg.http_error(&err) {
2952 sleep(d).await;
2953 continue;
2954 }
2955 dlg.finished(false);
2956 return Err(common::Error::HttpError(err));
2957 }
2958 Ok(res) => {
2959 let (mut parts, body) = res.into_parts();
2960 let mut body = common::Body::new(body);
2961 if !parts.status.is_success() {
2962 let bytes = common::to_bytes(body).await.unwrap_or_default();
2963 let error = serde_json::from_str(&common::to_string(&bytes));
2964 let response = common::to_response(parts, bytes.into());
2965
2966 if let common::Retry::After(d) =
2967 dlg.http_failure(&response, error.as_ref().ok())
2968 {
2969 sleep(d).await;
2970 continue;
2971 }
2972
2973 dlg.finished(false);
2974
2975 return Err(match error {
2976 Ok(value) => common::Error::BadRequest(value),
2977 _ => common::Error::Failure(response),
2978 });
2979 }
2980 let response = {
2981 let bytes = common::to_bytes(body).await.unwrap_or_default();
2982 let encoded = common::to_string(&bytes);
2983 match serde_json::from_str(&encoded) {
2984 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2985 Err(error) => {
2986 dlg.response_json_decode_error(&encoded, &error);
2987 return Err(common::Error::JsonDecodeError(
2988 encoded.to_string(),
2989 error,
2990 ));
2991 }
2992 }
2993 };
2994
2995 dlg.finished(true);
2996 return Ok(response);
2997 }
2998 }
2999 }
3000 }
3001
3002 ///
3003 /// Sets the *request* property to the given value.
3004 ///
3005 /// Even though the property as already been set when instantiating this call,
3006 /// we provide this method for API completeness.
3007 pub fn request(
3008 mut self,
3009 new_value: GoogleCloudDocumentaiV1beta2BatchProcessDocumentsRequest,
3010 ) -> ProjectLocationDocumentBatchProcesCall<'a, C> {
3011 self._request = new_value;
3012 self
3013 }
3014 /// Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no location is specified, a region will be chosen automatically.
3015 ///
3016 /// Sets the *parent* path property to the given value.
3017 ///
3018 /// Even though the property as already been set when instantiating this call,
3019 /// we provide this method for API completeness.
3020 pub fn parent(mut self, new_value: &str) -> ProjectLocationDocumentBatchProcesCall<'a, C> {
3021 self._parent = new_value.to_string();
3022 self
3023 }
3024 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3025 /// while executing the actual API request.
3026 ///
3027 /// ````text
3028 /// It should be used to handle progress information, and to implement a certain level of resilience.
3029 /// ````
3030 ///
3031 /// Sets the *delegate* property to the given value.
3032 pub fn delegate(
3033 mut self,
3034 new_value: &'a mut dyn common::Delegate,
3035 ) -> ProjectLocationDocumentBatchProcesCall<'a, C> {
3036 self._delegate = Some(new_value);
3037 self
3038 }
3039
3040 /// Set any additional parameter of the query string used in the request.
3041 /// It should be used to set parameters which are not yet available through their own
3042 /// setters.
3043 ///
3044 /// Please note that this method must not be used to set any of the known parameters
3045 /// which have their own setter method. If done anyway, the request will fail.
3046 ///
3047 /// # Additional Parameters
3048 ///
3049 /// * *$.xgafv* (query-string) - V1 error format.
3050 /// * *access_token* (query-string) - OAuth access token.
3051 /// * *alt* (query-string) - Data format for response.
3052 /// * *callback* (query-string) - JSONP
3053 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3054 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3055 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3056 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3057 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3058 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3059 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3060 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationDocumentBatchProcesCall<'a, C>
3061 where
3062 T: AsRef<str>,
3063 {
3064 self._additional_params
3065 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3066 self
3067 }
3068
3069 /// Identifies the authorization scope for the method you are building.
3070 ///
3071 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3072 /// [`Scope::CloudPlatform`].
3073 ///
3074 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3075 /// tokens for more than one scope.
3076 ///
3077 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3078 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3079 /// sufficient, a read-write scope will do as well.
3080 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationDocumentBatchProcesCall<'a, C>
3081 where
3082 St: AsRef<str>,
3083 {
3084 self._scopes.insert(String::from(scope.as_ref()));
3085 self
3086 }
3087 /// Identifies the authorization scope(s) for the method you are building.
3088 ///
3089 /// See [`Self::add_scope()`] for details.
3090 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationDocumentBatchProcesCall<'a, C>
3091 where
3092 I: IntoIterator<Item = St>,
3093 St: AsRef<str>,
3094 {
3095 self._scopes
3096 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3097 self
3098 }
3099
3100 /// Removes all scopes, and no default scope will be used either.
3101 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3102 /// for details).
3103 pub fn clear_scopes(mut self) -> ProjectLocationDocumentBatchProcesCall<'a, C> {
3104 self._scopes.clear();
3105 self
3106 }
3107}
3108
3109/// Processes a single document.
3110///
3111/// A builder for the *locations.documents.process* method supported by a *project* resource.
3112/// It is not used directly, but through a [`ProjectMethods`] instance.
3113///
3114/// # Example
3115///
3116/// Instantiate a resource method builder
3117///
3118/// ```test_harness,no_run
3119/// # extern crate hyper;
3120/// # extern crate hyper_rustls;
3121/// # extern crate google_documentai1_beta2 as documentai1_beta2;
3122/// use documentai1_beta2::api::GoogleCloudDocumentaiV1beta2ProcessDocumentRequest;
3123/// # async fn dox() {
3124/// # use documentai1_beta2::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3125///
3126/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3127/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3128/// # .with_native_roots()
3129/// # .unwrap()
3130/// # .https_only()
3131/// # .enable_http2()
3132/// # .build();
3133///
3134/// # let executor = hyper_util::rt::TokioExecutor::new();
3135/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3136/// # secret,
3137/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3138/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3139/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3140/// # ),
3141/// # ).build().await.unwrap();
3142///
3143/// # let client = hyper_util::client::legacy::Client::builder(
3144/// # hyper_util::rt::TokioExecutor::new()
3145/// # )
3146/// # .build(
3147/// # hyper_rustls::HttpsConnectorBuilder::new()
3148/// # .with_native_roots()
3149/// # .unwrap()
3150/// # .https_or_http()
3151/// # .enable_http2()
3152/// # .build()
3153/// # );
3154/// # let mut hub = Document::new(client, auth);
3155/// // As the method needs a request, you would usually fill it with the desired information
3156/// // into the respective structure. Some of the parts shown here might not be applicable !
3157/// // Values shown here are possibly random and not representative !
3158/// let mut req = GoogleCloudDocumentaiV1beta2ProcessDocumentRequest::default();
3159///
3160/// // You can configure optional parameters by calling the respective setters at will, and
3161/// // execute the final call using `doit()`.
3162/// // Values shown here are possibly random and not representative !
3163/// let result = hub.projects().locations_documents_process(req, "parent")
3164/// .doit().await;
3165/// # }
3166/// ```
3167pub struct ProjectLocationDocumentProcesCall<'a, C>
3168where
3169 C: 'a,
3170{
3171 hub: &'a Document<C>,
3172 _request: GoogleCloudDocumentaiV1beta2ProcessDocumentRequest,
3173 _parent: String,
3174 _delegate: Option<&'a mut dyn common::Delegate>,
3175 _additional_params: HashMap<String, String>,
3176 _scopes: BTreeSet<String>,
3177}
3178
3179impl<'a, C> common::CallBuilder for ProjectLocationDocumentProcesCall<'a, C> {}
3180
3181impl<'a, C> ProjectLocationDocumentProcesCall<'a, C>
3182where
3183 C: common::Connector,
3184{
3185 /// Perform the operation you have build so far.
3186 pub async fn doit(
3187 mut self,
3188 ) -> common::Result<(common::Response, GoogleCloudDocumentaiV1beta2Document)> {
3189 use std::borrow::Cow;
3190 use std::io::{Read, Seek};
3191
3192 use common::{url::Params, ToParts};
3193 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3194
3195 let mut dd = common::DefaultDelegate;
3196 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3197 dlg.begin(common::MethodInfo {
3198 id: "documentai.projects.locations.documents.process",
3199 http_method: hyper::Method::POST,
3200 });
3201
3202 for &field in ["alt", "parent"].iter() {
3203 if self._additional_params.contains_key(field) {
3204 dlg.finished(false);
3205 return Err(common::Error::FieldClash(field));
3206 }
3207 }
3208
3209 let mut params = Params::with_capacity(4 + self._additional_params.len());
3210 params.push("parent", self._parent);
3211
3212 params.extend(self._additional_params.iter());
3213
3214 params.push("alt", "json");
3215 let mut url = self.hub._base_url.clone() + "v1beta2/{+parent}/documents:process";
3216 if self._scopes.is_empty() {
3217 self._scopes
3218 .insert(Scope::CloudPlatform.as_ref().to_string());
3219 }
3220
3221 #[allow(clippy::single_element_loop)]
3222 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3223 url = params.uri_replacement(url, param_name, find_this, true);
3224 }
3225 {
3226 let to_remove = ["parent"];
3227 params.remove_params(&to_remove);
3228 }
3229
3230 let url = params.parse_with_url(&url);
3231
3232 let mut json_mime_type = mime::APPLICATION_JSON;
3233 let mut request_value_reader = {
3234 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3235 common::remove_json_null_values(&mut value);
3236 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3237 serde_json::to_writer(&mut dst, &value).unwrap();
3238 dst
3239 };
3240 let request_size = request_value_reader
3241 .seek(std::io::SeekFrom::End(0))
3242 .unwrap();
3243 request_value_reader
3244 .seek(std::io::SeekFrom::Start(0))
3245 .unwrap();
3246
3247 loop {
3248 let token = match self
3249 .hub
3250 .auth
3251 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3252 .await
3253 {
3254 Ok(token) => token,
3255 Err(e) => match dlg.token(e) {
3256 Ok(token) => token,
3257 Err(e) => {
3258 dlg.finished(false);
3259 return Err(common::Error::MissingToken(e));
3260 }
3261 },
3262 };
3263 request_value_reader
3264 .seek(std::io::SeekFrom::Start(0))
3265 .unwrap();
3266 let mut req_result = {
3267 let client = &self.hub.client;
3268 dlg.pre_request();
3269 let mut req_builder = hyper::Request::builder()
3270 .method(hyper::Method::POST)
3271 .uri(url.as_str())
3272 .header(USER_AGENT, self.hub._user_agent.clone());
3273
3274 if let Some(token) = token.as_ref() {
3275 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3276 }
3277
3278 let request = req_builder
3279 .header(CONTENT_TYPE, json_mime_type.to_string())
3280 .header(CONTENT_LENGTH, request_size as u64)
3281 .body(common::to_body(
3282 request_value_reader.get_ref().clone().into(),
3283 ));
3284
3285 client.request(request.unwrap()).await
3286 };
3287
3288 match req_result {
3289 Err(err) => {
3290 if let common::Retry::After(d) = dlg.http_error(&err) {
3291 sleep(d).await;
3292 continue;
3293 }
3294 dlg.finished(false);
3295 return Err(common::Error::HttpError(err));
3296 }
3297 Ok(res) => {
3298 let (mut parts, body) = res.into_parts();
3299 let mut body = common::Body::new(body);
3300 if !parts.status.is_success() {
3301 let bytes = common::to_bytes(body).await.unwrap_or_default();
3302 let error = serde_json::from_str(&common::to_string(&bytes));
3303 let response = common::to_response(parts, bytes.into());
3304
3305 if let common::Retry::After(d) =
3306 dlg.http_failure(&response, error.as_ref().ok())
3307 {
3308 sleep(d).await;
3309 continue;
3310 }
3311
3312 dlg.finished(false);
3313
3314 return Err(match error {
3315 Ok(value) => common::Error::BadRequest(value),
3316 _ => common::Error::Failure(response),
3317 });
3318 }
3319 let response = {
3320 let bytes = common::to_bytes(body).await.unwrap_or_default();
3321 let encoded = common::to_string(&bytes);
3322 match serde_json::from_str(&encoded) {
3323 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3324 Err(error) => {
3325 dlg.response_json_decode_error(&encoded, &error);
3326 return Err(common::Error::JsonDecodeError(
3327 encoded.to_string(),
3328 error,
3329 ));
3330 }
3331 }
3332 };
3333
3334 dlg.finished(true);
3335 return Ok(response);
3336 }
3337 }
3338 }
3339 }
3340
3341 ///
3342 /// Sets the *request* property to the given value.
3343 ///
3344 /// Even though the property as already been set when instantiating this call,
3345 /// we provide this method for API completeness.
3346 pub fn request(
3347 mut self,
3348 new_value: GoogleCloudDocumentaiV1beta2ProcessDocumentRequest,
3349 ) -> ProjectLocationDocumentProcesCall<'a, C> {
3350 self._request = new_value;
3351 self
3352 }
3353 /// Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no location is specified, a region will be chosen automatically. This field is only populated when used in ProcessDocument method.
3354 ///
3355 /// Sets the *parent* path property to the given value.
3356 ///
3357 /// Even though the property as already been set when instantiating this call,
3358 /// we provide this method for API completeness.
3359 pub fn parent(mut self, new_value: &str) -> ProjectLocationDocumentProcesCall<'a, C> {
3360 self._parent = new_value.to_string();
3361 self
3362 }
3363 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3364 /// while executing the actual API request.
3365 ///
3366 /// ````text
3367 /// It should be used to handle progress information, and to implement a certain level of resilience.
3368 /// ````
3369 ///
3370 /// Sets the *delegate* property to the given value.
3371 pub fn delegate(
3372 mut self,
3373 new_value: &'a mut dyn common::Delegate,
3374 ) -> ProjectLocationDocumentProcesCall<'a, C> {
3375 self._delegate = Some(new_value);
3376 self
3377 }
3378
3379 /// Set any additional parameter of the query string used in the request.
3380 /// It should be used to set parameters which are not yet available through their own
3381 /// setters.
3382 ///
3383 /// Please note that this method must not be used to set any of the known parameters
3384 /// which have their own setter method. If done anyway, the request will fail.
3385 ///
3386 /// # Additional Parameters
3387 ///
3388 /// * *$.xgafv* (query-string) - V1 error format.
3389 /// * *access_token* (query-string) - OAuth access token.
3390 /// * *alt* (query-string) - Data format for response.
3391 /// * *callback* (query-string) - JSONP
3392 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3393 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3394 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3395 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3396 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3397 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3398 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3399 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationDocumentProcesCall<'a, C>
3400 where
3401 T: AsRef<str>,
3402 {
3403 self._additional_params
3404 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3405 self
3406 }
3407
3408 /// Identifies the authorization scope for the method you are building.
3409 ///
3410 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3411 /// [`Scope::CloudPlatform`].
3412 ///
3413 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3414 /// tokens for more than one scope.
3415 ///
3416 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3417 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3418 /// sufficient, a read-write scope will do as well.
3419 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationDocumentProcesCall<'a, C>
3420 where
3421 St: AsRef<str>,
3422 {
3423 self._scopes.insert(String::from(scope.as_ref()));
3424 self
3425 }
3426 /// Identifies the authorization scope(s) for the method you are building.
3427 ///
3428 /// See [`Self::add_scope()`] for details.
3429 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationDocumentProcesCall<'a, C>
3430 where
3431 I: IntoIterator<Item = St>,
3432 St: AsRef<str>,
3433 {
3434 self._scopes
3435 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3436 self
3437 }
3438
3439 /// Removes all scopes, and no default scope will be used either.
3440 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3441 /// for details).
3442 pub fn clear_scopes(mut self) -> ProjectLocationDocumentProcesCall<'a, C> {
3443 self._scopes.clear();
3444 self
3445 }
3446}
3447
3448/// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
3449///
3450/// A builder for the *locations.operations.get* method supported by a *project* resource.
3451/// It is not used directly, but through a [`ProjectMethods`] instance.
3452///
3453/// # Example
3454///
3455/// Instantiate a resource method builder
3456///
3457/// ```test_harness,no_run
3458/// # extern crate hyper;
3459/// # extern crate hyper_rustls;
3460/// # extern crate google_documentai1_beta2 as documentai1_beta2;
3461/// # async fn dox() {
3462/// # use documentai1_beta2::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3463///
3464/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3465/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3466/// # .with_native_roots()
3467/// # .unwrap()
3468/// # .https_only()
3469/// # .enable_http2()
3470/// # .build();
3471///
3472/// # let executor = hyper_util::rt::TokioExecutor::new();
3473/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3474/// # secret,
3475/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3476/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3477/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3478/// # ),
3479/// # ).build().await.unwrap();
3480///
3481/// # let client = hyper_util::client::legacy::Client::builder(
3482/// # hyper_util::rt::TokioExecutor::new()
3483/// # )
3484/// # .build(
3485/// # hyper_rustls::HttpsConnectorBuilder::new()
3486/// # .with_native_roots()
3487/// # .unwrap()
3488/// # .https_or_http()
3489/// # .enable_http2()
3490/// # .build()
3491/// # );
3492/// # let mut hub = Document::new(client, auth);
3493/// // You can configure optional parameters by calling the respective setters at will, and
3494/// // execute the final call using `doit()`.
3495/// // Values shown here are possibly random and not representative !
3496/// let result = hub.projects().locations_operations_get("name")
3497/// .doit().await;
3498/// # }
3499/// ```
3500pub struct ProjectLocationOperationGetCall<'a, C>
3501where
3502 C: 'a,
3503{
3504 hub: &'a Document<C>,
3505 _name: String,
3506 _delegate: Option<&'a mut dyn common::Delegate>,
3507 _additional_params: HashMap<String, String>,
3508 _scopes: BTreeSet<String>,
3509}
3510
3511impl<'a, C> common::CallBuilder for ProjectLocationOperationGetCall<'a, C> {}
3512
3513impl<'a, C> ProjectLocationOperationGetCall<'a, C>
3514where
3515 C: common::Connector,
3516{
3517 /// Perform the operation you have build so far.
3518 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
3519 use std::borrow::Cow;
3520 use std::io::{Read, Seek};
3521
3522 use common::{url::Params, ToParts};
3523 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3524
3525 let mut dd = common::DefaultDelegate;
3526 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3527 dlg.begin(common::MethodInfo {
3528 id: "documentai.projects.locations.operations.get",
3529 http_method: hyper::Method::GET,
3530 });
3531
3532 for &field in ["alt", "name"].iter() {
3533 if self._additional_params.contains_key(field) {
3534 dlg.finished(false);
3535 return Err(common::Error::FieldClash(field));
3536 }
3537 }
3538
3539 let mut params = Params::with_capacity(3 + self._additional_params.len());
3540 params.push("name", self._name);
3541
3542 params.extend(self._additional_params.iter());
3543
3544 params.push("alt", "json");
3545 let mut url = self.hub._base_url.clone() + "v1beta2/{+name}";
3546 if self._scopes.is_empty() {
3547 self._scopes
3548 .insert(Scope::CloudPlatform.as_ref().to_string());
3549 }
3550
3551 #[allow(clippy::single_element_loop)]
3552 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3553 url = params.uri_replacement(url, param_name, find_this, true);
3554 }
3555 {
3556 let to_remove = ["name"];
3557 params.remove_params(&to_remove);
3558 }
3559
3560 let url = params.parse_with_url(&url);
3561
3562 loop {
3563 let token = match self
3564 .hub
3565 .auth
3566 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3567 .await
3568 {
3569 Ok(token) => token,
3570 Err(e) => match dlg.token(e) {
3571 Ok(token) => token,
3572 Err(e) => {
3573 dlg.finished(false);
3574 return Err(common::Error::MissingToken(e));
3575 }
3576 },
3577 };
3578 let mut req_result = {
3579 let client = &self.hub.client;
3580 dlg.pre_request();
3581 let mut req_builder = hyper::Request::builder()
3582 .method(hyper::Method::GET)
3583 .uri(url.as_str())
3584 .header(USER_AGENT, self.hub._user_agent.clone());
3585
3586 if let Some(token) = token.as_ref() {
3587 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3588 }
3589
3590 let request = req_builder
3591 .header(CONTENT_LENGTH, 0_u64)
3592 .body(common::to_body::<String>(None));
3593
3594 client.request(request.unwrap()).await
3595 };
3596
3597 match req_result {
3598 Err(err) => {
3599 if let common::Retry::After(d) = dlg.http_error(&err) {
3600 sleep(d).await;
3601 continue;
3602 }
3603 dlg.finished(false);
3604 return Err(common::Error::HttpError(err));
3605 }
3606 Ok(res) => {
3607 let (mut parts, body) = res.into_parts();
3608 let mut body = common::Body::new(body);
3609 if !parts.status.is_success() {
3610 let bytes = common::to_bytes(body).await.unwrap_or_default();
3611 let error = serde_json::from_str(&common::to_string(&bytes));
3612 let response = common::to_response(parts, bytes.into());
3613
3614 if let common::Retry::After(d) =
3615 dlg.http_failure(&response, error.as_ref().ok())
3616 {
3617 sleep(d).await;
3618 continue;
3619 }
3620
3621 dlg.finished(false);
3622
3623 return Err(match error {
3624 Ok(value) => common::Error::BadRequest(value),
3625 _ => common::Error::Failure(response),
3626 });
3627 }
3628 let response = {
3629 let bytes = common::to_bytes(body).await.unwrap_or_default();
3630 let encoded = common::to_string(&bytes);
3631 match serde_json::from_str(&encoded) {
3632 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3633 Err(error) => {
3634 dlg.response_json_decode_error(&encoded, &error);
3635 return Err(common::Error::JsonDecodeError(
3636 encoded.to_string(),
3637 error,
3638 ));
3639 }
3640 }
3641 };
3642
3643 dlg.finished(true);
3644 return Ok(response);
3645 }
3646 }
3647 }
3648 }
3649
3650 /// The name of the operation resource.
3651 ///
3652 /// Sets the *name* path property to the given value.
3653 ///
3654 /// Even though the property as already been set when instantiating this call,
3655 /// we provide this method for API completeness.
3656 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationGetCall<'a, C> {
3657 self._name = new_value.to_string();
3658 self
3659 }
3660 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3661 /// while executing the actual API request.
3662 ///
3663 /// ````text
3664 /// It should be used to handle progress information, and to implement a certain level of resilience.
3665 /// ````
3666 ///
3667 /// Sets the *delegate* property to the given value.
3668 pub fn delegate(
3669 mut self,
3670 new_value: &'a mut dyn common::Delegate,
3671 ) -> ProjectLocationOperationGetCall<'a, C> {
3672 self._delegate = Some(new_value);
3673 self
3674 }
3675
3676 /// Set any additional parameter of the query string used in the request.
3677 /// It should be used to set parameters which are not yet available through their own
3678 /// setters.
3679 ///
3680 /// Please note that this method must not be used to set any of the known parameters
3681 /// which have their own setter method. If done anyway, the request will fail.
3682 ///
3683 /// # Additional Parameters
3684 ///
3685 /// * *$.xgafv* (query-string) - V1 error format.
3686 /// * *access_token* (query-string) - OAuth access token.
3687 /// * *alt* (query-string) - Data format for response.
3688 /// * *callback* (query-string) - JSONP
3689 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3690 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3691 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3692 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3693 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3694 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3695 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3696 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationGetCall<'a, C>
3697 where
3698 T: AsRef<str>,
3699 {
3700 self._additional_params
3701 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3702 self
3703 }
3704
3705 /// Identifies the authorization scope for the method you are building.
3706 ///
3707 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3708 /// [`Scope::CloudPlatform`].
3709 ///
3710 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3711 /// tokens for more than one scope.
3712 ///
3713 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3714 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3715 /// sufficient, a read-write scope will do as well.
3716 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationGetCall<'a, C>
3717 where
3718 St: AsRef<str>,
3719 {
3720 self._scopes.insert(String::from(scope.as_ref()));
3721 self
3722 }
3723 /// Identifies the authorization scope(s) for the method you are building.
3724 ///
3725 /// See [`Self::add_scope()`] for details.
3726 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationGetCall<'a, C>
3727 where
3728 I: IntoIterator<Item = St>,
3729 St: AsRef<str>,
3730 {
3731 self._scopes
3732 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3733 self
3734 }
3735
3736 /// Removes all scopes, and no default scope will be used either.
3737 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3738 /// for details).
3739 pub fn clear_scopes(mut self) -> ProjectLocationOperationGetCall<'a, C> {
3740 self._scopes.clear();
3741 self
3742 }
3743}
3744
3745/// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
3746///
3747/// A builder for the *operations.get* method supported by a *project* resource.
3748/// It is not used directly, but through a [`ProjectMethods`] instance.
3749///
3750/// # Example
3751///
3752/// Instantiate a resource method builder
3753///
3754/// ```test_harness,no_run
3755/// # extern crate hyper;
3756/// # extern crate hyper_rustls;
3757/// # extern crate google_documentai1_beta2 as documentai1_beta2;
3758/// # async fn dox() {
3759/// # use documentai1_beta2::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3760///
3761/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3762/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3763/// # .with_native_roots()
3764/// # .unwrap()
3765/// # .https_only()
3766/// # .enable_http2()
3767/// # .build();
3768///
3769/// # let executor = hyper_util::rt::TokioExecutor::new();
3770/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3771/// # secret,
3772/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3773/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3774/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3775/// # ),
3776/// # ).build().await.unwrap();
3777///
3778/// # let client = hyper_util::client::legacy::Client::builder(
3779/// # hyper_util::rt::TokioExecutor::new()
3780/// # )
3781/// # .build(
3782/// # hyper_rustls::HttpsConnectorBuilder::new()
3783/// # .with_native_roots()
3784/// # .unwrap()
3785/// # .https_or_http()
3786/// # .enable_http2()
3787/// # .build()
3788/// # );
3789/// # let mut hub = Document::new(client, auth);
3790/// // You can configure optional parameters by calling the respective setters at will, and
3791/// // execute the final call using `doit()`.
3792/// // Values shown here are possibly random and not representative !
3793/// let result = hub.projects().operations_get("name")
3794/// .doit().await;
3795/// # }
3796/// ```
3797pub struct ProjectOperationGetCall<'a, C>
3798where
3799 C: 'a,
3800{
3801 hub: &'a Document<C>,
3802 _name: String,
3803 _delegate: Option<&'a mut dyn common::Delegate>,
3804 _additional_params: HashMap<String, String>,
3805 _scopes: BTreeSet<String>,
3806}
3807
3808impl<'a, C> common::CallBuilder for ProjectOperationGetCall<'a, C> {}
3809
3810impl<'a, C> ProjectOperationGetCall<'a, C>
3811where
3812 C: common::Connector,
3813{
3814 /// Perform the operation you have build so far.
3815 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
3816 use std::borrow::Cow;
3817 use std::io::{Read, Seek};
3818
3819 use common::{url::Params, ToParts};
3820 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3821
3822 let mut dd = common::DefaultDelegate;
3823 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3824 dlg.begin(common::MethodInfo {
3825 id: "documentai.projects.operations.get",
3826 http_method: hyper::Method::GET,
3827 });
3828
3829 for &field in ["alt", "name"].iter() {
3830 if self._additional_params.contains_key(field) {
3831 dlg.finished(false);
3832 return Err(common::Error::FieldClash(field));
3833 }
3834 }
3835
3836 let mut params = Params::with_capacity(3 + self._additional_params.len());
3837 params.push("name", self._name);
3838
3839 params.extend(self._additional_params.iter());
3840
3841 params.push("alt", "json");
3842 let mut url = self.hub._base_url.clone() + "v1beta2/{+name}";
3843 if self._scopes.is_empty() {
3844 self._scopes
3845 .insert(Scope::CloudPlatform.as_ref().to_string());
3846 }
3847
3848 #[allow(clippy::single_element_loop)]
3849 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3850 url = params.uri_replacement(url, param_name, find_this, true);
3851 }
3852 {
3853 let to_remove = ["name"];
3854 params.remove_params(&to_remove);
3855 }
3856
3857 let url = params.parse_with_url(&url);
3858
3859 loop {
3860 let token = match self
3861 .hub
3862 .auth
3863 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3864 .await
3865 {
3866 Ok(token) => token,
3867 Err(e) => match dlg.token(e) {
3868 Ok(token) => token,
3869 Err(e) => {
3870 dlg.finished(false);
3871 return Err(common::Error::MissingToken(e));
3872 }
3873 },
3874 };
3875 let mut req_result = {
3876 let client = &self.hub.client;
3877 dlg.pre_request();
3878 let mut req_builder = hyper::Request::builder()
3879 .method(hyper::Method::GET)
3880 .uri(url.as_str())
3881 .header(USER_AGENT, self.hub._user_agent.clone());
3882
3883 if let Some(token) = token.as_ref() {
3884 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3885 }
3886
3887 let request = req_builder
3888 .header(CONTENT_LENGTH, 0_u64)
3889 .body(common::to_body::<String>(None));
3890
3891 client.request(request.unwrap()).await
3892 };
3893
3894 match req_result {
3895 Err(err) => {
3896 if let common::Retry::After(d) = dlg.http_error(&err) {
3897 sleep(d).await;
3898 continue;
3899 }
3900 dlg.finished(false);
3901 return Err(common::Error::HttpError(err));
3902 }
3903 Ok(res) => {
3904 let (mut parts, body) = res.into_parts();
3905 let mut body = common::Body::new(body);
3906 if !parts.status.is_success() {
3907 let bytes = common::to_bytes(body).await.unwrap_or_default();
3908 let error = serde_json::from_str(&common::to_string(&bytes));
3909 let response = common::to_response(parts, bytes.into());
3910
3911 if let common::Retry::After(d) =
3912 dlg.http_failure(&response, error.as_ref().ok())
3913 {
3914 sleep(d).await;
3915 continue;
3916 }
3917
3918 dlg.finished(false);
3919
3920 return Err(match error {
3921 Ok(value) => common::Error::BadRequest(value),
3922 _ => common::Error::Failure(response),
3923 });
3924 }
3925 let response = {
3926 let bytes = common::to_bytes(body).await.unwrap_or_default();
3927 let encoded = common::to_string(&bytes);
3928 match serde_json::from_str(&encoded) {
3929 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3930 Err(error) => {
3931 dlg.response_json_decode_error(&encoded, &error);
3932 return Err(common::Error::JsonDecodeError(
3933 encoded.to_string(),
3934 error,
3935 ));
3936 }
3937 }
3938 };
3939
3940 dlg.finished(true);
3941 return Ok(response);
3942 }
3943 }
3944 }
3945 }
3946
3947 /// The name of the operation resource.
3948 ///
3949 /// Sets the *name* path property to the given value.
3950 ///
3951 /// Even though the property as already been set when instantiating this call,
3952 /// we provide this method for API completeness.
3953 pub fn name(mut self, new_value: &str) -> ProjectOperationGetCall<'a, C> {
3954 self._name = new_value.to_string();
3955 self
3956 }
3957 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3958 /// while executing the actual API request.
3959 ///
3960 /// ````text
3961 /// It should be used to handle progress information, and to implement a certain level of resilience.
3962 /// ````
3963 ///
3964 /// Sets the *delegate* property to the given value.
3965 pub fn delegate(
3966 mut self,
3967 new_value: &'a mut dyn common::Delegate,
3968 ) -> ProjectOperationGetCall<'a, C> {
3969 self._delegate = Some(new_value);
3970 self
3971 }
3972
3973 /// Set any additional parameter of the query string used in the request.
3974 /// It should be used to set parameters which are not yet available through their own
3975 /// setters.
3976 ///
3977 /// Please note that this method must not be used to set any of the known parameters
3978 /// which have their own setter method. If done anyway, the request will fail.
3979 ///
3980 /// # Additional Parameters
3981 ///
3982 /// * *$.xgafv* (query-string) - V1 error format.
3983 /// * *access_token* (query-string) - OAuth access token.
3984 /// * *alt* (query-string) - Data format for response.
3985 /// * *callback* (query-string) - JSONP
3986 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3987 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3988 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3989 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3990 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3991 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3992 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3993 pub fn param<T>(mut self, name: T, value: T) -> ProjectOperationGetCall<'a, C>
3994 where
3995 T: AsRef<str>,
3996 {
3997 self._additional_params
3998 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3999 self
4000 }
4001
4002 /// Identifies the authorization scope for the method you are building.
4003 ///
4004 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4005 /// [`Scope::CloudPlatform`].
4006 ///
4007 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4008 /// tokens for more than one scope.
4009 ///
4010 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4011 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4012 /// sufficient, a read-write scope will do as well.
4013 pub fn add_scope<St>(mut self, scope: St) -> ProjectOperationGetCall<'a, C>
4014 where
4015 St: AsRef<str>,
4016 {
4017 self._scopes.insert(String::from(scope.as_ref()));
4018 self
4019 }
4020 /// Identifies the authorization scope(s) for the method you are building.
4021 ///
4022 /// See [`Self::add_scope()`] for details.
4023 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOperationGetCall<'a, C>
4024 where
4025 I: IntoIterator<Item = St>,
4026 St: AsRef<str>,
4027 {
4028 self._scopes
4029 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4030 self
4031 }
4032
4033 /// Removes all scopes, and no default scope will be used either.
4034 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4035 /// for details).
4036 pub fn clear_scopes(mut self) -> ProjectOperationGetCall<'a, C> {
4037 self._scopes.clear();
4038 self
4039 }
4040}