google_documentai1/
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 as documentai1;
49/// use documentai1::api::GoogleCloudDocumentaiV1ReviewDocumentRequest;
50/// use documentai1::{Result, Error};
51/// # async fn dox() {
52/// use documentai1::{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 auth = yup_oauth2::InstalledFlowAuthenticator::builder(
63///     secret,
64///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
65/// ).build().await.unwrap();
66///
67/// let client = hyper_util::client::legacy::Client::builder(
68///     hyper_util::rt::TokioExecutor::new()
69/// )
70/// .build(
71///     hyper_rustls::HttpsConnectorBuilder::new()
72///         .with_native_roots()
73///         .unwrap()
74///         .https_or_http()
75///         .enable_http1()
76///         .build()
77/// );
78/// let mut hub = Document::new(client, auth);
79/// // As the method needs a request, you would usually fill it with the desired information
80/// // into the respective structure. Some of the parts shown here might not be applicable !
81/// // Values shown here are possibly random and not representative !
82/// let mut req = GoogleCloudDocumentaiV1ReviewDocumentRequest::default();
83///
84/// // You can configure optional parameters by calling the respective setters at will, and
85/// // execute the final call using `doit()`.
86/// // Values shown here are possibly random and not representative !
87/// let result = hub.projects().locations_processors_human_review_config_review_document(req, "humanReviewConfig")
88///              .doit().await;
89///
90/// match result {
91///     Err(e) => match e {
92///         // The Error enum provides details about what exactly happened.
93///         // You can also just use its `Debug`, `Display` or `Error` traits
94///          Error::HttpError(_)
95///         |Error::Io(_)
96///         |Error::MissingAPIKey
97///         |Error::MissingToken(_)
98///         |Error::Cancelled
99///         |Error::UploadSizeLimitExceeded(_, _)
100///         |Error::Failure(_)
101///         |Error::BadRequest(_)
102///         |Error::FieldClash(_)
103///         |Error::JsonDecodeError(_, _) => println!("{}", e),
104///     },
105///     Ok(res) => println!("Success: {:?}", res),
106/// }
107/// # }
108/// ```
109#[derive(Clone)]
110pub struct Document<C> {
111    pub client: common::Client<C>,
112    pub auth: Box<dyn common::GetToken>,
113    _user_agent: String,
114    _base_url: String,
115    _root_url: String,
116}
117
118impl<C> common::Hub for Document<C> {}
119
120impl<'a, C> Document<C> {
121    pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Document<C> {
122        Document {
123            client,
124            auth: Box::new(auth),
125            _user_agent: "google-api-rust-client/6.0.0".to_string(),
126            _base_url: "https://documentai.googleapis.com/".to_string(),
127            _root_url: "https://documentai.googleapis.com/".to_string(),
128        }
129    }
130
131    pub fn operations(&'a self) -> OperationMethods<'a, C> {
132        OperationMethods { hub: self }
133    }
134    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
135        ProjectMethods { hub: self }
136    }
137
138    /// Set the user-agent header field to use in all requests to the server.
139    /// It defaults to `google-api-rust-client/6.0.0`.
140    ///
141    /// Returns the previously set user-agent.
142    pub fn user_agent(&mut self, agent_name: String) -> String {
143        std::mem::replace(&mut self._user_agent, agent_name)
144    }
145
146    /// Set the base url to use in all requests to the server.
147    /// It defaults to `https://documentai.googleapis.com/`.
148    ///
149    /// Returns the previously set base url.
150    pub fn base_url(&mut self, new_base_url: String) -> String {
151        std::mem::replace(&mut self._base_url, new_base_url)
152    }
153
154    /// Set the root url to use in all requests to the server.
155    /// It defaults to `https://documentai.googleapis.com/`.
156    ///
157    /// Returns the previously set root url.
158    pub fn root_url(&mut self, new_root_url: String) -> String {
159        std::mem::replace(&mut self._root_url, new_root_url)
160    }
161}
162
163// ############
164// SCHEMAS ###
165// ##########
166/// Encodes the detailed information of a barcode.
167///
168/// This type is not used in any activity, and only used as *part* of another schema.
169///
170#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
171#[serde_with::serde_as]
172#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
173pub struct GoogleCloudDocumentaiV1Barcode {
174    /// 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.
175    pub format: Option<String>,
176    /// Raw value encoded in the barcode. For example: `'MEBKM:TITLE:Google;URL:https://www.google.com;;'`.
177    #[serde(rename = "rawValue")]
178    pub raw_value: Option<String>,
179    /// 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.
180    #[serde(rename = "valueFormat")]
181    pub value_format: Option<String>,
182}
183
184impl common::Part for GoogleCloudDocumentaiV1Barcode {}
185
186/// The common config to specify a set of documents used as input.
187///
188/// This type is not used in any activity, and only used as *part* of another schema.
189///
190#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
191#[serde_with::serde_as]
192#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
193pub struct GoogleCloudDocumentaiV1BatchDocumentsInputConfig {
194    /// The set of documents individually specified on Cloud Storage.
195    #[serde(rename = "gcsDocuments")]
196    pub gcs_documents: Option<GoogleCloudDocumentaiV1GcsDocuments>,
197    /// The set of documents that match the specified Cloud Storage `gcs_prefix`.
198    #[serde(rename = "gcsPrefix")]
199    pub gcs_prefix: Option<GoogleCloudDocumentaiV1GcsPrefix>,
200}
201
202impl common::Part for GoogleCloudDocumentaiV1BatchDocumentsInputConfig {}
203
204/// Request message for BatchProcessDocuments.
205///
206/// # Activities
207///
208/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
209/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
210///
211/// * [locations processors processor versions batch process projects](ProjectLocationProcessorProcessorVersionBatchProcesCall) (request)
212/// * [locations processors batch process projects](ProjectLocationProcessorBatchProcesCall) (request)
213#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
214#[serde_with::serde_as]
215#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
216pub struct GoogleCloudDocumentaiV1BatchProcessRequest {
217    /// The output configuration for the BatchProcessDocuments method.
218    #[serde(rename = "documentOutputConfig")]
219    pub document_output_config: Option<GoogleCloudDocumentaiV1DocumentOutputConfig>,
220    /// The input documents for the BatchProcessDocuments method.
221    #[serde(rename = "inputDocuments")]
222    pub input_documents: Option<GoogleCloudDocumentaiV1BatchDocumentsInputConfig>,
223    /// Optional. The labels with user-defined metadata for the request. Label keys and values can be no longer than 63 characters (Unicode codepoints) and can only contain lowercase letters, numeric characters, underscores, and dashes. International characters are allowed. Label values are optional. Label keys must start with a letter.
224    pub labels: Option<HashMap<String, String>>,
225    /// Inference-time options for the process API
226    #[serde(rename = "processOptions")]
227    pub process_options: Option<GoogleCloudDocumentaiV1ProcessOptions>,
228    /// Whether human review should be skipped for this request. Default to `false`.
229    #[serde(rename = "skipHumanReview")]
230    pub skip_human_review: Option<bool>,
231}
232
233impl common::RequestValue for GoogleCloudDocumentaiV1BatchProcessRequest {}
234
235/// A bounding polygon for the detected image annotation.
236///
237/// This type is not used in any activity, and only used as *part* of another schema.
238///
239#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
240#[serde_with::serde_as]
241#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
242pub struct GoogleCloudDocumentaiV1BoundingPoly {
243    /// The bounding polygon normalized vertices.
244    #[serde(rename = "normalizedVertices")]
245    pub normalized_vertices: Option<Vec<GoogleCloudDocumentaiV1NormalizedVertex>>,
246    /// The bounding polygon vertices.
247    pub vertices: Option<Vec<GoogleCloudDocumentaiV1Vertex>>,
248}
249
250impl common::Part for GoogleCloudDocumentaiV1BoundingPoly {}
251
252/// Request message for the DeployProcessorVersion method.
253///
254/// # Activities
255///
256/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
257/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
258///
259/// * [locations processors processor versions deploy projects](ProjectLocationProcessorProcessorVersionDeployCall) (request)
260#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
261#[serde_with::serde_as]
262#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
263pub struct GoogleCloudDocumentaiV1DeployProcessorVersionRequest {
264    _never_set: Option<bool>,
265}
266
267impl common::RequestValue for GoogleCloudDocumentaiV1DeployProcessorVersionRequest {}
268
269/// Request message for the DisableProcessor method.
270///
271/// # Activities
272///
273/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
274/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
275///
276/// * [locations processors disable projects](ProjectLocationProcessorDisableCall) (request)
277#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
278#[serde_with::serde_as]
279#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
280pub struct GoogleCloudDocumentaiV1DisableProcessorRequest {
281    _never_set: Option<bool>,
282}
283
284impl common::RequestValue for GoogleCloudDocumentaiV1DisableProcessorRequest {}
285
286/// 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.
287///
288/// This type is not used in any activity, and only used as *part* of another schema.
289///
290#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
291#[serde_with::serde_as]
292#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
293pub struct GoogleCloudDocumentaiV1Document {
294    /// Document chunked based on chunking config.
295    #[serde(rename = "chunkedDocument")]
296    pub chunked_document: Option<GoogleCloudDocumentaiV1DocumentChunkedDocument>,
297    /// 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.
298    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
299    pub content: Option<Vec<u8>>,
300    /// Parsed layout of the document.
301    #[serde(rename = "documentLayout")]
302    pub document_layout: Option<GoogleCloudDocumentaiV1DocumentDocumentLayout>,
303    /// A list of entities detected on Document.text. For document shards, entities in this list may cross shard boundaries.
304    pub entities: Option<Vec<GoogleCloudDocumentaiV1DocumentEntity>>,
305    /// Placeholder. Relationship among Document.entities.
306    #[serde(rename = "entityRelations")]
307    pub entity_relations: Option<Vec<GoogleCloudDocumentaiV1DocumentEntityRelation>>,
308    /// Any error that occurred while processing this document.
309    pub error: Option<GoogleRpcStatus>,
310    /// An IANA published [media type (MIME type)](https://www.iana.org/assignments/media-types/media-types.xhtml).
311    #[serde(rename = "mimeType")]
312    pub mime_type: Option<String>,
313    /// Visual page layout for the Document.
314    pub pages: Option<Vec<GoogleCloudDocumentaiV1DocumentPage>>,
315    /// Placeholder. Revision history of this document.
316    pub revisions: Option<Vec<GoogleCloudDocumentaiV1DocumentRevision>>,
317    /// 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.
318    #[serde(rename = "shardInfo")]
319    pub shard_info: Option<GoogleCloudDocumentaiV1DocumentShardInfo>,
320    /// Optional. UTF-8 encoded text in reading order from the document.
321    pub text: Option<String>,
322    /// 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.
323    #[serde(rename = "textChanges")]
324    pub text_changes: Option<Vec<GoogleCloudDocumentaiV1DocumentTextChange>>,
325    /// Styles for the Document.text.
326    #[serde(rename = "textStyles")]
327    pub text_styles: Option<Vec<GoogleCloudDocumentaiV1DocumentStyle>>,
328    /// 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).
329    pub uri: Option<String>,
330}
331
332impl common::Part for GoogleCloudDocumentaiV1Document {}
333
334/// Represents the chunks that the document is divided into.
335///
336/// This type is not used in any activity, and only used as *part* of another schema.
337///
338#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
339#[serde_with::serde_as]
340#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
341pub struct GoogleCloudDocumentaiV1DocumentChunkedDocument {
342    /// List of chunks.
343    pub chunks: Option<Vec<GoogleCloudDocumentaiV1DocumentChunkedDocumentChunk>>,
344}
345
346impl common::Part for GoogleCloudDocumentaiV1DocumentChunkedDocument {}
347
348/// Represents a chunk.
349///
350/// This type is not used in any activity, and only used as *part* of another schema.
351///
352#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
353#[serde_with::serde_as]
354#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
355pub struct GoogleCloudDocumentaiV1DocumentChunkedDocumentChunk {
356    /// ID of the chunk.
357    #[serde(rename = "chunkId")]
358    pub chunk_id: Option<String>,
359    /// Text content of the chunk.
360    pub content: Option<String>,
361    /// Page footers associated with the chunk.
362    #[serde(rename = "pageFooters")]
363    pub page_footers:
364        Option<Vec<GoogleCloudDocumentaiV1DocumentChunkedDocumentChunkChunkPageFooter>>,
365    /// Page headers associated with the chunk.
366    #[serde(rename = "pageHeaders")]
367    pub page_headers:
368        Option<Vec<GoogleCloudDocumentaiV1DocumentChunkedDocumentChunkChunkPageHeader>>,
369    /// Page span of the chunk.
370    #[serde(rename = "pageSpan")]
371    pub page_span: Option<GoogleCloudDocumentaiV1DocumentChunkedDocumentChunkChunkPageSpan>,
372    /// Unused.
373    #[serde(rename = "sourceBlockIds")]
374    pub source_block_ids: Option<Vec<String>>,
375}
376
377impl common::Part for GoogleCloudDocumentaiV1DocumentChunkedDocumentChunk {}
378
379/// Represents the page footer associated with the chunk.
380///
381/// This type is not used in any activity, and only used as *part* of another schema.
382///
383#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
384#[serde_with::serde_as]
385#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
386pub struct GoogleCloudDocumentaiV1DocumentChunkedDocumentChunkChunkPageFooter {
387    /// Page span of the footer.
388    #[serde(rename = "pageSpan")]
389    pub page_span: Option<GoogleCloudDocumentaiV1DocumentChunkedDocumentChunkChunkPageSpan>,
390    /// Footer in text format.
391    pub text: Option<String>,
392}
393
394impl common::Part for GoogleCloudDocumentaiV1DocumentChunkedDocumentChunkChunkPageFooter {}
395
396/// Represents the page header associated with the chunk.
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 GoogleCloudDocumentaiV1DocumentChunkedDocumentChunkChunkPageHeader {
404    /// Page span of the header.
405    #[serde(rename = "pageSpan")]
406    pub page_span: Option<GoogleCloudDocumentaiV1DocumentChunkedDocumentChunkChunkPageSpan>,
407    /// Header in text format.
408    pub text: Option<String>,
409}
410
411impl common::Part for GoogleCloudDocumentaiV1DocumentChunkedDocumentChunkChunkPageHeader {}
412
413/// Represents where the chunk starts and ends in the document.
414///
415/// This type is not used in any activity, and only used as *part* of another schema.
416///
417#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
418#[serde_with::serde_as]
419#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
420pub struct GoogleCloudDocumentaiV1DocumentChunkedDocumentChunkChunkPageSpan {
421    /// Page where chunk ends in the document.
422    #[serde(rename = "pageEnd")]
423    pub page_end: Option<i32>,
424    /// Page where chunk starts in the document.
425    #[serde(rename = "pageStart")]
426    pub page_start: Option<i32>,
427}
428
429impl common::Part for GoogleCloudDocumentaiV1DocumentChunkedDocumentChunkChunkPageSpan {}
430
431/// Represents the parsed layout of a document as a collection of blocks that the document is divided into.
432///
433/// This type is not used in any activity, and only used as *part* of another schema.
434///
435#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
436#[serde_with::serde_as]
437#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
438pub struct GoogleCloudDocumentaiV1DocumentDocumentLayout {
439    /// List of blocks in the document.
440    pub blocks: Option<Vec<GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlock>>,
441}
442
443impl common::Part for GoogleCloudDocumentaiV1DocumentDocumentLayout {}
444
445/// Represents a block. A block could be one of the various types (text, table, list) supported.
446///
447/// This type is not used in any activity, and only used as *part* of another schema.
448///
449#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
450#[serde_with::serde_as]
451#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
452pub struct GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlock {
453    /// ID of the block.
454    #[serde(rename = "blockId")]
455    pub block_id: Option<String>,
456    /// Block consisting of list content/structure.
457    #[serde(rename = "listBlock")]
458    pub list_block:
459        Option<GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutListBlock>,
460    /// Page span of the block.
461    #[serde(rename = "pageSpan")]
462    pub page_span:
463        Option<GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutPageSpan>,
464    /// Block consisting of table content/structure.
465    #[serde(rename = "tableBlock")]
466    pub table_block:
467        Option<GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutTableBlock>,
468    /// Block consisting of text content.
469    #[serde(rename = "textBlock")]
470    pub text_block:
471        Option<GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutTextBlock>,
472}
473
474impl common::Part for GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlock {}
475
476/// Represents a list type block.
477///
478/// This type is not used in any activity, and only used as *part* of another schema.
479///
480#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
481#[serde_with::serde_as]
482#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
483pub struct GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutListBlock {
484    /// List entries that constitute a list block.
485    #[serde(rename = "listEntries")]
486    pub list_entries: Option<
487        Vec<GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutListEntry>,
488    >,
489    /// Type of the list_entries (if exist). Available options are `ordered` and `unordered`.
490    #[serde(rename = "type")]
491    pub type_: Option<String>,
492}
493
494impl common::Part
495    for GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutListBlock
496{
497}
498
499/// Represents an entry in the list.
500///
501/// This type is not used in any activity, and only used as *part* of another schema.
502///
503#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
504#[serde_with::serde_as]
505#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
506pub struct GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutListEntry {
507    /// A list entry is a list of blocks. Repeated blocks support further hierarchies and nested blocks.
508    pub blocks: Option<Vec<GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlock>>,
509}
510
511impl common::Part
512    for GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutListEntry
513{
514}
515
516/// Represents where the block starts and ends in the document.
517///
518/// This type is not used in any activity, and only used as *part* of another schema.
519///
520#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
521#[serde_with::serde_as]
522#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
523pub struct GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutPageSpan {
524    /// Page where block ends in the document.
525    #[serde(rename = "pageEnd")]
526    pub page_end: Option<i32>,
527    /// Page where block starts in the document.
528    #[serde(rename = "pageStart")]
529    pub page_start: Option<i32>,
530}
531
532impl common::Part
533    for GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutPageSpan
534{
535}
536
537/// Represents a table type block.
538///
539/// This type is not used in any activity, and only used as *part* of another schema.
540///
541#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
542#[serde_with::serde_as]
543#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
544pub struct GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutTableBlock {
545    /// Body rows containing main table content.
546    #[serde(rename = "bodyRows")]
547    pub body_rows:
548        Option<Vec<GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutTableRow>>,
549    /// Table caption/title.
550    pub caption: Option<String>,
551    /// Header rows at the top of the table.
552    #[serde(rename = "headerRows")]
553    pub header_rows:
554        Option<Vec<GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutTableRow>>,
555}
556
557impl common::Part
558    for GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutTableBlock
559{
560}
561
562/// Represents a cell in a table row.
563///
564/// This type is not used in any activity, and only used as *part* of another schema.
565///
566#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
567#[serde_with::serde_as]
568#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
569pub struct GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutTableCell {
570    /// A table cell is a list of blocks. Repeated blocks support further hierarchies and nested blocks.
571    pub blocks: Option<Vec<GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlock>>,
572    /// How many columns this cell spans.
573    #[serde(rename = "colSpan")]
574    pub col_span: Option<i32>,
575    /// How many rows this cell spans.
576    #[serde(rename = "rowSpan")]
577    pub row_span: Option<i32>,
578}
579
580impl common::Part
581    for GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutTableCell
582{
583}
584
585/// Represents a row in a table.
586///
587/// This type is not used in any activity, and only used as *part* of another schema.
588///
589#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
590#[serde_with::serde_as]
591#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
592pub struct GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutTableRow {
593    /// A table row is a list of table cells.
594    pub cells: Option<
595        Vec<GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutTableCell>,
596    >,
597}
598
599impl common::Part
600    for GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutTableRow
601{
602}
603
604/// Represents a text type block.
605///
606/// This type is not used in any activity, and only used as *part* of another schema.
607///
608#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
609#[serde_with::serde_as]
610#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
611pub struct GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutTextBlock {
612    /// A text block could further have child blocks. Repeated blocks support further hierarchies and nested blocks.
613    pub blocks: Option<Vec<GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlock>>,
614    /// Text content stored in the block.
615    pub text: Option<String>,
616    /// Type of the text in the block. Available options are: `paragraph`, `subtitle`, `heading-1`, `heading-2`, `heading-3`, `heading-4`, `heading-5`, `header`, `footer`.
617    #[serde(rename = "type")]
618    pub type_: Option<String>,
619}
620
621impl common::Part
622    for GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutTextBlock
623{
624}
625
626/// 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.
627///
628/// This type is not used in any activity, and only used as *part* of another schema.
629///
630#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
631#[serde_with::serde_as]
632#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
633pub struct GoogleCloudDocumentaiV1DocumentEntity {
634    /// Optional. Confidence of detected Schema entity. Range `[0, 1]`.
635    pub confidence: Option<f32>,
636    /// Optional. Canonical id. This will be a unique value in the entity list for this document.
637    pub id: Option<String>,
638    /// Optional. Deprecated. Use `id` field instead.
639    #[serde(rename = "mentionId")]
640    pub mention_id: Option<String>,
641    /// Optional. Text value of the entity e.g. `1600 Amphitheatre Pkwy`.
642    #[serde(rename = "mentionText")]
643    pub mention_text: Option<String>,
644    /// 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.
645    #[serde(rename = "normalizedValue")]
646    pub normalized_value: Option<GoogleCloudDocumentaiV1DocumentEntityNormalizedValue>,
647    /// Optional. Represents the provenance of this entity wrt. the location on the page where it was found.
648    #[serde(rename = "pageAnchor")]
649    pub page_anchor: Option<GoogleCloudDocumentaiV1DocumentPageAnchor>,
650    /// Optional. Entities can be nested to form a hierarchical data structure representing the content in the document.
651    pub properties: Option<Vec<GoogleCloudDocumentaiV1DocumentEntity>>,
652    /// Optional. The history of this annotation.
653    pub provenance: Option<GoogleCloudDocumentaiV1DocumentProvenance>,
654    /// Optional. Whether the entity will be redacted for de-identification purposes.
655    pub redacted: Option<bool>,
656    /// Optional. Provenance of the entity. Text anchor indexing into the Document.text.
657    #[serde(rename = "textAnchor")]
658    pub text_anchor: Option<GoogleCloudDocumentaiV1DocumentTextAnchor>,
659    /// Required. Entity type from a schema e.g. `Address`.
660    #[serde(rename = "type")]
661    pub type_: Option<String>,
662}
663
664impl common::Part for GoogleCloudDocumentaiV1DocumentEntity {}
665
666/// Parsed and normalized entity value.
667///
668/// This type is not used in any activity, and only used as *part* of another schema.
669///
670#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
671#[serde_with::serde_as]
672#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
673pub struct GoogleCloudDocumentaiV1DocumentEntityNormalizedValue {
674    /// Postal address. See also: https://github.com/googleapis/googleapis/blob/master/google/type/postal_address.proto
675    #[serde(rename = "addressValue")]
676    pub address_value: Option<GoogleTypePostalAddress>,
677    /// Boolean value. Can be used for entities with binary values, or for checkboxes.
678    #[serde(rename = "booleanValue")]
679    pub boolean_value: Option<bool>,
680    /// Date value. Includes year, month, day. See also: https://github.com/googleapis/googleapis/blob/master/google/type/date.proto
681    #[serde(rename = "dateValue")]
682    pub date_value: Option<GoogleTypeDate>,
683    /// DateTime value. Includes date, time, and timezone. See also: https://github.com/googleapis/googleapis/blob/master/google/type/datetime.proto
684    #[serde(rename = "datetimeValue")]
685    pub datetime_value: Option<GoogleTypeDateTime>,
686    /// Float value.
687    #[serde(rename = "floatValue")]
688    pub float_value: Option<f32>,
689    /// Integer value.
690    #[serde(rename = "integerValue")]
691    pub integer_value: Option<i32>,
692    /// Money value. See also: https://github.com/googleapis/googleapis/blob/master/google/type/money.proto
693    #[serde(rename = "moneyValue")]
694    pub money_value: Option<GoogleTypeMoney>,
695    /// 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.
696    pub text: Option<String>,
697}
698
699impl common::Part for GoogleCloudDocumentaiV1DocumentEntityNormalizedValue {}
700
701/// Relationship between Entities.
702///
703/// This type is not used in any activity, and only used as *part* of another schema.
704///
705#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
706#[serde_with::serde_as]
707#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
708pub struct GoogleCloudDocumentaiV1DocumentEntityRelation {
709    /// Object entity id.
710    #[serde(rename = "objectId")]
711    pub object_id: Option<String>,
712    /// Relationship description.
713    pub relation: Option<String>,
714    /// Subject entity id.
715    #[serde(rename = "subjectId")]
716    pub subject_id: Option<String>,
717}
718
719impl common::Part for GoogleCloudDocumentaiV1DocumentEntityRelation {}
720
721/// Config that controls the output of documents. All documents will be written as a JSON file.
722///
723/// This type is not used in any activity, and only used as *part* of another schema.
724///
725#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
726#[serde_with::serde_as]
727#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
728pub struct GoogleCloudDocumentaiV1DocumentOutputConfig {
729    /// Output config to write the results to Cloud Storage.
730    #[serde(rename = "gcsOutputConfig")]
731    pub gcs_output_config: Option<GoogleCloudDocumentaiV1DocumentOutputConfigGcsOutputConfig>,
732}
733
734impl common::Part for GoogleCloudDocumentaiV1DocumentOutputConfig {}
735
736/// The configuration used when outputting documents.
737///
738/// This type is not used in any activity, and only used as *part* of another schema.
739///
740#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
741#[serde_with::serde_as]
742#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
743pub struct GoogleCloudDocumentaiV1DocumentOutputConfigGcsOutputConfig {
744    /// Specifies which fields to include in the output documents. Only supports top level document and pages field so it must be in the form of `{document_field_name}` or `pages.{page_field_name}`.
745    #[serde(rename = "fieldMask")]
746    pub field_mask: Option<common::FieldMask>,
747    /// The Cloud Storage uri (a directory) of the output.
748    #[serde(rename = "gcsUri")]
749    pub gcs_uri: Option<String>,
750    /// Specifies the sharding config for the output document.
751    #[serde(rename = "shardingConfig")]
752    pub sharding_config:
753        Option<GoogleCloudDocumentaiV1DocumentOutputConfigGcsOutputConfigShardingConfig>,
754}
755
756impl common::Part for GoogleCloudDocumentaiV1DocumentOutputConfigGcsOutputConfig {}
757
758/// The sharding config for the output document.
759///
760/// This type is not used in any activity, and only used as *part* of another schema.
761///
762#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
763#[serde_with::serde_as]
764#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
765pub struct GoogleCloudDocumentaiV1DocumentOutputConfigGcsOutputConfigShardingConfig {
766    /// The number of overlapping pages between consecutive shards.
767    #[serde(rename = "pagesOverlap")]
768    pub pages_overlap: Option<i32>,
769    /// The number of pages per shard.
770    #[serde(rename = "pagesPerShard")]
771    pub pages_per_shard: Option<i32>,
772}
773
774impl common::Part for GoogleCloudDocumentaiV1DocumentOutputConfigGcsOutputConfigShardingConfig {}
775
776/// A page in a Document.
777///
778/// This type is not used in any activity, and only used as *part* of another schema.
779///
780#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
781#[serde_with::serde_as]
782#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
783pub struct GoogleCloudDocumentaiV1DocumentPage {
784    /// 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.
785    pub blocks: Option<Vec<GoogleCloudDocumentaiV1DocumentPageBlock>>,
786    /// A list of detected barcodes.
787    #[serde(rename = "detectedBarcodes")]
788    pub detected_barcodes: Option<Vec<GoogleCloudDocumentaiV1DocumentPageDetectedBarcode>>,
789    /// A list of detected languages together with confidence.
790    #[serde(rename = "detectedLanguages")]
791    pub detected_languages: Option<Vec<GoogleCloudDocumentaiV1DocumentPageDetectedLanguage>>,
792    /// Physical dimension of the page.
793    pub dimension: Option<GoogleCloudDocumentaiV1DocumentPageDimension>,
794    /// A list of visually detected form fields on the page.
795    #[serde(rename = "formFields")]
796    pub form_fields: Option<Vec<GoogleCloudDocumentaiV1DocumentPageFormField>>,
797    /// 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.
798    pub image: Option<GoogleCloudDocumentaiV1DocumentPageImage>,
799    /// Image quality scores.
800    #[serde(rename = "imageQualityScores")]
801    pub image_quality_scores: Option<GoogleCloudDocumentaiV1DocumentPageImageQualityScores>,
802    /// Layout for the page.
803    pub layout: Option<GoogleCloudDocumentaiV1DocumentPageLayout>,
804    /// A list of visually detected text lines on the page. A collection of tokens that a human would perceive as a line.
805    pub lines: Option<Vec<GoogleCloudDocumentaiV1DocumentPageLine>>,
806    /// 1-based index for current Page in a parent Document. Useful when a page is taken out of a Document for individual processing.
807    #[serde(rename = "pageNumber")]
808    pub page_number: Option<i32>,
809    /// A list of visually detected text paragraphs on the page. A collection of lines that a human would perceive as a paragraph.
810    pub paragraphs: Option<Vec<GoogleCloudDocumentaiV1DocumentPageParagraph>>,
811    /// The history of this page.
812    pub provenance: Option<GoogleCloudDocumentaiV1DocumentProvenance>,
813    /// A list of visually detected symbols on the page.
814    pub symbols: Option<Vec<GoogleCloudDocumentaiV1DocumentPageSymbol>>,
815    /// A list of visually detected tables on the page.
816    pub tables: Option<Vec<GoogleCloudDocumentaiV1DocumentPageTable>>,
817    /// A list of visually detected tokens on the page.
818    pub tokens: Option<Vec<GoogleCloudDocumentaiV1DocumentPageToken>>,
819    /// Transformation matrices that were applied to the original document image to produce Page.image.
820    pub transforms: Option<Vec<GoogleCloudDocumentaiV1DocumentPageMatrix>>,
821    /// A list of detected non-text visual elements e.g. checkbox, signature etc. on the page.
822    #[serde(rename = "visualElements")]
823    pub visual_elements: Option<Vec<GoogleCloudDocumentaiV1DocumentPageVisualElement>>,
824}
825
826impl common::Part for GoogleCloudDocumentaiV1DocumentPage {}
827
828/// 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.
829///
830/// This type is not used in any activity, and only used as *part* of another schema.
831///
832#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
833#[serde_with::serde_as]
834#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
835pub struct GoogleCloudDocumentaiV1DocumentPageAnchor {
836    /// One or more references to visual page elements
837    #[serde(rename = "pageRefs")]
838    pub page_refs: Option<Vec<GoogleCloudDocumentaiV1DocumentPageAnchorPageRef>>,
839}
840
841impl common::Part for GoogleCloudDocumentaiV1DocumentPageAnchor {}
842
843/// Represents a weak reference to a page element within a document.
844///
845/// This type is not used in any activity, and only used as *part* of another schema.
846///
847#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
848#[serde_with::serde_as]
849#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
850pub struct GoogleCloudDocumentaiV1DocumentPageAnchorPageRef {
851    /// 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.
852    #[serde(rename = "boundingPoly")]
853    pub bounding_poly: Option<GoogleCloudDocumentaiV1BoundingPoly>,
854    /// Optional. Confidence of detected page element, if applicable. Range `[0, 1]`.
855    pub confidence: Option<f32>,
856    /// Optional. Deprecated. Use PageRef.bounding_poly instead.
857    #[serde(rename = "layoutId")]
858    pub layout_id: Option<String>,
859    /// Optional. The type of the layout element that is being referenced if any.
860    #[serde(rename = "layoutType")]
861    pub layout_type: Option<String>,
862    /// 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.
863    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
864    pub page: Option<i64>,
865}
866
867impl common::Part for GoogleCloudDocumentaiV1DocumentPageAnchorPageRef {}
868
869/// A block has a set of lines (collected into paragraphs) that have a common line-spacing and orientation.
870///
871/// This type is not used in any activity, and only used as *part* of another schema.
872///
873#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
874#[serde_with::serde_as]
875#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
876pub struct GoogleCloudDocumentaiV1DocumentPageBlock {
877    /// A list of detected languages together with confidence.
878    #[serde(rename = "detectedLanguages")]
879    pub detected_languages: Option<Vec<GoogleCloudDocumentaiV1DocumentPageDetectedLanguage>>,
880    /// Layout for Block.
881    pub layout: Option<GoogleCloudDocumentaiV1DocumentPageLayout>,
882    /// The history of this annotation.
883    pub provenance: Option<GoogleCloudDocumentaiV1DocumentProvenance>,
884}
885
886impl common::Part for GoogleCloudDocumentaiV1DocumentPageBlock {}
887
888/// A detected barcode.
889///
890/// This type is not used in any activity, and only used as *part* of another schema.
891///
892#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
893#[serde_with::serde_as]
894#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
895pub struct GoogleCloudDocumentaiV1DocumentPageDetectedBarcode {
896    /// Detailed barcode information of the DetectedBarcode.
897    pub barcode: Option<GoogleCloudDocumentaiV1Barcode>,
898    /// Layout for DetectedBarcode.
899    pub layout: Option<GoogleCloudDocumentaiV1DocumentPageLayout>,
900}
901
902impl common::Part for GoogleCloudDocumentaiV1DocumentPageDetectedBarcode {}
903
904/// Detected language for a structural component.
905///
906/// This type is not used in any activity, and only used as *part* of another schema.
907///
908#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
909#[serde_with::serde_as]
910#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
911pub struct GoogleCloudDocumentaiV1DocumentPageDetectedLanguage {
912    /// Confidence of detected language. Range `[0, 1]`.
913    pub confidence: Option<f32>,
914    /// The [BCP-47 language code](https://www.unicode.org/reports/tr35/#Unicode_locale_identifier), such as `en-US` or `sr-Latn`.
915    #[serde(rename = "languageCode")]
916    pub language_code: Option<String>,
917}
918
919impl common::Part for GoogleCloudDocumentaiV1DocumentPageDetectedLanguage {}
920
921/// Dimension for the page.
922///
923/// This type is not used in any activity, and only used as *part* of another schema.
924///
925#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
926#[serde_with::serde_as]
927#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
928pub struct GoogleCloudDocumentaiV1DocumentPageDimension {
929    /// Page height.
930    pub height: Option<f32>,
931    /// Dimension unit.
932    pub unit: Option<String>,
933    /// Page width.
934    pub width: Option<f32>,
935}
936
937impl common::Part for GoogleCloudDocumentaiV1DocumentPageDimension {}
938
939/// A form field detected on the page.
940///
941/// This type is not used in any activity, and only used as *part* of another schema.
942///
943#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
944#[serde_with::serde_as]
945#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
946pub struct GoogleCloudDocumentaiV1DocumentPageFormField {
947    /// 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.
948    #[serde(rename = "correctedKeyText")]
949    pub corrected_key_text: Option<String>,
950    /// 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.
951    #[serde(rename = "correctedValueText")]
952    pub corrected_value_text: Option<String>,
953    /// Layout for the FormField name. e.g. `Address`, `Email`, `Grand total`, `Phone number`, etc.
954    #[serde(rename = "fieldName")]
955    pub field_name: Option<GoogleCloudDocumentaiV1DocumentPageLayout>,
956    /// Layout for the FormField value.
957    #[serde(rename = "fieldValue")]
958    pub field_value: Option<GoogleCloudDocumentaiV1DocumentPageLayout>,
959    /// A list of detected languages for name together with confidence.
960    #[serde(rename = "nameDetectedLanguages")]
961    pub name_detected_languages: Option<Vec<GoogleCloudDocumentaiV1DocumentPageDetectedLanguage>>,
962    /// The history of this annotation.
963    pub provenance: Option<GoogleCloudDocumentaiV1DocumentProvenance>,
964    /// A list of detected languages for value together with confidence.
965    #[serde(rename = "valueDetectedLanguages")]
966    pub value_detected_languages: Option<Vec<GoogleCloudDocumentaiV1DocumentPageDetectedLanguage>>,
967    /// 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`
968    #[serde(rename = "valueType")]
969    pub value_type: Option<String>,
970}
971
972impl common::Part for GoogleCloudDocumentaiV1DocumentPageFormField {}
973
974/// Rendered image contents for this page.
975///
976/// This type is not used in any activity, and only used as *part* of another schema.
977///
978#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
979#[serde_with::serde_as]
980#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
981pub struct GoogleCloudDocumentaiV1DocumentPageImage {
982    /// Raw byte content of the image.
983    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
984    pub content: Option<Vec<u8>>,
985    /// Height of the image in pixels.
986    pub height: Option<i32>,
987    /// Encoding [media type (MIME type)](https://www.iana.org/assignments/media-types/media-types.xhtml) for the image.
988    #[serde(rename = "mimeType")]
989    pub mime_type: Option<String>,
990    /// Width of the image in pixels.
991    pub width: Option<i32>,
992}
993
994impl common::Part for GoogleCloudDocumentaiV1DocumentPageImage {}
995
996/// Image quality scores for the page image.
997///
998/// This type is not used in any activity, and only used as *part* of another schema.
999///
1000#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1001#[serde_with::serde_as]
1002#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1003pub struct GoogleCloudDocumentaiV1DocumentPageImageQualityScores {
1004    /// A list of detected defects.
1005    #[serde(rename = "detectedDefects")]
1006    pub detected_defects:
1007        Option<Vec<GoogleCloudDocumentaiV1DocumentPageImageQualityScoresDetectedDefect>>,
1008    /// The overall quality score. Range `[0, 1]` where `1` is perfect quality.
1009    #[serde(rename = "qualityScore")]
1010    pub quality_score: Option<f32>,
1011}
1012
1013impl common::Part for GoogleCloudDocumentaiV1DocumentPageImageQualityScores {}
1014
1015/// Image Quality Defects
1016///
1017/// This type is not used in any activity, and only used as *part* of another schema.
1018///
1019#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1020#[serde_with::serde_as]
1021#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1022pub struct GoogleCloudDocumentaiV1DocumentPageImageQualityScoresDetectedDefect {
1023    /// Confidence of detected defect. Range `[0, 1]` where `1` indicates strong confidence that the defect exists.
1024    pub confidence: Option<f32>,
1025    /// 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`
1026    #[serde(rename = "type")]
1027    pub type_: Option<String>,
1028}
1029
1030impl common::Part for GoogleCloudDocumentaiV1DocumentPageImageQualityScoresDetectedDefect {}
1031
1032/// Visual element describing a layout unit on a page.
1033///
1034/// This type is not used in any activity, and only used as *part* of another schema.
1035///
1036#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1037#[serde_with::serde_as]
1038#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1039pub struct GoogleCloudDocumentaiV1DocumentPageLayout {
1040    /// The bounding polygon for the Layout.
1041    #[serde(rename = "boundingPoly")]
1042    pub bounding_poly: Option<GoogleCloudDocumentaiV1BoundingPoly>,
1043    /// 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]`.
1044    pub confidence: Option<f32>,
1045    /// Detected orientation for the Layout.
1046    pub orientation: Option<String>,
1047    /// Text anchor indexing into the Document.text.
1048    #[serde(rename = "textAnchor")]
1049    pub text_anchor: Option<GoogleCloudDocumentaiV1DocumentTextAnchor>,
1050}
1051
1052impl common::Part for GoogleCloudDocumentaiV1DocumentPageLayout {}
1053
1054/// A collection of tokens that a human would perceive as a line. Does not cross column boundaries, can be horizontal, vertical, etc.
1055///
1056/// This type is not used in any activity, and only used as *part* of another schema.
1057///
1058#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1059#[serde_with::serde_as]
1060#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1061pub struct GoogleCloudDocumentaiV1DocumentPageLine {
1062    /// A list of detected languages together with confidence.
1063    #[serde(rename = "detectedLanguages")]
1064    pub detected_languages: Option<Vec<GoogleCloudDocumentaiV1DocumentPageDetectedLanguage>>,
1065    /// Layout for Line.
1066    pub layout: Option<GoogleCloudDocumentaiV1DocumentPageLayout>,
1067    /// The history of this annotation.
1068    pub provenance: Option<GoogleCloudDocumentaiV1DocumentProvenance>,
1069}
1070
1071impl common::Part for GoogleCloudDocumentaiV1DocumentPageLine {}
1072
1073/// Representation for transformation matrix, intended to be compatible and used with OpenCV format for image manipulation.
1074///
1075/// This type is not used in any activity, and only used as *part* of another schema.
1076///
1077#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1078#[serde_with::serde_as]
1079#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1080pub struct GoogleCloudDocumentaiV1DocumentPageMatrix {
1081    /// Number of columns in the matrix.
1082    pub cols: Option<i32>,
1083    /// The matrix data.
1084    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1085    pub data: Option<Vec<u8>>,
1086    /// Number of rows in the matrix.
1087    pub rows: Option<i32>,
1088    /// 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
1089    #[serde(rename = "type")]
1090    pub type_: Option<i32>,
1091}
1092
1093impl common::Part for GoogleCloudDocumentaiV1DocumentPageMatrix {}
1094
1095/// A collection of lines that a human would perceive as a paragraph.
1096///
1097/// This type is not used in any activity, and only used as *part* of another schema.
1098///
1099#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1100#[serde_with::serde_as]
1101#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1102pub struct GoogleCloudDocumentaiV1DocumentPageParagraph {
1103    /// A list of detected languages together with confidence.
1104    #[serde(rename = "detectedLanguages")]
1105    pub detected_languages: Option<Vec<GoogleCloudDocumentaiV1DocumentPageDetectedLanguage>>,
1106    /// Layout for Paragraph.
1107    pub layout: Option<GoogleCloudDocumentaiV1DocumentPageLayout>,
1108    /// The history of this annotation.
1109    pub provenance: Option<GoogleCloudDocumentaiV1DocumentProvenance>,
1110}
1111
1112impl common::Part for GoogleCloudDocumentaiV1DocumentPageParagraph {}
1113
1114/// A detected symbol.
1115///
1116/// This type is not used in any activity, and only used as *part* of another schema.
1117///
1118#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1119#[serde_with::serde_as]
1120#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1121pub struct GoogleCloudDocumentaiV1DocumentPageSymbol {
1122    /// A list of detected languages together with confidence.
1123    #[serde(rename = "detectedLanguages")]
1124    pub detected_languages: Option<Vec<GoogleCloudDocumentaiV1DocumentPageDetectedLanguage>>,
1125    /// Layout for Symbol.
1126    pub layout: Option<GoogleCloudDocumentaiV1DocumentPageLayout>,
1127}
1128
1129impl common::Part for GoogleCloudDocumentaiV1DocumentPageSymbol {}
1130
1131/// A table representation similar to HTML table structure.
1132///
1133/// This type is not used in any activity, and only used as *part* of another schema.
1134///
1135#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1136#[serde_with::serde_as]
1137#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1138pub struct GoogleCloudDocumentaiV1DocumentPageTable {
1139    /// Body rows of the table.
1140    #[serde(rename = "bodyRows")]
1141    pub body_rows: Option<Vec<GoogleCloudDocumentaiV1DocumentPageTableTableRow>>,
1142    /// A list of detected languages together with confidence.
1143    #[serde(rename = "detectedLanguages")]
1144    pub detected_languages: Option<Vec<GoogleCloudDocumentaiV1DocumentPageDetectedLanguage>>,
1145    /// Header rows of the table.
1146    #[serde(rename = "headerRows")]
1147    pub header_rows: Option<Vec<GoogleCloudDocumentaiV1DocumentPageTableTableRow>>,
1148    /// Layout for Table.
1149    pub layout: Option<GoogleCloudDocumentaiV1DocumentPageLayout>,
1150    /// The history of this table.
1151    pub provenance: Option<GoogleCloudDocumentaiV1DocumentProvenance>,
1152}
1153
1154impl common::Part for GoogleCloudDocumentaiV1DocumentPageTable {}
1155
1156/// A cell representation inside the table.
1157///
1158/// This type is not used in any activity, and only used as *part* of another schema.
1159///
1160#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1161#[serde_with::serde_as]
1162#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1163pub struct GoogleCloudDocumentaiV1DocumentPageTableTableCell {
1164    /// How many columns this cell spans.
1165    #[serde(rename = "colSpan")]
1166    pub col_span: Option<i32>,
1167    /// A list of detected languages together with confidence.
1168    #[serde(rename = "detectedLanguages")]
1169    pub detected_languages: Option<Vec<GoogleCloudDocumentaiV1DocumentPageDetectedLanguage>>,
1170    /// Layout for TableCell.
1171    pub layout: Option<GoogleCloudDocumentaiV1DocumentPageLayout>,
1172    /// How many rows this cell spans.
1173    #[serde(rename = "rowSpan")]
1174    pub row_span: Option<i32>,
1175}
1176
1177impl common::Part for GoogleCloudDocumentaiV1DocumentPageTableTableCell {}
1178
1179/// A row of table cells.
1180///
1181/// This type is not used in any activity, and only used as *part* of another schema.
1182///
1183#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1184#[serde_with::serde_as]
1185#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1186pub struct GoogleCloudDocumentaiV1DocumentPageTableTableRow {
1187    /// Cells that make up this row.
1188    pub cells: Option<Vec<GoogleCloudDocumentaiV1DocumentPageTableTableCell>>,
1189}
1190
1191impl common::Part for GoogleCloudDocumentaiV1DocumentPageTableTableRow {}
1192
1193/// A detected token.
1194///
1195/// This type is not used in any activity, and only used as *part* of another schema.
1196///
1197#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1198#[serde_with::serde_as]
1199#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1200pub struct GoogleCloudDocumentaiV1DocumentPageToken {
1201    /// Detected break at the end of a Token.
1202    #[serde(rename = "detectedBreak")]
1203    pub detected_break: Option<GoogleCloudDocumentaiV1DocumentPageTokenDetectedBreak>,
1204    /// A list of detected languages together with confidence.
1205    #[serde(rename = "detectedLanguages")]
1206    pub detected_languages: Option<Vec<GoogleCloudDocumentaiV1DocumentPageDetectedLanguage>>,
1207    /// Layout for Token.
1208    pub layout: Option<GoogleCloudDocumentaiV1DocumentPageLayout>,
1209    /// The history of this annotation.
1210    pub provenance: Option<GoogleCloudDocumentaiV1DocumentProvenance>,
1211    /// Text style attributes.
1212    #[serde(rename = "styleInfo")]
1213    pub style_info: Option<GoogleCloudDocumentaiV1DocumentPageTokenStyleInfo>,
1214}
1215
1216impl common::Part for GoogleCloudDocumentaiV1DocumentPageToken {}
1217
1218/// Detected break at the end of a Token.
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 GoogleCloudDocumentaiV1DocumentPageTokenDetectedBreak {
1226    /// Detected break type.
1227    #[serde(rename = "type")]
1228    pub type_: Option<String>,
1229}
1230
1231impl common::Part for GoogleCloudDocumentaiV1DocumentPageTokenDetectedBreak {}
1232
1233/// Font and other text style attributes.
1234///
1235/// This type is not used in any activity, and only used as *part* of another schema.
1236///
1237#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1238#[serde_with::serde_as]
1239#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1240pub struct GoogleCloudDocumentaiV1DocumentPageTokenStyleInfo {
1241    /// Color of the background.
1242    #[serde(rename = "backgroundColor")]
1243    pub background_color: Option<GoogleTypeColor>,
1244    /// Whether the text is bold (equivalent to font_weight is at least `700`).
1245    pub bold: Option<bool>,
1246    /// Font size in points (`1` point is `¹⁄₇₂` inches).
1247    #[serde(rename = "fontSize")]
1248    pub font_size: Option<i32>,
1249    /// Name or style of the font.
1250    #[serde(rename = "fontType")]
1251    pub font_type: Option<String>,
1252    /// TrueType weight on a scale `100` (thin) to `1000` (ultra-heavy). Normal is `400`, bold is `700`.
1253    #[serde(rename = "fontWeight")]
1254    pub font_weight: Option<i32>,
1255    /// Whether the text is handwritten.
1256    pub handwritten: Option<bool>,
1257    /// Whether the text is italic.
1258    pub italic: Option<bool>,
1259    /// Letter spacing in points.
1260    #[serde(rename = "letterSpacing")]
1261    pub letter_spacing: Option<f64>,
1262    /// Font size in pixels, equal to _unrounded font_size_ * _resolution_ ÷ `72.0`.
1263    #[serde(rename = "pixelFontSize")]
1264    pub pixel_font_size: Option<f64>,
1265    /// Whether the text is in small caps. This feature is not supported yet.
1266    pub smallcaps: Option<bool>,
1267    /// Whether the text is strikethrough. This feature is not supported yet.
1268    pub strikeout: Option<bool>,
1269    /// Whether the text is a subscript. This feature is not supported yet.
1270    pub subscript: Option<bool>,
1271    /// Whether the text is a superscript. This feature is not supported yet.
1272    pub superscript: Option<bool>,
1273    /// Color of the text.
1274    #[serde(rename = "textColor")]
1275    pub text_color: Option<GoogleTypeColor>,
1276    /// Whether the text is underlined.
1277    pub underlined: Option<bool>,
1278}
1279
1280impl common::Part for GoogleCloudDocumentaiV1DocumentPageTokenStyleInfo {}
1281
1282/// Detected non-text visual elements e.g. checkbox, signature etc. on the page.
1283///
1284/// This type is not used in any activity, and only used as *part* of another schema.
1285///
1286#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1287#[serde_with::serde_as]
1288#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1289pub struct GoogleCloudDocumentaiV1DocumentPageVisualElement {
1290    /// A list of detected languages together with confidence.
1291    #[serde(rename = "detectedLanguages")]
1292    pub detected_languages: Option<Vec<GoogleCloudDocumentaiV1DocumentPageDetectedLanguage>>,
1293    /// Layout for VisualElement.
1294    pub layout: Option<GoogleCloudDocumentaiV1DocumentPageLayout>,
1295    /// Type of the VisualElement.
1296    #[serde(rename = "type")]
1297    pub type_: Option<String>,
1298}
1299
1300impl common::Part for GoogleCloudDocumentaiV1DocumentPageVisualElement {}
1301
1302/// Structure to identify provenance relationships between annotations in different revisions.
1303///
1304/// This type is not used in any activity, and only used as *part* of another schema.
1305///
1306#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1307#[serde_with::serde_as]
1308#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1309pub struct GoogleCloudDocumentaiV1DocumentProvenance {
1310    /// The Id of this operation. Needs to be unique within the scope of the revision.
1311    pub id: Option<i32>,
1312    /// References to the original elements that are replaced.
1313    pub parents: Option<Vec<GoogleCloudDocumentaiV1DocumentProvenanceParent>>,
1314    /// The index of the revision that produced this element.
1315    pub revision: Option<i32>,
1316    /// The type of provenance operation.
1317    #[serde(rename = "type")]
1318    pub type_: Option<String>,
1319}
1320
1321impl common::Part for GoogleCloudDocumentaiV1DocumentProvenance {}
1322
1323/// The parent element the current element is based on. Used for referencing/aligning, removal and replacement operations.
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 GoogleCloudDocumentaiV1DocumentProvenanceParent {
1331    /// The id of the parent provenance.
1332    pub id: Option<i32>,
1333    /// The index of the parent item in the corresponding item list (eg. list of entities, properties within entities, etc.) in the parent revision.
1334    pub index: Option<i32>,
1335    /// The index of the index into current revision's parent_ids list.
1336    pub revision: Option<i32>,
1337}
1338
1339impl common::Part for GoogleCloudDocumentaiV1DocumentProvenanceParent {}
1340
1341/// Contains past or forward revisions of this document.
1342///
1343/// This type is not used in any activity, and only used as *part* of another schema.
1344///
1345#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1346#[serde_with::serde_as]
1347#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1348pub struct GoogleCloudDocumentaiV1DocumentRevision {
1349    /// If the change was made by a person specify the name or id of that person.
1350    pub agent: Option<String>,
1351    /// The time that the revision was created, internally generated by doc proto storage at the time of create.
1352    #[serde(rename = "createTime")]
1353    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1354    /// Human Review information of this revision.
1355    #[serde(rename = "humanReview")]
1356    pub human_review: Option<GoogleCloudDocumentaiV1DocumentRevisionHumanReview>,
1357    /// Id of the revision, internally generated by doc proto storage. Unique within the context of the document.
1358    pub id: Option<String>,
1359    /// 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.
1360    pub parent: Option<Vec<i32>>,
1361    /// 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.
1362    #[serde(rename = "parentIds")]
1363    pub parent_ids: Option<Vec<String>>,
1364    /// If the annotation was made by processor identify the processor by its resource name.
1365    pub processor: Option<String>,
1366}
1367
1368impl common::Part for GoogleCloudDocumentaiV1DocumentRevision {}
1369
1370/// Human Review information of the document.
1371///
1372/// This type is not used in any activity, and only used as *part* of another schema.
1373///
1374#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1375#[serde_with::serde_as]
1376#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1377pub struct GoogleCloudDocumentaiV1DocumentRevisionHumanReview {
1378    /// Human review state. e.g. `requested`, `succeeded`, `rejected`.
1379    pub state: Option<String>,
1380    /// A message providing more details about the current state of processing. For example, the rejection reason when the state is `rejected`.
1381    #[serde(rename = "stateMessage")]
1382    pub state_message: Option<String>,
1383}
1384
1385impl common::Part for GoogleCloudDocumentaiV1DocumentRevisionHumanReview {}
1386
1387/// The schema defines the output of the processed document by a processor.
1388///
1389/// This type is not used in any activity, and only used as *part* of another schema.
1390///
1391#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1392#[serde_with::serde_as]
1393#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1394pub struct GoogleCloudDocumentaiV1DocumentSchema {
1395    /// Description of the schema.
1396    pub description: Option<String>,
1397    /// Display name to show to users.
1398    #[serde(rename = "displayName")]
1399    pub display_name: Option<String>,
1400    /// Entity types of the schema.
1401    #[serde(rename = "entityTypes")]
1402    pub entity_types: Option<Vec<GoogleCloudDocumentaiV1DocumentSchemaEntityType>>,
1403    /// Metadata of the schema.
1404    pub metadata: Option<GoogleCloudDocumentaiV1DocumentSchemaMetadata>,
1405}
1406
1407impl common::Part for GoogleCloudDocumentaiV1DocumentSchema {}
1408
1409/// EntityType is the wrapper of a label of the corresponding model with detailed attributes and limitations for entity-based processors. Multiple types can also compose a dependency tree to represent nested types.
1410///
1411/// This type is not used in any activity, and only used as *part* of another schema.
1412///
1413#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1414#[serde_with::serde_as]
1415#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1416pub struct GoogleCloudDocumentaiV1DocumentSchemaEntityType {
1417    /// The entity type that this type is derived from. For now, one and only one should be set.
1418    #[serde(rename = "baseTypes")]
1419    pub base_types: Option<Vec<String>>,
1420    /// User defined name for the type.
1421    #[serde(rename = "displayName")]
1422    pub display_name: Option<String>,
1423    /// If specified, lists all the possible values for this entity. This should not be more than a handful of values. If the number of values is >10 or could change frequently use the `EntityType.value_ontology` field and specify a list of all possible values in a value ontology file.
1424    #[serde(rename = "enumValues")]
1425    pub enum_values: Option<GoogleCloudDocumentaiV1DocumentSchemaEntityTypeEnumValues>,
1426    /// Name of the type. It must be unique within the schema file and cannot be a "Common Type". The following naming conventions are used: - Use `snake_casing`. - Name matching is case-sensitive. - Maximum 64 characters. - Must start with a letter. - Allowed characters: ASCII letters `[a-z0-9_-]`. (For backward compatibility internal infrastructure and tooling can handle any ascii character.) - The `/` is sometimes used to denote a property of a type. For example `line_item/amount`. This convention is deprecated, but will still be honored for backward compatibility.
1427    pub name: Option<String>,
1428    /// Description the nested structure, or composition of an entity.
1429    pub properties: Option<Vec<GoogleCloudDocumentaiV1DocumentSchemaEntityTypeProperty>>,
1430}
1431
1432impl common::Part for GoogleCloudDocumentaiV1DocumentSchemaEntityType {}
1433
1434/// Defines the a list of enum values.
1435///
1436/// This type is not used in any activity, and only used as *part* of another schema.
1437///
1438#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1439#[serde_with::serde_as]
1440#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1441pub struct GoogleCloudDocumentaiV1DocumentSchemaEntityTypeEnumValues {
1442    /// The individual values that this enum values type can include.
1443    pub values: Option<Vec<String>>,
1444}
1445
1446impl common::Part for GoogleCloudDocumentaiV1DocumentSchemaEntityTypeEnumValues {}
1447
1448/// Defines properties that can be part of the entity type.
1449///
1450/// This type is not used in any activity, and only used as *part* of another schema.
1451///
1452#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1453#[serde_with::serde_as]
1454#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1455pub struct GoogleCloudDocumentaiV1DocumentSchemaEntityTypeProperty {
1456    /// User defined name for the property.
1457    #[serde(rename = "displayName")]
1458    pub display_name: Option<String>,
1459    /// The name of the property. Follows the same guidelines as the EntityType name.
1460    pub name: Option<String>,
1461    /// Occurrence type limits the number of instances an entity type appears in the document.
1462    #[serde(rename = "occurrenceType")]
1463    pub occurrence_type: Option<String>,
1464    /// A reference to the value type of the property. This type is subject to the same conventions as the `Entity.base_types` field.
1465    #[serde(rename = "valueType")]
1466    pub value_type: Option<String>,
1467}
1468
1469impl common::Part for GoogleCloudDocumentaiV1DocumentSchemaEntityTypeProperty {}
1470
1471/// Metadata for global schema behavior.
1472///
1473/// This type is not used in any activity, and only used as *part* of another schema.
1474///
1475#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1476#[serde_with::serde_as]
1477#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1478pub struct GoogleCloudDocumentaiV1DocumentSchemaMetadata {
1479    /// If true, on a given page, there can be multiple `document` annotations covering it.
1480    #[serde(rename = "documentAllowMultipleLabels")]
1481    pub document_allow_multiple_labels: Option<bool>,
1482    /// If true, a `document` entity type can be applied to subdocument (splitting). Otherwise, it can only be applied to the entire document (classification).
1483    #[serde(rename = "documentSplitter")]
1484    pub document_splitter: Option<bool>,
1485    /// If set, all the nested entities must be prefixed with the parents.
1486    #[serde(rename = "prefixedNamingOnProperties")]
1487    pub prefixed_naming_on_properties: Option<bool>,
1488    /// If set, we will skip the naming format validation in the schema. So the string values in `DocumentSchema.EntityType.name` and `DocumentSchema.EntityType.Property.name` will not be checked.
1489    #[serde(rename = "skipNamingValidation")]
1490    pub skip_naming_validation: Option<bool>,
1491}
1492
1493impl common::Part for GoogleCloudDocumentaiV1DocumentSchemaMetadata {}
1494
1495/// 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.
1496///
1497/// This type is not used in any activity, and only used as *part* of another schema.
1498///
1499#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1500#[serde_with::serde_as]
1501#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1502pub struct GoogleCloudDocumentaiV1DocumentShardInfo {
1503    /// Total number of shards.
1504    #[serde(rename = "shardCount")]
1505    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1506    pub shard_count: Option<i64>,
1507    /// The 0-based index of this shard.
1508    #[serde(rename = "shardIndex")]
1509    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1510    pub shard_index: Option<i64>,
1511    /// The index of the first character in Document.text in the overall document global text.
1512    #[serde(rename = "textOffset")]
1513    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1514    pub text_offset: Option<i64>,
1515}
1516
1517impl common::Part for GoogleCloudDocumentaiV1DocumentShardInfo {}
1518
1519/// Annotation for common text style attributes. This adheres to CSS conventions as much as possible.
1520///
1521/// This type is not used in any activity, and only used as *part* of another schema.
1522///
1523#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1524#[serde_with::serde_as]
1525#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1526pub struct GoogleCloudDocumentaiV1DocumentStyle {
1527    /// Text background color.
1528    #[serde(rename = "backgroundColor")]
1529    pub background_color: Option<GoogleTypeColor>,
1530    /// Text color.
1531    pub color: Option<GoogleTypeColor>,
1532    /// Font family such as `Arial`, `Times New Roman`. https://www.w3schools.com/cssref/pr_font_font-family.asp
1533    #[serde(rename = "fontFamily")]
1534    pub font_family: Option<String>,
1535    /// Font size.
1536    #[serde(rename = "fontSize")]
1537    pub font_size: Option<GoogleCloudDocumentaiV1DocumentStyleFontSize>,
1538    /// [Font weight](https://www.w3schools.com/cssref/pr_font_weight.asp). Possible values are `normal`, `bold`, `bolder`, and `lighter`.
1539    #[serde(rename = "fontWeight")]
1540    pub font_weight: Option<String>,
1541    /// Text anchor indexing into the Document.text.
1542    #[serde(rename = "textAnchor")]
1543    pub text_anchor: Option<GoogleCloudDocumentaiV1DocumentTextAnchor>,
1544    /// [Text decoration](https://www.w3schools.com/cssref/pr_text_text-decoration.asp). Follows CSS standard.
1545    #[serde(rename = "textDecoration")]
1546    pub text_decoration: Option<String>,
1547    /// [Text style](https://www.w3schools.com/cssref/pr_font_font-style.asp). Possible values are `normal`, `italic`, and `oblique`.
1548    #[serde(rename = "textStyle")]
1549    pub text_style: Option<String>,
1550}
1551
1552impl common::Part for GoogleCloudDocumentaiV1DocumentStyle {}
1553
1554/// Font size with unit.
1555///
1556/// This type is not used in any activity, and only used as *part* of another schema.
1557///
1558#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1559#[serde_with::serde_as]
1560#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1561pub struct GoogleCloudDocumentaiV1DocumentStyleFontSize {
1562    /// Font size for the text.
1563    pub size: Option<f32>,
1564    /// Unit for the font size. Follows CSS naming (such as `in`, `px`, and `pt`).
1565    pub unit: Option<String>,
1566}
1567
1568impl common::Part for GoogleCloudDocumentaiV1DocumentStyleFontSize {}
1569
1570/// Text reference indexing into the Document.text.
1571///
1572/// This type is not used in any activity, and only used as *part* of another schema.
1573///
1574#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1575#[serde_with::serde_as]
1576#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1577pub struct GoogleCloudDocumentaiV1DocumentTextAnchor {
1578    /// 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.
1579    pub content: Option<String>,
1580    /// The text segments from the Document.text.
1581    #[serde(rename = "textSegments")]
1582    pub text_segments: Option<Vec<GoogleCloudDocumentaiV1DocumentTextAnchorTextSegment>>,
1583}
1584
1585impl common::Part for GoogleCloudDocumentaiV1DocumentTextAnchor {}
1586
1587/// 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
1588///
1589/// This type is not used in any activity, and only used as *part* of another schema.
1590///
1591#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1592#[serde_with::serde_as]
1593#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1594pub struct GoogleCloudDocumentaiV1DocumentTextAnchorTextSegment {
1595    /// TextSegment half open end UTF-8 char index in the Document.text.
1596    #[serde(rename = "endIndex")]
1597    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1598    pub end_index: Option<i64>,
1599    /// TextSegment start UTF-8 char index in the Document.text.
1600    #[serde(rename = "startIndex")]
1601    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1602    pub start_index: Option<i64>,
1603}
1604
1605impl common::Part for GoogleCloudDocumentaiV1DocumentTextAnchorTextSegment {}
1606
1607/// This message is used for text changes aka. OCR corrections.
1608///
1609/// This type is not used in any activity, and only used as *part* of another schema.
1610///
1611#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1612#[serde_with::serde_as]
1613#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1614pub struct GoogleCloudDocumentaiV1DocumentTextChange {
1615    /// The text that replaces the text identified in the `text_anchor`.
1616    #[serde(rename = "changedText")]
1617    pub changed_text: Option<String>,
1618    /// The history of this annotation.
1619    pub provenance: Option<Vec<GoogleCloudDocumentaiV1DocumentProvenance>>,
1620    /// 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.
1621    #[serde(rename = "textAnchor")]
1622    pub text_anchor: Option<GoogleCloudDocumentaiV1DocumentTextAnchor>,
1623}
1624
1625impl common::Part for GoogleCloudDocumentaiV1DocumentTextChange {}
1626
1627/// Request message for the EnableProcessor method.
1628///
1629/// # Activities
1630///
1631/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1632/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1633///
1634/// * [locations processors enable projects](ProjectLocationProcessorEnableCall) (request)
1635#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1636#[serde_with::serde_as]
1637#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1638pub struct GoogleCloudDocumentaiV1EnableProcessorRequest {
1639    _never_set: Option<bool>,
1640}
1641
1642impl common::RequestValue for GoogleCloudDocumentaiV1EnableProcessorRequest {}
1643
1644/// Evaluates the given ProcessorVersion against the supplied documents.
1645///
1646/// # Activities
1647///
1648/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1649/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1650///
1651/// * [locations processors processor versions evaluate processor version projects](ProjectLocationProcessorProcessorVersionEvaluateProcessorVersionCall) (request)
1652#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1653#[serde_with::serde_as]
1654#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1655pub struct GoogleCloudDocumentaiV1EvaluateProcessorVersionRequest {
1656    /// Optional. The documents used in the evaluation. If unspecified, use the processor's dataset as evaluation input.
1657    #[serde(rename = "evaluationDocuments")]
1658    pub evaluation_documents: Option<GoogleCloudDocumentaiV1BatchDocumentsInputConfig>,
1659}
1660
1661impl common::RequestValue for GoogleCloudDocumentaiV1EvaluateProcessorVersionRequest {}
1662
1663/// An evaluation of a ProcessorVersion’s performance.
1664///
1665/// # Activities
1666///
1667/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1668/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1669///
1670/// * [locations processors processor versions evaluations get projects](ProjectLocationProcessorProcessorVersionEvaluationGetCall) (response)
1671#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1672#[serde_with::serde_as]
1673#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1674pub struct GoogleCloudDocumentaiV1Evaluation {
1675    /// Metrics for all the entities in aggregate.
1676    #[serde(rename = "allEntitiesMetrics")]
1677    pub all_entities_metrics: Option<GoogleCloudDocumentaiV1EvaluationMultiConfidenceMetrics>,
1678    /// The time that the evaluation was created.
1679    #[serde(rename = "createTime")]
1680    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1681    /// Counters for the documents used in the evaluation.
1682    #[serde(rename = "documentCounters")]
1683    pub document_counters: Option<GoogleCloudDocumentaiV1EvaluationCounters>,
1684    /// Metrics across confidence levels, for different entities.
1685    #[serde(rename = "entityMetrics")]
1686    pub entity_metrics:
1687        Option<HashMap<String, GoogleCloudDocumentaiV1EvaluationMultiConfidenceMetrics>>,
1688    /// The KMS key name used for encryption.
1689    #[serde(rename = "kmsKeyName")]
1690    pub kms_key_name: Option<String>,
1691    /// The KMS key version with which data is encrypted.
1692    #[serde(rename = "kmsKeyVersionName")]
1693    pub kms_key_version_name: Option<String>,
1694    /// The resource name of the evaluation. Format: `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processor_version}/evaluations/{evaluation}`
1695    pub name: Option<String>,
1696}
1697
1698impl common::ResponseResult for GoogleCloudDocumentaiV1Evaluation {}
1699
1700/// Evaluations metrics, at a specific confidence level.
1701///
1702/// This type is not used in any activity, and only used as *part* of another schema.
1703///
1704#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1705#[serde_with::serde_as]
1706#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1707pub struct GoogleCloudDocumentaiV1EvaluationConfidenceLevelMetrics {
1708    /// The confidence level.
1709    #[serde(rename = "confidenceLevel")]
1710    pub confidence_level: Option<f32>,
1711    /// The metrics at the specific confidence level.
1712    pub metrics: Option<GoogleCloudDocumentaiV1EvaluationMetrics>,
1713}
1714
1715impl common::Part for GoogleCloudDocumentaiV1EvaluationConfidenceLevelMetrics {}
1716
1717/// Evaluation counters for the documents that were used.
1718///
1719/// This type is not used in any activity, and only used as *part* of another schema.
1720///
1721#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1722#[serde_with::serde_as]
1723#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1724pub struct GoogleCloudDocumentaiV1EvaluationCounters {
1725    /// How many documents were used in the evaluation.
1726    #[serde(rename = "evaluatedDocumentsCount")]
1727    pub evaluated_documents_count: Option<i32>,
1728    /// How many documents were not included in the evaluation as Document AI failed to process them.
1729    #[serde(rename = "failedDocumentsCount")]
1730    pub failed_documents_count: Option<i32>,
1731    /// How many documents were sent for evaluation.
1732    #[serde(rename = "inputDocumentsCount")]
1733    pub input_documents_count: Option<i32>,
1734    /// How many documents were not included in the evaluation as they didn't pass validation.
1735    #[serde(rename = "invalidDocumentsCount")]
1736    pub invalid_documents_count: Option<i32>,
1737}
1738
1739impl common::Part for GoogleCloudDocumentaiV1EvaluationCounters {}
1740
1741/// Evaluation metrics, either in aggregate or about a specific entity.
1742///
1743/// This type is not used in any activity, and only used as *part* of another schema.
1744///
1745#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1746#[serde_with::serde_as]
1747#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1748pub struct GoogleCloudDocumentaiV1EvaluationMetrics {
1749    /// The calculated f1 score.
1750    #[serde(rename = "f1Score")]
1751    pub f1_score: Option<f32>,
1752    /// The amount of false negatives.
1753    #[serde(rename = "falseNegativesCount")]
1754    pub false_negatives_count: Option<i32>,
1755    /// The amount of false positives.
1756    #[serde(rename = "falsePositivesCount")]
1757    pub false_positives_count: Option<i32>,
1758    /// The amount of documents with a ground truth occurrence.
1759    #[serde(rename = "groundTruthDocumentCount")]
1760    pub ground_truth_document_count: Option<i32>,
1761    /// The amount of occurrences in ground truth documents.
1762    #[serde(rename = "groundTruthOccurrencesCount")]
1763    pub ground_truth_occurrences_count: Option<i32>,
1764    /// The calculated precision.
1765    pub precision: Option<f32>,
1766    /// The amount of documents with a predicted occurrence.
1767    #[serde(rename = "predictedDocumentCount")]
1768    pub predicted_document_count: Option<i32>,
1769    /// The amount of occurrences in predicted documents.
1770    #[serde(rename = "predictedOccurrencesCount")]
1771    pub predicted_occurrences_count: Option<i32>,
1772    /// The calculated recall.
1773    pub recall: Option<f32>,
1774    /// The amount of documents that had an occurrence of this label.
1775    #[serde(rename = "totalDocumentsCount")]
1776    pub total_documents_count: Option<i32>,
1777    /// The amount of true positives.
1778    #[serde(rename = "truePositivesCount")]
1779    pub true_positives_count: Option<i32>,
1780}
1781
1782impl common::Part for GoogleCloudDocumentaiV1EvaluationMetrics {}
1783
1784/// Metrics across multiple confidence levels.
1785///
1786/// This type is not used in any activity, and only used as *part* of another schema.
1787///
1788#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1789#[serde_with::serde_as]
1790#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1791pub struct GoogleCloudDocumentaiV1EvaluationMultiConfidenceMetrics {
1792    /// The calculated area under the precision recall curve (AUPRC), computed by integrating over all confidence thresholds.
1793    pub auprc: Option<f32>,
1794    /// The AUPRC for metrics with fuzzy matching disabled, i.e., exact matching only.
1795    #[serde(rename = "auprcExact")]
1796    pub auprc_exact: Option<f32>,
1797    /// Metrics across confidence levels with fuzzy matching enabled.
1798    #[serde(rename = "confidenceLevelMetrics")]
1799    pub confidence_level_metrics:
1800        Option<Vec<GoogleCloudDocumentaiV1EvaluationConfidenceLevelMetrics>>,
1801    /// Metrics across confidence levels with only exact matching.
1802    #[serde(rename = "confidenceLevelMetricsExact")]
1803    pub confidence_level_metrics_exact:
1804        Option<Vec<GoogleCloudDocumentaiV1EvaluationConfidenceLevelMetrics>>,
1805    /// The Estimated Calibration Error (ECE) of the confidence of the predicted entities.
1806    #[serde(rename = "estimatedCalibrationError")]
1807    pub estimated_calibration_error: Option<f32>,
1808    /// The ECE for the predicted entities with fuzzy matching disabled, i.e., exact matching only.
1809    #[serde(rename = "estimatedCalibrationErrorExact")]
1810    pub estimated_calibration_error_exact: Option<f32>,
1811    /// The metrics type for the label.
1812    #[serde(rename = "metricsType")]
1813    pub metrics_type: Option<String>,
1814}
1815
1816impl common::Part for GoogleCloudDocumentaiV1EvaluationMultiConfidenceMetrics {}
1817
1818/// Gives a short summary of an evaluation, and links to the evaluation itself.
1819///
1820/// This type is not used in any activity, and only used as *part* of another schema.
1821///
1822#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1823#[serde_with::serde_as]
1824#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1825pub struct GoogleCloudDocumentaiV1EvaluationReference {
1826    /// An aggregate of the statistics for the evaluation with fuzzy matching on.
1827    #[serde(rename = "aggregateMetrics")]
1828    pub aggregate_metrics: Option<GoogleCloudDocumentaiV1EvaluationMetrics>,
1829    /// An aggregate of the statistics for the evaluation with fuzzy matching off.
1830    #[serde(rename = "aggregateMetricsExact")]
1831    pub aggregate_metrics_exact: Option<GoogleCloudDocumentaiV1EvaluationMetrics>,
1832    /// The resource name of the evaluation.
1833    pub evaluation: Option<String>,
1834    /// The resource name of the Long Running Operation for the evaluation.
1835    pub operation: Option<String>,
1836}
1837
1838impl common::Part for GoogleCloudDocumentaiV1EvaluationReference {}
1839
1840/// Response message for the FetchProcessorTypes method.
1841///
1842/// # Activities
1843///
1844/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1845/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1846///
1847/// * [locations fetch processor types projects](ProjectLocationFetchProcessorTypeCall) (response)
1848#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1849#[serde_with::serde_as]
1850#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1851pub struct GoogleCloudDocumentaiV1FetchProcessorTypesResponse {
1852    /// The list of processor types.
1853    #[serde(rename = "processorTypes")]
1854    pub processor_types: Option<Vec<GoogleCloudDocumentaiV1ProcessorType>>,
1855}
1856
1857impl common::ResponseResult for GoogleCloudDocumentaiV1FetchProcessorTypesResponse {}
1858
1859/// Specifies a document stored on Cloud Storage.
1860///
1861/// This type is not used in any activity, and only used as *part* of another schema.
1862///
1863#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1864#[serde_with::serde_as]
1865#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1866pub struct GoogleCloudDocumentaiV1GcsDocument {
1867    /// The Cloud Storage object uri.
1868    #[serde(rename = "gcsUri")]
1869    pub gcs_uri: Option<String>,
1870    /// An IANA MIME type (RFC6838) of the content.
1871    #[serde(rename = "mimeType")]
1872    pub mime_type: Option<String>,
1873}
1874
1875impl common::Part for GoogleCloudDocumentaiV1GcsDocument {}
1876
1877/// Specifies a set of documents on Cloud Storage.
1878///
1879/// This type is not used in any activity, and only used as *part* of another schema.
1880///
1881#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1882#[serde_with::serde_as]
1883#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1884pub struct GoogleCloudDocumentaiV1GcsDocuments {
1885    /// The list of documents.
1886    pub documents: Option<Vec<GoogleCloudDocumentaiV1GcsDocument>>,
1887}
1888
1889impl common::Part for GoogleCloudDocumentaiV1GcsDocuments {}
1890
1891/// Specifies all documents on Cloud Storage with a common prefix.
1892///
1893/// This type is not used in any activity, and only used as *part* of another schema.
1894///
1895#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1896#[serde_with::serde_as]
1897#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1898pub struct GoogleCloudDocumentaiV1GcsPrefix {
1899    /// The URI prefix.
1900    #[serde(rename = "gcsUriPrefix")]
1901    pub gcs_uri_prefix: Option<String>,
1902}
1903
1904impl common::Part for GoogleCloudDocumentaiV1GcsPrefix {}
1905
1906/// The status of human review on a processed document.
1907///
1908/// This type is not used in any activity, and only used as *part* of another schema.
1909///
1910#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1911#[serde_with::serde_as]
1912#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1913pub struct GoogleCloudDocumentaiV1HumanReviewStatus {
1914    /// The name of the operation triggered by the processed document. This field is populated only when the state is `HUMAN_REVIEW_IN_PROGRESS`. It has the same response type and metadata as the long-running operation returned by ReviewDocument.
1915    #[serde(rename = "humanReviewOperation")]
1916    pub human_review_operation: Option<String>,
1917    /// The state of human review on the processing request.
1918    pub state: Option<String>,
1919    /// A message providing more details about the human review state.
1920    #[serde(rename = "stateMessage")]
1921    pub state_message: Option<String>,
1922}
1923
1924impl common::Part for GoogleCloudDocumentaiV1HumanReviewStatus {}
1925
1926/// The response from `ListEvaluations`.
1927///
1928/// # Activities
1929///
1930/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1931/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1932///
1933/// * [locations processors processor versions evaluations list projects](ProjectLocationProcessorProcessorVersionEvaluationListCall) (response)
1934#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1935#[serde_with::serde_as]
1936#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1937pub struct GoogleCloudDocumentaiV1ListEvaluationsResponse {
1938    /// The evaluations requested.
1939    pub evaluations: Option<Vec<GoogleCloudDocumentaiV1Evaluation>>,
1940    /// A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
1941    #[serde(rename = "nextPageToken")]
1942    pub next_page_token: Option<String>,
1943}
1944
1945impl common::ResponseResult for GoogleCloudDocumentaiV1ListEvaluationsResponse {}
1946
1947/// Response message for the ListProcessorTypes method.
1948///
1949/// # Activities
1950///
1951/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1952/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1953///
1954/// * [locations processor types list projects](ProjectLocationProcessorTypeListCall) (response)
1955#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1956#[serde_with::serde_as]
1957#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1958pub struct GoogleCloudDocumentaiV1ListProcessorTypesResponse {
1959    /// Points to the next page, otherwise empty.
1960    #[serde(rename = "nextPageToken")]
1961    pub next_page_token: Option<String>,
1962    /// The processor types.
1963    #[serde(rename = "processorTypes")]
1964    pub processor_types: Option<Vec<GoogleCloudDocumentaiV1ProcessorType>>,
1965}
1966
1967impl common::ResponseResult for GoogleCloudDocumentaiV1ListProcessorTypesResponse {}
1968
1969/// Response message for the ListProcessorVersions method.
1970///
1971/// # Activities
1972///
1973/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1974/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1975///
1976/// * [locations processors processor versions list projects](ProjectLocationProcessorProcessorVersionListCall) (response)
1977#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1978#[serde_with::serde_as]
1979#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1980pub struct GoogleCloudDocumentaiV1ListProcessorVersionsResponse {
1981    /// Points to the next processor, otherwise empty.
1982    #[serde(rename = "nextPageToken")]
1983    pub next_page_token: Option<String>,
1984    /// The list of processors.
1985    #[serde(rename = "processorVersions")]
1986    pub processor_versions: Option<Vec<GoogleCloudDocumentaiV1ProcessorVersion>>,
1987}
1988
1989impl common::ResponseResult for GoogleCloudDocumentaiV1ListProcessorVersionsResponse {}
1990
1991/// Response message for the ListProcessors method.
1992///
1993/// # Activities
1994///
1995/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1996/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1997///
1998/// * [locations processors list projects](ProjectLocationProcessorListCall) (response)
1999#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2000#[serde_with::serde_as]
2001#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2002pub struct GoogleCloudDocumentaiV1ListProcessorsResponse {
2003    /// Points to the next processor, otherwise empty.
2004    #[serde(rename = "nextPageToken")]
2005    pub next_page_token: Option<String>,
2006    /// The list of processors.
2007    pub processors: Option<Vec<GoogleCloudDocumentaiV1Processor>>,
2008}
2009
2010impl common::ResponseResult for GoogleCloudDocumentaiV1ListProcessorsResponse {}
2011
2012/// 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.
2013///
2014/// This type is not used in any activity, and only used as *part* of another schema.
2015///
2016#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2017#[serde_with::serde_as]
2018#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2019pub struct GoogleCloudDocumentaiV1NormalizedVertex {
2020    /// X coordinate.
2021    pub x: Option<f32>,
2022    /// Y coordinate (starts from the top of the image).
2023    pub y: Option<f32>,
2024}
2025
2026impl common::Part for GoogleCloudDocumentaiV1NormalizedVertex {}
2027
2028/// Config for Document OCR.
2029///
2030/// This type is not used in any activity, and only used as *part* of another schema.
2031///
2032#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2033#[serde_with::serde_as]
2034#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2035pub struct GoogleCloudDocumentaiV1OcrConfig {
2036    /// A list of advanced OCR options to further fine-tune OCR behavior. Current valid values are: - `legacy_layout`: a heuristics layout detection algorithm, which serves as an alternative to the current ML-based layout detection algorithm. Customers can choose the best suitable layout algorithm based on their situation.
2037    #[serde(rename = "advancedOcrOptions")]
2038    pub advanced_ocr_options: Option<Vec<String>>,
2039    /// Turn on font identification model and return font style information. Deprecated, use PremiumFeatures.compute_style_info instead.
2040    #[serde(rename = "computeStyleInfo")]
2041    pub compute_style_info: Option<bool>,
2042    /// Turn off character box detector in OCR engine. Character box detection is enabled by default in OCR 2.0 (and later) processors.
2043    #[serde(rename = "disableCharacterBoxesDetection")]
2044    pub disable_character_boxes_detection: Option<bool>,
2045    /// Enables intelligent document quality scores after OCR. Can help with diagnosing why OCR responses are of poor quality for a given input. Adds additional latency comparable to regular OCR to the process call.
2046    #[serde(rename = "enableImageQualityScores")]
2047    pub enable_image_quality_scores: Option<bool>,
2048    /// Enables special handling for PDFs with existing text information. Results in better text extraction quality in such PDF inputs.
2049    #[serde(rename = "enableNativePdfParsing")]
2050    pub enable_native_pdf_parsing: Option<bool>,
2051    /// Includes symbol level OCR information if set to true.
2052    #[serde(rename = "enableSymbol")]
2053    pub enable_symbol: Option<bool>,
2054    /// Hints for the OCR model.
2055    pub hints: Option<GoogleCloudDocumentaiV1OcrConfigHints>,
2056    /// Configurations for premium OCR features.
2057    #[serde(rename = "premiumFeatures")]
2058    pub premium_features: Option<GoogleCloudDocumentaiV1OcrConfigPremiumFeatures>,
2059}
2060
2061impl common::Part for GoogleCloudDocumentaiV1OcrConfig {}
2062
2063/// Hints for OCR Engine
2064///
2065/// This type is not used in any activity, and only used as *part* of another schema.
2066///
2067#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2068#[serde_with::serde_as]
2069#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2070pub struct GoogleCloudDocumentaiV1OcrConfigHints {
2071    /// List of BCP-47 language codes to use for OCR. In most cases, not specifying it yields the best results since it enables automatic language detection. For languages based on the Latin alphabet, setting 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).
2072    #[serde(rename = "languageHints")]
2073    pub language_hints: Option<Vec<String>>,
2074}
2075
2076impl common::Part for GoogleCloudDocumentaiV1OcrConfigHints {}
2077
2078/// Configurations for premium OCR features.
2079///
2080/// This type is not used in any activity, and only used as *part* of another schema.
2081///
2082#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2083#[serde_with::serde_as]
2084#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2085pub struct GoogleCloudDocumentaiV1OcrConfigPremiumFeatures {
2086    /// Turn on font identification model and return font style information.
2087    #[serde(rename = "computeStyleInfo")]
2088    pub compute_style_info: Option<bool>,
2089    /// Turn on the model that can extract LaTeX math formulas.
2090    #[serde(rename = "enableMathOcr")]
2091    pub enable_math_ocr: Option<bool>,
2092    /// Turn on selection mark detector in OCR engine. Only available in OCR 2.0 (and later) processors.
2093    #[serde(rename = "enableSelectionMarkDetection")]
2094    pub enable_selection_mark_detection: Option<bool>,
2095}
2096
2097impl common::Part for GoogleCloudDocumentaiV1OcrConfigPremiumFeatures {}
2098
2099/// Options for Process API
2100///
2101/// This type is not used in any activity, and only used as *part* of another schema.
2102///
2103#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2104#[serde_with::serde_as]
2105#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2106pub struct GoogleCloudDocumentaiV1ProcessOptions {
2107    /// Only process certain pages from the end, same as above.
2108    #[serde(rename = "fromEnd")]
2109    pub from_end: Option<i32>,
2110    /// Only process certain pages from the start. Process all if the document has fewer pages.
2111    #[serde(rename = "fromStart")]
2112    pub from_start: Option<i32>,
2113    /// Which pages to process (1-indexed).
2114    #[serde(rename = "individualPageSelector")]
2115    pub individual_page_selector:
2116        Option<GoogleCloudDocumentaiV1ProcessOptionsIndividualPageSelector>,
2117    /// Optional. Only applicable to `LAYOUT_PARSER_PROCESSOR`. Returns error if set on other processor types.
2118    #[serde(rename = "layoutConfig")]
2119    pub layout_config: Option<GoogleCloudDocumentaiV1ProcessOptionsLayoutConfig>,
2120    /// Only applicable to `OCR_PROCESSOR` and `FORM_PARSER_PROCESSOR`. Returns error if set on other processor types.
2121    #[serde(rename = "ocrConfig")]
2122    pub ocr_config: Option<GoogleCloudDocumentaiV1OcrConfig>,
2123    /// Optional. Override the schema of the ProcessorVersion. Will return an Invalid Argument error if this field is set when the underlying ProcessorVersion doesn't support schema override.
2124    #[serde(rename = "schemaOverride")]
2125    pub schema_override: Option<GoogleCloudDocumentaiV1DocumentSchema>,
2126}
2127
2128impl common::Part for GoogleCloudDocumentaiV1ProcessOptions {}
2129
2130/// A list of individual page numbers.
2131///
2132/// This type is not used in any activity, and only used as *part* of another schema.
2133///
2134#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2135#[serde_with::serde_as]
2136#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2137pub struct GoogleCloudDocumentaiV1ProcessOptionsIndividualPageSelector {
2138    /// Optional. Indices of the pages (starting from 1).
2139    pub pages: Option<Vec<i32>>,
2140}
2141
2142impl common::Part for GoogleCloudDocumentaiV1ProcessOptionsIndividualPageSelector {}
2143
2144/// Serving config for layout parser processor.
2145///
2146/// This type is not used in any activity, and only used as *part* of another schema.
2147///
2148#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2149#[serde_with::serde_as]
2150#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2151pub struct GoogleCloudDocumentaiV1ProcessOptionsLayoutConfig {
2152    /// Optional. Config for chunking in layout parser processor.
2153    #[serde(rename = "chunkingConfig")]
2154    pub chunking_config: Option<GoogleCloudDocumentaiV1ProcessOptionsLayoutConfigChunkingConfig>,
2155}
2156
2157impl common::Part for GoogleCloudDocumentaiV1ProcessOptionsLayoutConfig {}
2158
2159/// Serving config for chunking.
2160///
2161/// This type is not used in any activity, and only used as *part* of another schema.
2162///
2163#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2164#[serde_with::serde_as]
2165#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2166pub struct GoogleCloudDocumentaiV1ProcessOptionsLayoutConfigChunkingConfig {
2167    /// Optional. The chunk sizes to use when splitting documents, in order of level.
2168    #[serde(rename = "chunkSize")]
2169    pub chunk_size: Option<i32>,
2170    /// Optional. Whether or not to include ancestor headings when splitting.
2171    #[serde(rename = "includeAncestorHeadings")]
2172    pub include_ancestor_headings: Option<bool>,
2173}
2174
2175impl common::Part for GoogleCloudDocumentaiV1ProcessOptionsLayoutConfigChunkingConfig {}
2176
2177/// Request message for the ProcessDocument method.
2178///
2179/// # Activities
2180///
2181/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2182/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2183///
2184/// * [locations processors processor versions process projects](ProjectLocationProcessorProcessorVersionProcesCall) (request)
2185/// * [locations processors process projects](ProjectLocationProcessorProcesCall) (request)
2186#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2187#[serde_with::serde_as]
2188#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2189pub struct GoogleCloudDocumentaiV1ProcessRequest {
2190    /// Specifies which fields to include in the ProcessResponse.document output. Only supports top-level document and pages field, so it must be in the form of `{document_field_name}` or `pages.{page_field_name}`.
2191    #[serde(rename = "fieldMask")]
2192    pub field_mask: Option<common::FieldMask>,
2193    /// A raw document on Google Cloud Storage.
2194    #[serde(rename = "gcsDocument")]
2195    pub gcs_document: Option<GoogleCloudDocumentaiV1GcsDocument>,
2196    /// An inline document proto.
2197    #[serde(rename = "inlineDocument")]
2198    pub inline_document: Option<GoogleCloudDocumentaiV1Document>,
2199    /// Optional. The labels with user-defined metadata for the request. Label keys and values can be no longer than 63 characters (Unicode codepoints) and can only contain lowercase letters, numeric characters, underscores, and dashes. International characters are allowed. Label values are optional. Label keys must start with a letter.
2200    pub labels: Option<HashMap<String, String>>,
2201    /// Inference-time options for the process API
2202    #[serde(rename = "processOptions")]
2203    pub process_options: Option<GoogleCloudDocumentaiV1ProcessOptions>,
2204    /// A raw document content (bytes).
2205    #[serde(rename = "rawDocument")]
2206    pub raw_document: Option<GoogleCloudDocumentaiV1RawDocument>,
2207    /// Whether human review should be skipped for this request. Default to `false`.
2208    #[serde(rename = "skipHumanReview")]
2209    pub skip_human_review: Option<bool>,
2210}
2211
2212impl common::RequestValue for GoogleCloudDocumentaiV1ProcessRequest {}
2213
2214/// Response message for the ProcessDocument method.
2215///
2216/// # Activities
2217///
2218/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2219/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2220///
2221/// * [locations processors processor versions process projects](ProjectLocationProcessorProcessorVersionProcesCall) (response)
2222/// * [locations processors process projects](ProjectLocationProcessorProcesCall) (response)
2223#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2224#[serde_with::serde_as]
2225#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2226pub struct GoogleCloudDocumentaiV1ProcessResponse {
2227    /// The document payload, will populate fields based on the processor's behavior.
2228    pub document: Option<GoogleCloudDocumentaiV1Document>,
2229    /// The status of human review on the processed document.
2230    #[serde(rename = "humanReviewStatus")]
2231    pub human_review_status: Option<GoogleCloudDocumentaiV1HumanReviewStatus>,
2232}
2233
2234impl common::ResponseResult for GoogleCloudDocumentaiV1ProcessResponse {}
2235
2236/// The first-class citizen for Document AI. Each processor defines how to extract structural information from a document.
2237///
2238/// # Activities
2239///
2240/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2241/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2242///
2243/// * [locations processors create projects](ProjectLocationProcessorCreateCall) (request|response)
2244/// * [locations processors get projects](ProjectLocationProcessorGetCall) (response)
2245#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2246#[serde_with::serde_as]
2247#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2248pub struct GoogleCloudDocumentaiV1Processor {
2249    /// The time the processor was created.
2250    #[serde(rename = "createTime")]
2251    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2252    /// The default processor version.
2253    #[serde(rename = "defaultProcessorVersion")]
2254    pub default_processor_version: Option<String>,
2255    /// The display name of the processor.
2256    #[serde(rename = "displayName")]
2257    pub display_name: Option<String>,
2258    /// The [KMS key](https://cloud.google.com/security-key-management) used for encryption and decryption in CMEK scenarios.
2259    #[serde(rename = "kmsKeyName")]
2260    pub kms_key_name: Option<String>,
2261    /// Output only. Immutable. The resource name of the processor. Format: `projects/{project}/locations/{location}/processors/{processor}`
2262    pub name: Option<String>,
2263    /// Output only. Immutable. The http endpoint that can be called to invoke processing.
2264    #[serde(rename = "processEndpoint")]
2265    pub process_endpoint: Option<String>,
2266    /// Output only. The processor version aliases.
2267    #[serde(rename = "processorVersionAliases")]
2268    pub processor_version_aliases: Option<Vec<GoogleCloudDocumentaiV1ProcessorVersionAlias>>,
2269    /// Output only. Reserved for future use.
2270    #[serde(rename = "satisfiesPzi")]
2271    pub satisfies_pzi: Option<bool>,
2272    /// Output only. Reserved for future use.
2273    #[serde(rename = "satisfiesPzs")]
2274    pub satisfies_pzs: Option<bool>,
2275    /// Output only. The state of the processor.
2276    pub state: Option<String>,
2277    /// The processor type, such as: `OCR_PROCESSOR`, `INVOICE_PROCESSOR`. To get a list of processor types, see FetchProcessorTypes.
2278    #[serde(rename = "type")]
2279    pub type_: Option<String>,
2280}
2281
2282impl common::RequestValue for GoogleCloudDocumentaiV1Processor {}
2283impl common::ResponseResult for GoogleCloudDocumentaiV1Processor {}
2284
2285/// A processor type is responsible for performing a certain document understanding task on a certain type of document.
2286///
2287/// # Activities
2288///
2289/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2290/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2291///
2292/// * [locations processor types get projects](ProjectLocationProcessorTypeGetCall) (response)
2293#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2294#[serde_with::serde_as]
2295#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2296pub struct GoogleCloudDocumentaiV1ProcessorType {
2297    /// Whether the processor type allows creation. If true, users can create a processor of this processor type. Otherwise, users need to request access.
2298    #[serde(rename = "allowCreation")]
2299    pub allow_creation: Option<bool>,
2300    /// The locations in which this processor is available.
2301    #[serde(rename = "availableLocations")]
2302    pub available_locations: Option<Vec<GoogleCloudDocumentaiV1ProcessorTypeLocationInfo>>,
2303    /// The processor category, used by UI to group processor types.
2304    pub category: Option<String>,
2305    /// Launch stage of the processor type
2306    #[serde(rename = "launchStage")]
2307    pub launch_stage: Option<String>,
2308    /// The resource name of the processor type. Format: `projects/{project}/processorTypes/{processor_type}`
2309    pub name: Option<String>,
2310    /// A set of Cloud Storage URIs of sample documents for this processor.
2311    #[serde(rename = "sampleDocumentUris")]
2312    pub sample_document_uris: Option<Vec<String>>,
2313    /// The processor type, such as: `OCR_PROCESSOR`, `INVOICE_PROCESSOR`.
2314    #[serde(rename = "type")]
2315    pub type_: Option<String>,
2316}
2317
2318impl common::ResponseResult for GoogleCloudDocumentaiV1ProcessorType {}
2319
2320/// The location information about where the processor is available.
2321///
2322/// This type is not used in any activity, and only used as *part* of another schema.
2323///
2324#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2325#[serde_with::serde_as]
2326#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2327pub struct GoogleCloudDocumentaiV1ProcessorTypeLocationInfo {
2328    /// The location ID. For supported locations, refer to [regional and multi-regional support](https://cloud.google.com/document-ai/docs/regions).
2329    #[serde(rename = "locationId")]
2330    pub location_id: Option<String>,
2331}
2332
2333impl common::Part for GoogleCloudDocumentaiV1ProcessorTypeLocationInfo {}
2334
2335/// A processor version is an implementation of a processor. Each processor can have multiple versions, pretrained by Google internally or uptrained by the customer. A processor can only have one default version at a time. Its document-processing behavior is defined by that version.
2336///
2337/// # Activities
2338///
2339/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2340/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2341///
2342/// * [locations processors processor versions get projects](ProjectLocationProcessorProcessorVersionGetCall) (response)
2343#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2344#[serde_with::serde_as]
2345#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2346pub struct GoogleCloudDocumentaiV1ProcessorVersion {
2347    /// The time the processor version was created.
2348    #[serde(rename = "createTime")]
2349    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2350    /// If set, information about the eventual deprecation of this version.
2351    #[serde(rename = "deprecationInfo")]
2352    pub deprecation_info: Option<GoogleCloudDocumentaiV1ProcessorVersionDeprecationInfo>,
2353    /// The display name of the processor version.
2354    #[serde(rename = "displayName")]
2355    pub display_name: Option<String>,
2356    /// The schema of the processor version. Describes the output.
2357    #[serde(rename = "documentSchema")]
2358    pub document_schema: Option<GoogleCloudDocumentaiV1DocumentSchema>,
2359    /// Output only. Denotes that this `ProcessorVersion` is managed by Google.
2360    #[serde(rename = "googleManaged")]
2361    pub google_managed: Option<bool>,
2362    /// The KMS key name used for encryption.
2363    #[serde(rename = "kmsKeyName")]
2364    pub kms_key_name: Option<String>,
2365    /// The KMS key version with which data is encrypted.
2366    #[serde(rename = "kmsKeyVersionName")]
2367    pub kms_key_version_name: Option<String>,
2368    /// The most recently invoked evaluation for the processor version.
2369    #[serde(rename = "latestEvaluation")]
2370    pub latest_evaluation: Option<GoogleCloudDocumentaiV1EvaluationReference>,
2371    /// Output only. The model type of this processor version.
2372    #[serde(rename = "modelType")]
2373    pub model_type: Option<String>,
2374    /// Identifier. The resource name of the processor version. Format: `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processor_version}`
2375    pub name: Option<String>,
2376    /// Output only. Reserved for future use.
2377    #[serde(rename = "satisfiesPzi")]
2378    pub satisfies_pzi: Option<bool>,
2379    /// Output only. Reserved for future use.
2380    #[serde(rename = "satisfiesPzs")]
2381    pub satisfies_pzs: Option<bool>,
2382    /// Output only. The state of the processor version.
2383    pub state: Option<String>,
2384}
2385
2386impl common::ResponseResult for GoogleCloudDocumentaiV1ProcessorVersion {}
2387
2388/// Contains the alias and the aliased resource name of processor version.
2389///
2390/// This type is not used in any activity, and only used as *part* of another schema.
2391///
2392#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2393#[serde_with::serde_as]
2394#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2395pub struct GoogleCloudDocumentaiV1ProcessorVersionAlias {
2396    /// The alias in the form of `processor_version` resource name.
2397    pub alias: Option<String>,
2398    /// The resource name of aliased processor version.
2399    #[serde(rename = "processorVersion")]
2400    pub processor_version: Option<String>,
2401}
2402
2403impl common::Part for GoogleCloudDocumentaiV1ProcessorVersionAlias {}
2404
2405/// Information about the upcoming deprecation of this processor version.
2406///
2407/// This type is not used in any activity, and only used as *part* of another schema.
2408///
2409#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2410#[serde_with::serde_as]
2411#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2412pub struct GoogleCloudDocumentaiV1ProcessorVersionDeprecationInfo {
2413    /// The time at which this processor version will be deprecated.
2414    #[serde(rename = "deprecationTime")]
2415    pub deprecation_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2416    /// If set, the processor version that will be used as a replacement.
2417    #[serde(rename = "replacementProcessorVersion")]
2418    pub replacement_processor_version: Option<String>,
2419}
2420
2421impl common::Part for GoogleCloudDocumentaiV1ProcessorVersionDeprecationInfo {}
2422
2423/// Payload message of raw document content (bytes).
2424///
2425/// This type is not used in any activity, and only used as *part* of another schema.
2426///
2427#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2428#[serde_with::serde_as]
2429#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2430pub struct GoogleCloudDocumentaiV1RawDocument {
2431    /// Inline document content.
2432    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2433    pub content: Option<Vec<u8>>,
2434    /// The display name of the document, it supports all Unicode characters except the following: `*`, `?`, `[`, `]`, `%`, `{`, `}`,`'`, `\"`, `,` `~`, `=` and `:` are reserved. If not specified, a default ID is generated.
2435    #[serde(rename = "displayName")]
2436    pub display_name: Option<String>,
2437    /// An IANA MIME type (RFC6838) indicating the nature and format of the content.
2438    #[serde(rename = "mimeType")]
2439    pub mime_type: Option<String>,
2440}
2441
2442impl common::Part for GoogleCloudDocumentaiV1RawDocument {}
2443
2444/// Request message for the ReviewDocument method.
2445///
2446/// # Activities
2447///
2448/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2449/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2450///
2451/// * [locations processors human review config review document projects](ProjectLocationProcessorHumanReviewConfigReviewDocumentCall) (request)
2452#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2453#[serde_with::serde_as]
2454#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2455pub struct GoogleCloudDocumentaiV1ReviewDocumentRequest {
2456    /// The document schema of the human review task.
2457    #[serde(rename = "documentSchema")]
2458    pub document_schema: Option<GoogleCloudDocumentaiV1DocumentSchema>,
2459    /// Whether the validation should be performed on the ad-hoc review request.
2460    #[serde(rename = "enableSchemaValidation")]
2461    pub enable_schema_validation: Option<bool>,
2462    /// An inline document proto.
2463    #[serde(rename = "inlineDocument")]
2464    pub inline_document: Option<GoogleCloudDocumentaiV1Document>,
2465    /// The priority of the human review task.
2466    pub priority: Option<String>,
2467}
2468
2469impl common::RequestValue for GoogleCloudDocumentaiV1ReviewDocumentRequest {}
2470
2471/// Request message for the SetDefaultProcessorVersion method.
2472///
2473/// # Activities
2474///
2475/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2476/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2477///
2478/// * [locations processors set default processor version projects](ProjectLocationProcessorSetDefaultProcessorVersionCall) (request)
2479#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2480#[serde_with::serde_as]
2481#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2482pub struct GoogleCloudDocumentaiV1SetDefaultProcessorVersionRequest {
2483    /// Required. The resource name of child ProcessorVersion to use as default. Format: `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{version}`
2484    #[serde(rename = "defaultProcessorVersion")]
2485    pub default_processor_version: Option<String>,
2486}
2487
2488impl common::RequestValue for GoogleCloudDocumentaiV1SetDefaultProcessorVersionRequest {}
2489
2490/// Request message for the TrainProcessorVersion method.
2491///
2492/// # Activities
2493///
2494/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2495/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2496///
2497/// * [locations processors processor versions train projects](ProjectLocationProcessorProcessorVersionTrainCall) (request)
2498#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2499#[serde_with::serde_as]
2500#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2501pub struct GoogleCloudDocumentaiV1TrainProcessorVersionRequest {
2502    /// Optional. The processor version to use as a base for training. This processor version must be a child of `parent`. Format: `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`.
2503    #[serde(rename = "baseProcessorVersion")]
2504    pub base_processor_version: Option<String>,
2505    /// Options to control Custom Document Extraction (CDE) Processor.
2506    #[serde(rename = "customDocumentExtractionOptions")]
2507    pub custom_document_extraction_options:
2508        Option<GoogleCloudDocumentaiV1TrainProcessorVersionRequestCustomDocumentExtractionOptions>,
2509    /// Optional. The schema the processor version will be trained with.
2510    #[serde(rename = "documentSchema")]
2511    pub document_schema: Option<GoogleCloudDocumentaiV1DocumentSchema>,
2512    /// Options to control foundation model tuning of a processor.
2513    #[serde(rename = "foundationModelTuningOptions")]
2514    pub foundation_model_tuning_options:
2515        Option<GoogleCloudDocumentaiV1TrainProcessorVersionRequestFoundationModelTuningOptions>,
2516    /// Optional. The input data used to train the ProcessorVersion.
2517    #[serde(rename = "inputData")]
2518    pub input_data: Option<GoogleCloudDocumentaiV1TrainProcessorVersionRequestInputData>,
2519    /// Required. The processor version to be created.
2520    #[serde(rename = "processorVersion")]
2521    pub processor_version: Option<GoogleCloudDocumentaiV1ProcessorVersion>,
2522}
2523
2524impl common::RequestValue for GoogleCloudDocumentaiV1TrainProcessorVersionRequest {}
2525
2526/// Options to control the training of the Custom Document Extraction (CDE) Processor.
2527///
2528/// This type is not used in any activity, and only used as *part* of another schema.
2529///
2530#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2531#[serde_with::serde_as]
2532#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2533pub struct GoogleCloudDocumentaiV1TrainProcessorVersionRequestCustomDocumentExtractionOptions {
2534    /// Training method to use for CDE training.
2535    #[serde(rename = "trainingMethod")]
2536    pub training_method: Option<String>,
2537}
2538
2539impl common::Part
2540    for GoogleCloudDocumentaiV1TrainProcessorVersionRequestCustomDocumentExtractionOptions
2541{
2542}
2543
2544/// Options to control foundation model tuning of the processor.
2545///
2546/// This type is not used in any activity, and only used as *part* of another schema.
2547///
2548#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2549#[serde_with::serde_as]
2550#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2551pub struct GoogleCloudDocumentaiV1TrainProcessorVersionRequestFoundationModelTuningOptions {
2552    /// Optional. The multiplier to apply to the recommended learning rate. Valid values are between 0.1 and 10. If not provided, recommended learning rate will be used.
2553    #[serde(rename = "learningRateMultiplier")]
2554    pub learning_rate_multiplier: Option<f32>,
2555    /// Optional. The number of steps to run for model tuning. Valid values are between 1 and 400. If not provided, recommended steps will be used.
2556    #[serde(rename = "trainSteps")]
2557    pub train_steps: Option<i32>,
2558}
2559
2560impl common::Part
2561    for GoogleCloudDocumentaiV1TrainProcessorVersionRequestFoundationModelTuningOptions
2562{
2563}
2564
2565/// The input data used to train a new ProcessorVersion.
2566///
2567/// This type is not used in any activity, and only used as *part* of another schema.
2568///
2569#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2570#[serde_with::serde_as]
2571#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2572pub struct GoogleCloudDocumentaiV1TrainProcessorVersionRequestInputData {
2573    /// The documents used for testing the trained version.
2574    #[serde(rename = "testDocuments")]
2575    pub test_documents: Option<GoogleCloudDocumentaiV1BatchDocumentsInputConfig>,
2576    /// The documents used for training the new version.
2577    #[serde(rename = "trainingDocuments")]
2578    pub training_documents: Option<GoogleCloudDocumentaiV1BatchDocumentsInputConfig>,
2579}
2580
2581impl common::Part for GoogleCloudDocumentaiV1TrainProcessorVersionRequestInputData {}
2582
2583/// Request message for the UndeployProcessorVersion method.
2584///
2585/// # Activities
2586///
2587/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2588/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2589///
2590/// * [locations processors processor versions undeploy projects](ProjectLocationProcessorProcessorVersionUndeployCall) (request)
2591#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2592#[serde_with::serde_as]
2593#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2594pub struct GoogleCloudDocumentaiV1UndeployProcessorVersionRequest {
2595    _never_set: Option<bool>,
2596}
2597
2598impl common::RequestValue for GoogleCloudDocumentaiV1UndeployProcessorVersionRequest {}
2599
2600/// A vertex represents a 2D point in the image. NOTE: the vertex coordinates are in the same scale as the original image.
2601///
2602/// This type is not used in any activity, and only used as *part* of another schema.
2603///
2604#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2605#[serde_with::serde_as]
2606#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2607pub struct GoogleCloudDocumentaiV1Vertex {
2608    /// X coordinate.
2609    pub x: Option<i32>,
2610    /// Y coordinate (starts from the top of the image).
2611    pub y: Option<i32>,
2612}
2613
2614impl common::Part for GoogleCloudDocumentaiV1Vertex {}
2615
2616/// The response message for Locations.ListLocations.
2617///
2618/// # Activities
2619///
2620/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2621/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2622///
2623/// * [locations list projects](ProjectLocationListCall) (response)
2624#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2625#[serde_with::serde_as]
2626#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2627pub struct GoogleCloudLocationListLocationsResponse {
2628    /// A list of locations that matches the specified filter in the request.
2629    pub locations: Option<Vec<GoogleCloudLocationLocation>>,
2630    /// The standard List next-page token.
2631    #[serde(rename = "nextPageToken")]
2632    pub next_page_token: Option<String>,
2633}
2634
2635impl common::ResponseResult for GoogleCloudLocationListLocationsResponse {}
2636
2637/// A resource that represents a Google Cloud location.
2638///
2639/// # Activities
2640///
2641/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2642/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2643///
2644/// * [locations get projects](ProjectLocationGetCall) (response)
2645#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2646#[serde_with::serde_as]
2647#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2648pub struct GoogleCloudLocationLocation {
2649    /// The friendly name for this location, typically a nearby city name. For example, "Tokyo".
2650    #[serde(rename = "displayName")]
2651    pub display_name: Option<String>,
2652    /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"}
2653    pub labels: Option<HashMap<String, String>>,
2654    /// The canonical id for this location. For example: `"us-east1"`.
2655    #[serde(rename = "locationId")]
2656    pub location_id: Option<String>,
2657    /// Service-specific metadata. For example the available capacity at the given location.
2658    pub metadata: Option<HashMap<String, serde_json::Value>>,
2659    /// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"`
2660    pub name: Option<String>,
2661}
2662
2663impl common::ResponseResult for GoogleCloudLocationLocation {}
2664
2665/// The response message for Operations.ListOperations.
2666///
2667/// # Activities
2668///
2669/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2670/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2671///
2672/// * [locations operations list projects](ProjectLocationOperationListCall) (response)
2673#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2674#[serde_with::serde_as]
2675#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2676pub struct GoogleLongrunningListOperationsResponse {
2677    /// The standard List next-page token.
2678    #[serde(rename = "nextPageToken")]
2679    pub next_page_token: Option<String>,
2680    /// A list of operations that matches the specified filter in the request.
2681    pub operations: Option<Vec<GoogleLongrunningOperation>>,
2682}
2683
2684impl common::ResponseResult for GoogleLongrunningListOperationsResponse {}
2685
2686/// This resource represents a long-running operation that is the result of a network API call.
2687///
2688/// # Activities
2689///
2690/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2691/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2692///
2693/// * [locations operations get projects](ProjectLocationOperationGetCall) (response)
2694/// * [locations processors human review config review document projects](ProjectLocationProcessorHumanReviewConfigReviewDocumentCall) (response)
2695/// * [locations processors processor versions batch process projects](ProjectLocationProcessorProcessorVersionBatchProcesCall) (response)
2696/// * [locations processors processor versions delete projects](ProjectLocationProcessorProcessorVersionDeleteCall) (response)
2697/// * [locations processors processor versions deploy projects](ProjectLocationProcessorProcessorVersionDeployCall) (response)
2698/// * [locations processors processor versions evaluate processor version projects](ProjectLocationProcessorProcessorVersionEvaluateProcessorVersionCall) (response)
2699/// * [locations processors processor versions train projects](ProjectLocationProcessorProcessorVersionTrainCall) (response)
2700/// * [locations processors processor versions undeploy projects](ProjectLocationProcessorProcessorVersionUndeployCall) (response)
2701/// * [locations processors batch process projects](ProjectLocationProcessorBatchProcesCall) (response)
2702/// * [locations processors delete projects](ProjectLocationProcessorDeleteCall) (response)
2703/// * [locations processors disable projects](ProjectLocationProcessorDisableCall) (response)
2704/// * [locations processors enable projects](ProjectLocationProcessorEnableCall) (response)
2705/// * [locations processors set default processor version projects](ProjectLocationProcessorSetDefaultProcessorVersionCall) (response)
2706/// * [operations get projects](ProjectOperationGetCall) (response)
2707#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2708#[serde_with::serde_as]
2709#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2710pub struct GoogleLongrunningOperation {
2711    /// 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.
2712    pub done: Option<bool>,
2713    /// The error result of the operation in case of failure or cancellation.
2714    pub error: Option<GoogleRpcStatus>,
2715    /// 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.
2716    pub metadata: Option<HashMap<String, serde_json::Value>>,
2717    /// 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}`.
2718    pub name: Option<String>,
2719    /// 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`.
2720    pub response: Option<HashMap<String, serde_json::Value>>,
2721}
2722
2723impl common::ResponseResult for GoogleLongrunningOperation {}
2724
2725/// A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
2726///
2727/// # Activities
2728///
2729/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2730/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2731///
2732/// * [delete operations](OperationDeleteCall) (response)
2733/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (response)
2734#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2735#[serde_with::serde_as]
2736#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2737pub struct GoogleProtobufEmpty {
2738    _never_set: Option<bool>,
2739}
2740
2741impl common::ResponseResult for GoogleProtobufEmpty {}
2742
2743/// 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).
2744///
2745/// This type is not used in any activity, and only used as *part* of another schema.
2746///
2747#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2748#[serde_with::serde_as]
2749#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2750pub struct GoogleRpcStatus {
2751    /// The status code, which should be an enum value of google.rpc.Code.
2752    pub code: Option<i32>,
2753    /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
2754    pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
2755    /// 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.
2756    pub message: Option<String>,
2757}
2758
2759impl common::Part for GoogleRpcStatus {}
2760
2761/// 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(''); }; // ...
2762///
2763/// This type is not used in any activity, and only used as *part* of another schema.
2764///
2765#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2766#[serde_with::serde_as]
2767#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2768pub struct GoogleTypeColor {
2769    /// 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).
2770    pub alpha: Option<f32>,
2771    /// The amount of blue in the color as a value in the interval [0, 1].
2772    pub blue: Option<f32>,
2773    /// The amount of green in the color as a value in the interval [0, 1].
2774    pub green: Option<f32>,
2775    /// The amount of red in the color as a value in the interval [0, 1].
2776    pub red: Option<f32>,
2777}
2778
2779impl common::Part for GoogleTypeColor {}
2780
2781/// 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
2782///
2783/// This type is not used in any activity, and only used as *part* of another schema.
2784///
2785#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2786#[serde_with::serde_as]
2787#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2788pub struct GoogleTypeDate {
2789    /// 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.
2790    pub day: Option<i32>,
2791    /// Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
2792    pub month: Option<i32>,
2793    /// Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
2794    pub year: Option<i32>,
2795}
2796
2797impl common::Part for GoogleTypeDate {}
2798
2799/// 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.
2800///
2801/// This type is not used in any activity, and only used as *part* of another schema.
2802///
2803#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2804#[serde_with::serde_as]
2805#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2806pub struct GoogleTypeDateTime {
2807    /// 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.
2808    pub day: Option<i32>,
2809    /// 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.
2810    pub hours: Option<i32>,
2811    /// Optional. Minutes of hour of day. Must be from 0 to 59, defaults to 0.
2812    pub minutes: Option<i32>,
2813    /// Optional. Month of year. Must be from 1 to 12, or 0 if specifying a datetime without a month.
2814    pub month: Option<i32>,
2815    /// Optional. Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999, defaults to 0.
2816    pub nanos: Option<i32>,
2817    /// 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.
2818    pub seconds: Option<i32>,
2819    /// Time zone.
2820    #[serde(rename = "timeZone")]
2821    pub time_zone: Option<GoogleTypeTimeZone>,
2822    /// 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 }.
2823    #[serde(rename = "utcOffset")]
2824    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
2825    pub utc_offset: Option<chrono::Duration>,
2826    /// Optional. Year of date. Must be from 1 to 9999, or 0 if specifying a datetime without a year.
2827    pub year: Option<i32>,
2828}
2829
2830impl common::Part for GoogleTypeDateTime {}
2831
2832/// Represents an amount of money with its currency type.
2833///
2834/// This type is not used in any activity, and only used as *part* of another schema.
2835///
2836#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2837#[serde_with::serde_as]
2838#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2839pub struct GoogleTypeMoney {
2840    /// The three-letter currency code defined in ISO 4217.
2841    #[serde(rename = "currencyCode")]
2842    pub currency_code: Option<String>,
2843    /// 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.
2844    pub nanos: Option<i32>,
2845    /// The whole units of the amount. For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar.
2846    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2847    pub units: Option<i64>,
2848}
2849
2850impl common::Part for GoogleTypeMoney {}
2851
2852/// 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
2853///
2854/// This type is not used in any activity, and only used as *part* of another schema.
2855///
2856#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2857#[serde_with::serde_as]
2858#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2859pub struct GoogleTypePostalAddress {
2860    /// 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).
2861    #[serde(rename = "addressLines")]
2862    pub address_lines: Option<Vec<String>>,
2863    /// 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.
2864    #[serde(rename = "administrativeArea")]
2865    pub administrative_area: Option<String>,
2866    /// 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".
2867    #[serde(rename = "languageCode")]
2868    pub language_code: Option<String>,
2869    /// 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.
2870    pub locality: Option<String>,
2871    /// Optional. The name of the organization at the address.
2872    pub organization: Option<String>,
2873    /// 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.).
2874    #[serde(rename = "postalCode")]
2875    pub postal_code: Option<String>,
2876    /// Optional. The recipient at the address. This field may, under certain circumstances, contain multiline information. For example, it might contain "care of" information.
2877    pub recipients: Option<Vec<String>>,
2878    /// 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.
2879    #[serde(rename = "regionCode")]
2880    pub region_code: Option<String>,
2881    /// 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.
2882    pub revision: Option<i32>,
2883    /// 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).
2884    #[serde(rename = "sortingCode")]
2885    pub sorting_code: Option<String>,
2886    /// Optional. Sublocality of the address. For example, this can be neighborhoods, boroughs, districts.
2887    pub sublocality: Option<String>,
2888}
2889
2890impl common::Part for GoogleTypePostalAddress {}
2891
2892/// Represents a time zone from the [IANA Time Zone Database](https://www.iana.org/time-zones).
2893///
2894/// This type is not used in any activity, and only used as *part* of another schema.
2895///
2896#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2897#[serde_with::serde_as]
2898#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2899pub struct GoogleTypeTimeZone {
2900    /// IANA Time Zone Database time zone, e.g. "America/New_York".
2901    pub id: Option<String>,
2902    /// Optional. IANA Time Zone Database version number, e.g. "2019a".
2903    pub version: Option<String>,
2904}
2905
2906impl common::Part for GoogleTypeTimeZone {}
2907
2908// ###################
2909// MethodBuilders ###
2910// #################
2911
2912/// A builder providing access to all methods supported on *operation* resources.
2913/// It is not used directly, but through the [`Document`] hub.
2914///
2915/// # Example
2916///
2917/// Instantiate a resource builder
2918///
2919/// ```test_harness,no_run
2920/// extern crate hyper;
2921/// extern crate hyper_rustls;
2922/// extern crate google_documentai1 as documentai1;
2923///
2924/// # async fn dox() {
2925/// use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2926///
2927/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2928/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2929///     secret,
2930///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2931/// ).build().await.unwrap();
2932///
2933/// let client = hyper_util::client::legacy::Client::builder(
2934///     hyper_util::rt::TokioExecutor::new()
2935/// )
2936/// .build(
2937///     hyper_rustls::HttpsConnectorBuilder::new()
2938///         .with_native_roots()
2939///         .unwrap()
2940///         .https_or_http()
2941///         .enable_http1()
2942///         .build()
2943/// );
2944/// let mut hub = Document::new(client, auth);
2945/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2946/// // like `delete(...)`
2947/// // to build up your call.
2948/// let rb = hub.operations();
2949/// # }
2950/// ```
2951pub struct OperationMethods<'a, C>
2952where
2953    C: 'a,
2954{
2955    hub: &'a Document<C>,
2956}
2957
2958impl<'a, C> common::MethodsBuilder for OperationMethods<'a, C> {}
2959
2960impl<'a, C> OperationMethods<'a, C> {
2961    /// Create a builder to help you perform the following task:
2962    ///
2963    /// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`.
2964    ///
2965    /// # Arguments
2966    ///
2967    /// * `name` - The name of the operation resource to be deleted.
2968    pub fn delete(&self, name: &str) -> OperationDeleteCall<'a, C> {
2969        OperationDeleteCall {
2970            hub: self.hub,
2971            _name: name.to_string(),
2972            _delegate: Default::default(),
2973            _additional_params: Default::default(),
2974            _scopes: Default::default(),
2975        }
2976    }
2977}
2978
2979/// A builder providing access to all methods supported on *project* resources.
2980/// It is not used directly, but through the [`Document`] hub.
2981///
2982/// # Example
2983///
2984/// Instantiate a resource builder
2985///
2986/// ```test_harness,no_run
2987/// extern crate hyper;
2988/// extern crate hyper_rustls;
2989/// extern crate google_documentai1 as documentai1;
2990///
2991/// # async fn dox() {
2992/// use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2993///
2994/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2995/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2996///     secret,
2997///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2998/// ).build().await.unwrap();
2999///
3000/// let client = hyper_util::client::legacy::Client::builder(
3001///     hyper_util::rt::TokioExecutor::new()
3002/// )
3003/// .build(
3004///     hyper_rustls::HttpsConnectorBuilder::new()
3005///         .with_native_roots()
3006///         .unwrap()
3007///         .https_or_http()
3008///         .enable_http1()
3009///         .build()
3010/// );
3011/// let mut hub = Document::new(client, auth);
3012/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3013/// // like `locations_fetch_processor_types(...)`, `locations_get(...)`, `locations_list(...)`, `locations_operations_cancel(...)`, `locations_operations_get(...)`, `locations_operations_list(...)`, `locations_processor_types_get(...)`, `locations_processor_types_list(...)`, `locations_processors_batch_process(...)`, `locations_processors_create(...)`, `locations_processors_delete(...)`, `locations_processors_disable(...)`, `locations_processors_enable(...)`, `locations_processors_get(...)`, `locations_processors_human_review_config_review_document(...)`, `locations_processors_list(...)`, `locations_processors_process(...)`, `locations_processors_processor_versions_batch_process(...)`, `locations_processors_processor_versions_delete(...)`, `locations_processors_processor_versions_deploy(...)`, `locations_processors_processor_versions_evaluate_processor_version(...)`, `locations_processors_processor_versions_evaluations_get(...)`, `locations_processors_processor_versions_evaluations_list(...)`, `locations_processors_processor_versions_get(...)`, `locations_processors_processor_versions_list(...)`, `locations_processors_processor_versions_process(...)`, `locations_processors_processor_versions_train(...)`, `locations_processors_processor_versions_undeploy(...)`, `locations_processors_set_default_processor_version(...)` and `operations_get(...)`
3014/// // to build up your call.
3015/// let rb = hub.projects();
3016/// # }
3017/// ```
3018pub struct ProjectMethods<'a, C>
3019where
3020    C: 'a,
3021{
3022    hub: &'a Document<C>,
3023}
3024
3025impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
3026
3027impl<'a, C> ProjectMethods<'a, C> {
3028    /// Create a builder to help you perform the following task:
3029    ///
3030    /// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of 1, corresponding to `Code.CANCELLED`.
3031    ///
3032    /// # Arguments
3033    ///
3034    /// * `name` - The name of the operation resource to be cancelled.
3035    pub fn locations_operations_cancel(
3036        &self,
3037        name: &str,
3038    ) -> ProjectLocationOperationCancelCall<'a, C> {
3039        ProjectLocationOperationCancelCall {
3040            hub: self.hub,
3041            _name: name.to_string(),
3042            _delegate: Default::default(),
3043            _additional_params: Default::default(),
3044            _scopes: Default::default(),
3045        }
3046    }
3047
3048    /// Create a builder to help you perform the following task:
3049    ///
3050    /// 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.
3051    ///
3052    /// # Arguments
3053    ///
3054    /// * `name` - The name of the operation resource.
3055    pub fn locations_operations_get(&self, name: &str) -> ProjectLocationOperationGetCall<'a, C> {
3056        ProjectLocationOperationGetCall {
3057            hub: self.hub,
3058            _name: name.to_string(),
3059            _delegate: Default::default(),
3060            _additional_params: Default::default(),
3061            _scopes: Default::default(),
3062        }
3063    }
3064
3065    /// Create a builder to help you perform the following task:
3066    ///
3067    /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
3068    ///
3069    /// # Arguments
3070    ///
3071    /// * `name` - The name of the operation's parent resource.
3072    pub fn locations_operations_list(&self, name: &str) -> ProjectLocationOperationListCall<'a, C> {
3073        ProjectLocationOperationListCall {
3074            hub: self.hub,
3075            _name: name.to_string(),
3076            _page_token: Default::default(),
3077            _page_size: Default::default(),
3078            _filter: Default::default(),
3079            _delegate: Default::default(),
3080            _additional_params: Default::default(),
3081            _scopes: Default::default(),
3082        }
3083    }
3084
3085    /// Create a builder to help you perform the following task:
3086    ///
3087    /// Gets a processor type detail.
3088    ///
3089    /// # Arguments
3090    ///
3091    /// * `name` - Required. The processor type resource name.
3092    pub fn locations_processor_types_get(
3093        &self,
3094        name: &str,
3095    ) -> ProjectLocationProcessorTypeGetCall<'a, C> {
3096        ProjectLocationProcessorTypeGetCall {
3097            hub: self.hub,
3098            _name: name.to_string(),
3099            _delegate: Default::default(),
3100            _additional_params: Default::default(),
3101            _scopes: Default::default(),
3102        }
3103    }
3104
3105    /// Create a builder to help you perform the following task:
3106    ///
3107    /// Lists the processor types that exist.
3108    ///
3109    /// # Arguments
3110    ///
3111    /// * `parent` - Required. The location of processor types to list. Format: `projects/{project}/locations/{location}`.
3112    pub fn locations_processor_types_list(
3113        &self,
3114        parent: &str,
3115    ) -> ProjectLocationProcessorTypeListCall<'a, C> {
3116        ProjectLocationProcessorTypeListCall {
3117            hub: self.hub,
3118            _parent: parent.to_string(),
3119            _page_token: Default::default(),
3120            _page_size: Default::default(),
3121            _delegate: Default::default(),
3122            _additional_params: Default::default(),
3123            _scopes: Default::default(),
3124        }
3125    }
3126
3127    /// Create a builder to help you perform the following task:
3128    ///
3129    /// Send a document for Human Review. The input document should be processed by the specified processor.
3130    ///
3131    /// # Arguments
3132    ///
3133    /// * `request` - No description provided.
3134    /// * `humanReviewConfig` - Required. The resource name of the HumanReviewConfig that the document will be reviewed with.
3135    pub fn locations_processors_human_review_config_review_document(
3136        &self,
3137        request: GoogleCloudDocumentaiV1ReviewDocumentRequest,
3138        human_review_config: &str,
3139    ) -> ProjectLocationProcessorHumanReviewConfigReviewDocumentCall<'a, C> {
3140        ProjectLocationProcessorHumanReviewConfigReviewDocumentCall {
3141            hub: self.hub,
3142            _request: request,
3143            _human_review_config: human_review_config.to_string(),
3144            _delegate: Default::default(),
3145            _additional_params: Default::default(),
3146            _scopes: Default::default(),
3147        }
3148    }
3149
3150    /// Create a builder to help you perform the following task:
3151    ///
3152    /// Retrieves a specific evaluation.
3153    ///
3154    /// # Arguments
3155    ///
3156    /// * `name` - Required. The resource name of the Evaluation to get. `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}/evaluations/{evaluation}`
3157    pub fn locations_processors_processor_versions_evaluations_get(
3158        &self,
3159        name: &str,
3160    ) -> ProjectLocationProcessorProcessorVersionEvaluationGetCall<'a, C> {
3161        ProjectLocationProcessorProcessorVersionEvaluationGetCall {
3162            hub: self.hub,
3163            _name: name.to_string(),
3164            _delegate: Default::default(),
3165            _additional_params: Default::default(),
3166            _scopes: Default::default(),
3167        }
3168    }
3169
3170    /// Create a builder to help you perform the following task:
3171    ///
3172    /// Retrieves a set of evaluations for a given processor version.
3173    ///
3174    /// # Arguments
3175    ///
3176    /// * `parent` - Required. The resource name of the ProcessorVersion to list evaluations for. `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`
3177    pub fn locations_processors_processor_versions_evaluations_list(
3178        &self,
3179        parent: &str,
3180    ) -> ProjectLocationProcessorProcessorVersionEvaluationListCall<'a, C> {
3181        ProjectLocationProcessorProcessorVersionEvaluationListCall {
3182            hub: self.hub,
3183            _parent: parent.to_string(),
3184            _page_token: Default::default(),
3185            _page_size: Default::default(),
3186            _delegate: Default::default(),
3187            _additional_params: Default::default(),
3188            _scopes: Default::default(),
3189        }
3190    }
3191
3192    /// Create a builder to help you perform the following task:
3193    ///
3194    /// LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in the [Document] format.
3195    ///
3196    /// # Arguments
3197    ///
3198    /// * `request` - No description provided.
3199    /// * `name` - Required. The resource name of Processor or ProcessorVersion. Format: `projects/{project}/locations/{location}/processors/{processor}`, or `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`
3200    pub fn locations_processors_processor_versions_batch_process(
3201        &self,
3202        request: GoogleCloudDocumentaiV1BatchProcessRequest,
3203        name: &str,
3204    ) -> ProjectLocationProcessorProcessorVersionBatchProcesCall<'a, C> {
3205        ProjectLocationProcessorProcessorVersionBatchProcesCall {
3206            hub: self.hub,
3207            _request: request,
3208            _name: name.to_string(),
3209            _delegate: Default::default(),
3210            _additional_params: Default::default(),
3211            _scopes: Default::default(),
3212        }
3213    }
3214
3215    /// Create a builder to help you perform the following task:
3216    ///
3217    /// Deletes the processor version, all artifacts under the processor version will be deleted.
3218    ///
3219    /// # Arguments
3220    ///
3221    /// * `name` - Required. The processor version resource name to be deleted.
3222    pub fn locations_processors_processor_versions_delete(
3223        &self,
3224        name: &str,
3225    ) -> ProjectLocationProcessorProcessorVersionDeleteCall<'a, C> {
3226        ProjectLocationProcessorProcessorVersionDeleteCall {
3227            hub: self.hub,
3228            _name: name.to_string(),
3229            _delegate: Default::default(),
3230            _additional_params: Default::default(),
3231            _scopes: Default::default(),
3232        }
3233    }
3234
3235    /// Create a builder to help you perform the following task:
3236    ///
3237    /// Deploys the processor version.
3238    ///
3239    /// # Arguments
3240    ///
3241    /// * `request` - No description provided.
3242    /// * `name` - Required. The processor version resource name to be deployed.
3243    pub fn locations_processors_processor_versions_deploy(
3244        &self,
3245        request: GoogleCloudDocumentaiV1DeployProcessorVersionRequest,
3246        name: &str,
3247    ) -> ProjectLocationProcessorProcessorVersionDeployCall<'a, C> {
3248        ProjectLocationProcessorProcessorVersionDeployCall {
3249            hub: self.hub,
3250            _request: request,
3251            _name: name.to_string(),
3252            _delegate: Default::default(),
3253            _additional_params: Default::default(),
3254            _scopes: Default::default(),
3255        }
3256    }
3257
3258    /// Create a builder to help you perform the following task:
3259    ///
3260    /// Evaluates a ProcessorVersion against annotated documents, producing an Evaluation.
3261    ///
3262    /// # Arguments
3263    ///
3264    /// * `request` - No description provided.
3265    /// * `processorVersion` - Required. The resource name of the ProcessorVersion to evaluate. `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`
3266    pub fn locations_processors_processor_versions_evaluate_processor_version(
3267        &self,
3268        request: GoogleCloudDocumentaiV1EvaluateProcessorVersionRequest,
3269        processor_version: &str,
3270    ) -> ProjectLocationProcessorProcessorVersionEvaluateProcessorVersionCall<'a, C> {
3271        ProjectLocationProcessorProcessorVersionEvaluateProcessorVersionCall {
3272            hub: self.hub,
3273            _request: request,
3274            _processor_version: processor_version.to_string(),
3275            _delegate: Default::default(),
3276            _additional_params: Default::default(),
3277            _scopes: Default::default(),
3278        }
3279    }
3280
3281    /// Create a builder to help you perform the following task:
3282    ///
3283    /// Gets a processor version detail.
3284    ///
3285    /// # Arguments
3286    ///
3287    /// * `name` - Required. The processor resource name.
3288    pub fn locations_processors_processor_versions_get(
3289        &self,
3290        name: &str,
3291    ) -> ProjectLocationProcessorProcessorVersionGetCall<'a, C> {
3292        ProjectLocationProcessorProcessorVersionGetCall {
3293            hub: self.hub,
3294            _name: name.to_string(),
3295            _delegate: Default::default(),
3296            _additional_params: Default::default(),
3297            _scopes: Default::default(),
3298        }
3299    }
3300
3301    /// Create a builder to help you perform the following task:
3302    ///
3303    /// Lists all versions of a processor.
3304    ///
3305    /// # Arguments
3306    ///
3307    /// * `parent` - Required. The parent (project, location and processor) to list all versions. Format: `projects/{project}/locations/{location}/processors/{processor}`
3308    pub fn locations_processors_processor_versions_list(
3309        &self,
3310        parent: &str,
3311    ) -> ProjectLocationProcessorProcessorVersionListCall<'a, C> {
3312        ProjectLocationProcessorProcessorVersionListCall {
3313            hub: self.hub,
3314            _parent: parent.to_string(),
3315            _page_token: Default::default(),
3316            _page_size: Default::default(),
3317            _delegate: Default::default(),
3318            _additional_params: Default::default(),
3319            _scopes: Default::default(),
3320        }
3321    }
3322
3323    /// Create a builder to help you perform the following task:
3324    ///
3325    /// Processes a single document.
3326    ///
3327    /// # Arguments
3328    ///
3329    /// * `request` - No description provided.
3330    /// * `name` - Required. The resource name of the Processor or ProcessorVersion to use for processing. If a Processor is specified, the server will use its default version. Format: `projects/{project}/locations/{location}/processors/{processor}`, or `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`
3331    pub fn locations_processors_processor_versions_process(
3332        &self,
3333        request: GoogleCloudDocumentaiV1ProcessRequest,
3334        name: &str,
3335    ) -> ProjectLocationProcessorProcessorVersionProcesCall<'a, C> {
3336        ProjectLocationProcessorProcessorVersionProcesCall {
3337            hub: self.hub,
3338            _request: request,
3339            _name: name.to_string(),
3340            _delegate: Default::default(),
3341            _additional_params: Default::default(),
3342            _scopes: Default::default(),
3343        }
3344    }
3345
3346    /// Create a builder to help you perform the following task:
3347    ///
3348    /// Trains a new processor version. Operation metadata is returned as TrainProcessorVersionMetadata.
3349    ///
3350    /// # Arguments
3351    ///
3352    /// * `request` - No description provided.
3353    /// * `parent` - Required. The parent (project, location and processor) to create the new version for. Format: `projects/{project}/locations/{location}/processors/{processor}`.
3354    pub fn locations_processors_processor_versions_train(
3355        &self,
3356        request: GoogleCloudDocumentaiV1TrainProcessorVersionRequest,
3357        parent: &str,
3358    ) -> ProjectLocationProcessorProcessorVersionTrainCall<'a, C> {
3359        ProjectLocationProcessorProcessorVersionTrainCall {
3360            hub: self.hub,
3361            _request: request,
3362            _parent: parent.to_string(),
3363            _delegate: Default::default(),
3364            _additional_params: Default::default(),
3365            _scopes: Default::default(),
3366        }
3367    }
3368
3369    /// Create a builder to help you perform the following task:
3370    ///
3371    /// Undeploys the processor version.
3372    ///
3373    /// # Arguments
3374    ///
3375    /// * `request` - No description provided.
3376    /// * `name` - Required. The processor version resource name to be undeployed.
3377    pub fn locations_processors_processor_versions_undeploy(
3378        &self,
3379        request: GoogleCloudDocumentaiV1UndeployProcessorVersionRequest,
3380        name: &str,
3381    ) -> ProjectLocationProcessorProcessorVersionUndeployCall<'a, C> {
3382        ProjectLocationProcessorProcessorVersionUndeployCall {
3383            hub: self.hub,
3384            _request: request,
3385            _name: name.to_string(),
3386            _delegate: Default::default(),
3387            _additional_params: Default::default(),
3388            _scopes: Default::default(),
3389        }
3390    }
3391
3392    /// Create a builder to help you perform the following task:
3393    ///
3394    /// LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in the [Document] format.
3395    ///
3396    /// # Arguments
3397    ///
3398    /// * `request` - No description provided.
3399    /// * `name` - Required. The resource name of Processor or ProcessorVersion. Format: `projects/{project}/locations/{location}/processors/{processor}`, or `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`
3400    pub fn locations_processors_batch_process(
3401        &self,
3402        request: GoogleCloudDocumentaiV1BatchProcessRequest,
3403        name: &str,
3404    ) -> ProjectLocationProcessorBatchProcesCall<'a, C> {
3405        ProjectLocationProcessorBatchProcesCall {
3406            hub: self.hub,
3407            _request: request,
3408            _name: name.to_string(),
3409            _delegate: Default::default(),
3410            _additional_params: Default::default(),
3411            _scopes: Default::default(),
3412        }
3413    }
3414
3415    /// Create a builder to help you perform the following task:
3416    ///
3417    /// Creates a processor from the ProcessorType provided. The processor will be at `ENABLED` state by default after its creation. Note that this method requires the `documentai.processors.create` permission on the project, which is highly privileged. A user or service account with this permission can create new processors that can interact with any gcs bucket in your project.
3418    ///
3419    /// # Arguments
3420    ///
3421    /// * `request` - No description provided.
3422    /// * `parent` - Required. The parent (project and location) under which to create the processor. Format: `projects/{project}/locations/{location}`
3423    pub fn locations_processors_create(
3424        &self,
3425        request: GoogleCloudDocumentaiV1Processor,
3426        parent: &str,
3427    ) -> ProjectLocationProcessorCreateCall<'a, C> {
3428        ProjectLocationProcessorCreateCall {
3429            hub: self.hub,
3430            _request: request,
3431            _parent: parent.to_string(),
3432            _delegate: Default::default(),
3433            _additional_params: Default::default(),
3434            _scopes: Default::default(),
3435        }
3436    }
3437
3438    /// Create a builder to help you perform the following task:
3439    ///
3440    /// Deletes the processor, unloads all deployed model artifacts if it was enabled and then deletes all artifacts associated with this processor.
3441    ///
3442    /// # Arguments
3443    ///
3444    /// * `name` - Required. The processor resource name to be deleted.
3445    pub fn locations_processors_delete(
3446        &self,
3447        name: &str,
3448    ) -> ProjectLocationProcessorDeleteCall<'a, C> {
3449        ProjectLocationProcessorDeleteCall {
3450            hub: self.hub,
3451            _name: name.to_string(),
3452            _delegate: Default::default(),
3453            _additional_params: Default::default(),
3454            _scopes: Default::default(),
3455        }
3456    }
3457
3458    /// Create a builder to help you perform the following task:
3459    ///
3460    /// Disables a processor
3461    ///
3462    /// # Arguments
3463    ///
3464    /// * `request` - No description provided.
3465    /// * `name` - Required. The processor resource name to be disabled.
3466    pub fn locations_processors_disable(
3467        &self,
3468        request: GoogleCloudDocumentaiV1DisableProcessorRequest,
3469        name: &str,
3470    ) -> ProjectLocationProcessorDisableCall<'a, C> {
3471        ProjectLocationProcessorDisableCall {
3472            hub: self.hub,
3473            _request: request,
3474            _name: name.to_string(),
3475            _delegate: Default::default(),
3476            _additional_params: Default::default(),
3477            _scopes: Default::default(),
3478        }
3479    }
3480
3481    /// Create a builder to help you perform the following task:
3482    ///
3483    /// Enables a processor
3484    ///
3485    /// # Arguments
3486    ///
3487    /// * `request` - No description provided.
3488    /// * `name` - Required. The processor resource name to be enabled.
3489    pub fn locations_processors_enable(
3490        &self,
3491        request: GoogleCloudDocumentaiV1EnableProcessorRequest,
3492        name: &str,
3493    ) -> ProjectLocationProcessorEnableCall<'a, C> {
3494        ProjectLocationProcessorEnableCall {
3495            hub: self.hub,
3496            _request: request,
3497            _name: name.to_string(),
3498            _delegate: Default::default(),
3499            _additional_params: Default::default(),
3500            _scopes: Default::default(),
3501        }
3502    }
3503
3504    /// Create a builder to help you perform the following task:
3505    ///
3506    /// Gets a processor detail.
3507    ///
3508    /// # Arguments
3509    ///
3510    /// * `name` - Required. The processor resource name.
3511    pub fn locations_processors_get(&self, name: &str) -> ProjectLocationProcessorGetCall<'a, C> {
3512        ProjectLocationProcessorGetCall {
3513            hub: self.hub,
3514            _name: name.to_string(),
3515            _delegate: Default::default(),
3516            _additional_params: Default::default(),
3517            _scopes: Default::default(),
3518        }
3519    }
3520
3521    /// Create a builder to help you perform the following task:
3522    ///
3523    /// Lists all processors which belong to this project.
3524    ///
3525    /// # Arguments
3526    ///
3527    /// * `parent` - Required. The parent (project and location) which owns this collection of Processors. Format: `projects/{project}/locations/{location}`
3528    pub fn locations_processors_list(
3529        &self,
3530        parent: &str,
3531    ) -> ProjectLocationProcessorListCall<'a, C> {
3532        ProjectLocationProcessorListCall {
3533            hub: self.hub,
3534            _parent: parent.to_string(),
3535            _page_token: Default::default(),
3536            _page_size: Default::default(),
3537            _delegate: Default::default(),
3538            _additional_params: Default::default(),
3539            _scopes: Default::default(),
3540        }
3541    }
3542
3543    /// Create a builder to help you perform the following task:
3544    ///
3545    /// Processes a single document.
3546    ///
3547    /// # Arguments
3548    ///
3549    /// * `request` - No description provided.
3550    /// * `name` - Required. The resource name of the Processor or ProcessorVersion to use for processing. If a Processor is specified, the server will use its default version. Format: `projects/{project}/locations/{location}/processors/{processor}`, or `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`
3551    pub fn locations_processors_process(
3552        &self,
3553        request: GoogleCloudDocumentaiV1ProcessRequest,
3554        name: &str,
3555    ) -> ProjectLocationProcessorProcesCall<'a, C> {
3556        ProjectLocationProcessorProcesCall {
3557            hub: self.hub,
3558            _request: request,
3559            _name: name.to_string(),
3560            _delegate: Default::default(),
3561            _additional_params: Default::default(),
3562            _scopes: Default::default(),
3563        }
3564    }
3565
3566    /// Create a builder to help you perform the following task:
3567    ///
3568    /// Set the default (active) version of a Processor that will be used in ProcessDocument and BatchProcessDocuments.
3569    ///
3570    /// # Arguments
3571    ///
3572    /// * `request` - No description provided.
3573    /// * `processor` - Required. The resource name of the Processor to change default version.
3574    pub fn locations_processors_set_default_processor_version(
3575        &self,
3576        request: GoogleCloudDocumentaiV1SetDefaultProcessorVersionRequest,
3577        processor: &str,
3578    ) -> ProjectLocationProcessorSetDefaultProcessorVersionCall<'a, C> {
3579        ProjectLocationProcessorSetDefaultProcessorVersionCall {
3580            hub: self.hub,
3581            _request: request,
3582            _processor: processor.to_string(),
3583            _delegate: Default::default(),
3584            _additional_params: Default::default(),
3585            _scopes: Default::default(),
3586        }
3587    }
3588
3589    /// Create a builder to help you perform the following task:
3590    ///
3591    /// Fetches processor types. Note that we don't use ListProcessorTypes here, because it isn't paginated.
3592    ///
3593    /// # Arguments
3594    ///
3595    /// * `parent` - Required. The location of processor types to list. Format: `projects/{project}/locations/{location}`.
3596    pub fn locations_fetch_processor_types(
3597        &self,
3598        parent: &str,
3599    ) -> ProjectLocationFetchProcessorTypeCall<'a, C> {
3600        ProjectLocationFetchProcessorTypeCall {
3601            hub: self.hub,
3602            _parent: parent.to_string(),
3603            _delegate: Default::default(),
3604            _additional_params: Default::default(),
3605            _scopes: Default::default(),
3606        }
3607    }
3608
3609    /// Create a builder to help you perform the following task:
3610    ///
3611    /// Gets information about a location.
3612    ///
3613    /// # Arguments
3614    ///
3615    /// * `name` - Resource name for the location.
3616    pub fn locations_get(&self, name: &str) -> ProjectLocationGetCall<'a, C> {
3617        ProjectLocationGetCall {
3618            hub: self.hub,
3619            _name: name.to_string(),
3620            _delegate: Default::default(),
3621            _additional_params: Default::default(),
3622            _scopes: Default::default(),
3623        }
3624    }
3625
3626    /// Create a builder to help you perform the following task:
3627    ///
3628    /// Lists information about the supported locations for this service.
3629    ///
3630    /// # Arguments
3631    ///
3632    /// * `name` - The resource that owns the locations collection, if applicable.
3633    pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C> {
3634        ProjectLocationListCall {
3635            hub: self.hub,
3636            _name: name.to_string(),
3637            _page_token: Default::default(),
3638            _page_size: Default::default(),
3639            _filter: Default::default(),
3640            _delegate: Default::default(),
3641            _additional_params: Default::default(),
3642            _scopes: Default::default(),
3643        }
3644    }
3645
3646    /// Create a builder to help you perform the following task:
3647    ///
3648    /// 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.
3649    ///
3650    /// # Arguments
3651    ///
3652    /// * `name` - The name of the operation resource.
3653    pub fn operations_get(&self, name: &str) -> ProjectOperationGetCall<'a, C> {
3654        ProjectOperationGetCall {
3655            hub: self.hub,
3656            _name: name.to_string(),
3657            _delegate: Default::default(),
3658            _additional_params: Default::default(),
3659            _scopes: Default::default(),
3660        }
3661    }
3662}
3663
3664// ###################
3665// CallBuilders   ###
3666// #################
3667
3668/// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`.
3669///
3670/// A builder for the *delete* method supported by a *operation* resource.
3671/// It is not used directly, but through a [`OperationMethods`] instance.
3672///
3673/// # Example
3674///
3675/// Instantiate a resource method builder
3676///
3677/// ```test_harness,no_run
3678/// # extern crate hyper;
3679/// # extern crate hyper_rustls;
3680/// # extern crate google_documentai1 as documentai1;
3681/// # async fn dox() {
3682/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3683///
3684/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3685/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3686/// #     secret,
3687/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3688/// # ).build().await.unwrap();
3689///
3690/// # let client = hyper_util::client::legacy::Client::builder(
3691/// #     hyper_util::rt::TokioExecutor::new()
3692/// # )
3693/// # .build(
3694/// #     hyper_rustls::HttpsConnectorBuilder::new()
3695/// #         .with_native_roots()
3696/// #         .unwrap()
3697/// #         .https_or_http()
3698/// #         .enable_http1()
3699/// #         .build()
3700/// # );
3701/// # let mut hub = Document::new(client, auth);
3702/// // You can configure optional parameters by calling the respective setters at will, and
3703/// // execute the final call using `doit()`.
3704/// // Values shown here are possibly random and not representative !
3705/// let result = hub.operations().delete("name")
3706///              .doit().await;
3707/// # }
3708/// ```
3709pub struct OperationDeleteCall<'a, C>
3710where
3711    C: 'a,
3712{
3713    hub: &'a Document<C>,
3714    _name: String,
3715    _delegate: Option<&'a mut dyn common::Delegate>,
3716    _additional_params: HashMap<String, String>,
3717    _scopes: BTreeSet<String>,
3718}
3719
3720impl<'a, C> common::CallBuilder for OperationDeleteCall<'a, C> {}
3721
3722impl<'a, C> OperationDeleteCall<'a, C>
3723where
3724    C: common::Connector,
3725{
3726    /// Perform the operation you have build so far.
3727    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleProtobufEmpty)> {
3728        use std::borrow::Cow;
3729        use std::io::{Read, Seek};
3730
3731        use common::{url::Params, ToParts};
3732        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3733
3734        let mut dd = common::DefaultDelegate;
3735        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3736        dlg.begin(common::MethodInfo {
3737            id: "documentai.operations.delete",
3738            http_method: hyper::Method::DELETE,
3739        });
3740
3741        for &field in ["alt", "name"].iter() {
3742            if self._additional_params.contains_key(field) {
3743                dlg.finished(false);
3744                return Err(common::Error::FieldClash(field));
3745            }
3746        }
3747
3748        let mut params = Params::with_capacity(3 + self._additional_params.len());
3749        params.push("name", self._name);
3750
3751        params.extend(self._additional_params.iter());
3752
3753        params.push("alt", "json");
3754        let mut url = self.hub._base_url.clone() + "v1/{+name}";
3755        if self._scopes.is_empty() {
3756            self._scopes
3757                .insert(Scope::CloudPlatform.as_ref().to_string());
3758        }
3759
3760        #[allow(clippy::single_element_loop)]
3761        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3762            url = params.uri_replacement(url, param_name, find_this, true);
3763        }
3764        {
3765            let to_remove = ["name"];
3766            params.remove_params(&to_remove);
3767        }
3768
3769        let url = params.parse_with_url(&url);
3770
3771        loop {
3772            let token = match self
3773                .hub
3774                .auth
3775                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3776                .await
3777            {
3778                Ok(token) => token,
3779                Err(e) => match dlg.token(e) {
3780                    Ok(token) => token,
3781                    Err(e) => {
3782                        dlg.finished(false);
3783                        return Err(common::Error::MissingToken(e));
3784                    }
3785                },
3786            };
3787            let mut req_result = {
3788                let client = &self.hub.client;
3789                dlg.pre_request();
3790                let mut req_builder = hyper::Request::builder()
3791                    .method(hyper::Method::DELETE)
3792                    .uri(url.as_str())
3793                    .header(USER_AGENT, self.hub._user_agent.clone());
3794
3795                if let Some(token) = token.as_ref() {
3796                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3797                }
3798
3799                let request = req_builder
3800                    .header(CONTENT_LENGTH, 0_u64)
3801                    .body(common::to_body::<String>(None));
3802
3803                client.request(request.unwrap()).await
3804            };
3805
3806            match req_result {
3807                Err(err) => {
3808                    if let common::Retry::After(d) = dlg.http_error(&err) {
3809                        sleep(d).await;
3810                        continue;
3811                    }
3812                    dlg.finished(false);
3813                    return Err(common::Error::HttpError(err));
3814                }
3815                Ok(res) => {
3816                    let (mut parts, body) = res.into_parts();
3817                    let mut body = common::Body::new(body);
3818                    if !parts.status.is_success() {
3819                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3820                        let error = serde_json::from_str(&common::to_string(&bytes));
3821                        let response = common::to_response(parts, bytes.into());
3822
3823                        if let common::Retry::After(d) =
3824                            dlg.http_failure(&response, error.as_ref().ok())
3825                        {
3826                            sleep(d).await;
3827                            continue;
3828                        }
3829
3830                        dlg.finished(false);
3831
3832                        return Err(match error {
3833                            Ok(value) => common::Error::BadRequest(value),
3834                            _ => common::Error::Failure(response),
3835                        });
3836                    }
3837                    let response = {
3838                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3839                        let encoded = common::to_string(&bytes);
3840                        match serde_json::from_str(&encoded) {
3841                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3842                            Err(error) => {
3843                                dlg.response_json_decode_error(&encoded, &error);
3844                                return Err(common::Error::JsonDecodeError(
3845                                    encoded.to_string(),
3846                                    error,
3847                                ));
3848                            }
3849                        }
3850                    };
3851
3852                    dlg.finished(true);
3853                    return Ok(response);
3854                }
3855            }
3856        }
3857    }
3858
3859    /// The name of the operation resource to be deleted.
3860    ///
3861    /// Sets the *name* path property to the given value.
3862    ///
3863    /// Even though the property as already been set when instantiating this call,
3864    /// we provide this method for API completeness.
3865    pub fn name(mut self, new_value: &str) -> OperationDeleteCall<'a, C> {
3866        self._name = new_value.to_string();
3867        self
3868    }
3869    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3870    /// while executing the actual API request.
3871    ///
3872    /// ````text
3873    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3874    /// ````
3875    ///
3876    /// Sets the *delegate* property to the given value.
3877    pub fn delegate(
3878        mut self,
3879        new_value: &'a mut dyn common::Delegate,
3880    ) -> OperationDeleteCall<'a, C> {
3881        self._delegate = Some(new_value);
3882        self
3883    }
3884
3885    /// Set any additional parameter of the query string used in the request.
3886    /// It should be used to set parameters which are not yet available through their own
3887    /// setters.
3888    ///
3889    /// Please note that this method must not be used to set any of the known parameters
3890    /// which have their own setter method. If done anyway, the request will fail.
3891    ///
3892    /// # Additional Parameters
3893    ///
3894    /// * *$.xgafv* (query-string) - V1 error format.
3895    /// * *access_token* (query-string) - OAuth access token.
3896    /// * *alt* (query-string) - Data format for response.
3897    /// * *callback* (query-string) - JSONP
3898    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3899    /// * *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.
3900    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3901    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3902    /// * *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.
3903    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3904    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3905    pub fn param<T>(mut self, name: T, value: T) -> OperationDeleteCall<'a, C>
3906    where
3907        T: AsRef<str>,
3908    {
3909        self._additional_params
3910            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3911        self
3912    }
3913
3914    /// Identifies the authorization scope for the method you are building.
3915    ///
3916    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3917    /// [`Scope::CloudPlatform`].
3918    ///
3919    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3920    /// tokens for more than one scope.
3921    ///
3922    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3923    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3924    /// sufficient, a read-write scope will do as well.
3925    pub fn add_scope<St>(mut self, scope: St) -> OperationDeleteCall<'a, C>
3926    where
3927        St: AsRef<str>,
3928    {
3929        self._scopes.insert(String::from(scope.as_ref()));
3930        self
3931    }
3932    /// Identifies the authorization scope(s) for the method you are building.
3933    ///
3934    /// See [`Self::add_scope()`] for details.
3935    pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationDeleteCall<'a, C>
3936    where
3937        I: IntoIterator<Item = St>,
3938        St: AsRef<str>,
3939    {
3940        self._scopes
3941            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3942        self
3943    }
3944
3945    /// Removes all scopes, and no default scope will be used either.
3946    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3947    /// for details).
3948    pub fn clear_scopes(mut self) -> OperationDeleteCall<'a, C> {
3949        self._scopes.clear();
3950        self
3951    }
3952}
3953
3954/// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of 1, corresponding to `Code.CANCELLED`.
3955///
3956/// A builder for the *locations.operations.cancel* method supported by a *project* resource.
3957/// It is not used directly, but through a [`ProjectMethods`] instance.
3958///
3959/// # Example
3960///
3961/// Instantiate a resource method builder
3962///
3963/// ```test_harness,no_run
3964/// # extern crate hyper;
3965/// # extern crate hyper_rustls;
3966/// # extern crate google_documentai1 as documentai1;
3967/// # async fn dox() {
3968/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3969///
3970/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3971/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3972/// #     secret,
3973/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3974/// # ).build().await.unwrap();
3975///
3976/// # let client = hyper_util::client::legacy::Client::builder(
3977/// #     hyper_util::rt::TokioExecutor::new()
3978/// # )
3979/// # .build(
3980/// #     hyper_rustls::HttpsConnectorBuilder::new()
3981/// #         .with_native_roots()
3982/// #         .unwrap()
3983/// #         .https_or_http()
3984/// #         .enable_http1()
3985/// #         .build()
3986/// # );
3987/// # let mut hub = Document::new(client, auth);
3988/// // You can configure optional parameters by calling the respective setters at will, and
3989/// // execute the final call using `doit()`.
3990/// // Values shown here are possibly random and not representative !
3991/// let result = hub.projects().locations_operations_cancel("name")
3992///              .doit().await;
3993/// # }
3994/// ```
3995pub struct ProjectLocationOperationCancelCall<'a, C>
3996where
3997    C: 'a,
3998{
3999    hub: &'a Document<C>,
4000    _name: String,
4001    _delegate: Option<&'a mut dyn common::Delegate>,
4002    _additional_params: HashMap<String, String>,
4003    _scopes: BTreeSet<String>,
4004}
4005
4006impl<'a, C> common::CallBuilder for ProjectLocationOperationCancelCall<'a, C> {}
4007
4008impl<'a, C> ProjectLocationOperationCancelCall<'a, C>
4009where
4010    C: common::Connector,
4011{
4012    /// Perform the operation you have build so far.
4013    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleProtobufEmpty)> {
4014        use std::borrow::Cow;
4015        use std::io::{Read, Seek};
4016
4017        use common::{url::Params, ToParts};
4018        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4019
4020        let mut dd = common::DefaultDelegate;
4021        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4022        dlg.begin(common::MethodInfo {
4023            id: "documentai.projects.locations.operations.cancel",
4024            http_method: hyper::Method::POST,
4025        });
4026
4027        for &field in ["alt", "name"].iter() {
4028            if self._additional_params.contains_key(field) {
4029                dlg.finished(false);
4030                return Err(common::Error::FieldClash(field));
4031            }
4032        }
4033
4034        let mut params = Params::with_capacity(3 + self._additional_params.len());
4035        params.push("name", self._name);
4036
4037        params.extend(self._additional_params.iter());
4038
4039        params.push("alt", "json");
4040        let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
4041        if self._scopes.is_empty() {
4042            self._scopes
4043                .insert(Scope::CloudPlatform.as_ref().to_string());
4044        }
4045
4046        #[allow(clippy::single_element_loop)]
4047        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4048            url = params.uri_replacement(url, param_name, find_this, true);
4049        }
4050        {
4051            let to_remove = ["name"];
4052            params.remove_params(&to_remove);
4053        }
4054
4055        let url = params.parse_with_url(&url);
4056
4057        loop {
4058            let token = match self
4059                .hub
4060                .auth
4061                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4062                .await
4063            {
4064                Ok(token) => token,
4065                Err(e) => match dlg.token(e) {
4066                    Ok(token) => token,
4067                    Err(e) => {
4068                        dlg.finished(false);
4069                        return Err(common::Error::MissingToken(e));
4070                    }
4071                },
4072            };
4073            let mut req_result = {
4074                let client = &self.hub.client;
4075                dlg.pre_request();
4076                let mut req_builder = hyper::Request::builder()
4077                    .method(hyper::Method::POST)
4078                    .uri(url.as_str())
4079                    .header(USER_AGENT, self.hub._user_agent.clone());
4080
4081                if let Some(token) = token.as_ref() {
4082                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4083                }
4084
4085                let request = req_builder
4086                    .header(CONTENT_LENGTH, 0_u64)
4087                    .body(common::to_body::<String>(None));
4088
4089                client.request(request.unwrap()).await
4090            };
4091
4092            match req_result {
4093                Err(err) => {
4094                    if let common::Retry::After(d) = dlg.http_error(&err) {
4095                        sleep(d).await;
4096                        continue;
4097                    }
4098                    dlg.finished(false);
4099                    return Err(common::Error::HttpError(err));
4100                }
4101                Ok(res) => {
4102                    let (mut parts, body) = res.into_parts();
4103                    let mut body = common::Body::new(body);
4104                    if !parts.status.is_success() {
4105                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4106                        let error = serde_json::from_str(&common::to_string(&bytes));
4107                        let response = common::to_response(parts, bytes.into());
4108
4109                        if let common::Retry::After(d) =
4110                            dlg.http_failure(&response, error.as_ref().ok())
4111                        {
4112                            sleep(d).await;
4113                            continue;
4114                        }
4115
4116                        dlg.finished(false);
4117
4118                        return Err(match error {
4119                            Ok(value) => common::Error::BadRequest(value),
4120                            _ => common::Error::Failure(response),
4121                        });
4122                    }
4123                    let response = {
4124                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4125                        let encoded = common::to_string(&bytes);
4126                        match serde_json::from_str(&encoded) {
4127                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4128                            Err(error) => {
4129                                dlg.response_json_decode_error(&encoded, &error);
4130                                return Err(common::Error::JsonDecodeError(
4131                                    encoded.to_string(),
4132                                    error,
4133                                ));
4134                            }
4135                        }
4136                    };
4137
4138                    dlg.finished(true);
4139                    return Ok(response);
4140                }
4141            }
4142        }
4143    }
4144
4145    /// The name of the operation resource to be cancelled.
4146    ///
4147    /// Sets the *name* path property to the given value.
4148    ///
4149    /// Even though the property as already been set when instantiating this call,
4150    /// we provide this method for API completeness.
4151    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationCancelCall<'a, C> {
4152        self._name = new_value.to_string();
4153        self
4154    }
4155    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4156    /// while executing the actual API request.
4157    ///
4158    /// ````text
4159    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4160    /// ````
4161    ///
4162    /// Sets the *delegate* property to the given value.
4163    pub fn delegate(
4164        mut self,
4165        new_value: &'a mut dyn common::Delegate,
4166    ) -> ProjectLocationOperationCancelCall<'a, C> {
4167        self._delegate = Some(new_value);
4168        self
4169    }
4170
4171    /// Set any additional parameter of the query string used in the request.
4172    /// It should be used to set parameters which are not yet available through their own
4173    /// setters.
4174    ///
4175    /// Please note that this method must not be used to set any of the known parameters
4176    /// which have their own setter method. If done anyway, the request will fail.
4177    ///
4178    /// # Additional Parameters
4179    ///
4180    /// * *$.xgafv* (query-string) - V1 error format.
4181    /// * *access_token* (query-string) - OAuth access token.
4182    /// * *alt* (query-string) - Data format for response.
4183    /// * *callback* (query-string) - JSONP
4184    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4185    /// * *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.
4186    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4187    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4188    /// * *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.
4189    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4190    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4191    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationCancelCall<'a, C>
4192    where
4193        T: AsRef<str>,
4194    {
4195        self._additional_params
4196            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4197        self
4198    }
4199
4200    /// Identifies the authorization scope for the method you are building.
4201    ///
4202    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4203    /// [`Scope::CloudPlatform`].
4204    ///
4205    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4206    /// tokens for more than one scope.
4207    ///
4208    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4209    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4210    /// sufficient, a read-write scope will do as well.
4211    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationCancelCall<'a, C>
4212    where
4213        St: AsRef<str>,
4214    {
4215        self._scopes.insert(String::from(scope.as_ref()));
4216        self
4217    }
4218    /// Identifies the authorization scope(s) for the method you are building.
4219    ///
4220    /// See [`Self::add_scope()`] for details.
4221    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationCancelCall<'a, C>
4222    where
4223        I: IntoIterator<Item = St>,
4224        St: AsRef<str>,
4225    {
4226        self._scopes
4227            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4228        self
4229    }
4230
4231    /// Removes all scopes, and no default scope will be used either.
4232    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4233    /// for details).
4234    pub fn clear_scopes(mut self) -> ProjectLocationOperationCancelCall<'a, C> {
4235        self._scopes.clear();
4236        self
4237    }
4238}
4239
4240/// 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.
4241///
4242/// A builder for the *locations.operations.get* method supported by a *project* resource.
4243/// It is not used directly, but through a [`ProjectMethods`] instance.
4244///
4245/// # Example
4246///
4247/// Instantiate a resource method builder
4248///
4249/// ```test_harness,no_run
4250/// # extern crate hyper;
4251/// # extern crate hyper_rustls;
4252/// # extern crate google_documentai1 as documentai1;
4253/// # async fn dox() {
4254/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4255///
4256/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4257/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4258/// #     secret,
4259/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4260/// # ).build().await.unwrap();
4261///
4262/// # let client = hyper_util::client::legacy::Client::builder(
4263/// #     hyper_util::rt::TokioExecutor::new()
4264/// # )
4265/// # .build(
4266/// #     hyper_rustls::HttpsConnectorBuilder::new()
4267/// #         .with_native_roots()
4268/// #         .unwrap()
4269/// #         .https_or_http()
4270/// #         .enable_http1()
4271/// #         .build()
4272/// # );
4273/// # let mut hub = Document::new(client, auth);
4274/// // You can configure optional parameters by calling the respective setters at will, and
4275/// // execute the final call using `doit()`.
4276/// // Values shown here are possibly random and not representative !
4277/// let result = hub.projects().locations_operations_get("name")
4278///              .doit().await;
4279/// # }
4280/// ```
4281pub struct ProjectLocationOperationGetCall<'a, C>
4282where
4283    C: 'a,
4284{
4285    hub: &'a Document<C>,
4286    _name: String,
4287    _delegate: Option<&'a mut dyn common::Delegate>,
4288    _additional_params: HashMap<String, String>,
4289    _scopes: BTreeSet<String>,
4290}
4291
4292impl<'a, C> common::CallBuilder for ProjectLocationOperationGetCall<'a, C> {}
4293
4294impl<'a, C> ProjectLocationOperationGetCall<'a, C>
4295where
4296    C: common::Connector,
4297{
4298    /// Perform the operation you have build so far.
4299    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
4300        use std::borrow::Cow;
4301        use std::io::{Read, Seek};
4302
4303        use common::{url::Params, ToParts};
4304        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4305
4306        let mut dd = common::DefaultDelegate;
4307        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4308        dlg.begin(common::MethodInfo {
4309            id: "documentai.projects.locations.operations.get",
4310            http_method: hyper::Method::GET,
4311        });
4312
4313        for &field in ["alt", "name"].iter() {
4314            if self._additional_params.contains_key(field) {
4315                dlg.finished(false);
4316                return Err(common::Error::FieldClash(field));
4317            }
4318        }
4319
4320        let mut params = Params::with_capacity(3 + self._additional_params.len());
4321        params.push("name", self._name);
4322
4323        params.extend(self._additional_params.iter());
4324
4325        params.push("alt", "json");
4326        let mut url = self.hub._base_url.clone() + "v1/{+name}";
4327        if self._scopes.is_empty() {
4328            self._scopes
4329                .insert(Scope::CloudPlatform.as_ref().to_string());
4330        }
4331
4332        #[allow(clippy::single_element_loop)]
4333        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4334            url = params.uri_replacement(url, param_name, find_this, true);
4335        }
4336        {
4337            let to_remove = ["name"];
4338            params.remove_params(&to_remove);
4339        }
4340
4341        let url = params.parse_with_url(&url);
4342
4343        loop {
4344            let token = match self
4345                .hub
4346                .auth
4347                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4348                .await
4349            {
4350                Ok(token) => token,
4351                Err(e) => match dlg.token(e) {
4352                    Ok(token) => token,
4353                    Err(e) => {
4354                        dlg.finished(false);
4355                        return Err(common::Error::MissingToken(e));
4356                    }
4357                },
4358            };
4359            let mut req_result = {
4360                let client = &self.hub.client;
4361                dlg.pre_request();
4362                let mut req_builder = hyper::Request::builder()
4363                    .method(hyper::Method::GET)
4364                    .uri(url.as_str())
4365                    .header(USER_AGENT, self.hub._user_agent.clone());
4366
4367                if let Some(token) = token.as_ref() {
4368                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4369                }
4370
4371                let request = req_builder
4372                    .header(CONTENT_LENGTH, 0_u64)
4373                    .body(common::to_body::<String>(None));
4374
4375                client.request(request.unwrap()).await
4376            };
4377
4378            match req_result {
4379                Err(err) => {
4380                    if let common::Retry::After(d) = dlg.http_error(&err) {
4381                        sleep(d).await;
4382                        continue;
4383                    }
4384                    dlg.finished(false);
4385                    return Err(common::Error::HttpError(err));
4386                }
4387                Ok(res) => {
4388                    let (mut parts, body) = res.into_parts();
4389                    let mut body = common::Body::new(body);
4390                    if !parts.status.is_success() {
4391                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4392                        let error = serde_json::from_str(&common::to_string(&bytes));
4393                        let response = common::to_response(parts, bytes.into());
4394
4395                        if let common::Retry::After(d) =
4396                            dlg.http_failure(&response, error.as_ref().ok())
4397                        {
4398                            sleep(d).await;
4399                            continue;
4400                        }
4401
4402                        dlg.finished(false);
4403
4404                        return Err(match error {
4405                            Ok(value) => common::Error::BadRequest(value),
4406                            _ => common::Error::Failure(response),
4407                        });
4408                    }
4409                    let response = {
4410                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4411                        let encoded = common::to_string(&bytes);
4412                        match serde_json::from_str(&encoded) {
4413                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4414                            Err(error) => {
4415                                dlg.response_json_decode_error(&encoded, &error);
4416                                return Err(common::Error::JsonDecodeError(
4417                                    encoded.to_string(),
4418                                    error,
4419                                ));
4420                            }
4421                        }
4422                    };
4423
4424                    dlg.finished(true);
4425                    return Ok(response);
4426                }
4427            }
4428        }
4429    }
4430
4431    /// The name of the operation resource.
4432    ///
4433    /// Sets the *name* path property to the given value.
4434    ///
4435    /// Even though the property as already been set when instantiating this call,
4436    /// we provide this method for API completeness.
4437    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationGetCall<'a, C> {
4438        self._name = new_value.to_string();
4439        self
4440    }
4441    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4442    /// while executing the actual API request.
4443    ///
4444    /// ````text
4445    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4446    /// ````
4447    ///
4448    /// Sets the *delegate* property to the given value.
4449    pub fn delegate(
4450        mut self,
4451        new_value: &'a mut dyn common::Delegate,
4452    ) -> ProjectLocationOperationGetCall<'a, C> {
4453        self._delegate = Some(new_value);
4454        self
4455    }
4456
4457    /// Set any additional parameter of the query string used in the request.
4458    /// It should be used to set parameters which are not yet available through their own
4459    /// setters.
4460    ///
4461    /// Please note that this method must not be used to set any of the known parameters
4462    /// which have their own setter method. If done anyway, the request will fail.
4463    ///
4464    /// # Additional Parameters
4465    ///
4466    /// * *$.xgafv* (query-string) - V1 error format.
4467    /// * *access_token* (query-string) - OAuth access token.
4468    /// * *alt* (query-string) - Data format for response.
4469    /// * *callback* (query-string) - JSONP
4470    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4471    /// * *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.
4472    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4473    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4474    /// * *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.
4475    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4476    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4477    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationGetCall<'a, C>
4478    where
4479        T: AsRef<str>,
4480    {
4481        self._additional_params
4482            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4483        self
4484    }
4485
4486    /// Identifies the authorization scope for the method you are building.
4487    ///
4488    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4489    /// [`Scope::CloudPlatform`].
4490    ///
4491    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4492    /// tokens for more than one scope.
4493    ///
4494    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4495    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4496    /// sufficient, a read-write scope will do as well.
4497    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationGetCall<'a, C>
4498    where
4499        St: AsRef<str>,
4500    {
4501        self._scopes.insert(String::from(scope.as_ref()));
4502        self
4503    }
4504    /// Identifies the authorization scope(s) for the method you are building.
4505    ///
4506    /// See [`Self::add_scope()`] for details.
4507    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationGetCall<'a, C>
4508    where
4509        I: IntoIterator<Item = St>,
4510        St: AsRef<str>,
4511    {
4512        self._scopes
4513            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4514        self
4515    }
4516
4517    /// Removes all scopes, and no default scope will be used either.
4518    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4519    /// for details).
4520    pub fn clear_scopes(mut self) -> ProjectLocationOperationGetCall<'a, C> {
4521        self._scopes.clear();
4522        self
4523    }
4524}
4525
4526/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
4527///
4528/// A builder for the *locations.operations.list* method supported by a *project* resource.
4529/// It is not used directly, but through a [`ProjectMethods`] instance.
4530///
4531/// # Example
4532///
4533/// Instantiate a resource method builder
4534///
4535/// ```test_harness,no_run
4536/// # extern crate hyper;
4537/// # extern crate hyper_rustls;
4538/// # extern crate google_documentai1 as documentai1;
4539/// # async fn dox() {
4540/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4541///
4542/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4543/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4544/// #     secret,
4545/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4546/// # ).build().await.unwrap();
4547///
4548/// # let client = hyper_util::client::legacy::Client::builder(
4549/// #     hyper_util::rt::TokioExecutor::new()
4550/// # )
4551/// # .build(
4552/// #     hyper_rustls::HttpsConnectorBuilder::new()
4553/// #         .with_native_roots()
4554/// #         .unwrap()
4555/// #         .https_or_http()
4556/// #         .enable_http1()
4557/// #         .build()
4558/// # );
4559/// # let mut hub = Document::new(client, auth);
4560/// // You can configure optional parameters by calling the respective setters at will, and
4561/// // execute the final call using `doit()`.
4562/// // Values shown here are possibly random and not representative !
4563/// let result = hub.projects().locations_operations_list("name")
4564///              .page_token("sed")
4565///              .page_size(-2)
4566///              .filter("takimata")
4567///              .doit().await;
4568/// # }
4569/// ```
4570pub struct ProjectLocationOperationListCall<'a, C>
4571where
4572    C: 'a,
4573{
4574    hub: &'a Document<C>,
4575    _name: String,
4576    _page_token: Option<String>,
4577    _page_size: Option<i32>,
4578    _filter: Option<String>,
4579    _delegate: Option<&'a mut dyn common::Delegate>,
4580    _additional_params: HashMap<String, String>,
4581    _scopes: BTreeSet<String>,
4582}
4583
4584impl<'a, C> common::CallBuilder for ProjectLocationOperationListCall<'a, C> {}
4585
4586impl<'a, C> ProjectLocationOperationListCall<'a, C>
4587where
4588    C: common::Connector,
4589{
4590    /// Perform the operation you have build so far.
4591    pub async fn doit(
4592        mut self,
4593    ) -> common::Result<(common::Response, GoogleLongrunningListOperationsResponse)> {
4594        use std::borrow::Cow;
4595        use std::io::{Read, Seek};
4596
4597        use common::{url::Params, ToParts};
4598        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4599
4600        let mut dd = common::DefaultDelegate;
4601        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4602        dlg.begin(common::MethodInfo {
4603            id: "documentai.projects.locations.operations.list",
4604            http_method: hyper::Method::GET,
4605        });
4606
4607        for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
4608            if self._additional_params.contains_key(field) {
4609                dlg.finished(false);
4610                return Err(common::Error::FieldClash(field));
4611            }
4612        }
4613
4614        let mut params = Params::with_capacity(6 + self._additional_params.len());
4615        params.push("name", self._name);
4616        if let Some(value) = self._page_token.as_ref() {
4617            params.push("pageToken", value);
4618        }
4619        if let Some(value) = self._page_size.as_ref() {
4620            params.push("pageSize", value.to_string());
4621        }
4622        if let Some(value) = self._filter.as_ref() {
4623            params.push("filter", value);
4624        }
4625
4626        params.extend(self._additional_params.iter());
4627
4628        params.push("alt", "json");
4629        let mut url = self.hub._base_url.clone() + "v1/{+name}";
4630        if self._scopes.is_empty() {
4631            self._scopes
4632                .insert(Scope::CloudPlatform.as_ref().to_string());
4633        }
4634
4635        #[allow(clippy::single_element_loop)]
4636        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4637            url = params.uri_replacement(url, param_name, find_this, true);
4638        }
4639        {
4640            let to_remove = ["name"];
4641            params.remove_params(&to_remove);
4642        }
4643
4644        let url = params.parse_with_url(&url);
4645
4646        loop {
4647            let token = match self
4648                .hub
4649                .auth
4650                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4651                .await
4652            {
4653                Ok(token) => token,
4654                Err(e) => match dlg.token(e) {
4655                    Ok(token) => token,
4656                    Err(e) => {
4657                        dlg.finished(false);
4658                        return Err(common::Error::MissingToken(e));
4659                    }
4660                },
4661            };
4662            let mut req_result = {
4663                let client = &self.hub.client;
4664                dlg.pre_request();
4665                let mut req_builder = hyper::Request::builder()
4666                    .method(hyper::Method::GET)
4667                    .uri(url.as_str())
4668                    .header(USER_AGENT, self.hub._user_agent.clone());
4669
4670                if let Some(token) = token.as_ref() {
4671                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4672                }
4673
4674                let request = req_builder
4675                    .header(CONTENT_LENGTH, 0_u64)
4676                    .body(common::to_body::<String>(None));
4677
4678                client.request(request.unwrap()).await
4679            };
4680
4681            match req_result {
4682                Err(err) => {
4683                    if let common::Retry::After(d) = dlg.http_error(&err) {
4684                        sleep(d).await;
4685                        continue;
4686                    }
4687                    dlg.finished(false);
4688                    return Err(common::Error::HttpError(err));
4689                }
4690                Ok(res) => {
4691                    let (mut parts, body) = res.into_parts();
4692                    let mut body = common::Body::new(body);
4693                    if !parts.status.is_success() {
4694                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4695                        let error = serde_json::from_str(&common::to_string(&bytes));
4696                        let response = common::to_response(parts, bytes.into());
4697
4698                        if let common::Retry::After(d) =
4699                            dlg.http_failure(&response, error.as_ref().ok())
4700                        {
4701                            sleep(d).await;
4702                            continue;
4703                        }
4704
4705                        dlg.finished(false);
4706
4707                        return Err(match error {
4708                            Ok(value) => common::Error::BadRequest(value),
4709                            _ => common::Error::Failure(response),
4710                        });
4711                    }
4712                    let response = {
4713                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4714                        let encoded = common::to_string(&bytes);
4715                        match serde_json::from_str(&encoded) {
4716                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4717                            Err(error) => {
4718                                dlg.response_json_decode_error(&encoded, &error);
4719                                return Err(common::Error::JsonDecodeError(
4720                                    encoded.to_string(),
4721                                    error,
4722                                ));
4723                            }
4724                        }
4725                    };
4726
4727                    dlg.finished(true);
4728                    return Ok(response);
4729                }
4730            }
4731        }
4732    }
4733
4734    /// The name of the operation's parent resource.
4735    ///
4736    /// Sets the *name* path property to the given value.
4737    ///
4738    /// Even though the property as already been set when instantiating this call,
4739    /// we provide this method for API completeness.
4740    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
4741        self._name = new_value.to_string();
4742        self
4743    }
4744    /// The standard list page token.
4745    ///
4746    /// Sets the *page token* query property to the given value.
4747    pub fn page_token(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
4748        self._page_token = Some(new_value.to_string());
4749        self
4750    }
4751    /// The standard list page size.
4752    ///
4753    /// Sets the *page size* query property to the given value.
4754    pub fn page_size(mut self, new_value: i32) -> ProjectLocationOperationListCall<'a, C> {
4755        self._page_size = Some(new_value);
4756        self
4757    }
4758    /// The standard list filter.
4759    ///
4760    /// Sets the *filter* query property to the given value.
4761    pub fn filter(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
4762        self._filter = Some(new_value.to_string());
4763        self
4764    }
4765    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4766    /// while executing the actual API request.
4767    ///
4768    /// ````text
4769    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4770    /// ````
4771    ///
4772    /// Sets the *delegate* property to the given value.
4773    pub fn delegate(
4774        mut self,
4775        new_value: &'a mut dyn common::Delegate,
4776    ) -> ProjectLocationOperationListCall<'a, C> {
4777        self._delegate = Some(new_value);
4778        self
4779    }
4780
4781    /// Set any additional parameter of the query string used in the request.
4782    /// It should be used to set parameters which are not yet available through their own
4783    /// setters.
4784    ///
4785    /// Please note that this method must not be used to set any of the known parameters
4786    /// which have their own setter method. If done anyway, the request will fail.
4787    ///
4788    /// # Additional Parameters
4789    ///
4790    /// * *$.xgafv* (query-string) - V1 error format.
4791    /// * *access_token* (query-string) - OAuth access token.
4792    /// * *alt* (query-string) - Data format for response.
4793    /// * *callback* (query-string) - JSONP
4794    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4795    /// * *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.
4796    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4797    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4798    /// * *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.
4799    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4800    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4801    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationListCall<'a, C>
4802    where
4803        T: AsRef<str>,
4804    {
4805        self._additional_params
4806            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4807        self
4808    }
4809
4810    /// Identifies the authorization scope for the method you are building.
4811    ///
4812    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4813    /// [`Scope::CloudPlatform`].
4814    ///
4815    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4816    /// tokens for more than one scope.
4817    ///
4818    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4819    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4820    /// sufficient, a read-write scope will do as well.
4821    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationListCall<'a, C>
4822    where
4823        St: AsRef<str>,
4824    {
4825        self._scopes.insert(String::from(scope.as_ref()));
4826        self
4827    }
4828    /// Identifies the authorization scope(s) for the method you are building.
4829    ///
4830    /// See [`Self::add_scope()`] for details.
4831    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationListCall<'a, C>
4832    where
4833        I: IntoIterator<Item = St>,
4834        St: AsRef<str>,
4835    {
4836        self._scopes
4837            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4838        self
4839    }
4840
4841    /// Removes all scopes, and no default scope will be used either.
4842    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4843    /// for details).
4844    pub fn clear_scopes(mut self) -> ProjectLocationOperationListCall<'a, C> {
4845        self._scopes.clear();
4846        self
4847    }
4848}
4849
4850/// Gets a processor type detail.
4851///
4852/// A builder for the *locations.processorTypes.get* method supported by a *project* resource.
4853/// It is not used directly, but through a [`ProjectMethods`] instance.
4854///
4855/// # Example
4856///
4857/// Instantiate a resource method builder
4858///
4859/// ```test_harness,no_run
4860/// # extern crate hyper;
4861/// # extern crate hyper_rustls;
4862/// # extern crate google_documentai1 as documentai1;
4863/// # async fn dox() {
4864/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4865///
4866/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4867/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4868/// #     secret,
4869/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4870/// # ).build().await.unwrap();
4871///
4872/// # let client = hyper_util::client::legacy::Client::builder(
4873/// #     hyper_util::rt::TokioExecutor::new()
4874/// # )
4875/// # .build(
4876/// #     hyper_rustls::HttpsConnectorBuilder::new()
4877/// #         .with_native_roots()
4878/// #         .unwrap()
4879/// #         .https_or_http()
4880/// #         .enable_http1()
4881/// #         .build()
4882/// # );
4883/// # let mut hub = Document::new(client, auth);
4884/// // You can configure optional parameters by calling the respective setters at will, and
4885/// // execute the final call using `doit()`.
4886/// // Values shown here are possibly random and not representative !
4887/// let result = hub.projects().locations_processor_types_get("name")
4888///              .doit().await;
4889/// # }
4890/// ```
4891pub struct ProjectLocationProcessorTypeGetCall<'a, C>
4892where
4893    C: 'a,
4894{
4895    hub: &'a Document<C>,
4896    _name: String,
4897    _delegate: Option<&'a mut dyn common::Delegate>,
4898    _additional_params: HashMap<String, String>,
4899    _scopes: BTreeSet<String>,
4900}
4901
4902impl<'a, C> common::CallBuilder for ProjectLocationProcessorTypeGetCall<'a, C> {}
4903
4904impl<'a, C> ProjectLocationProcessorTypeGetCall<'a, C>
4905where
4906    C: common::Connector,
4907{
4908    /// Perform the operation you have build so far.
4909    pub async fn doit(
4910        mut self,
4911    ) -> common::Result<(common::Response, GoogleCloudDocumentaiV1ProcessorType)> {
4912        use std::borrow::Cow;
4913        use std::io::{Read, Seek};
4914
4915        use common::{url::Params, ToParts};
4916        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4917
4918        let mut dd = common::DefaultDelegate;
4919        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4920        dlg.begin(common::MethodInfo {
4921            id: "documentai.projects.locations.processorTypes.get",
4922            http_method: hyper::Method::GET,
4923        });
4924
4925        for &field in ["alt", "name"].iter() {
4926            if self._additional_params.contains_key(field) {
4927                dlg.finished(false);
4928                return Err(common::Error::FieldClash(field));
4929            }
4930        }
4931
4932        let mut params = Params::with_capacity(3 + self._additional_params.len());
4933        params.push("name", self._name);
4934
4935        params.extend(self._additional_params.iter());
4936
4937        params.push("alt", "json");
4938        let mut url = self.hub._base_url.clone() + "v1/{+name}";
4939        if self._scopes.is_empty() {
4940            self._scopes
4941                .insert(Scope::CloudPlatform.as_ref().to_string());
4942        }
4943
4944        #[allow(clippy::single_element_loop)]
4945        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4946            url = params.uri_replacement(url, param_name, find_this, true);
4947        }
4948        {
4949            let to_remove = ["name"];
4950            params.remove_params(&to_remove);
4951        }
4952
4953        let url = params.parse_with_url(&url);
4954
4955        loop {
4956            let token = match self
4957                .hub
4958                .auth
4959                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4960                .await
4961            {
4962                Ok(token) => token,
4963                Err(e) => match dlg.token(e) {
4964                    Ok(token) => token,
4965                    Err(e) => {
4966                        dlg.finished(false);
4967                        return Err(common::Error::MissingToken(e));
4968                    }
4969                },
4970            };
4971            let mut req_result = {
4972                let client = &self.hub.client;
4973                dlg.pre_request();
4974                let mut req_builder = hyper::Request::builder()
4975                    .method(hyper::Method::GET)
4976                    .uri(url.as_str())
4977                    .header(USER_AGENT, self.hub._user_agent.clone());
4978
4979                if let Some(token) = token.as_ref() {
4980                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4981                }
4982
4983                let request = req_builder
4984                    .header(CONTENT_LENGTH, 0_u64)
4985                    .body(common::to_body::<String>(None));
4986
4987                client.request(request.unwrap()).await
4988            };
4989
4990            match req_result {
4991                Err(err) => {
4992                    if let common::Retry::After(d) = dlg.http_error(&err) {
4993                        sleep(d).await;
4994                        continue;
4995                    }
4996                    dlg.finished(false);
4997                    return Err(common::Error::HttpError(err));
4998                }
4999                Ok(res) => {
5000                    let (mut parts, body) = res.into_parts();
5001                    let mut body = common::Body::new(body);
5002                    if !parts.status.is_success() {
5003                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5004                        let error = serde_json::from_str(&common::to_string(&bytes));
5005                        let response = common::to_response(parts, bytes.into());
5006
5007                        if let common::Retry::After(d) =
5008                            dlg.http_failure(&response, error.as_ref().ok())
5009                        {
5010                            sleep(d).await;
5011                            continue;
5012                        }
5013
5014                        dlg.finished(false);
5015
5016                        return Err(match error {
5017                            Ok(value) => common::Error::BadRequest(value),
5018                            _ => common::Error::Failure(response),
5019                        });
5020                    }
5021                    let response = {
5022                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5023                        let encoded = common::to_string(&bytes);
5024                        match serde_json::from_str(&encoded) {
5025                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5026                            Err(error) => {
5027                                dlg.response_json_decode_error(&encoded, &error);
5028                                return Err(common::Error::JsonDecodeError(
5029                                    encoded.to_string(),
5030                                    error,
5031                                ));
5032                            }
5033                        }
5034                    };
5035
5036                    dlg.finished(true);
5037                    return Ok(response);
5038                }
5039            }
5040        }
5041    }
5042
5043    /// Required. The processor type resource name.
5044    ///
5045    /// Sets the *name* path property to the given value.
5046    ///
5047    /// Even though the property as already been set when instantiating this call,
5048    /// we provide this method for API completeness.
5049    pub fn name(mut self, new_value: &str) -> ProjectLocationProcessorTypeGetCall<'a, C> {
5050        self._name = new_value.to_string();
5051        self
5052    }
5053    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5054    /// while executing the actual API request.
5055    ///
5056    /// ````text
5057    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5058    /// ````
5059    ///
5060    /// Sets the *delegate* property to the given value.
5061    pub fn delegate(
5062        mut self,
5063        new_value: &'a mut dyn common::Delegate,
5064    ) -> ProjectLocationProcessorTypeGetCall<'a, C> {
5065        self._delegate = Some(new_value);
5066        self
5067    }
5068
5069    /// Set any additional parameter of the query string used in the request.
5070    /// It should be used to set parameters which are not yet available through their own
5071    /// setters.
5072    ///
5073    /// Please note that this method must not be used to set any of the known parameters
5074    /// which have their own setter method. If done anyway, the request will fail.
5075    ///
5076    /// # Additional Parameters
5077    ///
5078    /// * *$.xgafv* (query-string) - V1 error format.
5079    /// * *access_token* (query-string) - OAuth access token.
5080    /// * *alt* (query-string) - Data format for response.
5081    /// * *callback* (query-string) - JSONP
5082    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5083    /// * *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.
5084    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5085    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5086    /// * *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.
5087    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5088    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5089    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProcessorTypeGetCall<'a, C>
5090    where
5091        T: AsRef<str>,
5092    {
5093        self._additional_params
5094            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5095        self
5096    }
5097
5098    /// Identifies the authorization scope for the method you are building.
5099    ///
5100    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5101    /// [`Scope::CloudPlatform`].
5102    ///
5103    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5104    /// tokens for more than one scope.
5105    ///
5106    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5107    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5108    /// sufficient, a read-write scope will do as well.
5109    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProcessorTypeGetCall<'a, C>
5110    where
5111        St: AsRef<str>,
5112    {
5113        self._scopes.insert(String::from(scope.as_ref()));
5114        self
5115    }
5116    /// Identifies the authorization scope(s) for the method you are building.
5117    ///
5118    /// See [`Self::add_scope()`] for details.
5119    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProcessorTypeGetCall<'a, C>
5120    where
5121        I: IntoIterator<Item = St>,
5122        St: AsRef<str>,
5123    {
5124        self._scopes
5125            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5126        self
5127    }
5128
5129    /// Removes all scopes, and no default scope will be used either.
5130    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5131    /// for details).
5132    pub fn clear_scopes(mut self) -> ProjectLocationProcessorTypeGetCall<'a, C> {
5133        self._scopes.clear();
5134        self
5135    }
5136}
5137
5138/// Lists the processor types that exist.
5139///
5140/// A builder for the *locations.processorTypes.list* method supported by a *project* resource.
5141/// It is not used directly, but through a [`ProjectMethods`] instance.
5142///
5143/// # Example
5144///
5145/// Instantiate a resource method builder
5146///
5147/// ```test_harness,no_run
5148/// # extern crate hyper;
5149/// # extern crate hyper_rustls;
5150/// # extern crate google_documentai1 as documentai1;
5151/// # async fn dox() {
5152/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5153///
5154/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5155/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5156/// #     secret,
5157/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5158/// # ).build().await.unwrap();
5159///
5160/// # let client = hyper_util::client::legacy::Client::builder(
5161/// #     hyper_util::rt::TokioExecutor::new()
5162/// # )
5163/// # .build(
5164/// #     hyper_rustls::HttpsConnectorBuilder::new()
5165/// #         .with_native_roots()
5166/// #         .unwrap()
5167/// #         .https_or_http()
5168/// #         .enable_http1()
5169/// #         .build()
5170/// # );
5171/// # let mut hub = Document::new(client, auth);
5172/// // You can configure optional parameters by calling the respective setters at will, and
5173/// // execute the final call using `doit()`.
5174/// // Values shown here are possibly random and not representative !
5175/// let result = hub.projects().locations_processor_types_list("parent")
5176///              .page_token("ipsum")
5177///              .page_size(-62)
5178///              .doit().await;
5179/// # }
5180/// ```
5181pub struct ProjectLocationProcessorTypeListCall<'a, C>
5182where
5183    C: 'a,
5184{
5185    hub: &'a Document<C>,
5186    _parent: String,
5187    _page_token: Option<String>,
5188    _page_size: Option<i32>,
5189    _delegate: Option<&'a mut dyn common::Delegate>,
5190    _additional_params: HashMap<String, String>,
5191    _scopes: BTreeSet<String>,
5192}
5193
5194impl<'a, C> common::CallBuilder for ProjectLocationProcessorTypeListCall<'a, C> {}
5195
5196impl<'a, C> ProjectLocationProcessorTypeListCall<'a, C>
5197where
5198    C: common::Connector,
5199{
5200    /// Perform the operation you have build so far.
5201    pub async fn doit(
5202        mut self,
5203    ) -> common::Result<(
5204        common::Response,
5205        GoogleCloudDocumentaiV1ListProcessorTypesResponse,
5206    )> {
5207        use std::borrow::Cow;
5208        use std::io::{Read, Seek};
5209
5210        use common::{url::Params, ToParts};
5211        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5212
5213        let mut dd = common::DefaultDelegate;
5214        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5215        dlg.begin(common::MethodInfo {
5216            id: "documentai.projects.locations.processorTypes.list",
5217            http_method: hyper::Method::GET,
5218        });
5219
5220        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
5221            if self._additional_params.contains_key(field) {
5222                dlg.finished(false);
5223                return Err(common::Error::FieldClash(field));
5224            }
5225        }
5226
5227        let mut params = Params::with_capacity(5 + self._additional_params.len());
5228        params.push("parent", self._parent);
5229        if let Some(value) = self._page_token.as_ref() {
5230            params.push("pageToken", value);
5231        }
5232        if let Some(value) = self._page_size.as_ref() {
5233            params.push("pageSize", value.to_string());
5234        }
5235
5236        params.extend(self._additional_params.iter());
5237
5238        params.push("alt", "json");
5239        let mut url = self.hub._base_url.clone() + "v1/{+parent}/processorTypes";
5240        if self._scopes.is_empty() {
5241            self._scopes
5242                .insert(Scope::CloudPlatform.as_ref().to_string());
5243        }
5244
5245        #[allow(clippy::single_element_loop)]
5246        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5247            url = params.uri_replacement(url, param_name, find_this, true);
5248        }
5249        {
5250            let to_remove = ["parent"];
5251            params.remove_params(&to_remove);
5252        }
5253
5254        let url = params.parse_with_url(&url);
5255
5256        loop {
5257            let token = match self
5258                .hub
5259                .auth
5260                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5261                .await
5262            {
5263                Ok(token) => token,
5264                Err(e) => match dlg.token(e) {
5265                    Ok(token) => token,
5266                    Err(e) => {
5267                        dlg.finished(false);
5268                        return Err(common::Error::MissingToken(e));
5269                    }
5270                },
5271            };
5272            let mut req_result = {
5273                let client = &self.hub.client;
5274                dlg.pre_request();
5275                let mut req_builder = hyper::Request::builder()
5276                    .method(hyper::Method::GET)
5277                    .uri(url.as_str())
5278                    .header(USER_AGENT, self.hub._user_agent.clone());
5279
5280                if let Some(token) = token.as_ref() {
5281                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5282                }
5283
5284                let request = req_builder
5285                    .header(CONTENT_LENGTH, 0_u64)
5286                    .body(common::to_body::<String>(None));
5287
5288                client.request(request.unwrap()).await
5289            };
5290
5291            match req_result {
5292                Err(err) => {
5293                    if let common::Retry::After(d) = dlg.http_error(&err) {
5294                        sleep(d).await;
5295                        continue;
5296                    }
5297                    dlg.finished(false);
5298                    return Err(common::Error::HttpError(err));
5299                }
5300                Ok(res) => {
5301                    let (mut parts, body) = res.into_parts();
5302                    let mut body = common::Body::new(body);
5303                    if !parts.status.is_success() {
5304                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5305                        let error = serde_json::from_str(&common::to_string(&bytes));
5306                        let response = common::to_response(parts, bytes.into());
5307
5308                        if let common::Retry::After(d) =
5309                            dlg.http_failure(&response, error.as_ref().ok())
5310                        {
5311                            sleep(d).await;
5312                            continue;
5313                        }
5314
5315                        dlg.finished(false);
5316
5317                        return Err(match error {
5318                            Ok(value) => common::Error::BadRequest(value),
5319                            _ => common::Error::Failure(response),
5320                        });
5321                    }
5322                    let response = {
5323                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5324                        let encoded = common::to_string(&bytes);
5325                        match serde_json::from_str(&encoded) {
5326                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5327                            Err(error) => {
5328                                dlg.response_json_decode_error(&encoded, &error);
5329                                return Err(common::Error::JsonDecodeError(
5330                                    encoded.to_string(),
5331                                    error,
5332                                ));
5333                            }
5334                        }
5335                    };
5336
5337                    dlg.finished(true);
5338                    return Ok(response);
5339                }
5340            }
5341        }
5342    }
5343
5344    /// Required. The location of processor types to list. Format: `projects/{project}/locations/{location}`.
5345    ///
5346    /// Sets the *parent* path property to the given value.
5347    ///
5348    /// Even though the property as already been set when instantiating this call,
5349    /// we provide this method for API completeness.
5350    pub fn parent(mut self, new_value: &str) -> ProjectLocationProcessorTypeListCall<'a, C> {
5351        self._parent = new_value.to_string();
5352        self
5353    }
5354    /// Used to retrieve the next page of results, empty if at the end of the list.
5355    ///
5356    /// Sets the *page token* query property to the given value.
5357    pub fn page_token(mut self, new_value: &str) -> ProjectLocationProcessorTypeListCall<'a, C> {
5358        self._page_token = Some(new_value.to_string());
5359        self
5360    }
5361    /// The maximum number of processor types to return. If unspecified, at most `100` processor types will be returned. The maximum value is `500`. Values above `500` will be coerced to `500`.
5362    ///
5363    /// Sets the *page size* query property to the given value.
5364    pub fn page_size(mut self, new_value: i32) -> ProjectLocationProcessorTypeListCall<'a, C> {
5365        self._page_size = Some(new_value);
5366        self
5367    }
5368    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5369    /// while executing the actual API request.
5370    ///
5371    /// ````text
5372    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5373    /// ````
5374    ///
5375    /// Sets the *delegate* property to the given value.
5376    pub fn delegate(
5377        mut self,
5378        new_value: &'a mut dyn common::Delegate,
5379    ) -> ProjectLocationProcessorTypeListCall<'a, C> {
5380        self._delegate = Some(new_value);
5381        self
5382    }
5383
5384    /// Set any additional parameter of the query string used in the request.
5385    /// It should be used to set parameters which are not yet available through their own
5386    /// setters.
5387    ///
5388    /// Please note that this method must not be used to set any of the known parameters
5389    /// which have their own setter method. If done anyway, the request will fail.
5390    ///
5391    /// # Additional Parameters
5392    ///
5393    /// * *$.xgafv* (query-string) - V1 error format.
5394    /// * *access_token* (query-string) - OAuth access token.
5395    /// * *alt* (query-string) - Data format for response.
5396    /// * *callback* (query-string) - JSONP
5397    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5398    /// * *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.
5399    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5400    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5401    /// * *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.
5402    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5403    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5404    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProcessorTypeListCall<'a, C>
5405    where
5406        T: AsRef<str>,
5407    {
5408        self._additional_params
5409            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5410        self
5411    }
5412
5413    /// Identifies the authorization scope for the method you are building.
5414    ///
5415    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5416    /// [`Scope::CloudPlatform`].
5417    ///
5418    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5419    /// tokens for more than one scope.
5420    ///
5421    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5422    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5423    /// sufficient, a read-write scope will do as well.
5424    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProcessorTypeListCall<'a, C>
5425    where
5426        St: AsRef<str>,
5427    {
5428        self._scopes.insert(String::from(scope.as_ref()));
5429        self
5430    }
5431    /// Identifies the authorization scope(s) for the method you are building.
5432    ///
5433    /// See [`Self::add_scope()`] for details.
5434    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProcessorTypeListCall<'a, C>
5435    where
5436        I: IntoIterator<Item = St>,
5437        St: AsRef<str>,
5438    {
5439        self._scopes
5440            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5441        self
5442    }
5443
5444    /// Removes all scopes, and no default scope will be used either.
5445    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5446    /// for details).
5447    pub fn clear_scopes(mut self) -> ProjectLocationProcessorTypeListCall<'a, C> {
5448        self._scopes.clear();
5449        self
5450    }
5451}
5452
5453/// Send a document for Human Review. The input document should be processed by the specified processor.
5454///
5455/// A builder for the *locations.processors.humanReviewConfig.reviewDocument* method supported by a *project* resource.
5456/// It is not used directly, but through a [`ProjectMethods`] instance.
5457///
5458/// # Example
5459///
5460/// Instantiate a resource method builder
5461///
5462/// ```test_harness,no_run
5463/// # extern crate hyper;
5464/// # extern crate hyper_rustls;
5465/// # extern crate google_documentai1 as documentai1;
5466/// use documentai1::api::GoogleCloudDocumentaiV1ReviewDocumentRequest;
5467/// # async fn dox() {
5468/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5469///
5470/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5471/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5472/// #     secret,
5473/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5474/// # ).build().await.unwrap();
5475///
5476/// # let client = hyper_util::client::legacy::Client::builder(
5477/// #     hyper_util::rt::TokioExecutor::new()
5478/// # )
5479/// # .build(
5480/// #     hyper_rustls::HttpsConnectorBuilder::new()
5481/// #         .with_native_roots()
5482/// #         .unwrap()
5483/// #         .https_or_http()
5484/// #         .enable_http1()
5485/// #         .build()
5486/// # );
5487/// # let mut hub = Document::new(client, auth);
5488/// // As the method needs a request, you would usually fill it with the desired information
5489/// // into the respective structure. Some of the parts shown here might not be applicable !
5490/// // Values shown here are possibly random and not representative !
5491/// let mut req = GoogleCloudDocumentaiV1ReviewDocumentRequest::default();
5492///
5493/// // You can configure optional parameters by calling the respective setters at will, and
5494/// // execute the final call using `doit()`.
5495/// // Values shown here are possibly random and not representative !
5496/// let result = hub.projects().locations_processors_human_review_config_review_document(req, "humanReviewConfig")
5497///              .doit().await;
5498/// # }
5499/// ```
5500pub struct ProjectLocationProcessorHumanReviewConfigReviewDocumentCall<'a, C>
5501where
5502    C: 'a,
5503{
5504    hub: &'a Document<C>,
5505    _request: GoogleCloudDocumentaiV1ReviewDocumentRequest,
5506    _human_review_config: String,
5507    _delegate: Option<&'a mut dyn common::Delegate>,
5508    _additional_params: HashMap<String, String>,
5509    _scopes: BTreeSet<String>,
5510}
5511
5512impl<'a, C> common::CallBuilder
5513    for ProjectLocationProcessorHumanReviewConfigReviewDocumentCall<'a, C>
5514{
5515}
5516
5517impl<'a, C> ProjectLocationProcessorHumanReviewConfigReviewDocumentCall<'a, C>
5518where
5519    C: common::Connector,
5520{
5521    /// Perform the operation you have build so far.
5522    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
5523        use std::borrow::Cow;
5524        use std::io::{Read, Seek};
5525
5526        use common::{url::Params, ToParts};
5527        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5528
5529        let mut dd = common::DefaultDelegate;
5530        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5531        dlg.begin(common::MethodInfo {
5532            id: "documentai.projects.locations.processors.humanReviewConfig.reviewDocument",
5533            http_method: hyper::Method::POST,
5534        });
5535
5536        for &field in ["alt", "humanReviewConfig"].iter() {
5537            if self._additional_params.contains_key(field) {
5538                dlg.finished(false);
5539                return Err(common::Error::FieldClash(field));
5540            }
5541        }
5542
5543        let mut params = Params::with_capacity(4 + self._additional_params.len());
5544        params.push("humanReviewConfig", self._human_review_config);
5545
5546        params.extend(self._additional_params.iter());
5547
5548        params.push("alt", "json");
5549        let mut url = self.hub._base_url.clone() + "v1/{+humanReviewConfig}:reviewDocument";
5550        if self._scopes.is_empty() {
5551            self._scopes
5552                .insert(Scope::CloudPlatform.as_ref().to_string());
5553        }
5554
5555        #[allow(clippy::single_element_loop)]
5556        for &(find_this, param_name) in [("{+humanReviewConfig}", "humanReviewConfig")].iter() {
5557            url = params.uri_replacement(url, param_name, find_this, true);
5558        }
5559        {
5560            let to_remove = ["humanReviewConfig"];
5561            params.remove_params(&to_remove);
5562        }
5563
5564        let url = params.parse_with_url(&url);
5565
5566        let mut json_mime_type = mime::APPLICATION_JSON;
5567        let mut request_value_reader = {
5568            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5569            common::remove_json_null_values(&mut value);
5570            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5571            serde_json::to_writer(&mut dst, &value).unwrap();
5572            dst
5573        };
5574        let request_size = request_value_reader
5575            .seek(std::io::SeekFrom::End(0))
5576            .unwrap();
5577        request_value_reader
5578            .seek(std::io::SeekFrom::Start(0))
5579            .unwrap();
5580
5581        loop {
5582            let token = match self
5583                .hub
5584                .auth
5585                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5586                .await
5587            {
5588                Ok(token) => token,
5589                Err(e) => match dlg.token(e) {
5590                    Ok(token) => token,
5591                    Err(e) => {
5592                        dlg.finished(false);
5593                        return Err(common::Error::MissingToken(e));
5594                    }
5595                },
5596            };
5597            request_value_reader
5598                .seek(std::io::SeekFrom::Start(0))
5599                .unwrap();
5600            let mut req_result = {
5601                let client = &self.hub.client;
5602                dlg.pre_request();
5603                let mut req_builder = hyper::Request::builder()
5604                    .method(hyper::Method::POST)
5605                    .uri(url.as_str())
5606                    .header(USER_AGENT, self.hub._user_agent.clone());
5607
5608                if let Some(token) = token.as_ref() {
5609                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5610                }
5611
5612                let request = req_builder
5613                    .header(CONTENT_TYPE, json_mime_type.to_string())
5614                    .header(CONTENT_LENGTH, request_size as u64)
5615                    .body(common::to_body(
5616                        request_value_reader.get_ref().clone().into(),
5617                    ));
5618
5619                client.request(request.unwrap()).await
5620            };
5621
5622            match req_result {
5623                Err(err) => {
5624                    if let common::Retry::After(d) = dlg.http_error(&err) {
5625                        sleep(d).await;
5626                        continue;
5627                    }
5628                    dlg.finished(false);
5629                    return Err(common::Error::HttpError(err));
5630                }
5631                Ok(res) => {
5632                    let (mut parts, body) = res.into_parts();
5633                    let mut body = common::Body::new(body);
5634                    if !parts.status.is_success() {
5635                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5636                        let error = serde_json::from_str(&common::to_string(&bytes));
5637                        let response = common::to_response(parts, bytes.into());
5638
5639                        if let common::Retry::After(d) =
5640                            dlg.http_failure(&response, error.as_ref().ok())
5641                        {
5642                            sleep(d).await;
5643                            continue;
5644                        }
5645
5646                        dlg.finished(false);
5647
5648                        return Err(match error {
5649                            Ok(value) => common::Error::BadRequest(value),
5650                            _ => common::Error::Failure(response),
5651                        });
5652                    }
5653                    let response = {
5654                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5655                        let encoded = common::to_string(&bytes);
5656                        match serde_json::from_str(&encoded) {
5657                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5658                            Err(error) => {
5659                                dlg.response_json_decode_error(&encoded, &error);
5660                                return Err(common::Error::JsonDecodeError(
5661                                    encoded.to_string(),
5662                                    error,
5663                                ));
5664                            }
5665                        }
5666                    };
5667
5668                    dlg.finished(true);
5669                    return Ok(response);
5670                }
5671            }
5672        }
5673    }
5674
5675    ///
5676    /// Sets the *request* property to the given value.
5677    ///
5678    /// Even though the property as already been set when instantiating this call,
5679    /// we provide this method for API completeness.
5680    pub fn request(
5681        mut self,
5682        new_value: GoogleCloudDocumentaiV1ReviewDocumentRequest,
5683    ) -> ProjectLocationProcessorHumanReviewConfigReviewDocumentCall<'a, C> {
5684        self._request = new_value;
5685        self
5686    }
5687    /// Required. The resource name of the HumanReviewConfig that the document will be reviewed with.
5688    ///
5689    /// Sets the *human review config* path property to the given value.
5690    ///
5691    /// Even though the property as already been set when instantiating this call,
5692    /// we provide this method for API completeness.
5693    pub fn human_review_config(
5694        mut self,
5695        new_value: &str,
5696    ) -> ProjectLocationProcessorHumanReviewConfigReviewDocumentCall<'a, C> {
5697        self._human_review_config = new_value.to_string();
5698        self
5699    }
5700    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5701    /// while executing the actual API request.
5702    ///
5703    /// ````text
5704    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5705    /// ````
5706    ///
5707    /// Sets the *delegate* property to the given value.
5708    pub fn delegate(
5709        mut self,
5710        new_value: &'a mut dyn common::Delegate,
5711    ) -> ProjectLocationProcessorHumanReviewConfigReviewDocumentCall<'a, C> {
5712        self._delegate = Some(new_value);
5713        self
5714    }
5715
5716    /// Set any additional parameter of the query string used in the request.
5717    /// It should be used to set parameters which are not yet available through their own
5718    /// setters.
5719    ///
5720    /// Please note that this method must not be used to set any of the known parameters
5721    /// which have their own setter method. If done anyway, the request will fail.
5722    ///
5723    /// # Additional Parameters
5724    ///
5725    /// * *$.xgafv* (query-string) - V1 error format.
5726    /// * *access_token* (query-string) - OAuth access token.
5727    /// * *alt* (query-string) - Data format for response.
5728    /// * *callback* (query-string) - JSONP
5729    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5730    /// * *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.
5731    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5732    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5733    /// * *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.
5734    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5735    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5736    pub fn param<T>(
5737        mut self,
5738        name: T,
5739        value: T,
5740    ) -> ProjectLocationProcessorHumanReviewConfigReviewDocumentCall<'a, C>
5741    where
5742        T: AsRef<str>,
5743    {
5744        self._additional_params
5745            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5746        self
5747    }
5748
5749    /// Identifies the authorization scope for the method you are building.
5750    ///
5751    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5752    /// [`Scope::CloudPlatform`].
5753    ///
5754    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5755    /// tokens for more than one scope.
5756    ///
5757    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5758    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5759    /// sufficient, a read-write scope will do as well.
5760    pub fn add_scope<St>(
5761        mut self,
5762        scope: St,
5763    ) -> ProjectLocationProcessorHumanReviewConfigReviewDocumentCall<'a, C>
5764    where
5765        St: AsRef<str>,
5766    {
5767        self._scopes.insert(String::from(scope.as_ref()));
5768        self
5769    }
5770    /// Identifies the authorization scope(s) for the method you are building.
5771    ///
5772    /// See [`Self::add_scope()`] for details.
5773    pub fn add_scopes<I, St>(
5774        mut self,
5775        scopes: I,
5776    ) -> ProjectLocationProcessorHumanReviewConfigReviewDocumentCall<'a, C>
5777    where
5778        I: IntoIterator<Item = St>,
5779        St: AsRef<str>,
5780    {
5781        self._scopes
5782            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5783        self
5784    }
5785
5786    /// Removes all scopes, and no default scope will be used either.
5787    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5788    /// for details).
5789    pub fn clear_scopes(
5790        mut self,
5791    ) -> ProjectLocationProcessorHumanReviewConfigReviewDocumentCall<'a, C> {
5792        self._scopes.clear();
5793        self
5794    }
5795}
5796
5797/// Retrieves a specific evaluation.
5798///
5799/// A builder for the *locations.processors.processorVersions.evaluations.get* method supported by a *project* resource.
5800/// It is not used directly, but through a [`ProjectMethods`] instance.
5801///
5802/// # Example
5803///
5804/// Instantiate a resource method builder
5805///
5806/// ```test_harness,no_run
5807/// # extern crate hyper;
5808/// # extern crate hyper_rustls;
5809/// # extern crate google_documentai1 as documentai1;
5810/// # async fn dox() {
5811/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5812///
5813/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5814/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5815/// #     secret,
5816/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5817/// # ).build().await.unwrap();
5818///
5819/// # let client = hyper_util::client::legacy::Client::builder(
5820/// #     hyper_util::rt::TokioExecutor::new()
5821/// # )
5822/// # .build(
5823/// #     hyper_rustls::HttpsConnectorBuilder::new()
5824/// #         .with_native_roots()
5825/// #         .unwrap()
5826/// #         .https_or_http()
5827/// #         .enable_http1()
5828/// #         .build()
5829/// # );
5830/// # let mut hub = Document::new(client, auth);
5831/// // You can configure optional parameters by calling the respective setters at will, and
5832/// // execute the final call using `doit()`.
5833/// // Values shown here are possibly random and not representative !
5834/// let result = hub.projects().locations_processors_processor_versions_evaluations_get("name")
5835///              .doit().await;
5836/// # }
5837/// ```
5838pub struct ProjectLocationProcessorProcessorVersionEvaluationGetCall<'a, C>
5839where
5840    C: 'a,
5841{
5842    hub: &'a Document<C>,
5843    _name: String,
5844    _delegate: Option<&'a mut dyn common::Delegate>,
5845    _additional_params: HashMap<String, String>,
5846    _scopes: BTreeSet<String>,
5847}
5848
5849impl<'a, C> common::CallBuilder
5850    for ProjectLocationProcessorProcessorVersionEvaluationGetCall<'a, C>
5851{
5852}
5853
5854impl<'a, C> ProjectLocationProcessorProcessorVersionEvaluationGetCall<'a, C>
5855where
5856    C: common::Connector,
5857{
5858    /// Perform the operation you have build so far.
5859    pub async fn doit(
5860        mut self,
5861    ) -> common::Result<(common::Response, GoogleCloudDocumentaiV1Evaluation)> {
5862        use std::borrow::Cow;
5863        use std::io::{Read, Seek};
5864
5865        use common::{url::Params, ToParts};
5866        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5867
5868        let mut dd = common::DefaultDelegate;
5869        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5870        dlg.begin(common::MethodInfo {
5871            id: "documentai.projects.locations.processors.processorVersions.evaluations.get",
5872            http_method: hyper::Method::GET,
5873        });
5874
5875        for &field in ["alt", "name"].iter() {
5876            if self._additional_params.contains_key(field) {
5877                dlg.finished(false);
5878                return Err(common::Error::FieldClash(field));
5879            }
5880        }
5881
5882        let mut params = Params::with_capacity(3 + self._additional_params.len());
5883        params.push("name", self._name);
5884
5885        params.extend(self._additional_params.iter());
5886
5887        params.push("alt", "json");
5888        let mut url = self.hub._base_url.clone() + "v1/{+name}";
5889        if self._scopes.is_empty() {
5890            self._scopes
5891                .insert(Scope::CloudPlatform.as_ref().to_string());
5892        }
5893
5894        #[allow(clippy::single_element_loop)]
5895        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5896            url = params.uri_replacement(url, param_name, find_this, true);
5897        }
5898        {
5899            let to_remove = ["name"];
5900            params.remove_params(&to_remove);
5901        }
5902
5903        let url = params.parse_with_url(&url);
5904
5905        loop {
5906            let token = match self
5907                .hub
5908                .auth
5909                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5910                .await
5911            {
5912                Ok(token) => token,
5913                Err(e) => match dlg.token(e) {
5914                    Ok(token) => token,
5915                    Err(e) => {
5916                        dlg.finished(false);
5917                        return Err(common::Error::MissingToken(e));
5918                    }
5919                },
5920            };
5921            let mut req_result = {
5922                let client = &self.hub.client;
5923                dlg.pre_request();
5924                let mut req_builder = hyper::Request::builder()
5925                    .method(hyper::Method::GET)
5926                    .uri(url.as_str())
5927                    .header(USER_AGENT, self.hub._user_agent.clone());
5928
5929                if let Some(token) = token.as_ref() {
5930                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5931                }
5932
5933                let request = req_builder
5934                    .header(CONTENT_LENGTH, 0_u64)
5935                    .body(common::to_body::<String>(None));
5936
5937                client.request(request.unwrap()).await
5938            };
5939
5940            match req_result {
5941                Err(err) => {
5942                    if let common::Retry::After(d) = dlg.http_error(&err) {
5943                        sleep(d).await;
5944                        continue;
5945                    }
5946                    dlg.finished(false);
5947                    return Err(common::Error::HttpError(err));
5948                }
5949                Ok(res) => {
5950                    let (mut parts, body) = res.into_parts();
5951                    let mut body = common::Body::new(body);
5952                    if !parts.status.is_success() {
5953                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5954                        let error = serde_json::from_str(&common::to_string(&bytes));
5955                        let response = common::to_response(parts, bytes.into());
5956
5957                        if let common::Retry::After(d) =
5958                            dlg.http_failure(&response, error.as_ref().ok())
5959                        {
5960                            sleep(d).await;
5961                            continue;
5962                        }
5963
5964                        dlg.finished(false);
5965
5966                        return Err(match error {
5967                            Ok(value) => common::Error::BadRequest(value),
5968                            _ => common::Error::Failure(response),
5969                        });
5970                    }
5971                    let response = {
5972                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5973                        let encoded = common::to_string(&bytes);
5974                        match serde_json::from_str(&encoded) {
5975                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5976                            Err(error) => {
5977                                dlg.response_json_decode_error(&encoded, &error);
5978                                return Err(common::Error::JsonDecodeError(
5979                                    encoded.to_string(),
5980                                    error,
5981                                ));
5982                            }
5983                        }
5984                    };
5985
5986                    dlg.finished(true);
5987                    return Ok(response);
5988                }
5989            }
5990        }
5991    }
5992
5993    /// Required. The resource name of the Evaluation to get. `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}/evaluations/{evaluation}`
5994    ///
5995    /// Sets the *name* path property to the given value.
5996    ///
5997    /// Even though the property as already been set when instantiating this call,
5998    /// we provide this method for API completeness.
5999    pub fn name(
6000        mut self,
6001        new_value: &str,
6002    ) -> ProjectLocationProcessorProcessorVersionEvaluationGetCall<'a, C> {
6003        self._name = new_value.to_string();
6004        self
6005    }
6006    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6007    /// while executing the actual API request.
6008    ///
6009    /// ````text
6010    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6011    /// ````
6012    ///
6013    /// Sets the *delegate* property to the given value.
6014    pub fn delegate(
6015        mut self,
6016        new_value: &'a mut dyn common::Delegate,
6017    ) -> ProjectLocationProcessorProcessorVersionEvaluationGetCall<'a, C> {
6018        self._delegate = Some(new_value);
6019        self
6020    }
6021
6022    /// Set any additional parameter of the query string used in the request.
6023    /// It should be used to set parameters which are not yet available through their own
6024    /// setters.
6025    ///
6026    /// Please note that this method must not be used to set any of the known parameters
6027    /// which have their own setter method. If done anyway, the request will fail.
6028    ///
6029    /// # Additional Parameters
6030    ///
6031    /// * *$.xgafv* (query-string) - V1 error format.
6032    /// * *access_token* (query-string) - OAuth access token.
6033    /// * *alt* (query-string) - Data format for response.
6034    /// * *callback* (query-string) - JSONP
6035    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6036    /// * *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.
6037    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6038    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6039    /// * *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.
6040    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6041    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6042    pub fn param<T>(
6043        mut self,
6044        name: T,
6045        value: T,
6046    ) -> ProjectLocationProcessorProcessorVersionEvaluationGetCall<'a, C>
6047    where
6048        T: AsRef<str>,
6049    {
6050        self._additional_params
6051            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6052        self
6053    }
6054
6055    /// Identifies the authorization scope for the method you are building.
6056    ///
6057    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6058    /// [`Scope::CloudPlatform`].
6059    ///
6060    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6061    /// tokens for more than one scope.
6062    ///
6063    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6064    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6065    /// sufficient, a read-write scope will do as well.
6066    pub fn add_scope<St>(
6067        mut self,
6068        scope: St,
6069    ) -> ProjectLocationProcessorProcessorVersionEvaluationGetCall<'a, C>
6070    where
6071        St: AsRef<str>,
6072    {
6073        self._scopes.insert(String::from(scope.as_ref()));
6074        self
6075    }
6076    /// Identifies the authorization scope(s) for the method you are building.
6077    ///
6078    /// See [`Self::add_scope()`] for details.
6079    pub fn add_scopes<I, St>(
6080        mut self,
6081        scopes: I,
6082    ) -> ProjectLocationProcessorProcessorVersionEvaluationGetCall<'a, C>
6083    where
6084        I: IntoIterator<Item = St>,
6085        St: AsRef<str>,
6086    {
6087        self._scopes
6088            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6089        self
6090    }
6091
6092    /// Removes all scopes, and no default scope will be used either.
6093    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6094    /// for details).
6095    pub fn clear_scopes(
6096        mut self,
6097    ) -> ProjectLocationProcessorProcessorVersionEvaluationGetCall<'a, C> {
6098        self._scopes.clear();
6099        self
6100    }
6101}
6102
6103/// Retrieves a set of evaluations for a given processor version.
6104///
6105/// A builder for the *locations.processors.processorVersions.evaluations.list* method supported by a *project* resource.
6106/// It is not used directly, but through a [`ProjectMethods`] instance.
6107///
6108/// # Example
6109///
6110/// Instantiate a resource method builder
6111///
6112/// ```test_harness,no_run
6113/// # extern crate hyper;
6114/// # extern crate hyper_rustls;
6115/// # extern crate google_documentai1 as documentai1;
6116/// # async fn dox() {
6117/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6118///
6119/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6120/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6121/// #     secret,
6122/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6123/// # ).build().await.unwrap();
6124///
6125/// # let client = hyper_util::client::legacy::Client::builder(
6126/// #     hyper_util::rt::TokioExecutor::new()
6127/// # )
6128/// # .build(
6129/// #     hyper_rustls::HttpsConnectorBuilder::new()
6130/// #         .with_native_roots()
6131/// #         .unwrap()
6132/// #         .https_or_http()
6133/// #         .enable_http1()
6134/// #         .build()
6135/// # );
6136/// # let mut hub = Document::new(client, auth);
6137/// // You can configure optional parameters by calling the respective setters at will, and
6138/// // execute the final call using `doit()`.
6139/// // Values shown here are possibly random and not representative !
6140/// let result = hub.projects().locations_processors_processor_versions_evaluations_list("parent")
6141///              .page_token("dolor")
6142///              .page_size(-17)
6143///              .doit().await;
6144/// # }
6145/// ```
6146pub struct ProjectLocationProcessorProcessorVersionEvaluationListCall<'a, C>
6147where
6148    C: 'a,
6149{
6150    hub: &'a Document<C>,
6151    _parent: String,
6152    _page_token: Option<String>,
6153    _page_size: Option<i32>,
6154    _delegate: Option<&'a mut dyn common::Delegate>,
6155    _additional_params: HashMap<String, String>,
6156    _scopes: BTreeSet<String>,
6157}
6158
6159impl<'a, C> common::CallBuilder
6160    for ProjectLocationProcessorProcessorVersionEvaluationListCall<'a, C>
6161{
6162}
6163
6164impl<'a, C> ProjectLocationProcessorProcessorVersionEvaluationListCall<'a, C>
6165where
6166    C: common::Connector,
6167{
6168    /// Perform the operation you have build so far.
6169    pub async fn doit(
6170        mut self,
6171    ) -> common::Result<(
6172        common::Response,
6173        GoogleCloudDocumentaiV1ListEvaluationsResponse,
6174    )> {
6175        use std::borrow::Cow;
6176        use std::io::{Read, Seek};
6177
6178        use common::{url::Params, ToParts};
6179        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6180
6181        let mut dd = common::DefaultDelegate;
6182        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6183        dlg.begin(common::MethodInfo {
6184            id: "documentai.projects.locations.processors.processorVersions.evaluations.list",
6185            http_method: hyper::Method::GET,
6186        });
6187
6188        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
6189            if self._additional_params.contains_key(field) {
6190                dlg.finished(false);
6191                return Err(common::Error::FieldClash(field));
6192            }
6193        }
6194
6195        let mut params = Params::with_capacity(5 + self._additional_params.len());
6196        params.push("parent", self._parent);
6197        if let Some(value) = self._page_token.as_ref() {
6198            params.push("pageToken", value);
6199        }
6200        if let Some(value) = self._page_size.as_ref() {
6201            params.push("pageSize", value.to_string());
6202        }
6203
6204        params.extend(self._additional_params.iter());
6205
6206        params.push("alt", "json");
6207        let mut url = self.hub._base_url.clone() + "v1/{+parent}/evaluations";
6208        if self._scopes.is_empty() {
6209            self._scopes
6210                .insert(Scope::CloudPlatform.as_ref().to_string());
6211        }
6212
6213        #[allow(clippy::single_element_loop)]
6214        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6215            url = params.uri_replacement(url, param_name, find_this, true);
6216        }
6217        {
6218            let to_remove = ["parent"];
6219            params.remove_params(&to_remove);
6220        }
6221
6222        let url = params.parse_with_url(&url);
6223
6224        loop {
6225            let token = match self
6226                .hub
6227                .auth
6228                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6229                .await
6230            {
6231                Ok(token) => token,
6232                Err(e) => match dlg.token(e) {
6233                    Ok(token) => token,
6234                    Err(e) => {
6235                        dlg.finished(false);
6236                        return Err(common::Error::MissingToken(e));
6237                    }
6238                },
6239            };
6240            let mut req_result = {
6241                let client = &self.hub.client;
6242                dlg.pre_request();
6243                let mut req_builder = hyper::Request::builder()
6244                    .method(hyper::Method::GET)
6245                    .uri(url.as_str())
6246                    .header(USER_AGENT, self.hub._user_agent.clone());
6247
6248                if let Some(token) = token.as_ref() {
6249                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6250                }
6251
6252                let request = req_builder
6253                    .header(CONTENT_LENGTH, 0_u64)
6254                    .body(common::to_body::<String>(None));
6255
6256                client.request(request.unwrap()).await
6257            };
6258
6259            match req_result {
6260                Err(err) => {
6261                    if let common::Retry::After(d) = dlg.http_error(&err) {
6262                        sleep(d).await;
6263                        continue;
6264                    }
6265                    dlg.finished(false);
6266                    return Err(common::Error::HttpError(err));
6267                }
6268                Ok(res) => {
6269                    let (mut parts, body) = res.into_parts();
6270                    let mut body = common::Body::new(body);
6271                    if !parts.status.is_success() {
6272                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6273                        let error = serde_json::from_str(&common::to_string(&bytes));
6274                        let response = common::to_response(parts, bytes.into());
6275
6276                        if let common::Retry::After(d) =
6277                            dlg.http_failure(&response, error.as_ref().ok())
6278                        {
6279                            sleep(d).await;
6280                            continue;
6281                        }
6282
6283                        dlg.finished(false);
6284
6285                        return Err(match error {
6286                            Ok(value) => common::Error::BadRequest(value),
6287                            _ => common::Error::Failure(response),
6288                        });
6289                    }
6290                    let response = {
6291                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6292                        let encoded = common::to_string(&bytes);
6293                        match serde_json::from_str(&encoded) {
6294                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6295                            Err(error) => {
6296                                dlg.response_json_decode_error(&encoded, &error);
6297                                return Err(common::Error::JsonDecodeError(
6298                                    encoded.to_string(),
6299                                    error,
6300                                ));
6301                            }
6302                        }
6303                    };
6304
6305                    dlg.finished(true);
6306                    return Ok(response);
6307                }
6308            }
6309        }
6310    }
6311
6312    /// Required. The resource name of the ProcessorVersion to list evaluations for. `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`
6313    ///
6314    /// Sets the *parent* path property to the given value.
6315    ///
6316    /// Even though the property as already been set when instantiating this call,
6317    /// we provide this method for API completeness.
6318    pub fn parent(
6319        mut self,
6320        new_value: &str,
6321    ) -> ProjectLocationProcessorProcessorVersionEvaluationListCall<'a, C> {
6322        self._parent = new_value.to_string();
6323        self
6324    }
6325    /// A page token, received from a previous `ListEvaluations` call. Provide this to retrieve the subsequent page.
6326    ///
6327    /// Sets the *page token* query property to the given value.
6328    pub fn page_token(
6329        mut self,
6330        new_value: &str,
6331    ) -> ProjectLocationProcessorProcessorVersionEvaluationListCall<'a, C> {
6332        self._page_token = Some(new_value.to_string());
6333        self
6334    }
6335    /// The standard list page size. If unspecified, at most `5` evaluations are returned. The maximum value is `100`. Values above `100` are coerced to `100`.
6336    ///
6337    /// Sets the *page size* query property to the given value.
6338    pub fn page_size(
6339        mut self,
6340        new_value: i32,
6341    ) -> ProjectLocationProcessorProcessorVersionEvaluationListCall<'a, C> {
6342        self._page_size = Some(new_value);
6343        self
6344    }
6345    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6346    /// while executing the actual API request.
6347    ///
6348    /// ````text
6349    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6350    /// ````
6351    ///
6352    /// Sets the *delegate* property to the given value.
6353    pub fn delegate(
6354        mut self,
6355        new_value: &'a mut dyn common::Delegate,
6356    ) -> ProjectLocationProcessorProcessorVersionEvaluationListCall<'a, C> {
6357        self._delegate = Some(new_value);
6358        self
6359    }
6360
6361    /// Set any additional parameter of the query string used in the request.
6362    /// It should be used to set parameters which are not yet available through their own
6363    /// setters.
6364    ///
6365    /// Please note that this method must not be used to set any of the known parameters
6366    /// which have their own setter method. If done anyway, the request will fail.
6367    ///
6368    /// # Additional Parameters
6369    ///
6370    /// * *$.xgafv* (query-string) - V1 error format.
6371    /// * *access_token* (query-string) - OAuth access token.
6372    /// * *alt* (query-string) - Data format for response.
6373    /// * *callback* (query-string) - JSONP
6374    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6375    /// * *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.
6376    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6377    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6378    /// * *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.
6379    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6380    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6381    pub fn param<T>(
6382        mut self,
6383        name: T,
6384        value: T,
6385    ) -> ProjectLocationProcessorProcessorVersionEvaluationListCall<'a, C>
6386    where
6387        T: AsRef<str>,
6388    {
6389        self._additional_params
6390            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6391        self
6392    }
6393
6394    /// Identifies the authorization scope for the method you are building.
6395    ///
6396    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6397    /// [`Scope::CloudPlatform`].
6398    ///
6399    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6400    /// tokens for more than one scope.
6401    ///
6402    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6403    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6404    /// sufficient, a read-write scope will do as well.
6405    pub fn add_scope<St>(
6406        mut self,
6407        scope: St,
6408    ) -> ProjectLocationProcessorProcessorVersionEvaluationListCall<'a, C>
6409    where
6410        St: AsRef<str>,
6411    {
6412        self._scopes.insert(String::from(scope.as_ref()));
6413        self
6414    }
6415    /// Identifies the authorization scope(s) for the method you are building.
6416    ///
6417    /// See [`Self::add_scope()`] for details.
6418    pub fn add_scopes<I, St>(
6419        mut self,
6420        scopes: I,
6421    ) -> ProjectLocationProcessorProcessorVersionEvaluationListCall<'a, C>
6422    where
6423        I: IntoIterator<Item = St>,
6424        St: AsRef<str>,
6425    {
6426        self._scopes
6427            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6428        self
6429    }
6430
6431    /// Removes all scopes, and no default scope will be used either.
6432    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6433    /// for details).
6434    pub fn clear_scopes(
6435        mut self,
6436    ) -> ProjectLocationProcessorProcessorVersionEvaluationListCall<'a, C> {
6437        self._scopes.clear();
6438        self
6439    }
6440}
6441
6442/// LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in the [Document] format.
6443///
6444/// A builder for the *locations.processors.processorVersions.batchProcess* method supported by a *project* resource.
6445/// It is not used directly, but through a [`ProjectMethods`] instance.
6446///
6447/// # Example
6448///
6449/// Instantiate a resource method builder
6450///
6451/// ```test_harness,no_run
6452/// # extern crate hyper;
6453/// # extern crate hyper_rustls;
6454/// # extern crate google_documentai1 as documentai1;
6455/// use documentai1::api::GoogleCloudDocumentaiV1BatchProcessRequest;
6456/// # async fn dox() {
6457/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6458///
6459/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6460/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6461/// #     secret,
6462/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6463/// # ).build().await.unwrap();
6464///
6465/// # let client = hyper_util::client::legacy::Client::builder(
6466/// #     hyper_util::rt::TokioExecutor::new()
6467/// # )
6468/// # .build(
6469/// #     hyper_rustls::HttpsConnectorBuilder::new()
6470/// #         .with_native_roots()
6471/// #         .unwrap()
6472/// #         .https_or_http()
6473/// #         .enable_http1()
6474/// #         .build()
6475/// # );
6476/// # let mut hub = Document::new(client, auth);
6477/// // As the method needs a request, you would usually fill it with the desired information
6478/// // into the respective structure. Some of the parts shown here might not be applicable !
6479/// // Values shown here are possibly random and not representative !
6480/// let mut req = GoogleCloudDocumentaiV1BatchProcessRequest::default();
6481///
6482/// // You can configure optional parameters by calling the respective setters at will, and
6483/// // execute the final call using `doit()`.
6484/// // Values shown here are possibly random and not representative !
6485/// let result = hub.projects().locations_processors_processor_versions_batch_process(req, "name")
6486///              .doit().await;
6487/// # }
6488/// ```
6489pub struct ProjectLocationProcessorProcessorVersionBatchProcesCall<'a, C>
6490where
6491    C: 'a,
6492{
6493    hub: &'a Document<C>,
6494    _request: GoogleCloudDocumentaiV1BatchProcessRequest,
6495    _name: String,
6496    _delegate: Option<&'a mut dyn common::Delegate>,
6497    _additional_params: HashMap<String, String>,
6498    _scopes: BTreeSet<String>,
6499}
6500
6501impl<'a, C> common::CallBuilder for ProjectLocationProcessorProcessorVersionBatchProcesCall<'a, C> {}
6502
6503impl<'a, C> ProjectLocationProcessorProcessorVersionBatchProcesCall<'a, C>
6504where
6505    C: common::Connector,
6506{
6507    /// Perform the operation you have build so far.
6508    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
6509        use std::borrow::Cow;
6510        use std::io::{Read, Seek};
6511
6512        use common::{url::Params, ToParts};
6513        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6514
6515        let mut dd = common::DefaultDelegate;
6516        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6517        dlg.begin(common::MethodInfo {
6518            id: "documentai.projects.locations.processors.processorVersions.batchProcess",
6519            http_method: hyper::Method::POST,
6520        });
6521
6522        for &field in ["alt", "name"].iter() {
6523            if self._additional_params.contains_key(field) {
6524                dlg.finished(false);
6525                return Err(common::Error::FieldClash(field));
6526            }
6527        }
6528
6529        let mut params = Params::with_capacity(4 + self._additional_params.len());
6530        params.push("name", self._name);
6531
6532        params.extend(self._additional_params.iter());
6533
6534        params.push("alt", "json");
6535        let mut url = self.hub._base_url.clone() + "v1/{+name}:batchProcess";
6536        if self._scopes.is_empty() {
6537            self._scopes
6538                .insert(Scope::CloudPlatform.as_ref().to_string());
6539        }
6540
6541        #[allow(clippy::single_element_loop)]
6542        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6543            url = params.uri_replacement(url, param_name, find_this, true);
6544        }
6545        {
6546            let to_remove = ["name"];
6547            params.remove_params(&to_remove);
6548        }
6549
6550        let url = params.parse_with_url(&url);
6551
6552        let mut json_mime_type = mime::APPLICATION_JSON;
6553        let mut request_value_reader = {
6554            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6555            common::remove_json_null_values(&mut value);
6556            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6557            serde_json::to_writer(&mut dst, &value).unwrap();
6558            dst
6559        };
6560        let request_size = request_value_reader
6561            .seek(std::io::SeekFrom::End(0))
6562            .unwrap();
6563        request_value_reader
6564            .seek(std::io::SeekFrom::Start(0))
6565            .unwrap();
6566
6567        loop {
6568            let token = match self
6569                .hub
6570                .auth
6571                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6572                .await
6573            {
6574                Ok(token) => token,
6575                Err(e) => match dlg.token(e) {
6576                    Ok(token) => token,
6577                    Err(e) => {
6578                        dlg.finished(false);
6579                        return Err(common::Error::MissingToken(e));
6580                    }
6581                },
6582            };
6583            request_value_reader
6584                .seek(std::io::SeekFrom::Start(0))
6585                .unwrap();
6586            let mut req_result = {
6587                let client = &self.hub.client;
6588                dlg.pre_request();
6589                let mut req_builder = hyper::Request::builder()
6590                    .method(hyper::Method::POST)
6591                    .uri(url.as_str())
6592                    .header(USER_AGENT, self.hub._user_agent.clone());
6593
6594                if let Some(token) = token.as_ref() {
6595                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6596                }
6597
6598                let request = req_builder
6599                    .header(CONTENT_TYPE, json_mime_type.to_string())
6600                    .header(CONTENT_LENGTH, request_size as u64)
6601                    .body(common::to_body(
6602                        request_value_reader.get_ref().clone().into(),
6603                    ));
6604
6605                client.request(request.unwrap()).await
6606            };
6607
6608            match req_result {
6609                Err(err) => {
6610                    if let common::Retry::After(d) = dlg.http_error(&err) {
6611                        sleep(d).await;
6612                        continue;
6613                    }
6614                    dlg.finished(false);
6615                    return Err(common::Error::HttpError(err));
6616                }
6617                Ok(res) => {
6618                    let (mut parts, body) = res.into_parts();
6619                    let mut body = common::Body::new(body);
6620                    if !parts.status.is_success() {
6621                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6622                        let error = serde_json::from_str(&common::to_string(&bytes));
6623                        let response = common::to_response(parts, bytes.into());
6624
6625                        if let common::Retry::After(d) =
6626                            dlg.http_failure(&response, error.as_ref().ok())
6627                        {
6628                            sleep(d).await;
6629                            continue;
6630                        }
6631
6632                        dlg.finished(false);
6633
6634                        return Err(match error {
6635                            Ok(value) => common::Error::BadRequest(value),
6636                            _ => common::Error::Failure(response),
6637                        });
6638                    }
6639                    let response = {
6640                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6641                        let encoded = common::to_string(&bytes);
6642                        match serde_json::from_str(&encoded) {
6643                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6644                            Err(error) => {
6645                                dlg.response_json_decode_error(&encoded, &error);
6646                                return Err(common::Error::JsonDecodeError(
6647                                    encoded.to_string(),
6648                                    error,
6649                                ));
6650                            }
6651                        }
6652                    };
6653
6654                    dlg.finished(true);
6655                    return Ok(response);
6656                }
6657            }
6658        }
6659    }
6660
6661    ///
6662    /// Sets the *request* property to the given value.
6663    ///
6664    /// Even though the property as already been set when instantiating this call,
6665    /// we provide this method for API completeness.
6666    pub fn request(
6667        mut self,
6668        new_value: GoogleCloudDocumentaiV1BatchProcessRequest,
6669    ) -> ProjectLocationProcessorProcessorVersionBatchProcesCall<'a, C> {
6670        self._request = new_value;
6671        self
6672    }
6673    /// Required. The resource name of Processor or ProcessorVersion. Format: `projects/{project}/locations/{location}/processors/{processor}`, or `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`
6674    ///
6675    /// Sets the *name* path property to the given value.
6676    ///
6677    /// Even though the property as already been set when instantiating this call,
6678    /// we provide this method for API completeness.
6679    pub fn name(
6680        mut self,
6681        new_value: &str,
6682    ) -> ProjectLocationProcessorProcessorVersionBatchProcesCall<'a, C> {
6683        self._name = new_value.to_string();
6684        self
6685    }
6686    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6687    /// while executing the actual API request.
6688    ///
6689    /// ````text
6690    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6691    /// ````
6692    ///
6693    /// Sets the *delegate* property to the given value.
6694    pub fn delegate(
6695        mut self,
6696        new_value: &'a mut dyn common::Delegate,
6697    ) -> ProjectLocationProcessorProcessorVersionBatchProcesCall<'a, C> {
6698        self._delegate = Some(new_value);
6699        self
6700    }
6701
6702    /// Set any additional parameter of the query string used in the request.
6703    /// It should be used to set parameters which are not yet available through their own
6704    /// setters.
6705    ///
6706    /// Please note that this method must not be used to set any of the known parameters
6707    /// which have their own setter method. If done anyway, the request will fail.
6708    ///
6709    /// # Additional Parameters
6710    ///
6711    /// * *$.xgafv* (query-string) - V1 error format.
6712    /// * *access_token* (query-string) - OAuth access token.
6713    /// * *alt* (query-string) - Data format for response.
6714    /// * *callback* (query-string) - JSONP
6715    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6716    /// * *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.
6717    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6718    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6719    /// * *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.
6720    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6721    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6722    pub fn param<T>(
6723        mut self,
6724        name: T,
6725        value: T,
6726    ) -> ProjectLocationProcessorProcessorVersionBatchProcesCall<'a, C>
6727    where
6728        T: AsRef<str>,
6729    {
6730        self._additional_params
6731            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6732        self
6733    }
6734
6735    /// Identifies the authorization scope for the method you are building.
6736    ///
6737    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6738    /// [`Scope::CloudPlatform`].
6739    ///
6740    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6741    /// tokens for more than one scope.
6742    ///
6743    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6744    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6745    /// sufficient, a read-write scope will do as well.
6746    pub fn add_scope<St>(
6747        mut self,
6748        scope: St,
6749    ) -> ProjectLocationProcessorProcessorVersionBatchProcesCall<'a, C>
6750    where
6751        St: AsRef<str>,
6752    {
6753        self._scopes.insert(String::from(scope.as_ref()));
6754        self
6755    }
6756    /// Identifies the authorization scope(s) for the method you are building.
6757    ///
6758    /// See [`Self::add_scope()`] for details.
6759    pub fn add_scopes<I, St>(
6760        mut self,
6761        scopes: I,
6762    ) -> ProjectLocationProcessorProcessorVersionBatchProcesCall<'a, C>
6763    where
6764        I: IntoIterator<Item = St>,
6765        St: AsRef<str>,
6766    {
6767        self._scopes
6768            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6769        self
6770    }
6771
6772    /// Removes all scopes, and no default scope will be used either.
6773    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6774    /// for details).
6775    pub fn clear_scopes(
6776        mut self,
6777    ) -> ProjectLocationProcessorProcessorVersionBatchProcesCall<'a, C> {
6778        self._scopes.clear();
6779        self
6780    }
6781}
6782
6783/// Deletes the processor version, all artifacts under the processor version will be deleted.
6784///
6785/// A builder for the *locations.processors.processorVersions.delete* method supported by a *project* resource.
6786/// It is not used directly, but through a [`ProjectMethods`] instance.
6787///
6788/// # Example
6789///
6790/// Instantiate a resource method builder
6791///
6792/// ```test_harness,no_run
6793/// # extern crate hyper;
6794/// # extern crate hyper_rustls;
6795/// # extern crate google_documentai1 as documentai1;
6796/// # async fn dox() {
6797/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6798///
6799/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6800/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6801/// #     secret,
6802/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6803/// # ).build().await.unwrap();
6804///
6805/// # let client = hyper_util::client::legacy::Client::builder(
6806/// #     hyper_util::rt::TokioExecutor::new()
6807/// # )
6808/// # .build(
6809/// #     hyper_rustls::HttpsConnectorBuilder::new()
6810/// #         .with_native_roots()
6811/// #         .unwrap()
6812/// #         .https_or_http()
6813/// #         .enable_http1()
6814/// #         .build()
6815/// # );
6816/// # let mut hub = Document::new(client, auth);
6817/// // You can configure optional parameters by calling the respective setters at will, and
6818/// // execute the final call using `doit()`.
6819/// // Values shown here are possibly random and not representative !
6820/// let result = hub.projects().locations_processors_processor_versions_delete("name")
6821///              .doit().await;
6822/// # }
6823/// ```
6824pub struct ProjectLocationProcessorProcessorVersionDeleteCall<'a, C>
6825where
6826    C: 'a,
6827{
6828    hub: &'a Document<C>,
6829    _name: String,
6830    _delegate: Option<&'a mut dyn common::Delegate>,
6831    _additional_params: HashMap<String, String>,
6832    _scopes: BTreeSet<String>,
6833}
6834
6835impl<'a, C> common::CallBuilder for ProjectLocationProcessorProcessorVersionDeleteCall<'a, C> {}
6836
6837impl<'a, C> ProjectLocationProcessorProcessorVersionDeleteCall<'a, C>
6838where
6839    C: common::Connector,
6840{
6841    /// Perform the operation you have build so far.
6842    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
6843        use std::borrow::Cow;
6844        use std::io::{Read, Seek};
6845
6846        use common::{url::Params, ToParts};
6847        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6848
6849        let mut dd = common::DefaultDelegate;
6850        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6851        dlg.begin(common::MethodInfo {
6852            id: "documentai.projects.locations.processors.processorVersions.delete",
6853            http_method: hyper::Method::DELETE,
6854        });
6855
6856        for &field in ["alt", "name"].iter() {
6857            if self._additional_params.contains_key(field) {
6858                dlg.finished(false);
6859                return Err(common::Error::FieldClash(field));
6860            }
6861        }
6862
6863        let mut params = Params::with_capacity(3 + self._additional_params.len());
6864        params.push("name", self._name);
6865
6866        params.extend(self._additional_params.iter());
6867
6868        params.push("alt", "json");
6869        let mut url = self.hub._base_url.clone() + "v1/{+name}";
6870        if self._scopes.is_empty() {
6871            self._scopes
6872                .insert(Scope::CloudPlatform.as_ref().to_string());
6873        }
6874
6875        #[allow(clippy::single_element_loop)]
6876        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6877            url = params.uri_replacement(url, param_name, find_this, true);
6878        }
6879        {
6880            let to_remove = ["name"];
6881            params.remove_params(&to_remove);
6882        }
6883
6884        let url = params.parse_with_url(&url);
6885
6886        loop {
6887            let token = match self
6888                .hub
6889                .auth
6890                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6891                .await
6892            {
6893                Ok(token) => token,
6894                Err(e) => match dlg.token(e) {
6895                    Ok(token) => token,
6896                    Err(e) => {
6897                        dlg.finished(false);
6898                        return Err(common::Error::MissingToken(e));
6899                    }
6900                },
6901            };
6902            let mut req_result = {
6903                let client = &self.hub.client;
6904                dlg.pre_request();
6905                let mut req_builder = hyper::Request::builder()
6906                    .method(hyper::Method::DELETE)
6907                    .uri(url.as_str())
6908                    .header(USER_AGENT, self.hub._user_agent.clone());
6909
6910                if let Some(token) = token.as_ref() {
6911                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6912                }
6913
6914                let request = req_builder
6915                    .header(CONTENT_LENGTH, 0_u64)
6916                    .body(common::to_body::<String>(None));
6917
6918                client.request(request.unwrap()).await
6919            };
6920
6921            match req_result {
6922                Err(err) => {
6923                    if let common::Retry::After(d) = dlg.http_error(&err) {
6924                        sleep(d).await;
6925                        continue;
6926                    }
6927                    dlg.finished(false);
6928                    return Err(common::Error::HttpError(err));
6929                }
6930                Ok(res) => {
6931                    let (mut parts, body) = res.into_parts();
6932                    let mut body = common::Body::new(body);
6933                    if !parts.status.is_success() {
6934                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6935                        let error = serde_json::from_str(&common::to_string(&bytes));
6936                        let response = common::to_response(parts, bytes.into());
6937
6938                        if let common::Retry::After(d) =
6939                            dlg.http_failure(&response, error.as_ref().ok())
6940                        {
6941                            sleep(d).await;
6942                            continue;
6943                        }
6944
6945                        dlg.finished(false);
6946
6947                        return Err(match error {
6948                            Ok(value) => common::Error::BadRequest(value),
6949                            _ => common::Error::Failure(response),
6950                        });
6951                    }
6952                    let response = {
6953                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6954                        let encoded = common::to_string(&bytes);
6955                        match serde_json::from_str(&encoded) {
6956                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6957                            Err(error) => {
6958                                dlg.response_json_decode_error(&encoded, &error);
6959                                return Err(common::Error::JsonDecodeError(
6960                                    encoded.to_string(),
6961                                    error,
6962                                ));
6963                            }
6964                        }
6965                    };
6966
6967                    dlg.finished(true);
6968                    return Ok(response);
6969                }
6970            }
6971        }
6972    }
6973
6974    /// Required. The processor version resource name to be deleted.
6975    ///
6976    /// Sets the *name* path property to the given value.
6977    ///
6978    /// Even though the property as already been set when instantiating this call,
6979    /// we provide this method for API completeness.
6980    pub fn name(
6981        mut self,
6982        new_value: &str,
6983    ) -> ProjectLocationProcessorProcessorVersionDeleteCall<'a, C> {
6984        self._name = new_value.to_string();
6985        self
6986    }
6987    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6988    /// while executing the actual API request.
6989    ///
6990    /// ````text
6991    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6992    /// ````
6993    ///
6994    /// Sets the *delegate* property to the given value.
6995    pub fn delegate(
6996        mut self,
6997        new_value: &'a mut dyn common::Delegate,
6998    ) -> ProjectLocationProcessorProcessorVersionDeleteCall<'a, C> {
6999        self._delegate = Some(new_value);
7000        self
7001    }
7002
7003    /// Set any additional parameter of the query string used in the request.
7004    /// It should be used to set parameters which are not yet available through their own
7005    /// setters.
7006    ///
7007    /// Please note that this method must not be used to set any of the known parameters
7008    /// which have their own setter method. If done anyway, the request will fail.
7009    ///
7010    /// # Additional Parameters
7011    ///
7012    /// * *$.xgafv* (query-string) - V1 error format.
7013    /// * *access_token* (query-string) - OAuth access token.
7014    /// * *alt* (query-string) - Data format for response.
7015    /// * *callback* (query-string) - JSONP
7016    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7017    /// * *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.
7018    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7019    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7020    /// * *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.
7021    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7022    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7023    pub fn param<T>(
7024        mut self,
7025        name: T,
7026        value: T,
7027    ) -> ProjectLocationProcessorProcessorVersionDeleteCall<'a, C>
7028    where
7029        T: AsRef<str>,
7030    {
7031        self._additional_params
7032            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7033        self
7034    }
7035
7036    /// Identifies the authorization scope for the method you are building.
7037    ///
7038    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7039    /// [`Scope::CloudPlatform`].
7040    ///
7041    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7042    /// tokens for more than one scope.
7043    ///
7044    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7045    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7046    /// sufficient, a read-write scope will do as well.
7047    pub fn add_scope<St>(
7048        mut self,
7049        scope: St,
7050    ) -> ProjectLocationProcessorProcessorVersionDeleteCall<'a, C>
7051    where
7052        St: AsRef<str>,
7053    {
7054        self._scopes.insert(String::from(scope.as_ref()));
7055        self
7056    }
7057    /// Identifies the authorization scope(s) for the method you are building.
7058    ///
7059    /// See [`Self::add_scope()`] for details.
7060    pub fn add_scopes<I, St>(
7061        mut self,
7062        scopes: I,
7063    ) -> ProjectLocationProcessorProcessorVersionDeleteCall<'a, C>
7064    where
7065        I: IntoIterator<Item = St>,
7066        St: AsRef<str>,
7067    {
7068        self._scopes
7069            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7070        self
7071    }
7072
7073    /// Removes all scopes, and no default scope will be used either.
7074    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7075    /// for details).
7076    pub fn clear_scopes(mut self) -> ProjectLocationProcessorProcessorVersionDeleteCall<'a, C> {
7077        self._scopes.clear();
7078        self
7079    }
7080}
7081
7082/// Deploys the processor version.
7083///
7084/// A builder for the *locations.processors.processorVersions.deploy* method supported by a *project* resource.
7085/// It is not used directly, but through a [`ProjectMethods`] instance.
7086///
7087/// # Example
7088///
7089/// Instantiate a resource method builder
7090///
7091/// ```test_harness,no_run
7092/// # extern crate hyper;
7093/// # extern crate hyper_rustls;
7094/// # extern crate google_documentai1 as documentai1;
7095/// use documentai1::api::GoogleCloudDocumentaiV1DeployProcessorVersionRequest;
7096/// # async fn dox() {
7097/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7098///
7099/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7100/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7101/// #     secret,
7102/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7103/// # ).build().await.unwrap();
7104///
7105/// # let client = hyper_util::client::legacy::Client::builder(
7106/// #     hyper_util::rt::TokioExecutor::new()
7107/// # )
7108/// # .build(
7109/// #     hyper_rustls::HttpsConnectorBuilder::new()
7110/// #         .with_native_roots()
7111/// #         .unwrap()
7112/// #         .https_or_http()
7113/// #         .enable_http1()
7114/// #         .build()
7115/// # );
7116/// # let mut hub = Document::new(client, auth);
7117/// // As the method needs a request, you would usually fill it with the desired information
7118/// // into the respective structure. Some of the parts shown here might not be applicable !
7119/// // Values shown here are possibly random and not representative !
7120/// let mut req = GoogleCloudDocumentaiV1DeployProcessorVersionRequest::default();
7121///
7122/// // You can configure optional parameters by calling the respective setters at will, and
7123/// // execute the final call using `doit()`.
7124/// // Values shown here are possibly random and not representative !
7125/// let result = hub.projects().locations_processors_processor_versions_deploy(req, "name")
7126///              .doit().await;
7127/// # }
7128/// ```
7129pub struct ProjectLocationProcessorProcessorVersionDeployCall<'a, C>
7130where
7131    C: 'a,
7132{
7133    hub: &'a Document<C>,
7134    _request: GoogleCloudDocumentaiV1DeployProcessorVersionRequest,
7135    _name: String,
7136    _delegate: Option<&'a mut dyn common::Delegate>,
7137    _additional_params: HashMap<String, String>,
7138    _scopes: BTreeSet<String>,
7139}
7140
7141impl<'a, C> common::CallBuilder for ProjectLocationProcessorProcessorVersionDeployCall<'a, C> {}
7142
7143impl<'a, C> ProjectLocationProcessorProcessorVersionDeployCall<'a, C>
7144where
7145    C: common::Connector,
7146{
7147    /// Perform the operation you have build so far.
7148    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
7149        use std::borrow::Cow;
7150        use std::io::{Read, Seek};
7151
7152        use common::{url::Params, ToParts};
7153        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7154
7155        let mut dd = common::DefaultDelegate;
7156        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7157        dlg.begin(common::MethodInfo {
7158            id: "documentai.projects.locations.processors.processorVersions.deploy",
7159            http_method: hyper::Method::POST,
7160        });
7161
7162        for &field in ["alt", "name"].iter() {
7163            if self._additional_params.contains_key(field) {
7164                dlg.finished(false);
7165                return Err(common::Error::FieldClash(field));
7166            }
7167        }
7168
7169        let mut params = Params::with_capacity(4 + self._additional_params.len());
7170        params.push("name", self._name);
7171
7172        params.extend(self._additional_params.iter());
7173
7174        params.push("alt", "json");
7175        let mut url = self.hub._base_url.clone() + "v1/{+name}:deploy";
7176        if self._scopes.is_empty() {
7177            self._scopes
7178                .insert(Scope::CloudPlatform.as_ref().to_string());
7179        }
7180
7181        #[allow(clippy::single_element_loop)]
7182        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7183            url = params.uri_replacement(url, param_name, find_this, true);
7184        }
7185        {
7186            let to_remove = ["name"];
7187            params.remove_params(&to_remove);
7188        }
7189
7190        let url = params.parse_with_url(&url);
7191
7192        let mut json_mime_type = mime::APPLICATION_JSON;
7193        let mut request_value_reader = {
7194            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7195            common::remove_json_null_values(&mut value);
7196            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7197            serde_json::to_writer(&mut dst, &value).unwrap();
7198            dst
7199        };
7200        let request_size = request_value_reader
7201            .seek(std::io::SeekFrom::End(0))
7202            .unwrap();
7203        request_value_reader
7204            .seek(std::io::SeekFrom::Start(0))
7205            .unwrap();
7206
7207        loop {
7208            let token = match self
7209                .hub
7210                .auth
7211                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7212                .await
7213            {
7214                Ok(token) => token,
7215                Err(e) => match dlg.token(e) {
7216                    Ok(token) => token,
7217                    Err(e) => {
7218                        dlg.finished(false);
7219                        return Err(common::Error::MissingToken(e));
7220                    }
7221                },
7222            };
7223            request_value_reader
7224                .seek(std::io::SeekFrom::Start(0))
7225                .unwrap();
7226            let mut req_result = {
7227                let client = &self.hub.client;
7228                dlg.pre_request();
7229                let mut req_builder = hyper::Request::builder()
7230                    .method(hyper::Method::POST)
7231                    .uri(url.as_str())
7232                    .header(USER_AGENT, self.hub._user_agent.clone());
7233
7234                if let Some(token) = token.as_ref() {
7235                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7236                }
7237
7238                let request = req_builder
7239                    .header(CONTENT_TYPE, json_mime_type.to_string())
7240                    .header(CONTENT_LENGTH, request_size as u64)
7241                    .body(common::to_body(
7242                        request_value_reader.get_ref().clone().into(),
7243                    ));
7244
7245                client.request(request.unwrap()).await
7246            };
7247
7248            match req_result {
7249                Err(err) => {
7250                    if let common::Retry::After(d) = dlg.http_error(&err) {
7251                        sleep(d).await;
7252                        continue;
7253                    }
7254                    dlg.finished(false);
7255                    return Err(common::Error::HttpError(err));
7256                }
7257                Ok(res) => {
7258                    let (mut parts, body) = res.into_parts();
7259                    let mut body = common::Body::new(body);
7260                    if !parts.status.is_success() {
7261                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7262                        let error = serde_json::from_str(&common::to_string(&bytes));
7263                        let response = common::to_response(parts, bytes.into());
7264
7265                        if let common::Retry::After(d) =
7266                            dlg.http_failure(&response, error.as_ref().ok())
7267                        {
7268                            sleep(d).await;
7269                            continue;
7270                        }
7271
7272                        dlg.finished(false);
7273
7274                        return Err(match error {
7275                            Ok(value) => common::Error::BadRequest(value),
7276                            _ => common::Error::Failure(response),
7277                        });
7278                    }
7279                    let response = {
7280                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7281                        let encoded = common::to_string(&bytes);
7282                        match serde_json::from_str(&encoded) {
7283                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7284                            Err(error) => {
7285                                dlg.response_json_decode_error(&encoded, &error);
7286                                return Err(common::Error::JsonDecodeError(
7287                                    encoded.to_string(),
7288                                    error,
7289                                ));
7290                            }
7291                        }
7292                    };
7293
7294                    dlg.finished(true);
7295                    return Ok(response);
7296                }
7297            }
7298        }
7299    }
7300
7301    ///
7302    /// Sets the *request* property to the given value.
7303    ///
7304    /// Even though the property as already been set when instantiating this call,
7305    /// we provide this method for API completeness.
7306    pub fn request(
7307        mut self,
7308        new_value: GoogleCloudDocumentaiV1DeployProcessorVersionRequest,
7309    ) -> ProjectLocationProcessorProcessorVersionDeployCall<'a, C> {
7310        self._request = new_value;
7311        self
7312    }
7313    /// Required. The processor version resource name to be deployed.
7314    ///
7315    /// Sets the *name* path property to the given value.
7316    ///
7317    /// Even though the property as already been set when instantiating this call,
7318    /// we provide this method for API completeness.
7319    pub fn name(
7320        mut self,
7321        new_value: &str,
7322    ) -> ProjectLocationProcessorProcessorVersionDeployCall<'a, C> {
7323        self._name = new_value.to_string();
7324        self
7325    }
7326    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7327    /// while executing the actual API request.
7328    ///
7329    /// ````text
7330    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7331    /// ````
7332    ///
7333    /// Sets the *delegate* property to the given value.
7334    pub fn delegate(
7335        mut self,
7336        new_value: &'a mut dyn common::Delegate,
7337    ) -> ProjectLocationProcessorProcessorVersionDeployCall<'a, C> {
7338        self._delegate = Some(new_value);
7339        self
7340    }
7341
7342    /// Set any additional parameter of the query string used in the request.
7343    /// It should be used to set parameters which are not yet available through their own
7344    /// setters.
7345    ///
7346    /// Please note that this method must not be used to set any of the known parameters
7347    /// which have their own setter method. If done anyway, the request will fail.
7348    ///
7349    /// # Additional Parameters
7350    ///
7351    /// * *$.xgafv* (query-string) - V1 error format.
7352    /// * *access_token* (query-string) - OAuth access token.
7353    /// * *alt* (query-string) - Data format for response.
7354    /// * *callback* (query-string) - JSONP
7355    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7356    /// * *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.
7357    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7358    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7359    /// * *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.
7360    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7361    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7362    pub fn param<T>(
7363        mut self,
7364        name: T,
7365        value: T,
7366    ) -> ProjectLocationProcessorProcessorVersionDeployCall<'a, C>
7367    where
7368        T: AsRef<str>,
7369    {
7370        self._additional_params
7371            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7372        self
7373    }
7374
7375    /// Identifies the authorization scope for the method you are building.
7376    ///
7377    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7378    /// [`Scope::CloudPlatform`].
7379    ///
7380    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7381    /// tokens for more than one scope.
7382    ///
7383    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7384    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7385    /// sufficient, a read-write scope will do as well.
7386    pub fn add_scope<St>(
7387        mut self,
7388        scope: St,
7389    ) -> ProjectLocationProcessorProcessorVersionDeployCall<'a, C>
7390    where
7391        St: AsRef<str>,
7392    {
7393        self._scopes.insert(String::from(scope.as_ref()));
7394        self
7395    }
7396    /// Identifies the authorization scope(s) for the method you are building.
7397    ///
7398    /// See [`Self::add_scope()`] for details.
7399    pub fn add_scopes<I, St>(
7400        mut self,
7401        scopes: I,
7402    ) -> ProjectLocationProcessorProcessorVersionDeployCall<'a, C>
7403    where
7404        I: IntoIterator<Item = St>,
7405        St: AsRef<str>,
7406    {
7407        self._scopes
7408            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7409        self
7410    }
7411
7412    /// Removes all scopes, and no default scope will be used either.
7413    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7414    /// for details).
7415    pub fn clear_scopes(mut self) -> ProjectLocationProcessorProcessorVersionDeployCall<'a, C> {
7416        self._scopes.clear();
7417        self
7418    }
7419}
7420
7421/// Evaluates a ProcessorVersion against annotated documents, producing an Evaluation.
7422///
7423/// A builder for the *locations.processors.processorVersions.evaluateProcessorVersion* method supported by a *project* resource.
7424/// It is not used directly, but through a [`ProjectMethods`] instance.
7425///
7426/// # Example
7427///
7428/// Instantiate a resource method builder
7429///
7430/// ```test_harness,no_run
7431/// # extern crate hyper;
7432/// # extern crate hyper_rustls;
7433/// # extern crate google_documentai1 as documentai1;
7434/// use documentai1::api::GoogleCloudDocumentaiV1EvaluateProcessorVersionRequest;
7435/// # async fn dox() {
7436/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7437///
7438/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7439/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7440/// #     secret,
7441/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7442/// # ).build().await.unwrap();
7443///
7444/// # let client = hyper_util::client::legacy::Client::builder(
7445/// #     hyper_util::rt::TokioExecutor::new()
7446/// # )
7447/// # .build(
7448/// #     hyper_rustls::HttpsConnectorBuilder::new()
7449/// #         .with_native_roots()
7450/// #         .unwrap()
7451/// #         .https_or_http()
7452/// #         .enable_http1()
7453/// #         .build()
7454/// # );
7455/// # let mut hub = Document::new(client, auth);
7456/// // As the method needs a request, you would usually fill it with the desired information
7457/// // into the respective structure. Some of the parts shown here might not be applicable !
7458/// // Values shown here are possibly random and not representative !
7459/// let mut req = GoogleCloudDocumentaiV1EvaluateProcessorVersionRequest::default();
7460///
7461/// // You can configure optional parameters by calling the respective setters at will, and
7462/// // execute the final call using `doit()`.
7463/// // Values shown here are possibly random and not representative !
7464/// let result = hub.projects().locations_processors_processor_versions_evaluate_processor_version(req, "processorVersion")
7465///              .doit().await;
7466/// # }
7467/// ```
7468pub struct ProjectLocationProcessorProcessorVersionEvaluateProcessorVersionCall<'a, C>
7469where
7470    C: 'a,
7471{
7472    hub: &'a Document<C>,
7473    _request: GoogleCloudDocumentaiV1EvaluateProcessorVersionRequest,
7474    _processor_version: String,
7475    _delegate: Option<&'a mut dyn common::Delegate>,
7476    _additional_params: HashMap<String, String>,
7477    _scopes: BTreeSet<String>,
7478}
7479
7480impl<'a, C> common::CallBuilder
7481    for ProjectLocationProcessorProcessorVersionEvaluateProcessorVersionCall<'a, C>
7482{
7483}
7484
7485impl<'a, C> ProjectLocationProcessorProcessorVersionEvaluateProcessorVersionCall<'a, C>
7486where
7487    C: common::Connector,
7488{
7489    /// Perform the operation you have build so far.
7490    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
7491        use std::borrow::Cow;
7492        use std::io::{Read, Seek};
7493
7494        use common::{url::Params, ToParts};
7495        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7496
7497        let mut dd = common::DefaultDelegate;
7498        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7499        dlg.begin(common::MethodInfo { id: "documentai.projects.locations.processors.processorVersions.evaluateProcessorVersion",
7500                               http_method: hyper::Method::POST });
7501
7502        for &field in ["alt", "processorVersion"].iter() {
7503            if self._additional_params.contains_key(field) {
7504                dlg.finished(false);
7505                return Err(common::Error::FieldClash(field));
7506            }
7507        }
7508
7509        let mut params = Params::with_capacity(4 + self._additional_params.len());
7510        params.push("processorVersion", self._processor_version);
7511
7512        params.extend(self._additional_params.iter());
7513
7514        params.push("alt", "json");
7515        let mut url =
7516            self.hub._base_url.clone() + "v1/{+processorVersion}:evaluateProcessorVersion";
7517        if self._scopes.is_empty() {
7518            self._scopes
7519                .insert(Scope::CloudPlatform.as_ref().to_string());
7520        }
7521
7522        #[allow(clippy::single_element_loop)]
7523        for &(find_this, param_name) in [("{+processorVersion}", "processorVersion")].iter() {
7524            url = params.uri_replacement(url, param_name, find_this, true);
7525        }
7526        {
7527            let to_remove = ["processorVersion"];
7528            params.remove_params(&to_remove);
7529        }
7530
7531        let url = params.parse_with_url(&url);
7532
7533        let mut json_mime_type = mime::APPLICATION_JSON;
7534        let mut request_value_reader = {
7535            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7536            common::remove_json_null_values(&mut value);
7537            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7538            serde_json::to_writer(&mut dst, &value).unwrap();
7539            dst
7540        };
7541        let request_size = request_value_reader
7542            .seek(std::io::SeekFrom::End(0))
7543            .unwrap();
7544        request_value_reader
7545            .seek(std::io::SeekFrom::Start(0))
7546            .unwrap();
7547
7548        loop {
7549            let token = match self
7550                .hub
7551                .auth
7552                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7553                .await
7554            {
7555                Ok(token) => token,
7556                Err(e) => match dlg.token(e) {
7557                    Ok(token) => token,
7558                    Err(e) => {
7559                        dlg.finished(false);
7560                        return Err(common::Error::MissingToken(e));
7561                    }
7562                },
7563            };
7564            request_value_reader
7565                .seek(std::io::SeekFrom::Start(0))
7566                .unwrap();
7567            let mut req_result = {
7568                let client = &self.hub.client;
7569                dlg.pre_request();
7570                let mut req_builder = hyper::Request::builder()
7571                    .method(hyper::Method::POST)
7572                    .uri(url.as_str())
7573                    .header(USER_AGENT, self.hub._user_agent.clone());
7574
7575                if let Some(token) = token.as_ref() {
7576                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7577                }
7578
7579                let request = req_builder
7580                    .header(CONTENT_TYPE, json_mime_type.to_string())
7581                    .header(CONTENT_LENGTH, request_size as u64)
7582                    .body(common::to_body(
7583                        request_value_reader.get_ref().clone().into(),
7584                    ));
7585
7586                client.request(request.unwrap()).await
7587            };
7588
7589            match req_result {
7590                Err(err) => {
7591                    if let common::Retry::After(d) = dlg.http_error(&err) {
7592                        sleep(d).await;
7593                        continue;
7594                    }
7595                    dlg.finished(false);
7596                    return Err(common::Error::HttpError(err));
7597                }
7598                Ok(res) => {
7599                    let (mut parts, body) = res.into_parts();
7600                    let mut body = common::Body::new(body);
7601                    if !parts.status.is_success() {
7602                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7603                        let error = serde_json::from_str(&common::to_string(&bytes));
7604                        let response = common::to_response(parts, bytes.into());
7605
7606                        if let common::Retry::After(d) =
7607                            dlg.http_failure(&response, error.as_ref().ok())
7608                        {
7609                            sleep(d).await;
7610                            continue;
7611                        }
7612
7613                        dlg.finished(false);
7614
7615                        return Err(match error {
7616                            Ok(value) => common::Error::BadRequest(value),
7617                            _ => common::Error::Failure(response),
7618                        });
7619                    }
7620                    let response = {
7621                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7622                        let encoded = common::to_string(&bytes);
7623                        match serde_json::from_str(&encoded) {
7624                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7625                            Err(error) => {
7626                                dlg.response_json_decode_error(&encoded, &error);
7627                                return Err(common::Error::JsonDecodeError(
7628                                    encoded.to_string(),
7629                                    error,
7630                                ));
7631                            }
7632                        }
7633                    };
7634
7635                    dlg.finished(true);
7636                    return Ok(response);
7637                }
7638            }
7639        }
7640    }
7641
7642    ///
7643    /// Sets the *request* property to the given value.
7644    ///
7645    /// Even though the property as already been set when instantiating this call,
7646    /// we provide this method for API completeness.
7647    pub fn request(
7648        mut self,
7649        new_value: GoogleCloudDocumentaiV1EvaluateProcessorVersionRequest,
7650    ) -> ProjectLocationProcessorProcessorVersionEvaluateProcessorVersionCall<'a, C> {
7651        self._request = new_value;
7652        self
7653    }
7654    /// Required. The resource name of the ProcessorVersion to evaluate. `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`
7655    ///
7656    /// Sets the *processor version* path property to the given value.
7657    ///
7658    /// Even though the property as already been set when instantiating this call,
7659    /// we provide this method for API completeness.
7660    pub fn processor_version(
7661        mut self,
7662        new_value: &str,
7663    ) -> ProjectLocationProcessorProcessorVersionEvaluateProcessorVersionCall<'a, C> {
7664        self._processor_version = new_value.to_string();
7665        self
7666    }
7667    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7668    /// while executing the actual API request.
7669    ///
7670    /// ````text
7671    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7672    /// ````
7673    ///
7674    /// Sets the *delegate* property to the given value.
7675    pub fn delegate(
7676        mut self,
7677        new_value: &'a mut dyn common::Delegate,
7678    ) -> ProjectLocationProcessorProcessorVersionEvaluateProcessorVersionCall<'a, C> {
7679        self._delegate = Some(new_value);
7680        self
7681    }
7682
7683    /// Set any additional parameter of the query string used in the request.
7684    /// It should be used to set parameters which are not yet available through their own
7685    /// setters.
7686    ///
7687    /// Please note that this method must not be used to set any of the known parameters
7688    /// which have their own setter method. If done anyway, the request will fail.
7689    ///
7690    /// # Additional Parameters
7691    ///
7692    /// * *$.xgafv* (query-string) - V1 error format.
7693    /// * *access_token* (query-string) - OAuth access token.
7694    /// * *alt* (query-string) - Data format for response.
7695    /// * *callback* (query-string) - JSONP
7696    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7697    /// * *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.
7698    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7699    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7700    /// * *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.
7701    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7702    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7703    pub fn param<T>(
7704        mut self,
7705        name: T,
7706        value: T,
7707    ) -> ProjectLocationProcessorProcessorVersionEvaluateProcessorVersionCall<'a, C>
7708    where
7709        T: AsRef<str>,
7710    {
7711        self._additional_params
7712            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7713        self
7714    }
7715
7716    /// Identifies the authorization scope for the method you are building.
7717    ///
7718    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7719    /// [`Scope::CloudPlatform`].
7720    ///
7721    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7722    /// tokens for more than one scope.
7723    ///
7724    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7725    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7726    /// sufficient, a read-write scope will do as well.
7727    pub fn add_scope<St>(
7728        mut self,
7729        scope: St,
7730    ) -> ProjectLocationProcessorProcessorVersionEvaluateProcessorVersionCall<'a, C>
7731    where
7732        St: AsRef<str>,
7733    {
7734        self._scopes.insert(String::from(scope.as_ref()));
7735        self
7736    }
7737    /// Identifies the authorization scope(s) for the method you are building.
7738    ///
7739    /// See [`Self::add_scope()`] for details.
7740    pub fn add_scopes<I, St>(
7741        mut self,
7742        scopes: I,
7743    ) -> ProjectLocationProcessorProcessorVersionEvaluateProcessorVersionCall<'a, C>
7744    where
7745        I: IntoIterator<Item = St>,
7746        St: AsRef<str>,
7747    {
7748        self._scopes
7749            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7750        self
7751    }
7752
7753    /// Removes all scopes, and no default scope will be used either.
7754    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7755    /// for details).
7756    pub fn clear_scopes(
7757        mut self,
7758    ) -> ProjectLocationProcessorProcessorVersionEvaluateProcessorVersionCall<'a, C> {
7759        self._scopes.clear();
7760        self
7761    }
7762}
7763
7764/// Gets a processor version detail.
7765///
7766/// A builder for the *locations.processors.processorVersions.get* method supported by a *project* resource.
7767/// It is not used directly, but through a [`ProjectMethods`] instance.
7768///
7769/// # Example
7770///
7771/// Instantiate a resource method builder
7772///
7773/// ```test_harness,no_run
7774/// # extern crate hyper;
7775/// # extern crate hyper_rustls;
7776/// # extern crate google_documentai1 as documentai1;
7777/// # async fn dox() {
7778/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7779///
7780/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7781/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7782/// #     secret,
7783/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7784/// # ).build().await.unwrap();
7785///
7786/// # let client = hyper_util::client::legacy::Client::builder(
7787/// #     hyper_util::rt::TokioExecutor::new()
7788/// # )
7789/// # .build(
7790/// #     hyper_rustls::HttpsConnectorBuilder::new()
7791/// #         .with_native_roots()
7792/// #         .unwrap()
7793/// #         .https_or_http()
7794/// #         .enable_http1()
7795/// #         .build()
7796/// # );
7797/// # let mut hub = Document::new(client, auth);
7798/// // You can configure optional parameters by calling the respective setters at will, and
7799/// // execute the final call using `doit()`.
7800/// // Values shown here are possibly random and not representative !
7801/// let result = hub.projects().locations_processors_processor_versions_get("name")
7802///              .doit().await;
7803/// # }
7804/// ```
7805pub struct ProjectLocationProcessorProcessorVersionGetCall<'a, C>
7806where
7807    C: 'a,
7808{
7809    hub: &'a Document<C>,
7810    _name: String,
7811    _delegate: Option<&'a mut dyn common::Delegate>,
7812    _additional_params: HashMap<String, String>,
7813    _scopes: BTreeSet<String>,
7814}
7815
7816impl<'a, C> common::CallBuilder for ProjectLocationProcessorProcessorVersionGetCall<'a, C> {}
7817
7818impl<'a, C> ProjectLocationProcessorProcessorVersionGetCall<'a, C>
7819where
7820    C: common::Connector,
7821{
7822    /// Perform the operation you have build so far.
7823    pub async fn doit(
7824        mut self,
7825    ) -> common::Result<(common::Response, GoogleCloudDocumentaiV1ProcessorVersion)> {
7826        use std::borrow::Cow;
7827        use std::io::{Read, Seek};
7828
7829        use common::{url::Params, ToParts};
7830        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7831
7832        let mut dd = common::DefaultDelegate;
7833        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7834        dlg.begin(common::MethodInfo {
7835            id: "documentai.projects.locations.processors.processorVersions.get",
7836            http_method: hyper::Method::GET,
7837        });
7838
7839        for &field in ["alt", "name"].iter() {
7840            if self._additional_params.contains_key(field) {
7841                dlg.finished(false);
7842                return Err(common::Error::FieldClash(field));
7843            }
7844        }
7845
7846        let mut params = Params::with_capacity(3 + self._additional_params.len());
7847        params.push("name", self._name);
7848
7849        params.extend(self._additional_params.iter());
7850
7851        params.push("alt", "json");
7852        let mut url = self.hub._base_url.clone() + "v1/{+name}";
7853        if self._scopes.is_empty() {
7854            self._scopes
7855                .insert(Scope::CloudPlatform.as_ref().to_string());
7856        }
7857
7858        #[allow(clippy::single_element_loop)]
7859        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7860            url = params.uri_replacement(url, param_name, find_this, true);
7861        }
7862        {
7863            let to_remove = ["name"];
7864            params.remove_params(&to_remove);
7865        }
7866
7867        let url = params.parse_with_url(&url);
7868
7869        loop {
7870            let token = match self
7871                .hub
7872                .auth
7873                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7874                .await
7875            {
7876                Ok(token) => token,
7877                Err(e) => match dlg.token(e) {
7878                    Ok(token) => token,
7879                    Err(e) => {
7880                        dlg.finished(false);
7881                        return Err(common::Error::MissingToken(e));
7882                    }
7883                },
7884            };
7885            let mut req_result = {
7886                let client = &self.hub.client;
7887                dlg.pre_request();
7888                let mut req_builder = hyper::Request::builder()
7889                    .method(hyper::Method::GET)
7890                    .uri(url.as_str())
7891                    .header(USER_AGENT, self.hub._user_agent.clone());
7892
7893                if let Some(token) = token.as_ref() {
7894                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7895                }
7896
7897                let request = req_builder
7898                    .header(CONTENT_LENGTH, 0_u64)
7899                    .body(common::to_body::<String>(None));
7900
7901                client.request(request.unwrap()).await
7902            };
7903
7904            match req_result {
7905                Err(err) => {
7906                    if let common::Retry::After(d) = dlg.http_error(&err) {
7907                        sleep(d).await;
7908                        continue;
7909                    }
7910                    dlg.finished(false);
7911                    return Err(common::Error::HttpError(err));
7912                }
7913                Ok(res) => {
7914                    let (mut parts, body) = res.into_parts();
7915                    let mut body = common::Body::new(body);
7916                    if !parts.status.is_success() {
7917                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7918                        let error = serde_json::from_str(&common::to_string(&bytes));
7919                        let response = common::to_response(parts, bytes.into());
7920
7921                        if let common::Retry::After(d) =
7922                            dlg.http_failure(&response, error.as_ref().ok())
7923                        {
7924                            sleep(d).await;
7925                            continue;
7926                        }
7927
7928                        dlg.finished(false);
7929
7930                        return Err(match error {
7931                            Ok(value) => common::Error::BadRequest(value),
7932                            _ => common::Error::Failure(response),
7933                        });
7934                    }
7935                    let response = {
7936                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7937                        let encoded = common::to_string(&bytes);
7938                        match serde_json::from_str(&encoded) {
7939                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7940                            Err(error) => {
7941                                dlg.response_json_decode_error(&encoded, &error);
7942                                return Err(common::Error::JsonDecodeError(
7943                                    encoded.to_string(),
7944                                    error,
7945                                ));
7946                            }
7947                        }
7948                    };
7949
7950                    dlg.finished(true);
7951                    return Ok(response);
7952                }
7953            }
7954        }
7955    }
7956
7957    /// Required. The processor resource name.
7958    ///
7959    /// Sets the *name* path property to the given value.
7960    ///
7961    /// Even though the property as already been set when instantiating this call,
7962    /// we provide this method for API completeness.
7963    pub fn name(
7964        mut self,
7965        new_value: &str,
7966    ) -> ProjectLocationProcessorProcessorVersionGetCall<'a, C> {
7967        self._name = new_value.to_string();
7968        self
7969    }
7970    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7971    /// while executing the actual API request.
7972    ///
7973    /// ````text
7974    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7975    /// ````
7976    ///
7977    /// Sets the *delegate* property to the given value.
7978    pub fn delegate(
7979        mut self,
7980        new_value: &'a mut dyn common::Delegate,
7981    ) -> ProjectLocationProcessorProcessorVersionGetCall<'a, C> {
7982        self._delegate = Some(new_value);
7983        self
7984    }
7985
7986    /// Set any additional parameter of the query string used in the request.
7987    /// It should be used to set parameters which are not yet available through their own
7988    /// setters.
7989    ///
7990    /// Please note that this method must not be used to set any of the known parameters
7991    /// which have their own setter method. If done anyway, the request will fail.
7992    ///
7993    /// # Additional Parameters
7994    ///
7995    /// * *$.xgafv* (query-string) - V1 error format.
7996    /// * *access_token* (query-string) - OAuth access token.
7997    /// * *alt* (query-string) - Data format for response.
7998    /// * *callback* (query-string) - JSONP
7999    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8000    /// * *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.
8001    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8002    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8003    /// * *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.
8004    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8005    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8006    pub fn param<T>(
8007        mut self,
8008        name: T,
8009        value: T,
8010    ) -> ProjectLocationProcessorProcessorVersionGetCall<'a, C>
8011    where
8012        T: AsRef<str>,
8013    {
8014        self._additional_params
8015            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8016        self
8017    }
8018
8019    /// Identifies the authorization scope for the method you are building.
8020    ///
8021    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8022    /// [`Scope::CloudPlatform`].
8023    ///
8024    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8025    /// tokens for more than one scope.
8026    ///
8027    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8028    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8029    /// sufficient, a read-write scope will do as well.
8030    pub fn add_scope<St>(
8031        mut self,
8032        scope: St,
8033    ) -> ProjectLocationProcessorProcessorVersionGetCall<'a, C>
8034    where
8035        St: AsRef<str>,
8036    {
8037        self._scopes.insert(String::from(scope.as_ref()));
8038        self
8039    }
8040    /// Identifies the authorization scope(s) for the method you are building.
8041    ///
8042    /// See [`Self::add_scope()`] for details.
8043    pub fn add_scopes<I, St>(
8044        mut self,
8045        scopes: I,
8046    ) -> ProjectLocationProcessorProcessorVersionGetCall<'a, C>
8047    where
8048        I: IntoIterator<Item = St>,
8049        St: AsRef<str>,
8050    {
8051        self._scopes
8052            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8053        self
8054    }
8055
8056    /// Removes all scopes, and no default scope will be used either.
8057    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8058    /// for details).
8059    pub fn clear_scopes(mut self) -> ProjectLocationProcessorProcessorVersionGetCall<'a, C> {
8060        self._scopes.clear();
8061        self
8062    }
8063}
8064
8065/// Lists all versions of a processor.
8066///
8067/// A builder for the *locations.processors.processorVersions.list* method supported by a *project* resource.
8068/// It is not used directly, but through a [`ProjectMethods`] instance.
8069///
8070/// # Example
8071///
8072/// Instantiate a resource method builder
8073///
8074/// ```test_harness,no_run
8075/// # extern crate hyper;
8076/// # extern crate hyper_rustls;
8077/// # extern crate google_documentai1 as documentai1;
8078/// # async fn dox() {
8079/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8080///
8081/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8082/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8083/// #     secret,
8084/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8085/// # ).build().await.unwrap();
8086///
8087/// # let client = hyper_util::client::legacy::Client::builder(
8088/// #     hyper_util::rt::TokioExecutor::new()
8089/// # )
8090/// # .build(
8091/// #     hyper_rustls::HttpsConnectorBuilder::new()
8092/// #         .with_native_roots()
8093/// #         .unwrap()
8094/// #         .https_or_http()
8095/// #         .enable_http1()
8096/// #         .build()
8097/// # );
8098/// # let mut hub = Document::new(client, auth);
8099/// // You can configure optional parameters by calling the respective setters at will, and
8100/// // execute the final call using `doit()`.
8101/// // Values shown here are possibly random and not representative !
8102/// let result = hub.projects().locations_processors_processor_versions_list("parent")
8103///              .page_token("ut")
8104///              .page_size(-12)
8105///              .doit().await;
8106/// # }
8107/// ```
8108pub struct ProjectLocationProcessorProcessorVersionListCall<'a, C>
8109where
8110    C: 'a,
8111{
8112    hub: &'a Document<C>,
8113    _parent: String,
8114    _page_token: Option<String>,
8115    _page_size: Option<i32>,
8116    _delegate: Option<&'a mut dyn common::Delegate>,
8117    _additional_params: HashMap<String, String>,
8118    _scopes: BTreeSet<String>,
8119}
8120
8121impl<'a, C> common::CallBuilder for ProjectLocationProcessorProcessorVersionListCall<'a, C> {}
8122
8123impl<'a, C> ProjectLocationProcessorProcessorVersionListCall<'a, C>
8124where
8125    C: common::Connector,
8126{
8127    /// Perform the operation you have build so far.
8128    pub async fn doit(
8129        mut self,
8130    ) -> common::Result<(
8131        common::Response,
8132        GoogleCloudDocumentaiV1ListProcessorVersionsResponse,
8133    )> {
8134        use std::borrow::Cow;
8135        use std::io::{Read, Seek};
8136
8137        use common::{url::Params, ToParts};
8138        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8139
8140        let mut dd = common::DefaultDelegate;
8141        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8142        dlg.begin(common::MethodInfo {
8143            id: "documentai.projects.locations.processors.processorVersions.list",
8144            http_method: hyper::Method::GET,
8145        });
8146
8147        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
8148            if self._additional_params.contains_key(field) {
8149                dlg.finished(false);
8150                return Err(common::Error::FieldClash(field));
8151            }
8152        }
8153
8154        let mut params = Params::with_capacity(5 + self._additional_params.len());
8155        params.push("parent", self._parent);
8156        if let Some(value) = self._page_token.as_ref() {
8157            params.push("pageToken", value);
8158        }
8159        if let Some(value) = self._page_size.as_ref() {
8160            params.push("pageSize", value.to_string());
8161        }
8162
8163        params.extend(self._additional_params.iter());
8164
8165        params.push("alt", "json");
8166        let mut url = self.hub._base_url.clone() + "v1/{+parent}/processorVersions";
8167        if self._scopes.is_empty() {
8168            self._scopes
8169                .insert(Scope::CloudPlatform.as_ref().to_string());
8170        }
8171
8172        #[allow(clippy::single_element_loop)]
8173        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8174            url = params.uri_replacement(url, param_name, find_this, true);
8175        }
8176        {
8177            let to_remove = ["parent"];
8178            params.remove_params(&to_remove);
8179        }
8180
8181        let url = params.parse_with_url(&url);
8182
8183        loop {
8184            let token = match self
8185                .hub
8186                .auth
8187                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8188                .await
8189            {
8190                Ok(token) => token,
8191                Err(e) => match dlg.token(e) {
8192                    Ok(token) => token,
8193                    Err(e) => {
8194                        dlg.finished(false);
8195                        return Err(common::Error::MissingToken(e));
8196                    }
8197                },
8198            };
8199            let mut req_result = {
8200                let client = &self.hub.client;
8201                dlg.pre_request();
8202                let mut req_builder = hyper::Request::builder()
8203                    .method(hyper::Method::GET)
8204                    .uri(url.as_str())
8205                    .header(USER_AGENT, self.hub._user_agent.clone());
8206
8207                if let Some(token) = token.as_ref() {
8208                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8209                }
8210
8211                let request = req_builder
8212                    .header(CONTENT_LENGTH, 0_u64)
8213                    .body(common::to_body::<String>(None));
8214
8215                client.request(request.unwrap()).await
8216            };
8217
8218            match req_result {
8219                Err(err) => {
8220                    if let common::Retry::After(d) = dlg.http_error(&err) {
8221                        sleep(d).await;
8222                        continue;
8223                    }
8224                    dlg.finished(false);
8225                    return Err(common::Error::HttpError(err));
8226                }
8227                Ok(res) => {
8228                    let (mut parts, body) = res.into_parts();
8229                    let mut body = common::Body::new(body);
8230                    if !parts.status.is_success() {
8231                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8232                        let error = serde_json::from_str(&common::to_string(&bytes));
8233                        let response = common::to_response(parts, bytes.into());
8234
8235                        if let common::Retry::After(d) =
8236                            dlg.http_failure(&response, error.as_ref().ok())
8237                        {
8238                            sleep(d).await;
8239                            continue;
8240                        }
8241
8242                        dlg.finished(false);
8243
8244                        return Err(match error {
8245                            Ok(value) => common::Error::BadRequest(value),
8246                            _ => common::Error::Failure(response),
8247                        });
8248                    }
8249                    let response = {
8250                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8251                        let encoded = common::to_string(&bytes);
8252                        match serde_json::from_str(&encoded) {
8253                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8254                            Err(error) => {
8255                                dlg.response_json_decode_error(&encoded, &error);
8256                                return Err(common::Error::JsonDecodeError(
8257                                    encoded.to_string(),
8258                                    error,
8259                                ));
8260                            }
8261                        }
8262                    };
8263
8264                    dlg.finished(true);
8265                    return Ok(response);
8266                }
8267            }
8268        }
8269    }
8270
8271    /// Required. The parent (project, location and processor) to list all versions. Format: `projects/{project}/locations/{location}/processors/{processor}`
8272    ///
8273    /// Sets the *parent* path property to the given value.
8274    ///
8275    /// Even though the property as already been set when instantiating this call,
8276    /// we provide this method for API completeness.
8277    pub fn parent(
8278        mut self,
8279        new_value: &str,
8280    ) -> ProjectLocationProcessorProcessorVersionListCall<'a, C> {
8281        self._parent = new_value.to_string();
8282        self
8283    }
8284    /// We will return the processor versions sorted by creation time. The page token will point to the next processor version.
8285    ///
8286    /// Sets the *page token* query property to the given value.
8287    pub fn page_token(
8288        mut self,
8289        new_value: &str,
8290    ) -> ProjectLocationProcessorProcessorVersionListCall<'a, C> {
8291        self._page_token = Some(new_value.to_string());
8292        self
8293    }
8294    /// The maximum number of processor versions to return. If unspecified, at most `10` processor versions will be returned. The maximum value is `20`. Values above `20` will be coerced to `20`.
8295    ///
8296    /// Sets the *page size* query property to the given value.
8297    pub fn page_size(
8298        mut self,
8299        new_value: i32,
8300    ) -> ProjectLocationProcessorProcessorVersionListCall<'a, C> {
8301        self._page_size = Some(new_value);
8302        self
8303    }
8304    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8305    /// while executing the actual API request.
8306    ///
8307    /// ````text
8308    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8309    /// ````
8310    ///
8311    /// Sets the *delegate* property to the given value.
8312    pub fn delegate(
8313        mut self,
8314        new_value: &'a mut dyn common::Delegate,
8315    ) -> ProjectLocationProcessorProcessorVersionListCall<'a, C> {
8316        self._delegate = Some(new_value);
8317        self
8318    }
8319
8320    /// Set any additional parameter of the query string used in the request.
8321    /// It should be used to set parameters which are not yet available through their own
8322    /// setters.
8323    ///
8324    /// Please note that this method must not be used to set any of the known parameters
8325    /// which have their own setter method. If done anyway, the request will fail.
8326    ///
8327    /// # Additional Parameters
8328    ///
8329    /// * *$.xgafv* (query-string) - V1 error format.
8330    /// * *access_token* (query-string) - OAuth access token.
8331    /// * *alt* (query-string) - Data format for response.
8332    /// * *callback* (query-string) - JSONP
8333    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8334    /// * *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.
8335    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8336    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8337    /// * *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.
8338    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8339    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8340    pub fn param<T>(
8341        mut self,
8342        name: T,
8343        value: T,
8344    ) -> ProjectLocationProcessorProcessorVersionListCall<'a, C>
8345    where
8346        T: AsRef<str>,
8347    {
8348        self._additional_params
8349            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8350        self
8351    }
8352
8353    /// Identifies the authorization scope for the method you are building.
8354    ///
8355    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8356    /// [`Scope::CloudPlatform`].
8357    ///
8358    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8359    /// tokens for more than one scope.
8360    ///
8361    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8362    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8363    /// sufficient, a read-write scope will do as well.
8364    pub fn add_scope<St>(
8365        mut self,
8366        scope: St,
8367    ) -> ProjectLocationProcessorProcessorVersionListCall<'a, C>
8368    where
8369        St: AsRef<str>,
8370    {
8371        self._scopes.insert(String::from(scope.as_ref()));
8372        self
8373    }
8374    /// Identifies the authorization scope(s) for the method you are building.
8375    ///
8376    /// See [`Self::add_scope()`] for details.
8377    pub fn add_scopes<I, St>(
8378        mut self,
8379        scopes: I,
8380    ) -> ProjectLocationProcessorProcessorVersionListCall<'a, C>
8381    where
8382        I: IntoIterator<Item = St>,
8383        St: AsRef<str>,
8384    {
8385        self._scopes
8386            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8387        self
8388    }
8389
8390    /// Removes all scopes, and no default scope will be used either.
8391    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8392    /// for details).
8393    pub fn clear_scopes(mut self) -> ProjectLocationProcessorProcessorVersionListCall<'a, C> {
8394        self._scopes.clear();
8395        self
8396    }
8397}
8398
8399/// Processes a single document.
8400///
8401/// A builder for the *locations.processors.processorVersions.process* method supported by a *project* resource.
8402/// It is not used directly, but through a [`ProjectMethods`] instance.
8403///
8404/// # Example
8405///
8406/// Instantiate a resource method builder
8407///
8408/// ```test_harness,no_run
8409/// # extern crate hyper;
8410/// # extern crate hyper_rustls;
8411/// # extern crate google_documentai1 as documentai1;
8412/// use documentai1::api::GoogleCloudDocumentaiV1ProcessRequest;
8413/// # async fn dox() {
8414/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8415///
8416/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8417/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8418/// #     secret,
8419/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8420/// # ).build().await.unwrap();
8421///
8422/// # let client = hyper_util::client::legacy::Client::builder(
8423/// #     hyper_util::rt::TokioExecutor::new()
8424/// # )
8425/// # .build(
8426/// #     hyper_rustls::HttpsConnectorBuilder::new()
8427/// #         .with_native_roots()
8428/// #         .unwrap()
8429/// #         .https_or_http()
8430/// #         .enable_http1()
8431/// #         .build()
8432/// # );
8433/// # let mut hub = Document::new(client, auth);
8434/// // As the method needs a request, you would usually fill it with the desired information
8435/// // into the respective structure. Some of the parts shown here might not be applicable !
8436/// // Values shown here are possibly random and not representative !
8437/// let mut req = GoogleCloudDocumentaiV1ProcessRequest::default();
8438///
8439/// // You can configure optional parameters by calling the respective setters at will, and
8440/// // execute the final call using `doit()`.
8441/// // Values shown here are possibly random and not representative !
8442/// let result = hub.projects().locations_processors_processor_versions_process(req, "name")
8443///              .doit().await;
8444/// # }
8445/// ```
8446pub struct ProjectLocationProcessorProcessorVersionProcesCall<'a, C>
8447where
8448    C: 'a,
8449{
8450    hub: &'a Document<C>,
8451    _request: GoogleCloudDocumentaiV1ProcessRequest,
8452    _name: String,
8453    _delegate: Option<&'a mut dyn common::Delegate>,
8454    _additional_params: HashMap<String, String>,
8455    _scopes: BTreeSet<String>,
8456}
8457
8458impl<'a, C> common::CallBuilder for ProjectLocationProcessorProcessorVersionProcesCall<'a, C> {}
8459
8460impl<'a, C> ProjectLocationProcessorProcessorVersionProcesCall<'a, C>
8461where
8462    C: common::Connector,
8463{
8464    /// Perform the operation you have build so far.
8465    pub async fn doit(
8466        mut self,
8467    ) -> common::Result<(common::Response, GoogleCloudDocumentaiV1ProcessResponse)> {
8468        use std::borrow::Cow;
8469        use std::io::{Read, Seek};
8470
8471        use common::{url::Params, ToParts};
8472        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8473
8474        let mut dd = common::DefaultDelegate;
8475        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8476        dlg.begin(common::MethodInfo {
8477            id: "documentai.projects.locations.processors.processorVersions.process",
8478            http_method: hyper::Method::POST,
8479        });
8480
8481        for &field in ["alt", "name"].iter() {
8482            if self._additional_params.contains_key(field) {
8483                dlg.finished(false);
8484                return Err(common::Error::FieldClash(field));
8485            }
8486        }
8487
8488        let mut params = Params::with_capacity(4 + self._additional_params.len());
8489        params.push("name", self._name);
8490
8491        params.extend(self._additional_params.iter());
8492
8493        params.push("alt", "json");
8494        let mut url = self.hub._base_url.clone() + "v1/{+name}:process";
8495        if self._scopes.is_empty() {
8496            self._scopes
8497                .insert(Scope::CloudPlatform.as_ref().to_string());
8498        }
8499
8500        #[allow(clippy::single_element_loop)]
8501        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8502            url = params.uri_replacement(url, param_name, find_this, true);
8503        }
8504        {
8505            let to_remove = ["name"];
8506            params.remove_params(&to_remove);
8507        }
8508
8509        let url = params.parse_with_url(&url);
8510
8511        let mut json_mime_type = mime::APPLICATION_JSON;
8512        let mut request_value_reader = {
8513            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8514            common::remove_json_null_values(&mut value);
8515            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8516            serde_json::to_writer(&mut dst, &value).unwrap();
8517            dst
8518        };
8519        let request_size = request_value_reader
8520            .seek(std::io::SeekFrom::End(0))
8521            .unwrap();
8522        request_value_reader
8523            .seek(std::io::SeekFrom::Start(0))
8524            .unwrap();
8525
8526        loop {
8527            let token = match self
8528                .hub
8529                .auth
8530                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8531                .await
8532            {
8533                Ok(token) => token,
8534                Err(e) => match dlg.token(e) {
8535                    Ok(token) => token,
8536                    Err(e) => {
8537                        dlg.finished(false);
8538                        return Err(common::Error::MissingToken(e));
8539                    }
8540                },
8541            };
8542            request_value_reader
8543                .seek(std::io::SeekFrom::Start(0))
8544                .unwrap();
8545            let mut req_result = {
8546                let client = &self.hub.client;
8547                dlg.pre_request();
8548                let mut req_builder = hyper::Request::builder()
8549                    .method(hyper::Method::POST)
8550                    .uri(url.as_str())
8551                    .header(USER_AGENT, self.hub._user_agent.clone());
8552
8553                if let Some(token) = token.as_ref() {
8554                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8555                }
8556
8557                let request = req_builder
8558                    .header(CONTENT_TYPE, json_mime_type.to_string())
8559                    .header(CONTENT_LENGTH, request_size as u64)
8560                    .body(common::to_body(
8561                        request_value_reader.get_ref().clone().into(),
8562                    ));
8563
8564                client.request(request.unwrap()).await
8565            };
8566
8567            match req_result {
8568                Err(err) => {
8569                    if let common::Retry::After(d) = dlg.http_error(&err) {
8570                        sleep(d).await;
8571                        continue;
8572                    }
8573                    dlg.finished(false);
8574                    return Err(common::Error::HttpError(err));
8575                }
8576                Ok(res) => {
8577                    let (mut parts, body) = res.into_parts();
8578                    let mut body = common::Body::new(body);
8579                    if !parts.status.is_success() {
8580                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8581                        let error = serde_json::from_str(&common::to_string(&bytes));
8582                        let response = common::to_response(parts, bytes.into());
8583
8584                        if let common::Retry::After(d) =
8585                            dlg.http_failure(&response, error.as_ref().ok())
8586                        {
8587                            sleep(d).await;
8588                            continue;
8589                        }
8590
8591                        dlg.finished(false);
8592
8593                        return Err(match error {
8594                            Ok(value) => common::Error::BadRequest(value),
8595                            _ => common::Error::Failure(response),
8596                        });
8597                    }
8598                    let response = {
8599                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8600                        let encoded = common::to_string(&bytes);
8601                        match serde_json::from_str(&encoded) {
8602                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8603                            Err(error) => {
8604                                dlg.response_json_decode_error(&encoded, &error);
8605                                return Err(common::Error::JsonDecodeError(
8606                                    encoded.to_string(),
8607                                    error,
8608                                ));
8609                            }
8610                        }
8611                    };
8612
8613                    dlg.finished(true);
8614                    return Ok(response);
8615                }
8616            }
8617        }
8618    }
8619
8620    ///
8621    /// Sets the *request* property to the given value.
8622    ///
8623    /// Even though the property as already been set when instantiating this call,
8624    /// we provide this method for API completeness.
8625    pub fn request(
8626        mut self,
8627        new_value: GoogleCloudDocumentaiV1ProcessRequest,
8628    ) -> ProjectLocationProcessorProcessorVersionProcesCall<'a, C> {
8629        self._request = new_value;
8630        self
8631    }
8632    /// Required. The resource name of the Processor or ProcessorVersion to use for processing. If a Processor is specified, the server will use its default version. Format: `projects/{project}/locations/{location}/processors/{processor}`, or `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`
8633    ///
8634    /// Sets the *name* path property to the given value.
8635    ///
8636    /// Even though the property as already been set when instantiating this call,
8637    /// we provide this method for API completeness.
8638    pub fn name(
8639        mut self,
8640        new_value: &str,
8641    ) -> ProjectLocationProcessorProcessorVersionProcesCall<'a, C> {
8642        self._name = new_value.to_string();
8643        self
8644    }
8645    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8646    /// while executing the actual API request.
8647    ///
8648    /// ````text
8649    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8650    /// ````
8651    ///
8652    /// Sets the *delegate* property to the given value.
8653    pub fn delegate(
8654        mut self,
8655        new_value: &'a mut dyn common::Delegate,
8656    ) -> ProjectLocationProcessorProcessorVersionProcesCall<'a, C> {
8657        self._delegate = Some(new_value);
8658        self
8659    }
8660
8661    /// Set any additional parameter of the query string used in the request.
8662    /// It should be used to set parameters which are not yet available through their own
8663    /// setters.
8664    ///
8665    /// Please note that this method must not be used to set any of the known parameters
8666    /// which have their own setter method. If done anyway, the request will fail.
8667    ///
8668    /// # Additional Parameters
8669    ///
8670    /// * *$.xgafv* (query-string) - V1 error format.
8671    /// * *access_token* (query-string) - OAuth access token.
8672    /// * *alt* (query-string) - Data format for response.
8673    /// * *callback* (query-string) - JSONP
8674    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8675    /// * *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.
8676    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8677    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8678    /// * *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.
8679    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8680    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8681    pub fn param<T>(
8682        mut self,
8683        name: T,
8684        value: T,
8685    ) -> ProjectLocationProcessorProcessorVersionProcesCall<'a, C>
8686    where
8687        T: AsRef<str>,
8688    {
8689        self._additional_params
8690            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8691        self
8692    }
8693
8694    /// Identifies the authorization scope for the method you are building.
8695    ///
8696    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8697    /// [`Scope::CloudPlatform`].
8698    ///
8699    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8700    /// tokens for more than one scope.
8701    ///
8702    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8703    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8704    /// sufficient, a read-write scope will do as well.
8705    pub fn add_scope<St>(
8706        mut self,
8707        scope: St,
8708    ) -> ProjectLocationProcessorProcessorVersionProcesCall<'a, C>
8709    where
8710        St: AsRef<str>,
8711    {
8712        self._scopes.insert(String::from(scope.as_ref()));
8713        self
8714    }
8715    /// Identifies the authorization scope(s) for the method you are building.
8716    ///
8717    /// See [`Self::add_scope()`] for details.
8718    pub fn add_scopes<I, St>(
8719        mut self,
8720        scopes: I,
8721    ) -> ProjectLocationProcessorProcessorVersionProcesCall<'a, C>
8722    where
8723        I: IntoIterator<Item = St>,
8724        St: AsRef<str>,
8725    {
8726        self._scopes
8727            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8728        self
8729    }
8730
8731    /// Removes all scopes, and no default scope will be used either.
8732    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8733    /// for details).
8734    pub fn clear_scopes(mut self) -> ProjectLocationProcessorProcessorVersionProcesCall<'a, C> {
8735        self._scopes.clear();
8736        self
8737    }
8738}
8739
8740/// Trains a new processor version. Operation metadata is returned as TrainProcessorVersionMetadata.
8741///
8742/// A builder for the *locations.processors.processorVersions.train* method supported by a *project* resource.
8743/// It is not used directly, but through a [`ProjectMethods`] instance.
8744///
8745/// # Example
8746///
8747/// Instantiate a resource method builder
8748///
8749/// ```test_harness,no_run
8750/// # extern crate hyper;
8751/// # extern crate hyper_rustls;
8752/// # extern crate google_documentai1 as documentai1;
8753/// use documentai1::api::GoogleCloudDocumentaiV1TrainProcessorVersionRequest;
8754/// # async fn dox() {
8755/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8756///
8757/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8758/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8759/// #     secret,
8760/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8761/// # ).build().await.unwrap();
8762///
8763/// # let client = hyper_util::client::legacy::Client::builder(
8764/// #     hyper_util::rt::TokioExecutor::new()
8765/// # )
8766/// # .build(
8767/// #     hyper_rustls::HttpsConnectorBuilder::new()
8768/// #         .with_native_roots()
8769/// #         .unwrap()
8770/// #         .https_or_http()
8771/// #         .enable_http1()
8772/// #         .build()
8773/// # );
8774/// # let mut hub = Document::new(client, auth);
8775/// // As the method needs a request, you would usually fill it with the desired information
8776/// // into the respective structure. Some of the parts shown here might not be applicable !
8777/// // Values shown here are possibly random and not representative !
8778/// let mut req = GoogleCloudDocumentaiV1TrainProcessorVersionRequest::default();
8779///
8780/// // You can configure optional parameters by calling the respective setters at will, and
8781/// // execute the final call using `doit()`.
8782/// // Values shown here are possibly random and not representative !
8783/// let result = hub.projects().locations_processors_processor_versions_train(req, "parent")
8784///              .doit().await;
8785/// # }
8786/// ```
8787pub struct ProjectLocationProcessorProcessorVersionTrainCall<'a, C>
8788where
8789    C: 'a,
8790{
8791    hub: &'a Document<C>,
8792    _request: GoogleCloudDocumentaiV1TrainProcessorVersionRequest,
8793    _parent: String,
8794    _delegate: Option<&'a mut dyn common::Delegate>,
8795    _additional_params: HashMap<String, String>,
8796    _scopes: BTreeSet<String>,
8797}
8798
8799impl<'a, C> common::CallBuilder for ProjectLocationProcessorProcessorVersionTrainCall<'a, C> {}
8800
8801impl<'a, C> ProjectLocationProcessorProcessorVersionTrainCall<'a, C>
8802where
8803    C: common::Connector,
8804{
8805    /// Perform the operation you have build so far.
8806    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
8807        use std::borrow::Cow;
8808        use std::io::{Read, Seek};
8809
8810        use common::{url::Params, ToParts};
8811        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8812
8813        let mut dd = common::DefaultDelegate;
8814        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8815        dlg.begin(common::MethodInfo {
8816            id: "documentai.projects.locations.processors.processorVersions.train",
8817            http_method: hyper::Method::POST,
8818        });
8819
8820        for &field in ["alt", "parent"].iter() {
8821            if self._additional_params.contains_key(field) {
8822                dlg.finished(false);
8823                return Err(common::Error::FieldClash(field));
8824            }
8825        }
8826
8827        let mut params = Params::with_capacity(4 + self._additional_params.len());
8828        params.push("parent", self._parent);
8829
8830        params.extend(self._additional_params.iter());
8831
8832        params.push("alt", "json");
8833        let mut url = self.hub._base_url.clone() + "v1/{+parent}/processorVersions:train";
8834        if self._scopes.is_empty() {
8835            self._scopes
8836                .insert(Scope::CloudPlatform.as_ref().to_string());
8837        }
8838
8839        #[allow(clippy::single_element_loop)]
8840        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8841            url = params.uri_replacement(url, param_name, find_this, true);
8842        }
8843        {
8844            let to_remove = ["parent"];
8845            params.remove_params(&to_remove);
8846        }
8847
8848        let url = params.parse_with_url(&url);
8849
8850        let mut json_mime_type = mime::APPLICATION_JSON;
8851        let mut request_value_reader = {
8852            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8853            common::remove_json_null_values(&mut value);
8854            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8855            serde_json::to_writer(&mut dst, &value).unwrap();
8856            dst
8857        };
8858        let request_size = request_value_reader
8859            .seek(std::io::SeekFrom::End(0))
8860            .unwrap();
8861        request_value_reader
8862            .seek(std::io::SeekFrom::Start(0))
8863            .unwrap();
8864
8865        loop {
8866            let token = match self
8867                .hub
8868                .auth
8869                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8870                .await
8871            {
8872                Ok(token) => token,
8873                Err(e) => match dlg.token(e) {
8874                    Ok(token) => token,
8875                    Err(e) => {
8876                        dlg.finished(false);
8877                        return Err(common::Error::MissingToken(e));
8878                    }
8879                },
8880            };
8881            request_value_reader
8882                .seek(std::io::SeekFrom::Start(0))
8883                .unwrap();
8884            let mut req_result = {
8885                let client = &self.hub.client;
8886                dlg.pre_request();
8887                let mut req_builder = hyper::Request::builder()
8888                    .method(hyper::Method::POST)
8889                    .uri(url.as_str())
8890                    .header(USER_AGENT, self.hub._user_agent.clone());
8891
8892                if let Some(token) = token.as_ref() {
8893                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8894                }
8895
8896                let request = req_builder
8897                    .header(CONTENT_TYPE, json_mime_type.to_string())
8898                    .header(CONTENT_LENGTH, request_size as u64)
8899                    .body(common::to_body(
8900                        request_value_reader.get_ref().clone().into(),
8901                    ));
8902
8903                client.request(request.unwrap()).await
8904            };
8905
8906            match req_result {
8907                Err(err) => {
8908                    if let common::Retry::After(d) = dlg.http_error(&err) {
8909                        sleep(d).await;
8910                        continue;
8911                    }
8912                    dlg.finished(false);
8913                    return Err(common::Error::HttpError(err));
8914                }
8915                Ok(res) => {
8916                    let (mut parts, body) = res.into_parts();
8917                    let mut body = common::Body::new(body);
8918                    if !parts.status.is_success() {
8919                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8920                        let error = serde_json::from_str(&common::to_string(&bytes));
8921                        let response = common::to_response(parts, bytes.into());
8922
8923                        if let common::Retry::After(d) =
8924                            dlg.http_failure(&response, error.as_ref().ok())
8925                        {
8926                            sleep(d).await;
8927                            continue;
8928                        }
8929
8930                        dlg.finished(false);
8931
8932                        return Err(match error {
8933                            Ok(value) => common::Error::BadRequest(value),
8934                            _ => common::Error::Failure(response),
8935                        });
8936                    }
8937                    let response = {
8938                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8939                        let encoded = common::to_string(&bytes);
8940                        match serde_json::from_str(&encoded) {
8941                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8942                            Err(error) => {
8943                                dlg.response_json_decode_error(&encoded, &error);
8944                                return Err(common::Error::JsonDecodeError(
8945                                    encoded.to_string(),
8946                                    error,
8947                                ));
8948                            }
8949                        }
8950                    };
8951
8952                    dlg.finished(true);
8953                    return Ok(response);
8954                }
8955            }
8956        }
8957    }
8958
8959    ///
8960    /// Sets the *request* property to the given value.
8961    ///
8962    /// Even though the property as already been set when instantiating this call,
8963    /// we provide this method for API completeness.
8964    pub fn request(
8965        mut self,
8966        new_value: GoogleCloudDocumentaiV1TrainProcessorVersionRequest,
8967    ) -> ProjectLocationProcessorProcessorVersionTrainCall<'a, C> {
8968        self._request = new_value;
8969        self
8970    }
8971    /// Required. The parent (project, location and processor) to create the new version for. Format: `projects/{project}/locations/{location}/processors/{processor}`.
8972    ///
8973    /// Sets the *parent* path property to the given value.
8974    ///
8975    /// Even though the property as already been set when instantiating this call,
8976    /// we provide this method for API completeness.
8977    pub fn parent(
8978        mut self,
8979        new_value: &str,
8980    ) -> ProjectLocationProcessorProcessorVersionTrainCall<'a, C> {
8981        self._parent = new_value.to_string();
8982        self
8983    }
8984    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8985    /// while executing the actual API request.
8986    ///
8987    /// ````text
8988    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8989    /// ````
8990    ///
8991    /// Sets the *delegate* property to the given value.
8992    pub fn delegate(
8993        mut self,
8994        new_value: &'a mut dyn common::Delegate,
8995    ) -> ProjectLocationProcessorProcessorVersionTrainCall<'a, C> {
8996        self._delegate = Some(new_value);
8997        self
8998    }
8999
9000    /// Set any additional parameter of the query string used in the request.
9001    /// It should be used to set parameters which are not yet available through their own
9002    /// setters.
9003    ///
9004    /// Please note that this method must not be used to set any of the known parameters
9005    /// which have their own setter method. If done anyway, the request will fail.
9006    ///
9007    /// # Additional Parameters
9008    ///
9009    /// * *$.xgafv* (query-string) - V1 error format.
9010    /// * *access_token* (query-string) - OAuth access token.
9011    /// * *alt* (query-string) - Data format for response.
9012    /// * *callback* (query-string) - JSONP
9013    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9014    /// * *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.
9015    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9016    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9017    /// * *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.
9018    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9019    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9020    pub fn param<T>(
9021        mut self,
9022        name: T,
9023        value: T,
9024    ) -> ProjectLocationProcessorProcessorVersionTrainCall<'a, C>
9025    where
9026        T: AsRef<str>,
9027    {
9028        self._additional_params
9029            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9030        self
9031    }
9032
9033    /// Identifies the authorization scope for the method you are building.
9034    ///
9035    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9036    /// [`Scope::CloudPlatform`].
9037    ///
9038    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9039    /// tokens for more than one scope.
9040    ///
9041    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9042    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9043    /// sufficient, a read-write scope will do as well.
9044    pub fn add_scope<St>(
9045        mut self,
9046        scope: St,
9047    ) -> ProjectLocationProcessorProcessorVersionTrainCall<'a, C>
9048    where
9049        St: AsRef<str>,
9050    {
9051        self._scopes.insert(String::from(scope.as_ref()));
9052        self
9053    }
9054    /// Identifies the authorization scope(s) for the method you are building.
9055    ///
9056    /// See [`Self::add_scope()`] for details.
9057    pub fn add_scopes<I, St>(
9058        mut self,
9059        scopes: I,
9060    ) -> ProjectLocationProcessorProcessorVersionTrainCall<'a, C>
9061    where
9062        I: IntoIterator<Item = St>,
9063        St: AsRef<str>,
9064    {
9065        self._scopes
9066            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9067        self
9068    }
9069
9070    /// Removes all scopes, and no default scope will be used either.
9071    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9072    /// for details).
9073    pub fn clear_scopes(mut self) -> ProjectLocationProcessorProcessorVersionTrainCall<'a, C> {
9074        self._scopes.clear();
9075        self
9076    }
9077}
9078
9079/// Undeploys the processor version.
9080///
9081/// A builder for the *locations.processors.processorVersions.undeploy* method supported by a *project* resource.
9082/// It is not used directly, but through a [`ProjectMethods`] instance.
9083///
9084/// # Example
9085///
9086/// Instantiate a resource method builder
9087///
9088/// ```test_harness,no_run
9089/// # extern crate hyper;
9090/// # extern crate hyper_rustls;
9091/// # extern crate google_documentai1 as documentai1;
9092/// use documentai1::api::GoogleCloudDocumentaiV1UndeployProcessorVersionRequest;
9093/// # async fn dox() {
9094/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9095///
9096/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9097/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9098/// #     secret,
9099/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9100/// # ).build().await.unwrap();
9101///
9102/// # let client = hyper_util::client::legacy::Client::builder(
9103/// #     hyper_util::rt::TokioExecutor::new()
9104/// # )
9105/// # .build(
9106/// #     hyper_rustls::HttpsConnectorBuilder::new()
9107/// #         .with_native_roots()
9108/// #         .unwrap()
9109/// #         .https_or_http()
9110/// #         .enable_http1()
9111/// #         .build()
9112/// # );
9113/// # let mut hub = Document::new(client, auth);
9114/// // As the method needs a request, you would usually fill it with the desired information
9115/// // into the respective structure. Some of the parts shown here might not be applicable !
9116/// // Values shown here are possibly random and not representative !
9117/// let mut req = GoogleCloudDocumentaiV1UndeployProcessorVersionRequest::default();
9118///
9119/// // You can configure optional parameters by calling the respective setters at will, and
9120/// // execute the final call using `doit()`.
9121/// // Values shown here are possibly random and not representative !
9122/// let result = hub.projects().locations_processors_processor_versions_undeploy(req, "name")
9123///              .doit().await;
9124/// # }
9125/// ```
9126pub struct ProjectLocationProcessorProcessorVersionUndeployCall<'a, C>
9127where
9128    C: 'a,
9129{
9130    hub: &'a Document<C>,
9131    _request: GoogleCloudDocumentaiV1UndeployProcessorVersionRequest,
9132    _name: String,
9133    _delegate: Option<&'a mut dyn common::Delegate>,
9134    _additional_params: HashMap<String, String>,
9135    _scopes: BTreeSet<String>,
9136}
9137
9138impl<'a, C> common::CallBuilder for ProjectLocationProcessorProcessorVersionUndeployCall<'a, C> {}
9139
9140impl<'a, C> ProjectLocationProcessorProcessorVersionUndeployCall<'a, C>
9141where
9142    C: common::Connector,
9143{
9144    /// Perform the operation you have build so far.
9145    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
9146        use std::borrow::Cow;
9147        use std::io::{Read, Seek};
9148
9149        use common::{url::Params, ToParts};
9150        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9151
9152        let mut dd = common::DefaultDelegate;
9153        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9154        dlg.begin(common::MethodInfo {
9155            id: "documentai.projects.locations.processors.processorVersions.undeploy",
9156            http_method: hyper::Method::POST,
9157        });
9158
9159        for &field in ["alt", "name"].iter() {
9160            if self._additional_params.contains_key(field) {
9161                dlg.finished(false);
9162                return Err(common::Error::FieldClash(field));
9163            }
9164        }
9165
9166        let mut params = Params::with_capacity(4 + self._additional_params.len());
9167        params.push("name", self._name);
9168
9169        params.extend(self._additional_params.iter());
9170
9171        params.push("alt", "json");
9172        let mut url = self.hub._base_url.clone() + "v1/{+name}:undeploy";
9173        if self._scopes.is_empty() {
9174            self._scopes
9175                .insert(Scope::CloudPlatform.as_ref().to_string());
9176        }
9177
9178        #[allow(clippy::single_element_loop)]
9179        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9180            url = params.uri_replacement(url, param_name, find_this, true);
9181        }
9182        {
9183            let to_remove = ["name"];
9184            params.remove_params(&to_remove);
9185        }
9186
9187        let url = params.parse_with_url(&url);
9188
9189        let mut json_mime_type = mime::APPLICATION_JSON;
9190        let mut request_value_reader = {
9191            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9192            common::remove_json_null_values(&mut value);
9193            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9194            serde_json::to_writer(&mut dst, &value).unwrap();
9195            dst
9196        };
9197        let request_size = request_value_reader
9198            .seek(std::io::SeekFrom::End(0))
9199            .unwrap();
9200        request_value_reader
9201            .seek(std::io::SeekFrom::Start(0))
9202            .unwrap();
9203
9204        loop {
9205            let token = match self
9206                .hub
9207                .auth
9208                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9209                .await
9210            {
9211                Ok(token) => token,
9212                Err(e) => match dlg.token(e) {
9213                    Ok(token) => token,
9214                    Err(e) => {
9215                        dlg.finished(false);
9216                        return Err(common::Error::MissingToken(e));
9217                    }
9218                },
9219            };
9220            request_value_reader
9221                .seek(std::io::SeekFrom::Start(0))
9222                .unwrap();
9223            let mut req_result = {
9224                let client = &self.hub.client;
9225                dlg.pre_request();
9226                let mut req_builder = hyper::Request::builder()
9227                    .method(hyper::Method::POST)
9228                    .uri(url.as_str())
9229                    .header(USER_AGENT, self.hub._user_agent.clone());
9230
9231                if let Some(token) = token.as_ref() {
9232                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9233                }
9234
9235                let request = req_builder
9236                    .header(CONTENT_TYPE, json_mime_type.to_string())
9237                    .header(CONTENT_LENGTH, request_size as u64)
9238                    .body(common::to_body(
9239                        request_value_reader.get_ref().clone().into(),
9240                    ));
9241
9242                client.request(request.unwrap()).await
9243            };
9244
9245            match req_result {
9246                Err(err) => {
9247                    if let common::Retry::After(d) = dlg.http_error(&err) {
9248                        sleep(d).await;
9249                        continue;
9250                    }
9251                    dlg.finished(false);
9252                    return Err(common::Error::HttpError(err));
9253                }
9254                Ok(res) => {
9255                    let (mut parts, body) = res.into_parts();
9256                    let mut body = common::Body::new(body);
9257                    if !parts.status.is_success() {
9258                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9259                        let error = serde_json::from_str(&common::to_string(&bytes));
9260                        let response = common::to_response(parts, bytes.into());
9261
9262                        if let common::Retry::After(d) =
9263                            dlg.http_failure(&response, error.as_ref().ok())
9264                        {
9265                            sleep(d).await;
9266                            continue;
9267                        }
9268
9269                        dlg.finished(false);
9270
9271                        return Err(match error {
9272                            Ok(value) => common::Error::BadRequest(value),
9273                            _ => common::Error::Failure(response),
9274                        });
9275                    }
9276                    let response = {
9277                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9278                        let encoded = common::to_string(&bytes);
9279                        match serde_json::from_str(&encoded) {
9280                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9281                            Err(error) => {
9282                                dlg.response_json_decode_error(&encoded, &error);
9283                                return Err(common::Error::JsonDecodeError(
9284                                    encoded.to_string(),
9285                                    error,
9286                                ));
9287                            }
9288                        }
9289                    };
9290
9291                    dlg.finished(true);
9292                    return Ok(response);
9293                }
9294            }
9295        }
9296    }
9297
9298    ///
9299    /// Sets the *request* property to the given value.
9300    ///
9301    /// Even though the property as already been set when instantiating this call,
9302    /// we provide this method for API completeness.
9303    pub fn request(
9304        mut self,
9305        new_value: GoogleCloudDocumentaiV1UndeployProcessorVersionRequest,
9306    ) -> ProjectLocationProcessorProcessorVersionUndeployCall<'a, C> {
9307        self._request = new_value;
9308        self
9309    }
9310    /// Required. The processor version resource name to be undeployed.
9311    ///
9312    /// Sets the *name* path property to the given value.
9313    ///
9314    /// Even though the property as already been set when instantiating this call,
9315    /// we provide this method for API completeness.
9316    pub fn name(
9317        mut self,
9318        new_value: &str,
9319    ) -> ProjectLocationProcessorProcessorVersionUndeployCall<'a, C> {
9320        self._name = new_value.to_string();
9321        self
9322    }
9323    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9324    /// while executing the actual API request.
9325    ///
9326    /// ````text
9327    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9328    /// ````
9329    ///
9330    /// Sets the *delegate* property to the given value.
9331    pub fn delegate(
9332        mut self,
9333        new_value: &'a mut dyn common::Delegate,
9334    ) -> ProjectLocationProcessorProcessorVersionUndeployCall<'a, C> {
9335        self._delegate = Some(new_value);
9336        self
9337    }
9338
9339    /// Set any additional parameter of the query string used in the request.
9340    /// It should be used to set parameters which are not yet available through their own
9341    /// setters.
9342    ///
9343    /// Please note that this method must not be used to set any of the known parameters
9344    /// which have their own setter method. If done anyway, the request will fail.
9345    ///
9346    /// # Additional Parameters
9347    ///
9348    /// * *$.xgafv* (query-string) - V1 error format.
9349    /// * *access_token* (query-string) - OAuth access token.
9350    /// * *alt* (query-string) - Data format for response.
9351    /// * *callback* (query-string) - JSONP
9352    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9353    /// * *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.
9354    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9355    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9356    /// * *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.
9357    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9358    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9359    pub fn param<T>(
9360        mut self,
9361        name: T,
9362        value: T,
9363    ) -> ProjectLocationProcessorProcessorVersionUndeployCall<'a, C>
9364    where
9365        T: AsRef<str>,
9366    {
9367        self._additional_params
9368            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9369        self
9370    }
9371
9372    /// Identifies the authorization scope for the method you are building.
9373    ///
9374    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9375    /// [`Scope::CloudPlatform`].
9376    ///
9377    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9378    /// tokens for more than one scope.
9379    ///
9380    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9381    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9382    /// sufficient, a read-write scope will do as well.
9383    pub fn add_scope<St>(
9384        mut self,
9385        scope: St,
9386    ) -> ProjectLocationProcessorProcessorVersionUndeployCall<'a, C>
9387    where
9388        St: AsRef<str>,
9389    {
9390        self._scopes.insert(String::from(scope.as_ref()));
9391        self
9392    }
9393    /// Identifies the authorization scope(s) for the method you are building.
9394    ///
9395    /// See [`Self::add_scope()`] for details.
9396    pub fn add_scopes<I, St>(
9397        mut self,
9398        scopes: I,
9399    ) -> ProjectLocationProcessorProcessorVersionUndeployCall<'a, C>
9400    where
9401        I: IntoIterator<Item = St>,
9402        St: AsRef<str>,
9403    {
9404        self._scopes
9405            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9406        self
9407    }
9408
9409    /// Removes all scopes, and no default scope will be used either.
9410    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9411    /// for details).
9412    pub fn clear_scopes(mut self) -> ProjectLocationProcessorProcessorVersionUndeployCall<'a, C> {
9413        self._scopes.clear();
9414        self
9415    }
9416}
9417
9418/// LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in the [Document] format.
9419///
9420/// A builder for the *locations.processors.batchProcess* method supported by a *project* resource.
9421/// It is not used directly, but through a [`ProjectMethods`] instance.
9422///
9423/// # Example
9424///
9425/// Instantiate a resource method builder
9426///
9427/// ```test_harness,no_run
9428/// # extern crate hyper;
9429/// # extern crate hyper_rustls;
9430/// # extern crate google_documentai1 as documentai1;
9431/// use documentai1::api::GoogleCloudDocumentaiV1BatchProcessRequest;
9432/// # async fn dox() {
9433/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9434///
9435/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9436/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9437/// #     secret,
9438/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9439/// # ).build().await.unwrap();
9440///
9441/// # let client = hyper_util::client::legacy::Client::builder(
9442/// #     hyper_util::rt::TokioExecutor::new()
9443/// # )
9444/// # .build(
9445/// #     hyper_rustls::HttpsConnectorBuilder::new()
9446/// #         .with_native_roots()
9447/// #         .unwrap()
9448/// #         .https_or_http()
9449/// #         .enable_http1()
9450/// #         .build()
9451/// # );
9452/// # let mut hub = Document::new(client, auth);
9453/// // As the method needs a request, you would usually fill it with the desired information
9454/// // into the respective structure. Some of the parts shown here might not be applicable !
9455/// // Values shown here are possibly random and not representative !
9456/// let mut req = GoogleCloudDocumentaiV1BatchProcessRequest::default();
9457///
9458/// // You can configure optional parameters by calling the respective setters at will, and
9459/// // execute the final call using `doit()`.
9460/// // Values shown here are possibly random and not representative !
9461/// let result = hub.projects().locations_processors_batch_process(req, "name")
9462///              .doit().await;
9463/// # }
9464/// ```
9465pub struct ProjectLocationProcessorBatchProcesCall<'a, C>
9466where
9467    C: 'a,
9468{
9469    hub: &'a Document<C>,
9470    _request: GoogleCloudDocumentaiV1BatchProcessRequest,
9471    _name: String,
9472    _delegate: Option<&'a mut dyn common::Delegate>,
9473    _additional_params: HashMap<String, String>,
9474    _scopes: BTreeSet<String>,
9475}
9476
9477impl<'a, C> common::CallBuilder for ProjectLocationProcessorBatchProcesCall<'a, C> {}
9478
9479impl<'a, C> ProjectLocationProcessorBatchProcesCall<'a, C>
9480where
9481    C: common::Connector,
9482{
9483    /// Perform the operation you have build so far.
9484    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
9485        use std::borrow::Cow;
9486        use std::io::{Read, Seek};
9487
9488        use common::{url::Params, ToParts};
9489        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9490
9491        let mut dd = common::DefaultDelegate;
9492        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9493        dlg.begin(common::MethodInfo {
9494            id: "documentai.projects.locations.processors.batchProcess",
9495            http_method: hyper::Method::POST,
9496        });
9497
9498        for &field in ["alt", "name"].iter() {
9499            if self._additional_params.contains_key(field) {
9500                dlg.finished(false);
9501                return Err(common::Error::FieldClash(field));
9502            }
9503        }
9504
9505        let mut params = Params::with_capacity(4 + self._additional_params.len());
9506        params.push("name", self._name);
9507
9508        params.extend(self._additional_params.iter());
9509
9510        params.push("alt", "json");
9511        let mut url = self.hub._base_url.clone() + "v1/{+name}:batchProcess";
9512        if self._scopes.is_empty() {
9513            self._scopes
9514                .insert(Scope::CloudPlatform.as_ref().to_string());
9515        }
9516
9517        #[allow(clippy::single_element_loop)]
9518        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9519            url = params.uri_replacement(url, param_name, find_this, true);
9520        }
9521        {
9522            let to_remove = ["name"];
9523            params.remove_params(&to_remove);
9524        }
9525
9526        let url = params.parse_with_url(&url);
9527
9528        let mut json_mime_type = mime::APPLICATION_JSON;
9529        let mut request_value_reader = {
9530            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9531            common::remove_json_null_values(&mut value);
9532            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9533            serde_json::to_writer(&mut dst, &value).unwrap();
9534            dst
9535        };
9536        let request_size = request_value_reader
9537            .seek(std::io::SeekFrom::End(0))
9538            .unwrap();
9539        request_value_reader
9540            .seek(std::io::SeekFrom::Start(0))
9541            .unwrap();
9542
9543        loop {
9544            let token = match self
9545                .hub
9546                .auth
9547                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9548                .await
9549            {
9550                Ok(token) => token,
9551                Err(e) => match dlg.token(e) {
9552                    Ok(token) => token,
9553                    Err(e) => {
9554                        dlg.finished(false);
9555                        return Err(common::Error::MissingToken(e));
9556                    }
9557                },
9558            };
9559            request_value_reader
9560                .seek(std::io::SeekFrom::Start(0))
9561                .unwrap();
9562            let mut req_result = {
9563                let client = &self.hub.client;
9564                dlg.pre_request();
9565                let mut req_builder = hyper::Request::builder()
9566                    .method(hyper::Method::POST)
9567                    .uri(url.as_str())
9568                    .header(USER_AGENT, self.hub._user_agent.clone());
9569
9570                if let Some(token) = token.as_ref() {
9571                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9572                }
9573
9574                let request = req_builder
9575                    .header(CONTENT_TYPE, json_mime_type.to_string())
9576                    .header(CONTENT_LENGTH, request_size as u64)
9577                    .body(common::to_body(
9578                        request_value_reader.get_ref().clone().into(),
9579                    ));
9580
9581                client.request(request.unwrap()).await
9582            };
9583
9584            match req_result {
9585                Err(err) => {
9586                    if let common::Retry::After(d) = dlg.http_error(&err) {
9587                        sleep(d).await;
9588                        continue;
9589                    }
9590                    dlg.finished(false);
9591                    return Err(common::Error::HttpError(err));
9592                }
9593                Ok(res) => {
9594                    let (mut parts, body) = res.into_parts();
9595                    let mut body = common::Body::new(body);
9596                    if !parts.status.is_success() {
9597                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9598                        let error = serde_json::from_str(&common::to_string(&bytes));
9599                        let response = common::to_response(parts, bytes.into());
9600
9601                        if let common::Retry::After(d) =
9602                            dlg.http_failure(&response, error.as_ref().ok())
9603                        {
9604                            sleep(d).await;
9605                            continue;
9606                        }
9607
9608                        dlg.finished(false);
9609
9610                        return Err(match error {
9611                            Ok(value) => common::Error::BadRequest(value),
9612                            _ => common::Error::Failure(response),
9613                        });
9614                    }
9615                    let response = {
9616                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9617                        let encoded = common::to_string(&bytes);
9618                        match serde_json::from_str(&encoded) {
9619                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9620                            Err(error) => {
9621                                dlg.response_json_decode_error(&encoded, &error);
9622                                return Err(common::Error::JsonDecodeError(
9623                                    encoded.to_string(),
9624                                    error,
9625                                ));
9626                            }
9627                        }
9628                    };
9629
9630                    dlg.finished(true);
9631                    return Ok(response);
9632                }
9633            }
9634        }
9635    }
9636
9637    ///
9638    /// Sets the *request* property to the given value.
9639    ///
9640    /// Even though the property as already been set when instantiating this call,
9641    /// we provide this method for API completeness.
9642    pub fn request(
9643        mut self,
9644        new_value: GoogleCloudDocumentaiV1BatchProcessRequest,
9645    ) -> ProjectLocationProcessorBatchProcesCall<'a, C> {
9646        self._request = new_value;
9647        self
9648    }
9649    /// Required. The resource name of Processor or ProcessorVersion. Format: `projects/{project}/locations/{location}/processors/{processor}`, or `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`
9650    ///
9651    /// Sets the *name* path property to the given value.
9652    ///
9653    /// Even though the property as already been set when instantiating this call,
9654    /// we provide this method for API completeness.
9655    pub fn name(mut self, new_value: &str) -> ProjectLocationProcessorBatchProcesCall<'a, C> {
9656        self._name = new_value.to_string();
9657        self
9658    }
9659    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9660    /// while executing the actual API request.
9661    ///
9662    /// ````text
9663    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9664    /// ````
9665    ///
9666    /// Sets the *delegate* property to the given value.
9667    pub fn delegate(
9668        mut self,
9669        new_value: &'a mut dyn common::Delegate,
9670    ) -> ProjectLocationProcessorBatchProcesCall<'a, C> {
9671        self._delegate = Some(new_value);
9672        self
9673    }
9674
9675    /// Set any additional parameter of the query string used in the request.
9676    /// It should be used to set parameters which are not yet available through their own
9677    /// setters.
9678    ///
9679    /// Please note that this method must not be used to set any of the known parameters
9680    /// which have their own setter method. If done anyway, the request will fail.
9681    ///
9682    /// # Additional Parameters
9683    ///
9684    /// * *$.xgafv* (query-string) - V1 error format.
9685    /// * *access_token* (query-string) - OAuth access token.
9686    /// * *alt* (query-string) - Data format for response.
9687    /// * *callback* (query-string) - JSONP
9688    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9689    /// * *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.
9690    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9691    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9692    /// * *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.
9693    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9694    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9695    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProcessorBatchProcesCall<'a, C>
9696    where
9697        T: AsRef<str>,
9698    {
9699        self._additional_params
9700            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9701        self
9702    }
9703
9704    /// Identifies the authorization scope for the method you are building.
9705    ///
9706    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9707    /// [`Scope::CloudPlatform`].
9708    ///
9709    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9710    /// tokens for more than one scope.
9711    ///
9712    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9713    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9714    /// sufficient, a read-write scope will do as well.
9715    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProcessorBatchProcesCall<'a, C>
9716    where
9717        St: AsRef<str>,
9718    {
9719        self._scopes.insert(String::from(scope.as_ref()));
9720        self
9721    }
9722    /// Identifies the authorization scope(s) for the method you are building.
9723    ///
9724    /// See [`Self::add_scope()`] for details.
9725    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProcessorBatchProcesCall<'a, C>
9726    where
9727        I: IntoIterator<Item = St>,
9728        St: AsRef<str>,
9729    {
9730        self._scopes
9731            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9732        self
9733    }
9734
9735    /// Removes all scopes, and no default scope will be used either.
9736    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9737    /// for details).
9738    pub fn clear_scopes(mut self) -> ProjectLocationProcessorBatchProcesCall<'a, C> {
9739        self._scopes.clear();
9740        self
9741    }
9742}
9743
9744/// Creates a processor from the ProcessorType provided. The processor will be at `ENABLED` state by default after its creation. Note that this method requires the `documentai.processors.create` permission on the project, which is highly privileged. A user or service account with this permission can create new processors that can interact with any gcs bucket in your project.
9745///
9746/// A builder for the *locations.processors.create* method supported by a *project* resource.
9747/// It is not used directly, but through a [`ProjectMethods`] instance.
9748///
9749/// # Example
9750///
9751/// Instantiate a resource method builder
9752///
9753/// ```test_harness,no_run
9754/// # extern crate hyper;
9755/// # extern crate hyper_rustls;
9756/// # extern crate google_documentai1 as documentai1;
9757/// use documentai1::api::GoogleCloudDocumentaiV1Processor;
9758/// # async fn dox() {
9759/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9760///
9761/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9762/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9763/// #     secret,
9764/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9765/// # ).build().await.unwrap();
9766///
9767/// # let client = hyper_util::client::legacy::Client::builder(
9768/// #     hyper_util::rt::TokioExecutor::new()
9769/// # )
9770/// # .build(
9771/// #     hyper_rustls::HttpsConnectorBuilder::new()
9772/// #         .with_native_roots()
9773/// #         .unwrap()
9774/// #         .https_or_http()
9775/// #         .enable_http1()
9776/// #         .build()
9777/// # );
9778/// # let mut hub = Document::new(client, auth);
9779/// // As the method needs a request, you would usually fill it with the desired information
9780/// // into the respective structure. Some of the parts shown here might not be applicable !
9781/// // Values shown here are possibly random and not representative !
9782/// let mut req = GoogleCloudDocumentaiV1Processor::default();
9783///
9784/// // You can configure optional parameters by calling the respective setters at will, and
9785/// // execute the final call using `doit()`.
9786/// // Values shown here are possibly random and not representative !
9787/// let result = hub.projects().locations_processors_create(req, "parent")
9788///              .doit().await;
9789/// # }
9790/// ```
9791pub struct ProjectLocationProcessorCreateCall<'a, C>
9792where
9793    C: 'a,
9794{
9795    hub: &'a Document<C>,
9796    _request: GoogleCloudDocumentaiV1Processor,
9797    _parent: String,
9798    _delegate: Option<&'a mut dyn common::Delegate>,
9799    _additional_params: HashMap<String, String>,
9800    _scopes: BTreeSet<String>,
9801}
9802
9803impl<'a, C> common::CallBuilder for ProjectLocationProcessorCreateCall<'a, C> {}
9804
9805impl<'a, C> ProjectLocationProcessorCreateCall<'a, C>
9806where
9807    C: common::Connector,
9808{
9809    /// Perform the operation you have build so far.
9810    pub async fn doit(
9811        mut self,
9812    ) -> common::Result<(common::Response, GoogleCloudDocumentaiV1Processor)> {
9813        use std::borrow::Cow;
9814        use std::io::{Read, Seek};
9815
9816        use common::{url::Params, ToParts};
9817        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9818
9819        let mut dd = common::DefaultDelegate;
9820        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9821        dlg.begin(common::MethodInfo {
9822            id: "documentai.projects.locations.processors.create",
9823            http_method: hyper::Method::POST,
9824        });
9825
9826        for &field in ["alt", "parent"].iter() {
9827            if self._additional_params.contains_key(field) {
9828                dlg.finished(false);
9829                return Err(common::Error::FieldClash(field));
9830            }
9831        }
9832
9833        let mut params = Params::with_capacity(4 + self._additional_params.len());
9834        params.push("parent", self._parent);
9835
9836        params.extend(self._additional_params.iter());
9837
9838        params.push("alt", "json");
9839        let mut url = self.hub._base_url.clone() + "v1/{+parent}/processors";
9840        if self._scopes.is_empty() {
9841            self._scopes
9842                .insert(Scope::CloudPlatform.as_ref().to_string());
9843        }
9844
9845        #[allow(clippy::single_element_loop)]
9846        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9847            url = params.uri_replacement(url, param_name, find_this, true);
9848        }
9849        {
9850            let to_remove = ["parent"];
9851            params.remove_params(&to_remove);
9852        }
9853
9854        let url = params.parse_with_url(&url);
9855
9856        let mut json_mime_type = mime::APPLICATION_JSON;
9857        let mut request_value_reader = {
9858            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9859            common::remove_json_null_values(&mut value);
9860            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9861            serde_json::to_writer(&mut dst, &value).unwrap();
9862            dst
9863        };
9864        let request_size = request_value_reader
9865            .seek(std::io::SeekFrom::End(0))
9866            .unwrap();
9867        request_value_reader
9868            .seek(std::io::SeekFrom::Start(0))
9869            .unwrap();
9870
9871        loop {
9872            let token = match self
9873                .hub
9874                .auth
9875                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9876                .await
9877            {
9878                Ok(token) => token,
9879                Err(e) => match dlg.token(e) {
9880                    Ok(token) => token,
9881                    Err(e) => {
9882                        dlg.finished(false);
9883                        return Err(common::Error::MissingToken(e));
9884                    }
9885                },
9886            };
9887            request_value_reader
9888                .seek(std::io::SeekFrom::Start(0))
9889                .unwrap();
9890            let mut req_result = {
9891                let client = &self.hub.client;
9892                dlg.pre_request();
9893                let mut req_builder = hyper::Request::builder()
9894                    .method(hyper::Method::POST)
9895                    .uri(url.as_str())
9896                    .header(USER_AGENT, self.hub._user_agent.clone());
9897
9898                if let Some(token) = token.as_ref() {
9899                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9900                }
9901
9902                let request = req_builder
9903                    .header(CONTENT_TYPE, json_mime_type.to_string())
9904                    .header(CONTENT_LENGTH, request_size as u64)
9905                    .body(common::to_body(
9906                        request_value_reader.get_ref().clone().into(),
9907                    ));
9908
9909                client.request(request.unwrap()).await
9910            };
9911
9912            match req_result {
9913                Err(err) => {
9914                    if let common::Retry::After(d) = dlg.http_error(&err) {
9915                        sleep(d).await;
9916                        continue;
9917                    }
9918                    dlg.finished(false);
9919                    return Err(common::Error::HttpError(err));
9920                }
9921                Ok(res) => {
9922                    let (mut parts, body) = res.into_parts();
9923                    let mut body = common::Body::new(body);
9924                    if !parts.status.is_success() {
9925                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9926                        let error = serde_json::from_str(&common::to_string(&bytes));
9927                        let response = common::to_response(parts, bytes.into());
9928
9929                        if let common::Retry::After(d) =
9930                            dlg.http_failure(&response, error.as_ref().ok())
9931                        {
9932                            sleep(d).await;
9933                            continue;
9934                        }
9935
9936                        dlg.finished(false);
9937
9938                        return Err(match error {
9939                            Ok(value) => common::Error::BadRequest(value),
9940                            _ => common::Error::Failure(response),
9941                        });
9942                    }
9943                    let response = {
9944                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9945                        let encoded = common::to_string(&bytes);
9946                        match serde_json::from_str(&encoded) {
9947                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9948                            Err(error) => {
9949                                dlg.response_json_decode_error(&encoded, &error);
9950                                return Err(common::Error::JsonDecodeError(
9951                                    encoded.to_string(),
9952                                    error,
9953                                ));
9954                            }
9955                        }
9956                    };
9957
9958                    dlg.finished(true);
9959                    return Ok(response);
9960                }
9961            }
9962        }
9963    }
9964
9965    ///
9966    /// Sets the *request* property to the given value.
9967    ///
9968    /// Even though the property as already been set when instantiating this call,
9969    /// we provide this method for API completeness.
9970    pub fn request(
9971        mut self,
9972        new_value: GoogleCloudDocumentaiV1Processor,
9973    ) -> ProjectLocationProcessorCreateCall<'a, C> {
9974        self._request = new_value;
9975        self
9976    }
9977    /// Required. The parent (project and location) under which to create the processor. Format: `projects/{project}/locations/{location}`
9978    ///
9979    /// Sets the *parent* path property to the given value.
9980    ///
9981    /// Even though the property as already been set when instantiating this call,
9982    /// we provide this method for API completeness.
9983    pub fn parent(mut self, new_value: &str) -> ProjectLocationProcessorCreateCall<'a, C> {
9984        self._parent = new_value.to_string();
9985        self
9986    }
9987    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9988    /// while executing the actual API request.
9989    ///
9990    /// ````text
9991    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9992    /// ````
9993    ///
9994    /// Sets the *delegate* property to the given value.
9995    pub fn delegate(
9996        mut self,
9997        new_value: &'a mut dyn common::Delegate,
9998    ) -> ProjectLocationProcessorCreateCall<'a, C> {
9999        self._delegate = Some(new_value);
10000        self
10001    }
10002
10003    /// Set any additional parameter of the query string used in the request.
10004    /// It should be used to set parameters which are not yet available through their own
10005    /// setters.
10006    ///
10007    /// Please note that this method must not be used to set any of the known parameters
10008    /// which have their own setter method. If done anyway, the request will fail.
10009    ///
10010    /// # Additional Parameters
10011    ///
10012    /// * *$.xgafv* (query-string) - V1 error format.
10013    /// * *access_token* (query-string) - OAuth access token.
10014    /// * *alt* (query-string) - Data format for response.
10015    /// * *callback* (query-string) - JSONP
10016    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10017    /// * *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.
10018    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10019    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10020    /// * *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.
10021    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10022    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10023    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProcessorCreateCall<'a, C>
10024    where
10025        T: AsRef<str>,
10026    {
10027        self._additional_params
10028            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10029        self
10030    }
10031
10032    /// Identifies the authorization scope for the method you are building.
10033    ///
10034    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10035    /// [`Scope::CloudPlatform`].
10036    ///
10037    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10038    /// tokens for more than one scope.
10039    ///
10040    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10041    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10042    /// sufficient, a read-write scope will do as well.
10043    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProcessorCreateCall<'a, C>
10044    where
10045        St: AsRef<str>,
10046    {
10047        self._scopes.insert(String::from(scope.as_ref()));
10048        self
10049    }
10050    /// Identifies the authorization scope(s) for the method you are building.
10051    ///
10052    /// See [`Self::add_scope()`] for details.
10053    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProcessorCreateCall<'a, C>
10054    where
10055        I: IntoIterator<Item = St>,
10056        St: AsRef<str>,
10057    {
10058        self._scopes
10059            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10060        self
10061    }
10062
10063    /// Removes all scopes, and no default scope will be used either.
10064    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10065    /// for details).
10066    pub fn clear_scopes(mut self) -> ProjectLocationProcessorCreateCall<'a, C> {
10067        self._scopes.clear();
10068        self
10069    }
10070}
10071
10072/// Deletes the processor, unloads all deployed model artifacts if it was enabled and then deletes all artifacts associated with this processor.
10073///
10074/// A builder for the *locations.processors.delete* method supported by a *project* resource.
10075/// It is not used directly, but through a [`ProjectMethods`] instance.
10076///
10077/// # Example
10078///
10079/// Instantiate a resource method builder
10080///
10081/// ```test_harness,no_run
10082/// # extern crate hyper;
10083/// # extern crate hyper_rustls;
10084/// # extern crate google_documentai1 as documentai1;
10085/// # async fn dox() {
10086/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10087///
10088/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10089/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10090/// #     secret,
10091/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10092/// # ).build().await.unwrap();
10093///
10094/// # let client = hyper_util::client::legacy::Client::builder(
10095/// #     hyper_util::rt::TokioExecutor::new()
10096/// # )
10097/// # .build(
10098/// #     hyper_rustls::HttpsConnectorBuilder::new()
10099/// #         .with_native_roots()
10100/// #         .unwrap()
10101/// #         .https_or_http()
10102/// #         .enable_http1()
10103/// #         .build()
10104/// # );
10105/// # let mut hub = Document::new(client, auth);
10106/// // You can configure optional parameters by calling the respective setters at will, and
10107/// // execute the final call using `doit()`.
10108/// // Values shown here are possibly random and not representative !
10109/// let result = hub.projects().locations_processors_delete("name")
10110///              .doit().await;
10111/// # }
10112/// ```
10113pub struct ProjectLocationProcessorDeleteCall<'a, C>
10114where
10115    C: 'a,
10116{
10117    hub: &'a Document<C>,
10118    _name: String,
10119    _delegate: Option<&'a mut dyn common::Delegate>,
10120    _additional_params: HashMap<String, String>,
10121    _scopes: BTreeSet<String>,
10122}
10123
10124impl<'a, C> common::CallBuilder for ProjectLocationProcessorDeleteCall<'a, C> {}
10125
10126impl<'a, C> ProjectLocationProcessorDeleteCall<'a, C>
10127where
10128    C: common::Connector,
10129{
10130    /// Perform the operation you have build so far.
10131    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
10132        use std::borrow::Cow;
10133        use std::io::{Read, Seek};
10134
10135        use common::{url::Params, ToParts};
10136        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10137
10138        let mut dd = common::DefaultDelegate;
10139        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10140        dlg.begin(common::MethodInfo {
10141            id: "documentai.projects.locations.processors.delete",
10142            http_method: hyper::Method::DELETE,
10143        });
10144
10145        for &field in ["alt", "name"].iter() {
10146            if self._additional_params.contains_key(field) {
10147                dlg.finished(false);
10148                return Err(common::Error::FieldClash(field));
10149            }
10150        }
10151
10152        let mut params = Params::with_capacity(3 + self._additional_params.len());
10153        params.push("name", self._name);
10154
10155        params.extend(self._additional_params.iter());
10156
10157        params.push("alt", "json");
10158        let mut url = self.hub._base_url.clone() + "v1/{+name}";
10159        if self._scopes.is_empty() {
10160            self._scopes
10161                .insert(Scope::CloudPlatform.as_ref().to_string());
10162        }
10163
10164        #[allow(clippy::single_element_loop)]
10165        for &(find_this, param_name) in [("{+name}", "name")].iter() {
10166            url = params.uri_replacement(url, param_name, find_this, true);
10167        }
10168        {
10169            let to_remove = ["name"];
10170            params.remove_params(&to_remove);
10171        }
10172
10173        let url = params.parse_with_url(&url);
10174
10175        loop {
10176            let token = match self
10177                .hub
10178                .auth
10179                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10180                .await
10181            {
10182                Ok(token) => token,
10183                Err(e) => match dlg.token(e) {
10184                    Ok(token) => token,
10185                    Err(e) => {
10186                        dlg.finished(false);
10187                        return Err(common::Error::MissingToken(e));
10188                    }
10189                },
10190            };
10191            let mut req_result = {
10192                let client = &self.hub.client;
10193                dlg.pre_request();
10194                let mut req_builder = hyper::Request::builder()
10195                    .method(hyper::Method::DELETE)
10196                    .uri(url.as_str())
10197                    .header(USER_AGENT, self.hub._user_agent.clone());
10198
10199                if let Some(token) = token.as_ref() {
10200                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10201                }
10202
10203                let request = req_builder
10204                    .header(CONTENT_LENGTH, 0_u64)
10205                    .body(common::to_body::<String>(None));
10206
10207                client.request(request.unwrap()).await
10208            };
10209
10210            match req_result {
10211                Err(err) => {
10212                    if let common::Retry::After(d) = dlg.http_error(&err) {
10213                        sleep(d).await;
10214                        continue;
10215                    }
10216                    dlg.finished(false);
10217                    return Err(common::Error::HttpError(err));
10218                }
10219                Ok(res) => {
10220                    let (mut parts, body) = res.into_parts();
10221                    let mut body = common::Body::new(body);
10222                    if !parts.status.is_success() {
10223                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10224                        let error = serde_json::from_str(&common::to_string(&bytes));
10225                        let response = common::to_response(parts, bytes.into());
10226
10227                        if let common::Retry::After(d) =
10228                            dlg.http_failure(&response, error.as_ref().ok())
10229                        {
10230                            sleep(d).await;
10231                            continue;
10232                        }
10233
10234                        dlg.finished(false);
10235
10236                        return Err(match error {
10237                            Ok(value) => common::Error::BadRequest(value),
10238                            _ => common::Error::Failure(response),
10239                        });
10240                    }
10241                    let response = {
10242                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10243                        let encoded = common::to_string(&bytes);
10244                        match serde_json::from_str(&encoded) {
10245                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10246                            Err(error) => {
10247                                dlg.response_json_decode_error(&encoded, &error);
10248                                return Err(common::Error::JsonDecodeError(
10249                                    encoded.to_string(),
10250                                    error,
10251                                ));
10252                            }
10253                        }
10254                    };
10255
10256                    dlg.finished(true);
10257                    return Ok(response);
10258                }
10259            }
10260        }
10261    }
10262
10263    /// Required. The processor resource name to be deleted.
10264    ///
10265    /// Sets the *name* path property to the given value.
10266    ///
10267    /// Even though the property as already been set when instantiating this call,
10268    /// we provide this method for API completeness.
10269    pub fn name(mut self, new_value: &str) -> ProjectLocationProcessorDeleteCall<'a, C> {
10270        self._name = new_value.to_string();
10271        self
10272    }
10273    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10274    /// while executing the actual API request.
10275    ///
10276    /// ````text
10277    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10278    /// ````
10279    ///
10280    /// Sets the *delegate* property to the given value.
10281    pub fn delegate(
10282        mut self,
10283        new_value: &'a mut dyn common::Delegate,
10284    ) -> ProjectLocationProcessorDeleteCall<'a, C> {
10285        self._delegate = Some(new_value);
10286        self
10287    }
10288
10289    /// Set any additional parameter of the query string used in the request.
10290    /// It should be used to set parameters which are not yet available through their own
10291    /// setters.
10292    ///
10293    /// Please note that this method must not be used to set any of the known parameters
10294    /// which have their own setter method. If done anyway, the request will fail.
10295    ///
10296    /// # Additional Parameters
10297    ///
10298    /// * *$.xgafv* (query-string) - V1 error format.
10299    /// * *access_token* (query-string) - OAuth access token.
10300    /// * *alt* (query-string) - Data format for response.
10301    /// * *callback* (query-string) - JSONP
10302    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10303    /// * *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.
10304    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10305    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10306    /// * *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.
10307    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10308    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10309    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProcessorDeleteCall<'a, C>
10310    where
10311        T: AsRef<str>,
10312    {
10313        self._additional_params
10314            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10315        self
10316    }
10317
10318    /// Identifies the authorization scope for the method you are building.
10319    ///
10320    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10321    /// [`Scope::CloudPlatform`].
10322    ///
10323    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10324    /// tokens for more than one scope.
10325    ///
10326    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10327    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10328    /// sufficient, a read-write scope will do as well.
10329    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProcessorDeleteCall<'a, C>
10330    where
10331        St: AsRef<str>,
10332    {
10333        self._scopes.insert(String::from(scope.as_ref()));
10334        self
10335    }
10336    /// Identifies the authorization scope(s) for the method you are building.
10337    ///
10338    /// See [`Self::add_scope()`] for details.
10339    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProcessorDeleteCall<'a, C>
10340    where
10341        I: IntoIterator<Item = St>,
10342        St: AsRef<str>,
10343    {
10344        self._scopes
10345            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10346        self
10347    }
10348
10349    /// Removes all scopes, and no default scope will be used either.
10350    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10351    /// for details).
10352    pub fn clear_scopes(mut self) -> ProjectLocationProcessorDeleteCall<'a, C> {
10353        self._scopes.clear();
10354        self
10355    }
10356}
10357
10358/// Disables a processor
10359///
10360/// A builder for the *locations.processors.disable* method supported by a *project* resource.
10361/// It is not used directly, but through a [`ProjectMethods`] instance.
10362///
10363/// # Example
10364///
10365/// Instantiate a resource method builder
10366///
10367/// ```test_harness,no_run
10368/// # extern crate hyper;
10369/// # extern crate hyper_rustls;
10370/// # extern crate google_documentai1 as documentai1;
10371/// use documentai1::api::GoogleCloudDocumentaiV1DisableProcessorRequest;
10372/// # async fn dox() {
10373/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10374///
10375/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10376/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10377/// #     secret,
10378/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10379/// # ).build().await.unwrap();
10380///
10381/// # let client = hyper_util::client::legacy::Client::builder(
10382/// #     hyper_util::rt::TokioExecutor::new()
10383/// # )
10384/// # .build(
10385/// #     hyper_rustls::HttpsConnectorBuilder::new()
10386/// #         .with_native_roots()
10387/// #         .unwrap()
10388/// #         .https_or_http()
10389/// #         .enable_http1()
10390/// #         .build()
10391/// # );
10392/// # let mut hub = Document::new(client, auth);
10393/// // As the method needs a request, you would usually fill it with the desired information
10394/// // into the respective structure. Some of the parts shown here might not be applicable !
10395/// // Values shown here are possibly random and not representative !
10396/// let mut req = GoogleCloudDocumentaiV1DisableProcessorRequest::default();
10397///
10398/// // You can configure optional parameters by calling the respective setters at will, and
10399/// // execute the final call using `doit()`.
10400/// // Values shown here are possibly random and not representative !
10401/// let result = hub.projects().locations_processors_disable(req, "name")
10402///              .doit().await;
10403/// # }
10404/// ```
10405pub struct ProjectLocationProcessorDisableCall<'a, C>
10406where
10407    C: 'a,
10408{
10409    hub: &'a Document<C>,
10410    _request: GoogleCloudDocumentaiV1DisableProcessorRequest,
10411    _name: String,
10412    _delegate: Option<&'a mut dyn common::Delegate>,
10413    _additional_params: HashMap<String, String>,
10414    _scopes: BTreeSet<String>,
10415}
10416
10417impl<'a, C> common::CallBuilder for ProjectLocationProcessorDisableCall<'a, C> {}
10418
10419impl<'a, C> ProjectLocationProcessorDisableCall<'a, C>
10420where
10421    C: common::Connector,
10422{
10423    /// Perform the operation you have build so far.
10424    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
10425        use std::borrow::Cow;
10426        use std::io::{Read, Seek};
10427
10428        use common::{url::Params, ToParts};
10429        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10430
10431        let mut dd = common::DefaultDelegate;
10432        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10433        dlg.begin(common::MethodInfo {
10434            id: "documentai.projects.locations.processors.disable",
10435            http_method: hyper::Method::POST,
10436        });
10437
10438        for &field in ["alt", "name"].iter() {
10439            if self._additional_params.contains_key(field) {
10440                dlg.finished(false);
10441                return Err(common::Error::FieldClash(field));
10442            }
10443        }
10444
10445        let mut params = Params::with_capacity(4 + self._additional_params.len());
10446        params.push("name", self._name);
10447
10448        params.extend(self._additional_params.iter());
10449
10450        params.push("alt", "json");
10451        let mut url = self.hub._base_url.clone() + "v1/{+name}:disable";
10452        if self._scopes.is_empty() {
10453            self._scopes
10454                .insert(Scope::CloudPlatform.as_ref().to_string());
10455        }
10456
10457        #[allow(clippy::single_element_loop)]
10458        for &(find_this, param_name) in [("{+name}", "name")].iter() {
10459            url = params.uri_replacement(url, param_name, find_this, true);
10460        }
10461        {
10462            let to_remove = ["name"];
10463            params.remove_params(&to_remove);
10464        }
10465
10466        let url = params.parse_with_url(&url);
10467
10468        let mut json_mime_type = mime::APPLICATION_JSON;
10469        let mut request_value_reader = {
10470            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10471            common::remove_json_null_values(&mut value);
10472            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10473            serde_json::to_writer(&mut dst, &value).unwrap();
10474            dst
10475        };
10476        let request_size = request_value_reader
10477            .seek(std::io::SeekFrom::End(0))
10478            .unwrap();
10479        request_value_reader
10480            .seek(std::io::SeekFrom::Start(0))
10481            .unwrap();
10482
10483        loop {
10484            let token = match self
10485                .hub
10486                .auth
10487                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10488                .await
10489            {
10490                Ok(token) => token,
10491                Err(e) => match dlg.token(e) {
10492                    Ok(token) => token,
10493                    Err(e) => {
10494                        dlg.finished(false);
10495                        return Err(common::Error::MissingToken(e));
10496                    }
10497                },
10498            };
10499            request_value_reader
10500                .seek(std::io::SeekFrom::Start(0))
10501                .unwrap();
10502            let mut req_result = {
10503                let client = &self.hub.client;
10504                dlg.pre_request();
10505                let mut req_builder = hyper::Request::builder()
10506                    .method(hyper::Method::POST)
10507                    .uri(url.as_str())
10508                    .header(USER_AGENT, self.hub._user_agent.clone());
10509
10510                if let Some(token) = token.as_ref() {
10511                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10512                }
10513
10514                let request = req_builder
10515                    .header(CONTENT_TYPE, json_mime_type.to_string())
10516                    .header(CONTENT_LENGTH, request_size as u64)
10517                    .body(common::to_body(
10518                        request_value_reader.get_ref().clone().into(),
10519                    ));
10520
10521                client.request(request.unwrap()).await
10522            };
10523
10524            match req_result {
10525                Err(err) => {
10526                    if let common::Retry::After(d) = dlg.http_error(&err) {
10527                        sleep(d).await;
10528                        continue;
10529                    }
10530                    dlg.finished(false);
10531                    return Err(common::Error::HttpError(err));
10532                }
10533                Ok(res) => {
10534                    let (mut parts, body) = res.into_parts();
10535                    let mut body = common::Body::new(body);
10536                    if !parts.status.is_success() {
10537                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10538                        let error = serde_json::from_str(&common::to_string(&bytes));
10539                        let response = common::to_response(parts, bytes.into());
10540
10541                        if let common::Retry::After(d) =
10542                            dlg.http_failure(&response, error.as_ref().ok())
10543                        {
10544                            sleep(d).await;
10545                            continue;
10546                        }
10547
10548                        dlg.finished(false);
10549
10550                        return Err(match error {
10551                            Ok(value) => common::Error::BadRequest(value),
10552                            _ => common::Error::Failure(response),
10553                        });
10554                    }
10555                    let response = {
10556                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10557                        let encoded = common::to_string(&bytes);
10558                        match serde_json::from_str(&encoded) {
10559                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10560                            Err(error) => {
10561                                dlg.response_json_decode_error(&encoded, &error);
10562                                return Err(common::Error::JsonDecodeError(
10563                                    encoded.to_string(),
10564                                    error,
10565                                ));
10566                            }
10567                        }
10568                    };
10569
10570                    dlg.finished(true);
10571                    return Ok(response);
10572                }
10573            }
10574        }
10575    }
10576
10577    ///
10578    /// Sets the *request* property to the given value.
10579    ///
10580    /// Even though the property as already been set when instantiating this call,
10581    /// we provide this method for API completeness.
10582    pub fn request(
10583        mut self,
10584        new_value: GoogleCloudDocumentaiV1DisableProcessorRequest,
10585    ) -> ProjectLocationProcessorDisableCall<'a, C> {
10586        self._request = new_value;
10587        self
10588    }
10589    /// Required. The processor resource name to be disabled.
10590    ///
10591    /// Sets the *name* path property to the given value.
10592    ///
10593    /// Even though the property as already been set when instantiating this call,
10594    /// we provide this method for API completeness.
10595    pub fn name(mut self, new_value: &str) -> ProjectLocationProcessorDisableCall<'a, C> {
10596        self._name = new_value.to_string();
10597        self
10598    }
10599    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10600    /// while executing the actual API request.
10601    ///
10602    /// ````text
10603    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10604    /// ````
10605    ///
10606    /// Sets the *delegate* property to the given value.
10607    pub fn delegate(
10608        mut self,
10609        new_value: &'a mut dyn common::Delegate,
10610    ) -> ProjectLocationProcessorDisableCall<'a, C> {
10611        self._delegate = Some(new_value);
10612        self
10613    }
10614
10615    /// Set any additional parameter of the query string used in the request.
10616    /// It should be used to set parameters which are not yet available through their own
10617    /// setters.
10618    ///
10619    /// Please note that this method must not be used to set any of the known parameters
10620    /// which have their own setter method. If done anyway, the request will fail.
10621    ///
10622    /// # Additional Parameters
10623    ///
10624    /// * *$.xgafv* (query-string) - V1 error format.
10625    /// * *access_token* (query-string) - OAuth access token.
10626    /// * *alt* (query-string) - Data format for response.
10627    /// * *callback* (query-string) - JSONP
10628    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10629    /// * *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.
10630    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10631    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10632    /// * *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.
10633    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10634    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10635    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProcessorDisableCall<'a, C>
10636    where
10637        T: AsRef<str>,
10638    {
10639        self._additional_params
10640            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10641        self
10642    }
10643
10644    /// Identifies the authorization scope for the method you are building.
10645    ///
10646    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10647    /// [`Scope::CloudPlatform`].
10648    ///
10649    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10650    /// tokens for more than one scope.
10651    ///
10652    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10653    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10654    /// sufficient, a read-write scope will do as well.
10655    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProcessorDisableCall<'a, C>
10656    where
10657        St: AsRef<str>,
10658    {
10659        self._scopes.insert(String::from(scope.as_ref()));
10660        self
10661    }
10662    /// Identifies the authorization scope(s) for the method you are building.
10663    ///
10664    /// See [`Self::add_scope()`] for details.
10665    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProcessorDisableCall<'a, C>
10666    where
10667        I: IntoIterator<Item = St>,
10668        St: AsRef<str>,
10669    {
10670        self._scopes
10671            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10672        self
10673    }
10674
10675    /// Removes all scopes, and no default scope will be used either.
10676    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10677    /// for details).
10678    pub fn clear_scopes(mut self) -> ProjectLocationProcessorDisableCall<'a, C> {
10679        self._scopes.clear();
10680        self
10681    }
10682}
10683
10684/// Enables a processor
10685///
10686/// A builder for the *locations.processors.enable* method supported by a *project* resource.
10687/// It is not used directly, but through a [`ProjectMethods`] instance.
10688///
10689/// # Example
10690///
10691/// Instantiate a resource method builder
10692///
10693/// ```test_harness,no_run
10694/// # extern crate hyper;
10695/// # extern crate hyper_rustls;
10696/// # extern crate google_documentai1 as documentai1;
10697/// use documentai1::api::GoogleCloudDocumentaiV1EnableProcessorRequest;
10698/// # async fn dox() {
10699/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10700///
10701/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10702/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10703/// #     secret,
10704/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10705/// # ).build().await.unwrap();
10706///
10707/// # let client = hyper_util::client::legacy::Client::builder(
10708/// #     hyper_util::rt::TokioExecutor::new()
10709/// # )
10710/// # .build(
10711/// #     hyper_rustls::HttpsConnectorBuilder::new()
10712/// #         .with_native_roots()
10713/// #         .unwrap()
10714/// #         .https_or_http()
10715/// #         .enable_http1()
10716/// #         .build()
10717/// # );
10718/// # let mut hub = Document::new(client, auth);
10719/// // As the method needs a request, you would usually fill it with the desired information
10720/// // into the respective structure. Some of the parts shown here might not be applicable !
10721/// // Values shown here are possibly random and not representative !
10722/// let mut req = GoogleCloudDocumentaiV1EnableProcessorRequest::default();
10723///
10724/// // You can configure optional parameters by calling the respective setters at will, and
10725/// // execute the final call using `doit()`.
10726/// // Values shown here are possibly random and not representative !
10727/// let result = hub.projects().locations_processors_enable(req, "name")
10728///              .doit().await;
10729/// # }
10730/// ```
10731pub struct ProjectLocationProcessorEnableCall<'a, C>
10732where
10733    C: 'a,
10734{
10735    hub: &'a Document<C>,
10736    _request: GoogleCloudDocumentaiV1EnableProcessorRequest,
10737    _name: String,
10738    _delegate: Option<&'a mut dyn common::Delegate>,
10739    _additional_params: HashMap<String, String>,
10740    _scopes: BTreeSet<String>,
10741}
10742
10743impl<'a, C> common::CallBuilder for ProjectLocationProcessorEnableCall<'a, C> {}
10744
10745impl<'a, C> ProjectLocationProcessorEnableCall<'a, C>
10746where
10747    C: common::Connector,
10748{
10749    /// Perform the operation you have build so far.
10750    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
10751        use std::borrow::Cow;
10752        use std::io::{Read, Seek};
10753
10754        use common::{url::Params, ToParts};
10755        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10756
10757        let mut dd = common::DefaultDelegate;
10758        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10759        dlg.begin(common::MethodInfo {
10760            id: "documentai.projects.locations.processors.enable",
10761            http_method: hyper::Method::POST,
10762        });
10763
10764        for &field in ["alt", "name"].iter() {
10765            if self._additional_params.contains_key(field) {
10766                dlg.finished(false);
10767                return Err(common::Error::FieldClash(field));
10768            }
10769        }
10770
10771        let mut params = Params::with_capacity(4 + self._additional_params.len());
10772        params.push("name", self._name);
10773
10774        params.extend(self._additional_params.iter());
10775
10776        params.push("alt", "json");
10777        let mut url = self.hub._base_url.clone() + "v1/{+name}:enable";
10778        if self._scopes.is_empty() {
10779            self._scopes
10780                .insert(Scope::CloudPlatform.as_ref().to_string());
10781        }
10782
10783        #[allow(clippy::single_element_loop)]
10784        for &(find_this, param_name) in [("{+name}", "name")].iter() {
10785            url = params.uri_replacement(url, param_name, find_this, true);
10786        }
10787        {
10788            let to_remove = ["name"];
10789            params.remove_params(&to_remove);
10790        }
10791
10792        let url = params.parse_with_url(&url);
10793
10794        let mut json_mime_type = mime::APPLICATION_JSON;
10795        let mut request_value_reader = {
10796            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10797            common::remove_json_null_values(&mut value);
10798            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10799            serde_json::to_writer(&mut dst, &value).unwrap();
10800            dst
10801        };
10802        let request_size = request_value_reader
10803            .seek(std::io::SeekFrom::End(0))
10804            .unwrap();
10805        request_value_reader
10806            .seek(std::io::SeekFrom::Start(0))
10807            .unwrap();
10808
10809        loop {
10810            let token = match self
10811                .hub
10812                .auth
10813                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10814                .await
10815            {
10816                Ok(token) => token,
10817                Err(e) => match dlg.token(e) {
10818                    Ok(token) => token,
10819                    Err(e) => {
10820                        dlg.finished(false);
10821                        return Err(common::Error::MissingToken(e));
10822                    }
10823                },
10824            };
10825            request_value_reader
10826                .seek(std::io::SeekFrom::Start(0))
10827                .unwrap();
10828            let mut req_result = {
10829                let client = &self.hub.client;
10830                dlg.pre_request();
10831                let mut req_builder = hyper::Request::builder()
10832                    .method(hyper::Method::POST)
10833                    .uri(url.as_str())
10834                    .header(USER_AGENT, self.hub._user_agent.clone());
10835
10836                if let Some(token) = token.as_ref() {
10837                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10838                }
10839
10840                let request = req_builder
10841                    .header(CONTENT_TYPE, json_mime_type.to_string())
10842                    .header(CONTENT_LENGTH, request_size as u64)
10843                    .body(common::to_body(
10844                        request_value_reader.get_ref().clone().into(),
10845                    ));
10846
10847                client.request(request.unwrap()).await
10848            };
10849
10850            match req_result {
10851                Err(err) => {
10852                    if let common::Retry::After(d) = dlg.http_error(&err) {
10853                        sleep(d).await;
10854                        continue;
10855                    }
10856                    dlg.finished(false);
10857                    return Err(common::Error::HttpError(err));
10858                }
10859                Ok(res) => {
10860                    let (mut parts, body) = res.into_parts();
10861                    let mut body = common::Body::new(body);
10862                    if !parts.status.is_success() {
10863                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10864                        let error = serde_json::from_str(&common::to_string(&bytes));
10865                        let response = common::to_response(parts, bytes.into());
10866
10867                        if let common::Retry::After(d) =
10868                            dlg.http_failure(&response, error.as_ref().ok())
10869                        {
10870                            sleep(d).await;
10871                            continue;
10872                        }
10873
10874                        dlg.finished(false);
10875
10876                        return Err(match error {
10877                            Ok(value) => common::Error::BadRequest(value),
10878                            _ => common::Error::Failure(response),
10879                        });
10880                    }
10881                    let response = {
10882                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10883                        let encoded = common::to_string(&bytes);
10884                        match serde_json::from_str(&encoded) {
10885                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10886                            Err(error) => {
10887                                dlg.response_json_decode_error(&encoded, &error);
10888                                return Err(common::Error::JsonDecodeError(
10889                                    encoded.to_string(),
10890                                    error,
10891                                ));
10892                            }
10893                        }
10894                    };
10895
10896                    dlg.finished(true);
10897                    return Ok(response);
10898                }
10899            }
10900        }
10901    }
10902
10903    ///
10904    /// Sets the *request* property to the given value.
10905    ///
10906    /// Even though the property as already been set when instantiating this call,
10907    /// we provide this method for API completeness.
10908    pub fn request(
10909        mut self,
10910        new_value: GoogleCloudDocumentaiV1EnableProcessorRequest,
10911    ) -> ProjectLocationProcessorEnableCall<'a, C> {
10912        self._request = new_value;
10913        self
10914    }
10915    /// Required. The processor resource name to be enabled.
10916    ///
10917    /// Sets the *name* path property to the given value.
10918    ///
10919    /// Even though the property as already been set when instantiating this call,
10920    /// we provide this method for API completeness.
10921    pub fn name(mut self, new_value: &str) -> ProjectLocationProcessorEnableCall<'a, C> {
10922        self._name = new_value.to_string();
10923        self
10924    }
10925    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10926    /// while executing the actual API request.
10927    ///
10928    /// ````text
10929    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10930    /// ````
10931    ///
10932    /// Sets the *delegate* property to the given value.
10933    pub fn delegate(
10934        mut self,
10935        new_value: &'a mut dyn common::Delegate,
10936    ) -> ProjectLocationProcessorEnableCall<'a, C> {
10937        self._delegate = Some(new_value);
10938        self
10939    }
10940
10941    /// Set any additional parameter of the query string used in the request.
10942    /// It should be used to set parameters which are not yet available through their own
10943    /// setters.
10944    ///
10945    /// Please note that this method must not be used to set any of the known parameters
10946    /// which have their own setter method. If done anyway, the request will fail.
10947    ///
10948    /// # Additional Parameters
10949    ///
10950    /// * *$.xgafv* (query-string) - V1 error format.
10951    /// * *access_token* (query-string) - OAuth access token.
10952    /// * *alt* (query-string) - Data format for response.
10953    /// * *callback* (query-string) - JSONP
10954    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10955    /// * *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.
10956    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10957    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10958    /// * *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.
10959    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10960    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10961    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProcessorEnableCall<'a, C>
10962    where
10963        T: AsRef<str>,
10964    {
10965        self._additional_params
10966            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10967        self
10968    }
10969
10970    /// Identifies the authorization scope for the method you are building.
10971    ///
10972    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10973    /// [`Scope::CloudPlatform`].
10974    ///
10975    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10976    /// tokens for more than one scope.
10977    ///
10978    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10979    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10980    /// sufficient, a read-write scope will do as well.
10981    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProcessorEnableCall<'a, C>
10982    where
10983        St: AsRef<str>,
10984    {
10985        self._scopes.insert(String::from(scope.as_ref()));
10986        self
10987    }
10988    /// Identifies the authorization scope(s) for the method you are building.
10989    ///
10990    /// See [`Self::add_scope()`] for details.
10991    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProcessorEnableCall<'a, C>
10992    where
10993        I: IntoIterator<Item = St>,
10994        St: AsRef<str>,
10995    {
10996        self._scopes
10997            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10998        self
10999    }
11000
11001    /// Removes all scopes, and no default scope will be used either.
11002    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11003    /// for details).
11004    pub fn clear_scopes(mut self) -> ProjectLocationProcessorEnableCall<'a, C> {
11005        self._scopes.clear();
11006        self
11007    }
11008}
11009
11010/// Gets a processor detail.
11011///
11012/// A builder for the *locations.processors.get* method supported by a *project* resource.
11013/// It is not used directly, but through a [`ProjectMethods`] instance.
11014///
11015/// # Example
11016///
11017/// Instantiate a resource method builder
11018///
11019/// ```test_harness,no_run
11020/// # extern crate hyper;
11021/// # extern crate hyper_rustls;
11022/// # extern crate google_documentai1 as documentai1;
11023/// # async fn dox() {
11024/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11025///
11026/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11027/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11028/// #     secret,
11029/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11030/// # ).build().await.unwrap();
11031///
11032/// # let client = hyper_util::client::legacy::Client::builder(
11033/// #     hyper_util::rt::TokioExecutor::new()
11034/// # )
11035/// # .build(
11036/// #     hyper_rustls::HttpsConnectorBuilder::new()
11037/// #         .with_native_roots()
11038/// #         .unwrap()
11039/// #         .https_or_http()
11040/// #         .enable_http1()
11041/// #         .build()
11042/// # );
11043/// # let mut hub = Document::new(client, auth);
11044/// // You can configure optional parameters by calling the respective setters at will, and
11045/// // execute the final call using `doit()`.
11046/// // Values shown here are possibly random and not representative !
11047/// let result = hub.projects().locations_processors_get("name")
11048///              .doit().await;
11049/// # }
11050/// ```
11051pub struct ProjectLocationProcessorGetCall<'a, C>
11052where
11053    C: 'a,
11054{
11055    hub: &'a Document<C>,
11056    _name: String,
11057    _delegate: Option<&'a mut dyn common::Delegate>,
11058    _additional_params: HashMap<String, String>,
11059    _scopes: BTreeSet<String>,
11060}
11061
11062impl<'a, C> common::CallBuilder for ProjectLocationProcessorGetCall<'a, C> {}
11063
11064impl<'a, C> ProjectLocationProcessorGetCall<'a, C>
11065where
11066    C: common::Connector,
11067{
11068    /// Perform the operation you have build so far.
11069    pub async fn doit(
11070        mut self,
11071    ) -> common::Result<(common::Response, GoogleCloudDocumentaiV1Processor)> {
11072        use std::borrow::Cow;
11073        use std::io::{Read, Seek};
11074
11075        use common::{url::Params, ToParts};
11076        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11077
11078        let mut dd = common::DefaultDelegate;
11079        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11080        dlg.begin(common::MethodInfo {
11081            id: "documentai.projects.locations.processors.get",
11082            http_method: hyper::Method::GET,
11083        });
11084
11085        for &field in ["alt", "name"].iter() {
11086            if self._additional_params.contains_key(field) {
11087                dlg.finished(false);
11088                return Err(common::Error::FieldClash(field));
11089            }
11090        }
11091
11092        let mut params = Params::with_capacity(3 + self._additional_params.len());
11093        params.push("name", self._name);
11094
11095        params.extend(self._additional_params.iter());
11096
11097        params.push("alt", "json");
11098        let mut url = self.hub._base_url.clone() + "v1/{+name}";
11099        if self._scopes.is_empty() {
11100            self._scopes
11101                .insert(Scope::CloudPlatform.as_ref().to_string());
11102        }
11103
11104        #[allow(clippy::single_element_loop)]
11105        for &(find_this, param_name) in [("{+name}", "name")].iter() {
11106            url = params.uri_replacement(url, param_name, find_this, true);
11107        }
11108        {
11109            let to_remove = ["name"];
11110            params.remove_params(&to_remove);
11111        }
11112
11113        let url = params.parse_with_url(&url);
11114
11115        loop {
11116            let token = match self
11117                .hub
11118                .auth
11119                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11120                .await
11121            {
11122                Ok(token) => token,
11123                Err(e) => match dlg.token(e) {
11124                    Ok(token) => token,
11125                    Err(e) => {
11126                        dlg.finished(false);
11127                        return Err(common::Error::MissingToken(e));
11128                    }
11129                },
11130            };
11131            let mut req_result = {
11132                let client = &self.hub.client;
11133                dlg.pre_request();
11134                let mut req_builder = hyper::Request::builder()
11135                    .method(hyper::Method::GET)
11136                    .uri(url.as_str())
11137                    .header(USER_AGENT, self.hub._user_agent.clone());
11138
11139                if let Some(token) = token.as_ref() {
11140                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11141                }
11142
11143                let request = req_builder
11144                    .header(CONTENT_LENGTH, 0_u64)
11145                    .body(common::to_body::<String>(None));
11146
11147                client.request(request.unwrap()).await
11148            };
11149
11150            match req_result {
11151                Err(err) => {
11152                    if let common::Retry::After(d) = dlg.http_error(&err) {
11153                        sleep(d).await;
11154                        continue;
11155                    }
11156                    dlg.finished(false);
11157                    return Err(common::Error::HttpError(err));
11158                }
11159                Ok(res) => {
11160                    let (mut parts, body) = res.into_parts();
11161                    let mut body = common::Body::new(body);
11162                    if !parts.status.is_success() {
11163                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11164                        let error = serde_json::from_str(&common::to_string(&bytes));
11165                        let response = common::to_response(parts, bytes.into());
11166
11167                        if let common::Retry::After(d) =
11168                            dlg.http_failure(&response, error.as_ref().ok())
11169                        {
11170                            sleep(d).await;
11171                            continue;
11172                        }
11173
11174                        dlg.finished(false);
11175
11176                        return Err(match error {
11177                            Ok(value) => common::Error::BadRequest(value),
11178                            _ => common::Error::Failure(response),
11179                        });
11180                    }
11181                    let response = {
11182                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11183                        let encoded = common::to_string(&bytes);
11184                        match serde_json::from_str(&encoded) {
11185                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11186                            Err(error) => {
11187                                dlg.response_json_decode_error(&encoded, &error);
11188                                return Err(common::Error::JsonDecodeError(
11189                                    encoded.to_string(),
11190                                    error,
11191                                ));
11192                            }
11193                        }
11194                    };
11195
11196                    dlg.finished(true);
11197                    return Ok(response);
11198                }
11199            }
11200        }
11201    }
11202
11203    /// Required. The processor resource name.
11204    ///
11205    /// Sets the *name* path property to the given value.
11206    ///
11207    /// Even though the property as already been set when instantiating this call,
11208    /// we provide this method for API completeness.
11209    pub fn name(mut self, new_value: &str) -> ProjectLocationProcessorGetCall<'a, C> {
11210        self._name = new_value.to_string();
11211        self
11212    }
11213    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11214    /// while executing the actual API request.
11215    ///
11216    /// ````text
11217    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11218    /// ````
11219    ///
11220    /// Sets the *delegate* property to the given value.
11221    pub fn delegate(
11222        mut self,
11223        new_value: &'a mut dyn common::Delegate,
11224    ) -> ProjectLocationProcessorGetCall<'a, C> {
11225        self._delegate = Some(new_value);
11226        self
11227    }
11228
11229    /// Set any additional parameter of the query string used in the request.
11230    /// It should be used to set parameters which are not yet available through their own
11231    /// setters.
11232    ///
11233    /// Please note that this method must not be used to set any of the known parameters
11234    /// which have their own setter method. If done anyway, the request will fail.
11235    ///
11236    /// # Additional Parameters
11237    ///
11238    /// * *$.xgafv* (query-string) - V1 error format.
11239    /// * *access_token* (query-string) - OAuth access token.
11240    /// * *alt* (query-string) - Data format for response.
11241    /// * *callback* (query-string) - JSONP
11242    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11243    /// * *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.
11244    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11245    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11246    /// * *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.
11247    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11248    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11249    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProcessorGetCall<'a, C>
11250    where
11251        T: AsRef<str>,
11252    {
11253        self._additional_params
11254            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11255        self
11256    }
11257
11258    /// Identifies the authorization scope for the method you are building.
11259    ///
11260    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11261    /// [`Scope::CloudPlatform`].
11262    ///
11263    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11264    /// tokens for more than one scope.
11265    ///
11266    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11267    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11268    /// sufficient, a read-write scope will do as well.
11269    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProcessorGetCall<'a, C>
11270    where
11271        St: AsRef<str>,
11272    {
11273        self._scopes.insert(String::from(scope.as_ref()));
11274        self
11275    }
11276    /// Identifies the authorization scope(s) for the method you are building.
11277    ///
11278    /// See [`Self::add_scope()`] for details.
11279    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProcessorGetCall<'a, C>
11280    where
11281        I: IntoIterator<Item = St>,
11282        St: AsRef<str>,
11283    {
11284        self._scopes
11285            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11286        self
11287    }
11288
11289    /// Removes all scopes, and no default scope will be used either.
11290    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11291    /// for details).
11292    pub fn clear_scopes(mut self) -> ProjectLocationProcessorGetCall<'a, C> {
11293        self._scopes.clear();
11294        self
11295    }
11296}
11297
11298/// Lists all processors which belong to this project.
11299///
11300/// A builder for the *locations.processors.list* method supported by a *project* resource.
11301/// It is not used directly, but through a [`ProjectMethods`] instance.
11302///
11303/// # Example
11304///
11305/// Instantiate a resource method builder
11306///
11307/// ```test_harness,no_run
11308/// # extern crate hyper;
11309/// # extern crate hyper_rustls;
11310/// # extern crate google_documentai1 as documentai1;
11311/// # async fn dox() {
11312/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11313///
11314/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11315/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11316/// #     secret,
11317/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11318/// # ).build().await.unwrap();
11319///
11320/// # let client = hyper_util::client::legacy::Client::builder(
11321/// #     hyper_util::rt::TokioExecutor::new()
11322/// # )
11323/// # .build(
11324/// #     hyper_rustls::HttpsConnectorBuilder::new()
11325/// #         .with_native_roots()
11326/// #         .unwrap()
11327/// #         .https_or_http()
11328/// #         .enable_http1()
11329/// #         .build()
11330/// # );
11331/// # let mut hub = Document::new(client, auth);
11332/// // You can configure optional parameters by calling the respective setters at will, and
11333/// // execute the final call using `doit()`.
11334/// // Values shown here are possibly random and not representative !
11335/// let result = hub.projects().locations_processors_list("parent")
11336///              .page_token("labore")
11337///              .page_size(-43)
11338///              .doit().await;
11339/// # }
11340/// ```
11341pub struct ProjectLocationProcessorListCall<'a, C>
11342where
11343    C: 'a,
11344{
11345    hub: &'a Document<C>,
11346    _parent: String,
11347    _page_token: Option<String>,
11348    _page_size: Option<i32>,
11349    _delegate: Option<&'a mut dyn common::Delegate>,
11350    _additional_params: HashMap<String, String>,
11351    _scopes: BTreeSet<String>,
11352}
11353
11354impl<'a, C> common::CallBuilder for ProjectLocationProcessorListCall<'a, C> {}
11355
11356impl<'a, C> ProjectLocationProcessorListCall<'a, C>
11357where
11358    C: common::Connector,
11359{
11360    /// Perform the operation you have build so far.
11361    pub async fn doit(
11362        mut self,
11363    ) -> common::Result<(
11364        common::Response,
11365        GoogleCloudDocumentaiV1ListProcessorsResponse,
11366    )> {
11367        use std::borrow::Cow;
11368        use std::io::{Read, Seek};
11369
11370        use common::{url::Params, ToParts};
11371        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11372
11373        let mut dd = common::DefaultDelegate;
11374        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11375        dlg.begin(common::MethodInfo {
11376            id: "documentai.projects.locations.processors.list",
11377            http_method: hyper::Method::GET,
11378        });
11379
11380        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
11381            if self._additional_params.contains_key(field) {
11382                dlg.finished(false);
11383                return Err(common::Error::FieldClash(field));
11384            }
11385        }
11386
11387        let mut params = Params::with_capacity(5 + self._additional_params.len());
11388        params.push("parent", self._parent);
11389        if let Some(value) = self._page_token.as_ref() {
11390            params.push("pageToken", value);
11391        }
11392        if let Some(value) = self._page_size.as_ref() {
11393            params.push("pageSize", value.to_string());
11394        }
11395
11396        params.extend(self._additional_params.iter());
11397
11398        params.push("alt", "json");
11399        let mut url = self.hub._base_url.clone() + "v1/{+parent}/processors";
11400        if self._scopes.is_empty() {
11401            self._scopes
11402                .insert(Scope::CloudPlatform.as_ref().to_string());
11403        }
11404
11405        #[allow(clippy::single_element_loop)]
11406        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
11407            url = params.uri_replacement(url, param_name, find_this, true);
11408        }
11409        {
11410            let to_remove = ["parent"];
11411            params.remove_params(&to_remove);
11412        }
11413
11414        let url = params.parse_with_url(&url);
11415
11416        loop {
11417            let token = match self
11418                .hub
11419                .auth
11420                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11421                .await
11422            {
11423                Ok(token) => token,
11424                Err(e) => match dlg.token(e) {
11425                    Ok(token) => token,
11426                    Err(e) => {
11427                        dlg.finished(false);
11428                        return Err(common::Error::MissingToken(e));
11429                    }
11430                },
11431            };
11432            let mut req_result = {
11433                let client = &self.hub.client;
11434                dlg.pre_request();
11435                let mut req_builder = hyper::Request::builder()
11436                    .method(hyper::Method::GET)
11437                    .uri(url.as_str())
11438                    .header(USER_AGENT, self.hub._user_agent.clone());
11439
11440                if let Some(token) = token.as_ref() {
11441                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11442                }
11443
11444                let request = req_builder
11445                    .header(CONTENT_LENGTH, 0_u64)
11446                    .body(common::to_body::<String>(None));
11447
11448                client.request(request.unwrap()).await
11449            };
11450
11451            match req_result {
11452                Err(err) => {
11453                    if let common::Retry::After(d) = dlg.http_error(&err) {
11454                        sleep(d).await;
11455                        continue;
11456                    }
11457                    dlg.finished(false);
11458                    return Err(common::Error::HttpError(err));
11459                }
11460                Ok(res) => {
11461                    let (mut parts, body) = res.into_parts();
11462                    let mut body = common::Body::new(body);
11463                    if !parts.status.is_success() {
11464                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11465                        let error = serde_json::from_str(&common::to_string(&bytes));
11466                        let response = common::to_response(parts, bytes.into());
11467
11468                        if let common::Retry::After(d) =
11469                            dlg.http_failure(&response, error.as_ref().ok())
11470                        {
11471                            sleep(d).await;
11472                            continue;
11473                        }
11474
11475                        dlg.finished(false);
11476
11477                        return Err(match error {
11478                            Ok(value) => common::Error::BadRequest(value),
11479                            _ => common::Error::Failure(response),
11480                        });
11481                    }
11482                    let response = {
11483                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11484                        let encoded = common::to_string(&bytes);
11485                        match serde_json::from_str(&encoded) {
11486                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11487                            Err(error) => {
11488                                dlg.response_json_decode_error(&encoded, &error);
11489                                return Err(common::Error::JsonDecodeError(
11490                                    encoded.to_string(),
11491                                    error,
11492                                ));
11493                            }
11494                        }
11495                    };
11496
11497                    dlg.finished(true);
11498                    return Ok(response);
11499                }
11500            }
11501        }
11502    }
11503
11504    /// Required. The parent (project and location) which owns this collection of Processors. Format: `projects/{project}/locations/{location}`
11505    ///
11506    /// Sets the *parent* path property to the given value.
11507    ///
11508    /// Even though the property as already been set when instantiating this call,
11509    /// we provide this method for API completeness.
11510    pub fn parent(mut self, new_value: &str) -> ProjectLocationProcessorListCall<'a, C> {
11511        self._parent = new_value.to_string();
11512        self
11513    }
11514    /// We will return the processors sorted by creation time. The page token will point to the next processor.
11515    ///
11516    /// Sets the *page token* query property to the given value.
11517    pub fn page_token(mut self, new_value: &str) -> ProjectLocationProcessorListCall<'a, C> {
11518        self._page_token = Some(new_value.to_string());
11519        self
11520    }
11521    /// The maximum number of processors to return. If unspecified, at most `50` processors will be returned. The maximum value is `100`. Values above `100` will be coerced to `100`.
11522    ///
11523    /// Sets the *page size* query property to the given value.
11524    pub fn page_size(mut self, new_value: i32) -> ProjectLocationProcessorListCall<'a, C> {
11525        self._page_size = Some(new_value);
11526        self
11527    }
11528    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11529    /// while executing the actual API request.
11530    ///
11531    /// ````text
11532    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11533    /// ````
11534    ///
11535    /// Sets the *delegate* property to the given value.
11536    pub fn delegate(
11537        mut self,
11538        new_value: &'a mut dyn common::Delegate,
11539    ) -> ProjectLocationProcessorListCall<'a, C> {
11540        self._delegate = Some(new_value);
11541        self
11542    }
11543
11544    /// Set any additional parameter of the query string used in the request.
11545    /// It should be used to set parameters which are not yet available through their own
11546    /// setters.
11547    ///
11548    /// Please note that this method must not be used to set any of the known parameters
11549    /// which have their own setter method. If done anyway, the request will fail.
11550    ///
11551    /// # Additional Parameters
11552    ///
11553    /// * *$.xgafv* (query-string) - V1 error format.
11554    /// * *access_token* (query-string) - OAuth access token.
11555    /// * *alt* (query-string) - Data format for response.
11556    /// * *callback* (query-string) - JSONP
11557    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11558    /// * *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.
11559    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11560    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11561    /// * *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.
11562    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11563    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11564    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProcessorListCall<'a, C>
11565    where
11566        T: AsRef<str>,
11567    {
11568        self._additional_params
11569            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11570        self
11571    }
11572
11573    /// Identifies the authorization scope for the method you are building.
11574    ///
11575    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11576    /// [`Scope::CloudPlatform`].
11577    ///
11578    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11579    /// tokens for more than one scope.
11580    ///
11581    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11582    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11583    /// sufficient, a read-write scope will do as well.
11584    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProcessorListCall<'a, C>
11585    where
11586        St: AsRef<str>,
11587    {
11588        self._scopes.insert(String::from(scope.as_ref()));
11589        self
11590    }
11591    /// Identifies the authorization scope(s) for the method you are building.
11592    ///
11593    /// See [`Self::add_scope()`] for details.
11594    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProcessorListCall<'a, C>
11595    where
11596        I: IntoIterator<Item = St>,
11597        St: AsRef<str>,
11598    {
11599        self._scopes
11600            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11601        self
11602    }
11603
11604    /// Removes all scopes, and no default scope will be used either.
11605    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11606    /// for details).
11607    pub fn clear_scopes(mut self) -> ProjectLocationProcessorListCall<'a, C> {
11608        self._scopes.clear();
11609        self
11610    }
11611}
11612
11613/// Processes a single document.
11614///
11615/// A builder for the *locations.processors.process* method supported by a *project* resource.
11616/// It is not used directly, but through a [`ProjectMethods`] instance.
11617///
11618/// # Example
11619///
11620/// Instantiate a resource method builder
11621///
11622/// ```test_harness,no_run
11623/// # extern crate hyper;
11624/// # extern crate hyper_rustls;
11625/// # extern crate google_documentai1 as documentai1;
11626/// use documentai1::api::GoogleCloudDocumentaiV1ProcessRequest;
11627/// # async fn dox() {
11628/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11629///
11630/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11631/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11632/// #     secret,
11633/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11634/// # ).build().await.unwrap();
11635///
11636/// # let client = hyper_util::client::legacy::Client::builder(
11637/// #     hyper_util::rt::TokioExecutor::new()
11638/// # )
11639/// # .build(
11640/// #     hyper_rustls::HttpsConnectorBuilder::new()
11641/// #         .with_native_roots()
11642/// #         .unwrap()
11643/// #         .https_or_http()
11644/// #         .enable_http1()
11645/// #         .build()
11646/// # );
11647/// # let mut hub = Document::new(client, auth);
11648/// // As the method needs a request, you would usually fill it with the desired information
11649/// // into the respective structure. Some of the parts shown here might not be applicable !
11650/// // Values shown here are possibly random and not representative !
11651/// let mut req = GoogleCloudDocumentaiV1ProcessRequest::default();
11652///
11653/// // You can configure optional parameters by calling the respective setters at will, and
11654/// // execute the final call using `doit()`.
11655/// // Values shown here are possibly random and not representative !
11656/// let result = hub.projects().locations_processors_process(req, "name")
11657///              .doit().await;
11658/// # }
11659/// ```
11660pub struct ProjectLocationProcessorProcesCall<'a, C>
11661where
11662    C: 'a,
11663{
11664    hub: &'a Document<C>,
11665    _request: GoogleCloudDocumentaiV1ProcessRequest,
11666    _name: String,
11667    _delegate: Option<&'a mut dyn common::Delegate>,
11668    _additional_params: HashMap<String, String>,
11669    _scopes: BTreeSet<String>,
11670}
11671
11672impl<'a, C> common::CallBuilder for ProjectLocationProcessorProcesCall<'a, C> {}
11673
11674impl<'a, C> ProjectLocationProcessorProcesCall<'a, C>
11675where
11676    C: common::Connector,
11677{
11678    /// Perform the operation you have build so far.
11679    pub async fn doit(
11680        mut self,
11681    ) -> common::Result<(common::Response, GoogleCloudDocumentaiV1ProcessResponse)> {
11682        use std::borrow::Cow;
11683        use std::io::{Read, Seek};
11684
11685        use common::{url::Params, ToParts};
11686        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11687
11688        let mut dd = common::DefaultDelegate;
11689        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11690        dlg.begin(common::MethodInfo {
11691            id: "documentai.projects.locations.processors.process",
11692            http_method: hyper::Method::POST,
11693        });
11694
11695        for &field in ["alt", "name"].iter() {
11696            if self._additional_params.contains_key(field) {
11697                dlg.finished(false);
11698                return Err(common::Error::FieldClash(field));
11699            }
11700        }
11701
11702        let mut params = Params::with_capacity(4 + self._additional_params.len());
11703        params.push("name", self._name);
11704
11705        params.extend(self._additional_params.iter());
11706
11707        params.push("alt", "json");
11708        let mut url = self.hub._base_url.clone() + "v1/{+name}:process";
11709        if self._scopes.is_empty() {
11710            self._scopes
11711                .insert(Scope::CloudPlatform.as_ref().to_string());
11712        }
11713
11714        #[allow(clippy::single_element_loop)]
11715        for &(find_this, param_name) in [("{+name}", "name")].iter() {
11716            url = params.uri_replacement(url, param_name, find_this, true);
11717        }
11718        {
11719            let to_remove = ["name"];
11720            params.remove_params(&to_remove);
11721        }
11722
11723        let url = params.parse_with_url(&url);
11724
11725        let mut json_mime_type = mime::APPLICATION_JSON;
11726        let mut request_value_reader = {
11727            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11728            common::remove_json_null_values(&mut value);
11729            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11730            serde_json::to_writer(&mut dst, &value).unwrap();
11731            dst
11732        };
11733        let request_size = request_value_reader
11734            .seek(std::io::SeekFrom::End(0))
11735            .unwrap();
11736        request_value_reader
11737            .seek(std::io::SeekFrom::Start(0))
11738            .unwrap();
11739
11740        loop {
11741            let token = match self
11742                .hub
11743                .auth
11744                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11745                .await
11746            {
11747                Ok(token) => token,
11748                Err(e) => match dlg.token(e) {
11749                    Ok(token) => token,
11750                    Err(e) => {
11751                        dlg.finished(false);
11752                        return Err(common::Error::MissingToken(e));
11753                    }
11754                },
11755            };
11756            request_value_reader
11757                .seek(std::io::SeekFrom::Start(0))
11758                .unwrap();
11759            let mut req_result = {
11760                let client = &self.hub.client;
11761                dlg.pre_request();
11762                let mut req_builder = hyper::Request::builder()
11763                    .method(hyper::Method::POST)
11764                    .uri(url.as_str())
11765                    .header(USER_AGENT, self.hub._user_agent.clone());
11766
11767                if let Some(token) = token.as_ref() {
11768                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11769                }
11770
11771                let request = req_builder
11772                    .header(CONTENT_TYPE, json_mime_type.to_string())
11773                    .header(CONTENT_LENGTH, request_size as u64)
11774                    .body(common::to_body(
11775                        request_value_reader.get_ref().clone().into(),
11776                    ));
11777
11778                client.request(request.unwrap()).await
11779            };
11780
11781            match req_result {
11782                Err(err) => {
11783                    if let common::Retry::After(d) = dlg.http_error(&err) {
11784                        sleep(d).await;
11785                        continue;
11786                    }
11787                    dlg.finished(false);
11788                    return Err(common::Error::HttpError(err));
11789                }
11790                Ok(res) => {
11791                    let (mut parts, body) = res.into_parts();
11792                    let mut body = common::Body::new(body);
11793                    if !parts.status.is_success() {
11794                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11795                        let error = serde_json::from_str(&common::to_string(&bytes));
11796                        let response = common::to_response(parts, bytes.into());
11797
11798                        if let common::Retry::After(d) =
11799                            dlg.http_failure(&response, error.as_ref().ok())
11800                        {
11801                            sleep(d).await;
11802                            continue;
11803                        }
11804
11805                        dlg.finished(false);
11806
11807                        return Err(match error {
11808                            Ok(value) => common::Error::BadRequest(value),
11809                            _ => common::Error::Failure(response),
11810                        });
11811                    }
11812                    let response = {
11813                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11814                        let encoded = common::to_string(&bytes);
11815                        match serde_json::from_str(&encoded) {
11816                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11817                            Err(error) => {
11818                                dlg.response_json_decode_error(&encoded, &error);
11819                                return Err(common::Error::JsonDecodeError(
11820                                    encoded.to_string(),
11821                                    error,
11822                                ));
11823                            }
11824                        }
11825                    };
11826
11827                    dlg.finished(true);
11828                    return Ok(response);
11829                }
11830            }
11831        }
11832    }
11833
11834    ///
11835    /// Sets the *request* property to the given value.
11836    ///
11837    /// Even though the property as already been set when instantiating this call,
11838    /// we provide this method for API completeness.
11839    pub fn request(
11840        mut self,
11841        new_value: GoogleCloudDocumentaiV1ProcessRequest,
11842    ) -> ProjectLocationProcessorProcesCall<'a, C> {
11843        self._request = new_value;
11844        self
11845    }
11846    /// Required. The resource name of the Processor or ProcessorVersion to use for processing. If a Processor is specified, the server will use its default version. Format: `projects/{project}/locations/{location}/processors/{processor}`, or `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`
11847    ///
11848    /// Sets the *name* path property to the given value.
11849    ///
11850    /// Even though the property as already been set when instantiating this call,
11851    /// we provide this method for API completeness.
11852    pub fn name(mut self, new_value: &str) -> ProjectLocationProcessorProcesCall<'a, C> {
11853        self._name = new_value.to_string();
11854        self
11855    }
11856    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11857    /// while executing the actual API request.
11858    ///
11859    /// ````text
11860    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11861    /// ````
11862    ///
11863    /// Sets the *delegate* property to the given value.
11864    pub fn delegate(
11865        mut self,
11866        new_value: &'a mut dyn common::Delegate,
11867    ) -> ProjectLocationProcessorProcesCall<'a, C> {
11868        self._delegate = Some(new_value);
11869        self
11870    }
11871
11872    /// Set any additional parameter of the query string used in the request.
11873    /// It should be used to set parameters which are not yet available through their own
11874    /// setters.
11875    ///
11876    /// Please note that this method must not be used to set any of the known parameters
11877    /// which have their own setter method. If done anyway, the request will fail.
11878    ///
11879    /// # Additional Parameters
11880    ///
11881    /// * *$.xgafv* (query-string) - V1 error format.
11882    /// * *access_token* (query-string) - OAuth access token.
11883    /// * *alt* (query-string) - Data format for response.
11884    /// * *callback* (query-string) - JSONP
11885    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11886    /// * *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.
11887    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11888    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11889    /// * *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.
11890    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11891    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11892    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProcessorProcesCall<'a, C>
11893    where
11894        T: AsRef<str>,
11895    {
11896        self._additional_params
11897            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11898        self
11899    }
11900
11901    /// Identifies the authorization scope for the method you are building.
11902    ///
11903    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11904    /// [`Scope::CloudPlatform`].
11905    ///
11906    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11907    /// tokens for more than one scope.
11908    ///
11909    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11910    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11911    /// sufficient, a read-write scope will do as well.
11912    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProcessorProcesCall<'a, C>
11913    where
11914        St: AsRef<str>,
11915    {
11916        self._scopes.insert(String::from(scope.as_ref()));
11917        self
11918    }
11919    /// Identifies the authorization scope(s) for the method you are building.
11920    ///
11921    /// See [`Self::add_scope()`] for details.
11922    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProcessorProcesCall<'a, C>
11923    where
11924        I: IntoIterator<Item = St>,
11925        St: AsRef<str>,
11926    {
11927        self._scopes
11928            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11929        self
11930    }
11931
11932    /// Removes all scopes, and no default scope will be used either.
11933    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11934    /// for details).
11935    pub fn clear_scopes(mut self) -> ProjectLocationProcessorProcesCall<'a, C> {
11936        self._scopes.clear();
11937        self
11938    }
11939}
11940
11941/// Set the default (active) version of a Processor that will be used in ProcessDocument and BatchProcessDocuments.
11942///
11943/// A builder for the *locations.processors.setDefaultProcessorVersion* method supported by a *project* resource.
11944/// It is not used directly, but through a [`ProjectMethods`] instance.
11945///
11946/// # Example
11947///
11948/// Instantiate a resource method builder
11949///
11950/// ```test_harness,no_run
11951/// # extern crate hyper;
11952/// # extern crate hyper_rustls;
11953/// # extern crate google_documentai1 as documentai1;
11954/// use documentai1::api::GoogleCloudDocumentaiV1SetDefaultProcessorVersionRequest;
11955/// # async fn dox() {
11956/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11957///
11958/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11959/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11960/// #     secret,
11961/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11962/// # ).build().await.unwrap();
11963///
11964/// # let client = hyper_util::client::legacy::Client::builder(
11965/// #     hyper_util::rt::TokioExecutor::new()
11966/// # )
11967/// # .build(
11968/// #     hyper_rustls::HttpsConnectorBuilder::new()
11969/// #         .with_native_roots()
11970/// #         .unwrap()
11971/// #         .https_or_http()
11972/// #         .enable_http1()
11973/// #         .build()
11974/// # );
11975/// # let mut hub = Document::new(client, auth);
11976/// // As the method needs a request, you would usually fill it with the desired information
11977/// // into the respective structure. Some of the parts shown here might not be applicable !
11978/// // Values shown here are possibly random and not representative !
11979/// let mut req = GoogleCloudDocumentaiV1SetDefaultProcessorVersionRequest::default();
11980///
11981/// // You can configure optional parameters by calling the respective setters at will, and
11982/// // execute the final call using `doit()`.
11983/// // Values shown here are possibly random and not representative !
11984/// let result = hub.projects().locations_processors_set_default_processor_version(req, "processor")
11985///              .doit().await;
11986/// # }
11987/// ```
11988pub struct ProjectLocationProcessorSetDefaultProcessorVersionCall<'a, C>
11989where
11990    C: 'a,
11991{
11992    hub: &'a Document<C>,
11993    _request: GoogleCloudDocumentaiV1SetDefaultProcessorVersionRequest,
11994    _processor: String,
11995    _delegate: Option<&'a mut dyn common::Delegate>,
11996    _additional_params: HashMap<String, String>,
11997    _scopes: BTreeSet<String>,
11998}
11999
12000impl<'a, C> common::CallBuilder for ProjectLocationProcessorSetDefaultProcessorVersionCall<'a, C> {}
12001
12002impl<'a, C> ProjectLocationProcessorSetDefaultProcessorVersionCall<'a, C>
12003where
12004    C: common::Connector,
12005{
12006    /// Perform the operation you have build so far.
12007    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
12008        use std::borrow::Cow;
12009        use std::io::{Read, Seek};
12010
12011        use common::{url::Params, ToParts};
12012        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12013
12014        let mut dd = common::DefaultDelegate;
12015        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12016        dlg.begin(common::MethodInfo {
12017            id: "documentai.projects.locations.processors.setDefaultProcessorVersion",
12018            http_method: hyper::Method::POST,
12019        });
12020
12021        for &field in ["alt", "processor"].iter() {
12022            if self._additional_params.contains_key(field) {
12023                dlg.finished(false);
12024                return Err(common::Error::FieldClash(field));
12025            }
12026        }
12027
12028        let mut params = Params::with_capacity(4 + self._additional_params.len());
12029        params.push("processor", self._processor);
12030
12031        params.extend(self._additional_params.iter());
12032
12033        params.push("alt", "json");
12034        let mut url = self.hub._base_url.clone() + "v1/{+processor}:setDefaultProcessorVersion";
12035        if self._scopes.is_empty() {
12036            self._scopes
12037                .insert(Scope::CloudPlatform.as_ref().to_string());
12038        }
12039
12040        #[allow(clippy::single_element_loop)]
12041        for &(find_this, param_name) in [("{+processor}", "processor")].iter() {
12042            url = params.uri_replacement(url, param_name, find_this, true);
12043        }
12044        {
12045            let to_remove = ["processor"];
12046            params.remove_params(&to_remove);
12047        }
12048
12049        let url = params.parse_with_url(&url);
12050
12051        let mut json_mime_type = mime::APPLICATION_JSON;
12052        let mut request_value_reader = {
12053            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12054            common::remove_json_null_values(&mut value);
12055            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12056            serde_json::to_writer(&mut dst, &value).unwrap();
12057            dst
12058        };
12059        let request_size = request_value_reader
12060            .seek(std::io::SeekFrom::End(0))
12061            .unwrap();
12062        request_value_reader
12063            .seek(std::io::SeekFrom::Start(0))
12064            .unwrap();
12065
12066        loop {
12067            let token = match self
12068                .hub
12069                .auth
12070                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12071                .await
12072            {
12073                Ok(token) => token,
12074                Err(e) => match dlg.token(e) {
12075                    Ok(token) => token,
12076                    Err(e) => {
12077                        dlg.finished(false);
12078                        return Err(common::Error::MissingToken(e));
12079                    }
12080                },
12081            };
12082            request_value_reader
12083                .seek(std::io::SeekFrom::Start(0))
12084                .unwrap();
12085            let mut req_result = {
12086                let client = &self.hub.client;
12087                dlg.pre_request();
12088                let mut req_builder = hyper::Request::builder()
12089                    .method(hyper::Method::POST)
12090                    .uri(url.as_str())
12091                    .header(USER_AGENT, self.hub._user_agent.clone());
12092
12093                if let Some(token) = token.as_ref() {
12094                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12095                }
12096
12097                let request = req_builder
12098                    .header(CONTENT_TYPE, json_mime_type.to_string())
12099                    .header(CONTENT_LENGTH, request_size as u64)
12100                    .body(common::to_body(
12101                        request_value_reader.get_ref().clone().into(),
12102                    ));
12103
12104                client.request(request.unwrap()).await
12105            };
12106
12107            match req_result {
12108                Err(err) => {
12109                    if let common::Retry::After(d) = dlg.http_error(&err) {
12110                        sleep(d).await;
12111                        continue;
12112                    }
12113                    dlg.finished(false);
12114                    return Err(common::Error::HttpError(err));
12115                }
12116                Ok(res) => {
12117                    let (mut parts, body) = res.into_parts();
12118                    let mut body = common::Body::new(body);
12119                    if !parts.status.is_success() {
12120                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12121                        let error = serde_json::from_str(&common::to_string(&bytes));
12122                        let response = common::to_response(parts, bytes.into());
12123
12124                        if let common::Retry::After(d) =
12125                            dlg.http_failure(&response, error.as_ref().ok())
12126                        {
12127                            sleep(d).await;
12128                            continue;
12129                        }
12130
12131                        dlg.finished(false);
12132
12133                        return Err(match error {
12134                            Ok(value) => common::Error::BadRequest(value),
12135                            _ => common::Error::Failure(response),
12136                        });
12137                    }
12138                    let response = {
12139                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12140                        let encoded = common::to_string(&bytes);
12141                        match serde_json::from_str(&encoded) {
12142                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12143                            Err(error) => {
12144                                dlg.response_json_decode_error(&encoded, &error);
12145                                return Err(common::Error::JsonDecodeError(
12146                                    encoded.to_string(),
12147                                    error,
12148                                ));
12149                            }
12150                        }
12151                    };
12152
12153                    dlg.finished(true);
12154                    return Ok(response);
12155                }
12156            }
12157        }
12158    }
12159
12160    ///
12161    /// Sets the *request* property to the given value.
12162    ///
12163    /// Even though the property as already been set when instantiating this call,
12164    /// we provide this method for API completeness.
12165    pub fn request(
12166        mut self,
12167        new_value: GoogleCloudDocumentaiV1SetDefaultProcessorVersionRequest,
12168    ) -> ProjectLocationProcessorSetDefaultProcessorVersionCall<'a, C> {
12169        self._request = new_value;
12170        self
12171    }
12172    /// Required. The resource name of the Processor to change default version.
12173    ///
12174    /// Sets the *processor* path property to the given value.
12175    ///
12176    /// Even though the property as already been set when instantiating this call,
12177    /// we provide this method for API completeness.
12178    pub fn processor(
12179        mut self,
12180        new_value: &str,
12181    ) -> ProjectLocationProcessorSetDefaultProcessorVersionCall<'a, C> {
12182        self._processor = new_value.to_string();
12183        self
12184    }
12185    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12186    /// while executing the actual API request.
12187    ///
12188    /// ````text
12189    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12190    /// ````
12191    ///
12192    /// Sets the *delegate* property to the given value.
12193    pub fn delegate(
12194        mut self,
12195        new_value: &'a mut dyn common::Delegate,
12196    ) -> ProjectLocationProcessorSetDefaultProcessorVersionCall<'a, C> {
12197        self._delegate = Some(new_value);
12198        self
12199    }
12200
12201    /// Set any additional parameter of the query string used in the request.
12202    /// It should be used to set parameters which are not yet available through their own
12203    /// setters.
12204    ///
12205    /// Please note that this method must not be used to set any of the known parameters
12206    /// which have their own setter method. If done anyway, the request will fail.
12207    ///
12208    /// # Additional Parameters
12209    ///
12210    /// * *$.xgafv* (query-string) - V1 error format.
12211    /// * *access_token* (query-string) - OAuth access token.
12212    /// * *alt* (query-string) - Data format for response.
12213    /// * *callback* (query-string) - JSONP
12214    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12215    /// * *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.
12216    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12217    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12218    /// * *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.
12219    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12220    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12221    pub fn param<T>(
12222        mut self,
12223        name: T,
12224        value: T,
12225    ) -> ProjectLocationProcessorSetDefaultProcessorVersionCall<'a, C>
12226    where
12227        T: AsRef<str>,
12228    {
12229        self._additional_params
12230            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12231        self
12232    }
12233
12234    /// Identifies the authorization scope for the method you are building.
12235    ///
12236    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12237    /// [`Scope::CloudPlatform`].
12238    ///
12239    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12240    /// tokens for more than one scope.
12241    ///
12242    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12243    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12244    /// sufficient, a read-write scope will do as well.
12245    pub fn add_scope<St>(
12246        mut self,
12247        scope: St,
12248    ) -> ProjectLocationProcessorSetDefaultProcessorVersionCall<'a, C>
12249    where
12250        St: AsRef<str>,
12251    {
12252        self._scopes.insert(String::from(scope.as_ref()));
12253        self
12254    }
12255    /// Identifies the authorization scope(s) for the method you are building.
12256    ///
12257    /// See [`Self::add_scope()`] for details.
12258    pub fn add_scopes<I, St>(
12259        mut self,
12260        scopes: I,
12261    ) -> ProjectLocationProcessorSetDefaultProcessorVersionCall<'a, C>
12262    where
12263        I: IntoIterator<Item = St>,
12264        St: AsRef<str>,
12265    {
12266        self._scopes
12267            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12268        self
12269    }
12270
12271    /// Removes all scopes, and no default scope will be used either.
12272    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12273    /// for details).
12274    pub fn clear_scopes(mut self) -> ProjectLocationProcessorSetDefaultProcessorVersionCall<'a, C> {
12275        self._scopes.clear();
12276        self
12277    }
12278}
12279
12280/// Fetches processor types. Note that we don't use ListProcessorTypes here, because it isn't paginated.
12281///
12282/// A builder for the *locations.fetchProcessorTypes* method supported by a *project* resource.
12283/// It is not used directly, but through a [`ProjectMethods`] instance.
12284///
12285/// # Example
12286///
12287/// Instantiate a resource method builder
12288///
12289/// ```test_harness,no_run
12290/// # extern crate hyper;
12291/// # extern crate hyper_rustls;
12292/// # extern crate google_documentai1 as documentai1;
12293/// # async fn dox() {
12294/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12295///
12296/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12297/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12298/// #     secret,
12299/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12300/// # ).build().await.unwrap();
12301///
12302/// # let client = hyper_util::client::legacy::Client::builder(
12303/// #     hyper_util::rt::TokioExecutor::new()
12304/// # )
12305/// # .build(
12306/// #     hyper_rustls::HttpsConnectorBuilder::new()
12307/// #         .with_native_roots()
12308/// #         .unwrap()
12309/// #         .https_or_http()
12310/// #         .enable_http1()
12311/// #         .build()
12312/// # );
12313/// # let mut hub = Document::new(client, auth);
12314/// // You can configure optional parameters by calling the respective setters at will, and
12315/// // execute the final call using `doit()`.
12316/// // Values shown here are possibly random and not representative !
12317/// let result = hub.projects().locations_fetch_processor_types("parent")
12318///              .doit().await;
12319/// # }
12320/// ```
12321pub struct ProjectLocationFetchProcessorTypeCall<'a, C>
12322where
12323    C: 'a,
12324{
12325    hub: &'a Document<C>,
12326    _parent: String,
12327    _delegate: Option<&'a mut dyn common::Delegate>,
12328    _additional_params: HashMap<String, String>,
12329    _scopes: BTreeSet<String>,
12330}
12331
12332impl<'a, C> common::CallBuilder for ProjectLocationFetchProcessorTypeCall<'a, C> {}
12333
12334impl<'a, C> ProjectLocationFetchProcessorTypeCall<'a, C>
12335where
12336    C: common::Connector,
12337{
12338    /// Perform the operation you have build so far.
12339    pub async fn doit(
12340        mut self,
12341    ) -> common::Result<(
12342        common::Response,
12343        GoogleCloudDocumentaiV1FetchProcessorTypesResponse,
12344    )> {
12345        use std::borrow::Cow;
12346        use std::io::{Read, Seek};
12347
12348        use common::{url::Params, ToParts};
12349        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12350
12351        let mut dd = common::DefaultDelegate;
12352        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12353        dlg.begin(common::MethodInfo {
12354            id: "documentai.projects.locations.fetchProcessorTypes",
12355            http_method: hyper::Method::GET,
12356        });
12357
12358        for &field in ["alt", "parent"].iter() {
12359            if self._additional_params.contains_key(field) {
12360                dlg.finished(false);
12361                return Err(common::Error::FieldClash(field));
12362            }
12363        }
12364
12365        let mut params = Params::with_capacity(3 + self._additional_params.len());
12366        params.push("parent", self._parent);
12367
12368        params.extend(self._additional_params.iter());
12369
12370        params.push("alt", "json");
12371        let mut url = self.hub._base_url.clone() + "v1/{+parent}:fetchProcessorTypes";
12372        if self._scopes.is_empty() {
12373            self._scopes
12374                .insert(Scope::CloudPlatform.as_ref().to_string());
12375        }
12376
12377        #[allow(clippy::single_element_loop)]
12378        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
12379            url = params.uri_replacement(url, param_name, find_this, true);
12380        }
12381        {
12382            let to_remove = ["parent"];
12383            params.remove_params(&to_remove);
12384        }
12385
12386        let url = params.parse_with_url(&url);
12387
12388        loop {
12389            let token = match self
12390                .hub
12391                .auth
12392                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12393                .await
12394            {
12395                Ok(token) => token,
12396                Err(e) => match dlg.token(e) {
12397                    Ok(token) => token,
12398                    Err(e) => {
12399                        dlg.finished(false);
12400                        return Err(common::Error::MissingToken(e));
12401                    }
12402                },
12403            };
12404            let mut req_result = {
12405                let client = &self.hub.client;
12406                dlg.pre_request();
12407                let mut req_builder = hyper::Request::builder()
12408                    .method(hyper::Method::GET)
12409                    .uri(url.as_str())
12410                    .header(USER_AGENT, self.hub._user_agent.clone());
12411
12412                if let Some(token) = token.as_ref() {
12413                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12414                }
12415
12416                let request = req_builder
12417                    .header(CONTENT_LENGTH, 0_u64)
12418                    .body(common::to_body::<String>(None));
12419
12420                client.request(request.unwrap()).await
12421            };
12422
12423            match req_result {
12424                Err(err) => {
12425                    if let common::Retry::After(d) = dlg.http_error(&err) {
12426                        sleep(d).await;
12427                        continue;
12428                    }
12429                    dlg.finished(false);
12430                    return Err(common::Error::HttpError(err));
12431                }
12432                Ok(res) => {
12433                    let (mut parts, body) = res.into_parts();
12434                    let mut body = common::Body::new(body);
12435                    if !parts.status.is_success() {
12436                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12437                        let error = serde_json::from_str(&common::to_string(&bytes));
12438                        let response = common::to_response(parts, bytes.into());
12439
12440                        if let common::Retry::After(d) =
12441                            dlg.http_failure(&response, error.as_ref().ok())
12442                        {
12443                            sleep(d).await;
12444                            continue;
12445                        }
12446
12447                        dlg.finished(false);
12448
12449                        return Err(match error {
12450                            Ok(value) => common::Error::BadRequest(value),
12451                            _ => common::Error::Failure(response),
12452                        });
12453                    }
12454                    let response = {
12455                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12456                        let encoded = common::to_string(&bytes);
12457                        match serde_json::from_str(&encoded) {
12458                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12459                            Err(error) => {
12460                                dlg.response_json_decode_error(&encoded, &error);
12461                                return Err(common::Error::JsonDecodeError(
12462                                    encoded.to_string(),
12463                                    error,
12464                                ));
12465                            }
12466                        }
12467                    };
12468
12469                    dlg.finished(true);
12470                    return Ok(response);
12471                }
12472            }
12473        }
12474    }
12475
12476    /// Required. The location of processor types to list. Format: `projects/{project}/locations/{location}`.
12477    ///
12478    /// Sets the *parent* path property to the given value.
12479    ///
12480    /// Even though the property as already been set when instantiating this call,
12481    /// we provide this method for API completeness.
12482    pub fn parent(mut self, new_value: &str) -> ProjectLocationFetchProcessorTypeCall<'a, C> {
12483        self._parent = new_value.to_string();
12484        self
12485    }
12486    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12487    /// while executing the actual API request.
12488    ///
12489    /// ````text
12490    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12491    /// ````
12492    ///
12493    /// Sets the *delegate* property to the given value.
12494    pub fn delegate(
12495        mut self,
12496        new_value: &'a mut dyn common::Delegate,
12497    ) -> ProjectLocationFetchProcessorTypeCall<'a, C> {
12498        self._delegate = Some(new_value);
12499        self
12500    }
12501
12502    /// Set any additional parameter of the query string used in the request.
12503    /// It should be used to set parameters which are not yet available through their own
12504    /// setters.
12505    ///
12506    /// Please note that this method must not be used to set any of the known parameters
12507    /// which have their own setter method. If done anyway, the request will fail.
12508    ///
12509    /// # Additional Parameters
12510    ///
12511    /// * *$.xgafv* (query-string) - V1 error format.
12512    /// * *access_token* (query-string) - OAuth access token.
12513    /// * *alt* (query-string) - Data format for response.
12514    /// * *callback* (query-string) - JSONP
12515    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12516    /// * *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.
12517    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12518    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12519    /// * *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.
12520    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12521    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12522    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationFetchProcessorTypeCall<'a, C>
12523    where
12524        T: AsRef<str>,
12525    {
12526        self._additional_params
12527            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12528        self
12529    }
12530
12531    /// Identifies the authorization scope for the method you are building.
12532    ///
12533    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12534    /// [`Scope::CloudPlatform`].
12535    ///
12536    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12537    /// tokens for more than one scope.
12538    ///
12539    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12540    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12541    /// sufficient, a read-write scope will do as well.
12542    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationFetchProcessorTypeCall<'a, C>
12543    where
12544        St: AsRef<str>,
12545    {
12546        self._scopes.insert(String::from(scope.as_ref()));
12547        self
12548    }
12549    /// Identifies the authorization scope(s) for the method you are building.
12550    ///
12551    /// See [`Self::add_scope()`] for details.
12552    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationFetchProcessorTypeCall<'a, C>
12553    where
12554        I: IntoIterator<Item = St>,
12555        St: AsRef<str>,
12556    {
12557        self._scopes
12558            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12559        self
12560    }
12561
12562    /// Removes all scopes, and no default scope will be used either.
12563    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12564    /// for details).
12565    pub fn clear_scopes(mut self) -> ProjectLocationFetchProcessorTypeCall<'a, C> {
12566        self._scopes.clear();
12567        self
12568    }
12569}
12570
12571/// Gets information about a location.
12572///
12573/// A builder for the *locations.get* method supported by a *project* resource.
12574/// It is not used directly, but through a [`ProjectMethods`] instance.
12575///
12576/// # Example
12577///
12578/// Instantiate a resource method builder
12579///
12580/// ```test_harness,no_run
12581/// # extern crate hyper;
12582/// # extern crate hyper_rustls;
12583/// # extern crate google_documentai1 as documentai1;
12584/// # async fn dox() {
12585/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12586///
12587/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12588/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12589/// #     secret,
12590/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12591/// # ).build().await.unwrap();
12592///
12593/// # let client = hyper_util::client::legacy::Client::builder(
12594/// #     hyper_util::rt::TokioExecutor::new()
12595/// # )
12596/// # .build(
12597/// #     hyper_rustls::HttpsConnectorBuilder::new()
12598/// #         .with_native_roots()
12599/// #         .unwrap()
12600/// #         .https_or_http()
12601/// #         .enable_http1()
12602/// #         .build()
12603/// # );
12604/// # let mut hub = Document::new(client, auth);
12605/// // You can configure optional parameters by calling the respective setters at will, and
12606/// // execute the final call using `doit()`.
12607/// // Values shown here are possibly random and not representative !
12608/// let result = hub.projects().locations_get("name")
12609///              .doit().await;
12610/// # }
12611/// ```
12612pub struct ProjectLocationGetCall<'a, C>
12613where
12614    C: 'a,
12615{
12616    hub: &'a Document<C>,
12617    _name: String,
12618    _delegate: Option<&'a mut dyn common::Delegate>,
12619    _additional_params: HashMap<String, String>,
12620    _scopes: BTreeSet<String>,
12621}
12622
12623impl<'a, C> common::CallBuilder for ProjectLocationGetCall<'a, C> {}
12624
12625impl<'a, C> ProjectLocationGetCall<'a, C>
12626where
12627    C: common::Connector,
12628{
12629    /// Perform the operation you have build so far.
12630    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleCloudLocationLocation)> {
12631        use std::borrow::Cow;
12632        use std::io::{Read, Seek};
12633
12634        use common::{url::Params, ToParts};
12635        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12636
12637        let mut dd = common::DefaultDelegate;
12638        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12639        dlg.begin(common::MethodInfo {
12640            id: "documentai.projects.locations.get",
12641            http_method: hyper::Method::GET,
12642        });
12643
12644        for &field in ["alt", "name"].iter() {
12645            if self._additional_params.contains_key(field) {
12646                dlg.finished(false);
12647                return Err(common::Error::FieldClash(field));
12648            }
12649        }
12650
12651        let mut params = Params::with_capacity(3 + self._additional_params.len());
12652        params.push("name", self._name);
12653
12654        params.extend(self._additional_params.iter());
12655
12656        params.push("alt", "json");
12657        let mut url = self.hub._base_url.clone() + "v1/{+name}";
12658        if self._scopes.is_empty() {
12659            self._scopes
12660                .insert(Scope::CloudPlatform.as_ref().to_string());
12661        }
12662
12663        #[allow(clippy::single_element_loop)]
12664        for &(find_this, param_name) in [("{+name}", "name")].iter() {
12665            url = params.uri_replacement(url, param_name, find_this, true);
12666        }
12667        {
12668            let to_remove = ["name"];
12669            params.remove_params(&to_remove);
12670        }
12671
12672        let url = params.parse_with_url(&url);
12673
12674        loop {
12675            let token = match self
12676                .hub
12677                .auth
12678                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12679                .await
12680            {
12681                Ok(token) => token,
12682                Err(e) => match dlg.token(e) {
12683                    Ok(token) => token,
12684                    Err(e) => {
12685                        dlg.finished(false);
12686                        return Err(common::Error::MissingToken(e));
12687                    }
12688                },
12689            };
12690            let mut req_result = {
12691                let client = &self.hub.client;
12692                dlg.pre_request();
12693                let mut req_builder = hyper::Request::builder()
12694                    .method(hyper::Method::GET)
12695                    .uri(url.as_str())
12696                    .header(USER_AGENT, self.hub._user_agent.clone());
12697
12698                if let Some(token) = token.as_ref() {
12699                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12700                }
12701
12702                let request = req_builder
12703                    .header(CONTENT_LENGTH, 0_u64)
12704                    .body(common::to_body::<String>(None));
12705
12706                client.request(request.unwrap()).await
12707            };
12708
12709            match req_result {
12710                Err(err) => {
12711                    if let common::Retry::After(d) = dlg.http_error(&err) {
12712                        sleep(d).await;
12713                        continue;
12714                    }
12715                    dlg.finished(false);
12716                    return Err(common::Error::HttpError(err));
12717                }
12718                Ok(res) => {
12719                    let (mut parts, body) = res.into_parts();
12720                    let mut body = common::Body::new(body);
12721                    if !parts.status.is_success() {
12722                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12723                        let error = serde_json::from_str(&common::to_string(&bytes));
12724                        let response = common::to_response(parts, bytes.into());
12725
12726                        if let common::Retry::After(d) =
12727                            dlg.http_failure(&response, error.as_ref().ok())
12728                        {
12729                            sleep(d).await;
12730                            continue;
12731                        }
12732
12733                        dlg.finished(false);
12734
12735                        return Err(match error {
12736                            Ok(value) => common::Error::BadRequest(value),
12737                            _ => common::Error::Failure(response),
12738                        });
12739                    }
12740                    let response = {
12741                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12742                        let encoded = common::to_string(&bytes);
12743                        match serde_json::from_str(&encoded) {
12744                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12745                            Err(error) => {
12746                                dlg.response_json_decode_error(&encoded, &error);
12747                                return Err(common::Error::JsonDecodeError(
12748                                    encoded.to_string(),
12749                                    error,
12750                                ));
12751                            }
12752                        }
12753                    };
12754
12755                    dlg.finished(true);
12756                    return Ok(response);
12757                }
12758            }
12759        }
12760    }
12761
12762    /// Resource name for the location.
12763    ///
12764    /// Sets the *name* path property to the given value.
12765    ///
12766    /// Even though the property as already been set when instantiating this call,
12767    /// we provide this method for API completeness.
12768    pub fn name(mut self, new_value: &str) -> ProjectLocationGetCall<'a, C> {
12769        self._name = new_value.to_string();
12770        self
12771    }
12772    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12773    /// while executing the actual API request.
12774    ///
12775    /// ````text
12776    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12777    /// ````
12778    ///
12779    /// Sets the *delegate* property to the given value.
12780    pub fn delegate(
12781        mut self,
12782        new_value: &'a mut dyn common::Delegate,
12783    ) -> ProjectLocationGetCall<'a, C> {
12784        self._delegate = Some(new_value);
12785        self
12786    }
12787
12788    /// Set any additional parameter of the query string used in the request.
12789    /// It should be used to set parameters which are not yet available through their own
12790    /// setters.
12791    ///
12792    /// Please note that this method must not be used to set any of the known parameters
12793    /// which have their own setter method. If done anyway, the request will fail.
12794    ///
12795    /// # Additional Parameters
12796    ///
12797    /// * *$.xgafv* (query-string) - V1 error format.
12798    /// * *access_token* (query-string) - OAuth access token.
12799    /// * *alt* (query-string) - Data format for response.
12800    /// * *callback* (query-string) - JSONP
12801    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12802    /// * *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.
12803    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12804    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12805    /// * *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.
12806    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12807    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12808    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCall<'a, C>
12809    where
12810        T: AsRef<str>,
12811    {
12812        self._additional_params
12813            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12814        self
12815    }
12816
12817    /// Identifies the authorization scope for the method you are building.
12818    ///
12819    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12820    /// [`Scope::CloudPlatform`].
12821    ///
12822    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12823    /// tokens for more than one scope.
12824    ///
12825    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12826    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12827    /// sufficient, a read-write scope will do as well.
12828    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCall<'a, C>
12829    where
12830        St: AsRef<str>,
12831    {
12832        self._scopes.insert(String::from(scope.as_ref()));
12833        self
12834    }
12835    /// Identifies the authorization scope(s) for the method you are building.
12836    ///
12837    /// See [`Self::add_scope()`] for details.
12838    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCall<'a, C>
12839    where
12840        I: IntoIterator<Item = St>,
12841        St: AsRef<str>,
12842    {
12843        self._scopes
12844            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12845        self
12846    }
12847
12848    /// Removes all scopes, and no default scope will be used either.
12849    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12850    /// for details).
12851    pub fn clear_scopes(mut self) -> ProjectLocationGetCall<'a, C> {
12852        self._scopes.clear();
12853        self
12854    }
12855}
12856
12857/// Lists information about the supported locations for this service.
12858///
12859/// A builder for the *locations.list* method supported by a *project* resource.
12860/// It is not used directly, but through a [`ProjectMethods`] instance.
12861///
12862/// # Example
12863///
12864/// Instantiate a resource method builder
12865///
12866/// ```test_harness,no_run
12867/// # extern crate hyper;
12868/// # extern crate hyper_rustls;
12869/// # extern crate google_documentai1 as documentai1;
12870/// # async fn dox() {
12871/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12872///
12873/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12874/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12875/// #     secret,
12876/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12877/// # ).build().await.unwrap();
12878///
12879/// # let client = hyper_util::client::legacy::Client::builder(
12880/// #     hyper_util::rt::TokioExecutor::new()
12881/// # )
12882/// # .build(
12883/// #     hyper_rustls::HttpsConnectorBuilder::new()
12884/// #         .with_native_roots()
12885/// #         .unwrap()
12886/// #         .https_or_http()
12887/// #         .enable_http1()
12888/// #         .build()
12889/// # );
12890/// # let mut hub = Document::new(client, auth);
12891/// // You can configure optional parameters by calling the respective setters at will, and
12892/// // execute the final call using `doit()`.
12893/// // Values shown here are possibly random and not representative !
12894/// let result = hub.projects().locations_list("name")
12895///              .page_token("et")
12896///              .page_size(-43)
12897///              .filter("et")
12898///              .doit().await;
12899/// # }
12900/// ```
12901pub struct ProjectLocationListCall<'a, C>
12902where
12903    C: 'a,
12904{
12905    hub: &'a Document<C>,
12906    _name: String,
12907    _page_token: Option<String>,
12908    _page_size: Option<i32>,
12909    _filter: Option<String>,
12910    _delegate: Option<&'a mut dyn common::Delegate>,
12911    _additional_params: HashMap<String, String>,
12912    _scopes: BTreeSet<String>,
12913}
12914
12915impl<'a, C> common::CallBuilder for ProjectLocationListCall<'a, C> {}
12916
12917impl<'a, C> ProjectLocationListCall<'a, C>
12918where
12919    C: common::Connector,
12920{
12921    /// Perform the operation you have build so far.
12922    pub async fn doit(
12923        mut self,
12924    ) -> common::Result<(common::Response, GoogleCloudLocationListLocationsResponse)> {
12925        use std::borrow::Cow;
12926        use std::io::{Read, Seek};
12927
12928        use common::{url::Params, ToParts};
12929        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12930
12931        let mut dd = common::DefaultDelegate;
12932        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12933        dlg.begin(common::MethodInfo {
12934            id: "documentai.projects.locations.list",
12935            http_method: hyper::Method::GET,
12936        });
12937
12938        for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
12939            if self._additional_params.contains_key(field) {
12940                dlg.finished(false);
12941                return Err(common::Error::FieldClash(field));
12942            }
12943        }
12944
12945        let mut params = Params::with_capacity(6 + self._additional_params.len());
12946        params.push("name", self._name);
12947        if let Some(value) = self._page_token.as_ref() {
12948            params.push("pageToken", value);
12949        }
12950        if let Some(value) = self._page_size.as_ref() {
12951            params.push("pageSize", value.to_string());
12952        }
12953        if let Some(value) = self._filter.as_ref() {
12954            params.push("filter", value);
12955        }
12956
12957        params.extend(self._additional_params.iter());
12958
12959        params.push("alt", "json");
12960        let mut url = self.hub._base_url.clone() + "v1/{+name}/locations";
12961        if self._scopes.is_empty() {
12962            self._scopes
12963                .insert(Scope::CloudPlatform.as_ref().to_string());
12964        }
12965
12966        #[allow(clippy::single_element_loop)]
12967        for &(find_this, param_name) in [("{+name}", "name")].iter() {
12968            url = params.uri_replacement(url, param_name, find_this, true);
12969        }
12970        {
12971            let to_remove = ["name"];
12972            params.remove_params(&to_remove);
12973        }
12974
12975        let url = params.parse_with_url(&url);
12976
12977        loop {
12978            let token = match self
12979                .hub
12980                .auth
12981                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12982                .await
12983            {
12984                Ok(token) => token,
12985                Err(e) => match dlg.token(e) {
12986                    Ok(token) => token,
12987                    Err(e) => {
12988                        dlg.finished(false);
12989                        return Err(common::Error::MissingToken(e));
12990                    }
12991                },
12992            };
12993            let mut req_result = {
12994                let client = &self.hub.client;
12995                dlg.pre_request();
12996                let mut req_builder = hyper::Request::builder()
12997                    .method(hyper::Method::GET)
12998                    .uri(url.as_str())
12999                    .header(USER_AGENT, self.hub._user_agent.clone());
13000
13001                if let Some(token) = token.as_ref() {
13002                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13003                }
13004
13005                let request = req_builder
13006                    .header(CONTENT_LENGTH, 0_u64)
13007                    .body(common::to_body::<String>(None));
13008
13009                client.request(request.unwrap()).await
13010            };
13011
13012            match req_result {
13013                Err(err) => {
13014                    if let common::Retry::After(d) = dlg.http_error(&err) {
13015                        sleep(d).await;
13016                        continue;
13017                    }
13018                    dlg.finished(false);
13019                    return Err(common::Error::HttpError(err));
13020                }
13021                Ok(res) => {
13022                    let (mut parts, body) = res.into_parts();
13023                    let mut body = common::Body::new(body);
13024                    if !parts.status.is_success() {
13025                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13026                        let error = serde_json::from_str(&common::to_string(&bytes));
13027                        let response = common::to_response(parts, bytes.into());
13028
13029                        if let common::Retry::After(d) =
13030                            dlg.http_failure(&response, error.as_ref().ok())
13031                        {
13032                            sleep(d).await;
13033                            continue;
13034                        }
13035
13036                        dlg.finished(false);
13037
13038                        return Err(match error {
13039                            Ok(value) => common::Error::BadRequest(value),
13040                            _ => common::Error::Failure(response),
13041                        });
13042                    }
13043                    let response = {
13044                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13045                        let encoded = common::to_string(&bytes);
13046                        match serde_json::from_str(&encoded) {
13047                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13048                            Err(error) => {
13049                                dlg.response_json_decode_error(&encoded, &error);
13050                                return Err(common::Error::JsonDecodeError(
13051                                    encoded.to_string(),
13052                                    error,
13053                                ));
13054                            }
13055                        }
13056                    };
13057
13058                    dlg.finished(true);
13059                    return Ok(response);
13060                }
13061            }
13062        }
13063    }
13064
13065    /// The resource that owns the locations collection, if applicable.
13066    ///
13067    /// Sets the *name* path property to the given value.
13068    ///
13069    /// Even though the property as already been set when instantiating this call,
13070    /// we provide this method for API completeness.
13071    pub fn name(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
13072        self._name = new_value.to_string();
13073        self
13074    }
13075    /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
13076    ///
13077    /// Sets the *page token* query property to the given value.
13078    pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
13079        self._page_token = Some(new_value.to_string());
13080        self
13081    }
13082    /// The maximum number of results to return. If not set, the service selects a default.
13083    ///
13084    /// Sets the *page size* query property to the given value.
13085    pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C> {
13086        self._page_size = Some(new_value);
13087        self
13088    }
13089    /// A filter to narrow down results to a preferred subset. The filtering language accepts strings like `"displayName=tokyo"`, and is documented in more detail in [AIP-160](https://google.aip.dev/160).
13090    ///
13091    /// Sets the *filter* query property to the given value.
13092    pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
13093        self._filter = Some(new_value.to_string());
13094        self
13095    }
13096    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13097    /// while executing the actual API request.
13098    ///
13099    /// ````text
13100    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13101    /// ````
13102    ///
13103    /// Sets the *delegate* property to the given value.
13104    pub fn delegate(
13105        mut self,
13106        new_value: &'a mut dyn common::Delegate,
13107    ) -> ProjectLocationListCall<'a, C> {
13108        self._delegate = Some(new_value);
13109        self
13110    }
13111
13112    /// Set any additional parameter of the query string used in the request.
13113    /// It should be used to set parameters which are not yet available through their own
13114    /// setters.
13115    ///
13116    /// Please note that this method must not be used to set any of the known parameters
13117    /// which have their own setter method. If done anyway, the request will fail.
13118    ///
13119    /// # Additional Parameters
13120    ///
13121    /// * *$.xgafv* (query-string) - V1 error format.
13122    /// * *access_token* (query-string) - OAuth access token.
13123    /// * *alt* (query-string) - Data format for response.
13124    /// * *callback* (query-string) - JSONP
13125    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13126    /// * *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.
13127    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13128    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13129    /// * *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.
13130    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13131    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13132    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C>
13133    where
13134        T: AsRef<str>,
13135    {
13136        self._additional_params
13137            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13138        self
13139    }
13140
13141    /// Identifies the authorization scope for the method you are building.
13142    ///
13143    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13144    /// [`Scope::CloudPlatform`].
13145    ///
13146    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13147    /// tokens for more than one scope.
13148    ///
13149    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13150    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13151    /// sufficient, a read-write scope will do as well.
13152    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationListCall<'a, C>
13153    where
13154        St: AsRef<str>,
13155    {
13156        self._scopes.insert(String::from(scope.as_ref()));
13157        self
13158    }
13159    /// Identifies the authorization scope(s) for the method you are building.
13160    ///
13161    /// See [`Self::add_scope()`] for details.
13162    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationListCall<'a, C>
13163    where
13164        I: IntoIterator<Item = St>,
13165        St: AsRef<str>,
13166    {
13167        self._scopes
13168            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13169        self
13170    }
13171
13172    /// Removes all scopes, and no default scope will be used either.
13173    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13174    /// for details).
13175    pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, C> {
13176        self._scopes.clear();
13177        self
13178    }
13179}
13180
13181/// 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.
13182///
13183/// A builder for the *operations.get* method supported by a *project* resource.
13184/// It is not used directly, but through a [`ProjectMethods`] instance.
13185///
13186/// # Example
13187///
13188/// Instantiate a resource method builder
13189///
13190/// ```test_harness,no_run
13191/// # extern crate hyper;
13192/// # extern crate hyper_rustls;
13193/// # extern crate google_documentai1 as documentai1;
13194/// # async fn dox() {
13195/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13196///
13197/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13198/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13199/// #     secret,
13200/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13201/// # ).build().await.unwrap();
13202///
13203/// # let client = hyper_util::client::legacy::Client::builder(
13204/// #     hyper_util::rt::TokioExecutor::new()
13205/// # )
13206/// # .build(
13207/// #     hyper_rustls::HttpsConnectorBuilder::new()
13208/// #         .with_native_roots()
13209/// #         .unwrap()
13210/// #         .https_or_http()
13211/// #         .enable_http1()
13212/// #         .build()
13213/// # );
13214/// # let mut hub = Document::new(client, auth);
13215/// // You can configure optional parameters by calling the respective setters at will, and
13216/// // execute the final call using `doit()`.
13217/// // Values shown here are possibly random and not representative !
13218/// let result = hub.projects().operations_get("name")
13219///              .doit().await;
13220/// # }
13221/// ```
13222pub struct ProjectOperationGetCall<'a, C>
13223where
13224    C: 'a,
13225{
13226    hub: &'a Document<C>,
13227    _name: String,
13228    _delegate: Option<&'a mut dyn common::Delegate>,
13229    _additional_params: HashMap<String, String>,
13230    _scopes: BTreeSet<String>,
13231}
13232
13233impl<'a, C> common::CallBuilder for ProjectOperationGetCall<'a, C> {}
13234
13235impl<'a, C> ProjectOperationGetCall<'a, C>
13236where
13237    C: common::Connector,
13238{
13239    /// Perform the operation you have build so far.
13240    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
13241        use std::borrow::Cow;
13242        use std::io::{Read, Seek};
13243
13244        use common::{url::Params, ToParts};
13245        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13246
13247        let mut dd = common::DefaultDelegate;
13248        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13249        dlg.begin(common::MethodInfo {
13250            id: "documentai.projects.operations.get",
13251            http_method: hyper::Method::GET,
13252        });
13253
13254        for &field in ["alt", "name"].iter() {
13255            if self._additional_params.contains_key(field) {
13256                dlg.finished(false);
13257                return Err(common::Error::FieldClash(field));
13258            }
13259        }
13260
13261        let mut params = Params::with_capacity(3 + self._additional_params.len());
13262        params.push("name", self._name);
13263
13264        params.extend(self._additional_params.iter());
13265
13266        params.push("alt", "json");
13267        let mut url = self.hub._base_url.clone() + "v1/{+name}";
13268        if self._scopes.is_empty() {
13269            self._scopes
13270                .insert(Scope::CloudPlatform.as_ref().to_string());
13271        }
13272
13273        #[allow(clippy::single_element_loop)]
13274        for &(find_this, param_name) in [("{+name}", "name")].iter() {
13275            url = params.uri_replacement(url, param_name, find_this, true);
13276        }
13277        {
13278            let to_remove = ["name"];
13279            params.remove_params(&to_remove);
13280        }
13281
13282        let url = params.parse_with_url(&url);
13283
13284        loop {
13285            let token = match self
13286                .hub
13287                .auth
13288                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13289                .await
13290            {
13291                Ok(token) => token,
13292                Err(e) => match dlg.token(e) {
13293                    Ok(token) => token,
13294                    Err(e) => {
13295                        dlg.finished(false);
13296                        return Err(common::Error::MissingToken(e));
13297                    }
13298                },
13299            };
13300            let mut req_result = {
13301                let client = &self.hub.client;
13302                dlg.pre_request();
13303                let mut req_builder = hyper::Request::builder()
13304                    .method(hyper::Method::GET)
13305                    .uri(url.as_str())
13306                    .header(USER_AGENT, self.hub._user_agent.clone());
13307
13308                if let Some(token) = token.as_ref() {
13309                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13310                }
13311
13312                let request = req_builder
13313                    .header(CONTENT_LENGTH, 0_u64)
13314                    .body(common::to_body::<String>(None));
13315
13316                client.request(request.unwrap()).await
13317            };
13318
13319            match req_result {
13320                Err(err) => {
13321                    if let common::Retry::After(d) = dlg.http_error(&err) {
13322                        sleep(d).await;
13323                        continue;
13324                    }
13325                    dlg.finished(false);
13326                    return Err(common::Error::HttpError(err));
13327                }
13328                Ok(res) => {
13329                    let (mut parts, body) = res.into_parts();
13330                    let mut body = common::Body::new(body);
13331                    if !parts.status.is_success() {
13332                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13333                        let error = serde_json::from_str(&common::to_string(&bytes));
13334                        let response = common::to_response(parts, bytes.into());
13335
13336                        if let common::Retry::After(d) =
13337                            dlg.http_failure(&response, error.as_ref().ok())
13338                        {
13339                            sleep(d).await;
13340                            continue;
13341                        }
13342
13343                        dlg.finished(false);
13344
13345                        return Err(match error {
13346                            Ok(value) => common::Error::BadRequest(value),
13347                            _ => common::Error::Failure(response),
13348                        });
13349                    }
13350                    let response = {
13351                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13352                        let encoded = common::to_string(&bytes);
13353                        match serde_json::from_str(&encoded) {
13354                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13355                            Err(error) => {
13356                                dlg.response_json_decode_error(&encoded, &error);
13357                                return Err(common::Error::JsonDecodeError(
13358                                    encoded.to_string(),
13359                                    error,
13360                                ));
13361                            }
13362                        }
13363                    };
13364
13365                    dlg.finished(true);
13366                    return Ok(response);
13367                }
13368            }
13369        }
13370    }
13371
13372    /// The name of the operation resource.
13373    ///
13374    /// Sets the *name* path property to the given value.
13375    ///
13376    /// Even though the property as already been set when instantiating this call,
13377    /// we provide this method for API completeness.
13378    pub fn name(mut self, new_value: &str) -> ProjectOperationGetCall<'a, C> {
13379        self._name = new_value.to_string();
13380        self
13381    }
13382    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13383    /// while executing the actual API request.
13384    ///
13385    /// ````text
13386    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13387    /// ````
13388    ///
13389    /// Sets the *delegate* property to the given value.
13390    pub fn delegate(
13391        mut self,
13392        new_value: &'a mut dyn common::Delegate,
13393    ) -> ProjectOperationGetCall<'a, C> {
13394        self._delegate = Some(new_value);
13395        self
13396    }
13397
13398    /// Set any additional parameter of the query string used in the request.
13399    /// It should be used to set parameters which are not yet available through their own
13400    /// setters.
13401    ///
13402    /// Please note that this method must not be used to set any of the known parameters
13403    /// which have their own setter method. If done anyway, the request will fail.
13404    ///
13405    /// # Additional Parameters
13406    ///
13407    /// * *$.xgafv* (query-string) - V1 error format.
13408    /// * *access_token* (query-string) - OAuth access token.
13409    /// * *alt* (query-string) - Data format for response.
13410    /// * *callback* (query-string) - JSONP
13411    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13412    /// * *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.
13413    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13414    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13415    /// * *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.
13416    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13417    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13418    pub fn param<T>(mut self, name: T, value: T) -> ProjectOperationGetCall<'a, C>
13419    where
13420        T: AsRef<str>,
13421    {
13422        self._additional_params
13423            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13424        self
13425    }
13426
13427    /// Identifies the authorization scope for the method you are building.
13428    ///
13429    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13430    /// [`Scope::CloudPlatform`].
13431    ///
13432    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13433    /// tokens for more than one scope.
13434    ///
13435    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13436    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13437    /// sufficient, a read-write scope will do as well.
13438    pub fn add_scope<St>(mut self, scope: St) -> ProjectOperationGetCall<'a, C>
13439    where
13440        St: AsRef<str>,
13441    {
13442        self._scopes.insert(String::from(scope.as_ref()));
13443        self
13444    }
13445    /// Identifies the authorization scope(s) for the method you are building.
13446    ///
13447    /// See [`Self::add_scope()`] for details.
13448    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOperationGetCall<'a, C>
13449    where
13450        I: IntoIterator<Item = St>,
13451        St: AsRef<str>,
13452    {
13453        self._scopes
13454            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13455        self
13456    }
13457
13458    /// Removes all scopes, and no default scope will be used either.
13459    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13460    /// for details).
13461    pub fn clear_scopes(mut self) -> ProjectOperationGetCall<'a, C> {
13462        self._scopes.clear();
13463        self
13464    }
13465}