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 connector = hyper_rustls::HttpsConnectorBuilder::new()
63/// .with_native_roots()
64/// .unwrap()
65/// .https_only()
66/// .enable_http2()
67/// .build();
68///
69/// let executor = hyper_util::rt::TokioExecutor::new();
70/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
71/// secret,
72/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
73/// yup_oauth2::client::CustomHyperClientBuilder::from(
74/// hyper_util::client::legacy::Client::builder(executor).build(connector),
75/// ),
76/// ).build().await.unwrap();
77///
78/// let client = hyper_util::client::legacy::Client::builder(
79/// hyper_util::rt::TokioExecutor::new()
80/// )
81/// .build(
82/// hyper_rustls::HttpsConnectorBuilder::new()
83/// .with_native_roots()
84/// .unwrap()
85/// .https_or_http()
86/// .enable_http2()
87/// .build()
88/// );
89/// let mut hub = Document::new(client, auth);
90/// // As the method needs a request, you would usually fill it with the desired information
91/// // into the respective structure. Some of the parts shown here might not be applicable !
92/// // Values shown here are possibly random and not representative !
93/// let mut req = GoogleCloudDocumentaiV1ReviewDocumentRequest::default();
94///
95/// // You can configure optional parameters by calling the respective setters at will, and
96/// // execute the final call using `doit()`.
97/// // Values shown here are possibly random and not representative !
98/// let result = hub.projects().locations_processors_human_review_config_review_document(req, "humanReviewConfig")
99/// .doit().await;
100///
101/// match result {
102/// Err(e) => match e {
103/// // The Error enum provides details about what exactly happened.
104/// // You can also just use its `Debug`, `Display` or `Error` traits
105/// Error::HttpError(_)
106/// |Error::Io(_)
107/// |Error::MissingAPIKey
108/// |Error::MissingToken(_)
109/// |Error::Cancelled
110/// |Error::UploadSizeLimitExceeded(_, _)
111/// |Error::Failure(_)
112/// |Error::BadRequest(_)
113/// |Error::FieldClash(_)
114/// |Error::JsonDecodeError(_, _) => println!("{}", e),
115/// },
116/// Ok(res) => println!("Success: {:?}", res),
117/// }
118/// # }
119/// ```
120#[derive(Clone)]
121pub struct Document<C> {
122 pub client: common::Client<C>,
123 pub auth: Box<dyn common::GetToken>,
124 _user_agent: String,
125 _base_url: String,
126 _root_url: String,
127}
128
129impl<C> common::Hub for Document<C> {}
130
131impl<'a, C> Document<C> {
132 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Document<C> {
133 Document {
134 client,
135 auth: Box::new(auth),
136 _user_agent: "google-api-rust-client/7.0.0".to_string(),
137 _base_url: "https://documentai.googleapis.com/".to_string(),
138 _root_url: "https://documentai.googleapis.com/".to_string(),
139 }
140 }
141
142 pub fn operations(&'a self) -> OperationMethods<'a, C> {
143 OperationMethods { hub: self }
144 }
145 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
146 ProjectMethods { hub: self }
147 }
148
149 /// Set the user-agent header field to use in all requests to the server.
150 /// It defaults to `google-api-rust-client/7.0.0`.
151 ///
152 /// Returns the previously set user-agent.
153 pub fn user_agent(&mut self, agent_name: String) -> String {
154 std::mem::replace(&mut self._user_agent, agent_name)
155 }
156
157 /// Set the base url to use in all requests to the server.
158 /// It defaults to `https://documentai.googleapis.com/`.
159 ///
160 /// Returns the previously set base url.
161 pub fn base_url(&mut self, new_base_url: String) -> String {
162 std::mem::replace(&mut self._base_url, new_base_url)
163 }
164
165 /// Set the root url to use in all requests to the server.
166 /// It defaults to `https://documentai.googleapis.com/`.
167 ///
168 /// Returns the previously set root url.
169 pub fn root_url(&mut self, new_root_url: String) -> String {
170 std::mem::replace(&mut self._root_url, new_root_url)
171 }
172}
173
174// ############
175// SCHEMAS ###
176// ##########
177/// Encodes the detailed information of a barcode.
178///
179/// This type is not used in any activity, and only used as *part* of another schema.
180///
181#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
182#[serde_with::serde_as]
183#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
184pub struct GoogleCloudDocumentaiV1Barcode {
185 /// 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.
186 pub format: Option<String>,
187 /// Raw value encoded in the barcode. For example: `'MEBKM:TITLE:Google;URL:https://www.google.com;;'`.
188 #[serde(rename = "rawValue")]
189 pub raw_value: Option<String>,
190 /// 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.
191 #[serde(rename = "valueFormat")]
192 pub value_format: Option<String>,
193}
194
195impl common::Part for GoogleCloudDocumentaiV1Barcode {}
196
197/// The common config to specify a set of documents used as input.
198///
199/// This type is not used in any activity, and only used as *part* of another schema.
200///
201#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
202#[serde_with::serde_as]
203#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
204pub struct GoogleCloudDocumentaiV1BatchDocumentsInputConfig {
205 /// The set of documents individually specified on Cloud Storage.
206 #[serde(rename = "gcsDocuments")]
207 pub gcs_documents: Option<GoogleCloudDocumentaiV1GcsDocuments>,
208 /// The set of documents that match the specified Cloud Storage `gcs_prefix`.
209 #[serde(rename = "gcsPrefix")]
210 pub gcs_prefix: Option<GoogleCloudDocumentaiV1GcsPrefix>,
211}
212
213impl common::Part for GoogleCloudDocumentaiV1BatchDocumentsInputConfig {}
214
215/// Request message for BatchProcessDocuments.
216///
217/// # Activities
218///
219/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
220/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
221///
222/// * [locations processors processor versions batch process projects](ProjectLocationProcessorProcessorVersionBatchProcesCall) (request)
223/// * [locations processors batch process projects](ProjectLocationProcessorBatchProcesCall) (request)
224#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
225#[serde_with::serde_as]
226#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
227pub struct GoogleCloudDocumentaiV1BatchProcessRequest {
228 /// The output configuration for the BatchProcessDocuments method.
229 #[serde(rename = "documentOutputConfig")]
230 pub document_output_config: Option<GoogleCloudDocumentaiV1DocumentOutputConfig>,
231 /// The input documents for the BatchProcessDocuments method.
232 #[serde(rename = "inputDocuments")]
233 pub input_documents: Option<GoogleCloudDocumentaiV1BatchDocumentsInputConfig>,
234 /// 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.
235 pub labels: Option<HashMap<String, String>>,
236 /// Inference-time options for the process API
237 #[serde(rename = "processOptions")]
238 pub process_options: Option<GoogleCloudDocumentaiV1ProcessOptions>,
239 /// Whether human review should be skipped for this request. Default to `false`.
240 #[serde(rename = "skipHumanReview")]
241 pub skip_human_review: Option<bool>,
242}
243
244impl common::RequestValue for GoogleCloudDocumentaiV1BatchProcessRequest {}
245
246/// A bounding polygon for the detected image annotation.
247///
248/// This type is not used in any activity, and only used as *part* of another schema.
249///
250#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
251#[serde_with::serde_as]
252#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
253pub struct GoogleCloudDocumentaiV1BoundingPoly {
254 /// The bounding polygon normalized vertices.
255 #[serde(rename = "normalizedVertices")]
256 pub normalized_vertices: Option<Vec<GoogleCloudDocumentaiV1NormalizedVertex>>,
257 /// The bounding polygon vertices.
258 pub vertices: Option<Vec<GoogleCloudDocumentaiV1Vertex>>,
259}
260
261impl common::Part for GoogleCloudDocumentaiV1BoundingPoly {}
262
263/// Request message for the DeployProcessorVersion method.
264///
265/// # Activities
266///
267/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
268/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
269///
270/// * [locations processors processor versions deploy projects](ProjectLocationProcessorProcessorVersionDeployCall) (request)
271#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
272#[serde_with::serde_as]
273#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
274pub struct GoogleCloudDocumentaiV1DeployProcessorVersionRequest {
275 _never_set: Option<bool>,
276}
277
278impl common::RequestValue for GoogleCloudDocumentaiV1DeployProcessorVersionRequest {}
279
280/// Request message for the DisableProcessor method.
281///
282/// # Activities
283///
284/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
285/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
286///
287/// * [locations processors disable projects](ProjectLocationProcessorDisableCall) (request)
288#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
289#[serde_with::serde_as]
290#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
291pub struct GoogleCloudDocumentaiV1DisableProcessorRequest {
292 _never_set: Option<bool>,
293}
294
295impl common::RequestValue for GoogleCloudDocumentaiV1DisableProcessorRequest {}
296
297/// 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.
298///
299/// This type is not used in any activity, and only used as *part* of another schema.
300///
301#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
302#[serde_with::serde_as]
303#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
304pub struct GoogleCloudDocumentaiV1Document {
305 /// Document chunked based on chunking config.
306 #[serde(rename = "chunkedDocument")]
307 pub chunked_document: Option<GoogleCloudDocumentaiV1DocumentChunkedDocument>,
308 /// 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.
309 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
310 pub content: Option<Vec<u8>>,
311 /// Optional. An internal identifier for document. Should be loggable (no PII).
312 pub docid: Option<String>,
313 /// Parsed layout of the document.
314 #[serde(rename = "documentLayout")]
315 pub document_layout: Option<GoogleCloudDocumentaiV1DocumentDocumentLayout>,
316 /// A list of entities detected on Document.text. For document shards, entities in this list may cross shard boundaries.
317 pub entities: Option<Vec<GoogleCloudDocumentaiV1DocumentEntity>>,
318 /// The entity revision id that `document.entities` field is based on. If this field is set and `entities_revisions` is not empty, the entities in `document.entities` field are the entities in the entity revision with this id and `document.entity_validation_output` field is the `entity_validation_output` field in this entity revision.
319 #[serde(rename = "entitiesRevisionId")]
320 pub entities_revision_id: Option<String>,
321 /// A list of entity revisions. The entity revisions are appended to the document in the processing order. This field can be used for comparing the entity extraction results at different stages of the processing.
322 #[serde(rename = "entitiesRevisions")]
323 pub entities_revisions: Option<Vec<GoogleCloudDocumentaiV1DocumentEntitiesRevision>>,
324 /// Placeholder. Relationship among Document.entities.
325 #[serde(rename = "entityRelations")]
326 pub entity_relations: Option<Vec<GoogleCloudDocumentaiV1DocumentEntityRelation>>,
327 /// The entity validation output for the document. This is the validation output for `document.entities` field.
328 #[serde(rename = "entityValidationOutput")]
329 pub entity_validation_output: Option<GoogleCloudDocumentaiV1DocumentEntityValidationOutput>,
330 /// Any error that occurred while processing this document.
331 pub error: Option<GoogleRpcStatus>,
332 /// An IANA published [media type (MIME type)](https://www.iana.org/assignments/media-types/media-types.xhtml).
333 #[serde(rename = "mimeType")]
334 pub mime_type: Option<String>,
335 /// Visual page layout for the Document.
336 pub pages: Option<Vec<GoogleCloudDocumentaiV1DocumentPage>>,
337 /// Placeholder. Revision history of this document.
338 pub revisions: Option<Vec<GoogleCloudDocumentaiV1DocumentRevision>>,
339 /// 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.
340 #[serde(rename = "shardInfo")]
341 pub shard_info: Option<GoogleCloudDocumentaiV1DocumentShardInfo>,
342 /// Optional. UTF-8 encoded text in reading order from the document.
343 pub text: Option<String>,
344 /// 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.
345 #[serde(rename = "textChanges")]
346 pub text_changes: Option<Vec<GoogleCloudDocumentaiV1DocumentTextChange>>,
347 /// Styles for the Document.text.
348 #[serde(rename = "textStyles")]
349 pub text_styles: Option<Vec<GoogleCloudDocumentaiV1DocumentStyle>>,
350 /// 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).
351 pub uri: Option<String>,
352}
353
354impl common::Part for GoogleCloudDocumentaiV1Document {}
355
356/// Represents the chunks that the document is divided into.
357///
358/// This type is not used in any activity, and only used as *part* of another schema.
359///
360#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
361#[serde_with::serde_as]
362#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
363pub struct GoogleCloudDocumentaiV1DocumentChunkedDocument {
364 /// List of chunks.
365 pub chunks: Option<Vec<GoogleCloudDocumentaiV1DocumentChunkedDocumentChunk>>,
366}
367
368impl common::Part for GoogleCloudDocumentaiV1DocumentChunkedDocument {}
369
370/// Represents a chunk.
371///
372/// This type is not used in any activity, and only used as *part* of another schema.
373///
374#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
375#[serde_with::serde_as]
376#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
377pub struct GoogleCloudDocumentaiV1DocumentChunkedDocumentChunk {
378 /// ID of the chunk.
379 #[serde(rename = "chunkId")]
380 pub chunk_id: Option<String>,
381 /// Text content of the chunk.
382 pub content: Option<String>,
383 /// Page footers associated with the chunk.
384 #[serde(rename = "pageFooters")]
385 pub page_footers:
386 Option<Vec<GoogleCloudDocumentaiV1DocumentChunkedDocumentChunkChunkPageFooter>>,
387 /// Page headers associated with the chunk.
388 #[serde(rename = "pageHeaders")]
389 pub page_headers:
390 Option<Vec<GoogleCloudDocumentaiV1DocumentChunkedDocumentChunkChunkPageHeader>>,
391 /// Page span of the chunk.
392 #[serde(rename = "pageSpan")]
393 pub page_span: Option<GoogleCloudDocumentaiV1DocumentChunkedDocumentChunkChunkPageSpan>,
394 /// Unused.
395 #[serde(rename = "sourceBlockIds")]
396 pub source_block_ids: Option<Vec<String>>,
397}
398
399impl common::Part for GoogleCloudDocumentaiV1DocumentChunkedDocumentChunk {}
400
401/// Represents the page footer associated with the chunk.
402///
403/// This type is not used in any activity, and only used as *part* of another schema.
404///
405#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
406#[serde_with::serde_as]
407#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
408pub struct GoogleCloudDocumentaiV1DocumentChunkedDocumentChunkChunkPageFooter {
409 /// Page span of the footer.
410 #[serde(rename = "pageSpan")]
411 pub page_span: Option<GoogleCloudDocumentaiV1DocumentChunkedDocumentChunkChunkPageSpan>,
412 /// Footer in text format.
413 pub text: Option<String>,
414}
415
416impl common::Part for GoogleCloudDocumentaiV1DocumentChunkedDocumentChunkChunkPageFooter {}
417
418/// Represents the page header associated with the chunk.
419///
420/// This type is not used in any activity, and only used as *part* of another schema.
421///
422#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
423#[serde_with::serde_as]
424#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
425pub struct GoogleCloudDocumentaiV1DocumentChunkedDocumentChunkChunkPageHeader {
426 /// Page span of the header.
427 #[serde(rename = "pageSpan")]
428 pub page_span: Option<GoogleCloudDocumentaiV1DocumentChunkedDocumentChunkChunkPageSpan>,
429 /// Header in text format.
430 pub text: Option<String>,
431}
432
433impl common::Part for GoogleCloudDocumentaiV1DocumentChunkedDocumentChunkChunkPageHeader {}
434
435/// Represents where the chunk starts and ends in the document.
436///
437/// This type is not used in any activity, and only used as *part* of another schema.
438///
439#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
440#[serde_with::serde_as]
441#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
442pub struct GoogleCloudDocumentaiV1DocumentChunkedDocumentChunkChunkPageSpan {
443 /// Page where chunk ends in the document.
444 #[serde(rename = "pageEnd")]
445 pub page_end: Option<i32>,
446 /// Page where chunk starts in the document.
447 #[serde(rename = "pageStart")]
448 pub page_start: Option<i32>,
449}
450
451impl common::Part for GoogleCloudDocumentaiV1DocumentChunkedDocumentChunkChunkPageSpan {}
452
453/// Represents the parsed layout of a document as a collection of blocks that the document is divided into.
454///
455/// This type is not used in any activity, and only used as *part* of another schema.
456///
457#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
458#[serde_with::serde_as]
459#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
460pub struct GoogleCloudDocumentaiV1DocumentDocumentLayout {
461 /// List of blocks in the document.
462 pub blocks: Option<Vec<GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlock>>,
463}
464
465impl common::Part for GoogleCloudDocumentaiV1DocumentDocumentLayout {}
466
467/// Represents a block. A block could be one of the various types (text, table, list) supported.
468///
469/// This type is not used in any activity, and only used as *part* of another schema.
470///
471#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
472#[serde_with::serde_as]
473#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
474pub struct GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlock {
475 /// ID of the block.
476 #[serde(rename = "blockId")]
477 pub block_id: Option<String>,
478 /// Identifies the bounding box for the block.
479 #[serde(rename = "boundingBox")]
480 pub bounding_box: Option<GoogleCloudDocumentaiV1BoundingPoly>,
481 /// Block consisting of list content/structure.
482 #[serde(rename = "listBlock")]
483 pub list_block:
484 Option<GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutListBlock>,
485 /// Page span of the block.
486 #[serde(rename = "pageSpan")]
487 pub page_span:
488 Option<GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutPageSpan>,
489 /// Block consisting of table content/structure.
490 #[serde(rename = "tableBlock")]
491 pub table_block:
492 Option<GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutTableBlock>,
493 /// Block consisting of text content.
494 #[serde(rename = "textBlock")]
495 pub text_block:
496 Option<GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutTextBlock>,
497}
498
499impl common::Part for GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlock {}
500
501/// Represents a list type block.
502///
503/// This type is not used in any activity, and only used as *part* of another schema.
504///
505#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
506#[serde_with::serde_as]
507#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
508pub struct GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutListBlock {
509 /// List entries that constitute a list block.
510 #[serde(rename = "listEntries")]
511 pub list_entries: Option<
512 Vec<GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutListEntry>,
513 >,
514 /// Type of the list_entries (if exist). Available options are `ordered` and `unordered`.
515 #[serde(rename = "type")]
516 pub type_: Option<String>,
517}
518
519impl common::Part
520 for GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutListBlock
521{
522}
523
524/// Represents an entry in the list.
525///
526/// This type is not used in any activity, and only used as *part* of another schema.
527///
528#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
529#[serde_with::serde_as]
530#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
531pub struct GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutListEntry {
532 /// A list entry is a list of blocks. Repeated blocks support further hierarchies and nested blocks.
533 pub blocks: Option<Vec<GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlock>>,
534}
535
536impl common::Part
537 for GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutListEntry
538{
539}
540
541/// Represents where the block starts and ends in the document.
542///
543/// This type is not used in any activity, and only used as *part* of another schema.
544///
545#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
546#[serde_with::serde_as]
547#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
548pub struct GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutPageSpan {
549 /// Page where block ends in the document.
550 #[serde(rename = "pageEnd")]
551 pub page_end: Option<i32>,
552 /// Page where block starts in the document.
553 #[serde(rename = "pageStart")]
554 pub page_start: Option<i32>,
555}
556
557impl common::Part
558 for GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutPageSpan
559{
560}
561
562/// Represents a table type block.
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 GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutTableBlock {
570 /// Body rows containing main table content.
571 #[serde(rename = "bodyRows")]
572 pub body_rows:
573 Option<Vec<GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutTableRow>>,
574 /// Table caption/title.
575 pub caption: Option<String>,
576 /// Header rows at the top of the table.
577 #[serde(rename = "headerRows")]
578 pub header_rows:
579 Option<Vec<GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutTableRow>>,
580}
581
582impl common::Part
583 for GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutTableBlock
584{
585}
586
587/// Represents a cell in a table row.
588///
589/// This type is not used in any activity, and only used as *part* of another schema.
590///
591#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
592#[serde_with::serde_as]
593#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
594pub struct GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutTableCell {
595 /// A table cell is a list of blocks. Repeated blocks support further hierarchies and nested blocks.
596 pub blocks: Option<Vec<GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlock>>,
597 /// How many columns this cell spans.
598 #[serde(rename = "colSpan")]
599 pub col_span: Option<i32>,
600 /// How many rows this cell spans.
601 #[serde(rename = "rowSpan")]
602 pub row_span: Option<i32>,
603}
604
605impl common::Part
606 for GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutTableCell
607{
608}
609
610/// Represents a row in a table.
611///
612/// This type is not used in any activity, and only used as *part* of another schema.
613///
614#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
615#[serde_with::serde_as]
616#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
617pub struct GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutTableRow {
618 /// A table row is a list of table cells.
619 pub cells: Option<
620 Vec<GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutTableCell>,
621 >,
622}
623
624impl common::Part
625 for GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutTableRow
626{
627}
628
629/// Represents a text type block.
630///
631/// This type is not used in any activity, and only used as *part* of another schema.
632///
633#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
634#[serde_with::serde_as]
635#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
636pub struct GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutTextBlock {
637 /// A text block could further have child blocks. Repeated blocks support further hierarchies and nested blocks.
638 pub blocks: Option<Vec<GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlock>>,
639 /// Text content stored in the block.
640 pub text: Option<String>,
641 /// Type of the text in the block. Available options are: `paragraph`, `subtitle`, `heading-1`, `heading-2`, `heading-3`, `heading-4`, `heading-5`, `header`, `footer`.
642 #[serde(rename = "type")]
643 pub type_: Option<String>,
644}
645
646impl common::Part
647 for GoogleCloudDocumentaiV1DocumentDocumentLayoutDocumentLayoutBlockLayoutTextBlock
648{
649}
650
651/// Entity revision.
652///
653/// This type is not used in any activity, and only used as *part* of another schema.
654///
655#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
656#[serde_with::serde_as]
657#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
658pub struct GoogleCloudDocumentaiV1DocumentEntitiesRevision {
659 /// The entities in this revision.
660 pub entities: Option<Vec<GoogleCloudDocumentaiV1DocumentEntity>>,
661 /// The entity validation output for this revision.
662 #[serde(rename = "entityValidationOutput")]
663 pub entity_validation_output: Option<GoogleCloudDocumentaiV1DocumentEntityValidationOutput>,
664 /// The revision id.
665 #[serde(rename = "revisionId")]
666 pub revision_id: Option<String>,
667}
668
669impl common::Part for GoogleCloudDocumentaiV1DocumentEntitiesRevision {}
670
671/// 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.
672///
673/// This type is not used in any activity, and only used as *part* of another schema.
674///
675#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
676#[serde_with::serde_as]
677#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
678pub struct GoogleCloudDocumentaiV1DocumentEntity {
679 /// Optional. Confidence of detected Schema entity. Range `[0, 1]`.
680 pub confidence: Option<f32>,
681 /// Optional. Canonical id. This will be a unique value in the entity list for this document.
682 pub id: Option<String>,
683 /// Optional. Deprecated. Use `id` field instead.
684 #[serde(rename = "mentionId")]
685 pub mention_id: Option<String>,
686 /// Optional. Text value of the entity e.g. `1600 Amphitheatre Pkwy`.
687 #[serde(rename = "mentionText")]
688 pub mention_text: Option<String>,
689 /// Optional. Specifies how the entity's value is obtained.
690 pub method: Option<String>,
691 /// 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.
692 #[serde(rename = "normalizedValue")]
693 pub normalized_value: Option<GoogleCloudDocumentaiV1DocumentEntityNormalizedValue>,
694 /// Optional. Represents the provenance of this entity wrt. the location on the page where it was found.
695 #[serde(rename = "pageAnchor")]
696 pub page_anchor: Option<GoogleCloudDocumentaiV1DocumentPageAnchor>,
697 /// Optional. Entities can be nested to form a hierarchical data structure representing the content in the document.
698 pub properties: Option<Vec<GoogleCloudDocumentaiV1DocumentEntity>>,
699 /// Optional. The history of this annotation.
700 pub provenance: Option<GoogleCloudDocumentaiV1DocumentProvenance>,
701 /// Optional. Whether the entity will be redacted for de-identification purposes.
702 pub redacted: Option<bool>,
703 /// Optional. Provenance of the entity. Text anchor indexing into the Document.text.
704 #[serde(rename = "textAnchor")]
705 pub text_anchor: Option<GoogleCloudDocumentaiV1DocumentTextAnchor>,
706 /// Required. Entity type from a schema e.g. `Address`.
707 #[serde(rename = "type")]
708 pub type_: Option<String>,
709}
710
711impl common::Part for GoogleCloudDocumentaiV1DocumentEntity {}
712
713/// Parsed and normalized entity value.
714///
715/// This type is not used in any activity, and only used as *part* of another schema.
716///
717#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
718#[serde_with::serde_as]
719#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
720pub struct GoogleCloudDocumentaiV1DocumentEntityNormalizedValue {
721 /// Postal address. See also: https://github.com/googleapis/googleapis/blob/master/google/type/postal_address.proto
722 #[serde(rename = "addressValue")]
723 pub address_value: Option<GoogleTypePostalAddress>,
724 /// Boolean value. Can be used for entities with binary values, or for checkboxes.
725 #[serde(rename = "booleanValue")]
726 pub boolean_value: Option<bool>,
727 /// Date value. Includes year, month, day. See also: https://github.com/googleapis/googleapis/blob/master/google/type/date.proto
728 #[serde(rename = "dateValue")]
729 pub date_value: Option<GoogleTypeDate>,
730 /// DateTime value. Includes date, time, and timezone. See also: https://github.com/googleapis/googleapis/blob/master/google/type/datetime.proto
731 #[serde(rename = "datetimeValue")]
732 pub datetime_value: Option<GoogleTypeDateTime>,
733 /// Float value.
734 #[serde(rename = "floatValue")]
735 pub float_value: Option<f32>,
736 /// Integer value.
737 #[serde(rename = "integerValue")]
738 pub integer_value: Option<i32>,
739 /// Money value. See also: https://github.com/googleapis/googleapis/blob/master/google/type/money.proto
740 #[serde(rename = "moneyValue")]
741 pub money_value: Option<GoogleTypeMoney>,
742 /// A signature - a graphical representation of a person's name, often used to sign a document.
743 #[serde(rename = "signatureValue")]
744 pub signature_value: Option<bool>,
745 /// 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.
746 pub text: Option<String>,
747}
748
749impl common::Part for GoogleCloudDocumentaiV1DocumentEntityNormalizedValue {}
750
751/// Relationship between Entities.
752///
753/// This type is not used in any activity, and only used as *part* of another schema.
754///
755#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
756#[serde_with::serde_as]
757#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
758pub struct GoogleCloudDocumentaiV1DocumentEntityRelation {
759 /// Object entity id.
760 #[serde(rename = "objectId")]
761 pub object_id: Option<String>,
762 /// Relationship description.
763 pub relation: Option<String>,
764 /// Subject entity id.
765 #[serde(rename = "subjectId")]
766 pub subject_id: Option<String>,
767}
768
769impl common::Part for GoogleCloudDocumentaiV1DocumentEntityRelation {}
770
771/// The output of the validation given the document and the validation rules.
772///
773/// This type is not used in any activity, and only used as *part* of another schema.
774///
775#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
776#[serde_with::serde_as]
777#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
778pub struct GoogleCloudDocumentaiV1DocumentEntityValidationOutput {
779 /// The overall result of the validation, true if all applicable rules are valid.
780 #[serde(rename = "passAllRules")]
781 pub pass_all_rules: Option<bool>,
782 /// The result of each validation rule.
783 #[serde(rename = "validationResults")]
784 pub validation_results:
785 Option<Vec<GoogleCloudDocumentaiV1DocumentEntityValidationOutputValidationResult>>,
786}
787
788impl common::Part for GoogleCloudDocumentaiV1DocumentEntityValidationOutput {}
789
790/// Validation result for a single validation rule.
791///
792/// This type is not used in any activity, and only used as *part* of another schema.
793///
794#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
795#[serde_with::serde_as]
796#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
797pub struct GoogleCloudDocumentaiV1DocumentEntityValidationOutputValidationResult {
798 /// Optional. The name of the rule resource that is used for validation. Format: `projects/{project}/locations/{location}/rules/{rule}`
799 pub rule: Option<String>,
800 /// The description of the validation rule.
801 #[serde(rename = "ruleDescription")]
802 pub rule_description: Option<String>,
803 /// The display name of the validation rule.
804 #[serde(rename = "ruleName")]
805 pub rule_name: Option<String>,
806 /// The detailed information of the running the validation process using the entity from the document based on the validation rule.
807 #[serde(rename = "validationDetails")]
808 pub validation_details: Option<String>,
809 /// The result of the validation rule.
810 #[serde(rename = "validationResultType")]
811 pub validation_result_type: Option<String>,
812}
813
814impl common::Part for GoogleCloudDocumentaiV1DocumentEntityValidationOutputValidationResult {}
815
816/// Config that controls the output of documents. All documents will be written as a JSON file.
817///
818/// This type is not used in any activity, and only used as *part* of another schema.
819///
820#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
821#[serde_with::serde_as]
822#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
823pub struct GoogleCloudDocumentaiV1DocumentOutputConfig {
824 /// Output config to write the results to Cloud Storage.
825 #[serde(rename = "gcsOutputConfig")]
826 pub gcs_output_config: Option<GoogleCloudDocumentaiV1DocumentOutputConfigGcsOutputConfig>,
827}
828
829impl common::Part for GoogleCloudDocumentaiV1DocumentOutputConfig {}
830
831/// The configuration used when outputting documents.
832///
833/// This type is not used in any activity, and only used as *part* of another schema.
834///
835#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
836#[serde_with::serde_as]
837#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
838pub struct GoogleCloudDocumentaiV1DocumentOutputConfigGcsOutputConfig {
839 /// 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}`.
840 #[serde(rename = "fieldMask")]
841 pub field_mask: Option<common::FieldMask>,
842 /// The Cloud Storage uri (a directory) of the output.
843 #[serde(rename = "gcsUri")]
844 pub gcs_uri: Option<String>,
845 /// Specifies the sharding config for the output document.
846 #[serde(rename = "shardingConfig")]
847 pub sharding_config:
848 Option<GoogleCloudDocumentaiV1DocumentOutputConfigGcsOutputConfigShardingConfig>,
849}
850
851impl common::Part for GoogleCloudDocumentaiV1DocumentOutputConfigGcsOutputConfig {}
852
853/// The sharding config for the output document.
854///
855/// This type is not used in any activity, and only used as *part* of another schema.
856///
857#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
858#[serde_with::serde_as]
859#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
860pub struct GoogleCloudDocumentaiV1DocumentOutputConfigGcsOutputConfigShardingConfig {
861 /// The number of overlapping pages between consecutive shards.
862 #[serde(rename = "pagesOverlap")]
863 pub pages_overlap: Option<i32>,
864 /// The number of pages per shard.
865 #[serde(rename = "pagesPerShard")]
866 pub pages_per_shard: Option<i32>,
867}
868
869impl common::Part for GoogleCloudDocumentaiV1DocumentOutputConfigGcsOutputConfigShardingConfig {}
870
871/// A page in a Document.
872///
873/// This type is not used in any activity, and only used as *part* of another schema.
874///
875#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
876#[serde_with::serde_as]
877#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
878pub struct GoogleCloudDocumentaiV1DocumentPage {
879 /// 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.
880 pub blocks: Option<Vec<GoogleCloudDocumentaiV1DocumentPageBlock>>,
881 /// A list of detected barcodes.
882 #[serde(rename = "detectedBarcodes")]
883 pub detected_barcodes: Option<Vec<GoogleCloudDocumentaiV1DocumentPageDetectedBarcode>>,
884 /// A list of detected languages together with confidence.
885 #[serde(rename = "detectedLanguages")]
886 pub detected_languages: Option<Vec<GoogleCloudDocumentaiV1DocumentPageDetectedLanguage>>,
887 /// Physical dimension of the page.
888 pub dimension: Option<GoogleCloudDocumentaiV1DocumentPageDimension>,
889 /// A list of visually detected form fields on the page.
890 #[serde(rename = "formFields")]
891 pub form_fields: Option<Vec<GoogleCloudDocumentaiV1DocumentPageFormField>>,
892 /// 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.
893 pub image: Option<GoogleCloudDocumentaiV1DocumentPageImage>,
894 /// Image quality scores.
895 #[serde(rename = "imageQualityScores")]
896 pub image_quality_scores: Option<GoogleCloudDocumentaiV1DocumentPageImageQualityScores>,
897 /// Layout for the page.
898 pub layout: Option<GoogleCloudDocumentaiV1DocumentPageLayout>,
899 /// A list of visually detected text lines on the page. A collection of tokens that a human would perceive as a line.
900 pub lines: Option<Vec<GoogleCloudDocumentaiV1DocumentPageLine>>,
901 /// 1-based index for current Page in a parent Document. Useful when a page is taken out of a Document for individual processing.
902 #[serde(rename = "pageNumber")]
903 pub page_number: Option<i32>,
904 /// A list of visually detected text paragraphs on the page. A collection of lines that a human would perceive as a paragraph.
905 pub paragraphs: Option<Vec<GoogleCloudDocumentaiV1DocumentPageParagraph>>,
906 /// The history of this page.
907 pub provenance: Option<GoogleCloudDocumentaiV1DocumentProvenance>,
908 /// A list of visually detected symbols on the page.
909 pub symbols: Option<Vec<GoogleCloudDocumentaiV1DocumentPageSymbol>>,
910 /// A list of visually detected tables on the page.
911 pub tables: Option<Vec<GoogleCloudDocumentaiV1DocumentPageTable>>,
912 /// A list of visually detected tokens on the page.
913 pub tokens: Option<Vec<GoogleCloudDocumentaiV1DocumentPageToken>>,
914 /// Transformation matrices that were applied to the original document image to produce Page.image.
915 pub transforms: Option<Vec<GoogleCloudDocumentaiV1DocumentPageMatrix>>,
916 /// A list of detected non-text visual elements e.g. checkbox, signature etc. on the page.
917 #[serde(rename = "visualElements")]
918 pub visual_elements: Option<Vec<GoogleCloudDocumentaiV1DocumentPageVisualElement>>,
919}
920
921impl common::Part for GoogleCloudDocumentaiV1DocumentPage {}
922
923/// 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.
924///
925/// This type is not used in any activity, and only used as *part* of another schema.
926///
927#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
928#[serde_with::serde_as]
929#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
930pub struct GoogleCloudDocumentaiV1DocumentPageAnchor {
931 /// One or more references to visual page elements
932 #[serde(rename = "pageRefs")]
933 pub page_refs: Option<Vec<GoogleCloudDocumentaiV1DocumentPageAnchorPageRef>>,
934}
935
936impl common::Part for GoogleCloudDocumentaiV1DocumentPageAnchor {}
937
938/// Represents a weak reference to a page element within a document.
939///
940/// This type is not used in any activity, and only used as *part* of another schema.
941///
942#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
943#[serde_with::serde_as]
944#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
945pub struct GoogleCloudDocumentaiV1DocumentPageAnchorPageRef {
946 /// 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.
947 #[serde(rename = "boundingPoly")]
948 pub bounding_poly: Option<GoogleCloudDocumentaiV1BoundingPoly>,
949 /// Optional. Confidence of detected page element, if applicable. Range `[0, 1]`.
950 pub confidence: Option<f32>,
951 /// Optional. Deprecated. Use PageRef.bounding_poly instead.
952 #[serde(rename = "layoutId")]
953 pub layout_id: Option<String>,
954 /// Optional. The type of the layout element that is being referenced if any.
955 #[serde(rename = "layoutType")]
956 pub layout_type: Option<String>,
957 /// 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.
958 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
959 pub page: Option<i64>,
960}
961
962impl common::Part for GoogleCloudDocumentaiV1DocumentPageAnchorPageRef {}
963
964/// A block has a set of lines (collected into paragraphs) that have a common line-spacing and orientation.
965///
966/// This type is not used in any activity, and only used as *part* of another schema.
967///
968#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
969#[serde_with::serde_as]
970#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
971pub struct GoogleCloudDocumentaiV1DocumentPageBlock {
972 /// A list of detected languages together with confidence.
973 #[serde(rename = "detectedLanguages")]
974 pub detected_languages: Option<Vec<GoogleCloudDocumentaiV1DocumentPageDetectedLanguage>>,
975 /// Layout for Block.
976 pub layout: Option<GoogleCloudDocumentaiV1DocumentPageLayout>,
977 /// The history of this annotation.
978 pub provenance: Option<GoogleCloudDocumentaiV1DocumentProvenance>,
979}
980
981impl common::Part for GoogleCloudDocumentaiV1DocumentPageBlock {}
982
983/// A detected barcode.
984///
985/// This type is not used in any activity, and only used as *part* of another schema.
986///
987#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
988#[serde_with::serde_as]
989#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
990pub struct GoogleCloudDocumentaiV1DocumentPageDetectedBarcode {
991 /// Detailed barcode information of the DetectedBarcode.
992 pub barcode: Option<GoogleCloudDocumentaiV1Barcode>,
993 /// Layout for DetectedBarcode.
994 pub layout: Option<GoogleCloudDocumentaiV1DocumentPageLayout>,
995}
996
997impl common::Part for GoogleCloudDocumentaiV1DocumentPageDetectedBarcode {}
998
999/// Detected language for a structural component.
1000///
1001/// This type is not used in any activity, and only used as *part* of another schema.
1002///
1003#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1004#[serde_with::serde_as]
1005#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1006pub struct GoogleCloudDocumentaiV1DocumentPageDetectedLanguage {
1007 /// Confidence of detected language. Range `[0, 1]`.
1008 pub confidence: Option<f32>,
1009 /// The [BCP-47 language code](https://www.unicode.org/reports/tr35/#Unicode_locale_identifier), such as `en-US` or `sr-Latn`.
1010 #[serde(rename = "languageCode")]
1011 pub language_code: Option<String>,
1012}
1013
1014impl common::Part for GoogleCloudDocumentaiV1DocumentPageDetectedLanguage {}
1015
1016/// Dimension for the page.
1017///
1018/// This type is not used in any activity, and only used as *part* of another schema.
1019///
1020#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1021#[serde_with::serde_as]
1022#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1023pub struct GoogleCloudDocumentaiV1DocumentPageDimension {
1024 /// Page height.
1025 pub height: Option<f32>,
1026 /// Dimension unit.
1027 pub unit: Option<String>,
1028 /// Page width.
1029 pub width: Option<f32>,
1030}
1031
1032impl common::Part for GoogleCloudDocumentaiV1DocumentPageDimension {}
1033
1034/// A form field detected on the page.
1035///
1036/// This type is not used in any activity, and only used as *part* of another schema.
1037///
1038#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1039#[serde_with::serde_as]
1040#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1041pub struct GoogleCloudDocumentaiV1DocumentPageFormField {
1042 /// 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.
1043 #[serde(rename = "correctedKeyText")]
1044 pub corrected_key_text: Option<String>,
1045 /// 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.
1046 #[serde(rename = "correctedValueText")]
1047 pub corrected_value_text: Option<String>,
1048 /// Layout for the FormField name. e.g. `Address`, `Email`, `Grand total`, `Phone number`, etc.
1049 #[serde(rename = "fieldName")]
1050 pub field_name: Option<GoogleCloudDocumentaiV1DocumentPageLayout>,
1051 /// Layout for the FormField value.
1052 #[serde(rename = "fieldValue")]
1053 pub field_value: Option<GoogleCloudDocumentaiV1DocumentPageLayout>,
1054 /// A list of detected languages for name together with confidence.
1055 #[serde(rename = "nameDetectedLanguages")]
1056 pub name_detected_languages: Option<Vec<GoogleCloudDocumentaiV1DocumentPageDetectedLanguage>>,
1057 /// The history of this annotation.
1058 pub provenance: Option<GoogleCloudDocumentaiV1DocumentProvenance>,
1059 /// A list of detected languages for value together with confidence.
1060 #[serde(rename = "valueDetectedLanguages")]
1061 pub value_detected_languages: Option<Vec<GoogleCloudDocumentaiV1DocumentPageDetectedLanguage>>,
1062 /// 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`
1063 #[serde(rename = "valueType")]
1064 pub value_type: Option<String>,
1065}
1066
1067impl common::Part for GoogleCloudDocumentaiV1DocumentPageFormField {}
1068
1069/// Rendered image contents for this page.
1070///
1071/// This type is not used in any activity, and only used as *part* of another schema.
1072///
1073#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1074#[serde_with::serde_as]
1075#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1076pub struct GoogleCloudDocumentaiV1DocumentPageImage {
1077 /// Raw byte content of the image.
1078 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1079 pub content: Option<Vec<u8>>,
1080 /// Height of the image in pixels.
1081 pub height: Option<i32>,
1082 /// Encoding [media type (MIME type)](https://www.iana.org/assignments/media-types/media-types.xhtml) for the image.
1083 #[serde(rename = "mimeType")]
1084 pub mime_type: Option<String>,
1085 /// Width of the image in pixels.
1086 pub width: Option<i32>,
1087}
1088
1089impl common::Part for GoogleCloudDocumentaiV1DocumentPageImage {}
1090
1091/// Image quality scores for the page image.
1092///
1093/// This type is not used in any activity, and only used as *part* of another schema.
1094///
1095#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1096#[serde_with::serde_as]
1097#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1098pub struct GoogleCloudDocumentaiV1DocumentPageImageQualityScores {
1099 /// A list of detected defects.
1100 #[serde(rename = "detectedDefects")]
1101 pub detected_defects:
1102 Option<Vec<GoogleCloudDocumentaiV1DocumentPageImageQualityScoresDetectedDefect>>,
1103 /// The overall quality score. Range `[0, 1]` where `1` is perfect quality.
1104 #[serde(rename = "qualityScore")]
1105 pub quality_score: Option<f32>,
1106}
1107
1108impl common::Part for GoogleCloudDocumentaiV1DocumentPageImageQualityScores {}
1109
1110/// Image Quality Defects
1111///
1112/// This type is not used in any activity, and only used as *part* of another schema.
1113///
1114#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1115#[serde_with::serde_as]
1116#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1117pub struct GoogleCloudDocumentaiV1DocumentPageImageQualityScoresDetectedDefect {
1118 /// Confidence of detected defect. Range `[0, 1]` where `1` indicates strong confidence that the defect exists.
1119 pub confidence: Option<f32>,
1120 /// 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`
1121 #[serde(rename = "type")]
1122 pub type_: Option<String>,
1123}
1124
1125impl common::Part for GoogleCloudDocumentaiV1DocumentPageImageQualityScoresDetectedDefect {}
1126
1127/// Visual element describing a layout unit on a page.
1128///
1129/// This type is not used in any activity, and only used as *part* of another schema.
1130///
1131#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1132#[serde_with::serde_as]
1133#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1134pub struct GoogleCloudDocumentaiV1DocumentPageLayout {
1135 /// The bounding polygon for the Layout.
1136 #[serde(rename = "boundingPoly")]
1137 pub bounding_poly: Option<GoogleCloudDocumentaiV1BoundingPoly>,
1138 /// 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]`.
1139 pub confidence: Option<f32>,
1140 /// Detected orientation for the Layout.
1141 pub orientation: Option<String>,
1142 /// Text anchor indexing into the Document.text.
1143 #[serde(rename = "textAnchor")]
1144 pub text_anchor: Option<GoogleCloudDocumentaiV1DocumentTextAnchor>,
1145}
1146
1147impl common::Part for GoogleCloudDocumentaiV1DocumentPageLayout {}
1148
1149/// A collection of tokens that a human would perceive as a line. Does not cross column boundaries, can be horizontal, vertical, etc.
1150///
1151/// This type is not used in any activity, and only used as *part* of another schema.
1152///
1153#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1154#[serde_with::serde_as]
1155#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1156pub struct GoogleCloudDocumentaiV1DocumentPageLine {
1157 /// A list of detected languages together with confidence.
1158 #[serde(rename = "detectedLanguages")]
1159 pub detected_languages: Option<Vec<GoogleCloudDocumentaiV1DocumentPageDetectedLanguage>>,
1160 /// Layout for Line.
1161 pub layout: Option<GoogleCloudDocumentaiV1DocumentPageLayout>,
1162 /// The history of this annotation.
1163 pub provenance: Option<GoogleCloudDocumentaiV1DocumentProvenance>,
1164}
1165
1166impl common::Part for GoogleCloudDocumentaiV1DocumentPageLine {}
1167
1168/// Representation for transformation matrix, intended to be compatible and used with OpenCV format for image manipulation.
1169///
1170/// This type is not used in any activity, and only used as *part* of another schema.
1171///
1172#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1173#[serde_with::serde_as]
1174#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1175pub struct GoogleCloudDocumentaiV1DocumentPageMatrix {
1176 /// Number of columns in the matrix.
1177 pub cols: Option<i32>,
1178 /// The matrix data.
1179 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1180 pub data: Option<Vec<u8>>,
1181 /// Number of rows in the matrix.
1182 pub rows: Option<i32>,
1183 /// 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
1184 #[serde(rename = "type")]
1185 pub type_: Option<i32>,
1186}
1187
1188impl common::Part for GoogleCloudDocumentaiV1DocumentPageMatrix {}
1189
1190/// A collection of lines that a human would perceive as a paragraph.
1191///
1192/// This type is not used in any activity, and only used as *part* of another schema.
1193///
1194#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1195#[serde_with::serde_as]
1196#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1197pub struct GoogleCloudDocumentaiV1DocumentPageParagraph {
1198 /// A list of detected languages together with confidence.
1199 #[serde(rename = "detectedLanguages")]
1200 pub detected_languages: Option<Vec<GoogleCloudDocumentaiV1DocumentPageDetectedLanguage>>,
1201 /// Layout for Paragraph.
1202 pub layout: Option<GoogleCloudDocumentaiV1DocumentPageLayout>,
1203 /// The history of this annotation.
1204 pub provenance: Option<GoogleCloudDocumentaiV1DocumentProvenance>,
1205}
1206
1207impl common::Part for GoogleCloudDocumentaiV1DocumentPageParagraph {}
1208
1209/// A detected symbol.
1210///
1211/// This type is not used in any activity, and only used as *part* of another schema.
1212///
1213#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1214#[serde_with::serde_as]
1215#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1216pub struct GoogleCloudDocumentaiV1DocumentPageSymbol {
1217 /// A list of detected languages together with confidence.
1218 #[serde(rename = "detectedLanguages")]
1219 pub detected_languages: Option<Vec<GoogleCloudDocumentaiV1DocumentPageDetectedLanguage>>,
1220 /// Layout for Symbol.
1221 pub layout: Option<GoogleCloudDocumentaiV1DocumentPageLayout>,
1222}
1223
1224impl common::Part for GoogleCloudDocumentaiV1DocumentPageSymbol {}
1225
1226/// A table representation similar to HTML table structure.
1227///
1228/// This type is not used in any activity, and only used as *part* of another schema.
1229///
1230#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1231#[serde_with::serde_as]
1232#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1233pub struct GoogleCloudDocumentaiV1DocumentPageTable {
1234 /// Body rows of the table.
1235 #[serde(rename = "bodyRows")]
1236 pub body_rows: Option<Vec<GoogleCloudDocumentaiV1DocumentPageTableTableRow>>,
1237 /// A list of detected languages together with confidence.
1238 #[serde(rename = "detectedLanguages")]
1239 pub detected_languages: Option<Vec<GoogleCloudDocumentaiV1DocumentPageDetectedLanguage>>,
1240 /// Header rows of the table.
1241 #[serde(rename = "headerRows")]
1242 pub header_rows: Option<Vec<GoogleCloudDocumentaiV1DocumentPageTableTableRow>>,
1243 /// Layout for Table.
1244 pub layout: Option<GoogleCloudDocumentaiV1DocumentPageLayout>,
1245 /// The history of this table.
1246 pub provenance: Option<GoogleCloudDocumentaiV1DocumentProvenance>,
1247}
1248
1249impl common::Part for GoogleCloudDocumentaiV1DocumentPageTable {}
1250
1251/// A cell representation inside the table.
1252///
1253/// This type is not used in any activity, and only used as *part* of another schema.
1254///
1255#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1256#[serde_with::serde_as]
1257#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1258pub struct GoogleCloudDocumentaiV1DocumentPageTableTableCell {
1259 /// How many columns this cell spans.
1260 #[serde(rename = "colSpan")]
1261 pub col_span: Option<i32>,
1262 /// A list of detected languages together with confidence.
1263 #[serde(rename = "detectedLanguages")]
1264 pub detected_languages: Option<Vec<GoogleCloudDocumentaiV1DocumentPageDetectedLanguage>>,
1265 /// Layout for TableCell.
1266 pub layout: Option<GoogleCloudDocumentaiV1DocumentPageLayout>,
1267 /// How many rows this cell spans.
1268 #[serde(rename = "rowSpan")]
1269 pub row_span: Option<i32>,
1270}
1271
1272impl common::Part for GoogleCloudDocumentaiV1DocumentPageTableTableCell {}
1273
1274/// A row of table cells.
1275///
1276/// This type is not used in any activity, and only used as *part* of another schema.
1277///
1278#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1279#[serde_with::serde_as]
1280#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1281pub struct GoogleCloudDocumentaiV1DocumentPageTableTableRow {
1282 /// Cells that make up this row.
1283 pub cells: Option<Vec<GoogleCloudDocumentaiV1DocumentPageTableTableCell>>,
1284}
1285
1286impl common::Part for GoogleCloudDocumentaiV1DocumentPageTableTableRow {}
1287
1288/// A detected token.
1289///
1290/// This type is not used in any activity, and only used as *part* of another schema.
1291///
1292#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1293#[serde_with::serde_as]
1294#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1295pub struct GoogleCloudDocumentaiV1DocumentPageToken {
1296 /// Detected break at the end of a Token.
1297 #[serde(rename = "detectedBreak")]
1298 pub detected_break: Option<GoogleCloudDocumentaiV1DocumentPageTokenDetectedBreak>,
1299 /// A list of detected languages together with confidence.
1300 #[serde(rename = "detectedLanguages")]
1301 pub detected_languages: Option<Vec<GoogleCloudDocumentaiV1DocumentPageDetectedLanguage>>,
1302 /// Layout for Token.
1303 pub layout: Option<GoogleCloudDocumentaiV1DocumentPageLayout>,
1304 /// The history of this annotation.
1305 pub provenance: Option<GoogleCloudDocumentaiV1DocumentProvenance>,
1306 /// Text style attributes.
1307 #[serde(rename = "styleInfo")]
1308 pub style_info: Option<GoogleCloudDocumentaiV1DocumentPageTokenStyleInfo>,
1309}
1310
1311impl common::Part for GoogleCloudDocumentaiV1DocumentPageToken {}
1312
1313/// Detected break at the end of a Token.
1314///
1315/// This type is not used in any activity, and only used as *part* of another schema.
1316///
1317#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1318#[serde_with::serde_as]
1319#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1320pub struct GoogleCloudDocumentaiV1DocumentPageTokenDetectedBreak {
1321 /// Detected break type.
1322 #[serde(rename = "type")]
1323 pub type_: Option<String>,
1324}
1325
1326impl common::Part for GoogleCloudDocumentaiV1DocumentPageTokenDetectedBreak {}
1327
1328/// Font and other text style attributes.
1329///
1330/// This type is not used in any activity, and only used as *part* of another schema.
1331///
1332#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1333#[serde_with::serde_as]
1334#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1335pub struct GoogleCloudDocumentaiV1DocumentPageTokenStyleInfo {
1336 /// Color of the background.
1337 #[serde(rename = "backgroundColor")]
1338 pub background_color: Option<GoogleTypeColor>,
1339 /// Whether the text is bold (equivalent to font_weight is at least `700`).
1340 pub bold: Option<bool>,
1341 /// Font size in points (`1` point is `¹⁄₇₂` inches).
1342 #[serde(rename = "fontSize")]
1343 pub font_size: Option<i32>,
1344 /// Name or style of the font.
1345 #[serde(rename = "fontType")]
1346 pub font_type: Option<String>,
1347 /// TrueType weight on a scale `100` (thin) to `1000` (ultra-heavy). Normal is `400`, bold is `700`.
1348 #[serde(rename = "fontWeight")]
1349 pub font_weight: Option<i32>,
1350 /// Whether the text is handwritten.
1351 pub handwritten: Option<bool>,
1352 /// Whether the text is italic.
1353 pub italic: Option<bool>,
1354 /// Letter spacing in points.
1355 #[serde(rename = "letterSpacing")]
1356 pub letter_spacing: Option<f64>,
1357 /// Font size in pixels, equal to _unrounded font_size_ * _resolution_ ÷ `72.0`.
1358 #[serde(rename = "pixelFontSize")]
1359 pub pixel_font_size: Option<f64>,
1360 /// Whether the text is in small caps. This feature is not supported yet.
1361 pub smallcaps: Option<bool>,
1362 /// Whether the text is strikethrough. This feature is not supported yet.
1363 pub strikeout: Option<bool>,
1364 /// Whether the text is a subscript. This feature is not supported yet.
1365 pub subscript: Option<bool>,
1366 /// Whether the text is a superscript. This feature is not supported yet.
1367 pub superscript: Option<bool>,
1368 /// Color of the text.
1369 #[serde(rename = "textColor")]
1370 pub text_color: Option<GoogleTypeColor>,
1371 /// Whether the text is underlined.
1372 pub underlined: Option<bool>,
1373}
1374
1375impl common::Part for GoogleCloudDocumentaiV1DocumentPageTokenStyleInfo {}
1376
1377/// Detected non-text visual elements e.g. checkbox, signature etc. on the page.
1378///
1379/// This type is not used in any activity, and only used as *part* of another schema.
1380///
1381#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1382#[serde_with::serde_as]
1383#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1384pub struct GoogleCloudDocumentaiV1DocumentPageVisualElement {
1385 /// A list of detected languages together with confidence.
1386 #[serde(rename = "detectedLanguages")]
1387 pub detected_languages: Option<Vec<GoogleCloudDocumentaiV1DocumentPageDetectedLanguage>>,
1388 /// Layout for VisualElement.
1389 pub layout: Option<GoogleCloudDocumentaiV1DocumentPageLayout>,
1390 /// Type of the VisualElement.
1391 #[serde(rename = "type")]
1392 pub type_: Option<String>,
1393}
1394
1395impl common::Part for GoogleCloudDocumentaiV1DocumentPageVisualElement {}
1396
1397/// Structure to identify provenance relationships between annotations in different revisions.
1398///
1399/// This type is not used in any activity, and only used as *part* of another schema.
1400///
1401#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1402#[serde_with::serde_as]
1403#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1404pub struct GoogleCloudDocumentaiV1DocumentProvenance {
1405 /// The Id of this operation. Needs to be unique within the scope of the revision.
1406 pub id: Option<i32>,
1407 /// References to the original elements that are replaced.
1408 pub parents: Option<Vec<GoogleCloudDocumentaiV1DocumentProvenanceParent>>,
1409 /// The index of the revision that produced this element.
1410 pub revision: Option<i32>,
1411 /// The type of provenance operation.
1412 #[serde(rename = "type")]
1413 pub type_: Option<String>,
1414}
1415
1416impl common::Part for GoogleCloudDocumentaiV1DocumentProvenance {}
1417
1418/// The parent element the current element is based on. Used for referencing/aligning, removal and replacement operations.
1419///
1420/// This type is not used in any activity, and only used as *part* of another schema.
1421///
1422#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1423#[serde_with::serde_as]
1424#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1425pub struct GoogleCloudDocumentaiV1DocumentProvenanceParent {
1426 /// The id of the parent provenance.
1427 pub id: Option<i32>,
1428 /// The index of the parent item in the corresponding item list (eg. list of entities, properties within entities, etc.) in the parent revision.
1429 pub index: Option<i32>,
1430 /// The index of the index into current revision's parent_ids list.
1431 pub revision: Option<i32>,
1432}
1433
1434impl common::Part for GoogleCloudDocumentaiV1DocumentProvenanceParent {}
1435
1436/// Contains past or forward revisions of this document.
1437///
1438/// This type is not used in any activity, and only used as *part* of another schema.
1439///
1440#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1441#[serde_with::serde_as]
1442#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1443pub struct GoogleCloudDocumentaiV1DocumentRevision {
1444 /// If the change was made by a person specify the name or id of that person.
1445 pub agent: Option<String>,
1446 /// The time that the revision was created, internally generated by doc proto storage at the time of create.
1447 #[serde(rename = "createTime")]
1448 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1449 /// Human Review information of this revision.
1450 #[serde(rename = "humanReview")]
1451 pub human_review: Option<GoogleCloudDocumentaiV1DocumentRevisionHumanReview>,
1452 /// Id of the revision, internally generated by doc proto storage. Unique within the context of the document.
1453 pub id: Option<String>,
1454 /// 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.
1455 pub parent: Option<Vec<i32>>,
1456 /// 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.
1457 #[serde(rename = "parentIds")]
1458 pub parent_ids: Option<Vec<String>>,
1459 /// If the annotation was made by processor identify the processor by its resource name.
1460 pub processor: Option<String>,
1461}
1462
1463impl common::Part for GoogleCloudDocumentaiV1DocumentRevision {}
1464
1465/// Human Review information of the document.
1466///
1467/// This type is not used in any activity, and only used as *part* of another schema.
1468///
1469#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1470#[serde_with::serde_as]
1471#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1472pub struct GoogleCloudDocumentaiV1DocumentRevisionHumanReview {
1473 /// Human review state. e.g. `requested`, `succeeded`, `rejected`.
1474 pub state: Option<String>,
1475 /// A message providing more details about the current state of processing. For example, the rejection reason when the state is `rejected`.
1476 #[serde(rename = "stateMessage")]
1477 pub state_message: Option<String>,
1478}
1479
1480impl common::Part for GoogleCloudDocumentaiV1DocumentRevisionHumanReview {}
1481
1482/// The schema defines the output of the processed document by a processor.
1483///
1484/// This type is not used in any activity, and only used as *part* of another schema.
1485///
1486#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1487#[serde_with::serde_as]
1488#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1489pub struct GoogleCloudDocumentaiV1DocumentSchema {
1490 /// Description of the schema.
1491 pub description: Option<String>,
1492 /// Display name to show to users.
1493 #[serde(rename = "displayName")]
1494 pub display_name: Option<String>,
1495 /// Entity types of the schema.
1496 #[serde(rename = "entityTypes")]
1497 pub entity_types: Option<Vec<GoogleCloudDocumentaiV1DocumentSchemaEntityType>>,
1498 /// Metadata of the schema.
1499 pub metadata: Option<GoogleCloudDocumentaiV1DocumentSchemaMetadata>,
1500}
1501
1502impl common::Part for GoogleCloudDocumentaiV1DocumentSchema {}
1503
1504/// 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.
1505///
1506/// This type is not used in any activity, and only used as *part* of another schema.
1507///
1508#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1509#[serde_with::serde_as]
1510#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1511pub struct GoogleCloudDocumentaiV1DocumentSchemaEntityType {
1512 /// The entity type that this type is derived from. For now, one and only one should be set.
1513 #[serde(rename = "baseTypes")]
1514 pub base_types: Option<Vec<String>>,
1515 /// User defined name for the type.
1516 #[serde(rename = "displayName")]
1517 pub display_name: Option<String>,
1518 /// 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.
1519 #[serde(rename = "enumValues")]
1520 pub enum_values: Option<GoogleCloudDocumentaiV1DocumentSchemaEntityTypeEnumValues>,
1521 /// 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.
1522 pub name: Option<String>,
1523 /// Description the nested structure, or composition of an entity.
1524 pub properties: Option<Vec<GoogleCloudDocumentaiV1DocumentSchemaEntityTypeProperty>>,
1525}
1526
1527impl common::Part for GoogleCloudDocumentaiV1DocumentSchemaEntityType {}
1528
1529/// Defines the a list of enum values.
1530///
1531/// This type is not used in any activity, and only used as *part* of another schema.
1532///
1533#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1534#[serde_with::serde_as]
1535#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1536pub struct GoogleCloudDocumentaiV1DocumentSchemaEntityTypeEnumValues {
1537 /// The individual values that this enum values type can include.
1538 pub values: Option<Vec<String>>,
1539}
1540
1541impl common::Part for GoogleCloudDocumentaiV1DocumentSchemaEntityTypeEnumValues {}
1542
1543/// Defines properties that can be part of the entity type.
1544///
1545/// This type is not used in any activity, and only used as *part* of another schema.
1546///
1547#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1548#[serde_with::serde_as]
1549#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1550pub struct GoogleCloudDocumentaiV1DocumentSchemaEntityTypeProperty {
1551 /// User defined name for the property.
1552 #[serde(rename = "displayName")]
1553 pub display_name: Option<String>,
1554 /// Specifies how the entity's value is obtained.
1555 pub method: Option<String>,
1556 /// The name of the property. Follows the same guidelines as the EntityType name.
1557 pub name: Option<String>,
1558 /// Occurrence type limits the number of instances an entity type appears in the document.
1559 #[serde(rename = "occurrenceType")]
1560 pub occurrence_type: Option<String>,
1561 /// A reference to the value type of the property. This type is subject to the same conventions as the `Entity.base_types` field.
1562 #[serde(rename = "valueType")]
1563 pub value_type: Option<String>,
1564}
1565
1566impl common::Part for GoogleCloudDocumentaiV1DocumentSchemaEntityTypeProperty {}
1567
1568/// Metadata for global schema behavior.
1569///
1570/// This type is not used in any activity, and only used as *part* of another schema.
1571///
1572#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1573#[serde_with::serde_as]
1574#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1575pub struct GoogleCloudDocumentaiV1DocumentSchemaMetadata {
1576 /// If true, on a given page, there can be multiple `document` annotations covering it.
1577 #[serde(rename = "documentAllowMultipleLabels")]
1578 pub document_allow_multiple_labels: Option<bool>,
1579 /// If true, a `document` entity type can be applied to subdocument (splitting). Otherwise, it can only be applied to the entire document (classification).
1580 #[serde(rename = "documentSplitter")]
1581 pub document_splitter: Option<bool>,
1582 /// If set, all the nested entities must be prefixed with the parents.
1583 #[serde(rename = "prefixedNamingOnProperties")]
1584 pub prefixed_naming_on_properties: Option<bool>,
1585 /// 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.
1586 #[serde(rename = "skipNamingValidation")]
1587 pub skip_naming_validation: Option<bool>,
1588}
1589
1590impl common::Part for GoogleCloudDocumentaiV1DocumentSchemaMetadata {}
1591
1592/// 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.
1593///
1594/// This type is not used in any activity, and only used as *part* of another schema.
1595///
1596#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1597#[serde_with::serde_as]
1598#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1599pub struct GoogleCloudDocumentaiV1DocumentShardInfo {
1600 /// Total number of shards.
1601 #[serde(rename = "shardCount")]
1602 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1603 pub shard_count: Option<i64>,
1604 /// The 0-based index of this shard.
1605 #[serde(rename = "shardIndex")]
1606 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1607 pub shard_index: Option<i64>,
1608 /// The index of the first character in Document.text in the overall document global text.
1609 #[serde(rename = "textOffset")]
1610 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1611 pub text_offset: Option<i64>,
1612}
1613
1614impl common::Part for GoogleCloudDocumentaiV1DocumentShardInfo {}
1615
1616/// Annotation for common text style attributes. This adheres to CSS conventions as much as possible.
1617///
1618/// This type is not used in any activity, and only used as *part* of another schema.
1619///
1620#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1621#[serde_with::serde_as]
1622#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1623pub struct GoogleCloudDocumentaiV1DocumentStyle {
1624 /// Text background color.
1625 #[serde(rename = "backgroundColor")]
1626 pub background_color: Option<GoogleTypeColor>,
1627 /// Text color.
1628 pub color: Option<GoogleTypeColor>,
1629 /// Font family such as `Arial`, `Times New Roman`. https://www.w3schools.com/cssref/pr_font_font-family.asp
1630 #[serde(rename = "fontFamily")]
1631 pub font_family: Option<String>,
1632 /// Font size.
1633 #[serde(rename = "fontSize")]
1634 pub font_size: Option<GoogleCloudDocumentaiV1DocumentStyleFontSize>,
1635 /// [Font weight](https://www.w3schools.com/cssref/pr_font_weight.asp). Possible values are `normal`, `bold`, `bolder`, and `lighter`.
1636 #[serde(rename = "fontWeight")]
1637 pub font_weight: Option<String>,
1638 /// Text anchor indexing into the Document.text.
1639 #[serde(rename = "textAnchor")]
1640 pub text_anchor: Option<GoogleCloudDocumentaiV1DocumentTextAnchor>,
1641 /// [Text decoration](https://www.w3schools.com/cssref/pr_text_text-decoration.asp). Follows CSS standard.
1642 #[serde(rename = "textDecoration")]
1643 pub text_decoration: Option<String>,
1644 /// [Text style](https://www.w3schools.com/cssref/pr_font_font-style.asp). Possible values are `normal`, `italic`, and `oblique`.
1645 #[serde(rename = "textStyle")]
1646 pub text_style: Option<String>,
1647}
1648
1649impl common::Part for GoogleCloudDocumentaiV1DocumentStyle {}
1650
1651/// Font size with unit.
1652///
1653/// This type is not used in any activity, and only used as *part* of another schema.
1654///
1655#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1656#[serde_with::serde_as]
1657#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1658pub struct GoogleCloudDocumentaiV1DocumentStyleFontSize {
1659 /// Font size for the text.
1660 pub size: Option<f32>,
1661 /// Unit for the font size. Follows CSS naming (such as `in`, `px`, and `pt`).
1662 pub unit: Option<String>,
1663}
1664
1665impl common::Part for GoogleCloudDocumentaiV1DocumentStyleFontSize {}
1666
1667/// Text reference indexing into the Document.text.
1668///
1669/// This type is not used in any activity, and only used as *part* of another schema.
1670///
1671#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1672#[serde_with::serde_as]
1673#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1674pub struct GoogleCloudDocumentaiV1DocumentTextAnchor {
1675 /// 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.
1676 pub content: Option<String>,
1677 /// The text segments from the Document.text.
1678 #[serde(rename = "textSegments")]
1679 pub text_segments: Option<Vec<GoogleCloudDocumentaiV1DocumentTextAnchorTextSegment>>,
1680}
1681
1682impl common::Part for GoogleCloudDocumentaiV1DocumentTextAnchor {}
1683
1684/// 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
1685///
1686/// This type is not used in any activity, and only used as *part* of another schema.
1687///
1688#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1689#[serde_with::serde_as]
1690#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1691pub struct GoogleCloudDocumentaiV1DocumentTextAnchorTextSegment {
1692 /// TextSegment half open end UTF-8 char index in the Document.text.
1693 #[serde(rename = "endIndex")]
1694 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1695 pub end_index: Option<i64>,
1696 /// TextSegment start UTF-8 char index in the Document.text.
1697 #[serde(rename = "startIndex")]
1698 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1699 pub start_index: Option<i64>,
1700}
1701
1702impl common::Part for GoogleCloudDocumentaiV1DocumentTextAnchorTextSegment {}
1703
1704/// This message is used for text changes aka. OCR corrections.
1705///
1706/// This type is not used in any activity, and only used as *part* of another schema.
1707///
1708#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1709#[serde_with::serde_as]
1710#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1711pub struct GoogleCloudDocumentaiV1DocumentTextChange {
1712 /// The text that replaces the text identified in the `text_anchor`.
1713 #[serde(rename = "changedText")]
1714 pub changed_text: Option<String>,
1715 /// The history of this annotation.
1716 pub provenance: Option<Vec<GoogleCloudDocumentaiV1DocumentProvenance>>,
1717 /// 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.
1718 #[serde(rename = "textAnchor")]
1719 pub text_anchor: Option<GoogleCloudDocumentaiV1DocumentTextAnchor>,
1720}
1721
1722impl common::Part for GoogleCloudDocumentaiV1DocumentTextChange {}
1723
1724/// A set of inline documents.
1725///
1726/// This type is not used in any activity, and only used as *part* of another schema.
1727///
1728#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1729#[serde_with::serde_as]
1730#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1731pub struct GoogleCloudDocumentaiV1Documents {
1732 /// The list of documents.
1733 pub documents: Option<Vec<GoogleCloudDocumentaiV1Document>>,
1734}
1735
1736impl common::Part for GoogleCloudDocumentaiV1Documents {}
1737
1738/// Request message for the EnableProcessor method.
1739///
1740/// # Activities
1741///
1742/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1743/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1744///
1745/// * [locations processors enable projects](ProjectLocationProcessorEnableCall) (request)
1746#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1747#[serde_with::serde_as]
1748#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1749pub struct GoogleCloudDocumentaiV1EnableProcessorRequest {
1750 _never_set: Option<bool>,
1751}
1752
1753impl common::RequestValue for GoogleCloudDocumentaiV1EnableProcessorRequest {}
1754
1755/// Evaluates the given ProcessorVersion against the supplied documents.
1756///
1757/// # Activities
1758///
1759/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1760/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1761///
1762/// * [locations processors processor versions evaluate processor version projects](ProjectLocationProcessorProcessorVersionEvaluateProcessorVersionCall) (request)
1763#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1764#[serde_with::serde_as]
1765#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1766pub struct GoogleCloudDocumentaiV1EvaluateProcessorVersionRequest {
1767 /// Optional. The documents used in the evaluation. If unspecified, use the processor's dataset as evaluation input.
1768 #[serde(rename = "evaluationDocuments")]
1769 pub evaluation_documents: Option<GoogleCloudDocumentaiV1BatchDocumentsInputConfig>,
1770}
1771
1772impl common::RequestValue for GoogleCloudDocumentaiV1EvaluateProcessorVersionRequest {}
1773
1774/// An evaluation of a ProcessorVersion’s performance.
1775///
1776/// # Activities
1777///
1778/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1779/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1780///
1781/// * [locations processors processor versions evaluations get projects](ProjectLocationProcessorProcessorVersionEvaluationGetCall) (response)
1782#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1783#[serde_with::serde_as]
1784#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1785pub struct GoogleCloudDocumentaiV1Evaluation {
1786 /// Metrics for all the entities in aggregate.
1787 #[serde(rename = "allEntitiesMetrics")]
1788 pub all_entities_metrics: Option<GoogleCloudDocumentaiV1EvaluationMultiConfidenceMetrics>,
1789 /// The time that the evaluation was created.
1790 #[serde(rename = "createTime")]
1791 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1792 /// Counters for the documents used in the evaluation.
1793 #[serde(rename = "documentCounters")]
1794 pub document_counters: Option<GoogleCloudDocumentaiV1EvaluationCounters>,
1795 /// Metrics across confidence levels, for different entities.
1796 #[serde(rename = "entityMetrics")]
1797 pub entity_metrics:
1798 Option<HashMap<String, GoogleCloudDocumentaiV1EvaluationMultiConfidenceMetrics>>,
1799 /// The KMS key name used for encryption.
1800 #[serde(rename = "kmsKeyName")]
1801 pub kms_key_name: Option<String>,
1802 /// The KMS key version with which data is encrypted.
1803 #[serde(rename = "kmsKeyVersionName")]
1804 pub kms_key_version_name: Option<String>,
1805 /// The resource name of the evaluation. Format: `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processor_version}/evaluations/{evaluation}`
1806 pub name: Option<String>,
1807}
1808
1809impl common::ResponseResult for GoogleCloudDocumentaiV1Evaluation {}
1810
1811/// Evaluations metrics, at a specific confidence level.
1812///
1813/// This type is not used in any activity, and only used as *part* of another schema.
1814///
1815#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1816#[serde_with::serde_as]
1817#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1818pub struct GoogleCloudDocumentaiV1EvaluationConfidenceLevelMetrics {
1819 /// The confidence level.
1820 #[serde(rename = "confidenceLevel")]
1821 pub confidence_level: Option<f32>,
1822 /// The metrics at the specific confidence level.
1823 pub metrics: Option<GoogleCloudDocumentaiV1EvaluationMetrics>,
1824}
1825
1826impl common::Part for GoogleCloudDocumentaiV1EvaluationConfidenceLevelMetrics {}
1827
1828/// Evaluation counters for the documents that were used.
1829///
1830/// This type is not used in any activity, and only used as *part* of another schema.
1831///
1832#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1833#[serde_with::serde_as]
1834#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1835pub struct GoogleCloudDocumentaiV1EvaluationCounters {
1836 /// How many documents were used in the evaluation.
1837 #[serde(rename = "evaluatedDocumentsCount")]
1838 pub evaluated_documents_count: Option<i32>,
1839 /// How many documents were not included in the evaluation as Document AI failed to process them.
1840 #[serde(rename = "failedDocumentsCount")]
1841 pub failed_documents_count: Option<i32>,
1842 /// How many documents were sent for evaluation.
1843 #[serde(rename = "inputDocumentsCount")]
1844 pub input_documents_count: Option<i32>,
1845 /// How many documents were not included in the evaluation as they didn't pass validation.
1846 #[serde(rename = "invalidDocumentsCount")]
1847 pub invalid_documents_count: Option<i32>,
1848}
1849
1850impl common::Part for GoogleCloudDocumentaiV1EvaluationCounters {}
1851
1852/// Evaluation metrics, either in aggregate or about a specific entity.
1853///
1854/// This type is not used in any activity, and only used as *part* of another schema.
1855///
1856#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1857#[serde_with::serde_as]
1858#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1859pub struct GoogleCloudDocumentaiV1EvaluationMetrics {
1860 /// The calculated f1 score.
1861 #[serde(rename = "f1Score")]
1862 pub f1_score: Option<f32>,
1863 /// The amount of false negatives.
1864 #[serde(rename = "falseNegativesCount")]
1865 pub false_negatives_count: Option<i32>,
1866 /// The amount of false positives.
1867 #[serde(rename = "falsePositivesCount")]
1868 pub false_positives_count: Option<i32>,
1869 /// The amount of documents with a ground truth occurrence.
1870 #[serde(rename = "groundTruthDocumentCount")]
1871 pub ground_truth_document_count: Option<i32>,
1872 /// The amount of occurrences in ground truth documents.
1873 #[serde(rename = "groundTruthOccurrencesCount")]
1874 pub ground_truth_occurrences_count: Option<i32>,
1875 /// The calculated precision.
1876 pub precision: Option<f32>,
1877 /// The amount of documents with a predicted occurrence.
1878 #[serde(rename = "predictedDocumentCount")]
1879 pub predicted_document_count: Option<i32>,
1880 /// The amount of occurrences in predicted documents.
1881 #[serde(rename = "predictedOccurrencesCount")]
1882 pub predicted_occurrences_count: Option<i32>,
1883 /// The calculated recall.
1884 pub recall: Option<f32>,
1885 /// The amount of documents that had an occurrence of this label.
1886 #[serde(rename = "totalDocumentsCount")]
1887 pub total_documents_count: Option<i32>,
1888 /// The amount of true positives.
1889 #[serde(rename = "truePositivesCount")]
1890 pub true_positives_count: Option<i32>,
1891}
1892
1893impl common::Part for GoogleCloudDocumentaiV1EvaluationMetrics {}
1894
1895/// Metrics across multiple confidence levels.
1896///
1897/// This type is not used in any activity, and only used as *part* of another schema.
1898///
1899#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1900#[serde_with::serde_as]
1901#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1902pub struct GoogleCloudDocumentaiV1EvaluationMultiConfidenceMetrics {
1903 /// The calculated area under the precision recall curve (AUPRC), computed by integrating over all confidence thresholds.
1904 pub auprc: Option<f32>,
1905 /// The AUPRC for metrics with fuzzy matching disabled, i.e., exact matching only.
1906 #[serde(rename = "auprcExact")]
1907 pub auprc_exact: Option<f32>,
1908 /// Metrics across confidence levels with fuzzy matching enabled.
1909 #[serde(rename = "confidenceLevelMetrics")]
1910 pub confidence_level_metrics:
1911 Option<Vec<GoogleCloudDocumentaiV1EvaluationConfidenceLevelMetrics>>,
1912 /// Metrics across confidence levels with only exact matching.
1913 #[serde(rename = "confidenceLevelMetricsExact")]
1914 pub confidence_level_metrics_exact:
1915 Option<Vec<GoogleCloudDocumentaiV1EvaluationConfidenceLevelMetrics>>,
1916 /// The Estimated Calibration Error (ECE) of the confidence of the predicted entities.
1917 #[serde(rename = "estimatedCalibrationError")]
1918 pub estimated_calibration_error: Option<f32>,
1919 /// The ECE for the predicted entities with fuzzy matching disabled, i.e., exact matching only.
1920 #[serde(rename = "estimatedCalibrationErrorExact")]
1921 pub estimated_calibration_error_exact: Option<f32>,
1922 /// The metrics type for the label.
1923 #[serde(rename = "metricsType")]
1924 pub metrics_type: Option<String>,
1925}
1926
1927impl common::Part for GoogleCloudDocumentaiV1EvaluationMultiConfidenceMetrics {}
1928
1929/// Gives a short summary of an evaluation, and links to the evaluation itself.
1930///
1931/// This type is not used in any activity, and only used as *part* of another schema.
1932///
1933#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1934#[serde_with::serde_as]
1935#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1936pub struct GoogleCloudDocumentaiV1EvaluationReference {
1937 /// An aggregate of the statistics for the evaluation with fuzzy matching on.
1938 #[serde(rename = "aggregateMetrics")]
1939 pub aggregate_metrics: Option<GoogleCloudDocumentaiV1EvaluationMetrics>,
1940 /// An aggregate of the statistics for the evaluation with fuzzy matching off.
1941 #[serde(rename = "aggregateMetricsExact")]
1942 pub aggregate_metrics_exact: Option<GoogleCloudDocumentaiV1EvaluationMetrics>,
1943 /// The resource name of the evaluation.
1944 pub evaluation: Option<String>,
1945 /// The resource name of the Long Running Operation for the evaluation.
1946 pub operation: Option<String>,
1947}
1948
1949impl common::Part for GoogleCloudDocumentaiV1EvaluationReference {}
1950
1951/// Response message for the FetchProcessorTypes method.
1952///
1953/// # Activities
1954///
1955/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1956/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1957///
1958/// * [locations fetch processor types projects](ProjectLocationFetchProcessorTypeCall) (response)
1959#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1960#[serde_with::serde_as]
1961#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1962pub struct GoogleCloudDocumentaiV1FetchProcessorTypesResponse {
1963 /// The list of processor types.
1964 #[serde(rename = "processorTypes")]
1965 pub processor_types: Option<Vec<GoogleCloudDocumentaiV1ProcessorType>>,
1966}
1967
1968impl common::ResponseResult for GoogleCloudDocumentaiV1FetchProcessorTypesResponse {}
1969
1970/// Specifies a document stored on Cloud Storage.
1971///
1972/// This type is not used in any activity, and only used as *part* of another schema.
1973///
1974#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1975#[serde_with::serde_as]
1976#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1977pub struct GoogleCloudDocumentaiV1GcsDocument {
1978 /// The Cloud Storage object uri.
1979 #[serde(rename = "gcsUri")]
1980 pub gcs_uri: Option<String>,
1981 /// An IANA MIME type (RFC6838) of the content.
1982 #[serde(rename = "mimeType")]
1983 pub mime_type: Option<String>,
1984}
1985
1986impl common::Part for GoogleCloudDocumentaiV1GcsDocument {}
1987
1988/// Specifies a set of documents on Cloud Storage.
1989///
1990/// This type is not used in any activity, and only used as *part* of another schema.
1991///
1992#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1993#[serde_with::serde_as]
1994#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1995pub struct GoogleCloudDocumentaiV1GcsDocuments {
1996 /// The list of documents.
1997 pub documents: Option<Vec<GoogleCloudDocumentaiV1GcsDocument>>,
1998}
1999
2000impl common::Part for GoogleCloudDocumentaiV1GcsDocuments {}
2001
2002/// Specifies all documents on Cloud Storage with a common prefix.
2003///
2004/// This type is not used in any activity, and only used as *part* of another schema.
2005///
2006#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2007#[serde_with::serde_as]
2008#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2009pub struct GoogleCloudDocumentaiV1GcsPrefix {
2010 /// The URI prefix.
2011 #[serde(rename = "gcsUriPrefix")]
2012 pub gcs_uri_prefix: Option<String>,
2013}
2014
2015impl common::Part for GoogleCloudDocumentaiV1GcsPrefix {}
2016
2017/// Request message for GenerateSchemaVersion.
2018///
2019/// # Activities
2020///
2021/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2022/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2023///
2024/// * [locations schemas schema versions generate projects](ProjectLocationSchemaSchemaVersionGenerateCall) (request)
2025#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2026#[serde_with::serde_as]
2027#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2028pub struct GoogleCloudDocumentaiV1GenerateSchemaVersionRequest {
2029 /// The base schema version name to use for the schema generation. Format: `projects/{project}/locations/{location}/schemas/{schema}/schemaVersions/{schema_version}`
2030 #[serde(rename = "baseSchemaVersion")]
2031 pub base_schema_version: Option<String>,
2032 /// The set of documents placed on Cloud Storage.
2033 #[serde(rename = "gcsDocuments")]
2034 pub gcs_documents: Option<GoogleCloudDocumentaiV1GcsDocuments>,
2035 /// The common prefix of documents placed on Cloud Storage.
2036 #[serde(rename = "gcsPrefix")]
2037 pub gcs_prefix: Option<GoogleCloudDocumentaiV1GcsPrefix>,
2038 /// Optional. User specified parameters for the schema generation.
2039 #[serde(rename = "generateSchemaVersionParams")]
2040 pub generate_schema_version_params:
2041 Option<GoogleCloudDocumentaiV1GenerateSchemaVersionRequestGenerateSchemaVersionParams>,
2042 /// The set of documents specified inline. For each document, its `uri` or `content` field must be set.
2043 #[serde(rename = "inlineDocuments")]
2044 pub inline_documents: Option<GoogleCloudDocumentaiV1Documents>,
2045 /// The set of raw documents.
2046 #[serde(rename = "rawDocuments")]
2047 pub raw_documents: Option<GoogleCloudDocumentaiV1RawDocuments>,
2048}
2049
2050impl common::RequestValue for GoogleCloudDocumentaiV1GenerateSchemaVersionRequest {}
2051
2052/// The parameters for the schema generation.
2053///
2054/// This type is not used in any activity, and only used as *part* of another schema.
2055///
2056#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2057#[serde_with::serde_as]
2058#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2059pub struct GoogleCloudDocumentaiV1GenerateSchemaVersionRequestGenerateSchemaVersionParams {
2060 /// Optional. Previous prompt-answers in a chronological order.
2061 pub history: Option<GoogleCloudDocumentaiV1SchemaGenerationHistory>,
2062 /// Optional. The prompt used for the schema generation.
2063 pub prompt: Option<String>,
2064}
2065
2066impl common::Part
2067 for GoogleCloudDocumentaiV1GenerateSchemaVersionRequestGenerateSchemaVersionParams
2068{
2069}
2070
2071/// Response message for GenerateSchemaVersion.
2072///
2073/// # Activities
2074///
2075/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2076/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2077///
2078/// * [locations schemas schema versions generate projects](ProjectLocationSchemaSchemaVersionGenerateCall) (response)
2079#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2080#[serde_with::serde_as]
2081#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2082pub struct GoogleCloudDocumentaiV1GenerateSchemaVersionResponse {
2083 /// The schema version generated by the model.
2084 #[serde(rename = "schemaVersion")]
2085 pub schema_version: Option<GoogleCloudDocumentaiV1SchemaVersion>,
2086}
2087
2088impl common::ResponseResult for GoogleCloudDocumentaiV1GenerateSchemaVersionResponse {}
2089
2090/// The status of human review on a processed document.
2091///
2092/// This type is not used in any activity, and only used as *part* of another schema.
2093///
2094#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2095#[serde_with::serde_as]
2096#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2097pub struct GoogleCloudDocumentaiV1HumanReviewStatus {
2098 /// 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.
2099 #[serde(rename = "humanReviewOperation")]
2100 pub human_review_operation: Option<String>,
2101 /// The state of human review on the processing request.
2102 pub state: Option<String>,
2103 /// A message providing more details about the human review state.
2104 #[serde(rename = "stateMessage")]
2105 pub state_message: Option<String>,
2106}
2107
2108impl common::Part for GoogleCloudDocumentaiV1HumanReviewStatus {}
2109
2110/// The response from `ListEvaluations`.
2111///
2112/// # Activities
2113///
2114/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2115/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2116///
2117/// * [locations processors processor versions evaluations list projects](ProjectLocationProcessorProcessorVersionEvaluationListCall) (response)
2118#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2119#[serde_with::serde_as]
2120#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2121pub struct GoogleCloudDocumentaiV1ListEvaluationsResponse {
2122 /// The evaluations requested.
2123 pub evaluations: Option<Vec<GoogleCloudDocumentaiV1Evaluation>>,
2124 /// A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
2125 #[serde(rename = "nextPageToken")]
2126 pub next_page_token: Option<String>,
2127}
2128
2129impl common::ResponseResult for GoogleCloudDocumentaiV1ListEvaluationsResponse {}
2130
2131/// Response message for the ListProcessorTypes method.
2132///
2133/// # Activities
2134///
2135/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2136/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2137///
2138/// * [locations processor types list projects](ProjectLocationProcessorTypeListCall) (response)
2139#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2140#[serde_with::serde_as]
2141#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2142pub struct GoogleCloudDocumentaiV1ListProcessorTypesResponse {
2143 /// Points to the next page, otherwise empty.
2144 #[serde(rename = "nextPageToken")]
2145 pub next_page_token: Option<String>,
2146 /// The processor types.
2147 #[serde(rename = "processorTypes")]
2148 pub processor_types: Option<Vec<GoogleCloudDocumentaiV1ProcessorType>>,
2149}
2150
2151impl common::ResponseResult for GoogleCloudDocumentaiV1ListProcessorTypesResponse {}
2152
2153/// Response message for the ListProcessorVersions method.
2154///
2155/// # Activities
2156///
2157/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2158/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2159///
2160/// * [locations processors processor versions list projects](ProjectLocationProcessorProcessorVersionListCall) (response)
2161#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2162#[serde_with::serde_as]
2163#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2164pub struct GoogleCloudDocumentaiV1ListProcessorVersionsResponse {
2165 /// Points to the next processor, otherwise empty.
2166 #[serde(rename = "nextPageToken")]
2167 pub next_page_token: Option<String>,
2168 /// The list of processors.
2169 #[serde(rename = "processorVersions")]
2170 pub processor_versions: Option<Vec<GoogleCloudDocumentaiV1ProcessorVersion>>,
2171}
2172
2173impl common::ResponseResult for GoogleCloudDocumentaiV1ListProcessorVersionsResponse {}
2174
2175/// Response message for the ListProcessors method.
2176///
2177/// # Activities
2178///
2179/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2180/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2181///
2182/// * [locations processors list projects](ProjectLocationProcessorListCall) (response)
2183#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2184#[serde_with::serde_as]
2185#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2186pub struct GoogleCloudDocumentaiV1ListProcessorsResponse {
2187 /// Points to the next processor, otherwise empty.
2188 #[serde(rename = "nextPageToken")]
2189 pub next_page_token: Option<String>,
2190 /// The list of processors.
2191 pub processors: Option<Vec<GoogleCloudDocumentaiV1Processor>>,
2192}
2193
2194impl common::ResponseResult for GoogleCloudDocumentaiV1ListProcessorsResponse {}
2195
2196/// Response message for ListSchemaVersions.
2197///
2198/// # Activities
2199///
2200/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2201/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2202///
2203/// * [locations schemas schema versions list projects](ProjectLocationSchemaSchemaVersionListCall) (response)
2204#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2205#[serde_with::serde_as]
2206#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2207pub struct GoogleCloudDocumentaiV1ListSchemaVersionsResponse {
2208 /// Points to the next SchemaVersion, otherwise empty.
2209 #[serde(rename = "nextPageToken")]
2210 pub next_page_token: Option<String>,
2211 /// The list of SchemaVersions.
2212 #[serde(rename = "schemaVersions")]
2213 pub schema_versions: Option<Vec<GoogleCloudDocumentaiV1SchemaVersion>>,
2214}
2215
2216impl common::ResponseResult for GoogleCloudDocumentaiV1ListSchemaVersionsResponse {}
2217
2218/// Response message for ListSchemas.
2219///
2220/// # Activities
2221///
2222/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2223/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2224///
2225/// * [locations schemas list projects](ProjectLocationSchemaListCall) (response)
2226#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2227#[serde_with::serde_as]
2228#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2229pub struct GoogleCloudDocumentaiV1ListSchemasResponse {
2230 /// Points to the next Schema, otherwise empty.
2231 #[serde(rename = "nextPageToken")]
2232 pub next_page_token: Option<String>,
2233 /// The list of Schemas.
2234 pub schemas: Option<Vec<GoogleCloudDocumentaiV1NextSchema>>,
2235}
2236
2237impl common::ResponseResult for GoogleCloudDocumentaiV1ListSchemasResponse {}
2238
2239/// NextSchema is a collection of SchemaVersions.
2240///
2241/// # Activities
2242///
2243/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2244/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2245///
2246/// * [locations schemas create projects](ProjectLocationSchemaCreateCall) (request|response)
2247/// * [locations schemas get projects](ProjectLocationSchemaGetCall) (response)
2248/// * [locations schemas patch projects](ProjectLocationSchemaPatchCall) (request|response)
2249#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2250#[serde_with::serde_as]
2251#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2252pub struct GoogleCloudDocumentaiV1NextSchema {
2253 /// Output only. The time when the Schema was created.
2254 #[serde(rename = "createTime")]
2255 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2256 /// Required. The user-defined name of the Schema.
2257 #[serde(rename = "displayName")]
2258 pub display_name: Option<String>,
2259 /// Optional. The GCP labels for the Schema.
2260 pub labels: Option<HashMap<String, String>>,
2261 /// Identifier. The resource name of the Schema. Format: `projects/{project}/locations/{location}/schemas/{schema}`
2262 pub name: Option<String>,
2263 /// Output only. The time when the Schema was last updated.
2264 #[serde(rename = "updateTime")]
2265 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2266}
2267
2268impl common::RequestValue for GoogleCloudDocumentaiV1NextSchema {}
2269impl common::ResponseResult for GoogleCloudDocumentaiV1NextSchema {}
2270
2271/// 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.
2272///
2273/// This type is not used in any activity, and only used as *part* of another schema.
2274///
2275#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2276#[serde_with::serde_as]
2277#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2278pub struct GoogleCloudDocumentaiV1NormalizedVertex {
2279 /// X coordinate.
2280 pub x: Option<f32>,
2281 /// Y coordinate (starts from the top of the image).
2282 pub y: Option<f32>,
2283}
2284
2285impl common::Part for GoogleCloudDocumentaiV1NormalizedVertex {}
2286
2287/// Config for Document OCR.
2288///
2289/// This type is not used in any activity, and only used as *part* of another schema.
2290///
2291#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2292#[serde_with::serde_as]
2293#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2294pub struct GoogleCloudDocumentaiV1OcrConfig {
2295 /// 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.
2296 #[serde(rename = "advancedOcrOptions")]
2297 pub advanced_ocr_options: Option<Vec<String>>,
2298 /// Turn on font identification model and return font style information. Deprecated, use PremiumFeatures.compute_style_info instead.
2299 #[serde(rename = "computeStyleInfo")]
2300 pub compute_style_info: Option<bool>,
2301 /// Turn off character box detector in OCR engine. Character box detection is enabled by default in OCR 2.0 (and later) processors.
2302 #[serde(rename = "disableCharacterBoxesDetection")]
2303 pub disable_character_boxes_detection: Option<bool>,
2304 /// 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.
2305 #[serde(rename = "enableImageQualityScores")]
2306 pub enable_image_quality_scores: Option<bool>,
2307 /// Enables special handling for PDFs with existing text information. Results in better text extraction quality in such PDF inputs.
2308 #[serde(rename = "enableNativePdfParsing")]
2309 pub enable_native_pdf_parsing: Option<bool>,
2310 /// Includes symbol level OCR information if set to true.
2311 #[serde(rename = "enableSymbol")]
2312 pub enable_symbol: Option<bool>,
2313 /// Hints for the OCR model.
2314 pub hints: Option<GoogleCloudDocumentaiV1OcrConfigHints>,
2315 /// Configurations for premium OCR features.
2316 #[serde(rename = "premiumFeatures")]
2317 pub premium_features: Option<GoogleCloudDocumentaiV1OcrConfigPremiumFeatures>,
2318}
2319
2320impl common::Part for GoogleCloudDocumentaiV1OcrConfig {}
2321
2322/// Hints for OCR Engine
2323///
2324/// This type is not used in any activity, and only used as *part* of another schema.
2325///
2326#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2327#[serde_with::serde_as]
2328#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2329pub struct GoogleCloudDocumentaiV1OcrConfigHints {
2330 /// 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).
2331 #[serde(rename = "languageHints")]
2332 pub language_hints: Option<Vec<String>>,
2333}
2334
2335impl common::Part for GoogleCloudDocumentaiV1OcrConfigHints {}
2336
2337/// Configurations for premium OCR features.
2338///
2339/// This type is not used in any activity, and only used as *part* of another schema.
2340///
2341#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2342#[serde_with::serde_as]
2343#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2344pub struct GoogleCloudDocumentaiV1OcrConfigPremiumFeatures {
2345 /// Turn on font identification model and return font style information.
2346 #[serde(rename = "computeStyleInfo")]
2347 pub compute_style_info: Option<bool>,
2348 /// Turn on the model that can extract LaTeX math formulas.
2349 #[serde(rename = "enableMathOcr")]
2350 pub enable_math_ocr: Option<bool>,
2351 /// Turn on selection mark detector in OCR engine. Only available in OCR 2.0 (and later) processors.
2352 #[serde(rename = "enableSelectionMarkDetection")]
2353 pub enable_selection_mark_detection: Option<bool>,
2354}
2355
2356impl common::Part for GoogleCloudDocumentaiV1OcrConfigPremiumFeatures {}
2357
2358/// Options for Process API
2359///
2360/// This type is not used in any activity, and only used as *part* of another schema.
2361///
2362#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2363#[serde_with::serde_as]
2364#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2365pub struct GoogleCloudDocumentaiV1ProcessOptions {
2366 /// Only process certain pages from the end, same as above.
2367 #[serde(rename = "fromEnd")]
2368 pub from_end: Option<i32>,
2369 /// Only process certain pages from the start. Process all if the document has fewer pages.
2370 #[serde(rename = "fromStart")]
2371 pub from_start: Option<i32>,
2372 /// Which pages to process (1-indexed).
2373 #[serde(rename = "individualPageSelector")]
2374 pub individual_page_selector:
2375 Option<GoogleCloudDocumentaiV1ProcessOptionsIndividualPageSelector>,
2376 /// Optional. Only applicable to `LAYOUT_PARSER_PROCESSOR`. Returns error if set on other processor types.
2377 #[serde(rename = "layoutConfig")]
2378 pub layout_config: Option<GoogleCloudDocumentaiV1ProcessOptionsLayoutConfig>,
2379 /// Only applicable to `OCR_PROCESSOR` and `FORM_PARSER_PROCESSOR`. Returns error if set on other processor types.
2380 #[serde(rename = "ocrConfig")]
2381 pub ocr_config: Option<GoogleCloudDocumentaiV1OcrConfig>,
2382 /// 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.
2383 #[serde(rename = "schemaOverride")]
2384 pub schema_override: Option<GoogleCloudDocumentaiV1DocumentSchema>,
2385}
2386
2387impl common::Part for GoogleCloudDocumentaiV1ProcessOptions {}
2388
2389/// A list of individual page numbers.
2390///
2391/// This type is not used in any activity, and only used as *part* of another schema.
2392///
2393#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2394#[serde_with::serde_as]
2395#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2396pub struct GoogleCloudDocumentaiV1ProcessOptionsIndividualPageSelector {
2397 /// Optional. Indices of the pages (starting from 1).
2398 pub pages: Option<Vec<i32>>,
2399}
2400
2401impl common::Part for GoogleCloudDocumentaiV1ProcessOptionsIndividualPageSelector {}
2402
2403/// Serving config for layout parser processor.
2404///
2405/// This type is not used in any activity, and only used as *part* of another schema.
2406///
2407#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2408#[serde_with::serde_as]
2409#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2410pub struct GoogleCloudDocumentaiV1ProcessOptionsLayoutConfig {
2411 /// Optional. Config for chunking in layout parser processor.
2412 #[serde(rename = "chunkingConfig")]
2413 pub chunking_config: Option<GoogleCloudDocumentaiV1ProcessOptionsLayoutConfigChunkingConfig>,
2414 /// Optional. Whether to include image annotations in layout parser response.
2415 #[serde(rename = "enableImageAnnotation")]
2416 pub enable_image_annotation: Option<bool>,
2417 /// Optional. Whether to include table annotations in layout parser response.
2418 #[serde(rename = "enableTableAnnotation")]
2419 pub enable_table_annotation: Option<bool>,
2420 /// Optional. Whether to include bounding boxes in layout parser processor response.
2421 #[serde(rename = "returnBoundingBoxes")]
2422 pub return_bounding_boxes: Option<bool>,
2423 /// Optional. Whether to include images in layout parser processor response.
2424 #[serde(rename = "returnImages")]
2425 pub return_images: Option<bool>,
2426}
2427
2428impl common::Part for GoogleCloudDocumentaiV1ProcessOptionsLayoutConfig {}
2429
2430/// Serving config for chunking.
2431///
2432/// This type is not used in any activity, and only used as *part* of another schema.
2433///
2434#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2435#[serde_with::serde_as]
2436#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2437pub struct GoogleCloudDocumentaiV1ProcessOptionsLayoutConfigChunkingConfig {
2438 /// Optional. The chunk sizes to use when splitting documents, in order of level.
2439 #[serde(rename = "chunkSize")]
2440 pub chunk_size: Option<i32>,
2441 /// Optional. Whether or not to include ancestor headings when splitting.
2442 #[serde(rename = "includeAncestorHeadings")]
2443 pub include_ancestor_headings: Option<bool>,
2444}
2445
2446impl common::Part for GoogleCloudDocumentaiV1ProcessOptionsLayoutConfigChunkingConfig {}
2447
2448/// Request message for the ProcessDocument method.
2449///
2450/// # Activities
2451///
2452/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2453/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2454///
2455/// * [locations processors processor versions process projects](ProjectLocationProcessorProcessorVersionProcesCall) (request)
2456/// * [locations processors process projects](ProjectLocationProcessorProcesCall) (request)
2457#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2458#[serde_with::serde_as]
2459#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2460pub struct GoogleCloudDocumentaiV1ProcessRequest {
2461 /// 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}`.
2462 #[serde(rename = "fieldMask")]
2463 pub field_mask: Option<common::FieldMask>,
2464 /// A raw document on Google Cloud Storage.
2465 #[serde(rename = "gcsDocument")]
2466 pub gcs_document: Option<GoogleCloudDocumentaiV1GcsDocument>,
2467 /// Optional. Option to remove images from the document.
2468 #[serde(rename = "imagelessMode")]
2469 pub imageless_mode: Option<bool>,
2470 /// An inline document proto.
2471 #[serde(rename = "inlineDocument")]
2472 pub inline_document: Option<GoogleCloudDocumentaiV1Document>,
2473 /// 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.
2474 pub labels: Option<HashMap<String, String>>,
2475 /// Inference-time options for the process API
2476 #[serde(rename = "processOptions")]
2477 pub process_options: Option<GoogleCloudDocumentaiV1ProcessOptions>,
2478 /// A raw document content (bytes).
2479 #[serde(rename = "rawDocument")]
2480 pub raw_document: Option<GoogleCloudDocumentaiV1RawDocument>,
2481 /// Whether human review should be skipped for this request. Default to `false`.
2482 #[serde(rename = "skipHumanReview")]
2483 pub skip_human_review: Option<bool>,
2484}
2485
2486impl common::RequestValue for GoogleCloudDocumentaiV1ProcessRequest {}
2487
2488/// Response message for the ProcessDocument method.
2489///
2490/// # Activities
2491///
2492/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2493/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2494///
2495/// * [locations processors processor versions process projects](ProjectLocationProcessorProcessorVersionProcesCall) (response)
2496/// * [locations processors process projects](ProjectLocationProcessorProcesCall) (response)
2497#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2498#[serde_with::serde_as]
2499#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2500pub struct GoogleCloudDocumentaiV1ProcessResponse {
2501 /// The document payload, will populate fields based on the processor's behavior.
2502 pub document: Option<GoogleCloudDocumentaiV1Document>,
2503 /// The status of human review on the processed document.
2504 #[serde(rename = "humanReviewStatus")]
2505 pub human_review_status: Option<GoogleCloudDocumentaiV1HumanReviewStatus>,
2506}
2507
2508impl common::ResponseResult for GoogleCloudDocumentaiV1ProcessResponse {}
2509
2510/// The first-class citizen for Document AI. Each processor defines how to extract structural information from a document.
2511///
2512/// # Activities
2513///
2514/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2515/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2516///
2517/// * [locations processors create projects](ProjectLocationProcessorCreateCall) (request|response)
2518/// * [locations processors get projects](ProjectLocationProcessorGetCall) (response)
2519#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2520#[serde_with::serde_as]
2521#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2522pub struct GoogleCloudDocumentaiV1Processor {
2523 /// Optional. SchemaVersion used by the Processor. It is the same as Processor's DatasetSchema.schema_version Format is `projects/{project}/locations/{location}/schemas/{schema}/schemaVersions/{schema_version}
2524 #[serde(rename = "activeSchemaVersion")]
2525 pub active_schema_version: Option<String>,
2526 /// Output only. The time the processor was created.
2527 #[serde(rename = "createTime")]
2528 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2529 /// The default processor version.
2530 #[serde(rename = "defaultProcessorVersion")]
2531 pub default_processor_version: Option<String>,
2532 /// The display name of the processor.
2533 #[serde(rename = "displayName")]
2534 pub display_name: Option<String>,
2535 /// The [KMS key](https://cloud.google.com/security-key-management) used for encryption and decryption in CMEK scenarios.
2536 #[serde(rename = "kmsKeyName")]
2537 pub kms_key_name: Option<String>,
2538 /// Output only. Immutable. The resource name of the processor. Format: `projects/{project}/locations/{location}/processors/{processor}`
2539 pub name: Option<String>,
2540 /// Output only. Immutable. The http endpoint that can be called to invoke processing.
2541 #[serde(rename = "processEndpoint")]
2542 pub process_endpoint: Option<String>,
2543 /// Output only. The processor version aliases.
2544 #[serde(rename = "processorVersionAliases")]
2545 pub processor_version_aliases: Option<Vec<GoogleCloudDocumentaiV1ProcessorVersionAlias>>,
2546 /// Output only. Reserved for future use.
2547 #[serde(rename = "satisfiesPzi")]
2548 pub satisfies_pzi: Option<bool>,
2549 /// Output only. Reserved for future use.
2550 #[serde(rename = "satisfiesPzs")]
2551 pub satisfies_pzs: Option<bool>,
2552 /// Output only. The state of the processor.
2553 pub state: Option<String>,
2554 /// The processor type, such as: `OCR_PROCESSOR`, `INVOICE_PROCESSOR`. To get a list of processor types, see FetchProcessorTypes.
2555 #[serde(rename = "type")]
2556 pub type_: Option<String>,
2557}
2558
2559impl common::RequestValue for GoogleCloudDocumentaiV1Processor {}
2560impl common::ResponseResult for GoogleCloudDocumentaiV1Processor {}
2561
2562/// A processor type is responsible for performing a certain document understanding task on a certain type of document.
2563///
2564/// # Activities
2565///
2566/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2567/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2568///
2569/// * [locations processor types get projects](ProjectLocationProcessorTypeGetCall) (response)
2570#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2571#[serde_with::serde_as]
2572#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2573pub struct GoogleCloudDocumentaiV1ProcessorType {
2574 /// Whether the processor type allows creation. If true, users can create a processor of this processor type. Otherwise, users need to request access.
2575 #[serde(rename = "allowCreation")]
2576 pub allow_creation: Option<bool>,
2577 /// The locations in which this processor is available.
2578 #[serde(rename = "availableLocations")]
2579 pub available_locations: Option<Vec<GoogleCloudDocumentaiV1ProcessorTypeLocationInfo>>,
2580 /// The processor category, used by UI to group processor types.
2581 pub category: Option<String>,
2582 /// Launch stage of the processor type
2583 #[serde(rename = "launchStage")]
2584 pub launch_stage: Option<String>,
2585 /// The resource name of the processor type. Format: `projects/{project}/processorTypes/{processor_type}`
2586 pub name: Option<String>,
2587 /// A set of Cloud Storage URIs of sample documents for this processor.
2588 #[serde(rename = "sampleDocumentUris")]
2589 pub sample_document_uris: Option<Vec<String>>,
2590 /// The processor type, such as: `OCR_PROCESSOR`, `INVOICE_PROCESSOR`.
2591 #[serde(rename = "type")]
2592 pub type_: Option<String>,
2593}
2594
2595impl common::ResponseResult for GoogleCloudDocumentaiV1ProcessorType {}
2596
2597/// The location information about where the processor is available.
2598///
2599/// This type is not used in any activity, and only used as *part* of another schema.
2600///
2601#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2602#[serde_with::serde_as]
2603#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2604pub struct GoogleCloudDocumentaiV1ProcessorTypeLocationInfo {
2605 /// The location ID. For supported locations, refer to [regional and multi-regional support](https://cloud.google.com/document-ai/docs/regions).
2606 #[serde(rename = "locationId")]
2607 pub location_id: Option<String>,
2608}
2609
2610impl common::Part for GoogleCloudDocumentaiV1ProcessorTypeLocationInfo {}
2611
2612/// 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.
2613///
2614/// # Activities
2615///
2616/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2617/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2618///
2619/// * [locations processors processor versions get projects](ProjectLocationProcessorProcessorVersionGetCall) (response)
2620#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2621#[serde_with::serde_as]
2622#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2623pub struct GoogleCloudDocumentaiV1ProcessorVersion {
2624 /// Output only. The time the processor version was created.
2625 #[serde(rename = "createTime")]
2626 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2627 /// Output only. If set, information about the eventual deprecation of this version.
2628 #[serde(rename = "deprecationInfo")]
2629 pub deprecation_info: Option<GoogleCloudDocumentaiV1ProcessorVersionDeprecationInfo>,
2630 /// The display name of the processor version.
2631 #[serde(rename = "displayName")]
2632 pub display_name: Option<String>,
2633 /// Output only. The schema of the processor version. Describes the output.
2634 #[serde(rename = "documentSchema")]
2635 pub document_schema: Option<GoogleCloudDocumentaiV1DocumentSchema>,
2636 /// Output only. Information about Generative AI model-based processor versions.
2637 #[serde(rename = "genAiModelInfo")]
2638 pub gen_ai_model_info: Option<GoogleCloudDocumentaiV1ProcessorVersionGenAiModelInfo>,
2639 /// Output only. Denotes that this `ProcessorVersion` is managed by Google.
2640 #[serde(rename = "googleManaged")]
2641 pub google_managed: Option<bool>,
2642 /// Output only. The KMS key name used for encryption.
2643 #[serde(rename = "kmsKeyName")]
2644 pub kms_key_name: Option<String>,
2645 /// Output only. The KMS key version with which data is encrypted.
2646 #[serde(rename = "kmsKeyVersionName")]
2647 pub kms_key_version_name: Option<String>,
2648 /// Output only. The most recently invoked evaluation for the processor version.
2649 #[serde(rename = "latestEvaluation")]
2650 pub latest_evaluation: Option<GoogleCloudDocumentaiV1EvaluationReference>,
2651 /// Output only. The model type of this processor version.
2652 #[serde(rename = "modelType")]
2653 pub model_type: Option<String>,
2654 /// Identifier. The resource name of the processor version. Format: `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processor_version}`
2655 pub name: Option<String>,
2656 /// Output only. Reserved for future use.
2657 #[serde(rename = "satisfiesPzi")]
2658 pub satisfies_pzi: Option<bool>,
2659 /// Output only. Reserved for future use.
2660 #[serde(rename = "satisfiesPzs")]
2661 pub satisfies_pzs: Option<bool>,
2662 /// Output only. The state of the processor version.
2663 pub state: Option<String>,
2664}
2665
2666impl common::ResponseResult for GoogleCloudDocumentaiV1ProcessorVersion {}
2667
2668/// Contains the alias and the aliased resource name of processor version.
2669///
2670/// This type is not used in any activity, and only used as *part* of another schema.
2671///
2672#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2673#[serde_with::serde_as]
2674#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2675pub struct GoogleCloudDocumentaiV1ProcessorVersionAlias {
2676 /// The alias in the form of `processor_version` resource name.
2677 pub alias: Option<String>,
2678 /// The resource name of aliased processor version.
2679 #[serde(rename = "processorVersion")]
2680 pub processor_version: Option<String>,
2681}
2682
2683impl common::Part for GoogleCloudDocumentaiV1ProcessorVersionAlias {}
2684
2685/// Information about the upcoming deprecation of this processor version.
2686///
2687/// This type is not used in any activity, and only used as *part* of another schema.
2688///
2689#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2690#[serde_with::serde_as]
2691#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2692pub struct GoogleCloudDocumentaiV1ProcessorVersionDeprecationInfo {
2693 /// The time at which this processor version will be deprecated.
2694 #[serde(rename = "deprecationTime")]
2695 pub deprecation_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2696 /// If set, the processor version that will be used as a replacement.
2697 #[serde(rename = "replacementProcessorVersion")]
2698 pub replacement_processor_version: Option<String>,
2699}
2700
2701impl common::Part for GoogleCloudDocumentaiV1ProcessorVersionDeprecationInfo {}
2702
2703/// Information about Generative AI model-based processor versions.
2704///
2705/// This type is not used in any activity, and only used as *part* of another schema.
2706///
2707#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2708#[serde_with::serde_as]
2709#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2710pub struct GoogleCloudDocumentaiV1ProcessorVersionGenAiModelInfo {
2711 /// Information for a custom Generative AI model created by the user.
2712 #[serde(rename = "customGenAiModelInfo")]
2713 pub custom_gen_ai_model_info:
2714 Option<GoogleCloudDocumentaiV1ProcessorVersionGenAiModelInfoCustomGenAiModelInfo>,
2715 /// Information for a pretrained Google-managed foundation model.
2716 #[serde(rename = "foundationGenAiModelInfo")]
2717 pub foundation_gen_ai_model_info:
2718 Option<GoogleCloudDocumentaiV1ProcessorVersionGenAiModelInfoFoundationGenAiModelInfo>,
2719}
2720
2721impl common::Part for GoogleCloudDocumentaiV1ProcessorVersionGenAiModelInfo {}
2722
2723/// Information for a custom Generative AI model created by the user. These are created with `Create New Version` in either the `Call foundation model` or `Fine tuning` tabs.
2724///
2725/// This type is not used in any activity, and only used as *part* of another schema.
2726///
2727#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2728#[serde_with::serde_as]
2729#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2730pub struct GoogleCloudDocumentaiV1ProcessorVersionGenAiModelInfoCustomGenAiModelInfo {
2731 /// The base processor version ID for the custom model.
2732 #[serde(rename = "baseProcessorVersionId")]
2733 pub base_processor_version_id: Option<String>,
2734 /// The type of custom model created by the user.
2735 #[serde(rename = "customModelType")]
2736 pub custom_model_type: Option<String>,
2737}
2738
2739impl common::Part for GoogleCloudDocumentaiV1ProcessorVersionGenAiModelInfoCustomGenAiModelInfo {}
2740
2741/// Information for a pretrained Google-managed foundation model.
2742///
2743/// This type is not used in any activity, and only used as *part* of another schema.
2744///
2745#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2746#[serde_with::serde_as]
2747#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2748pub struct GoogleCloudDocumentaiV1ProcessorVersionGenAiModelInfoFoundationGenAiModelInfo {
2749 /// Whether finetuning is allowed for this base processor version.
2750 #[serde(rename = "finetuningAllowed")]
2751 pub finetuning_allowed: Option<bool>,
2752 /// The minimum number of labeled documents in the training dataset required for finetuning.
2753 #[serde(rename = "minTrainLabeledDocuments")]
2754 pub min_train_labeled_documents: Option<i32>,
2755}
2756
2757impl common::Part
2758 for GoogleCloudDocumentaiV1ProcessorVersionGenAiModelInfoFoundationGenAiModelInfo
2759{
2760}
2761
2762/// Payload message of raw document content (bytes).
2763///
2764/// This type is not used in any activity, and only used as *part* of another schema.
2765///
2766#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2767#[serde_with::serde_as]
2768#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2769pub struct GoogleCloudDocumentaiV1RawDocument {
2770 /// Inline document content.
2771 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2772 pub content: Option<Vec<u8>>,
2773 /// 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.
2774 #[serde(rename = "displayName")]
2775 pub display_name: Option<String>,
2776 /// An IANA MIME type (RFC6838) indicating the nature and format of the content.
2777 #[serde(rename = "mimeType")]
2778 pub mime_type: Option<String>,
2779}
2780
2781impl common::Part for GoogleCloudDocumentaiV1RawDocument {}
2782
2783/// Specifies a set of raw documents.
2784///
2785/// This type is not used in any activity, and only used as *part* of another schema.
2786///
2787#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2788#[serde_with::serde_as]
2789#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2790pub struct GoogleCloudDocumentaiV1RawDocuments {
2791 /// Specifies raw document content and mime type.
2792 pub documents: Option<Vec<GoogleCloudDocumentaiV1RawDocument>>,
2793}
2794
2795impl common::Part for GoogleCloudDocumentaiV1RawDocuments {}
2796
2797/// Request message for the ReviewDocument method.
2798///
2799/// # Activities
2800///
2801/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2802/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2803///
2804/// * [locations processors human review config review document projects](ProjectLocationProcessorHumanReviewConfigReviewDocumentCall) (request)
2805#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2806#[serde_with::serde_as]
2807#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2808pub struct GoogleCloudDocumentaiV1ReviewDocumentRequest {
2809 /// The document schema of the human review task.
2810 #[serde(rename = "documentSchema")]
2811 pub document_schema: Option<GoogleCloudDocumentaiV1DocumentSchema>,
2812 /// Whether the validation should be performed on the ad-hoc review request.
2813 #[serde(rename = "enableSchemaValidation")]
2814 pub enable_schema_validation: Option<bool>,
2815 /// An inline document proto.
2816 #[serde(rename = "inlineDocument")]
2817 pub inline_document: Option<GoogleCloudDocumentaiV1Document>,
2818 /// The priority of the human review task.
2819 pub priority: Option<String>,
2820}
2821
2822impl common::RequestValue for GoogleCloudDocumentaiV1ReviewDocumentRequest {}
2823
2824/// The history of schema generation iterations.
2825///
2826/// This type is not used in any activity, and only used as *part* of another schema.
2827///
2828#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2829#[serde_with::serde_as]
2830#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2831pub struct GoogleCloudDocumentaiV1SchemaGenerationHistory {
2832 /// Required. Previous prompt-answers in a chronological order.
2833 pub iterations: Option<Vec<GoogleCloudDocumentaiV1SchemaGenerationIteration>>,
2834}
2835
2836impl common::Part for GoogleCloudDocumentaiV1SchemaGenerationHistory {}
2837
2838/// A single iteration of the schema generation.
2839///
2840/// This type is not used in any activity, and only used as *part* of another schema.
2841///
2842#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2843#[serde_with::serde_as]
2844#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2845pub struct GoogleCloudDocumentaiV1SchemaGenerationIteration {
2846 /// Optional. The previous schema version adjusted by the model.
2847 #[serde(rename = "adjustedSchema")]
2848 pub adjusted_schema: Option<GoogleCloudDocumentaiV1SchemaVersion>,
2849 /// Required. The schema version generated by the model.
2850 #[serde(rename = "generatedSchema")]
2851 pub generated_schema: Option<GoogleCloudDocumentaiV1SchemaVersion>,
2852 /// Optional. The prompt used for the iteration.
2853 pub prompt: Option<String>,
2854}
2855
2856impl common::Part for GoogleCloudDocumentaiV1SchemaGenerationIteration {}
2857
2858/// SchemaVersion is a version of the Schema which is created in SchemaGroup.
2859///
2860/// # Activities
2861///
2862/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2863/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2864///
2865/// * [locations schemas schema versions create projects](ProjectLocationSchemaSchemaVersionCreateCall) (request|response)
2866/// * [locations schemas schema versions get projects](ProjectLocationSchemaSchemaVersionGetCall) (response)
2867/// * [locations schemas schema versions patch projects](ProjectLocationSchemaSchemaVersionPatchCall) (request|response)
2868#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2869#[serde_with::serde_as]
2870#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2871pub struct GoogleCloudDocumentaiV1SchemaVersion {
2872 /// Output only. The time when the SchemaVersion was created.
2873 #[serde(rename = "createTime")]
2874 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2875 /// Required. The user-defined name of the SchemaVersion.
2876 #[serde(rename = "displayName")]
2877 pub display_name: Option<String>,
2878 /// Optional. The GCP labels for the SchemaVersion.
2879 pub labels: Option<HashMap<String, String>>,
2880 /// Identifier. The resource name of the SchemaVersion. Format: `projects/{project}/locations/{location}/schemas/{schema}/schemaVersions/{schema_version}`
2881 pub name: Option<String>,
2882 /// Required. The schema of the SchemaVersion.
2883 pub schema: Option<GoogleCloudDocumentaiV1DocumentSchema>,
2884}
2885
2886impl common::RequestValue for GoogleCloudDocumentaiV1SchemaVersion {}
2887impl common::ResponseResult for GoogleCloudDocumentaiV1SchemaVersion {}
2888
2889/// Request message for the SetDefaultProcessorVersion method.
2890///
2891/// # Activities
2892///
2893/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2894/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2895///
2896/// * [locations processors set default processor version projects](ProjectLocationProcessorSetDefaultProcessorVersionCall) (request)
2897#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2898#[serde_with::serde_as]
2899#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2900pub struct GoogleCloudDocumentaiV1SetDefaultProcessorVersionRequest {
2901 /// Required. The resource name of child ProcessorVersion to use as default. Format: `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{version}`
2902 #[serde(rename = "defaultProcessorVersion")]
2903 pub default_processor_version: Option<String>,
2904}
2905
2906impl common::RequestValue for GoogleCloudDocumentaiV1SetDefaultProcessorVersionRequest {}
2907
2908/// Request message for the TrainProcessorVersion method.
2909///
2910/// # Activities
2911///
2912/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2913/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2914///
2915/// * [locations processors processor versions train projects](ProjectLocationProcessorProcessorVersionTrainCall) (request)
2916#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2917#[serde_with::serde_as]
2918#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2919pub struct GoogleCloudDocumentaiV1TrainProcessorVersionRequest {
2920 /// 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}`.
2921 #[serde(rename = "baseProcessorVersion")]
2922 pub base_processor_version: Option<String>,
2923 /// Options to control Custom Document Extraction (CDE) Processor.
2924 #[serde(rename = "customDocumentExtractionOptions")]
2925 pub custom_document_extraction_options:
2926 Option<GoogleCloudDocumentaiV1TrainProcessorVersionRequestCustomDocumentExtractionOptions>,
2927 /// Optional. The schema the processor version will be trained with.
2928 #[serde(rename = "documentSchema")]
2929 pub document_schema: Option<GoogleCloudDocumentaiV1DocumentSchema>,
2930 /// Options to control foundation model tuning of a processor.
2931 #[serde(rename = "foundationModelTuningOptions")]
2932 pub foundation_model_tuning_options:
2933 Option<GoogleCloudDocumentaiV1TrainProcessorVersionRequestFoundationModelTuningOptions>,
2934 /// Optional. The input data used to train the ProcessorVersion.
2935 #[serde(rename = "inputData")]
2936 pub input_data: Option<GoogleCloudDocumentaiV1TrainProcessorVersionRequestInputData>,
2937 /// Required. The processor version to be created.
2938 #[serde(rename = "processorVersion")]
2939 pub processor_version: Option<GoogleCloudDocumentaiV1ProcessorVersion>,
2940}
2941
2942impl common::RequestValue for GoogleCloudDocumentaiV1TrainProcessorVersionRequest {}
2943
2944/// Options to control the training of the Custom Document Extraction (CDE) Processor.
2945///
2946/// This type is not used in any activity, and only used as *part* of another schema.
2947///
2948#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2949#[serde_with::serde_as]
2950#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2951pub struct GoogleCloudDocumentaiV1TrainProcessorVersionRequestCustomDocumentExtractionOptions {
2952 /// Optional. Training method to use for CDE training.
2953 #[serde(rename = "trainingMethod")]
2954 pub training_method: Option<String>,
2955}
2956
2957impl common::Part
2958 for GoogleCloudDocumentaiV1TrainProcessorVersionRequestCustomDocumentExtractionOptions
2959{
2960}
2961
2962/// Options to control foundation model tuning of the processor.
2963///
2964/// This type is not used in any activity, and only used as *part* of another schema.
2965///
2966#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2967#[serde_with::serde_as]
2968#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2969pub struct GoogleCloudDocumentaiV1TrainProcessorVersionRequestFoundationModelTuningOptions {
2970 /// 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.
2971 #[serde(rename = "learningRateMultiplier")]
2972 pub learning_rate_multiplier: Option<f32>,
2973 /// 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.
2974 #[serde(rename = "trainSteps")]
2975 pub train_steps: Option<i32>,
2976}
2977
2978impl common::Part
2979 for GoogleCloudDocumentaiV1TrainProcessorVersionRequestFoundationModelTuningOptions
2980{
2981}
2982
2983/// The input data used to train a new ProcessorVersion.
2984///
2985/// This type is not used in any activity, and only used as *part* of another schema.
2986///
2987#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2988#[serde_with::serde_as]
2989#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2990pub struct GoogleCloudDocumentaiV1TrainProcessorVersionRequestInputData {
2991 /// The documents used for testing the trained version.
2992 #[serde(rename = "testDocuments")]
2993 pub test_documents: Option<GoogleCloudDocumentaiV1BatchDocumentsInputConfig>,
2994 /// The documents used for training the new version.
2995 #[serde(rename = "trainingDocuments")]
2996 pub training_documents: Option<GoogleCloudDocumentaiV1BatchDocumentsInputConfig>,
2997}
2998
2999impl common::Part for GoogleCloudDocumentaiV1TrainProcessorVersionRequestInputData {}
3000
3001/// Request message for the UndeployProcessorVersion method.
3002///
3003/// # Activities
3004///
3005/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3006/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3007///
3008/// * [locations processors processor versions undeploy projects](ProjectLocationProcessorProcessorVersionUndeployCall) (request)
3009#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3010#[serde_with::serde_as]
3011#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3012pub struct GoogleCloudDocumentaiV1UndeployProcessorVersionRequest {
3013 _never_set: Option<bool>,
3014}
3015
3016impl common::RequestValue for GoogleCloudDocumentaiV1UndeployProcessorVersionRequest {}
3017
3018/// A vertex represents a 2D point in the image. NOTE: the vertex coordinates are in the same scale as the original image.
3019///
3020/// This type is not used in any activity, and only used as *part* of another schema.
3021///
3022#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3023#[serde_with::serde_as]
3024#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3025pub struct GoogleCloudDocumentaiV1Vertex {
3026 /// X coordinate.
3027 pub x: Option<i32>,
3028 /// Y coordinate (starts from the top of the image).
3029 pub y: Option<i32>,
3030}
3031
3032impl common::Part for GoogleCloudDocumentaiV1Vertex {}
3033
3034/// The response message for Locations.ListLocations.
3035///
3036/// # Activities
3037///
3038/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3039/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3040///
3041/// * [locations list projects](ProjectLocationListCall) (response)
3042#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3043#[serde_with::serde_as]
3044#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3045pub struct GoogleCloudLocationListLocationsResponse {
3046 /// A list of locations that matches the specified filter in the request.
3047 pub locations: Option<Vec<GoogleCloudLocationLocation>>,
3048 /// The standard List next-page token.
3049 #[serde(rename = "nextPageToken")]
3050 pub next_page_token: Option<String>,
3051}
3052
3053impl common::ResponseResult for GoogleCloudLocationListLocationsResponse {}
3054
3055/// A resource that represents a Google Cloud location.
3056///
3057/// # Activities
3058///
3059/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3060/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3061///
3062/// * [locations get projects](ProjectLocationGetCall) (response)
3063#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3064#[serde_with::serde_as]
3065#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3066pub struct GoogleCloudLocationLocation {
3067 /// The friendly name for this location, typically a nearby city name. For example, "Tokyo".
3068 #[serde(rename = "displayName")]
3069 pub display_name: Option<String>,
3070 /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"}
3071 pub labels: Option<HashMap<String, String>>,
3072 /// The canonical id for this location. For example: `"us-east1"`.
3073 #[serde(rename = "locationId")]
3074 pub location_id: Option<String>,
3075 /// Service-specific metadata. For example the available capacity at the given location.
3076 pub metadata: Option<HashMap<String, serde_json::Value>>,
3077 /// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"`
3078 pub name: Option<String>,
3079}
3080
3081impl common::ResponseResult for GoogleCloudLocationLocation {}
3082
3083/// The response message for Operations.ListOperations.
3084///
3085/// # Activities
3086///
3087/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3088/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3089///
3090/// * [locations operations list projects](ProjectLocationOperationListCall) (response)
3091#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3092#[serde_with::serde_as]
3093#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3094pub struct GoogleLongrunningListOperationsResponse {
3095 /// The standard List next-page token.
3096 #[serde(rename = "nextPageToken")]
3097 pub next_page_token: Option<String>,
3098 /// A list of operations that matches the specified filter in the request.
3099 pub operations: Option<Vec<GoogleLongrunningOperation>>,
3100 /// Unordered list. Unreachable resources. Populated when the request sets `ListOperationsRequest.return_partial_success` and reads across collections. For example, when attempting to list all resources across all supported locations.
3101 pub unreachable: Option<Vec<String>>,
3102}
3103
3104impl common::ResponseResult for GoogleLongrunningListOperationsResponse {}
3105
3106/// This resource represents a long-running operation that is the result of a network API call.
3107///
3108/// # Activities
3109///
3110/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3111/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3112///
3113/// * [locations operations get projects](ProjectLocationOperationGetCall) (response)
3114/// * [locations processors human review config review document projects](ProjectLocationProcessorHumanReviewConfigReviewDocumentCall) (response)
3115/// * [locations processors processor versions batch process projects](ProjectLocationProcessorProcessorVersionBatchProcesCall) (response)
3116/// * [locations processors processor versions delete projects](ProjectLocationProcessorProcessorVersionDeleteCall) (response)
3117/// * [locations processors processor versions deploy projects](ProjectLocationProcessorProcessorVersionDeployCall) (response)
3118/// * [locations processors processor versions evaluate processor version projects](ProjectLocationProcessorProcessorVersionEvaluateProcessorVersionCall) (response)
3119/// * [locations processors processor versions train projects](ProjectLocationProcessorProcessorVersionTrainCall) (response)
3120/// * [locations processors processor versions undeploy projects](ProjectLocationProcessorProcessorVersionUndeployCall) (response)
3121/// * [locations processors batch process projects](ProjectLocationProcessorBatchProcesCall) (response)
3122/// * [locations processors delete projects](ProjectLocationProcessorDeleteCall) (response)
3123/// * [locations processors disable projects](ProjectLocationProcessorDisableCall) (response)
3124/// * [locations processors enable projects](ProjectLocationProcessorEnableCall) (response)
3125/// * [locations processors set default processor version projects](ProjectLocationProcessorSetDefaultProcessorVersionCall) (response)
3126/// * [locations schemas schema versions delete projects](ProjectLocationSchemaSchemaVersionDeleteCall) (response)
3127/// * [locations schemas delete projects](ProjectLocationSchemaDeleteCall) (response)
3128/// * [operations get projects](ProjectOperationGetCall) (response)
3129#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3130#[serde_with::serde_as]
3131#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3132pub struct GoogleLongrunningOperation {
3133 /// 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.
3134 pub done: Option<bool>,
3135 /// The error result of the operation in case of failure or cancellation.
3136 pub error: Option<GoogleRpcStatus>,
3137 /// 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.
3138 pub metadata: Option<HashMap<String, serde_json::Value>>,
3139 /// 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}`.
3140 pub name: Option<String>,
3141 /// 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`.
3142 pub response: Option<HashMap<String, serde_json::Value>>,
3143}
3144
3145impl common::ResponseResult for GoogleLongrunningOperation {}
3146
3147/// 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); }
3148///
3149/// # Activities
3150///
3151/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3152/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3153///
3154/// * [delete operations](OperationDeleteCall) (response)
3155/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (response)
3156#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3157#[serde_with::serde_as]
3158#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3159pub struct GoogleProtobufEmpty {
3160 _never_set: Option<bool>,
3161}
3162
3163impl common::ResponseResult for GoogleProtobufEmpty {}
3164
3165/// 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).
3166///
3167/// This type is not used in any activity, and only used as *part* of another schema.
3168///
3169#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3170#[serde_with::serde_as]
3171#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3172pub struct GoogleRpcStatus {
3173 /// The status code, which should be an enum value of google.rpc.Code.
3174 pub code: Option<i32>,
3175 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
3176 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
3177 /// 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.
3178 pub message: Option<String>,
3179}
3180
3181impl common::Part for GoogleRpcStatus {}
3182
3183/// 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(''); }; // ...
3184///
3185/// This type is not used in any activity, and only used as *part* of another schema.
3186///
3187#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3188#[serde_with::serde_as]
3189#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3190pub struct GoogleTypeColor {
3191 /// 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).
3192 pub alpha: Option<f32>,
3193 /// The amount of blue in the color as a value in the interval [0, 1].
3194 pub blue: Option<f32>,
3195 /// The amount of green in the color as a value in the interval [0, 1].
3196 pub green: Option<f32>,
3197 /// The amount of red in the color as a value in the interval [0, 1].
3198 pub red: Option<f32>,
3199}
3200
3201impl common::Part for GoogleTypeColor {}
3202
3203/// 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
3204///
3205/// This type is not used in any activity, and only used as *part* of another schema.
3206///
3207#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3208#[serde_with::serde_as]
3209#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3210pub struct GoogleTypeDate {
3211 /// 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.
3212 pub day: Option<i32>,
3213 /// Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
3214 pub month: Option<i32>,
3215 /// Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
3216 pub year: Option<i32>,
3217}
3218
3219impl common::Part for GoogleTypeDate {}
3220
3221/// 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.
3222///
3223/// This type is not used in any activity, and only used as *part* of another schema.
3224///
3225#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3226#[serde_with::serde_as]
3227#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3228pub struct GoogleTypeDateTime {
3229 /// 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.
3230 pub day: Option<i32>,
3231 /// 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.
3232 pub hours: Option<i32>,
3233 /// Optional. Minutes of hour of day. Must be from 0 to 59, defaults to 0.
3234 pub minutes: Option<i32>,
3235 /// Optional. Month of year. Must be from 1 to 12, or 0 if specifying a datetime without a month.
3236 pub month: Option<i32>,
3237 /// Optional. Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999, defaults to 0.
3238 pub nanos: Option<i32>,
3239 /// 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.
3240 pub seconds: Option<i32>,
3241 /// Time zone.
3242 #[serde(rename = "timeZone")]
3243 pub time_zone: Option<GoogleTypeTimeZone>,
3244 /// 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 }.
3245 #[serde(rename = "utcOffset")]
3246 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
3247 pub utc_offset: Option<chrono::Duration>,
3248 /// Optional. Year of date. Must be from 1 to 9999, or 0 if specifying a datetime without a year.
3249 pub year: Option<i32>,
3250}
3251
3252impl common::Part for GoogleTypeDateTime {}
3253
3254/// Represents an amount of money with its currency type.
3255///
3256/// This type is not used in any activity, and only used as *part* of another schema.
3257///
3258#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3259#[serde_with::serde_as]
3260#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3261pub struct GoogleTypeMoney {
3262 /// The three-letter currency code defined in ISO 4217.
3263 #[serde(rename = "currencyCode")]
3264 pub currency_code: Option<String>,
3265 /// 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.
3266 pub nanos: Option<i32>,
3267 /// The whole units of the amount. For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar.
3268 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
3269 pub units: Option<i64>,
3270}
3271
3272impl common::Part for GoogleTypeMoney {}
3273
3274/// Represents a postal address, such as for postal delivery or payments addresses. With a postal address, a postal service can deliver items to a premise, P.O. box, or similar. A postal address is not intended to model geographical locations like roads, towns, or mountains. In typical usage, an address would be created by user input or from importing existing data, depending on the type of process. Advice on address input or 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, see: https://support.google.com/business/answer/6397478.
3275///
3276/// This type is not used in any activity, and only used as *part* of another schema.
3277///
3278#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3279#[serde_with::serde_as]
3280#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3281pub struct GoogleTypePostalAddress {
3282 /// 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 (for example, "Austin, TX"), it is important that the line order is clear. The order of address lines should be "envelope order" for the country or region of the address. In places where this can vary (for example, Japan), `address_language` is used to make it explicit (for example, "ja" for large-to-small ordering and "ja-Latn" or "en" for small-to-large). In 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).
3283 #[serde(rename = "addressLines")]
3284 pub address_lines: Option<Vec<String>>,
3285 /// 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. For Spain, this is the province and not the autonomous community (for example, "Barcelona" and not "Catalonia"). Many countries don't use an administrative area in postal addresses. For example, in Switzerland, this should be left unpopulated.
3286 #[serde(rename = "administrativeArea")]
3287 pub administrative_area: Option<String>,
3288 /// 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".
3289 #[serde(rename = "languageCode")]
3290 pub language_code: Option<String>,
3291 /// Optional. Generally refers to the city or 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`.
3292 pub locality: Option<String>,
3293 /// Optional. The name of the organization at the address.
3294 pub organization: Option<String>,
3295 /// 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 (for example, state or zip code validation in the United States).
3296 #[serde(rename = "postalCode")]
3297 pub postal_code: Option<String>,
3298 /// Optional. The recipient at the address. This field may, under certain circumstances, contain multiline information. For example, it might contain "care of" information.
3299 pub recipients: Option<Vec<String>>,
3300 /// 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.
3301 #[serde(rename = "regionCode")]
3302 pub region_code: Option<String>,
3303 /// 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.
3304 pub revision: Option<i32>,
3305 /// 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 (for example, "CEDEX 7"), or just a number alone, representing the "sector code" (Jamaica), "delivery area indicator" (Malawi) or "post office indicator" (Côte d'Ivoire).
3306 #[serde(rename = "sortingCode")]
3307 pub sorting_code: Option<String>,
3308 /// Optional. Sublocality of the address. For example, this can be a neighborhood, borough, or district.
3309 pub sublocality: Option<String>,
3310}
3311
3312impl common::Part for GoogleTypePostalAddress {}
3313
3314/// Represents a time zone from the [IANA Time Zone Database](https://www.iana.org/time-zones).
3315///
3316/// This type is not used in any activity, and only used as *part* of another schema.
3317///
3318#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3319#[serde_with::serde_as]
3320#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3321pub struct GoogleTypeTimeZone {
3322 /// IANA Time Zone Database time zone. For example "America/New_York".
3323 pub id: Option<String>,
3324 /// Optional. IANA Time Zone Database version number. For example "2019a".
3325 pub version: Option<String>,
3326}
3327
3328impl common::Part for GoogleTypeTimeZone {}
3329
3330// ###################
3331// MethodBuilders ###
3332// #################
3333
3334/// A builder providing access to all methods supported on *operation* resources.
3335/// It is not used directly, but through the [`Document`] hub.
3336///
3337/// # Example
3338///
3339/// Instantiate a resource builder
3340///
3341/// ```test_harness,no_run
3342/// extern crate hyper;
3343/// extern crate hyper_rustls;
3344/// extern crate google_documentai1 as documentai1;
3345///
3346/// # async fn dox() {
3347/// use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3348///
3349/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3350/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3351/// .with_native_roots()
3352/// .unwrap()
3353/// .https_only()
3354/// .enable_http2()
3355/// .build();
3356///
3357/// let executor = hyper_util::rt::TokioExecutor::new();
3358/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3359/// secret,
3360/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3361/// yup_oauth2::client::CustomHyperClientBuilder::from(
3362/// hyper_util::client::legacy::Client::builder(executor).build(connector),
3363/// ),
3364/// ).build().await.unwrap();
3365///
3366/// let client = hyper_util::client::legacy::Client::builder(
3367/// hyper_util::rt::TokioExecutor::new()
3368/// )
3369/// .build(
3370/// hyper_rustls::HttpsConnectorBuilder::new()
3371/// .with_native_roots()
3372/// .unwrap()
3373/// .https_or_http()
3374/// .enable_http2()
3375/// .build()
3376/// );
3377/// let mut hub = Document::new(client, auth);
3378/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3379/// // like `delete(...)`
3380/// // to build up your call.
3381/// let rb = hub.operations();
3382/// # }
3383/// ```
3384pub struct OperationMethods<'a, C>
3385where
3386 C: 'a,
3387{
3388 hub: &'a Document<C>,
3389}
3390
3391impl<'a, C> common::MethodsBuilder for OperationMethods<'a, C> {}
3392
3393impl<'a, C> OperationMethods<'a, C> {
3394 /// Create a builder to help you perform the following task:
3395 ///
3396 /// 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`.
3397 ///
3398 /// # Arguments
3399 ///
3400 /// * `name` - The name of the operation resource to be deleted.
3401 pub fn delete(&self, name: &str) -> OperationDeleteCall<'a, C> {
3402 OperationDeleteCall {
3403 hub: self.hub,
3404 _name: name.to_string(),
3405 _delegate: Default::default(),
3406 _additional_params: Default::default(),
3407 _scopes: Default::default(),
3408 }
3409 }
3410}
3411
3412/// A builder providing access to all methods supported on *project* resources.
3413/// It is not used directly, but through the [`Document`] hub.
3414///
3415/// # Example
3416///
3417/// Instantiate a resource builder
3418///
3419/// ```test_harness,no_run
3420/// extern crate hyper;
3421/// extern crate hyper_rustls;
3422/// extern crate google_documentai1 as documentai1;
3423///
3424/// # async fn dox() {
3425/// use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3426///
3427/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3428/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3429/// .with_native_roots()
3430/// .unwrap()
3431/// .https_only()
3432/// .enable_http2()
3433/// .build();
3434///
3435/// let executor = hyper_util::rt::TokioExecutor::new();
3436/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3437/// secret,
3438/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3439/// yup_oauth2::client::CustomHyperClientBuilder::from(
3440/// hyper_util::client::legacy::Client::builder(executor).build(connector),
3441/// ),
3442/// ).build().await.unwrap();
3443///
3444/// let client = hyper_util::client::legacy::Client::builder(
3445/// hyper_util::rt::TokioExecutor::new()
3446/// )
3447/// .build(
3448/// hyper_rustls::HttpsConnectorBuilder::new()
3449/// .with_native_roots()
3450/// .unwrap()
3451/// .https_or_http()
3452/// .enable_http2()
3453/// .build()
3454/// );
3455/// let mut hub = Document::new(client, auth);
3456/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3457/// // 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(...)`, `locations_schemas_create(...)`, `locations_schemas_delete(...)`, `locations_schemas_get(...)`, `locations_schemas_list(...)`, `locations_schemas_patch(...)`, `locations_schemas_schema_versions_create(...)`, `locations_schemas_schema_versions_delete(...)`, `locations_schemas_schema_versions_generate(...)`, `locations_schemas_schema_versions_get(...)`, `locations_schemas_schema_versions_list(...)`, `locations_schemas_schema_versions_patch(...)` and `operations_get(...)`
3458/// // to build up your call.
3459/// let rb = hub.projects();
3460/// # }
3461/// ```
3462pub struct ProjectMethods<'a, C>
3463where
3464 C: 'a,
3465{
3466 hub: &'a Document<C>,
3467}
3468
3469impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
3470
3471impl<'a, C> ProjectMethods<'a, C> {
3472 /// Create a builder to help you perform the following task:
3473 ///
3474 /// 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`.
3475 ///
3476 /// # Arguments
3477 ///
3478 /// * `name` - The name of the operation resource to be cancelled.
3479 pub fn locations_operations_cancel(
3480 &self,
3481 name: &str,
3482 ) -> ProjectLocationOperationCancelCall<'a, C> {
3483 ProjectLocationOperationCancelCall {
3484 hub: self.hub,
3485 _name: name.to_string(),
3486 _delegate: Default::default(),
3487 _additional_params: Default::default(),
3488 _scopes: Default::default(),
3489 }
3490 }
3491
3492 /// Create a builder to help you perform the following task:
3493 ///
3494 /// 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.
3495 ///
3496 /// # Arguments
3497 ///
3498 /// * `name` - The name of the operation resource.
3499 pub fn locations_operations_get(&self, name: &str) -> ProjectLocationOperationGetCall<'a, C> {
3500 ProjectLocationOperationGetCall {
3501 hub: self.hub,
3502 _name: name.to_string(),
3503 _delegate: Default::default(),
3504 _additional_params: Default::default(),
3505 _scopes: Default::default(),
3506 }
3507 }
3508
3509 /// Create a builder to help you perform the following task:
3510 ///
3511 /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
3512 ///
3513 /// # Arguments
3514 ///
3515 /// * `name` - The name of the operation's parent resource.
3516 pub fn locations_operations_list(&self, name: &str) -> ProjectLocationOperationListCall<'a, C> {
3517 ProjectLocationOperationListCall {
3518 hub: self.hub,
3519 _name: name.to_string(),
3520 _return_partial_success: Default::default(),
3521 _page_token: Default::default(),
3522 _page_size: Default::default(),
3523 _filter: Default::default(),
3524 _delegate: Default::default(),
3525 _additional_params: Default::default(),
3526 _scopes: Default::default(),
3527 }
3528 }
3529
3530 /// Create a builder to help you perform the following task:
3531 ///
3532 /// Gets a processor type detail.
3533 ///
3534 /// # Arguments
3535 ///
3536 /// * `name` - Required. The processor type resource name.
3537 pub fn locations_processor_types_get(
3538 &self,
3539 name: &str,
3540 ) -> ProjectLocationProcessorTypeGetCall<'a, C> {
3541 ProjectLocationProcessorTypeGetCall {
3542 hub: self.hub,
3543 _name: name.to_string(),
3544 _delegate: Default::default(),
3545 _additional_params: Default::default(),
3546 _scopes: Default::default(),
3547 }
3548 }
3549
3550 /// Create a builder to help you perform the following task:
3551 ///
3552 /// Lists the processor types that exist.
3553 ///
3554 /// # Arguments
3555 ///
3556 /// * `parent` - Required. The location of processor types to list. Format: `projects/{project}/locations/{location}`.
3557 pub fn locations_processor_types_list(
3558 &self,
3559 parent: &str,
3560 ) -> ProjectLocationProcessorTypeListCall<'a, C> {
3561 ProjectLocationProcessorTypeListCall {
3562 hub: self.hub,
3563 _parent: parent.to_string(),
3564 _page_token: Default::default(),
3565 _page_size: Default::default(),
3566 _delegate: Default::default(),
3567 _additional_params: Default::default(),
3568 _scopes: Default::default(),
3569 }
3570 }
3571
3572 /// Create a builder to help you perform the following task:
3573 ///
3574 /// Send a document for Human Review. The input document should be processed by the specified processor.
3575 ///
3576 /// # Arguments
3577 ///
3578 /// * `request` - No description provided.
3579 /// * `humanReviewConfig` - Required. The resource name of the HumanReviewConfig that the document will be reviewed with.
3580 pub fn locations_processors_human_review_config_review_document(
3581 &self,
3582 request: GoogleCloudDocumentaiV1ReviewDocumentRequest,
3583 human_review_config: &str,
3584 ) -> ProjectLocationProcessorHumanReviewConfigReviewDocumentCall<'a, C> {
3585 ProjectLocationProcessorHumanReviewConfigReviewDocumentCall {
3586 hub: self.hub,
3587 _request: request,
3588 _human_review_config: human_review_config.to_string(),
3589 _delegate: Default::default(),
3590 _additional_params: Default::default(),
3591 _scopes: Default::default(),
3592 }
3593 }
3594
3595 /// Create a builder to help you perform the following task:
3596 ///
3597 /// Retrieves a specific evaluation.
3598 ///
3599 /// # Arguments
3600 ///
3601 /// * `name` - Required. The resource name of the Evaluation to get. `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}/evaluations/{evaluation}`
3602 pub fn locations_processors_processor_versions_evaluations_get(
3603 &self,
3604 name: &str,
3605 ) -> ProjectLocationProcessorProcessorVersionEvaluationGetCall<'a, C> {
3606 ProjectLocationProcessorProcessorVersionEvaluationGetCall {
3607 hub: self.hub,
3608 _name: name.to_string(),
3609 _delegate: Default::default(),
3610 _additional_params: Default::default(),
3611 _scopes: Default::default(),
3612 }
3613 }
3614
3615 /// Create a builder to help you perform the following task:
3616 ///
3617 /// Retrieves a set of evaluations for a given processor version.
3618 ///
3619 /// # Arguments
3620 ///
3621 /// * `parent` - Required. The resource name of the ProcessorVersion to list evaluations for. `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`
3622 pub fn locations_processors_processor_versions_evaluations_list(
3623 &self,
3624 parent: &str,
3625 ) -> ProjectLocationProcessorProcessorVersionEvaluationListCall<'a, C> {
3626 ProjectLocationProcessorProcessorVersionEvaluationListCall {
3627 hub: self.hub,
3628 _parent: parent.to_string(),
3629 _page_token: Default::default(),
3630 _page_size: Default::default(),
3631 _delegate: Default::default(),
3632 _additional_params: Default::default(),
3633 _scopes: Default::default(),
3634 }
3635 }
3636
3637 /// Create a builder to help you perform the following task:
3638 ///
3639 /// LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in the [Document] format.
3640 ///
3641 /// # Arguments
3642 ///
3643 /// * `request` - No description provided.
3644 /// * `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}`
3645 pub fn locations_processors_processor_versions_batch_process(
3646 &self,
3647 request: GoogleCloudDocumentaiV1BatchProcessRequest,
3648 name: &str,
3649 ) -> ProjectLocationProcessorProcessorVersionBatchProcesCall<'a, C> {
3650 ProjectLocationProcessorProcessorVersionBatchProcesCall {
3651 hub: self.hub,
3652 _request: request,
3653 _name: name.to_string(),
3654 _delegate: Default::default(),
3655 _additional_params: Default::default(),
3656 _scopes: Default::default(),
3657 }
3658 }
3659
3660 /// Create a builder to help you perform the following task:
3661 ///
3662 /// Deletes the processor version, all artifacts under the processor version will be deleted.
3663 ///
3664 /// # Arguments
3665 ///
3666 /// * `name` - Required. The processor version resource name to be deleted.
3667 pub fn locations_processors_processor_versions_delete(
3668 &self,
3669 name: &str,
3670 ) -> ProjectLocationProcessorProcessorVersionDeleteCall<'a, C> {
3671 ProjectLocationProcessorProcessorVersionDeleteCall {
3672 hub: self.hub,
3673 _name: name.to_string(),
3674 _delegate: Default::default(),
3675 _additional_params: Default::default(),
3676 _scopes: Default::default(),
3677 }
3678 }
3679
3680 /// Create a builder to help you perform the following task:
3681 ///
3682 /// Deploys the processor version.
3683 ///
3684 /// # Arguments
3685 ///
3686 /// * `request` - No description provided.
3687 /// * `name` - Required. The processor version resource name to be deployed.
3688 pub fn locations_processors_processor_versions_deploy(
3689 &self,
3690 request: GoogleCloudDocumentaiV1DeployProcessorVersionRequest,
3691 name: &str,
3692 ) -> ProjectLocationProcessorProcessorVersionDeployCall<'a, C> {
3693 ProjectLocationProcessorProcessorVersionDeployCall {
3694 hub: self.hub,
3695 _request: request,
3696 _name: name.to_string(),
3697 _delegate: Default::default(),
3698 _additional_params: Default::default(),
3699 _scopes: Default::default(),
3700 }
3701 }
3702
3703 /// Create a builder to help you perform the following task:
3704 ///
3705 /// Evaluates a ProcessorVersion against annotated documents, producing an Evaluation.
3706 ///
3707 /// # Arguments
3708 ///
3709 /// * `request` - No description provided.
3710 /// * `processorVersion` - Required. The resource name of the ProcessorVersion to evaluate. `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`
3711 pub fn locations_processors_processor_versions_evaluate_processor_version(
3712 &self,
3713 request: GoogleCloudDocumentaiV1EvaluateProcessorVersionRequest,
3714 processor_version: &str,
3715 ) -> ProjectLocationProcessorProcessorVersionEvaluateProcessorVersionCall<'a, C> {
3716 ProjectLocationProcessorProcessorVersionEvaluateProcessorVersionCall {
3717 hub: self.hub,
3718 _request: request,
3719 _processor_version: processor_version.to_string(),
3720 _delegate: Default::default(),
3721 _additional_params: Default::default(),
3722 _scopes: Default::default(),
3723 }
3724 }
3725
3726 /// Create a builder to help you perform the following task:
3727 ///
3728 /// Gets a processor version detail.
3729 ///
3730 /// # Arguments
3731 ///
3732 /// * `name` - Required. The processor resource name.
3733 pub fn locations_processors_processor_versions_get(
3734 &self,
3735 name: &str,
3736 ) -> ProjectLocationProcessorProcessorVersionGetCall<'a, C> {
3737 ProjectLocationProcessorProcessorVersionGetCall {
3738 hub: self.hub,
3739 _name: name.to_string(),
3740 _delegate: Default::default(),
3741 _additional_params: Default::default(),
3742 _scopes: Default::default(),
3743 }
3744 }
3745
3746 /// Create a builder to help you perform the following task:
3747 ///
3748 /// Lists all versions of a processor.
3749 ///
3750 /// # Arguments
3751 ///
3752 /// * `parent` - Required. The parent (project, location and processor) to list all versions. Format: `projects/{project}/locations/{location}/processors/{processor}`
3753 pub fn locations_processors_processor_versions_list(
3754 &self,
3755 parent: &str,
3756 ) -> ProjectLocationProcessorProcessorVersionListCall<'a, C> {
3757 ProjectLocationProcessorProcessorVersionListCall {
3758 hub: self.hub,
3759 _parent: parent.to_string(),
3760 _page_token: Default::default(),
3761 _page_size: Default::default(),
3762 _delegate: Default::default(),
3763 _additional_params: Default::default(),
3764 _scopes: Default::default(),
3765 }
3766 }
3767
3768 /// Create a builder to help you perform the following task:
3769 ///
3770 /// Processes a single document.
3771 ///
3772 /// # Arguments
3773 ///
3774 /// * `request` - No description provided.
3775 /// * `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}`
3776 pub fn locations_processors_processor_versions_process(
3777 &self,
3778 request: GoogleCloudDocumentaiV1ProcessRequest,
3779 name: &str,
3780 ) -> ProjectLocationProcessorProcessorVersionProcesCall<'a, C> {
3781 ProjectLocationProcessorProcessorVersionProcesCall {
3782 hub: self.hub,
3783 _request: request,
3784 _name: name.to_string(),
3785 _delegate: Default::default(),
3786 _additional_params: Default::default(),
3787 _scopes: Default::default(),
3788 }
3789 }
3790
3791 /// Create a builder to help you perform the following task:
3792 ///
3793 /// Trains a new processor version. Operation metadata is returned as TrainProcessorVersionMetadata.
3794 ///
3795 /// # Arguments
3796 ///
3797 /// * `request` - No description provided.
3798 /// * `parent` - Required. The parent (project, location and processor) to create the new version for. Format: `projects/{project}/locations/{location}/processors/{processor}`.
3799 pub fn locations_processors_processor_versions_train(
3800 &self,
3801 request: GoogleCloudDocumentaiV1TrainProcessorVersionRequest,
3802 parent: &str,
3803 ) -> ProjectLocationProcessorProcessorVersionTrainCall<'a, C> {
3804 ProjectLocationProcessorProcessorVersionTrainCall {
3805 hub: self.hub,
3806 _request: request,
3807 _parent: parent.to_string(),
3808 _delegate: Default::default(),
3809 _additional_params: Default::default(),
3810 _scopes: Default::default(),
3811 }
3812 }
3813
3814 /// Create a builder to help you perform the following task:
3815 ///
3816 /// Undeploys the processor version.
3817 ///
3818 /// # Arguments
3819 ///
3820 /// * `request` - No description provided.
3821 /// * `name` - Required. The processor version resource name to be undeployed.
3822 pub fn locations_processors_processor_versions_undeploy(
3823 &self,
3824 request: GoogleCloudDocumentaiV1UndeployProcessorVersionRequest,
3825 name: &str,
3826 ) -> ProjectLocationProcessorProcessorVersionUndeployCall<'a, C> {
3827 ProjectLocationProcessorProcessorVersionUndeployCall {
3828 hub: self.hub,
3829 _request: request,
3830 _name: name.to_string(),
3831 _delegate: Default::default(),
3832 _additional_params: Default::default(),
3833 _scopes: Default::default(),
3834 }
3835 }
3836
3837 /// Create a builder to help you perform the following task:
3838 ///
3839 /// LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in the [Document] format.
3840 ///
3841 /// # Arguments
3842 ///
3843 /// * `request` - No description provided.
3844 /// * `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}`
3845 pub fn locations_processors_batch_process(
3846 &self,
3847 request: GoogleCloudDocumentaiV1BatchProcessRequest,
3848 name: &str,
3849 ) -> ProjectLocationProcessorBatchProcesCall<'a, C> {
3850 ProjectLocationProcessorBatchProcesCall {
3851 hub: self.hub,
3852 _request: request,
3853 _name: name.to_string(),
3854 _delegate: Default::default(),
3855 _additional_params: Default::default(),
3856 _scopes: Default::default(),
3857 }
3858 }
3859
3860 /// Create a builder to help you perform the following task:
3861 ///
3862 /// 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.
3863 ///
3864 /// # Arguments
3865 ///
3866 /// * `request` - No description provided.
3867 /// * `parent` - Required. The parent (project and location) under which to create the processor. Format: `projects/{project}/locations/{location}`
3868 pub fn locations_processors_create(
3869 &self,
3870 request: GoogleCloudDocumentaiV1Processor,
3871 parent: &str,
3872 ) -> ProjectLocationProcessorCreateCall<'a, C> {
3873 ProjectLocationProcessorCreateCall {
3874 hub: self.hub,
3875 _request: request,
3876 _parent: parent.to_string(),
3877 _delegate: Default::default(),
3878 _additional_params: Default::default(),
3879 _scopes: Default::default(),
3880 }
3881 }
3882
3883 /// Create a builder to help you perform the following task:
3884 ///
3885 /// Deletes the processor, unloads all deployed model artifacts if it was enabled and then deletes all artifacts associated with this processor.
3886 ///
3887 /// # Arguments
3888 ///
3889 /// * `name` - Required. The processor resource name to be deleted.
3890 pub fn locations_processors_delete(
3891 &self,
3892 name: &str,
3893 ) -> ProjectLocationProcessorDeleteCall<'a, C> {
3894 ProjectLocationProcessorDeleteCall {
3895 hub: self.hub,
3896 _name: name.to_string(),
3897 _delegate: Default::default(),
3898 _additional_params: Default::default(),
3899 _scopes: Default::default(),
3900 }
3901 }
3902
3903 /// Create a builder to help you perform the following task:
3904 ///
3905 /// Disables a processor
3906 ///
3907 /// # Arguments
3908 ///
3909 /// * `request` - No description provided.
3910 /// * `name` - Required. The processor resource name to be disabled.
3911 pub fn locations_processors_disable(
3912 &self,
3913 request: GoogleCloudDocumentaiV1DisableProcessorRequest,
3914 name: &str,
3915 ) -> ProjectLocationProcessorDisableCall<'a, C> {
3916 ProjectLocationProcessorDisableCall {
3917 hub: self.hub,
3918 _request: request,
3919 _name: name.to_string(),
3920 _delegate: Default::default(),
3921 _additional_params: Default::default(),
3922 _scopes: Default::default(),
3923 }
3924 }
3925
3926 /// Create a builder to help you perform the following task:
3927 ///
3928 /// Enables a processor
3929 ///
3930 /// # Arguments
3931 ///
3932 /// * `request` - No description provided.
3933 /// * `name` - Required. The processor resource name to be enabled.
3934 pub fn locations_processors_enable(
3935 &self,
3936 request: GoogleCloudDocumentaiV1EnableProcessorRequest,
3937 name: &str,
3938 ) -> ProjectLocationProcessorEnableCall<'a, C> {
3939 ProjectLocationProcessorEnableCall {
3940 hub: self.hub,
3941 _request: request,
3942 _name: name.to_string(),
3943 _delegate: Default::default(),
3944 _additional_params: Default::default(),
3945 _scopes: Default::default(),
3946 }
3947 }
3948
3949 /// Create a builder to help you perform the following task:
3950 ///
3951 /// Gets a processor detail.
3952 ///
3953 /// # Arguments
3954 ///
3955 /// * `name` - Required. The processor resource name.
3956 pub fn locations_processors_get(&self, name: &str) -> ProjectLocationProcessorGetCall<'a, C> {
3957 ProjectLocationProcessorGetCall {
3958 hub: self.hub,
3959 _name: name.to_string(),
3960 _delegate: Default::default(),
3961 _additional_params: Default::default(),
3962 _scopes: Default::default(),
3963 }
3964 }
3965
3966 /// Create a builder to help you perform the following task:
3967 ///
3968 /// Lists all processors which belong to this project.
3969 ///
3970 /// # Arguments
3971 ///
3972 /// * `parent` - Required. The parent (project and location) which owns this collection of Processors. Format: `projects/{project}/locations/{location}`
3973 pub fn locations_processors_list(
3974 &self,
3975 parent: &str,
3976 ) -> ProjectLocationProcessorListCall<'a, C> {
3977 ProjectLocationProcessorListCall {
3978 hub: self.hub,
3979 _parent: parent.to_string(),
3980 _page_token: Default::default(),
3981 _page_size: Default::default(),
3982 _delegate: Default::default(),
3983 _additional_params: Default::default(),
3984 _scopes: Default::default(),
3985 }
3986 }
3987
3988 /// Create a builder to help you perform the following task:
3989 ///
3990 /// Processes a single document.
3991 ///
3992 /// # Arguments
3993 ///
3994 /// * `request` - No description provided.
3995 /// * `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}`
3996 pub fn locations_processors_process(
3997 &self,
3998 request: GoogleCloudDocumentaiV1ProcessRequest,
3999 name: &str,
4000 ) -> ProjectLocationProcessorProcesCall<'a, C> {
4001 ProjectLocationProcessorProcesCall {
4002 hub: self.hub,
4003 _request: request,
4004 _name: name.to_string(),
4005 _delegate: Default::default(),
4006 _additional_params: Default::default(),
4007 _scopes: Default::default(),
4008 }
4009 }
4010
4011 /// Create a builder to help you perform the following task:
4012 ///
4013 /// Set the default (active) version of a Processor that will be used in ProcessDocument and BatchProcessDocuments.
4014 ///
4015 /// # Arguments
4016 ///
4017 /// * `request` - No description provided.
4018 /// * `processor` - Required. The resource name of the Processor to change default version.
4019 pub fn locations_processors_set_default_processor_version(
4020 &self,
4021 request: GoogleCloudDocumentaiV1SetDefaultProcessorVersionRequest,
4022 processor: &str,
4023 ) -> ProjectLocationProcessorSetDefaultProcessorVersionCall<'a, C> {
4024 ProjectLocationProcessorSetDefaultProcessorVersionCall {
4025 hub: self.hub,
4026 _request: request,
4027 _processor: processor.to_string(),
4028 _delegate: Default::default(),
4029 _additional_params: Default::default(),
4030 _scopes: Default::default(),
4031 }
4032 }
4033
4034 /// Create a builder to help you perform the following task:
4035 ///
4036 /// Creates a schema version.
4037 ///
4038 /// # Arguments
4039 ///
4040 /// * `request` - No description provided.
4041 /// * `parent` - Required. The parent (project and location) under which to create the SchemaVersion. Format: `projects/{project}/locations/{location}/schemas/{schema}`
4042 pub fn locations_schemas_schema_versions_create(
4043 &self,
4044 request: GoogleCloudDocumentaiV1SchemaVersion,
4045 parent: &str,
4046 ) -> ProjectLocationSchemaSchemaVersionCreateCall<'a, C> {
4047 ProjectLocationSchemaSchemaVersionCreateCall {
4048 hub: self.hub,
4049 _request: request,
4050 _parent: parent.to_string(),
4051 _delegate: Default::default(),
4052 _additional_params: Default::default(),
4053 _scopes: Default::default(),
4054 }
4055 }
4056
4057 /// Create a builder to help you perform the following task:
4058 ///
4059 /// Deletes a schema version.
4060 ///
4061 /// # Arguments
4062 ///
4063 /// * `name` - Required. The name of the SchemaVersion to delete. Format: `projects/{project}/locations/{location}/schemas/{schema}/schemaVersions/{schema_version}`
4064 pub fn locations_schemas_schema_versions_delete(
4065 &self,
4066 name: &str,
4067 ) -> ProjectLocationSchemaSchemaVersionDeleteCall<'a, C> {
4068 ProjectLocationSchemaSchemaVersionDeleteCall {
4069 hub: self.hub,
4070 _name: name.to_string(),
4071 _delegate: Default::default(),
4072 _additional_params: Default::default(),
4073 _scopes: Default::default(),
4074 }
4075 }
4076
4077 /// Create a builder to help you perform the following task:
4078 ///
4079 /// Generates a schema version.
4080 ///
4081 /// # Arguments
4082 ///
4083 /// * `request` - No description provided.
4084 /// * `parent` - Required. The parent (project, location and schema) under which to generate the SchemaVersion. Format: `projects/{project}/locations/{location}/schemas/{schema}`
4085 pub fn locations_schemas_schema_versions_generate(
4086 &self,
4087 request: GoogleCloudDocumentaiV1GenerateSchemaVersionRequest,
4088 parent: &str,
4089 ) -> ProjectLocationSchemaSchemaVersionGenerateCall<'a, C> {
4090 ProjectLocationSchemaSchemaVersionGenerateCall {
4091 hub: self.hub,
4092 _request: request,
4093 _parent: parent.to_string(),
4094 _delegate: Default::default(),
4095 _additional_params: Default::default(),
4096 _scopes: Default::default(),
4097 }
4098 }
4099
4100 /// Create a builder to help you perform the following task:
4101 ///
4102 /// Gets a schema version.
4103 ///
4104 /// # Arguments
4105 ///
4106 /// * `name` - Required. The name of the SchemaVersion to get. Format: `projects/{project}/locations/{location}/schemas/{schema}/schemaVersions/{schema_version}`
4107 pub fn locations_schemas_schema_versions_get(
4108 &self,
4109 name: &str,
4110 ) -> ProjectLocationSchemaSchemaVersionGetCall<'a, C> {
4111 ProjectLocationSchemaSchemaVersionGetCall {
4112 hub: self.hub,
4113 _name: name.to_string(),
4114 _delegate: Default::default(),
4115 _additional_params: Default::default(),
4116 _scopes: Default::default(),
4117 }
4118 }
4119
4120 /// Create a builder to help you perform the following task:
4121 ///
4122 /// Lists SchemaVersions.
4123 ///
4124 /// # Arguments
4125 ///
4126 /// * `parent` - Required. Format: `projects/{project}/locations/{location}/schemas/{schema}`
4127 pub fn locations_schemas_schema_versions_list(
4128 &self,
4129 parent: &str,
4130 ) -> ProjectLocationSchemaSchemaVersionListCall<'a, C> {
4131 ProjectLocationSchemaSchemaVersionListCall {
4132 hub: self.hub,
4133 _parent: parent.to_string(),
4134 _page_token: Default::default(),
4135 _page_size: Default::default(),
4136 _delegate: Default::default(),
4137 _additional_params: Default::default(),
4138 _scopes: Default::default(),
4139 }
4140 }
4141
4142 /// Create a builder to help you perform the following task:
4143 ///
4144 /// Updates a schema version. Editable fields are: - `display_name` - `labels`
4145 ///
4146 /// # Arguments
4147 ///
4148 /// * `request` - No description provided.
4149 /// * `name` - Identifier. The resource name of the SchemaVersion. Format: `projects/{project}/locations/{location}/schemas/{schema}/schemaVersions/{schema_version}`
4150 pub fn locations_schemas_schema_versions_patch(
4151 &self,
4152 request: GoogleCloudDocumentaiV1SchemaVersion,
4153 name: &str,
4154 ) -> ProjectLocationSchemaSchemaVersionPatchCall<'a, C> {
4155 ProjectLocationSchemaSchemaVersionPatchCall {
4156 hub: self.hub,
4157 _request: request,
4158 _name: name.to_string(),
4159 _update_mask: Default::default(),
4160 _delegate: Default::default(),
4161 _additional_params: Default::default(),
4162 _scopes: Default::default(),
4163 }
4164 }
4165
4166 /// Create a builder to help you perform the following task:
4167 ///
4168 /// Creates a schema.
4169 ///
4170 /// # Arguments
4171 ///
4172 /// * `request` - No description provided.
4173 /// * `parent` - Required. The parent (project and location) under which to create the Schema. Format: `projects/{project}/locations/{location}`
4174 pub fn locations_schemas_create(
4175 &self,
4176 request: GoogleCloudDocumentaiV1NextSchema,
4177 parent: &str,
4178 ) -> ProjectLocationSchemaCreateCall<'a, C> {
4179 ProjectLocationSchemaCreateCall {
4180 hub: self.hub,
4181 _request: request,
4182 _parent: parent.to_string(),
4183 _delegate: Default::default(),
4184 _additional_params: Default::default(),
4185 _scopes: Default::default(),
4186 }
4187 }
4188
4189 /// Create a builder to help you perform the following task:
4190 ///
4191 /// Deletes a schema.
4192 ///
4193 /// # Arguments
4194 ///
4195 /// * `name` - Required. The name of the Schema to be deleted. Format: `projects/{project}/locations/{location}/schemas/{schema}`
4196 pub fn locations_schemas_delete(&self, name: &str) -> ProjectLocationSchemaDeleteCall<'a, C> {
4197 ProjectLocationSchemaDeleteCall {
4198 hub: self.hub,
4199 _name: name.to_string(),
4200 _force: Default::default(),
4201 _delegate: Default::default(),
4202 _additional_params: Default::default(),
4203 _scopes: Default::default(),
4204 }
4205 }
4206
4207 /// Create a builder to help you perform the following task:
4208 ///
4209 /// Gets a schema.
4210 ///
4211 /// # Arguments
4212 ///
4213 /// * `name` - Required. The name of the Schema to get. Format: `projects/{project}/locations/{location}/schemas/{schema}`
4214 pub fn locations_schemas_get(&self, name: &str) -> ProjectLocationSchemaGetCall<'a, C> {
4215 ProjectLocationSchemaGetCall {
4216 hub: self.hub,
4217 _name: name.to_string(),
4218 _delegate: Default::default(),
4219 _additional_params: Default::default(),
4220 _scopes: Default::default(),
4221 }
4222 }
4223
4224 /// Create a builder to help you perform the following task:
4225 ///
4226 /// Lists Schemas.
4227 ///
4228 /// # Arguments
4229 ///
4230 /// * `parent` - Required. Format: `projects/{project}/locations/{location}`
4231 pub fn locations_schemas_list(&self, parent: &str) -> ProjectLocationSchemaListCall<'a, C> {
4232 ProjectLocationSchemaListCall {
4233 hub: self.hub,
4234 _parent: parent.to_string(),
4235 _page_token: Default::default(),
4236 _page_size: Default::default(),
4237 _delegate: Default::default(),
4238 _additional_params: Default::default(),
4239 _scopes: Default::default(),
4240 }
4241 }
4242
4243 /// Create a builder to help you perform the following task:
4244 ///
4245 /// Updates a schema. Editable fields are: - `display_name` - `labels`
4246 ///
4247 /// # Arguments
4248 ///
4249 /// * `request` - No description provided.
4250 /// * `name` - Identifier. The resource name of the Schema. Format: `projects/{project}/locations/{location}/schemas/{schema}`
4251 pub fn locations_schemas_patch(
4252 &self,
4253 request: GoogleCloudDocumentaiV1NextSchema,
4254 name: &str,
4255 ) -> ProjectLocationSchemaPatchCall<'a, C> {
4256 ProjectLocationSchemaPatchCall {
4257 hub: self.hub,
4258 _request: request,
4259 _name: name.to_string(),
4260 _update_mask: Default::default(),
4261 _delegate: Default::default(),
4262 _additional_params: Default::default(),
4263 _scopes: Default::default(),
4264 }
4265 }
4266
4267 /// Create a builder to help you perform the following task:
4268 ///
4269 /// Fetches processor types. Note that we don't use ListProcessorTypes here, because it isn't paginated.
4270 ///
4271 /// # Arguments
4272 ///
4273 /// * `parent` - Required. The location of processor types to list. Format: `projects/{project}/locations/{location}`.
4274 pub fn locations_fetch_processor_types(
4275 &self,
4276 parent: &str,
4277 ) -> ProjectLocationFetchProcessorTypeCall<'a, C> {
4278 ProjectLocationFetchProcessorTypeCall {
4279 hub: self.hub,
4280 _parent: parent.to_string(),
4281 _delegate: Default::default(),
4282 _additional_params: Default::default(),
4283 _scopes: Default::default(),
4284 }
4285 }
4286
4287 /// Create a builder to help you perform the following task:
4288 ///
4289 /// Gets information about a location.
4290 ///
4291 /// # Arguments
4292 ///
4293 /// * `name` - Resource name for the location.
4294 pub fn locations_get(&self, name: &str) -> ProjectLocationGetCall<'a, C> {
4295 ProjectLocationGetCall {
4296 hub: self.hub,
4297 _name: name.to_string(),
4298 _delegate: Default::default(),
4299 _additional_params: Default::default(),
4300 _scopes: Default::default(),
4301 }
4302 }
4303
4304 /// Create a builder to help you perform the following task:
4305 ///
4306 /// Lists information about the supported locations for this service.
4307 ///
4308 /// # Arguments
4309 ///
4310 /// * `name` - The resource that owns the locations collection, if applicable.
4311 pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C> {
4312 ProjectLocationListCall {
4313 hub: self.hub,
4314 _name: name.to_string(),
4315 _page_token: Default::default(),
4316 _page_size: Default::default(),
4317 _filter: Default::default(),
4318 _extra_location_types: Default::default(),
4319 _delegate: Default::default(),
4320 _additional_params: Default::default(),
4321 _scopes: Default::default(),
4322 }
4323 }
4324
4325 /// Create a builder to help you perform the following task:
4326 ///
4327 /// 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.
4328 ///
4329 /// # Arguments
4330 ///
4331 /// * `name` - The name of the operation resource.
4332 pub fn operations_get(&self, name: &str) -> ProjectOperationGetCall<'a, C> {
4333 ProjectOperationGetCall {
4334 hub: self.hub,
4335 _name: name.to_string(),
4336 _delegate: Default::default(),
4337 _additional_params: Default::default(),
4338 _scopes: Default::default(),
4339 }
4340 }
4341}
4342
4343// ###################
4344// CallBuilders ###
4345// #################
4346
4347/// 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`.
4348///
4349/// A builder for the *delete* method supported by a *operation* resource.
4350/// It is not used directly, but through a [`OperationMethods`] instance.
4351///
4352/// # Example
4353///
4354/// Instantiate a resource method builder
4355///
4356/// ```test_harness,no_run
4357/// # extern crate hyper;
4358/// # extern crate hyper_rustls;
4359/// # extern crate google_documentai1 as documentai1;
4360/// # async fn dox() {
4361/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4362///
4363/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4364/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4365/// # .with_native_roots()
4366/// # .unwrap()
4367/// # .https_only()
4368/// # .enable_http2()
4369/// # .build();
4370///
4371/// # let executor = hyper_util::rt::TokioExecutor::new();
4372/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4373/// # secret,
4374/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4375/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4376/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4377/// # ),
4378/// # ).build().await.unwrap();
4379///
4380/// # let client = hyper_util::client::legacy::Client::builder(
4381/// # hyper_util::rt::TokioExecutor::new()
4382/// # )
4383/// # .build(
4384/// # hyper_rustls::HttpsConnectorBuilder::new()
4385/// # .with_native_roots()
4386/// # .unwrap()
4387/// # .https_or_http()
4388/// # .enable_http2()
4389/// # .build()
4390/// # );
4391/// # let mut hub = Document::new(client, auth);
4392/// // You can configure optional parameters by calling the respective setters at will, and
4393/// // execute the final call using `doit()`.
4394/// // Values shown here are possibly random and not representative !
4395/// let result = hub.operations().delete("name")
4396/// .doit().await;
4397/// # }
4398/// ```
4399pub struct OperationDeleteCall<'a, C>
4400where
4401 C: 'a,
4402{
4403 hub: &'a Document<C>,
4404 _name: String,
4405 _delegate: Option<&'a mut dyn common::Delegate>,
4406 _additional_params: HashMap<String, String>,
4407 _scopes: BTreeSet<String>,
4408}
4409
4410impl<'a, C> common::CallBuilder for OperationDeleteCall<'a, C> {}
4411
4412impl<'a, C> OperationDeleteCall<'a, C>
4413where
4414 C: common::Connector,
4415{
4416 /// Perform the operation you have build so far.
4417 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleProtobufEmpty)> {
4418 use std::borrow::Cow;
4419 use std::io::{Read, Seek};
4420
4421 use common::{url::Params, ToParts};
4422 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4423
4424 let mut dd = common::DefaultDelegate;
4425 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4426 dlg.begin(common::MethodInfo {
4427 id: "documentai.operations.delete",
4428 http_method: hyper::Method::DELETE,
4429 });
4430
4431 for &field in ["alt", "name"].iter() {
4432 if self._additional_params.contains_key(field) {
4433 dlg.finished(false);
4434 return Err(common::Error::FieldClash(field));
4435 }
4436 }
4437
4438 let mut params = Params::with_capacity(3 + self._additional_params.len());
4439 params.push("name", self._name);
4440
4441 params.extend(self._additional_params.iter());
4442
4443 params.push("alt", "json");
4444 let mut url = self.hub._base_url.clone() + "v1/{+name}";
4445 if self._scopes.is_empty() {
4446 self._scopes
4447 .insert(Scope::CloudPlatform.as_ref().to_string());
4448 }
4449
4450 #[allow(clippy::single_element_loop)]
4451 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4452 url = params.uri_replacement(url, param_name, find_this, true);
4453 }
4454 {
4455 let to_remove = ["name"];
4456 params.remove_params(&to_remove);
4457 }
4458
4459 let url = params.parse_with_url(&url);
4460
4461 loop {
4462 let token = match self
4463 .hub
4464 .auth
4465 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4466 .await
4467 {
4468 Ok(token) => token,
4469 Err(e) => match dlg.token(e) {
4470 Ok(token) => token,
4471 Err(e) => {
4472 dlg.finished(false);
4473 return Err(common::Error::MissingToken(e));
4474 }
4475 },
4476 };
4477 let mut req_result = {
4478 let client = &self.hub.client;
4479 dlg.pre_request();
4480 let mut req_builder = hyper::Request::builder()
4481 .method(hyper::Method::DELETE)
4482 .uri(url.as_str())
4483 .header(USER_AGENT, self.hub._user_agent.clone());
4484
4485 if let Some(token) = token.as_ref() {
4486 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4487 }
4488
4489 let request = req_builder
4490 .header(CONTENT_LENGTH, 0_u64)
4491 .body(common::to_body::<String>(None));
4492
4493 client.request(request.unwrap()).await
4494 };
4495
4496 match req_result {
4497 Err(err) => {
4498 if let common::Retry::After(d) = dlg.http_error(&err) {
4499 sleep(d).await;
4500 continue;
4501 }
4502 dlg.finished(false);
4503 return Err(common::Error::HttpError(err));
4504 }
4505 Ok(res) => {
4506 let (mut parts, body) = res.into_parts();
4507 let mut body = common::Body::new(body);
4508 if !parts.status.is_success() {
4509 let bytes = common::to_bytes(body).await.unwrap_or_default();
4510 let error = serde_json::from_str(&common::to_string(&bytes));
4511 let response = common::to_response(parts, bytes.into());
4512
4513 if let common::Retry::After(d) =
4514 dlg.http_failure(&response, error.as_ref().ok())
4515 {
4516 sleep(d).await;
4517 continue;
4518 }
4519
4520 dlg.finished(false);
4521
4522 return Err(match error {
4523 Ok(value) => common::Error::BadRequest(value),
4524 _ => common::Error::Failure(response),
4525 });
4526 }
4527 let response = {
4528 let bytes = common::to_bytes(body).await.unwrap_or_default();
4529 let encoded = common::to_string(&bytes);
4530 match serde_json::from_str(&encoded) {
4531 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4532 Err(error) => {
4533 dlg.response_json_decode_error(&encoded, &error);
4534 return Err(common::Error::JsonDecodeError(
4535 encoded.to_string(),
4536 error,
4537 ));
4538 }
4539 }
4540 };
4541
4542 dlg.finished(true);
4543 return Ok(response);
4544 }
4545 }
4546 }
4547 }
4548
4549 /// The name of the operation resource to be deleted.
4550 ///
4551 /// Sets the *name* path property to the given value.
4552 ///
4553 /// Even though the property as already been set when instantiating this call,
4554 /// we provide this method for API completeness.
4555 pub fn name(mut self, new_value: &str) -> OperationDeleteCall<'a, C> {
4556 self._name = new_value.to_string();
4557 self
4558 }
4559 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4560 /// while executing the actual API request.
4561 ///
4562 /// ````text
4563 /// It should be used to handle progress information, and to implement a certain level of resilience.
4564 /// ````
4565 ///
4566 /// Sets the *delegate* property to the given value.
4567 pub fn delegate(
4568 mut self,
4569 new_value: &'a mut dyn common::Delegate,
4570 ) -> OperationDeleteCall<'a, C> {
4571 self._delegate = Some(new_value);
4572 self
4573 }
4574
4575 /// Set any additional parameter of the query string used in the request.
4576 /// It should be used to set parameters which are not yet available through their own
4577 /// setters.
4578 ///
4579 /// Please note that this method must not be used to set any of the known parameters
4580 /// which have their own setter method. If done anyway, the request will fail.
4581 ///
4582 /// # Additional Parameters
4583 ///
4584 /// * *$.xgafv* (query-string) - V1 error format.
4585 /// * *access_token* (query-string) - OAuth access token.
4586 /// * *alt* (query-string) - Data format for response.
4587 /// * *callback* (query-string) - JSONP
4588 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4589 /// * *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.
4590 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4591 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4592 /// * *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.
4593 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4594 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4595 pub fn param<T>(mut self, name: T, value: T) -> OperationDeleteCall<'a, C>
4596 where
4597 T: AsRef<str>,
4598 {
4599 self._additional_params
4600 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4601 self
4602 }
4603
4604 /// Identifies the authorization scope for the method you are building.
4605 ///
4606 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4607 /// [`Scope::CloudPlatform`].
4608 ///
4609 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4610 /// tokens for more than one scope.
4611 ///
4612 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4613 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4614 /// sufficient, a read-write scope will do as well.
4615 pub fn add_scope<St>(mut self, scope: St) -> OperationDeleteCall<'a, C>
4616 where
4617 St: AsRef<str>,
4618 {
4619 self._scopes.insert(String::from(scope.as_ref()));
4620 self
4621 }
4622 /// Identifies the authorization scope(s) for the method you are building.
4623 ///
4624 /// See [`Self::add_scope()`] for details.
4625 pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationDeleteCall<'a, C>
4626 where
4627 I: IntoIterator<Item = St>,
4628 St: AsRef<str>,
4629 {
4630 self._scopes
4631 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4632 self
4633 }
4634
4635 /// Removes all scopes, and no default scope will be used either.
4636 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4637 /// for details).
4638 pub fn clear_scopes(mut self) -> OperationDeleteCall<'a, C> {
4639 self._scopes.clear();
4640 self
4641 }
4642}
4643
4644/// 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`.
4645///
4646/// A builder for the *locations.operations.cancel* method supported by a *project* resource.
4647/// It is not used directly, but through a [`ProjectMethods`] instance.
4648///
4649/// # Example
4650///
4651/// Instantiate a resource method builder
4652///
4653/// ```test_harness,no_run
4654/// # extern crate hyper;
4655/// # extern crate hyper_rustls;
4656/// # extern crate google_documentai1 as documentai1;
4657/// # async fn dox() {
4658/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4659///
4660/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4661/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4662/// # .with_native_roots()
4663/// # .unwrap()
4664/// # .https_only()
4665/// # .enable_http2()
4666/// # .build();
4667///
4668/// # let executor = hyper_util::rt::TokioExecutor::new();
4669/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4670/// # secret,
4671/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4672/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4673/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4674/// # ),
4675/// # ).build().await.unwrap();
4676///
4677/// # let client = hyper_util::client::legacy::Client::builder(
4678/// # hyper_util::rt::TokioExecutor::new()
4679/// # )
4680/// # .build(
4681/// # hyper_rustls::HttpsConnectorBuilder::new()
4682/// # .with_native_roots()
4683/// # .unwrap()
4684/// # .https_or_http()
4685/// # .enable_http2()
4686/// # .build()
4687/// # );
4688/// # let mut hub = Document::new(client, auth);
4689/// // You can configure optional parameters by calling the respective setters at will, and
4690/// // execute the final call using `doit()`.
4691/// // Values shown here are possibly random and not representative !
4692/// let result = hub.projects().locations_operations_cancel("name")
4693/// .doit().await;
4694/// # }
4695/// ```
4696pub struct ProjectLocationOperationCancelCall<'a, C>
4697where
4698 C: 'a,
4699{
4700 hub: &'a Document<C>,
4701 _name: String,
4702 _delegate: Option<&'a mut dyn common::Delegate>,
4703 _additional_params: HashMap<String, String>,
4704 _scopes: BTreeSet<String>,
4705}
4706
4707impl<'a, C> common::CallBuilder for ProjectLocationOperationCancelCall<'a, C> {}
4708
4709impl<'a, C> ProjectLocationOperationCancelCall<'a, C>
4710where
4711 C: common::Connector,
4712{
4713 /// Perform the operation you have build so far.
4714 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleProtobufEmpty)> {
4715 use std::borrow::Cow;
4716 use std::io::{Read, Seek};
4717
4718 use common::{url::Params, ToParts};
4719 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4720
4721 let mut dd = common::DefaultDelegate;
4722 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4723 dlg.begin(common::MethodInfo {
4724 id: "documentai.projects.locations.operations.cancel",
4725 http_method: hyper::Method::POST,
4726 });
4727
4728 for &field in ["alt", "name"].iter() {
4729 if self._additional_params.contains_key(field) {
4730 dlg.finished(false);
4731 return Err(common::Error::FieldClash(field));
4732 }
4733 }
4734
4735 let mut params = Params::with_capacity(3 + self._additional_params.len());
4736 params.push("name", self._name);
4737
4738 params.extend(self._additional_params.iter());
4739
4740 params.push("alt", "json");
4741 let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
4742 if self._scopes.is_empty() {
4743 self._scopes
4744 .insert(Scope::CloudPlatform.as_ref().to_string());
4745 }
4746
4747 #[allow(clippy::single_element_loop)]
4748 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4749 url = params.uri_replacement(url, param_name, find_this, true);
4750 }
4751 {
4752 let to_remove = ["name"];
4753 params.remove_params(&to_remove);
4754 }
4755
4756 let url = params.parse_with_url(&url);
4757
4758 loop {
4759 let token = match self
4760 .hub
4761 .auth
4762 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4763 .await
4764 {
4765 Ok(token) => token,
4766 Err(e) => match dlg.token(e) {
4767 Ok(token) => token,
4768 Err(e) => {
4769 dlg.finished(false);
4770 return Err(common::Error::MissingToken(e));
4771 }
4772 },
4773 };
4774 let mut req_result = {
4775 let client = &self.hub.client;
4776 dlg.pre_request();
4777 let mut req_builder = hyper::Request::builder()
4778 .method(hyper::Method::POST)
4779 .uri(url.as_str())
4780 .header(USER_AGENT, self.hub._user_agent.clone());
4781
4782 if let Some(token) = token.as_ref() {
4783 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4784 }
4785
4786 let request = req_builder
4787 .header(CONTENT_LENGTH, 0_u64)
4788 .body(common::to_body::<String>(None));
4789
4790 client.request(request.unwrap()).await
4791 };
4792
4793 match req_result {
4794 Err(err) => {
4795 if let common::Retry::After(d) = dlg.http_error(&err) {
4796 sleep(d).await;
4797 continue;
4798 }
4799 dlg.finished(false);
4800 return Err(common::Error::HttpError(err));
4801 }
4802 Ok(res) => {
4803 let (mut parts, body) = res.into_parts();
4804 let mut body = common::Body::new(body);
4805 if !parts.status.is_success() {
4806 let bytes = common::to_bytes(body).await.unwrap_or_default();
4807 let error = serde_json::from_str(&common::to_string(&bytes));
4808 let response = common::to_response(parts, bytes.into());
4809
4810 if let common::Retry::After(d) =
4811 dlg.http_failure(&response, error.as_ref().ok())
4812 {
4813 sleep(d).await;
4814 continue;
4815 }
4816
4817 dlg.finished(false);
4818
4819 return Err(match error {
4820 Ok(value) => common::Error::BadRequest(value),
4821 _ => common::Error::Failure(response),
4822 });
4823 }
4824 let response = {
4825 let bytes = common::to_bytes(body).await.unwrap_or_default();
4826 let encoded = common::to_string(&bytes);
4827 match serde_json::from_str(&encoded) {
4828 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4829 Err(error) => {
4830 dlg.response_json_decode_error(&encoded, &error);
4831 return Err(common::Error::JsonDecodeError(
4832 encoded.to_string(),
4833 error,
4834 ));
4835 }
4836 }
4837 };
4838
4839 dlg.finished(true);
4840 return Ok(response);
4841 }
4842 }
4843 }
4844 }
4845
4846 /// The name of the operation resource to be cancelled.
4847 ///
4848 /// Sets the *name* path property to the given value.
4849 ///
4850 /// Even though the property as already been set when instantiating this call,
4851 /// we provide this method for API completeness.
4852 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationCancelCall<'a, C> {
4853 self._name = new_value.to_string();
4854 self
4855 }
4856 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4857 /// while executing the actual API request.
4858 ///
4859 /// ````text
4860 /// It should be used to handle progress information, and to implement a certain level of resilience.
4861 /// ````
4862 ///
4863 /// Sets the *delegate* property to the given value.
4864 pub fn delegate(
4865 mut self,
4866 new_value: &'a mut dyn common::Delegate,
4867 ) -> ProjectLocationOperationCancelCall<'a, C> {
4868 self._delegate = Some(new_value);
4869 self
4870 }
4871
4872 /// Set any additional parameter of the query string used in the request.
4873 /// It should be used to set parameters which are not yet available through their own
4874 /// setters.
4875 ///
4876 /// Please note that this method must not be used to set any of the known parameters
4877 /// which have their own setter method. If done anyway, the request will fail.
4878 ///
4879 /// # Additional Parameters
4880 ///
4881 /// * *$.xgafv* (query-string) - V1 error format.
4882 /// * *access_token* (query-string) - OAuth access token.
4883 /// * *alt* (query-string) - Data format for response.
4884 /// * *callback* (query-string) - JSONP
4885 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4886 /// * *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.
4887 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4888 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4889 /// * *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.
4890 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4891 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4892 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationCancelCall<'a, C>
4893 where
4894 T: AsRef<str>,
4895 {
4896 self._additional_params
4897 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4898 self
4899 }
4900
4901 /// Identifies the authorization scope for the method you are building.
4902 ///
4903 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4904 /// [`Scope::CloudPlatform`].
4905 ///
4906 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4907 /// tokens for more than one scope.
4908 ///
4909 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4910 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4911 /// sufficient, a read-write scope will do as well.
4912 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationCancelCall<'a, C>
4913 where
4914 St: AsRef<str>,
4915 {
4916 self._scopes.insert(String::from(scope.as_ref()));
4917 self
4918 }
4919 /// Identifies the authorization scope(s) for the method you are building.
4920 ///
4921 /// See [`Self::add_scope()`] for details.
4922 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationCancelCall<'a, C>
4923 where
4924 I: IntoIterator<Item = St>,
4925 St: AsRef<str>,
4926 {
4927 self._scopes
4928 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4929 self
4930 }
4931
4932 /// Removes all scopes, and no default scope will be used either.
4933 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4934 /// for details).
4935 pub fn clear_scopes(mut self) -> ProjectLocationOperationCancelCall<'a, C> {
4936 self._scopes.clear();
4937 self
4938 }
4939}
4940
4941/// 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.
4942///
4943/// A builder for the *locations.operations.get* method supported by a *project* resource.
4944/// It is not used directly, but through a [`ProjectMethods`] instance.
4945///
4946/// # Example
4947///
4948/// Instantiate a resource method builder
4949///
4950/// ```test_harness,no_run
4951/// # extern crate hyper;
4952/// # extern crate hyper_rustls;
4953/// # extern crate google_documentai1 as documentai1;
4954/// # async fn dox() {
4955/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4956///
4957/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4958/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4959/// # .with_native_roots()
4960/// # .unwrap()
4961/// # .https_only()
4962/// # .enable_http2()
4963/// # .build();
4964///
4965/// # let executor = hyper_util::rt::TokioExecutor::new();
4966/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4967/// # secret,
4968/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4969/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4970/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4971/// # ),
4972/// # ).build().await.unwrap();
4973///
4974/// # let client = hyper_util::client::legacy::Client::builder(
4975/// # hyper_util::rt::TokioExecutor::new()
4976/// # )
4977/// # .build(
4978/// # hyper_rustls::HttpsConnectorBuilder::new()
4979/// # .with_native_roots()
4980/// # .unwrap()
4981/// # .https_or_http()
4982/// # .enable_http2()
4983/// # .build()
4984/// # );
4985/// # let mut hub = Document::new(client, auth);
4986/// // You can configure optional parameters by calling the respective setters at will, and
4987/// // execute the final call using `doit()`.
4988/// // Values shown here are possibly random and not representative !
4989/// let result = hub.projects().locations_operations_get("name")
4990/// .doit().await;
4991/// # }
4992/// ```
4993pub struct ProjectLocationOperationGetCall<'a, C>
4994where
4995 C: 'a,
4996{
4997 hub: &'a Document<C>,
4998 _name: String,
4999 _delegate: Option<&'a mut dyn common::Delegate>,
5000 _additional_params: HashMap<String, String>,
5001 _scopes: BTreeSet<String>,
5002}
5003
5004impl<'a, C> common::CallBuilder for ProjectLocationOperationGetCall<'a, C> {}
5005
5006impl<'a, C> ProjectLocationOperationGetCall<'a, C>
5007where
5008 C: common::Connector,
5009{
5010 /// Perform the operation you have build so far.
5011 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
5012 use std::borrow::Cow;
5013 use std::io::{Read, Seek};
5014
5015 use common::{url::Params, ToParts};
5016 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5017
5018 let mut dd = common::DefaultDelegate;
5019 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5020 dlg.begin(common::MethodInfo {
5021 id: "documentai.projects.locations.operations.get",
5022 http_method: hyper::Method::GET,
5023 });
5024
5025 for &field in ["alt", "name"].iter() {
5026 if self._additional_params.contains_key(field) {
5027 dlg.finished(false);
5028 return Err(common::Error::FieldClash(field));
5029 }
5030 }
5031
5032 let mut params = Params::with_capacity(3 + self._additional_params.len());
5033 params.push("name", self._name);
5034
5035 params.extend(self._additional_params.iter());
5036
5037 params.push("alt", "json");
5038 let mut url = self.hub._base_url.clone() + "v1/{+name}";
5039 if self._scopes.is_empty() {
5040 self._scopes
5041 .insert(Scope::CloudPlatform.as_ref().to_string());
5042 }
5043
5044 #[allow(clippy::single_element_loop)]
5045 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5046 url = params.uri_replacement(url, param_name, find_this, true);
5047 }
5048 {
5049 let to_remove = ["name"];
5050 params.remove_params(&to_remove);
5051 }
5052
5053 let url = params.parse_with_url(&url);
5054
5055 loop {
5056 let token = match self
5057 .hub
5058 .auth
5059 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5060 .await
5061 {
5062 Ok(token) => token,
5063 Err(e) => match dlg.token(e) {
5064 Ok(token) => token,
5065 Err(e) => {
5066 dlg.finished(false);
5067 return Err(common::Error::MissingToken(e));
5068 }
5069 },
5070 };
5071 let mut req_result = {
5072 let client = &self.hub.client;
5073 dlg.pre_request();
5074 let mut req_builder = hyper::Request::builder()
5075 .method(hyper::Method::GET)
5076 .uri(url.as_str())
5077 .header(USER_AGENT, self.hub._user_agent.clone());
5078
5079 if let Some(token) = token.as_ref() {
5080 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5081 }
5082
5083 let request = req_builder
5084 .header(CONTENT_LENGTH, 0_u64)
5085 .body(common::to_body::<String>(None));
5086
5087 client.request(request.unwrap()).await
5088 };
5089
5090 match req_result {
5091 Err(err) => {
5092 if let common::Retry::After(d) = dlg.http_error(&err) {
5093 sleep(d).await;
5094 continue;
5095 }
5096 dlg.finished(false);
5097 return Err(common::Error::HttpError(err));
5098 }
5099 Ok(res) => {
5100 let (mut parts, body) = res.into_parts();
5101 let mut body = common::Body::new(body);
5102 if !parts.status.is_success() {
5103 let bytes = common::to_bytes(body).await.unwrap_or_default();
5104 let error = serde_json::from_str(&common::to_string(&bytes));
5105 let response = common::to_response(parts, bytes.into());
5106
5107 if let common::Retry::After(d) =
5108 dlg.http_failure(&response, error.as_ref().ok())
5109 {
5110 sleep(d).await;
5111 continue;
5112 }
5113
5114 dlg.finished(false);
5115
5116 return Err(match error {
5117 Ok(value) => common::Error::BadRequest(value),
5118 _ => common::Error::Failure(response),
5119 });
5120 }
5121 let response = {
5122 let bytes = common::to_bytes(body).await.unwrap_or_default();
5123 let encoded = common::to_string(&bytes);
5124 match serde_json::from_str(&encoded) {
5125 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5126 Err(error) => {
5127 dlg.response_json_decode_error(&encoded, &error);
5128 return Err(common::Error::JsonDecodeError(
5129 encoded.to_string(),
5130 error,
5131 ));
5132 }
5133 }
5134 };
5135
5136 dlg.finished(true);
5137 return Ok(response);
5138 }
5139 }
5140 }
5141 }
5142
5143 /// The name of the operation resource.
5144 ///
5145 /// Sets the *name* path property to the given value.
5146 ///
5147 /// Even though the property as already been set when instantiating this call,
5148 /// we provide this method for API completeness.
5149 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationGetCall<'a, C> {
5150 self._name = new_value.to_string();
5151 self
5152 }
5153 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5154 /// while executing the actual API request.
5155 ///
5156 /// ````text
5157 /// It should be used to handle progress information, and to implement a certain level of resilience.
5158 /// ````
5159 ///
5160 /// Sets the *delegate* property to the given value.
5161 pub fn delegate(
5162 mut self,
5163 new_value: &'a mut dyn common::Delegate,
5164 ) -> ProjectLocationOperationGetCall<'a, C> {
5165 self._delegate = Some(new_value);
5166 self
5167 }
5168
5169 /// Set any additional parameter of the query string used in the request.
5170 /// It should be used to set parameters which are not yet available through their own
5171 /// setters.
5172 ///
5173 /// Please note that this method must not be used to set any of the known parameters
5174 /// which have their own setter method. If done anyway, the request will fail.
5175 ///
5176 /// # Additional Parameters
5177 ///
5178 /// * *$.xgafv* (query-string) - V1 error format.
5179 /// * *access_token* (query-string) - OAuth access token.
5180 /// * *alt* (query-string) - Data format for response.
5181 /// * *callback* (query-string) - JSONP
5182 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5183 /// * *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.
5184 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5185 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5186 /// * *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.
5187 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5188 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5189 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationGetCall<'a, C>
5190 where
5191 T: AsRef<str>,
5192 {
5193 self._additional_params
5194 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5195 self
5196 }
5197
5198 /// Identifies the authorization scope for the method you are building.
5199 ///
5200 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5201 /// [`Scope::CloudPlatform`].
5202 ///
5203 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5204 /// tokens for more than one scope.
5205 ///
5206 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5207 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5208 /// sufficient, a read-write scope will do as well.
5209 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationGetCall<'a, C>
5210 where
5211 St: AsRef<str>,
5212 {
5213 self._scopes.insert(String::from(scope.as_ref()));
5214 self
5215 }
5216 /// Identifies the authorization scope(s) for the method you are building.
5217 ///
5218 /// See [`Self::add_scope()`] for details.
5219 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationGetCall<'a, C>
5220 where
5221 I: IntoIterator<Item = St>,
5222 St: AsRef<str>,
5223 {
5224 self._scopes
5225 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5226 self
5227 }
5228
5229 /// Removes all scopes, and no default scope will be used either.
5230 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5231 /// for details).
5232 pub fn clear_scopes(mut self) -> ProjectLocationOperationGetCall<'a, C> {
5233 self._scopes.clear();
5234 self
5235 }
5236}
5237
5238/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
5239///
5240/// A builder for the *locations.operations.list* method supported by a *project* resource.
5241/// It is not used directly, but through a [`ProjectMethods`] instance.
5242///
5243/// # Example
5244///
5245/// Instantiate a resource method builder
5246///
5247/// ```test_harness,no_run
5248/// # extern crate hyper;
5249/// # extern crate hyper_rustls;
5250/// # extern crate google_documentai1 as documentai1;
5251/// # async fn dox() {
5252/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5253///
5254/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5255/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5256/// # .with_native_roots()
5257/// # .unwrap()
5258/// # .https_only()
5259/// # .enable_http2()
5260/// # .build();
5261///
5262/// # let executor = hyper_util::rt::TokioExecutor::new();
5263/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5264/// # secret,
5265/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5266/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5267/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5268/// # ),
5269/// # ).build().await.unwrap();
5270///
5271/// # let client = hyper_util::client::legacy::Client::builder(
5272/// # hyper_util::rt::TokioExecutor::new()
5273/// # )
5274/// # .build(
5275/// # hyper_rustls::HttpsConnectorBuilder::new()
5276/// # .with_native_roots()
5277/// # .unwrap()
5278/// # .https_or_http()
5279/// # .enable_http2()
5280/// # .build()
5281/// # );
5282/// # let mut hub = Document::new(client, auth);
5283/// // You can configure optional parameters by calling the respective setters at will, and
5284/// // execute the final call using `doit()`.
5285/// // Values shown here are possibly random and not representative !
5286/// let result = hub.projects().locations_operations_list("name")
5287/// .return_partial_success(false)
5288/// .page_token("amet.")
5289/// .page_size(-59)
5290/// .filter("amet.")
5291/// .doit().await;
5292/// # }
5293/// ```
5294pub struct ProjectLocationOperationListCall<'a, C>
5295where
5296 C: 'a,
5297{
5298 hub: &'a Document<C>,
5299 _name: String,
5300 _return_partial_success: Option<bool>,
5301 _page_token: Option<String>,
5302 _page_size: Option<i32>,
5303 _filter: Option<String>,
5304 _delegate: Option<&'a mut dyn common::Delegate>,
5305 _additional_params: HashMap<String, String>,
5306 _scopes: BTreeSet<String>,
5307}
5308
5309impl<'a, C> common::CallBuilder for ProjectLocationOperationListCall<'a, C> {}
5310
5311impl<'a, C> ProjectLocationOperationListCall<'a, C>
5312where
5313 C: common::Connector,
5314{
5315 /// Perform the operation you have build so far.
5316 pub async fn doit(
5317 mut self,
5318 ) -> common::Result<(common::Response, GoogleLongrunningListOperationsResponse)> {
5319 use std::borrow::Cow;
5320 use std::io::{Read, Seek};
5321
5322 use common::{url::Params, ToParts};
5323 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5324
5325 let mut dd = common::DefaultDelegate;
5326 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5327 dlg.begin(common::MethodInfo {
5328 id: "documentai.projects.locations.operations.list",
5329 http_method: hyper::Method::GET,
5330 });
5331
5332 for &field in [
5333 "alt",
5334 "name",
5335 "returnPartialSuccess",
5336 "pageToken",
5337 "pageSize",
5338 "filter",
5339 ]
5340 .iter()
5341 {
5342 if self._additional_params.contains_key(field) {
5343 dlg.finished(false);
5344 return Err(common::Error::FieldClash(field));
5345 }
5346 }
5347
5348 let mut params = Params::with_capacity(7 + self._additional_params.len());
5349 params.push("name", self._name);
5350 if let Some(value) = self._return_partial_success.as_ref() {
5351 params.push("returnPartialSuccess", value.to_string());
5352 }
5353 if let Some(value) = self._page_token.as_ref() {
5354 params.push("pageToken", value);
5355 }
5356 if let Some(value) = self._page_size.as_ref() {
5357 params.push("pageSize", value.to_string());
5358 }
5359 if let Some(value) = self._filter.as_ref() {
5360 params.push("filter", value);
5361 }
5362
5363 params.extend(self._additional_params.iter());
5364
5365 params.push("alt", "json");
5366 let mut url = self.hub._base_url.clone() + "v1/{+name}";
5367 if self._scopes.is_empty() {
5368 self._scopes
5369 .insert(Scope::CloudPlatform.as_ref().to_string());
5370 }
5371
5372 #[allow(clippy::single_element_loop)]
5373 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5374 url = params.uri_replacement(url, param_name, find_this, true);
5375 }
5376 {
5377 let to_remove = ["name"];
5378 params.remove_params(&to_remove);
5379 }
5380
5381 let url = params.parse_with_url(&url);
5382
5383 loop {
5384 let token = match self
5385 .hub
5386 .auth
5387 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5388 .await
5389 {
5390 Ok(token) => token,
5391 Err(e) => match dlg.token(e) {
5392 Ok(token) => token,
5393 Err(e) => {
5394 dlg.finished(false);
5395 return Err(common::Error::MissingToken(e));
5396 }
5397 },
5398 };
5399 let mut req_result = {
5400 let client = &self.hub.client;
5401 dlg.pre_request();
5402 let mut req_builder = hyper::Request::builder()
5403 .method(hyper::Method::GET)
5404 .uri(url.as_str())
5405 .header(USER_AGENT, self.hub._user_agent.clone());
5406
5407 if let Some(token) = token.as_ref() {
5408 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5409 }
5410
5411 let request = req_builder
5412 .header(CONTENT_LENGTH, 0_u64)
5413 .body(common::to_body::<String>(None));
5414
5415 client.request(request.unwrap()).await
5416 };
5417
5418 match req_result {
5419 Err(err) => {
5420 if let common::Retry::After(d) = dlg.http_error(&err) {
5421 sleep(d).await;
5422 continue;
5423 }
5424 dlg.finished(false);
5425 return Err(common::Error::HttpError(err));
5426 }
5427 Ok(res) => {
5428 let (mut parts, body) = res.into_parts();
5429 let mut body = common::Body::new(body);
5430 if !parts.status.is_success() {
5431 let bytes = common::to_bytes(body).await.unwrap_or_default();
5432 let error = serde_json::from_str(&common::to_string(&bytes));
5433 let response = common::to_response(parts, bytes.into());
5434
5435 if let common::Retry::After(d) =
5436 dlg.http_failure(&response, error.as_ref().ok())
5437 {
5438 sleep(d).await;
5439 continue;
5440 }
5441
5442 dlg.finished(false);
5443
5444 return Err(match error {
5445 Ok(value) => common::Error::BadRequest(value),
5446 _ => common::Error::Failure(response),
5447 });
5448 }
5449 let response = {
5450 let bytes = common::to_bytes(body).await.unwrap_or_default();
5451 let encoded = common::to_string(&bytes);
5452 match serde_json::from_str(&encoded) {
5453 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5454 Err(error) => {
5455 dlg.response_json_decode_error(&encoded, &error);
5456 return Err(common::Error::JsonDecodeError(
5457 encoded.to_string(),
5458 error,
5459 ));
5460 }
5461 }
5462 };
5463
5464 dlg.finished(true);
5465 return Ok(response);
5466 }
5467 }
5468 }
5469 }
5470
5471 /// The name of the operation's parent resource.
5472 ///
5473 /// Sets the *name* path property to the given value.
5474 ///
5475 /// Even though the property as already been set when instantiating this call,
5476 /// we provide this method for API completeness.
5477 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
5478 self._name = new_value.to_string();
5479 self
5480 }
5481 /// When set to `true`, operations that are reachable are returned as normal, and those that are unreachable are returned in the ListOperationsResponse.unreachable field. This can only be `true` when reading across collections. For example, when `parent` is set to `"projects/example/locations/-"`. This field is not supported by default and will result in an `UNIMPLEMENTED` error if set unless explicitly documented otherwise in service or product specific documentation.
5482 ///
5483 /// Sets the *return partial success* query property to the given value.
5484 pub fn return_partial_success(
5485 mut self,
5486 new_value: bool,
5487 ) -> ProjectLocationOperationListCall<'a, C> {
5488 self._return_partial_success = Some(new_value);
5489 self
5490 }
5491 /// The standard list page token.
5492 ///
5493 /// Sets the *page token* query property to the given value.
5494 pub fn page_token(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
5495 self._page_token = Some(new_value.to_string());
5496 self
5497 }
5498 /// The standard list page size.
5499 ///
5500 /// Sets the *page size* query property to the given value.
5501 pub fn page_size(mut self, new_value: i32) -> ProjectLocationOperationListCall<'a, C> {
5502 self._page_size = Some(new_value);
5503 self
5504 }
5505 /// The standard list filter.
5506 ///
5507 /// Sets the *filter* query property to the given value.
5508 pub fn filter(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
5509 self._filter = Some(new_value.to_string());
5510 self
5511 }
5512 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5513 /// while executing the actual API request.
5514 ///
5515 /// ````text
5516 /// It should be used to handle progress information, and to implement a certain level of resilience.
5517 /// ````
5518 ///
5519 /// Sets the *delegate* property to the given value.
5520 pub fn delegate(
5521 mut self,
5522 new_value: &'a mut dyn common::Delegate,
5523 ) -> ProjectLocationOperationListCall<'a, C> {
5524 self._delegate = Some(new_value);
5525 self
5526 }
5527
5528 /// Set any additional parameter of the query string used in the request.
5529 /// It should be used to set parameters which are not yet available through their own
5530 /// setters.
5531 ///
5532 /// Please note that this method must not be used to set any of the known parameters
5533 /// which have their own setter method. If done anyway, the request will fail.
5534 ///
5535 /// # Additional Parameters
5536 ///
5537 /// * *$.xgafv* (query-string) - V1 error format.
5538 /// * *access_token* (query-string) - OAuth access token.
5539 /// * *alt* (query-string) - Data format for response.
5540 /// * *callback* (query-string) - JSONP
5541 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5542 /// * *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.
5543 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5544 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5545 /// * *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.
5546 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5547 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5548 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationListCall<'a, C>
5549 where
5550 T: AsRef<str>,
5551 {
5552 self._additional_params
5553 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5554 self
5555 }
5556
5557 /// Identifies the authorization scope for the method you are building.
5558 ///
5559 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5560 /// [`Scope::CloudPlatform`].
5561 ///
5562 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5563 /// tokens for more than one scope.
5564 ///
5565 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5566 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5567 /// sufficient, a read-write scope will do as well.
5568 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationListCall<'a, C>
5569 where
5570 St: AsRef<str>,
5571 {
5572 self._scopes.insert(String::from(scope.as_ref()));
5573 self
5574 }
5575 /// Identifies the authorization scope(s) for the method you are building.
5576 ///
5577 /// See [`Self::add_scope()`] for details.
5578 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationListCall<'a, C>
5579 where
5580 I: IntoIterator<Item = St>,
5581 St: AsRef<str>,
5582 {
5583 self._scopes
5584 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5585 self
5586 }
5587
5588 /// Removes all scopes, and no default scope will be used either.
5589 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5590 /// for details).
5591 pub fn clear_scopes(mut self) -> ProjectLocationOperationListCall<'a, C> {
5592 self._scopes.clear();
5593 self
5594 }
5595}
5596
5597/// Gets a processor type detail.
5598///
5599/// A builder for the *locations.processorTypes.get* method supported by a *project* resource.
5600/// It is not used directly, but through a [`ProjectMethods`] instance.
5601///
5602/// # Example
5603///
5604/// Instantiate a resource method builder
5605///
5606/// ```test_harness,no_run
5607/// # extern crate hyper;
5608/// # extern crate hyper_rustls;
5609/// # extern crate google_documentai1 as documentai1;
5610/// # async fn dox() {
5611/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5612///
5613/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5614/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5615/// # .with_native_roots()
5616/// # .unwrap()
5617/// # .https_only()
5618/// # .enable_http2()
5619/// # .build();
5620///
5621/// # let executor = hyper_util::rt::TokioExecutor::new();
5622/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5623/// # secret,
5624/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5625/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5626/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5627/// # ),
5628/// # ).build().await.unwrap();
5629///
5630/// # let client = hyper_util::client::legacy::Client::builder(
5631/// # hyper_util::rt::TokioExecutor::new()
5632/// # )
5633/// # .build(
5634/// # hyper_rustls::HttpsConnectorBuilder::new()
5635/// # .with_native_roots()
5636/// # .unwrap()
5637/// # .https_or_http()
5638/// # .enable_http2()
5639/// # .build()
5640/// # );
5641/// # let mut hub = Document::new(client, auth);
5642/// // You can configure optional parameters by calling the respective setters at will, and
5643/// // execute the final call using `doit()`.
5644/// // Values shown here are possibly random and not representative !
5645/// let result = hub.projects().locations_processor_types_get("name")
5646/// .doit().await;
5647/// # }
5648/// ```
5649pub struct ProjectLocationProcessorTypeGetCall<'a, C>
5650where
5651 C: 'a,
5652{
5653 hub: &'a Document<C>,
5654 _name: String,
5655 _delegate: Option<&'a mut dyn common::Delegate>,
5656 _additional_params: HashMap<String, String>,
5657 _scopes: BTreeSet<String>,
5658}
5659
5660impl<'a, C> common::CallBuilder for ProjectLocationProcessorTypeGetCall<'a, C> {}
5661
5662impl<'a, C> ProjectLocationProcessorTypeGetCall<'a, C>
5663where
5664 C: common::Connector,
5665{
5666 /// Perform the operation you have build so far.
5667 pub async fn doit(
5668 mut self,
5669 ) -> common::Result<(common::Response, GoogleCloudDocumentaiV1ProcessorType)> {
5670 use std::borrow::Cow;
5671 use std::io::{Read, Seek};
5672
5673 use common::{url::Params, ToParts};
5674 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5675
5676 let mut dd = common::DefaultDelegate;
5677 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5678 dlg.begin(common::MethodInfo {
5679 id: "documentai.projects.locations.processorTypes.get",
5680 http_method: hyper::Method::GET,
5681 });
5682
5683 for &field in ["alt", "name"].iter() {
5684 if self._additional_params.contains_key(field) {
5685 dlg.finished(false);
5686 return Err(common::Error::FieldClash(field));
5687 }
5688 }
5689
5690 let mut params = Params::with_capacity(3 + self._additional_params.len());
5691 params.push("name", self._name);
5692
5693 params.extend(self._additional_params.iter());
5694
5695 params.push("alt", "json");
5696 let mut url = self.hub._base_url.clone() + "v1/{+name}";
5697 if self._scopes.is_empty() {
5698 self._scopes
5699 .insert(Scope::CloudPlatform.as_ref().to_string());
5700 }
5701
5702 #[allow(clippy::single_element_loop)]
5703 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5704 url = params.uri_replacement(url, param_name, find_this, true);
5705 }
5706 {
5707 let to_remove = ["name"];
5708 params.remove_params(&to_remove);
5709 }
5710
5711 let url = params.parse_with_url(&url);
5712
5713 loop {
5714 let token = match self
5715 .hub
5716 .auth
5717 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5718 .await
5719 {
5720 Ok(token) => token,
5721 Err(e) => match dlg.token(e) {
5722 Ok(token) => token,
5723 Err(e) => {
5724 dlg.finished(false);
5725 return Err(common::Error::MissingToken(e));
5726 }
5727 },
5728 };
5729 let mut req_result = {
5730 let client = &self.hub.client;
5731 dlg.pre_request();
5732 let mut req_builder = hyper::Request::builder()
5733 .method(hyper::Method::GET)
5734 .uri(url.as_str())
5735 .header(USER_AGENT, self.hub._user_agent.clone());
5736
5737 if let Some(token) = token.as_ref() {
5738 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5739 }
5740
5741 let request = req_builder
5742 .header(CONTENT_LENGTH, 0_u64)
5743 .body(common::to_body::<String>(None));
5744
5745 client.request(request.unwrap()).await
5746 };
5747
5748 match req_result {
5749 Err(err) => {
5750 if let common::Retry::After(d) = dlg.http_error(&err) {
5751 sleep(d).await;
5752 continue;
5753 }
5754 dlg.finished(false);
5755 return Err(common::Error::HttpError(err));
5756 }
5757 Ok(res) => {
5758 let (mut parts, body) = res.into_parts();
5759 let mut body = common::Body::new(body);
5760 if !parts.status.is_success() {
5761 let bytes = common::to_bytes(body).await.unwrap_or_default();
5762 let error = serde_json::from_str(&common::to_string(&bytes));
5763 let response = common::to_response(parts, bytes.into());
5764
5765 if let common::Retry::After(d) =
5766 dlg.http_failure(&response, error.as_ref().ok())
5767 {
5768 sleep(d).await;
5769 continue;
5770 }
5771
5772 dlg.finished(false);
5773
5774 return Err(match error {
5775 Ok(value) => common::Error::BadRequest(value),
5776 _ => common::Error::Failure(response),
5777 });
5778 }
5779 let response = {
5780 let bytes = common::to_bytes(body).await.unwrap_or_default();
5781 let encoded = common::to_string(&bytes);
5782 match serde_json::from_str(&encoded) {
5783 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5784 Err(error) => {
5785 dlg.response_json_decode_error(&encoded, &error);
5786 return Err(common::Error::JsonDecodeError(
5787 encoded.to_string(),
5788 error,
5789 ));
5790 }
5791 }
5792 };
5793
5794 dlg.finished(true);
5795 return Ok(response);
5796 }
5797 }
5798 }
5799 }
5800
5801 /// Required. The processor type resource name.
5802 ///
5803 /// Sets the *name* path property to the given value.
5804 ///
5805 /// Even though the property as already been set when instantiating this call,
5806 /// we provide this method for API completeness.
5807 pub fn name(mut self, new_value: &str) -> ProjectLocationProcessorTypeGetCall<'a, C> {
5808 self._name = new_value.to_string();
5809 self
5810 }
5811 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5812 /// while executing the actual API request.
5813 ///
5814 /// ````text
5815 /// It should be used to handle progress information, and to implement a certain level of resilience.
5816 /// ````
5817 ///
5818 /// Sets the *delegate* property to the given value.
5819 pub fn delegate(
5820 mut self,
5821 new_value: &'a mut dyn common::Delegate,
5822 ) -> ProjectLocationProcessorTypeGetCall<'a, C> {
5823 self._delegate = Some(new_value);
5824 self
5825 }
5826
5827 /// Set any additional parameter of the query string used in the request.
5828 /// It should be used to set parameters which are not yet available through their own
5829 /// setters.
5830 ///
5831 /// Please note that this method must not be used to set any of the known parameters
5832 /// which have their own setter method. If done anyway, the request will fail.
5833 ///
5834 /// # Additional Parameters
5835 ///
5836 /// * *$.xgafv* (query-string) - V1 error format.
5837 /// * *access_token* (query-string) - OAuth access token.
5838 /// * *alt* (query-string) - Data format for response.
5839 /// * *callback* (query-string) - JSONP
5840 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5841 /// * *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.
5842 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5843 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5844 /// * *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.
5845 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5846 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5847 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProcessorTypeGetCall<'a, C>
5848 where
5849 T: AsRef<str>,
5850 {
5851 self._additional_params
5852 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5853 self
5854 }
5855
5856 /// Identifies the authorization scope for the method you are building.
5857 ///
5858 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5859 /// [`Scope::CloudPlatform`].
5860 ///
5861 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5862 /// tokens for more than one scope.
5863 ///
5864 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5865 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5866 /// sufficient, a read-write scope will do as well.
5867 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProcessorTypeGetCall<'a, C>
5868 where
5869 St: AsRef<str>,
5870 {
5871 self._scopes.insert(String::from(scope.as_ref()));
5872 self
5873 }
5874 /// Identifies the authorization scope(s) for the method you are building.
5875 ///
5876 /// See [`Self::add_scope()`] for details.
5877 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProcessorTypeGetCall<'a, C>
5878 where
5879 I: IntoIterator<Item = St>,
5880 St: AsRef<str>,
5881 {
5882 self._scopes
5883 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5884 self
5885 }
5886
5887 /// Removes all scopes, and no default scope will be used either.
5888 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5889 /// for details).
5890 pub fn clear_scopes(mut self) -> ProjectLocationProcessorTypeGetCall<'a, C> {
5891 self._scopes.clear();
5892 self
5893 }
5894}
5895
5896/// Lists the processor types that exist.
5897///
5898/// A builder for the *locations.processorTypes.list* method supported by a *project* resource.
5899/// It is not used directly, but through a [`ProjectMethods`] instance.
5900///
5901/// # Example
5902///
5903/// Instantiate a resource method builder
5904///
5905/// ```test_harness,no_run
5906/// # extern crate hyper;
5907/// # extern crate hyper_rustls;
5908/// # extern crate google_documentai1 as documentai1;
5909/// # async fn dox() {
5910/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5911///
5912/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5913/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5914/// # .with_native_roots()
5915/// # .unwrap()
5916/// # .https_only()
5917/// # .enable_http2()
5918/// # .build();
5919///
5920/// # let executor = hyper_util::rt::TokioExecutor::new();
5921/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5922/// # secret,
5923/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5924/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5925/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5926/// # ),
5927/// # ).build().await.unwrap();
5928///
5929/// # let client = hyper_util::client::legacy::Client::builder(
5930/// # hyper_util::rt::TokioExecutor::new()
5931/// # )
5932/// # .build(
5933/// # hyper_rustls::HttpsConnectorBuilder::new()
5934/// # .with_native_roots()
5935/// # .unwrap()
5936/// # .https_or_http()
5937/// # .enable_http2()
5938/// # .build()
5939/// # );
5940/// # let mut hub = Document::new(client, auth);
5941/// // You can configure optional parameters by calling the respective setters at will, and
5942/// // execute the final call using `doit()`.
5943/// // Values shown here are possibly random and not representative !
5944/// let result = hub.projects().locations_processor_types_list("parent")
5945/// .page_token("gubergren")
5946/// .page_size(-51)
5947/// .doit().await;
5948/// # }
5949/// ```
5950pub struct ProjectLocationProcessorTypeListCall<'a, C>
5951where
5952 C: 'a,
5953{
5954 hub: &'a Document<C>,
5955 _parent: String,
5956 _page_token: Option<String>,
5957 _page_size: Option<i32>,
5958 _delegate: Option<&'a mut dyn common::Delegate>,
5959 _additional_params: HashMap<String, String>,
5960 _scopes: BTreeSet<String>,
5961}
5962
5963impl<'a, C> common::CallBuilder for ProjectLocationProcessorTypeListCall<'a, C> {}
5964
5965impl<'a, C> ProjectLocationProcessorTypeListCall<'a, C>
5966where
5967 C: common::Connector,
5968{
5969 /// Perform the operation you have build so far.
5970 pub async fn doit(
5971 mut self,
5972 ) -> common::Result<(
5973 common::Response,
5974 GoogleCloudDocumentaiV1ListProcessorTypesResponse,
5975 )> {
5976 use std::borrow::Cow;
5977 use std::io::{Read, Seek};
5978
5979 use common::{url::Params, ToParts};
5980 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5981
5982 let mut dd = common::DefaultDelegate;
5983 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5984 dlg.begin(common::MethodInfo {
5985 id: "documentai.projects.locations.processorTypes.list",
5986 http_method: hyper::Method::GET,
5987 });
5988
5989 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
5990 if self._additional_params.contains_key(field) {
5991 dlg.finished(false);
5992 return Err(common::Error::FieldClash(field));
5993 }
5994 }
5995
5996 let mut params = Params::with_capacity(5 + self._additional_params.len());
5997 params.push("parent", self._parent);
5998 if let Some(value) = self._page_token.as_ref() {
5999 params.push("pageToken", value);
6000 }
6001 if let Some(value) = self._page_size.as_ref() {
6002 params.push("pageSize", value.to_string());
6003 }
6004
6005 params.extend(self._additional_params.iter());
6006
6007 params.push("alt", "json");
6008 let mut url = self.hub._base_url.clone() + "v1/{+parent}/processorTypes";
6009 if self._scopes.is_empty() {
6010 self._scopes
6011 .insert(Scope::CloudPlatform.as_ref().to_string());
6012 }
6013
6014 #[allow(clippy::single_element_loop)]
6015 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6016 url = params.uri_replacement(url, param_name, find_this, true);
6017 }
6018 {
6019 let to_remove = ["parent"];
6020 params.remove_params(&to_remove);
6021 }
6022
6023 let url = params.parse_with_url(&url);
6024
6025 loop {
6026 let token = match self
6027 .hub
6028 .auth
6029 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6030 .await
6031 {
6032 Ok(token) => token,
6033 Err(e) => match dlg.token(e) {
6034 Ok(token) => token,
6035 Err(e) => {
6036 dlg.finished(false);
6037 return Err(common::Error::MissingToken(e));
6038 }
6039 },
6040 };
6041 let mut req_result = {
6042 let client = &self.hub.client;
6043 dlg.pre_request();
6044 let mut req_builder = hyper::Request::builder()
6045 .method(hyper::Method::GET)
6046 .uri(url.as_str())
6047 .header(USER_AGENT, self.hub._user_agent.clone());
6048
6049 if let Some(token) = token.as_ref() {
6050 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6051 }
6052
6053 let request = req_builder
6054 .header(CONTENT_LENGTH, 0_u64)
6055 .body(common::to_body::<String>(None));
6056
6057 client.request(request.unwrap()).await
6058 };
6059
6060 match req_result {
6061 Err(err) => {
6062 if let common::Retry::After(d) = dlg.http_error(&err) {
6063 sleep(d).await;
6064 continue;
6065 }
6066 dlg.finished(false);
6067 return Err(common::Error::HttpError(err));
6068 }
6069 Ok(res) => {
6070 let (mut parts, body) = res.into_parts();
6071 let mut body = common::Body::new(body);
6072 if !parts.status.is_success() {
6073 let bytes = common::to_bytes(body).await.unwrap_or_default();
6074 let error = serde_json::from_str(&common::to_string(&bytes));
6075 let response = common::to_response(parts, bytes.into());
6076
6077 if let common::Retry::After(d) =
6078 dlg.http_failure(&response, error.as_ref().ok())
6079 {
6080 sleep(d).await;
6081 continue;
6082 }
6083
6084 dlg.finished(false);
6085
6086 return Err(match error {
6087 Ok(value) => common::Error::BadRequest(value),
6088 _ => common::Error::Failure(response),
6089 });
6090 }
6091 let response = {
6092 let bytes = common::to_bytes(body).await.unwrap_or_default();
6093 let encoded = common::to_string(&bytes);
6094 match serde_json::from_str(&encoded) {
6095 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6096 Err(error) => {
6097 dlg.response_json_decode_error(&encoded, &error);
6098 return Err(common::Error::JsonDecodeError(
6099 encoded.to_string(),
6100 error,
6101 ));
6102 }
6103 }
6104 };
6105
6106 dlg.finished(true);
6107 return Ok(response);
6108 }
6109 }
6110 }
6111 }
6112
6113 /// Required. The location of processor types to list. Format: `projects/{project}/locations/{location}`.
6114 ///
6115 /// Sets the *parent* path property to the given value.
6116 ///
6117 /// Even though the property as already been set when instantiating this call,
6118 /// we provide this method for API completeness.
6119 pub fn parent(mut self, new_value: &str) -> ProjectLocationProcessorTypeListCall<'a, C> {
6120 self._parent = new_value.to_string();
6121 self
6122 }
6123 /// Used to retrieve the next page of results, empty if at the end of the list.
6124 ///
6125 /// Sets the *page token* query property to the given value.
6126 pub fn page_token(mut self, new_value: &str) -> ProjectLocationProcessorTypeListCall<'a, C> {
6127 self._page_token = Some(new_value.to_string());
6128 self
6129 }
6130 /// 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`.
6131 ///
6132 /// Sets the *page size* query property to the given value.
6133 pub fn page_size(mut self, new_value: i32) -> ProjectLocationProcessorTypeListCall<'a, C> {
6134 self._page_size = Some(new_value);
6135 self
6136 }
6137 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6138 /// while executing the actual API request.
6139 ///
6140 /// ````text
6141 /// It should be used to handle progress information, and to implement a certain level of resilience.
6142 /// ````
6143 ///
6144 /// Sets the *delegate* property to the given value.
6145 pub fn delegate(
6146 mut self,
6147 new_value: &'a mut dyn common::Delegate,
6148 ) -> ProjectLocationProcessorTypeListCall<'a, C> {
6149 self._delegate = Some(new_value);
6150 self
6151 }
6152
6153 /// Set any additional parameter of the query string used in the request.
6154 /// It should be used to set parameters which are not yet available through their own
6155 /// setters.
6156 ///
6157 /// Please note that this method must not be used to set any of the known parameters
6158 /// which have their own setter method. If done anyway, the request will fail.
6159 ///
6160 /// # Additional Parameters
6161 ///
6162 /// * *$.xgafv* (query-string) - V1 error format.
6163 /// * *access_token* (query-string) - OAuth access token.
6164 /// * *alt* (query-string) - Data format for response.
6165 /// * *callback* (query-string) - JSONP
6166 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6167 /// * *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.
6168 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6169 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6170 /// * *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.
6171 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6172 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6173 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProcessorTypeListCall<'a, C>
6174 where
6175 T: AsRef<str>,
6176 {
6177 self._additional_params
6178 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6179 self
6180 }
6181
6182 /// Identifies the authorization scope for the method you are building.
6183 ///
6184 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6185 /// [`Scope::CloudPlatform`].
6186 ///
6187 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6188 /// tokens for more than one scope.
6189 ///
6190 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6191 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6192 /// sufficient, a read-write scope will do as well.
6193 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProcessorTypeListCall<'a, C>
6194 where
6195 St: AsRef<str>,
6196 {
6197 self._scopes.insert(String::from(scope.as_ref()));
6198 self
6199 }
6200 /// Identifies the authorization scope(s) for the method you are building.
6201 ///
6202 /// See [`Self::add_scope()`] for details.
6203 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProcessorTypeListCall<'a, C>
6204 where
6205 I: IntoIterator<Item = St>,
6206 St: AsRef<str>,
6207 {
6208 self._scopes
6209 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6210 self
6211 }
6212
6213 /// Removes all scopes, and no default scope will be used either.
6214 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6215 /// for details).
6216 pub fn clear_scopes(mut self) -> ProjectLocationProcessorTypeListCall<'a, C> {
6217 self._scopes.clear();
6218 self
6219 }
6220}
6221
6222/// Send a document for Human Review. The input document should be processed by the specified processor.
6223///
6224/// A builder for the *locations.processors.humanReviewConfig.reviewDocument* method supported by a *project* resource.
6225/// It is not used directly, but through a [`ProjectMethods`] instance.
6226///
6227/// # Example
6228///
6229/// Instantiate a resource method builder
6230///
6231/// ```test_harness,no_run
6232/// # extern crate hyper;
6233/// # extern crate hyper_rustls;
6234/// # extern crate google_documentai1 as documentai1;
6235/// use documentai1::api::GoogleCloudDocumentaiV1ReviewDocumentRequest;
6236/// # async fn dox() {
6237/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6238///
6239/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6240/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6241/// # .with_native_roots()
6242/// # .unwrap()
6243/// # .https_only()
6244/// # .enable_http2()
6245/// # .build();
6246///
6247/// # let executor = hyper_util::rt::TokioExecutor::new();
6248/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6249/// # secret,
6250/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6251/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6252/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6253/// # ),
6254/// # ).build().await.unwrap();
6255///
6256/// # let client = hyper_util::client::legacy::Client::builder(
6257/// # hyper_util::rt::TokioExecutor::new()
6258/// # )
6259/// # .build(
6260/// # hyper_rustls::HttpsConnectorBuilder::new()
6261/// # .with_native_roots()
6262/// # .unwrap()
6263/// # .https_or_http()
6264/// # .enable_http2()
6265/// # .build()
6266/// # );
6267/// # let mut hub = Document::new(client, auth);
6268/// // As the method needs a request, you would usually fill it with the desired information
6269/// // into the respective structure. Some of the parts shown here might not be applicable !
6270/// // Values shown here are possibly random and not representative !
6271/// let mut req = GoogleCloudDocumentaiV1ReviewDocumentRequest::default();
6272///
6273/// // You can configure optional parameters by calling the respective setters at will, and
6274/// // execute the final call using `doit()`.
6275/// // Values shown here are possibly random and not representative !
6276/// let result = hub.projects().locations_processors_human_review_config_review_document(req, "humanReviewConfig")
6277/// .doit().await;
6278/// # }
6279/// ```
6280pub struct ProjectLocationProcessorHumanReviewConfigReviewDocumentCall<'a, C>
6281where
6282 C: 'a,
6283{
6284 hub: &'a Document<C>,
6285 _request: GoogleCloudDocumentaiV1ReviewDocumentRequest,
6286 _human_review_config: String,
6287 _delegate: Option<&'a mut dyn common::Delegate>,
6288 _additional_params: HashMap<String, String>,
6289 _scopes: BTreeSet<String>,
6290}
6291
6292impl<'a, C> common::CallBuilder
6293 for ProjectLocationProcessorHumanReviewConfigReviewDocumentCall<'a, C>
6294{
6295}
6296
6297impl<'a, C> ProjectLocationProcessorHumanReviewConfigReviewDocumentCall<'a, C>
6298where
6299 C: common::Connector,
6300{
6301 /// Perform the operation you have build so far.
6302 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
6303 use std::borrow::Cow;
6304 use std::io::{Read, Seek};
6305
6306 use common::{url::Params, ToParts};
6307 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6308
6309 let mut dd = common::DefaultDelegate;
6310 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6311 dlg.begin(common::MethodInfo {
6312 id: "documentai.projects.locations.processors.humanReviewConfig.reviewDocument",
6313 http_method: hyper::Method::POST,
6314 });
6315
6316 for &field in ["alt", "humanReviewConfig"].iter() {
6317 if self._additional_params.contains_key(field) {
6318 dlg.finished(false);
6319 return Err(common::Error::FieldClash(field));
6320 }
6321 }
6322
6323 let mut params = Params::with_capacity(4 + self._additional_params.len());
6324 params.push("humanReviewConfig", self._human_review_config);
6325
6326 params.extend(self._additional_params.iter());
6327
6328 params.push("alt", "json");
6329 let mut url = self.hub._base_url.clone() + "v1/{+humanReviewConfig}:reviewDocument";
6330 if self._scopes.is_empty() {
6331 self._scopes
6332 .insert(Scope::CloudPlatform.as_ref().to_string());
6333 }
6334
6335 #[allow(clippy::single_element_loop)]
6336 for &(find_this, param_name) in [("{+humanReviewConfig}", "humanReviewConfig")].iter() {
6337 url = params.uri_replacement(url, param_name, find_this, true);
6338 }
6339 {
6340 let to_remove = ["humanReviewConfig"];
6341 params.remove_params(&to_remove);
6342 }
6343
6344 let url = params.parse_with_url(&url);
6345
6346 let mut json_mime_type = mime::APPLICATION_JSON;
6347 let mut request_value_reader = {
6348 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6349 common::remove_json_null_values(&mut value);
6350 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6351 serde_json::to_writer(&mut dst, &value).unwrap();
6352 dst
6353 };
6354 let request_size = request_value_reader
6355 .seek(std::io::SeekFrom::End(0))
6356 .unwrap();
6357 request_value_reader
6358 .seek(std::io::SeekFrom::Start(0))
6359 .unwrap();
6360
6361 loop {
6362 let token = match self
6363 .hub
6364 .auth
6365 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6366 .await
6367 {
6368 Ok(token) => token,
6369 Err(e) => match dlg.token(e) {
6370 Ok(token) => token,
6371 Err(e) => {
6372 dlg.finished(false);
6373 return Err(common::Error::MissingToken(e));
6374 }
6375 },
6376 };
6377 request_value_reader
6378 .seek(std::io::SeekFrom::Start(0))
6379 .unwrap();
6380 let mut req_result = {
6381 let client = &self.hub.client;
6382 dlg.pre_request();
6383 let mut req_builder = hyper::Request::builder()
6384 .method(hyper::Method::POST)
6385 .uri(url.as_str())
6386 .header(USER_AGENT, self.hub._user_agent.clone());
6387
6388 if let Some(token) = token.as_ref() {
6389 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6390 }
6391
6392 let request = req_builder
6393 .header(CONTENT_TYPE, json_mime_type.to_string())
6394 .header(CONTENT_LENGTH, request_size as u64)
6395 .body(common::to_body(
6396 request_value_reader.get_ref().clone().into(),
6397 ));
6398
6399 client.request(request.unwrap()).await
6400 };
6401
6402 match req_result {
6403 Err(err) => {
6404 if let common::Retry::After(d) = dlg.http_error(&err) {
6405 sleep(d).await;
6406 continue;
6407 }
6408 dlg.finished(false);
6409 return Err(common::Error::HttpError(err));
6410 }
6411 Ok(res) => {
6412 let (mut parts, body) = res.into_parts();
6413 let mut body = common::Body::new(body);
6414 if !parts.status.is_success() {
6415 let bytes = common::to_bytes(body).await.unwrap_or_default();
6416 let error = serde_json::from_str(&common::to_string(&bytes));
6417 let response = common::to_response(parts, bytes.into());
6418
6419 if let common::Retry::After(d) =
6420 dlg.http_failure(&response, error.as_ref().ok())
6421 {
6422 sleep(d).await;
6423 continue;
6424 }
6425
6426 dlg.finished(false);
6427
6428 return Err(match error {
6429 Ok(value) => common::Error::BadRequest(value),
6430 _ => common::Error::Failure(response),
6431 });
6432 }
6433 let response = {
6434 let bytes = common::to_bytes(body).await.unwrap_or_default();
6435 let encoded = common::to_string(&bytes);
6436 match serde_json::from_str(&encoded) {
6437 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6438 Err(error) => {
6439 dlg.response_json_decode_error(&encoded, &error);
6440 return Err(common::Error::JsonDecodeError(
6441 encoded.to_string(),
6442 error,
6443 ));
6444 }
6445 }
6446 };
6447
6448 dlg.finished(true);
6449 return Ok(response);
6450 }
6451 }
6452 }
6453 }
6454
6455 ///
6456 /// Sets the *request* property to the given value.
6457 ///
6458 /// Even though the property as already been set when instantiating this call,
6459 /// we provide this method for API completeness.
6460 pub fn request(
6461 mut self,
6462 new_value: GoogleCloudDocumentaiV1ReviewDocumentRequest,
6463 ) -> ProjectLocationProcessorHumanReviewConfigReviewDocumentCall<'a, C> {
6464 self._request = new_value;
6465 self
6466 }
6467 /// Required. The resource name of the HumanReviewConfig that the document will be reviewed with.
6468 ///
6469 /// Sets the *human review config* path property to the given value.
6470 ///
6471 /// Even though the property as already been set when instantiating this call,
6472 /// we provide this method for API completeness.
6473 pub fn human_review_config(
6474 mut self,
6475 new_value: &str,
6476 ) -> ProjectLocationProcessorHumanReviewConfigReviewDocumentCall<'a, C> {
6477 self._human_review_config = new_value.to_string();
6478 self
6479 }
6480 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6481 /// while executing the actual API request.
6482 ///
6483 /// ````text
6484 /// It should be used to handle progress information, and to implement a certain level of resilience.
6485 /// ````
6486 ///
6487 /// Sets the *delegate* property to the given value.
6488 pub fn delegate(
6489 mut self,
6490 new_value: &'a mut dyn common::Delegate,
6491 ) -> ProjectLocationProcessorHumanReviewConfigReviewDocumentCall<'a, C> {
6492 self._delegate = Some(new_value);
6493 self
6494 }
6495
6496 /// Set any additional parameter of the query string used in the request.
6497 /// It should be used to set parameters which are not yet available through their own
6498 /// setters.
6499 ///
6500 /// Please note that this method must not be used to set any of the known parameters
6501 /// which have their own setter method. If done anyway, the request will fail.
6502 ///
6503 /// # Additional Parameters
6504 ///
6505 /// * *$.xgafv* (query-string) - V1 error format.
6506 /// * *access_token* (query-string) - OAuth access token.
6507 /// * *alt* (query-string) - Data format for response.
6508 /// * *callback* (query-string) - JSONP
6509 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6510 /// * *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.
6511 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6512 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6513 /// * *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.
6514 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6515 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6516 pub fn param<T>(
6517 mut self,
6518 name: T,
6519 value: T,
6520 ) -> ProjectLocationProcessorHumanReviewConfigReviewDocumentCall<'a, C>
6521 where
6522 T: AsRef<str>,
6523 {
6524 self._additional_params
6525 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6526 self
6527 }
6528
6529 /// Identifies the authorization scope for the method you are building.
6530 ///
6531 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6532 /// [`Scope::CloudPlatform`].
6533 ///
6534 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6535 /// tokens for more than one scope.
6536 ///
6537 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6538 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6539 /// sufficient, a read-write scope will do as well.
6540 pub fn add_scope<St>(
6541 mut self,
6542 scope: St,
6543 ) -> ProjectLocationProcessorHumanReviewConfigReviewDocumentCall<'a, C>
6544 where
6545 St: AsRef<str>,
6546 {
6547 self._scopes.insert(String::from(scope.as_ref()));
6548 self
6549 }
6550 /// Identifies the authorization scope(s) for the method you are building.
6551 ///
6552 /// See [`Self::add_scope()`] for details.
6553 pub fn add_scopes<I, St>(
6554 mut self,
6555 scopes: I,
6556 ) -> ProjectLocationProcessorHumanReviewConfigReviewDocumentCall<'a, C>
6557 where
6558 I: IntoIterator<Item = St>,
6559 St: AsRef<str>,
6560 {
6561 self._scopes
6562 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6563 self
6564 }
6565
6566 /// Removes all scopes, and no default scope will be used either.
6567 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6568 /// for details).
6569 pub fn clear_scopes(
6570 mut self,
6571 ) -> ProjectLocationProcessorHumanReviewConfigReviewDocumentCall<'a, C> {
6572 self._scopes.clear();
6573 self
6574 }
6575}
6576
6577/// Retrieves a specific evaluation.
6578///
6579/// A builder for the *locations.processors.processorVersions.evaluations.get* method supported by a *project* resource.
6580/// It is not used directly, but through a [`ProjectMethods`] instance.
6581///
6582/// # Example
6583///
6584/// Instantiate a resource method builder
6585///
6586/// ```test_harness,no_run
6587/// # extern crate hyper;
6588/// # extern crate hyper_rustls;
6589/// # extern crate google_documentai1 as documentai1;
6590/// # async fn dox() {
6591/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6592///
6593/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6594/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6595/// # .with_native_roots()
6596/// # .unwrap()
6597/// # .https_only()
6598/// # .enable_http2()
6599/// # .build();
6600///
6601/// # let executor = hyper_util::rt::TokioExecutor::new();
6602/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6603/// # secret,
6604/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6605/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6606/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6607/// # ),
6608/// # ).build().await.unwrap();
6609///
6610/// # let client = hyper_util::client::legacy::Client::builder(
6611/// # hyper_util::rt::TokioExecutor::new()
6612/// # )
6613/// # .build(
6614/// # hyper_rustls::HttpsConnectorBuilder::new()
6615/// # .with_native_roots()
6616/// # .unwrap()
6617/// # .https_or_http()
6618/// # .enable_http2()
6619/// # .build()
6620/// # );
6621/// # let mut hub = Document::new(client, auth);
6622/// // You can configure optional parameters by calling the respective setters at will, and
6623/// // execute the final call using `doit()`.
6624/// // Values shown here are possibly random and not representative !
6625/// let result = hub.projects().locations_processors_processor_versions_evaluations_get("name")
6626/// .doit().await;
6627/// # }
6628/// ```
6629pub struct ProjectLocationProcessorProcessorVersionEvaluationGetCall<'a, C>
6630where
6631 C: 'a,
6632{
6633 hub: &'a Document<C>,
6634 _name: String,
6635 _delegate: Option<&'a mut dyn common::Delegate>,
6636 _additional_params: HashMap<String, String>,
6637 _scopes: BTreeSet<String>,
6638}
6639
6640impl<'a, C> common::CallBuilder
6641 for ProjectLocationProcessorProcessorVersionEvaluationGetCall<'a, C>
6642{
6643}
6644
6645impl<'a, C> ProjectLocationProcessorProcessorVersionEvaluationGetCall<'a, C>
6646where
6647 C: common::Connector,
6648{
6649 /// Perform the operation you have build so far.
6650 pub async fn doit(
6651 mut self,
6652 ) -> common::Result<(common::Response, GoogleCloudDocumentaiV1Evaluation)> {
6653 use std::borrow::Cow;
6654 use std::io::{Read, Seek};
6655
6656 use common::{url::Params, ToParts};
6657 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6658
6659 let mut dd = common::DefaultDelegate;
6660 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6661 dlg.begin(common::MethodInfo {
6662 id: "documentai.projects.locations.processors.processorVersions.evaluations.get",
6663 http_method: hyper::Method::GET,
6664 });
6665
6666 for &field in ["alt", "name"].iter() {
6667 if self._additional_params.contains_key(field) {
6668 dlg.finished(false);
6669 return Err(common::Error::FieldClash(field));
6670 }
6671 }
6672
6673 let mut params = Params::with_capacity(3 + self._additional_params.len());
6674 params.push("name", self._name);
6675
6676 params.extend(self._additional_params.iter());
6677
6678 params.push("alt", "json");
6679 let mut url = self.hub._base_url.clone() + "v1/{+name}";
6680 if self._scopes.is_empty() {
6681 self._scopes
6682 .insert(Scope::CloudPlatform.as_ref().to_string());
6683 }
6684
6685 #[allow(clippy::single_element_loop)]
6686 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6687 url = params.uri_replacement(url, param_name, find_this, true);
6688 }
6689 {
6690 let to_remove = ["name"];
6691 params.remove_params(&to_remove);
6692 }
6693
6694 let url = params.parse_with_url(&url);
6695
6696 loop {
6697 let token = match self
6698 .hub
6699 .auth
6700 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6701 .await
6702 {
6703 Ok(token) => token,
6704 Err(e) => match dlg.token(e) {
6705 Ok(token) => token,
6706 Err(e) => {
6707 dlg.finished(false);
6708 return Err(common::Error::MissingToken(e));
6709 }
6710 },
6711 };
6712 let mut req_result = {
6713 let client = &self.hub.client;
6714 dlg.pre_request();
6715 let mut req_builder = hyper::Request::builder()
6716 .method(hyper::Method::GET)
6717 .uri(url.as_str())
6718 .header(USER_AGENT, self.hub._user_agent.clone());
6719
6720 if let Some(token) = token.as_ref() {
6721 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6722 }
6723
6724 let request = req_builder
6725 .header(CONTENT_LENGTH, 0_u64)
6726 .body(common::to_body::<String>(None));
6727
6728 client.request(request.unwrap()).await
6729 };
6730
6731 match req_result {
6732 Err(err) => {
6733 if let common::Retry::After(d) = dlg.http_error(&err) {
6734 sleep(d).await;
6735 continue;
6736 }
6737 dlg.finished(false);
6738 return Err(common::Error::HttpError(err));
6739 }
6740 Ok(res) => {
6741 let (mut parts, body) = res.into_parts();
6742 let mut body = common::Body::new(body);
6743 if !parts.status.is_success() {
6744 let bytes = common::to_bytes(body).await.unwrap_or_default();
6745 let error = serde_json::from_str(&common::to_string(&bytes));
6746 let response = common::to_response(parts, bytes.into());
6747
6748 if let common::Retry::After(d) =
6749 dlg.http_failure(&response, error.as_ref().ok())
6750 {
6751 sleep(d).await;
6752 continue;
6753 }
6754
6755 dlg.finished(false);
6756
6757 return Err(match error {
6758 Ok(value) => common::Error::BadRequest(value),
6759 _ => common::Error::Failure(response),
6760 });
6761 }
6762 let response = {
6763 let bytes = common::to_bytes(body).await.unwrap_or_default();
6764 let encoded = common::to_string(&bytes);
6765 match serde_json::from_str(&encoded) {
6766 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6767 Err(error) => {
6768 dlg.response_json_decode_error(&encoded, &error);
6769 return Err(common::Error::JsonDecodeError(
6770 encoded.to_string(),
6771 error,
6772 ));
6773 }
6774 }
6775 };
6776
6777 dlg.finished(true);
6778 return Ok(response);
6779 }
6780 }
6781 }
6782 }
6783
6784 /// Required. The resource name of the Evaluation to get. `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}/evaluations/{evaluation}`
6785 ///
6786 /// Sets the *name* path property to the given value.
6787 ///
6788 /// Even though the property as already been set when instantiating this call,
6789 /// we provide this method for API completeness.
6790 pub fn name(
6791 mut self,
6792 new_value: &str,
6793 ) -> ProjectLocationProcessorProcessorVersionEvaluationGetCall<'a, C> {
6794 self._name = new_value.to_string();
6795 self
6796 }
6797 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6798 /// while executing the actual API request.
6799 ///
6800 /// ````text
6801 /// It should be used to handle progress information, and to implement a certain level of resilience.
6802 /// ````
6803 ///
6804 /// Sets the *delegate* property to the given value.
6805 pub fn delegate(
6806 mut self,
6807 new_value: &'a mut dyn common::Delegate,
6808 ) -> ProjectLocationProcessorProcessorVersionEvaluationGetCall<'a, C> {
6809 self._delegate = Some(new_value);
6810 self
6811 }
6812
6813 /// Set any additional parameter of the query string used in the request.
6814 /// It should be used to set parameters which are not yet available through their own
6815 /// setters.
6816 ///
6817 /// Please note that this method must not be used to set any of the known parameters
6818 /// which have their own setter method. If done anyway, the request will fail.
6819 ///
6820 /// # Additional Parameters
6821 ///
6822 /// * *$.xgafv* (query-string) - V1 error format.
6823 /// * *access_token* (query-string) - OAuth access token.
6824 /// * *alt* (query-string) - Data format for response.
6825 /// * *callback* (query-string) - JSONP
6826 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6827 /// * *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.
6828 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6829 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6830 /// * *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.
6831 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6832 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6833 pub fn param<T>(
6834 mut self,
6835 name: T,
6836 value: T,
6837 ) -> ProjectLocationProcessorProcessorVersionEvaluationGetCall<'a, C>
6838 where
6839 T: AsRef<str>,
6840 {
6841 self._additional_params
6842 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6843 self
6844 }
6845
6846 /// Identifies the authorization scope for the method you are building.
6847 ///
6848 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6849 /// [`Scope::CloudPlatform`].
6850 ///
6851 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6852 /// tokens for more than one scope.
6853 ///
6854 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6855 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6856 /// sufficient, a read-write scope will do as well.
6857 pub fn add_scope<St>(
6858 mut self,
6859 scope: St,
6860 ) -> ProjectLocationProcessorProcessorVersionEvaluationGetCall<'a, C>
6861 where
6862 St: AsRef<str>,
6863 {
6864 self._scopes.insert(String::from(scope.as_ref()));
6865 self
6866 }
6867 /// Identifies the authorization scope(s) for the method you are building.
6868 ///
6869 /// See [`Self::add_scope()`] for details.
6870 pub fn add_scopes<I, St>(
6871 mut self,
6872 scopes: I,
6873 ) -> ProjectLocationProcessorProcessorVersionEvaluationGetCall<'a, C>
6874 where
6875 I: IntoIterator<Item = St>,
6876 St: AsRef<str>,
6877 {
6878 self._scopes
6879 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6880 self
6881 }
6882
6883 /// Removes all scopes, and no default scope will be used either.
6884 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6885 /// for details).
6886 pub fn clear_scopes(
6887 mut self,
6888 ) -> ProjectLocationProcessorProcessorVersionEvaluationGetCall<'a, C> {
6889 self._scopes.clear();
6890 self
6891 }
6892}
6893
6894/// Retrieves a set of evaluations for a given processor version.
6895///
6896/// A builder for the *locations.processors.processorVersions.evaluations.list* method supported by a *project* resource.
6897/// It is not used directly, but through a [`ProjectMethods`] instance.
6898///
6899/// # Example
6900///
6901/// Instantiate a resource method builder
6902///
6903/// ```test_harness,no_run
6904/// # extern crate hyper;
6905/// # extern crate hyper_rustls;
6906/// # extern crate google_documentai1 as documentai1;
6907/// # async fn dox() {
6908/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6909///
6910/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6911/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6912/// # .with_native_roots()
6913/// # .unwrap()
6914/// # .https_only()
6915/// # .enable_http2()
6916/// # .build();
6917///
6918/// # let executor = hyper_util::rt::TokioExecutor::new();
6919/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6920/// # secret,
6921/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6922/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6923/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6924/// # ),
6925/// # ).build().await.unwrap();
6926///
6927/// # let client = hyper_util::client::legacy::Client::builder(
6928/// # hyper_util::rt::TokioExecutor::new()
6929/// # )
6930/// # .build(
6931/// # hyper_rustls::HttpsConnectorBuilder::new()
6932/// # .with_native_roots()
6933/// # .unwrap()
6934/// # .https_or_http()
6935/// # .enable_http2()
6936/// # .build()
6937/// # );
6938/// # let mut hub = Document::new(client, auth);
6939/// // You can configure optional parameters by calling the respective setters at will, and
6940/// // execute the final call using `doit()`.
6941/// // Values shown here are possibly random and not representative !
6942/// let result = hub.projects().locations_processors_processor_versions_evaluations_list("parent")
6943/// .page_token("ea")
6944/// .page_size(-55)
6945/// .doit().await;
6946/// # }
6947/// ```
6948pub struct ProjectLocationProcessorProcessorVersionEvaluationListCall<'a, C>
6949where
6950 C: 'a,
6951{
6952 hub: &'a Document<C>,
6953 _parent: String,
6954 _page_token: Option<String>,
6955 _page_size: Option<i32>,
6956 _delegate: Option<&'a mut dyn common::Delegate>,
6957 _additional_params: HashMap<String, String>,
6958 _scopes: BTreeSet<String>,
6959}
6960
6961impl<'a, C> common::CallBuilder
6962 for ProjectLocationProcessorProcessorVersionEvaluationListCall<'a, C>
6963{
6964}
6965
6966impl<'a, C> ProjectLocationProcessorProcessorVersionEvaluationListCall<'a, C>
6967where
6968 C: common::Connector,
6969{
6970 /// Perform the operation you have build so far.
6971 pub async fn doit(
6972 mut self,
6973 ) -> common::Result<(
6974 common::Response,
6975 GoogleCloudDocumentaiV1ListEvaluationsResponse,
6976 )> {
6977 use std::borrow::Cow;
6978 use std::io::{Read, Seek};
6979
6980 use common::{url::Params, ToParts};
6981 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6982
6983 let mut dd = common::DefaultDelegate;
6984 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6985 dlg.begin(common::MethodInfo {
6986 id: "documentai.projects.locations.processors.processorVersions.evaluations.list",
6987 http_method: hyper::Method::GET,
6988 });
6989
6990 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
6991 if self._additional_params.contains_key(field) {
6992 dlg.finished(false);
6993 return Err(common::Error::FieldClash(field));
6994 }
6995 }
6996
6997 let mut params = Params::with_capacity(5 + self._additional_params.len());
6998 params.push("parent", self._parent);
6999 if let Some(value) = self._page_token.as_ref() {
7000 params.push("pageToken", value);
7001 }
7002 if let Some(value) = self._page_size.as_ref() {
7003 params.push("pageSize", value.to_string());
7004 }
7005
7006 params.extend(self._additional_params.iter());
7007
7008 params.push("alt", "json");
7009 let mut url = self.hub._base_url.clone() + "v1/{+parent}/evaluations";
7010 if self._scopes.is_empty() {
7011 self._scopes
7012 .insert(Scope::CloudPlatform.as_ref().to_string());
7013 }
7014
7015 #[allow(clippy::single_element_loop)]
7016 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7017 url = params.uri_replacement(url, param_name, find_this, true);
7018 }
7019 {
7020 let to_remove = ["parent"];
7021 params.remove_params(&to_remove);
7022 }
7023
7024 let url = params.parse_with_url(&url);
7025
7026 loop {
7027 let token = match self
7028 .hub
7029 .auth
7030 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7031 .await
7032 {
7033 Ok(token) => token,
7034 Err(e) => match dlg.token(e) {
7035 Ok(token) => token,
7036 Err(e) => {
7037 dlg.finished(false);
7038 return Err(common::Error::MissingToken(e));
7039 }
7040 },
7041 };
7042 let mut req_result = {
7043 let client = &self.hub.client;
7044 dlg.pre_request();
7045 let mut req_builder = hyper::Request::builder()
7046 .method(hyper::Method::GET)
7047 .uri(url.as_str())
7048 .header(USER_AGENT, self.hub._user_agent.clone());
7049
7050 if let Some(token) = token.as_ref() {
7051 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7052 }
7053
7054 let request = req_builder
7055 .header(CONTENT_LENGTH, 0_u64)
7056 .body(common::to_body::<String>(None));
7057
7058 client.request(request.unwrap()).await
7059 };
7060
7061 match req_result {
7062 Err(err) => {
7063 if let common::Retry::After(d) = dlg.http_error(&err) {
7064 sleep(d).await;
7065 continue;
7066 }
7067 dlg.finished(false);
7068 return Err(common::Error::HttpError(err));
7069 }
7070 Ok(res) => {
7071 let (mut parts, body) = res.into_parts();
7072 let mut body = common::Body::new(body);
7073 if !parts.status.is_success() {
7074 let bytes = common::to_bytes(body).await.unwrap_or_default();
7075 let error = serde_json::from_str(&common::to_string(&bytes));
7076 let response = common::to_response(parts, bytes.into());
7077
7078 if let common::Retry::After(d) =
7079 dlg.http_failure(&response, error.as_ref().ok())
7080 {
7081 sleep(d).await;
7082 continue;
7083 }
7084
7085 dlg.finished(false);
7086
7087 return Err(match error {
7088 Ok(value) => common::Error::BadRequest(value),
7089 _ => common::Error::Failure(response),
7090 });
7091 }
7092 let response = {
7093 let bytes = common::to_bytes(body).await.unwrap_or_default();
7094 let encoded = common::to_string(&bytes);
7095 match serde_json::from_str(&encoded) {
7096 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7097 Err(error) => {
7098 dlg.response_json_decode_error(&encoded, &error);
7099 return Err(common::Error::JsonDecodeError(
7100 encoded.to_string(),
7101 error,
7102 ));
7103 }
7104 }
7105 };
7106
7107 dlg.finished(true);
7108 return Ok(response);
7109 }
7110 }
7111 }
7112 }
7113
7114 /// Required. The resource name of the ProcessorVersion to list evaluations for. `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`
7115 ///
7116 /// Sets the *parent* path property to the given value.
7117 ///
7118 /// Even though the property as already been set when instantiating this call,
7119 /// we provide this method for API completeness.
7120 pub fn parent(
7121 mut self,
7122 new_value: &str,
7123 ) -> ProjectLocationProcessorProcessorVersionEvaluationListCall<'a, C> {
7124 self._parent = new_value.to_string();
7125 self
7126 }
7127 /// A page token, received from a previous `ListEvaluations` call. Provide this to retrieve the subsequent page.
7128 ///
7129 /// Sets the *page token* query property to the given value.
7130 pub fn page_token(
7131 mut self,
7132 new_value: &str,
7133 ) -> ProjectLocationProcessorProcessorVersionEvaluationListCall<'a, C> {
7134 self._page_token = Some(new_value.to_string());
7135 self
7136 }
7137 /// 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`.
7138 ///
7139 /// Sets the *page size* query property to the given value.
7140 pub fn page_size(
7141 mut self,
7142 new_value: i32,
7143 ) -> ProjectLocationProcessorProcessorVersionEvaluationListCall<'a, C> {
7144 self._page_size = Some(new_value);
7145 self
7146 }
7147 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7148 /// while executing the actual API request.
7149 ///
7150 /// ````text
7151 /// It should be used to handle progress information, and to implement a certain level of resilience.
7152 /// ````
7153 ///
7154 /// Sets the *delegate* property to the given value.
7155 pub fn delegate(
7156 mut self,
7157 new_value: &'a mut dyn common::Delegate,
7158 ) -> ProjectLocationProcessorProcessorVersionEvaluationListCall<'a, C> {
7159 self._delegate = Some(new_value);
7160 self
7161 }
7162
7163 /// Set any additional parameter of the query string used in the request.
7164 /// It should be used to set parameters which are not yet available through their own
7165 /// setters.
7166 ///
7167 /// Please note that this method must not be used to set any of the known parameters
7168 /// which have their own setter method. If done anyway, the request will fail.
7169 ///
7170 /// # Additional Parameters
7171 ///
7172 /// * *$.xgafv* (query-string) - V1 error format.
7173 /// * *access_token* (query-string) - OAuth access token.
7174 /// * *alt* (query-string) - Data format for response.
7175 /// * *callback* (query-string) - JSONP
7176 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7177 /// * *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.
7178 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7179 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7180 /// * *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.
7181 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7182 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7183 pub fn param<T>(
7184 mut self,
7185 name: T,
7186 value: T,
7187 ) -> ProjectLocationProcessorProcessorVersionEvaluationListCall<'a, C>
7188 where
7189 T: AsRef<str>,
7190 {
7191 self._additional_params
7192 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7193 self
7194 }
7195
7196 /// Identifies the authorization scope for the method you are building.
7197 ///
7198 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7199 /// [`Scope::CloudPlatform`].
7200 ///
7201 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7202 /// tokens for more than one scope.
7203 ///
7204 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7205 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7206 /// sufficient, a read-write scope will do as well.
7207 pub fn add_scope<St>(
7208 mut self,
7209 scope: St,
7210 ) -> ProjectLocationProcessorProcessorVersionEvaluationListCall<'a, C>
7211 where
7212 St: AsRef<str>,
7213 {
7214 self._scopes.insert(String::from(scope.as_ref()));
7215 self
7216 }
7217 /// Identifies the authorization scope(s) for the method you are building.
7218 ///
7219 /// See [`Self::add_scope()`] for details.
7220 pub fn add_scopes<I, St>(
7221 mut self,
7222 scopes: I,
7223 ) -> ProjectLocationProcessorProcessorVersionEvaluationListCall<'a, C>
7224 where
7225 I: IntoIterator<Item = St>,
7226 St: AsRef<str>,
7227 {
7228 self._scopes
7229 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7230 self
7231 }
7232
7233 /// Removes all scopes, and no default scope will be used either.
7234 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7235 /// for details).
7236 pub fn clear_scopes(
7237 mut self,
7238 ) -> ProjectLocationProcessorProcessorVersionEvaluationListCall<'a, C> {
7239 self._scopes.clear();
7240 self
7241 }
7242}
7243
7244/// LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in the [Document] format.
7245///
7246/// A builder for the *locations.processors.processorVersions.batchProcess* method supported by a *project* resource.
7247/// It is not used directly, but through a [`ProjectMethods`] instance.
7248///
7249/// # Example
7250///
7251/// Instantiate a resource method builder
7252///
7253/// ```test_harness,no_run
7254/// # extern crate hyper;
7255/// # extern crate hyper_rustls;
7256/// # extern crate google_documentai1 as documentai1;
7257/// use documentai1::api::GoogleCloudDocumentaiV1BatchProcessRequest;
7258/// # async fn dox() {
7259/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7260///
7261/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7262/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7263/// # .with_native_roots()
7264/// # .unwrap()
7265/// # .https_only()
7266/// # .enable_http2()
7267/// # .build();
7268///
7269/// # let executor = hyper_util::rt::TokioExecutor::new();
7270/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7271/// # secret,
7272/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7273/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7274/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7275/// # ),
7276/// # ).build().await.unwrap();
7277///
7278/// # let client = hyper_util::client::legacy::Client::builder(
7279/// # hyper_util::rt::TokioExecutor::new()
7280/// # )
7281/// # .build(
7282/// # hyper_rustls::HttpsConnectorBuilder::new()
7283/// # .with_native_roots()
7284/// # .unwrap()
7285/// # .https_or_http()
7286/// # .enable_http2()
7287/// # .build()
7288/// # );
7289/// # let mut hub = Document::new(client, auth);
7290/// // As the method needs a request, you would usually fill it with the desired information
7291/// // into the respective structure. Some of the parts shown here might not be applicable !
7292/// // Values shown here are possibly random and not representative !
7293/// let mut req = GoogleCloudDocumentaiV1BatchProcessRequest::default();
7294///
7295/// // You can configure optional parameters by calling the respective setters at will, and
7296/// // execute the final call using `doit()`.
7297/// // Values shown here are possibly random and not representative !
7298/// let result = hub.projects().locations_processors_processor_versions_batch_process(req, "name")
7299/// .doit().await;
7300/// # }
7301/// ```
7302pub struct ProjectLocationProcessorProcessorVersionBatchProcesCall<'a, C>
7303where
7304 C: 'a,
7305{
7306 hub: &'a Document<C>,
7307 _request: GoogleCloudDocumentaiV1BatchProcessRequest,
7308 _name: String,
7309 _delegate: Option<&'a mut dyn common::Delegate>,
7310 _additional_params: HashMap<String, String>,
7311 _scopes: BTreeSet<String>,
7312}
7313
7314impl<'a, C> common::CallBuilder for ProjectLocationProcessorProcessorVersionBatchProcesCall<'a, C> {}
7315
7316impl<'a, C> ProjectLocationProcessorProcessorVersionBatchProcesCall<'a, C>
7317where
7318 C: common::Connector,
7319{
7320 /// Perform the operation you have build so far.
7321 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
7322 use std::borrow::Cow;
7323 use std::io::{Read, Seek};
7324
7325 use common::{url::Params, ToParts};
7326 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7327
7328 let mut dd = common::DefaultDelegate;
7329 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7330 dlg.begin(common::MethodInfo {
7331 id: "documentai.projects.locations.processors.processorVersions.batchProcess",
7332 http_method: hyper::Method::POST,
7333 });
7334
7335 for &field in ["alt", "name"].iter() {
7336 if self._additional_params.contains_key(field) {
7337 dlg.finished(false);
7338 return Err(common::Error::FieldClash(field));
7339 }
7340 }
7341
7342 let mut params = Params::with_capacity(4 + self._additional_params.len());
7343 params.push("name", self._name);
7344
7345 params.extend(self._additional_params.iter());
7346
7347 params.push("alt", "json");
7348 let mut url = self.hub._base_url.clone() + "v1/{+name}:batchProcess";
7349 if self._scopes.is_empty() {
7350 self._scopes
7351 .insert(Scope::CloudPlatform.as_ref().to_string());
7352 }
7353
7354 #[allow(clippy::single_element_loop)]
7355 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7356 url = params.uri_replacement(url, param_name, find_this, true);
7357 }
7358 {
7359 let to_remove = ["name"];
7360 params.remove_params(&to_remove);
7361 }
7362
7363 let url = params.parse_with_url(&url);
7364
7365 let mut json_mime_type = mime::APPLICATION_JSON;
7366 let mut request_value_reader = {
7367 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7368 common::remove_json_null_values(&mut value);
7369 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7370 serde_json::to_writer(&mut dst, &value).unwrap();
7371 dst
7372 };
7373 let request_size = request_value_reader
7374 .seek(std::io::SeekFrom::End(0))
7375 .unwrap();
7376 request_value_reader
7377 .seek(std::io::SeekFrom::Start(0))
7378 .unwrap();
7379
7380 loop {
7381 let token = match self
7382 .hub
7383 .auth
7384 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7385 .await
7386 {
7387 Ok(token) => token,
7388 Err(e) => match dlg.token(e) {
7389 Ok(token) => token,
7390 Err(e) => {
7391 dlg.finished(false);
7392 return Err(common::Error::MissingToken(e));
7393 }
7394 },
7395 };
7396 request_value_reader
7397 .seek(std::io::SeekFrom::Start(0))
7398 .unwrap();
7399 let mut req_result = {
7400 let client = &self.hub.client;
7401 dlg.pre_request();
7402 let mut req_builder = hyper::Request::builder()
7403 .method(hyper::Method::POST)
7404 .uri(url.as_str())
7405 .header(USER_AGENT, self.hub._user_agent.clone());
7406
7407 if let Some(token) = token.as_ref() {
7408 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7409 }
7410
7411 let request = req_builder
7412 .header(CONTENT_TYPE, json_mime_type.to_string())
7413 .header(CONTENT_LENGTH, request_size as u64)
7414 .body(common::to_body(
7415 request_value_reader.get_ref().clone().into(),
7416 ));
7417
7418 client.request(request.unwrap()).await
7419 };
7420
7421 match req_result {
7422 Err(err) => {
7423 if let common::Retry::After(d) = dlg.http_error(&err) {
7424 sleep(d).await;
7425 continue;
7426 }
7427 dlg.finished(false);
7428 return Err(common::Error::HttpError(err));
7429 }
7430 Ok(res) => {
7431 let (mut parts, body) = res.into_parts();
7432 let mut body = common::Body::new(body);
7433 if !parts.status.is_success() {
7434 let bytes = common::to_bytes(body).await.unwrap_or_default();
7435 let error = serde_json::from_str(&common::to_string(&bytes));
7436 let response = common::to_response(parts, bytes.into());
7437
7438 if let common::Retry::After(d) =
7439 dlg.http_failure(&response, error.as_ref().ok())
7440 {
7441 sleep(d).await;
7442 continue;
7443 }
7444
7445 dlg.finished(false);
7446
7447 return Err(match error {
7448 Ok(value) => common::Error::BadRequest(value),
7449 _ => common::Error::Failure(response),
7450 });
7451 }
7452 let response = {
7453 let bytes = common::to_bytes(body).await.unwrap_or_default();
7454 let encoded = common::to_string(&bytes);
7455 match serde_json::from_str(&encoded) {
7456 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7457 Err(error) => {
7458 dlg.response_json_decode_error(&encoded, &error);
7459 return Err(common::Error::JsonDecodeError(
7460 encoded.to_string(),
7461 error,
7462 ));
7463 }
7464 }
7465 };
7466
7467 dlg.finished(true);
7468 return Ok(response);
7469 }
7470 }
7471 }
7472 }
7473
7474 ///
7475 /// Sets the *request* property to the given value.
7476 ///
7477 /// Even though the property as already been set when instantiating this call,
7478 /// we provide this method for API completeness.
7479 pub fn request(
7480 mut self,
7481 new_value: GoogleCloudDocumentaiV1BatchProcessRequest,
7482 ) -> ProjectLocationProcessorProcessorVersionBatchProcesCall<'a, C> {
7483 self._request = new_value;
7484 self
7485 }
7486 /// Required. The resource name of Processor or ProcessorVersion. Format: `projects/{project}/locations/{location}/processors/{processor}`, or `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`
7487 ///
7488 /// Sets the *name* path property to the given value.
7489 ///
7490 /// Even though the property as already been set when instantiating this call,
7491 /// we provide this method for API completeness.
7492 pub fn name(
7493 mut self,
7494 new_value: &str,
7495 ) -> ProjectLocationProcessorProcessorVersionBatchProcesCall<'a, C> {
7496 self._name = new_value.to_string();
7497 self
7498 }
7499 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7500 /// while executing the actual API request.
7501 ///
7502 /// ````text
7503 /// It should be used to handle progress information, and to implement a certain level of resilience.
7504 /// ````
7505 ///
7506 /// Sets the *delegate* property to the given value.
7507 pub fn delegate(
7508 mut self,
7509 new_value: &'a mut dyn common::Delegate,
7510 ) -> ProjectLocationProcessorProcessorVersionBatchProcesCall<'a, C> {
7511 self._delegate = Some(new_value);
7512 self
7513 }
7514
7515 /// Set any additional parameter of the query string used in the request.
7516 /// It should be used to set parameters which are not yet available through their own
7517 /// setters.
7518 ///
7519 /// Please note that this method must not be used to set any of the known parameters
7520 /// which have their own setter method. If done anyway, the request will fail.
7521 ///
7522 /// # Additional Parameters
7523 ///
7524 /// * *$.xgafv* (query-string) - V1 error format.
7525 /// * *access_token* (query-string) - OAuth access token.
7526 /// * *alt* (query-string) - Data format for response.
7527 /// * *callback* (query-string) - JSONP
7528 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7529 /// * *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.
7530 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7531 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7532 /// * *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.
7533 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7534 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7535 pub fn param<T>(
7536 mut self,
7537 name: T,
7538 value: T,
7539 ) -> ProjectLocationProcessorProcessorVersionBatchProcesCall<'a, C>
7540 where
7541 T: AsRef<str>,
7542 {
7543 self._additional_params
7544 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7545 self
7546 }
7547
7548 /// Identifies the authorization scope for the method you are building.
7549 ///
7550 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7551 /// [`Scope::CloudPlatform`].
7552 ///
7553 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7554 /// tokens for more than one scope.
7555 ///
7556 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7557 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7558 /// sufficient, a read-write scope will do as well.
7559 pub fn add_scope<St>(
7560 mut self,
7561 scope: St,
7562 ) -> ProjectLocationProcessorProcessorVersionBatchProcesCall<'a, C>
7563 where
7564 St: AsRef<str>,
7565 {
7566 self._scopes.insert(String::from(scope.as_ref()));
7567 self
7568 }
7569 /// Identifies the authorization scope(s) for the method you are building.
7570 ///
7571 /// See [`Self::add_scope()`] for details.
7572 pub fn add_scopes<I, St>(
7573 mut self,
7574 scopes: I,
7575 ) -> ProjectLocationProcessorProcessorVersionBatchProcesCall<'a, C>
7576 where
7577 I: IntoIterator<Item = St>,
7578 St: AsRef<str>,
7579 {
7580 self._scopes
7581 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7582 self
7583 }
7584
7585 /// Removes all scopes, and no default scope will be used either.
7586 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7587 /// for details).
7588 pub fn clear_scopes(
7589 mut self,
7590 ) -> ProjectLocationProcessorProcessorVersionBatchProcesCall<'a, C> {
7591 self._scopes.clear();
7592 self
7593 }
7594}
7595
7596/// Deletes the processor version, all artifacts under the processor version will be deleted.
7597///
7598/// A builder for the *locations.processors.processorVersions.delete* method supported by a *project* resource.
7599/// It is not used directly, but through a [`ProjectMethods`] instance.
7600///
7601/// # Example
7602///
7603/// Instantiate a resource method builder
7604///
7605/// ```test_harness,no_run
7606/// # extern crate hyper;
7607/// # extern crate hyper_rustls;
7608/// # extern crate google_documentai1 as documentai1;
7609/// # async fn dox() {
7610/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7611///
7612/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7613/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7614/// # .with_native_roots()
7615/// # .unwrap()
7616/// # .https_only()
7617/// # .enable_http2()
7618/// # .build();
7619///
7620/// # let executor = hyper_util::rt::TokioExecutor::new();
7621/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7622/// # secret,
7623/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7624/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7625/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7626/// # ),
7627/// # ).build().await.unwrap();
7628///
7629/// # let client = hyper_util::client::legacy::Client::builder(
7630/// # hyper_util::rt::TokioExecutor::new()
7631/// # )
7632/// # .build(
7633/// # hyper_rustls::HttpsConnectorBuilder::new()
7634/// # .with_native_roots()
7635/// # .unwrap()
7636/// # .https_or_http()
7637/// # .enable_http2()
7638/// # .build()
7639/// # );
7640/// # let mut hub = Document::new(client, auth);
7641/// // You can configure optional parameters by calling the respective setters at will, and
7642/// // execute the final call using `doit()`.
7643/// // Values shown here are possibly random and not representative !
7644/// let result = hub.projects().locations_processors_processor_versions_delete("name")
7645/// .doit().await;
7646/// # }
7647/// ```
7648pub struct ProjectLocationProcessorProcessorVersionDeleteCall<'a, C>
7649where
7650 C: 'a,
7651{
7652 hub: &'a Document<C>,
7653 _name: String,
7654 _delegate: Option<&'a mut dyn common::Delegate>,
7655 _additional_params: HashMap<String, String>,
7656 _scopes: BTreeSet<String>,
7657}
7658
7659impl<'a, C> common::CallBuilder for ProjectLocationProcessorProcessorVersionDeleteCall<'a, C> {}
7660
7661impl<'a, C> ProjectLocationProcessorProcessorVersionDeleteCall<'a, C>
7662where
7663 C: common::Connector,
7664{
7665 /// Perform the operation you have build so far.
7666 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
7667 use std::borrow::Cow;
7668 use std::io::{Read, Seek};
7669
7670 use common::{url::Params, ToParts};
7671 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7672
7673 let mut dd = common::DefaultDelegate;
7674 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7675 dlg.begin(common::MethodInfo {
7676 id: "documentai.projects.locations.processors.processorVersions.delete",
7677 http_method: hyper::Method::DELETE,
7678 });
7679
7680 for &field in ["alt", "name"].iter() {
7681 if self._additional_params.contains_key(field) {
7682 dlg.finished(false);
7683 return Err(common::Error::FieldClash(field));
7684 }
7685 }
7686
7687 let mut params = Params::with_capacity(3 + self._additional_params.len());
7688 params.push("name", self._name);
7689
7690 params.extend(self._additional_params.iter());
7691
7692 params.push("alt", "json");
7693 let mut url = self.hub._base_url.clone() + "v1/{+name}";
7694 if self._scopes.is_empty() {
7695 self._scopes
7696 .insert(Scope::CloudPlatform.as_ref().to_string());
7697 }
7698
7699 #[allow(clippy::single_element_loop)]
7700 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7701 url = params.uri_replacement(url, param_name, find_this, true);
7702 }
7703 {
7704 let to_remove = ["name"];
7705 params.remove_params(&to_remove);
7706 }
7707
7708 let url = params.parse_with_url(&url);
7709
7710 loop {
7711 let token = match self
7712 .hub
7713 .auth
7714 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7715 .await
7716 {
7717 Ok(token) => token,
7718 Err(e) => match dlg.token(e) {
7719 Ok(token) => token,
7720 Err(e) => {
7721 dlg.finished(false);
7722 return Err(common::Error::MissingToken(e));
7723 }
7724 },
7725 };
7726 let mut req_result = {
7727 let client = &self.hub.client;
7728 dlg.pre_request();
7729 let mut req_builder = hyper::Request::builder()
7730 .method(hyper::Method::DELETE)
7731 .uri(url.as_str())
7732 .header(USER_AGENT, self.hub._user_agent.clone());
7733
7734 if let Some(token) = token.as_ref() {
7735 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7736 }
7737
7738 let request = req_builder
7739 .header(CONTENT_LENGTH, 0_u64)
7740 .body(common::to_body::<String>(None));
7741
7742 client.request(request.unwrap()).await
7743 };
7744
7745 match req_result {
7746 Err(err) => {
7747 if let common::Retry::After(d) = dlg.http_error(&err) {
7748 sleep(d).await;
7749 continue;
7750 }
7751 dlg.finished(false);
7752 return Err(common::Error::HttpError(err));
7753 }
7754 Ok(res) => {
7755 let (mut parts, body) = res.into_parts();
7756 let mut body = common::Body::new(body);
7757 if !parts.status.is_success() {
7758 let bytes = common::to_bytes(body).await.unwrap_or_default();
7759 let error = serde_json::from_str(&common::to_string(&bytes));
7760 let response = common::to_response(parts, bytes.into());
7761
7762 if let common::Retry::After(d) =
7763 dlg.http_failure(&response, error.as_ref().ok())
7764 {
7765 sleep(d).await;
7766 continue;
7767 }
7768
7769 dlg.finished(false);
7770
7771 return Err(match error {
7772 Ok(value) => common::Error::BadRequest(value),
7773 _ => common::Error::Failure(response),
7774 });
7775 }
7776 let response = {
7777 let bytes = common::to_bytes(body).await.unwrap_or_default();
7778 let encoded = common::to_string(&bytes);
7779 match serde_json::from_str(&encoded) {
7780 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7781 Err(error) => {
7782 dlg.response_json_decode_error(&encoded, &error);
7783 return Err(common::Error::JsonDecodeError(
7784 encoded.to_string(),
7785 error,
7786 ));
7787 }
7788 }
7789 };
7790
7791 dlg.finished(true);
7792 return Ok(response);
7793 }
7794 }
7795 }
7796 }
7797
7798 /// Required. The processor version resource name to be deleted.
7799 ///
7800 /// Sets the *name* path property to the given value.
7801 ///
7802 /// Even though the property as already been set when instantiating this call,
7803 /// we provide this method for API completeness.
7804 pub fn name(
7805 mut self,
7806 new_value: &str,
7807 ) -> ProjectLocationProcessorProcessorVersionDeleteCall<'a, C> {
7808 self._name = new_value.to_string();
7809 self
7810 }
7811 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7812 /// while executing the actual API request.
7813 ///
7814 /// ````text
7815 /// It should be used to handle progress information, and to implement a certain level of resilience.
7816 /// ````
7817 ///
7818 /// Sets the *delegate* property to the given value.
7819 pub fn delegate(
7820 mut self,
7821 new_value: &'a mut dyn common::Delegate,
7822 ) -> ProjectLocationProcessorProcessorVersionDeleteCall<'a, C> {
7823 self._delegate = Some(new_value);
7824 self
7825 }
7826
7827 /// Set any additional parameter of the query string used in the request.
7828 /// It should be used to set parameters which are not yet available through their own
7829 /// setters.
7830 ///
7831 /// Please note that this method must not be used to set any of the known parameters
7832 /// which have their own setter method. If done anyway, the request will fail.
7833 ///
7834 /// # Additional Parameters
7835 ///
7836 /// * *$.xgafv* (query-string) - V1 error format.
7837 /// * *access_token* (query-string) - OAuth access token.
7838 /// * *alt* (query-string) - Data format for response.
7839 /// * *callback* (query-string) - JSONP
7840 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7841 /// * *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.
7842 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7843 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7844 /// * *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.
7845 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7846 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7847 pub fn param<T>(
7848 mut self,
7849 name: T,
7850 value: T,
7851 ) -> ProjectLocationProcessorProcessorVersionDeleteCall<'a, C>
7852 where
7853 T: AsRef<str>,
7854 {
7855 self._additional_params
7856 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7857 self
7858 }
7859
7860 /// Identifies the authorization scope for the method you are building.
7861 ///
7862 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7863 /// [`Scope::CloudPlatform`].
7864 ///
7865 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7866 /// tokens for more than one scope.
7867 ///
7868 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7869 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7870 /// sufficient, a read-write scope will do as well.
7871 pub fn add_scope<St>(
7872 mut self,
7873 scope: St,
7874 ) -> ProjectLocationProcessorProcessorVersionDeleteCall<'a, C>
7875 where
7876 St: AsRef<str>,
7877 {
7878 self._scopes.insert(String::from(scope.as_ref()));
7879 self
7880 }
7881 /// Identifies the authorization scope(s) for the method you are building.
7882 ///
7883 /// See [`Self::add_scope()`] for details.
7884 pub fn add_scopes<I, St>(
7885 mut self,
7886 scopes: I,
7887 ) -> ProjectLocationProcessorProcessorVersionDeleteCall<'a, C>
7888 where
7889 I: IntoIterator<Item = St>,
7890 St: AsRef<str>,
7891 {
7892 self._scopes
7893 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7894 self
7895 }
7896
7897 /// Removes all scopes, and no default scope will be used either.
7898 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7899 /// for details).
7900 pub fn clear_scopes(mut self) -> ProjectLocationProcessorProcessorVersionDeleteCall<'a, C> {
7901 self._scopes.clear();
7902 self
7903 }
7904}
7905
7906/// Deploys the processor version.
7907///
7908/// A builder for the *locations.processors.processorVersions.deploy* method supported by a *project* resource.
7909/// It is not used directly, but through a [`ProjectMethods`] instance.
7910///
7911/// # Example
7912///
7913/// Instantiate a resource method builder
7914///
7915/// ```test_harness,no_run
7916/// # extern crate hyper;
7917/// # extern crate hyper_rustls;
7918/// # extern crate google_documentai1 as documentai1;
7919/// use documentai1::api::GoogleCloudDocumentaiV1DeployProcessorVersionRequest;
7920/// # async fn dox() {
7921/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7922///
7923/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7924/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7925/// # .with_native_roots()
7926/// # .unwrap()
7927/// # .https_only()
7928/// # .enable_http2()
7929/// # .build();
7930///
7931/// # let executor = hyper_util::rt::TokioExecutor::new();
7932/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7933/// # secret,
7934/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7935/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7936/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7937/// # ),
7938/// # ).build().await.unwrap();
7939///
7940/// # let client = hyper_util::client::legacy::Client::builder(
7941/// # hyper_util::rt::TokioExecutor::new()
7942/// # )
7943/// # .build(
7944/// # hyper_rustls::HttpsConnectorBuilder::new()
7945/// # .with_native_roots()
7946/// # .unwrap()
7947/// # .https_or_http()
7948/// # .enable_http2()
7949/// # .build()
7950/// # );
7951/// # let mut hub = Document::new(client, auth);
7952/// // As the method needs a request, you would usually fill it with the desired information
7953/// // into the respective structure. Some of the parts shown here might not be applicable !
7954/// // Values shown here are possibly random and not representative !
7955/// let mut req = GoogleCloudDocumentaiV1DeployProcessorVersionRequest::default();
7956///
7957/// // You can configure optional parameters by calling the respective setters at will, and
7958/// // execute the final call using `doit()`.
7959/// // Values shown here are possibly random and not representative !
7960/// let result = hub.projects().locations_processors_processor_versions_deploy(req, "name")
7961/// .doit().await;
7962/// # }
7963/// ```
7964pub struct ProjectLocationProcessorProcessorVersionDeployCall<'a, C>
7965where
7966 C: 'a,
7967{
7968 hub: &'a Document<C>,
7969 _request: GoogleCloudDocumentaiV1DeployProcessorVersionRequest,
7970 _name: String,
7971 _delegate: Option<&'a mut dyn common::Delegate>,
7972 _additional_params: HashMap<String, String>,
7973 _scopes: BTreeSet<String>,
7974}
7975
7976impl<'a, C> common::CallBuilder for ProjectLocationProcessorProcessorVersionDeployCall<'a, C> {}
7977
7978impl<'a, C> ProjectLocationProcessorProcessorVersionDeployCall<'a, C>
7979where
7980 C: common::Connector,
7981{
7982 /// Perform the operation you have build so far.
7983 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
7984 use std::borrow::Cow;
7985 use std::io::{Read, Seek};
7986
7987 use common::{url::Params, ToParts};
7988 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7989
7990 let mut dd = common::DefaultDelegate;
7991 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7992 dlg.begin(common::MethodInfo {
7993 id: "documentai.projects.locations.processors.processorVersions.deploy",
7994 http_method: hyper::Method::POST,
7995 });
7996
7997 for &field in ["alt", "name"].iter() {
7998 if self._additional_params.contains_key(field) {
7999 dlg.finished(false);
8000 return Err(common::Error::FieldClash(field));
8001 }
8002 }
8003
8004 let mut params = Params::with_capacity(4 + self._additional_params.len());
8005 params.push("name", self._name);
8006
8007 params.extend(self._additional_params.iter());
8008
8009 params.push("alt", "json");
8010 let mut url = self.hub._base_url.clone() + "v1/{+name}:deploy";
8011 if self._scopes.is_empty() {
8012 self._scopes
8013 .insert(Scope::CloudPlatform.as_ref().to_string());
8014 }
8015
8016 #[allow(clippy::single_element_loop)]
8017 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8018 url = params.uri_replacement(url, param_name, find_this, true);
8019 }
8020 {
8021 let to_remove = ["name"];
8022 params.remove_params(&to_remove);
8023 }
8024
8025 let url = params.parse_with_url(&url);
8026
8027 let mut json_mime_type = mime::APPLICATION_JSON;
8028 let mut request_value_reader = {
8029 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8030 common::remove_json_null_values(&mut value);
8031 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8032 serde_json::to_writer(&mut dst, &value).unwrap();
8033 dst
8034 };
8035 let request_size = request_value_reader
8036 .seek(std::io::SeekFrom::End(0))
8037 .unwrap();
8038 request_value_reader
8039 .seek(std::io::SeekFrom::Start(0))
8040 .unwrap();
8041
8042 loop {
8043 let token = match self
8044 .hub
8045 .auth
8046 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8047 .await
8048 {
8049 Ok(token) => token,
8050 Err(e) => match dlg.token(e) {
8051 Ok(token) => token,
8052 Err(e) => {
8053 dlg.finished(false);
8054 return Err(common::Error::MissingToken(e));
8055 }
8056 },
8057 };
8058 request_value_reader
8059 .seek(std::io::SeekFrom::Start(0))
8060 .unwrap();
8061 let mut req_result = {
8062 let client = &self.hub.client;
8063 dlg.pre_request();
8064 let mut req_builder = hyper::Request::builder()
8065 .method(hyper::Method::POST)
8066 .uri(url.as_str())
8067 .header(USER_AGENT, self.hub._user_agent.clone());
8068
8069 if let Some(token) = token.as_ref() {
8070 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8071 }
8072
8073 let request = req_builder
8074 .header(CONTENT_TYPE, json_mime_type.to_string())
8075 .header(CONTENT_LENGTH, request_size as u64)
8076 .body(common::to_body(
8077 request_value_reader.get_ref().clone().into(),
8078 ));
8079
8080 client.request(request.unwrap()).await
8081 };
8082
8083 match req_result {
8084 Err(err) => {
8085 if let common::Retry::After(d) = dlg.http_error(&err) {
8086 sleep(d).await;
8087 continue;
8088 }
8089 dlg.finished(false);
8090 return Err(common::Error::HttpError(err));
8091 }
8092 Ok(res) => {
8093 let (mut parts, body) = res.into_parts();
8094 let mut body = common::Body::new(body);
8095 if !parts.status.is_success() {
8096 let bytes = common::to_bytes(body).await.unwrap_or_default();
8097 let error = serde_json::from_str(&common::to_string(&bytes));
8098 let response = common::to_response(parts, bytes.into());
8099
8100 if let common::Retry::After(d) =
8101 dlg.http_failure(&response, error.as_ref().ok())
8102 {
8103 sleep(d).await;
8104 continue;
8105 }
8106
8107 dlg.finished(false);
8108
8109 return Err(match error {
8110 Ok(value) => common::Error::BadRequest(value),
8111 _ => common::Error::Failure(response),
8112 });
8113 }
8114 let response = {
8115 let bytes = common::to_bytes(body).await.unwrap_or_default();
8116 let encoded = common::to_string(&bytes);
8117 match serde_json::from_str(&encoded) {
8118 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8119 Err(error) => {
8120 dlg.response_json_decode_error(&encoded, &error);
8121 return Err(common::Error::JsonDecodeError(
8122 encoded.to_string(),
8123 error,
8124 ));
8125 }
8126 }
8127 };
8128
8129 dlg.finished(true);
8130 return Ok(response);
8131 }
8132 }
8133 }
8134 }
8135
8136 ///
8137 /// Sets the *request* property to the given value.
8138 ///
8139 /// Even though the property as already been set when instantiating this call,
8140 /// we provide this method for API completeness.
8141 pub fn request(
8142 mut self,
8143 new_value: GoogleCloudDocumentaiV1DeployProcessorVersionRequest,
8144 ) -> ProjectLocationProcessorProcessorVersionDeployCall<'a, C> {
8145 self._request = new_value;
8146 self
8147 }
8148 /// Required. The processor version resource name to be deployed.
8149 ///
8150 /// Sets the *name* path property to the given value.
8151 ///
8152 /// Even though the property as already been set when instantiating this call,
8153 /// we provide this method for API completeness.
8154 pub fn name(
8155 mut self,
8156 new_value: &str,
8157 ) -> ProjectLocationProcessorProcessorVersionDeployCall<'a, C> {
8158 self._name = new_value.to_string();
8159 self
8160 }
8161 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8162 /// while executing the actual API request.
8163 ///
8164 /// ````text
8165 /// It should be used to handle progress information, and to implement a certain level of resilience.
8166 /// ````
8167 ///
8168 /// Sets the *delegate* property to the given value.
8169 pub fn delegate(
8170 mut self,
8171 new_value: &'a mut dyn common::Delegate,
8172 ) -> ProjectLocationProcessorProcessorVersionDeployCall<'a, C> {
8173 self._delegate = Some(new_value);
8174 self
8175 }
8176
8177 /// Set any additional parameter of the query string used in the request.
8178 /// It should be used to set parameters which are not yet available through their own
8179 /// setters.
8180 ///
8181 /// Please note that this method must not be used to set any of the known parameters
8182 /// which have their own setter method. If done anyway, the request will fail.
8183 ///
8184 /// # Additional Parameters
8185 ///
8186 /// * *$.xgafv* (query-string) - V1 error format.
8187 /// * *access_token* (query-string) - OAuth access token.
8188 /// * *alt* (query-string) - Data format for response.
8189 /// * *callback* (query-string) - JSONP
8190 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8191 /// * *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.
8192 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8193 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8194 /// * *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.
8195 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8196 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8197 pub fn param<T>(
8198 mut self,
8199 name: T,
8200 value: T,
8201 ) -> ProjectLocationProcessorProcessorVersionDeployCall<'a, C>
8202 where
8203 T: AsRef<str>,
8204 {
8205 self._additional_params
8206 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8207 self
8208 }
8209
8210 /// Identifies the authorization scope for the method you are building.
8211 ///
8212 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8213 /// [`Scope::CloudPlatform`].
8214 ///
8215 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8216 /// tokens for more than one scope.
8217 ///
8218 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8219 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8220 /// sufficient, a read-write scope will do as well.
8221 pub fn add_scope<St>(
8222 mut self,
8223 scope: St,
8224 ) -> ProjectLocationProcessorProcessorVersionDeployCall<'a, C>
8225 where
8226 St: AsRef<str>,
8227 {
8228 self._scopes.insert(String::from(scope.as_ref()));
8229 self
8230 }
8231 /// Identifies the authorization scope(s) for the method you are building.
8232 ///
8233 /// See [`Self::add_scope()`] for details.
8234 pub fn add_scopes<I, St>(
8235 mut self,
8236 scopes: I,
8237 ) -> ProjectLocationProcessorProcessorVersionDeployCall<'a, C>
8238 where
8239 I: IntoIterator<Item = St>,
8240 St: AsRef<str>,
8241 {
8242 self._scopes
8243 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8244 self
8245 }
8246
8247 /// Removes all scopes, and no default scope will be used either.
8248 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8249 /// for details).
8250 pub fn clear_scopes(mut self) -> ProjectLocationProcessorProcessorVersionDeployCall<'a, C> {
8251 self._scopes.clear();
8252 self
8253 }
8254}
8255
8256/// Evaluates a ProcessorVersion against annotated documents, producing an Evaluation.
8257///
8258/// A builder for the *locations.processors.processorVersions.evaluateProcessorVersion* method supported by a *project* resource.
8259/// It is not used directly, but through a [`ProjectMethods`] instance.
8260///
8261/// # Example
8262///
8263/// Instantiate a resource method builder
8264///
8265/// ```test_harness,no_run
8266/// # extern crate hyper;
8267/// # extern crate hyper_rustls;
8268/// # extern crate google_documentai1 as documentai1;
8269/// use documentai1::api::GoogleCloudDocumentaiV1EvaluateProcessorVersionRequest;
8270/// # async fn dox() {
8271/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8272///
8273/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8274/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8275/// # .with_native_roots()
8276/// # .unwrap()
8277/// # .https_only()
8278/// # .enable_http2()
8279/// # .build();
8280///
8281/// # let executor = hyper_util::rt::TokioExecutor::new();
8282/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8283/// # secret,
8284/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8285/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8286/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8287/// # ),
8288/// # ).build().await.unwrap();
8289///
8290/// # let client = hyper_util::client::legacy::Client::builder(
8291/// # hyper_util::rt::TokioExecutor::new()
8292/// # )
8293/// # .build(
8294/// # hyper_rustls::HttpsConnectorBuilder::new()
8295/// # .with_native_roots()
8296/// # .unwrap()
8297/// # .https_or_http()
8298/// # .enable_http2()
8299/// # .build()
8300/// # );
8301/// # let mut hub = Document::new(client, auth);
8302/// // As the method needs a request, you would usually fill it with the desired information
8303/// // into the respective structure. Some of the parts shown here might not be applicable !
8304/// // Values shown here are possibly random and not representative !
8305/// let mut req = GoogleCloudDocumentaiV1EvaluateProcessorVersionRequest::default();
8306///
8307/// // You can configure optional parameters by calling the respective setters at will, and
8308/// // execute the final call using `doit()`.
8309/// // Values shown here are possibly random and not representative !
8310/// let result = hub.projects().locations_processors_processor_versions_evaluate_processor_version(req, "processorVersion")
8311/// .doit().await;
8312/// # }
8313/// ```
8314pub struct ProjectLocationProcessorProcessorVersionEvaluateProcessorVersionCall<'a, C>
8315where
8316 C: 'a,
8317{
8318 hub: &'a Document<C>,
8319 _request: GoogleCloudDocumentaiV1EvaluateProcessorVersionRequest,
8320 _processor_version: String,
8321 _delegate: Option<&'a mut dyn common::Delegate>,
8322 _additional_params: HashMap<String, String>,
8323 _scopes: BTreeSet<String>,
8324}
8325
8326impl<'a, C> common::CallBuilder
8327 for ProjectLocationProcessorProcessorVersionEvaluateProcessorVersionCall<'a, C>
8328{
8329}
8330
8331impl<'a, C> ProjectLocationProcessorProcessorVersionEvaluateProcessorVersionCall<'a, C>
8332where
8333 C: common::Connector,
8334{
8335 /// Perform the operation you have build so far.
8336 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
8337 use std::borrow::Cow;
8338 use std::io::{Read, Seek};
8339
8340 use common::{url::Params, ToParts};
8341 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8342
8343 let mut dd = common::DefaultDelegate;
8344 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8345 dlg.begin(common::MethodInfo { id: "documentai.projects.locations.processors.processorVersions.evaluateProcessorVersion",
8346 http_method: hyper::Method::POST });
8347
8348 for &field in ["alt", "processorVersion"].iter() {
8349 if self._additional_params.contains_key(field) {
8350 dlg.finished(false);
8351 return Err(common::Error::FieldClash(field));
8352 }
8353 }
8354
8355 let mut params = Params::with_capacity(4 + self._additional_params.len());
8356 params.push("processorVersion", self._processor_version);
8357
8358 params.extend(self._additional_params.iter());
8359
8360 params.push("alt", "json");
8361 let mut url =
8362 self.hub._base_url.clone() + "v1/{+processorVersion}:evaluateProcessorVersion";
8363 if self._scopes.is_empty() {
8364 self._scopes
8365 .insert(Scope::CloudPlatform.as_ref().to_string());
8366 }
8367
8368 #[allow(clippy::single_element_loop)]
8369 for &(find_this, param_name) in [("{+processorVersion}", "processorVersion")].iter() {
8370 url = params.uri_replacement(url, param_name, find_this, true);
8371 }
8372 {
8373 let to_remove = ["processorVersion"];
8374 params.remove_params(&to_remove);
8375 }
8376
8377 let url = params.parse_with_url(&url);
8378
8379 let mut json_mime_type = mime::APPLICATION_JSON;
8380 let mut request_value_reader = {
8381 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8382 common::remove_json_null_values(&mut value);
8383 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8384 serde_json::to_writer(&mut dst, &value).unwrap();
8385 dst
8386 };
8387 let request_size = request_value_reader
8388 .seek(std::io::SeekFrom::End(0))
8389 .unwrap();
8390 request_value_reader
8391 .seek(std::io::SeekFrom::Start(0))
8392 .unwrap();
8393
8394 loop {
8395 let token = match self
8396 .hub
8397 .auth
8398 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8399 .await
8400 {
8401 Ok(token) => token,
8402 Err(e) => match dlg.token(e) {
8403 Ok(token) => token,
8404 Err(e) => {
8405 dlg.finished(false);
8406 return Err(common::Error::MissingToken(e));
8407 }
8408 },
8409 };
8410 request_value_reader
8411 .seek(std::io::SeekFrom::Start(0))
8412 .unwrap();
8413 let mut req_result = {
8414 let client = &self.hub.client;
8415 dlg.pre_request();
8416 let mut req_builder = hyper::Request::builder()
8417 .method(hyper::Method::POST)
8418 .uri(url.as_str())
8419 .header(USER_AGENT, self.hub._user_agent.clone());
8420
8421 if let Some(token) = token.as_ref() {
8422 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8423 }
8424
8425 let request = req_builder
8426 .header(CONTENT_TYPE, json_mime_type.to_string())
8427 .header(CONTENT_LENGTH, request_size as u64)
8428 .body(common::to_body(
8429 request_value_reader.get_ref().clone().into(),
8430 ));
8431
8432 client.request(request.unwrap()).await
8433 };
8434
8435 match req_result {
8436 Err(err) => {
8437 if let common::Retry::After(d) = dlg.http_error(&err) {
8438 sleep(d).await;
8439 continue;
8440 }
8441 dlg.finished(false);
8442 return Err(common::Error::HttpError(err));
8443 }
8444 Ok(res) => {
8445 let (mut parts, body) = res.into_parts();
8446 let mut body = common::Body::new(body);
8447 if !parts.status.is_success() {
8448 let bytes = common::to_bytes(body).await.unwrap_or_default();
8449 let error = serde_json::from_str(&common::to_string(&bytes));
8450 let response = common::to_response(parts, bytes.into());
8451
8452 if let common::Retry::After(d) =
8453 dlg.http_failure(&response, error.as_ref().ok())
8454 {
8455 sleep(d).await;
8456 continue;
8457 }
8458
8459 dlg.finished(false);
8460
8461 return Err(match error {
8462 Ok(value) => common::Error::BadRequest(value),
8463 _ => common::Error::Failure(response),
8464 });
8465 }
8466 let response = {
8467 let bytes = common::to_bytes(body).await.unwrap_or_default();
8468 let encoded = common::to_string(&bytes);
8469 match serde_json::from_str(&encoded) {
8470 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8471 Err(error) => {
8472 dlg.response_json_decode_error(&encoded, &error);
8473 return Err(common::Error::JsonDecodeError(
8474 encoded.to_string(),
8475 error,
8476 ));
8477 }
8478 }
8479 };
8480
8481 dlg.finished(true);
8482 return Ok(response);
8483 }
8484 }
8485 }
8486 }
8487
8488 ///
8489 /// Sets the *request* property to the given value.
8490 ///
8491 /// Even though the property as already been set when instantiating this call,
8492 /// we provide this method for API completeness.
8493 pub fn request(
8494 mut self,
8495 new_value: GoogleCloudDocumentaiV1EvaluateProcessorVersionRequest,
8496 ) -> ProjectLocationProcessorProcessorVersionEvaluateProcessorVersionCall<'a, C> {
8497 self._request = new_value;
8498 self
8499 }
8500 /// Required. The resource name of the ProcessorVersion to evaluate. `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`
8501 ///
8502 /// Sets the *processor version* path property to the given value.
8503 ///
8504 /// Even though the property as already been set when instantiating this call,
8505 /// we provide this method for API completeness.
8506 pub fn processor_version(
8507 mut self,
8508 new_value: &str,
8509 ) -> ProjectLocationProcessorProcessorVersionEvaluateProcessorVersionCall<'a, C> {
8510 self._processor_version = new_value.to_string();
8511 self
8512 }
8513 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8514 /// while executing the actual API request.
8515 ///
8516 /// ````text
8517 /// It should be used to handle progress information, and to implement a certain level of resilience.
8518 /// ````
8519 ///
8520 /// Sets the *delegate* property to the given value.
8521 pub fn delegate(
8522 mut self,
8523 new_value: &'a mut dyn common::Delegate,
8524 ) -> ProjectLocationProcessorProcessorVersionEvaluateProcessorVersionCall<'a, C> {
8525 self._delegate = Some(new_value);
8526 self
8527 }
8528
8529 /// Set any additional parameter of the query string used in the request.
8530 /// It should be used to set parameters which are not yet available through their own
8531 /// setters.
8532 ///
8533 /// Please note that this method must not be used to set any of the known parameters
8534 /// which have their own setter method. If done anyway, the request will fail.
8535 ///
8536 /// # Additional Parameters
8537 ///
8538 /// * *$.xgafv* (query-string) - V1 error format.
8539 /// * *access_token* (query-string) - OAuth access token.
8540 /// * *alt* (query-string) - Data format for response.
8541 /// * *callback* (query-string) - JSONP
8542 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8543 /// * *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.
8544 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8545 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8546 /// * *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.
8547 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8548 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8549 pub fn param<T>(
8550 mut self,
8551 name: T,
8552 value: T,
8553 ) -> ProjectLocationProcessorProcessorVersionEvaluateProcessorVersionCall<'a, C>
8554 where
8555 T: AsRef<str>,
8556 {
8557 self._additional_params
8558 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8559 self
8560 }
8561
8562 /// Identifies the authorization scope for the method you are building.
8563 ///
8564 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8565 /// [`Scope::CloudPlatform`].
8566 ///
8567 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8568 /// tokens for more than one scope.
8569 ///
8570 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8571 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8572 /// sufficient, a read-write scope will do as well.
8573 pub fn add_scope<St>(
8574 mut self,
8575 scope: St,
8576 ) -> ProjectLocationProcessorProcessorVersionEvaluateProcessorVersionCall<'a, C>
8577 where
8578 St: AsRef<str>,
8579 {
8580 self._scopes.insert(String::from(scope.as_ref()));
8581 self
8582 }
8583 /// Identifies the authorization scope(s) for the method you are building.
8584 ///
8585 /// See [`Self::add_scope()`] for details.
8586 pub fn add_scopes<I, St>(
8587 mut self,
8588 scopes: I,
8589 ) -> ProjectLocationProcessorProcessorVersionEvaluateProcessorVersionCall<'a, C>
8590 where
8591 I: IntoIterator<Item = St>,
8592 St: AsRef<str>,
8593 {
8594 self._scopes
8595 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8596 self
8597 }
8598
8599 /// Removes all scopes, and no default scope will be used either.
8600 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8601 /// for details).
8602 pub fn clear_scopes(
8603 mut self,
8604 ) -> ProjectLocationProcessorProcessorVersionEvaluateProcessorVersionCall<'a, C> {
8605 self._scopes.clear();
8606 self
8607 }
8608}
8609
8610/// Gets a processor version detail.
8611///
8612/// A builder for the *locations.processors.processorVersions.get* method supported by a *project* resource.
8613/// It is not used directly, but through a [`ProjectMethods`] instance.
8614///
8615/// # Example
8616///
8617/// Instantiate a resource method builder
8618///
8619/// ```test_harness,no_run
8620/// # extern crate hyper;
8621/// # extern crate hyper_rustls;
8622/// # extern crate google_documentai1 as documentai1;
8623/// # async fn dox() {
8624/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8625///
8626/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8627/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8628/// # .with_native_roots()
8629/// # .unwrap()
8630/// # .https_only()
8631/// # .enable_http2()
8632/// # .build();
8633///
8634/// # let executor = hyper_util::rt::TokioExecutor::new();
8635/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8636/// # secret,
8637/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8638/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8639/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8640/// # ),
8641/// # ).build().await.unwrap();
8642///
8643/// # let client = hyper_util::client::legacy::Client::builder(
8644/// # hyper_util::rt::TokioExecutor::new()
8645/// # )
8646/// # .build(
8647/// # hyper_rustls::HttpsConnectorBuilder::new()
8648/// # .with_native_roots()
8649/// # .unwrap()
8650/// # .https_or_http()
8651/// # .enable_http2()
8652/// # .build()
8653/// # );
8654/// # let mut hub = Document::new(client, auth);
8655/// // You can configure optional parameters by calling the respective setters at will, and
8656/// // execute the final call using `doit()`.
8657/// // Values shown here are possibly random and not representative !
8658/// let result = hub.projects().locations_processors_processor_versions_get("name")
8659/// .doit().await;
8660/// # }
8661/// ```
8662pub struct ProjectLocationProcessorProcessorVersionGetCall<'a, C>
8663where
8664 C: 'a,
8665{
8666 hub: &'a Document<C>,
8667 _name: String,
8668 _delegate: Option<&'a mut dyn common::Delegate>,
8669 _additional_params: HashMap<String, String>,
8670 _scopes: BTreeSet<String>,
8671}
8672
8673impl<'a, C> common::CallBuilder for ProjectLocationProcessorProcessorVersionGetCall<'a, C> {}
8674
8675impl<'a, C> ProjectLocationProcessorProcessorVersionGetCall<'a, C>
8676where
8677 C: common::Connector,
8678{
8679 /// Perform the operation you have build so far.
8680 pub async fn doit(
8681 mut self,
8682 ) -> common::Result<(common::Response, GoogleCloudDocumentaiV1ProcessorVersion)> {
8683 use std::borrow::Cow;
8684 use std::io::{Read, Seek};
8685
8686 use common::{url::Params, ToParts};
8687 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8688
8689 let mut dd = common::DefaultDelegate;
8690 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8691 dlg.begin(common::MethodInfo {
8692 id: "documentai.projects.locations.processors.processorVersions.get",
8693 http_method: hyper::Method::GET,
8694 });
8695
8696 for &field in ["alt", "name"].iter() {
8697 if self._additional_params.contains_key(field) {
8698 dlg.finished(false);
8699 return Err(common::Error::FieldClash(field));
8700 }
8701 }
8702
8703 let mut params = Params::with_capacity(3 + self._additional_params.len());
8704 params.push("name", self._name);
8705
8706 params.extend(self._additional_params.iter());
8707
8708 params.push("alt", "json");
8709 let mut url = self.hub._base_url.clone() + "v1/{+name}";
8710 if self._scopes.is_empty() {
8711 self._scopes
8712 .insert(Scope::CloudPlatform.as_ref().to_string());
8713 }
8714
8715 #[allow(clippy::single_element_loop)]
8716 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8717 url = params.uri_replacement(url, param_name, find_this, true);
8718 }
8719 {
8720 let to_remove = ["name"];
8721 params.remove_params(&to_remove);
8722 }
8723
8724 let url = params.parse_with_url(&url);
8725
8726 loop {
8727 let token = match self
8728 .hub
8729 .auth
8730 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8731 .await
8732 {
8733 Ok(token) => token,
8734 Err(e) => match dlg.token(e) {
8735 Ok(token) => token,
8736 Err(e) => {
8737 dlg.finished(false);
8738 return Err(common::Error::MissingToken(e));
8739 }
8740 },
8741 };
8742 let mut req_result = {
8743 let client = &self.hub.client;
8744 dlg.pre_request();
8745 let mut req_builder = hyper::Request::builder()
8746 .method(hyper::Method::GET)
8747 .uri(url.as_str())
8748 .header(USER_AGENT, self.hub._user_agent.clone());
8749
8750 if let Some(token) = token.as_ref() {
8751 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8752 }
8753
8754 let request = req_builder
8755 .header(CONTENT_LENGTH, 0_u64)
8756 .body(common::to_body::<String>(None));
8757
8758 client.request(request.unwrap()).await
8759 };
8760
8761 match req_result {
8762 Err(err) => {
8763 if let common::Retry::After(d) = dlg.http_error(&err) {
8764 sleep(d).await;
8765 continue;
8766 }
8767 dlg.finished(false);
8768 return Err(common::Error::HttpError(err));
8769 }
8770 Ok(res) => {
8771 let (mut parts, body) = res.into_parts();
8772 let mut body = common::Body::new(body);
8773 if !parts.status.is_success() {
8774 let bytes = common::to_bytes(body).await.unwrap_or_default();
8775 let error = serde_json::from_str(&common::to_string(&bytes));
8776 let response = common::to_response(parts, bytes.into());
8777
8778 if let common::Retry::After(d) =
8779 dlg.http_failure(&response, error.as_ref().ok())
8780 {
8781 sleep(d).await;
8782 continue;
8783 }
8784
8785 dlg.finished(false);
8786
8787 return Err(match error {
8788 Ok(value) => common::Error::BadRequest(value),
8789 _ => common::Error::Failure(response),
8790 });
8791 }
8792 let response = {
8793 let bytes = common::to_bytes(body).await.unwrap_or_default();
8794 let encoded = common::to_string(&bytes);
8795 match serde_json::from_str(&encoded) {
8796 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8797 Err(error) => {
8798 dlg.response_json_decode_error(&encoded, &error);
8799 return Err(common::Error::JsonDecodeError(
8800 encoded.to_string(),
8801 error,
8802 ));
8803 }
8804 }
8805 };
8806
8807 dlg.finished(true);
8808 return Ok(response);
8809 }
8810 }
8811 }
8812 }
8813
8814 /// Required. The processor resource name.
8815 ///
8816 /// Sets the *name* path property to the given value.
8817 ///
8818 /// Even though the property as already been set when instantiating this call,
8819 /// we provide this method for API completeness.
8820 pub fn name(
8821 mut self,
8822 new_value: &str,
8823 ) -> ProjectLocationProcessorProcessorVersionGetCall<'a, C> {
8824 self._name = new_value.to_string();
8825 self
8826 }
8827 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8828 /// while executing the actual API request.
8829 ///
8830 /// ````text
8831 /// It should be used to handle progress information, and to implement a certain level of resilience.
8832 /// ````
8833 ///
8834 /// Sets the *delegate* property to the given value.
8835 pub fn delegate(
8836 mut self,
8837 new_value: &'a mut dyn common::Delegate,
8838 ) -> ProjectLocationProcessorProcessorVersionGetCall<'a, C> {
8839 self._delegate = Some(new_value);
8840 self
8841 }
8842
8843 /// Set any additional parameter of the query string used in the request.
8844 /// It should be used to set parameters which are not yet available through their own
8845 /// setters.
8846 ///
8847 /// Please note that this method must not be used to set any of the known parameters
8848 /// which have their own setter method. If done anyway, the request will fail.
8849 ///
8850 /// # Additional Parameters
8851 ///
8852 /// * *$.xgafv* (query-string) - V1 error format.
8853 /// * *access_token* (query-string) - OAuth access token.
8854 /// * *alt* (query-string) - Data format for response.
8855 /// * *callback* (query-string) - JSONP
8856 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8857 /// * *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.
8858 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8859 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8860 /// * *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.
8861 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8862 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8863 pub fn param<T>(
8864 mut self,
8865 name: T,
8866 value: T,
8867 ) -> ProjectLocationProcessorProcessorVersionGetCall<'a, C>
8868 where
8869 T: AsRef<str>,
8870 {
8871 self._additional_params
8872 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8873 self
8874 }
8875
8876 /// Identifies the authorization scope for the method you are building.
8877 ///
8878 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8879 /// [`Scope::CloudPlatform`].
8880 ///
8881 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8882 /// tokens for more than one scope.
8883 ///
8884 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8885 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8886 /// sufficient, a read-write scope will do as well.
8887 pub fn add_scope<St>(
8888 mut self,
8889 scope: St,
8890 ) -> ProjectLocationProcessorProcessorVersionGetCall<'a, C>
8891 where
8892 St: AsRef<str>,
8893 {
8894 self._scopes.insert(String::from(scope.as_ref()));
8895 self
8896 }
8897 /// Identifies the authorization scope(s) for the method you are building.
8898 ///
8899 /// See [`Self::add_scope()`] for details.
8900 pub fn add_scopes<I, St>(
8901 mut self,
8902 scopes: I,
8903 ) -> ProjectLocationProcessorProcessorVersionGetCall<'a, C>
8904 where
8905 I: IntoIterator<Item = St>,
8906 St: AsRef<str>,
8907 {
8908 self._scopes
8909 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8910 self
8911 }
8912
8913 /// Removes all scopes, and no default scope will be used either.
8914 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8915 /// for details).
8916 pub fn clear_scopes(mut self) -> ProjectLocationProcessorProcessorVersionGetCall<'a, C> {
8917 self._scopes.clear();
8918 self
8919 }
8920}
8921
8922/// Lists all versions of a processor.
8923///
8924/// A builder for the *locations.processors.processorVersions.list* method supported by a *project* resource.
8925/// It is not used directly, but through a [`ProjectMethods`] instance.
8926///
8927/// # Example
8928///
8929/// Instantiate a resource method builder
8930///
8931/// ```test_harness,no_run
8932/// # extern crate hyper;
8933/// # extern crate hyper_rustls;
8934/// # extern crate google_documentai1 as documentai1;
8935/// # async fn dox() {
8936/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8937///
8938/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8939/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8940/// # .with_native_roots()
8941/// # .unwrap()
8942/// # .https_only()
8943/// # .enable_http2()
8944/// # .build();
8945///
8946/// # let executor = hyper_util::rt::TokioExecutor::new();
8947/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8948/// # secret,
8949/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8950/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8951/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8952/// # ),
8953/// # ).build().await.unwrap();
8954///
8955/// # let client = hyper_util::client::legacy::Client::builder(
8956/// # hyper_util::rt::TokioExecutor::new()
8957/// # )
8958/// # .build(
8959/// # hyper_rustls::HttpsConnectorBuilder::new()
8960/// # .with_native_roots()
8961/// # .unwrap()
8962/// # .https_or_http()
8963/// # .enable_http2()
8964/// # .build()
8965/// # );
8966/// # let mut hub = Document::new(client, auth);
8967/// // You can configure optional parameters by calling the respective setters at will, and
8968/// // execute the final call using `doit()`.
8969/// // Values shown here are possibly random and not representative !
8970/// let result = hub.projects().locations_processors_processor_versions_list("parent")
8971/// .page_token("gubergren")
8972/// .page_size(-16)
8973/// .doit().await;
8974/// # }
8975/// ```
8976pub struct ProjectLocationProcessorProcessorVersionListCall<'a, C>
8977where
8978 C: 'a,
8979{
8980 hub: &'a Document<C>,
8981 _parent: String,
8982 _page_token: Option<String>,
8983 _page_size: Option<i32>,
8984 _delegate: Option<&'a mut dyn common::Delegate>,
8985 _additional_params: HashMap<String, String>,
8986 _scopes: BTreeSet<String>,
8987}
8988
8989impl<'a, C> common::CallBuilder for ProjectLocationProcessorProcessorVersionListCall<'a, C> {}
8990
8991impl<'a, C> ProjectLocationProcessorProcessorVersionListCall<'a, C>
8992where
8993 C: common::Connector,
8994{
8995 /// Perform the operation you have build so far.
8996 pub async fn doit(
8997 mut self,
8998 ) -> common::Result<(
8999 common::Response,
9000 GoogleCloudDocumentaiV1ListProcessorVersionsResponse,
9001 )> {
9002 use std::borrow::Cow;
9003 use std::io::{Read, Seek};
9004
9005 use common::{url::Params, ToParts};
9006 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9007
9008 let mut dd = common::DefaultDelegate;
9009 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9010 dlg.begin(common::MethodInfo {
9011 id: "documentai.projects.locations.processors.processorVersions.list",
9012 http_method: hyper::Method::GET,
9013 });
9014
9015 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
9016 if self._additional_params.contains_key(field) {
9017 dlg.finished(false);
9018 return Err(common::Error::FieldClash(field));
9019 }
9020 }
9021
9022 let mut params = Params::with_capacity(5 + self._additional_params.len());
9023 params.push("parent", self._parent);
9024 if let Some(value) = self._page_token.as_ref() {
9025 params.push("pageToken", value);
9026 }
9027 if let Some(value) = self._page_size.as_ref() {
9028 params.push("pageSize", value.to_string());
9029 }
9030
9031 params.extend(self._additional_params.iter());
9032
9033 params.push("alt", "json");
9034 let mut url = self.hub._base_url.clone() + "v1/{+parent}/processorVersions";
9035 if self._scopes.is_empty() {
9036 self._scopes
9037 .insert(Scope::CloudPlatform.as_ref().to_string());
9038 }
9039
9040 #[allow(clippy::single_element_loop)]
9041 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9042 url = params.uri_replacement(url, param_name, find_this, true);
9043 }
9044 {
9045 let to_remove = ["parent"];
9046 params.remove_params(&to_remove);
9047 }
9048
9049 let url = params.parse_with_url(&url);
9050
9051 loop {
9052 let token = match self
9053 .hub
9054 .auth
9055 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9056 .await
9057 {
9058 Ok(token) => token,
9059 Err(e) => match dlg.token(e) {
9060 Ok(token) => token,
9061 Err(e) => {
9062 dlg.finished(false);
9063 return Err(common::Error::MissingToken(e));
9064 }
9065 },
9066 };
9067 let mut req_result = {
9068 let client = &self.hub.client;
9069 dlg.pre_request();
9070 let mut req_builder = hyper::Request::builder()
9071 .method(hyper::Method::GET)
9072 .uri(url.as_str())
9073 .header(USER_AGENT, self.hub._user_agent.clone());
9074
9075 if let Some(token) = token.as_ref() {
9076 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9077 }
9078
9079 let request = req_builder
9080 .header(CONTENT_LENGTH, 0_u64)
9081 .body(common::to_body::<String>(None));
9082
9083 client.request(request.unwrap()).await
9084 };
9085
9086 match req_result {
9087 Err(err) => {
9088 if let common::Retry::After(d) = dlg.http_error(&err) {
9089 sleep(d).await;
9090 continue;
9091 }
9092 dlg.finished(false);
9093 return Err(common::Error::HttpError(err));
9094 }
9095 Ok(res) => {
9096 let (mut parts, body) = res.into_parts();
9097 let mut body = common::Body::new(body);
9098 if !parts.status.is_success() {
9099 let bytes = common::to_bytes(body).await.unwrap_or_default();
9100 let error = serde_json::from_str(&common::to_string(&bytes));
9101 let response = common::to_response(parts, bytes.into());
9102
9103 if let common::Retry::After(d) =
9104 dlg.http_failure(&response, error.as_ref().ok())
9105 {
9106 sleep(d).await;
9107 continue;
9108 }
9109
9110 dlg.finished(false);
9111
9112 return Err(match error {
9113 Ok(value) => common::Error::BadRequest(value),
9114 _ => common::Error::Failure(response),
9115 });
9116 }
9117 let response = {
9118 let bytes = common::to_bytes(body).await.unwrap_or_default();
9119 let encoded = common::to_string(&bytes);
9120 match serde_json::from_str(&encoded) {
9121 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9122 Err(error) => {
9123 dlg.response_json_decode_error(&encoded, &error);
9124 return Err(common::Error::JsonDecodeError(
9125 encoded.to_string(),
9126 error,
9127 ));
9128 }
9129 }
9130 };
9131
9132 dlg.finished(true);
9133 return Ok(response);
9134 }
9135 }
9136 }
9137 }
9138
9139 /// Required. The parent (project, location and processor) to list all versions. Format: `projects/{project}/locations/{location}/processors/{processor}`
9140 ///
9141 /// Sets the *parent* path property to the given value.
9142 ///
9143 /// Even though the property as already been set when instantiating this call,
9144 /// we provide this method for API completeness.
9145 pub fn parent(
9146 mut self,
9147 new_value: &str,
9148 ) -> ProjectLocationProcessorProcessorVersionListCall<'a, C> {
9149 self._parent = new_value.to_string();
9150 self
9151 }
9152 /// We will return the processor versions sorted by creation time. The page token will point to the next processor version.
9153 ///
9154 /// Sets the *page token* query property to the given value.
9155 pub fn page_token(
9156 mut self,
9157 new_value: &str,
9158 ) -> ProjectLocationProcessorProcessorVersionListCall<'a, C> {
9159 self._page_token = Some(new_value.to_string());
9160 self
9161 }
9162 /// 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`.
9163 ///
9164 /// Sets the *page size* query property to the given value.
9165 pub fn page_size(
9166 mut self,
9167 new_value: i32,
9168 ) -> ProjectLocationProcessorProcessorVersionListCall<'a, C> {
9169 self._page_size = Some(new_value);
9170 self
9171 }
9172 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9173 /// while executing the actual API request.
9174 ///
9175 /// ````text
9176 /// It should be used to handle progress information, and to implement a certain level of resilience.
9177 /// ````
9178 ///
9179 /// Sets the *delegate* property to the given value.
9180 pub fn delegate(
9181 mut self,
9182 new_value: &'a mut dyn common::Delegate,
9183 ) -> ProjectLocationProcessorProcessorVersionListCall<'a, C> {
9184 self._delegate = Some(new_value);
9185 self
9186 }
9187
9188 /// Set any additional parameter of the query string used in the request.
9189 /// It should be used to set parameters which are not yet available through their own
9190 /// setters.
9191 ///
9192 /// Please note that this method must not be used to set any of the known parameters
9193 /// which have their own setter method. If done anyway, the request will fail.
9194 ///
9195 /// # Additional Parameters
9196 ///
9197 /// * *$.xgafv* (query-string) - V1 error format.
9198 /// * *access_token* (query-string) - OAuth access token.
9199 /// * *alt* (query-string) - Data format for response.
9200 /// * *callback* (query-string) - JSONP
9201 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9202 /// * *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.
9203 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9204 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9205 /// * *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.
9206 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9207 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9208 pub fn param<T>(
9209 mut self,
9210 name: T,
9211 value: T,
9212 ) -> ProjectLocationProcessorProcessorVersionListCall<'a, C>
9213 where
9214 T: AsRef<str>,
9215 {
9216 self._additional_params
9217 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9218 self
9219 }
9220
9221 /// Identifies the authorization scope for the method you are building.
9222 ///
9223 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9224 /// [`Scope::CloudPlatform`].
9225 ///
9226 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9227 /// tokens for more than one scope.
9228 ///
9229 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9230 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9231 /// sufficient, a read-write scope will do as well.
9232 pub fn add_scope<St>(
9233 mut self,
9234 scope: St,
9235 ) -> ProjectLocationProcessorProcessorVersionListCall<'a, C>
9236 where
9237 St: AsRef<str>,
9238 {
9239 self._scopes.insert(String::from(scope.as_ref()));
9240 self
9241 }
9242 /// Identifies the authorization scope(s) for the method you are building.
9243 ///
9244 /// See [`Self::add_scope()`] for details.
9245 pub fn add_scopes<I, St>(
9246 mut self,
9247 scopes: I,
9248 ) -> ProjectLocationProcessorProcessorVersionListCall<'a, C>
9249 where
9250 I: IntoIterator<Item = St>,
9251 St: AsRef<str>,
9252 {
9253 self._scopes
9254 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9255 self
9256 }
9257
9258 /// Removes all scopes, and no default scope will be used either.
9259 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9260 /// for details).
9261 pub fn clear_scopes(mut self) -> ProjectLocationProcessorProcessorVersionListCall<'a, C> {
9262 self._scopes.clear();
9263 self
9264 }
9265}
9266
9267/// Processes a single document.
9268///
9269/// A builder for the *locations.processors.processorVersions.process* method supported by a *project* resource.
9270/// It is not used directly, but through a [`ProjectMethods`] instance.
9271///
9272/// # Example
9273///
9274/// Instantiate a resource method builder
9275///
9276/// ```test_harness,no_run
9277/// # extern crate hyper;
9278/// # extern crate hyper_rustls;
9279/// # extern crate google_documentai1 as documentai1;
9280/// use documentai1::api::GoogleCloudDocumentaiV1ProcessRequest;
9281/// # async fn dox() {
9282/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9283///
9284/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9285/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9286/// # .with_native_roots()
9287/// # .unwrap()
9288/// # .https_only()
9289/// # .enable_http2()
9290/// # .build();
9291///
9292/// # let executor = hyper_util::rt::TokioExecutor::new();
9293/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9294/// # secret,
9295/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9296/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9297/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9298/// # ),
9299/// # ).build().await.unwrap();
9300///
9301/// # let client = hyper_util::client::legacy::Client::builder(
9302/// # hyper_util::rt::TokioExecutor::new()
9303/// # )
9304/// # .build(
9305/// # hyper_rustls::HttpsConnectorBuilder::new()
9306/// # .with_native_roots()
9307/// # .unwrap()
9308/// # .https_or_http()
9309/// # .enable_http2()
9310/// # .build()
9311/// # );
9312/// # let mut hub = Document::new(client, auth);
9313/// // As the method needs a request, you would usually fill it with the desired information
9314/// // into the respective structure. Some of the parts shown here might not be applicable !
9315/// // Values shown here are possibly random and not representative !
9316/// let mut req = GoogleCloudDocumentaiV1ProcessRequest::default();
9317///
9318/// // You can configure optional parameters by calling the respective setters at will, and
9319/// // execute the final call using `doit()`.
9320/// // Values shown here are possibly random and not representative !
9321/// let result = hub.projects().locations_processors_processor_versions_process(req, "name")
9322/// .doit().await;
9323/// # }
9324/// ```
9325pub struct ProjectLocationProcessorProcessorVersionProcesCall<'a, C>
9326where
9327 C: 'a,
9328{
9329 hub: &'a Document<C>,
9330 _request: GoogleCloudDocumentaiV1ProcessRequest,
9331 _name: String,
9332 _delegate: Option<&'a mut dyn common::Delegate>,
9333 _additional_params: HashMap<String, String>,
9334 _scopes: BTreeSet<String>,
9335}
9336
9337impl<'a, C> common::CallBuilder for ProjectLocationProcessorProcessorVersionProcesCall<'a, C> {}
9338
9339impl<'a, C> ProjectLocationProcessorProcessorVersionProcesCall<'a, C>
9340where
9341 C: common::Connector,
9342{
9343 /// Perform the operation you have build so far.
9344 pub async fn doit(
9345 mut self,
9346 ) -> common::Result<(common::Response, GoogleCloudDocumentaiV1ProcessResponse)> {
9347 use std::borrow::Cow;
9348 use std::io::{Read, Seek};
9349
9350 use common::{url::Params, ToParts};
9351 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9352
9353 let mut dd = common::DefaultDelegate;
9354 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9355 dlg.begin(common::MethodInfo {
9356 id: "documentai.projects.locations.processors.processorVersions.process",
9357 http_method: hyper::Method::POST,
9358 });
9359
9360 for &field in ["alt", "name"].iter() {
9361 if self._additional_params.contains_key(field) {
9362 dlg.finished(false);
9363 return Err(common::Error::FieldClash(field));
9364 }
9365 }
9366
9367 let mut params = Params::with_capacity(4 + self._additional_params.len());
9368 params.push("name", self._name);
9369
9370 params.extend(self._additional_params.iter());
9371
9372 params.push("alt", "json");
9373 let mut url = self.hub._base_url.clone() + "v1/{+name}:process";
9374 if self._scopes.is_empty() {
9375 self._scopes
9376 .insert(Scope::CloudPlatform.as_ref().to_string());
9377 }
9378
9379 #[allow(clippy::single_element_loop)]
9380 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9381 url = params.uri_replacement(url, param_name, find_this, true);
9382 }
9383 {
9384 let to_remove = ["name"];
9385 params.remove_params(&to_remove);
9386 }
9387
9388 let url = params.parse_with_url(&url);
9389
9390 let mut json_mime_type = mime::APPLICATION_JSON;
9391 let mut request_value_reader = {
9392 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9393 common::remove_json_null_values(&mut value);
9394 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9395 serde_json::to_writer(&mut dst, &value).unwrap();
9396 dst
9397 };
9398 let request_size = request_value_reader
9399 .seek(std::io::SeekFrom::End(0))
9400 .unwrap();
9401 request_value_reader
9402 .seek(std::io::SeekFrom::Start(0))
9403 .unwrap();
9404
9405 loop {
9406 let token = match self
9407 .hub
9408 .auth
9409 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9410 .await
9411 {
9412 Ok(token) => token,
9413 Err(e) => match dlg.token(e) {
9414 Ok(token) => token,
9415 Err(e) => {
9416 dlg.finished(false);
9417 return Err(common::Error::MissingToken(e));
9418 }
9419 },
9420 };
9421 request_value_reader
9422 .seek(std::io::SeekFrom::Start(0))
9423 .unwrap();
9424 let mut req_result = {
9425 let client = &self.hub.client;
9426 dlg.pre_request();
9427 let mut req_builder = hyper::Request::builder()
9428 .method(hyper::Method::POST)
9429 .uri(url.as_str())
9430 .header(USER_AGENT, self.hub._user_agent.clone());
9431
9432 if let Some(token) = token.as_ref() {
9433 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9434 }
9435
9436 let request = req_builder
9437 .header(CONTENT_TYPE, json_mime_type.to_string())
9438 .header(CONTENT_LENGTH, request_size as u64)
9439 .body(common::to_body(
9440 request_value_reader.get_ref().clone().into(),
9441 ));
9442
9443 client.request(request.unwrap()).await
9444 };
9445
9446 match req_result {
9447 Err(err) => {
9448 if let common::Retry::After(d) = dlg.http_error(&err) {
9449 sleep(d).await;
9450 continue;
9451 }
9452 dlg.finished(false);
9453 return Err(common::Error::HttpError(err));
9454 }
9455 Ok(res) => {
9456 let (mut parts, body) = res.into_parts();
9457 let mut body = common::Body::new(body);
9458 if !parts.status.is_success() {
9459 let bytes = common::to_bytes(body).await.unwrap_or_default();
9460 let error = serde_json::from_str(&common::to_string(&bytes));
9461 let response = common::to_response(parts, bytes.into());
9462
9463 if let common::Retry::After(d) =
9464 dlg.http_failure(&response, error.as_ref().ok())
9465 {
9466 sleep(d).await;
9467 continue;
9468 }
9469
9470 dlg.finished(false);
9471
9472 return Err(match error {
9473 Ok(value) => common::Error::BadRequest(value),
9474 _ => common::Error::Failure(response),
9475 });
9476 }
9477 let response = {
9478 let bytes = common::to_bytes(body).await.unwrap_or_default();
9479 let encoded = common::to_string(&bytes);
9480 match serde_json::from_str(&encoded) {
9481 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9482 Err(error) => {
9483 dlg.response_json_decode_error(&encoded, &error);
9484 return Err(common::Error::JsonDecodeError(
9485 encoded.to_string(),
9486 error,
9487 ));
9488 }
9489 }
9490 };
9491
9492 dlg.finished(true);
9493 return Ok(response);
9494 }
9495 }
9496 }
9497 }
9498
9499 ///
9500 /// Sets the *request* property to the given value.
9501 ///
9502 /// Even though the property as already been set when instantiating this call,
9503 /// we provide this method for API completeness.
9504 pub fn request(
9505 mut self,
9506 new_value: GoogleCloudDocumentaiV1ProcessRequest,
9507 ) -> ProjectLocationProcessorProcessorVersionProcesCall<'a, C> {
9508 self._request = new_value;
9509 self
9510 }
9511 /// 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}`
9512 ///
9513 /// Sets the *name* path property to the given value.
9514 ///
9515 /// Even though the property as already been set when instantiating this call,
9516 /// we provide this method for API completeness.
9517 pub fn name(
9518 mut self,
9519 new_value: &str,
9520 ) -> ProjectLocationProcessorProcessorVersionProcesCall<'a, C> {
9521 self._name = new_value.to_string();
9522 self
9523 }
9524 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9525 /// while executing the actual API request.
9526 ///
9527 /// ````text
9528 /// It should be used to handle progress information, and to implement a certain level of resilience.
9529 /// ````
9530 ///
9531 /// Sets the *delegate* property to the given value.
9532 pub fn delegate(
9533 mut self,
9534 new_value: &'a mut dyn common::Delegate,
9535 ) -> ProjectLocationProcessorProcessorVersionProcesCall<'a, C> {
9536 self._delegate = Some(new_value);
9537 self
9538 }
9539
9540 /// Set any additional parameter of the query string used in the request.
9541 /// It should be used to set parameters which are not yet available through their own
9542 /// setters.
9543 ///
9544 /// Please note that this method must not be used to set any of the known parameters
9545 /// which have their own setter method. If done anyway, the request will fail.
9546 ///
9547 /// # Additional Parameters
9548 ///
9549 /// * *$.xgafv* (query-string) - V1 error format.
9550 /// * *access_token* (query-string) - OAuth access token.
9551 /// * *alt* (query-string) - Data format for response.
9552 /// * *callback* (query-string) - JSONP
9553 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9554 /// * *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.
9555 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9556 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9557 /// * *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.
9558 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9559 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9560 pub fn param<T>(
9561 mut self,
9562 name: T,
9563 value: T,
9564 ) -> ProjectLocationProcessorProcessorVersionProcesCall<'a, C>
9565 where
9566 T: AsRef<str>,
9567 {
9568 self._additional_params
9569 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9570 self
9571 }
9572
9573 /// Identifies the authorization scope for the method you are building.
9574 ///
9575 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9576 /// [`Scope::CloudPlatform`].
9577 ///
9578 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9579 /// tokens for more than one scope.
9580 ///
9581 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9582 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9583 /// sufficient, a read-write scope will do as well.
9584 pub fn add_scope<St>(
9585 mut self,
9586 scope: St,
9587 ) -> ProjectLocationProcessorProcessorVersionProcesCall<'a, C>
9588 where
9589 St: AsRef<str>,
9590 {
9591 self._scopes.insert(String::from(scope.as_ref()));
9592 self
9593 }
9594 /// Identifies the authorization scope(s) for the method you are building.
9595 ///
9596 /// See [`Self::add_scope()`] for details.
9597 pub fn add_scopes<I, St>(
9598 mut self,
9599 scopes: I,
9600 ) -> ProjectLocationProcessorProcessorVersionProcesCall<'a, C>
9601 where
9602 I: IntoIterator<Item = St>,
9603 St: AsRef<str>,
9604 {
9605 self._scopes
9606 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9607 self
9608 }
9609
9610 /// Removes all scopes, and no default scope will be used either.
9611 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9612 /// for details).
9613 pub fn clear_scopes(mut self) -> ProjectLocationProcessorProcessorVersionProcesCall<'a, C> {
9614 self._scopes.clear();
9615 self
9616 }
9617}
9618
9619/// Trains a new processor version. Operation metadata is returned as TrainProcessorVersionMetadata.
9620///
9621/// A builder for the *locations.processors.processorVersions.train* method supported by a *project* resource.
9622/// It is not used directly, but through a [`ProjectMethods`] instance.
9623///
9624/// # Example
9625///
9626/// Instantiate a resource method builder
9627///
9628/// ```test_harness,no_run
9629/// # extern crate hyper;
9630/// # extern crate hyper_rustls;
9631/// # extern crate google_documentai1 as documentai1;
9632/// use documentai1::api::GoogleCloudDocumentaiV1TrainProcessorVersionRequest;
9633/// # async fn dox() {
9634/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9635///
9636/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9637/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9638/// # .with_native_roots()
9639/// # .unwrap()
9640/// # .https_only()
9641/// # .enable_http2()
9642/// # .build();
9643///
9644/// # let executor = hyper_util::rt::TokioExecutor::new();
9645/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9646/// # secret,
9647/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9648/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9649/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9650/// # ),
9651/// # ).build().await.unwrap();
9652///
9653/// # let client = hyper_util::client::legacy::Client::builder(
9654/// # hyper_util::rt::TokioExecutor::new()
9655/// # )
9656/// # .build(
9657/// # hyper_rustls::HttpsConnectorBuilder::new()
9658/// # .with_native_roots()
9659/// # .unwrap()
9660/// # .https_or_http()
9661/// # .enable_http2()
9662/// # .build()
9663/// # );
9664/// # let mut hub = Document::new(client, auth);
9665/// // As the method needs a request, you would usually fill it with the desired information
9666/// // into the respective structure. Some of the parts shown here might not be applicable !
9667/// // Values shown here are possibly random and not representative !
9668/// let mut req = GoogleCloudDocumentaiV1TrainProcessorVersionRequest::default();
9669///
9670/// // You can configure optional parameters by calling the respective setters at will, and
9671/// // execute the final call using `doit()`.
9672/// // Values shown here are possibly random and not representative !
9673/// let result = hub.projects().locations_processors_processor_versions_train(req, "parent")
9674/// .doit().await;
9675/// # }
9676/// ```
9677pub struct ProjectLocationProcessorProcessorVersionTrainCall<'a, C>
9678where
9679 C: 'a,
9680{
9681 hub: &'a Document<C>,
9682 _request: GoogleCloudDocumentaiV1TrainProcessorVersionRequest,
9683 _parent: String,
9684 _delegate: Option<&'a mut dyn common::Delegate>,
9685 _additional_params: HashMap<String, String>,
9686 _scopes: BTreeSet<String>,
9687}
9688
9689impl<'a, C> common::CallBuilder for ProjectLocationProcessorProcessorVersionTrainCall<'a, C> {}
9690
9691impl<'a, C> ProjectLocationProcessorProcessorVersionTrainCall<'a, C>
9692where
9693 C: common::Connector,
9694{
9695 /// Perform the operation you have build so far.
9696 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
9697 use std::borrow::Cow;
9698 use std::io::{Read, Seek};
9699
9700 use common::{url::Params, ToParts};
9701 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9702
9703 let mut dd = common::DefaultDelegate;
9704 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9705 dlg.begin(common::MethodInfo {
9706 id: "documentai.projects.locations.processors.processorVersions.train",
9707 http_method: hyper::Method::POST,
9708 });
9709
9710 for &field in ["alt", "parent"].iter() {
9711 if self._additional_params.contains_key(field) {
9712 dlg.finished(false);
9713 return Err(common::Error::FieldClash(field));
9714 }
9715 }
9716
9717 let mut params = Params::with_capacity(4 + self._additional_params.len());
9718 params.push("parent", self._parent);
9719
9720 params.extend(self._additional_params.iter());
9721
9722 params.push("alt", "json");
9723 let mut url = self.hub._base_url.clone() + "v1/{+parent}/processorVersions:train";
9724 if self._scopes.is_empty() {
9725 self._scopes
9726 .insert(Scope::CloudPlatform.as_ref().to_string());
9727 }
9728
9729 #[allow(clippy::single_element_loop)]
9730 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9731 url = params.uri_replacement(url, param_name, find_this, true);
9732 }
9733 {
9734 let to_remove = ["parent"];
9735 params.remove_params(&to_remove);
9736 }
9737
9738 let url = params.parse_with_url(&url);
9739
9740 let mut json_mime_type = mime::APPLICATION_JSON;
9741 let mut request_value_reader = {
9742 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9743 common::remove_json_null_values(&mut value);
9744 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9745 serde_json::to_writer(&mut dst, &value).unwrap();
9746 dst
9747 };
9748 let request_size = request_value_reader
9749 .seek(std::io::SeekFrom::End(0))
9750 .unwrap();
9751 request_value_reader
9752 .seek(std::io::SeekFrom::Start(0))
9753 .unwrap();
9754
9755 loop {
9756 let token = match self
9757 .hub
9758 .auth
9759 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9760 .await
9761 {
9762 Ok(token) => token,
9763 Err(e) => match dlg.token(e) {
9764 Ok(token) => token,
9765 Err(e) => {
9766 dlg.finished(false);
9767 return Err(common::Error::MissingToken(e));
9768 }
9769 },
9770 };
9771 request_value_reader
9772 .seek(std::io::SeekFrom::Start(0))
9773 .unwrap();
9774 let mut req_result = {
9775 let client = &self.hub.client;
9776 dlg.pre_request();
9777 let mut req_builder = hyper::Request::builder()
9778 .method(hyper::Method::POST)
9779 .uri(url.as_str())
9780 .header(USER_AGENT, self.hub._user_agent.clone());
9781
9782 if let Some(token) = token.as_ref() {
9783 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9784 }
9785
9786 let request = req_builder
9787 .header(CONTENT_TYPE, json_mime_type.to_string())
9788 .header(CONTENT_LENGTH, request_size as u64)
9789 .body(common::to_body(
9790 request_value_reader.get_ref().clone().into(),
9791 ));
9792
9793 client.request(request.unwrap()).await
9794 };
9795
9796 match req_result {
9797 Err(err) => {
9798 if let common::Retry::After(d) = dlg.http_error(&err) {
9799 sleep(d).await;
9800 continue;
9801 }
9802 dlg.finished(false);
9803 return Err(common::Error::HttpError(err));
9804 }
9805 Ok(res) => {
9806 let (mut parts, body) = res.into_parts();
9807 let mut body = common::Body::new(body);
9808 if !parts.status.is_success() {
9809 let bytes = common::to_bytes(body).await.unwrap_or_default();
9810 let error = serde_json::from_str(&common::to_string(&bytes));
9811 let response = common::to_response(parts, bytes.into());
9812
9813 if let common::Retry::After(d) =
9814 dlg.http_failure(&response, error.as_ref().ok())
9815 {
9816 sleep(d).await;
9817 continue;
9818 }
9819
9820 dlg.finished(false);
9821
9822 return Err(match error {
9823 Ok(value) => common::Error::BadRequest(value),
9824 _ => common::Error::Failure(response),
9825 });
9826 }
9827 let response = {
9828 let bytes = common::to_bytes(body).await.unwrap_or_default();
9829 let encoded = common::to_string(&bytes);
9830 match serde_json::from_str(&encoded) {
9831 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9832 Err(error) => {
9833 dlg.response_json_decode_error(&encoded, &error);
9834 return Err(common::Error::JsonDecodeError(
9835 encoded.to_string(),
9836 error,
9837 ));
9838 }
9839 }
9840 };
9841
9842 dlg.finished(true);
9843 return Ok(response);
9844 }
9845 }
9846 }
9847 }
9848
9849 ///
9850 /// Sets the *request* property to the given value.
9851 ///
9852 /// Even though the property as already been set when instantiating this call,
9853 /// we provide this method for API completeness.
9854 pub fn request(
9855 mut self,
9856 new_value: GoogleCloudDocumentaiV1TrainProcessorVersionRequest,
9857 ) -> ProjectLocationProcessorProcessorVersionTrainCall<'a, C> {
9858 self._request = new_value;
9859 self
9860 }
9861 /// Required. The parent (project, location and processor) to create the new version for. Format: `projects/{project}/locations/{location}/processors/{processor}`.
9862 ///
9863 /// Sets the *parent* path property to the given value.
9864 ///
9865 /// Even though the property as already been set when instantiating this call,
9866 /// we provide this method for API completeness.
9867 pub fn parent(
9868 mut self,
9869 new_value: &str,
9870 ) -> ProjectLocationProcessorProcessorVersionTrainCall<'a, C> {
9871 self._parent = new_value.to_string();
9872 self
9873 }
9874 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9875 /// while executing the actual API request.
9876 ///
9877 /// ````text
9878 /// It should be used to handle progress information, and to implement a certain level of resilience.
9879 /// ````
9880 ///
9881 /// Sets the *delegate* property to the given value.
9882 pub fn delegate(
9883 mut self,
9884 new_value: &'a mut dyn common::Delegate,
9885 ) -> ProjectLocationProcessorProcessorVersionTrainCall<'a, C> {
9886 self._delegate = Some(new_value);
9887 self
9888 }
9889
9890 /// Set any additional parameter of the query string used in the request.
9891 /// It should be used to set parameters which are not yet available through their own
9892 /// setters.
9893 ///
9894 /// Please note that this method must not be used to set any of the known parameters
9895 /// which have their own setter method. If done anyway, the request will fail.
9896 ///
9897 /// # Additional Parameters
9898 ///
9899 /// * *$.xgafv* (query-string) - V1 error format.
9900 /// * *access_token* (query-string) - OAuth access token.
9901 /// * *alt* (query-string) - Data format for response.
9902 /// * *callback* (query-string) - JSONP
9903 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9904 /// * *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.
9905 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9906 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9907 /// * *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.
9908 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9909 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9910 pub fn param<T>(
9911 mut self,
9912 name: T,
9913 value: T,
9914 ) -> ProjectLocationProcessorProcessorVersionTrainCall<'a, C>
9915 where
9916 T: AsRef<str>,
9917 {
9918 self._additional_params
9919 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9920 self
9921 }
9922
9923 /// Identifies the authorization scope for the method you are building.
9924 ///
9925 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9926 /// [`Scope::CloudPlatform`].
9927 ///
9928 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9929 /// tokens for more than one scope.
9930 ///
9931 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9932 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9933 /// sufficient, a read-write scope will do as well.
9934 pub fn add_scope<St>(
9935 mut self,
9936 scope: St,
9937 ) -> ProjectLocationProcessorProcessorVersionTrainCall<'a, C>
9938 where
9939 St: AsRef<str>,
9940 {
9941 self._scopes.insert(String::from(scope.as_ref()));
9942 self
9943 }
9944 /// Identifies the authorization scope(s) for the method you are building.
9945 ///
9946 /// See [`Self::add_scope()`] for details.
9947 pub fn add_scopes<I, St>(
9948 mut self,
9949 scopes: I,
9950 ) -> ProjectLocationProcessorProcessorVersionTrainCall<'a, C>
9951 where
9952 I: IntoIterator<Item = St>,
9953 St: AsRef<str>,
9954 {
9955 self._scopes
9956 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9957 self
9958 }
9959
9960 /// Removes all scopes, and no default scope will be used either.
9961 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9962 /// for details).
9963 pub fn clear_scopes(mut self) -> ProjectLocationProcessorProcessorVersionTrainCall<'a, C> {
9964 self._scopes.clear();
9965 self
9966 }
9967}
9968
9969/// Undeploys the processor version.
9970///
9971/// A builder for the *locations.processors.processorVersions.undeploy* method supported by a *project* resource.
9972/// It is not used directly, but through a [`ProjectMethods`] instance.
9973///
9974/// # Example
9975///
9976/// Instantiate a resource method builder
9977///
9978/// ```test_harness,no_run
9979/// # extern crate hyper;
9980/// # extern crate hyper_rustls;
9981/// # extern crate google_documentai1 as documentai1;
9982/// use documentai1::api::GoogleCloudDocumentaiV1UndeployProcessorVersionRequest;
9983/// # async fn dox() {
9984/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9985///
9986/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9987/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9988/// # .with_native_roots()
9989/// # .unwrap()
9990/// # .https_only()
9991/// # .enable_http2()
9992/// # .build();
9993///
9994/// # let executor = hyper_util::rt::TokioExecutor::new();
9995/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9996/// # secret,
9997/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9998/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9999/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10000/// # ),
10001/// # ).build().await.unwrap();
10002///
10003/// # let client = hyper_util::client::legacy::Client::builder(
10004/// # hyper_util::rt::TokioExecutor::new()
10005/// # )
10006/// # .build(
10007/// # hyper_rustls::HttpsConnectorBuilder::new()
10008/// # .with_native_roots()
10009/// # .unwrap()
10010/// # .https_or_http()
10011/// # .enable_http2()
10012/// # .build()
10013/// # );
10014/// # let mut hub = Document::new(client, auth);
10015/// // As the method needs a request, you would usually fill it with the desired information
10016/// // into the respective structure. Some of the parts shown here might not be applicable !
10017/// // Values shown here are possibly random and not representative !
10018/// let mut req = GoogleCloudDocumentaiV1UndeployProcessorVersionRequest::default();
10019///
10020/// // You can configure optional parameters by calling the respective setters at will, and
10021/// // execute the final call using `doit()`.
10022/// // Values shown here are possibly random and not representative !
10023/// let result = hub.projects().locations_processors_processor_versions_undeploy(req, "name")
10024/// .doit().await;
10025/// # }
10026/// ```
10027pub struct ProjectLocationProcessorProcessorVersionUndeployCall<'a, C>
10028where
10029 C: 'a,
10030{
10031 hub: &'a Document<C>,
10032 _request: GoogleCloudDocumentaiV1UndeployProcessorVersionRequest,
10033 _name: String,
10034 _delegate: Option<&'a mut dyn common::Delegate>,
10035 _additional_params: HashMap<String, String>,
10036 _scopes: BTreeSet<String>,
10037}
10038
10039impl<'a, C> common::CallBuilder for ProjectLocationProcessorProcessorVersionUndeployCall<'a, C> {}
10040
10041impl<'a, C> ProjectLocationProcessorProcessorVersionUndeployCall<'a, C>
10042where
10043 C: common::Connector,
10044{
10045 /// Perform the operation you have build so far.
10046 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
10047 use std::borrow::Cow;
10048 use std::io::{Read, Seek};
10049
10050 use common::{url::Params, ToParts};
10051 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10052
10053 let mut dd = common::DefaultDelegate;
10054 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10055 dlg.begin(common::MethodInfo {
10056 id: "documentai.projects.locations.processors.processorVersions.undeploy",
10057 http_method: hyper::Method::POST,
10058 });
10059
10060 for &field in ["alt", "name"].iter() {
10061 if self._additional_params.contains_key(field) {
10062 dlg.finished(false);
10063 return Err(common::Error::FieldClash(field));
10064 }
10065 }
10066
10067 let mut params = Params::with_capacity(4 + self._additional_params.len());
10068 params.push("name", self._name);
10069
10070 params.extend(self._additional_params.iter());
10071
10072 params.push("alt", "json");
10073 let mut url = self.hub._base_url.clone() + "v1/{+name}:undeploy";
10074 if self._scopes.is_empty() {
10075 self._scopes
10076 .insert(Scope::CloudPlatform.as_ref().to_string());
10077 }
10078
10079 #[allow(clippy::single_element_loop)]
10080 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10081 url = params.uri_replacement(url, param_name, find_this, true);
10082 }
10083 {
10084 let to_remove = ["name"];
10085 params.remove_params(&to_remove);
10086 }
10087
10088 let url = params.parse_with_url(&url);
10089
10090 let mut json_mime_type = mime::APPLICATION_JSON;
10091 let mut request_value_reader = {
10092 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10093 common::remove_json_null_values(&mut value);
10094 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10095 serde_json::to_writer(&mut dst, &value).unwrap();
10096 dst
10097 };
10098 let request_size = request_value_reader
10099 .seek(std::io::SeekFrom::End(0))
10100 .unwrap();
10101 request_value_reader
10102 .seek(std::io::SeekFrom::Start(0))
10103 .unwrap();
10104
10105 loop {
10106 let token = match self
10107 .hub
10108 .auth
10109 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10110 .await
10111 {
10112 Ok(token) => token,
10113 Err(e) => match dlg.token(e) {
10114 Ok(token) => token,
10115 Err(e) => {
10116 dlg.finished(false);
10117 return Err(common::Error::MissingToken(e));
10118 }
10119 },
10120 };
10121 request_value_reader
10122 .seek(std::io::SeekFrom::Start(0))
10123 .unwrap();
10124 let mut req_result = {
10125 let client = &self.hub.client;
10126 dlg.pre_request();
10127 let mut req_builder = hyper::Request::builder()
10128 .method(hyper::Method::POST)
10129 .uri(url.as_str())
10130 .header(USER_AGENT, self.hub._user_agent.clone());
10131
10132 if let Some(token) = token.as_ref() {
10133 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10134 }
10135
10136 let request = req_builder
10137 .header(CONTENT_TYPE, json_mime_type.to_string())
10138 .header(CONTENT_LENGTH, request_size as u64)
10139 .body(common::to_body(
10140 request_value_reader.get_ref().clone().into(),
10141 ));
10142
10143 client.request(request.unwrap()).await
10144 };
10145
10146 match req_result {
10147 Err(err) => {
10148 if let common::Retry::After(d) = dlg.http_error(&err) {
10149 sleep(d).await;
10150 continue;
10151 }
10152 dlg.finished(false);
10153 return Err(common::Error::HttpError(err));
10154 }
10155 Ok(res) => {
10156 let (mut parts, body) = res.into_parts();
10157 let mut body = common::Body::new(body);
10158 if !parts.status.is_success() {
10159 let bytes = common::to_bytes(body).await.unwrap_or_default();
10160 let error = serde_json::from_str(&common::to_string(&bytes));
10161 let response = common::to_response(parts, bytes.into());
10162
10163 if let common::Retry::After(d) =
10164 dlg.http_failure(&response, error.as_ref().ok())
10165 {
10166 sleep(d).await;
10167 continue;
10168 }
10169
10170 dlg.finished(false);
10171
10172 return Err(match error {
10173 Ok(value) => common::Error::BadRequest(value),
10174 _ => common::Error::Failure(response),
10175 });
10176 }
10177 let response = {
10178 let bytes = common::to_bytes(body).await.unwrap_or_default();
10179 let encoded = common::to_string(&bytes);
10180 match serde_json::from_str(&encoded) {
10181 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10182 Err(error) => {
10183 dlg.response_json_decode_error(&encoded, &error);
10184 return Err(common::Error::JsonDecodeError(
10185 encoded.to_string(),
10186 error,
10187 ));
10188 }
10189 }
10190 };
10191
10192 dlg.finished(true);
10193 return Ok(response);
10194 }
10195 }
10196 }
10197 }
10198
10199 ///
10200 /// Sets the *request* property to the given value.
10201 ///
10202 /// Even though the property as already been set when instantiating this call,
10203 /// we provide this method for API completeness.
10204 pub fn request(
10205 mut self,
10206 new_value: GoogleCloudDocumentaiV1UndeployProcessorVersionRequest,
10207 ) -> ProjectLocationProcessorProcessorVersionUndeployCall<'a, C> {
10208 self._request = new_value;
10209 self
10210 }
10211 /// Required. The processor version resource name to be undeployed.
10212 ///
10213 /// Sets the *name* path property to the given value.
10214 ///
10215 /// Even though the property as already been set when instantiating this call,
10216 /// we provide this method for API completeness.
10217 pub fn name(
10218 mut self,
10219 new_value: &str,
10220 ) -> ProjectLocationProcessorProcessorVersionUndeployCall<'a, C> {
10221 self._name = new_value.to_string();
10222 self
10223 }
10224 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10225 /// while executing the actual API request.
10226 ///
10227 /// ````text
10228 /// It should be used to handle progress information, and to implement a certain level of resilience.
10229 /// ````
10230 ///
10231 /// Sets the *delegate* property to the given value.
10232 pub fn delegate(
10233 mut self,
10234 new_value: &'a mut dyn common::Delegate,
10235 ) -> ProjectLocationProcessorProcessorVersionUndeployCall<'a, C> {
10236 self._delegate = Some(new_value);
10237 self
10238 }
10239
10240 /// Set any additional parameter of the query string used in the request.
10241 /// It should be used to set parameters which are not yet available through their own
10242 /// setters.
10243 ///
10244 /// Please note that this method must not be used to set any of the known parameters
10245 /// which have their own setter method. If done anyway, the request will fail.
10246 ///
10247 /// # Additional Parameters
10248 ///
10249 /// * *$.xgafv* (query-string) - V1 error format.
10250 /// * *access_token* (query-string) - OAuth access token.
10251 /// * *alt* (query-string) - Data format for response.
10252 /// * *callback* (query-string) - JSONP
10253 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10254 /// * *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.
10255 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10256 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10257 /// * *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.
10258 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10259 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10260 pub fn param<T>(
10261 mut self,
10262 name: T,
10263 value: T,
10264 ) -> ProjectLocationProcessorProcessorVersionUndeployCall<'a, C>
10265 where
10266 T: AsRef<str>,
10267 {
10268 self._additional_params
10269 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10270 self
10271 }
10272
10273 /// Identifies the authorization scope for the method you are building.
10274 ///
10275 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10276 /// [`Scope::CloudPlatform`].
10277 ///
10278 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10279 /// tokens for more than one scope.
10280 ///
10281 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10282 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10283 /// sufficient, a read-write scope will do as well.
10284 pub fn add_scope<St>(
10285 mut self,
10286 scope: St,
10287 ) -> ProjectLocationProcessorProcessorVersionUndeployCall<'a, C>
10288 where
10289 St: AsRef<str>,
10290 {
10291 self._scopes.insert(String::from(scope.as_ref()));
10292 self
10293 }
10294 /// Identifies the authorization scope(s) for the method you are building.
10295 ///
10296 /// See [`Self::add_scope()`] for details.
10297 pub fn add_scopes<I, St>(
10298 mut self,
10299 scopes: I,
10300 ) -> ProjectLocationProcessorProcessorVersionUndeployCall<'a, C>
10301 where
10302 I: IntoIterator<Item = St>,
10303 St: AsRef<str>,
10304 {
10305 self._scopes
10306 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10307 self
10308 }
10309
10310 /// Removes all scopes, and no default scope will be used either.
10311 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10312 /// for details).
10313 pub fn clear_scopes(mut self) -> ProjectLocationProcessorProcessorVersionUndeployCall<'a, C> {
10314 self._scopes.clear();
10315 self
10316 }
10317}
10318
10319/// LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in the [Document] format.
10320///
10321/// A builder for the *locations.processors.batchProcess* method supported by a *project* resource.
10322/// It is not used directly, but through a [`ProjectMethods`] instance.
10323///
10324/// # Example
10325///
10326/// Instantiate a resource method builder
10327///
10328/// ```test_harness,no_run
10329/// # extern crate hyper;
10330/// # extern crate hyper_rustls;
10331/// # extern crate google_documentai1 as documentai1;
10332/// use documentai1::api::GoogleCloudDocumentaiV1BatchProcessRequest;
10333/// # async fn dox() {
10334/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10335///
10336/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10337/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10338/// # .with_native_roots()
10339/// # .unwrap()
10340/// # .https_only()
10341/// # .enable_http2()
10342/// # .build();
10343///
10344/// # let executor = hyper_util::rt::TokioExecutor::new();
10345/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10346/// # secret,
10347/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10348/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10349/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10350/// # ),
10351/// # ).build().await.unwrap();
10352///
10353/// # let client = hyper_util::client::legacy::Client::builder(
10354/// # hyper_util::rt::TokioExecutor::new()
10355/// # )
10356/// # .build(
10357/// # hyper_rustls::HttpsConnectorBuilder::new()
10358/// # .with_native_roots()
10359/// # .unwrap()
10360/// # .https_or_http()
10361/// # .enable_http2()
10362/// # .build()
10363/// # );
10364/// # let mut hub = Document::new(client, auth);
10365/// // As the method needs a request, you would usually fill it with the desired information
10366/// // into the respective structure. Some of the parts shown here might not be applicable !
10367/// // Values shown here are possibly random and not representative !
10368/// let mut req = GoogleCloudDocumentaiV1BatchProcessRequest::default();
10369///
10370/// // You can configure optional parameters by calling the respective setters at will, and
10371/// // execute the final call using `doit()`.
10372/// // Values shown here are possibly random and not representative !
10373/// let result = hub.projects().locations_processors_batch_process(req, "name")
10374/// .doit().await;
10375/// # }
10376/// ```
10377pub struct ProjectLocationProcessorBatchProcesCall<'a, C>
10378where
10379 C: 'a,
10380{
10381 hub: &'a Document<C>,
10382 _request: GoogleCloudDocumentaiV1BatchProcessRequest,
10383 _name: String,
10384 _delegate: Option<&'a mut dyn common::Delegate>,
10385 _additional_params: HashMap<String, String>,
10386 _scopes: BTreeSet<String>,
10387}
10388
10389impl<'a, C> common::CallBuilder for ProjectLocationProcessorBatchProcesCall<'a, C> {}
10390
10391impl<'a, C> ProjectLocationProcessorBatchProcesCall<'a, C>
10392where
10393 C: common::Connector,
10394{
10395 /// Perform the operation you have build so far.
10396 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
10397 use std::borrow::Cow;
10398 use std::io::{Read, Seek};
10399
10400 use common::{url::Params, ToParts};
10401 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10402
10403 let mut dd = common::DefaultDelegate;
10404 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10405 dlg.begin(common::MethodInfo {
10406 id: "documentai.projects.locations.processors.batchProcess",
10407 http_method: hyper::Method::POST,
10408 });
10409
10410 for &field in ["alt", "name"].iter() {
10411 if self._additional_params.contains_key(field) {
10412 dlg.finished(false);
10413 return Err(common::Error::FieldClash(field));
10414 }
10415 }
10416
10417 let mut params = Params::with_capacity(4 + self._additional_params.len());
10418 params.push("name", self._name);
10419
10420 params.extend(self._additional_params.iter());
10421
10422 params.push("alt", "json");
10423 let mut url = self.hub._base_url.clone() + "v1/{+name}:batchProcess";
10424 if self._scopes.is_empty() {
10425 self._scopes
10426 .insert(Scope::CloudPlatform.as_ref().to_string());
10427 }
10428
10429 #[allow(clippy::single_element_loop)]
10430 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10431 url = params.uri_replacement(url, param_name, find_this, true);
10432 }
10433 {
10434 let to_remove = ["name"];
10435 params.remove_params(&to_remove);
10436 }
10437
10438 let url = params.parse_with_url(&url);
10439
10440 let mut json_mime_type = mime::APPLICATION_JSON;
10441 let mut request_value_reader = {
10442 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10443 common::remove_json_null_values(&mut value);
10444 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10445 serde_json::to_writer(&mut dst, &value).unwrap();
10446 dst
10447 };
10448 let request_size = request_value_reader
10449 .seek(std::io::SeekFrom::End(0))
10450 .unwrap();
10451 request_value_reader
10452 .seek(std::io::SeekFrom::Start(0))
10453 .unwrap();
10454
10455 loop {
10456 let token = match self
10457 .hub
10458 .auth
10459 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10460 .await
10461 {
10462 Ok(token) => token,
10463 Err(e) => match dlg.token(e) {
10464 Ok(token) => token,
10465 Err(e) => {
10466 dlg.finished(false);
10467 return Err(common::Error::MissingToken(e));
10468 }
10469 },
10470 };
10471 request_value_reader
10472 .seek(std::io::SeekFrom::Start(0))
10473 .unwrap();
10474 let mut req_result = {
10475 let client = &self.hub.client;
10476 dlg.pre_request();
10477 let mut req_builder = hyper::Request::builder()
10478 .method(hyper::Method::POST)
10479 .uri(url.as_str())
10480 .header(USER_AGENT, self.hub._user_agent.clone());
10481
10482 if let Some(token) = token.as_ref() {
10483 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10484 }
10485
10486 let request = req_builder
10487 .header(CONTENT_TYPE, json_mime_type.to_string())
10488 .header(CONTENT_LENGTH, request_size as u64)
10489 .body(common::to_body(
10490 request_value_reader.get_ref().clone().into(),
10491 ));
10492
10493 client.request(request.unwrap()).await
10494 };
10495
10496 match req_result {
10497 Err(err) => {
10498 if let common::Retry::After(d) = dlg.http_error(&err) {
10499 sleep(d).await;
10500 continue;
10501 }
10502 dlg.finished(false);
10503 return Err(common::Error::HttpError(err));
10504 }
10505 Ok(res) => {
10506 let (mut parts, body) = res.into_parts();
10507 let mut body = common::Body::new(body);
10508 if !parts.status.is_success() {
10509 let bytes = common::to_bytes(body).await.unwrap_or_default();
10510 let error = serde_json::from_str(&common::to_string(&bytes));
10511 let response = common::to_response(parts, bytes.into());
10512
10513 if let common::Retry::After(d) =
10514 dlg.http_failure(&response, error.as_ref().ok())
10515 {
10516 sleep(d).await;
10517 continue;
10518 }
10519
10520 dlg.finished(false);
10521
10522 return Err(match error {
10523 Ok(value) => common::Error::BadRequest(value),
10524 _ => common::Error::Failure(response),
10525 });
10526 }
10527 let response = {
10528 let bytes = common::to_bytes(body).await.unwrap_or_default();
10529 let encoded = common::to_string(&bytes);
10530 match serde_json::from_str(&encoded) {
10531 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10532 Err(error) => {
10533 dlg.response_json_decode_error(&encoded, &error);
10534 return Err(common::Error::JsonDecodeError(
10535 encoded.to_string(),
10536 error,
10537 ));
10538 }
10539 }
10540 };
10541
10542 dlg.finished(true);
10543 return Ok(response);
10544 }
10545 }
10546 }
10547 }
10548
10549 ///
10550 /// Sets the *request* property to the given value.
10551 ///
10552 /// Even though the property as already been set when instantiating this call,
10553 /// we provide this method for API completeness.
10554 pub fn request(
10555 mut self,
10556 new_value: GoogleCloudDocumentaiV1BatchProcessRequest,
10557 ) -> ProjectLocationProcessorBatchProcesCall<'a, C> {
10558 self._request = new_value;
10559 self
10560 }
10561 /// Required. The resource name of Processor or ProcessorVersion. Format: `projects/{project}/locations/{location}/processors/{processor}`, or `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`
10562 ///
10563 /// Sets the *name* path property to the given value.
10564 ///
10565 /// Even though the property as already been set when instantiating this call,
10566 /// we provide this method for API completeness.
10567 pub fn name(mut self, new_value: &str) -> ProjectLocationProcessorBatchProcesCall<'a, C> {
10568 self._name = new_value.to_string();
10569 self
10570 }
10571 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10572 /// while executing the actual API request.
10573 ///
10574 /// ````text
10575 /// It should be used to handle progress information, and to implement a certain level of resilience.
10576 /// ````
10577 ///
10578 /// Sets the *delegate* property to the given value.
10579 pub fn delegate(
10580 mut self,
10581 new_value: &'a mut dyn common::Delegate,
10582 ) -> ProjectLocationProcessorBatchProcesCall<'a, C> {
10583 self._delegate = Some(new_value);
10584 self
10585 }
10586
10587 /// Set any additional parameter of the query string used in the request.
10588 /// It should be used to set parameters which are not yet available through their own
10589 /// setters.
10590 ///
10591 /// Please note that this method must not be used to set any of the known parameters
10592 /// which have their own setter method. If done anyway, the request will fail.
10593 ///
10594 /// # Additional Parameters
10595 ///
10596 /// * *$.xgafv* (query-string) - V1 error format.
10597 /// * *access_token* (query-string) - OAuth access token.
10598 /// * *alt* (query-string) - Data format for response.
10599 /// * *callback* (query-string) - JSONP
10600 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10601 /// * *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.
10602 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10603 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10604 /// * *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.
10605 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10606 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10607 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProcessorBatchProcesCall<'a, C>
10608 where
10609 T: AsRef<str>,
10610 {
10611 self._additional_params
10612 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10613 self
10614 }
10615
10616 /// Identifies the authorization scope for the method you are building.
10617 ///
10618 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10619 /// [`Scope::CloudPlatform`].
10620 ///
10621 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10622 /// tokens for more than one scope.
10623 ///
10624 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10625 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10626 /// sufficient, a read-write scope will do as well.
10627 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProcessorBatchProcesCall<'a, C>
10628 where
10629 St: AsRef<str>,
10630 {
10631 self._scopes.insert(String::from(scope.as_ref()));
10632 self
10633 }
10634 /// Identifies the authorization scope(s) for the method you are building.
10635 ///
10636 /// See [`Self::add_scope()`] for details.
10637 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProcessorBatchProcesCall<'a, C>
10638 where
10639 I: IntoIterator<Item = St>,
10640 St: AsRef<str>,
10641 {
10642 self._scopes
10643 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10644 self
10645 }
10646
10647 /// Removes all scopes, and no default scope will be used either.
10648 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10649 /// for details).
10650 pub fn clear_scopes(mut self) -> ProjectLocationProcessorBatchProcesCall<'a, C> {
10651 self._scopes.clear();
10652 self
10653 }
10654}
10655
10656/// 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.
10657///
10658/// A builder for the *locations.processors.create* method supported by a *project* resource.
10659/// It is not used directly, but through a [`ProjectMethods`] instance.
10660///
10661/// # Example
10662///
10663/// Instantiate a resource method builder
10664///
10665/// ```test_harness,no_run
10666/// # extern crate hyper;
10667/// # extern crate hyper_rustls;
10668/// # extern crate google_documentai1 as documentai1;
10669/// use documentai1::api::GoogleCloudDocumentaiV1Processor;
10670/// # async fn dox() {
10671/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10672///
10673/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10674/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10675/// # .with_native_roots()
10676/// # .unwrap()
10677/// # .https_only()
10678/// # .enable_http2()
10679/// # .build();
10680///
10681/// # let executor = hyper_util::rt::TokioExecutor::new();
10682/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10683/// # secret,
10684/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10685/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10686/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10687/// # ),
10688/// # ).build().await.unwrap();
10689///
10690/// # let client = hyper_util::client::legacy::Client::builder(
10691/// # hyper_util::rt::TokioExecutor::new()
10692/// # )
10693/// # .build(
10694/// # hyper_rustls::HttpsConnectorBuilder::new()
10695/// # .with_native_roots()
10696/// # .unwrap()
10697/// # .https_or_http()
10698/// # .enable_http2()
10699/// # .build()
10700/// # );
10701/// # let mut hub = Document::new(client, auth);
10702/// // As the method needs a request, you would usually fill it with the desired information
10703/// // into the respective structure. Some of the parts shown here might not be applicable !
10704/// // Values shown here are possibly random and not representative !
10705/// let mut req = GoogleCloudDocumentaiV1Processor::default();
10706///
10707/// // You can configure optional parameters by calling the respective setters at will, and
10708/// // execute the final call using `doit()`.
10709/// // Values shown here are possibly random and not representative !
10710/// let result = hub.projects().locations_processors_create(req, "parent")
10711/// .doit().await;
10712/// # }
10713/// ```
10714pub struct ProjectLocationProcessorCreateCall<'a, C>
10715where
10716 C: 'a,
10717{
10718 hub: &'a Document<C>,
10719 _request: GoogleCloudDocumentaiV1Processor,
10720 _parent: String,
10721 _delegate: Option<&'a mut dyn common::Delegate>,
10722 _additional_params: HashMap<String, String>,
10723 _scopes: BTreeSet<String>,
10724}
10725
10726impl<'a, C> common::CallBuilder for ProjectLocationProcessorCreateCall<'a, C> {}
10727
10728impl<'a, C> ProjectLocationProcessorCreateCall<'a, C>
10729where
10730 C: common::Connector,
10731{
10732 /// Perform the operation you have build so far.
10733 pub async fn doit(
10734 mut self,
10735 ) -> common::Result<(common::Response, GoogleCloudDocumentaiV1Processor)> {
10736 use std::borrow::Cow;
10737 use std::io::{Read, Seek};
10738
10739 use common::{url::Params, ToParts};
10740 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10741
10742 let mut dd = common::DefaultDelegate;
10743 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10744 dlg.begin(common::MethodInfo {
10745 id: "documentai.projects.locations.processors.create",
10746 http_method: hyper::Method::POST,
10747 });
10748
10749 for &field in ["alt", "parent"].iter() {
10750 if self._additional_params.contains_key(field) {
10751 dlg.finished(false);
10752 return Err(common::Error::FieldClash(field));
10753 }
10754 }
10755
10756 let mut params = Params::with_capacity(4 + self._additional_params.len());
10757 params.push("parent", self._parent);
10758
10759 params.extend(self._additional_params.iter());
10760
10761 params.push("alt", "json");
10762 let mut url = self.hub._base_url.clone() + "v1/{+parent}/processors";
10763 if self._scopes.is_empty() {
10764 self._scopes
10765 .insert(Scope::CloudPlatform.as_ref().to_string());
10766 }
10767
10768 #[allow(clippy::single_element_loop)]
10769 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
10770 url = params.uri_replacement(url, param_name, find_this, true);
10771 }
10772 {
10773 let to_remove = ["parent"];
10774 params.remove_params(&to_remove);
10775 }
10776
10777 let url = params.parse_with_url(&url);
10778
10779 let mut json_mime_type = mime::APPLICATION_JSON;
10780 let mut request_value_reader = {
10781 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10782 common::remove_json_null_values(&mut value);
10783 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10784 serde_json::to_writer(&mut dst, &value).unwrap();
10785 dst
10786 };
10787 let request_size = request_value_reader
10788 .seek(std::io::SeekFrom::End(0))
10789 .unwrap();
10790 request_value_reader
10791 .seek(std::io::SeekFrom::Start(0))
10792 .unwrap();
10793
10794 loop {
10795 let token = match self
10796 .hub
10797 .auth
10798 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10799 .await
10800 {
10801 Ok(token) => token,
10802 Err(e) => match dlg.token(e) {
10803 Ok(token) => token,
10804 Err(e) => {
10805 dlg.finished(false);
10806 return Err(common::Error::MissingToken(e));
10807 }
10808 },
10809 };
10810 request_value_reader
10811 .seek(std::io::SeekFrom::Start(0))
10812 .unwrap();
10813 let mut req_result = {
10814 let client = &self.hub.client;
10815 dlg.pre_request();
10816 let mut req_builder = hyper::Request::builder()
10817 .method(hyper::Method::POST)
10818 .uri(url.as_str())
10819 .header(USER_AGENT, self.hub._user_agent.clone());
10820
10821 if let Some(token) = token.as_ref() {
10822 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10823 }
10824
10825 let request = req_builder
10826 .header(CONTENT_TYPE, json_mime_type.to_string())
10827 .header(CONTENT_LENGTH, request_size as u64)
10828 .body(common::to_body(
10829 request_value_reader.get_ref().clone().into(),
10830 ));
10831
10832 client.request(request.unwrap()).await
10833 };
10834
10835 match req_result {
10836 Err(err) => {
10837 if let common::Retry::After(d) = dlg.http_error(&err) {
10838 sleep(d).await;
10839 continue;
10840 }
10841 dlg.finished(false);
10842 return Err(common::Error::HttpError(err));
10843 }
10844 Ok(res) => {
10845 let (mut parts, body) = res.into_parts();
10846 let mut body = common::Body::new(body);
10847 if !parts.status.is_success() {
10848 let bytes = common::to_bytes(body).await.unwrap_or_default();
10849 let error = serde_json::from_str(&common::to_string(&bytes));
10850 let response = common::to_response(parts, bytes.into());
10851
10852 if let common::Retry::After(d) =
10853 dlg.http_failure(&response, error.as_ref().ok())
10854 {
10855 sleep(d).await;
10856 continue;
10857 }
10858
10859 dlg.finished(false);
10860
10861 return Err(match error {
10862 Ok(value) => common::Error::BadRequest(value),
10863 _ => common::Error::Failure(response),
10864 });
10865 }
10866 let response = {
10867 let bytes = common::to_bytes(body).await.unwrap_or_default();
10868 let encoded = common::to_string(&bytes);
10869 match serde_json::from_str(&encoded) {
10870 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10871 Err(error) => {
10872 dlg.response_json_decode_error(&encoded, &error);
10873 return Err(common::Error::JsonDecodeError(
10874 encoded.to_string(),
10875 error,
10876 ));
10877 }
10878 }
10879 };
10880
10881 dlg.finished(true);
10882 return Ok(response);
10883 }
10884 }
10885 }
10886 }
10887
10888 ///
10889 /// Sets the *request* property to the given value.
10890 ///
10891 /// Even though the property as already been set when instantiating this call,
10892 /// we provide this method for API completeness.
10893 pub fn request(
10894 mut self,
10895 new_value: GoogleCloudDocumentaiV1Processor,
10896 ) -> ProjectLocationProcessorCreateCall<'a, C> {
10897 self._request = new_value;
10898 self
10899 }
10900 /// Required. The parent (project and location) under which to create the processor. Format: `projects/{project}/locations/{location}`
10901 ///
10902 /// Sets the *parent* path property to the given value.
10903 ///
10904 /// Even though the property as already been set when instantiating this call,
10905 /// we provide this method for API completeness.
10906 pub fn parent(mut self, new_value: &str) -> ProjectLocationProcessorCreateCall<'a, C> {
10907 self._parent = new_value.to_string();
10908 self
10909 }
10910 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10911 /// while executing the actual API request.
10912 ///
10913 /// ````text
10914 /// It should be used to handle progress information, and to implement a certain level of resilience.
10915 /// ````
10916 ///
10917 /// Sets the *delegate* property to the given value.
10918 pub fn delegate(
10919 mut self,
10920 new_value: &'a mut dyn common::Delegate,
10921 ) -> ProjectLocationProcessorCreateCall<'a, C> {
10922 self._delegate = Some(new_value);
10923 self
10924 }
10925
10926 /// Set any additional parameter of the query string used in the request.
10927 /// It should be used to set parameters which are not yet available through their own
10928 /// setters.
10929 ///
10930 /// Please note that this method must not be used to set any of the known parameters
10931 /// which have their own setter method. If done anyway, the request will fail.
10932 ///
10933 /// # Additional Parameters
10934 ///
10935 /// * *$.xgafv* (query-string) - V1 error format.
10936 /// * *access_token* (query-string) - OAuth access token.
10937 /// * *alt* (query-string) - Data format for response.
10938 /// * *callback* (query-string) - JSONP
10939 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10940 /// * *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.
10941 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10942 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10943 /// * *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.
10944 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10945 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10946 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProcessorCreateCall<'a, C>
10947 where
10948 T: AsRef<str>,
10949 {
10950 self._additional_params
10951 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10952 self
10953 }
10954
10955 /// Identifies the authorization scope for the method you are building.
10956 ///
10957 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10958 /// [`Scope::CloudPlatform`].
10959 ///
10960 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10961 /// tokens for more than one scope.
10962 ///
10963 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10964 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10965 /// sufficient, a read-write scope will do as well.
10966 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProcessorCreateCall<'a, C>
10967 where
10968 St: AsRef<str>,
10969 {
10970 self._scopes.insert(String::from(scope.as_ref()));
10971 self
10972 }
10973 /// Identifies the authorization scope(s) for the method you are building.
10974 ///
10975 /// See [`Self::add_scope()`] for details.
10976 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProcessorCreateCall<'a, C>
10977 where
10978 I: IntoIterator<Item = St>,
10979 St: AsRef<str>,
10980 {
10981 self._scopes
10982 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10983 self
10984 }
10985
10986 /// Removes all scopes, and no default scope will be used either.
10987 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10988 /// for details).
10989 pub fn clear_scopes(mut self) -> ProjectLocationProcessorCreateCall<'a, C> {
10990 self._scopes.clear();
10991 self
10992 }
10993}
10994
10995/// Deletes the processor, unloads all deployed model artifacts if it was enabled and then deletes all artifacts associated with this processor.
10996///
10997/// A builder for the *locations.processors.delete* method supported by a *project* resource.
10998/// It is not used directly, but through a [`ProjectMethods`] instance.
10999///
11000/// # Example
11001///
11002/// Instantiate a resource method builder
11003///
11004/// ```test_harness,no_run
11005/// # extern crate hyper;
11006/// # extern crate hyper_rustls;
11007/// # extern crate google_documentai1 as documentai1;
11008/// # async fn dox() {
11009/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11010///
11011/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11012/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11013/// # .with_native_roots()
11014/// # .unwrap()
11015/// # .https_only()
11016/// # .enable_http2()
11017/// # .build();
11018///
11019/// # let executor = hyper_util::rt::TokioExecutor::new();
11020/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11021/// # secret,
11022/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11023/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11024/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11025/// # ),
11026/// # ).build().await.unwrap();
11027///
11028/// # let client = hyper_util::client::legacy::Client::builder(
11029/// # hyper_util::rt::TokioExecutor::new()
11030/// # )
11031/// # .build(
11032/// # hyper_rustls::HttpsConnectorBuilder::new()
11033/// # .with_native_roots()
11034/// # .unwrap()
11035/// # .https_or_http()
11036/// # .enable_http2()
11037/// # .build()
11038/// # );
11039/// # let mut hub = Document::new(client, auth);
11040/// // You can configure optional parameters by calling the respective setters at will, and
11041/// // execute the final call using `doit()`.
11042/// // Values shown here are possibly random and not representative !
11043/// let result = hub.projects().locations_processors_delete("name")
11044/// .doit().await;
11045/// # }
11046/// ```
11047pub struct ProjectLocationProcessorDeleteCall<'a, C>
11048where
11049 C: 'a,
11050{
11051 hub: &'a Document<C>,
11052 _name: String,
11053 _delegate: Option<&'a mut dyn common::Delegate>,
11054 _additional_params: HashMap<String, String>,
11055 _scopes: BTreeSet<String>,
11056}
11057
11058impl<'a, C> common::CallBuilder for ProjectLocationProcessorDeleteCall<'a, C> {}
11059
11060impl<'a, C> ProjectLocationProcessorDeleteCall<'a, C>
11061where
11062 C: common::Connector,
11063{
11064 /// Perform the operation you have build so far.
11065 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
11066 use std::borrow::Cow;
11067 use std::io::{Read, Seek};
11068
11069 use common::{url::Params, ToParts};
11070 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11071
11072 let mut dd = common::DefaultDelegate;
11073 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11074 dlg.begin(common::MethodInfo {
11075 id: "documentai.projects.locations.processors.delete",
11076 http_method: hyper::Method::DELETE,
11077 });
11078
11079 for &field in ["alt", "name"].iter() {
11080 if self._additional_params.contains_key(field) {
11081 dlg.finished(false);
11082 return Err(common::Error::FieldClash(field));
11083 }
11084 }
11085
11086 let mut params = Params::with_capacity(3 + self._additional_params.len());
11087 params.push("name", self._name);
11088
11089 params.extend(self._additional_params.iter());
11090
11091 params.push("alt", "json");
11092 let mut url = self.hub._base_url.clone() + "v1/{+name}";
11093 if self._scopes.is_empty() {
11094 self._scopes
11095 .insert(Scope::CloudPlatform.as_ref().to_string());
11096 }
11097
11098 #[allow(clippy::single_element_loop)]
11099 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11100 url = params.uri_replacement(url, param_name, find_this, true);
11101 }
11102 {
11103 let to_remove = ["name"];
11104 params.remove_params(&to_remove);
11105 }
11106
11107 let url = params.parse_with_url(&url);
11108
11109 loop {
11110 let token = match self
11111 .hub
11112 .auth
11113 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11114 .await
11115 {
11116 Ok(token) => token,
11117 Err(e) => match dlg.token(e) {
11118 Ok(token) => token,
11119 Err(e) => {
11120 dlg.finished(false);
11121 return Err(common::Error::MissingToken(e));
11122 }
11123 },
11124 };
11125 let mut req_result = {
11126 let client = &self.hub.client;
11127 dlg.pre_request();
11128 let mut req_builder = hyper::Request::builder()
11129 .method(hyper::Method::DELETE)
11130 .uri(url.as_str())
11131 .header(USER_AGENT, self.hub._user_agent.clone());
11132
11133 if let Some(token) = token.as_ref() {
11134 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11135 }
11136
11137 let request = req_builder
11138 .header(CONTENT_LENGTH, 0_u64)
11139 .body(common::to_body::<String>(None));
11140
11141 client.request(request.unwrap()).await
11142 };
11143
11144 match req_result {
11145 Err(err) => {
11146 if let common::Retry::After(d) = dlg.http_error(&err) {
11147 sleep(d).await;
11148 continue;
11149 }
11150 dlg.finished(false);
11151 return Err(common::Error::HttpError(err));
11152 }
11153 Ok(res) => {
11154 let (mut parts, body) = res.into_parts();
11155 let mut body = common::Body::new(body);
11156 if !parts.status.is_success() {
11157 let bytes = common::to_bytes(body).await.unwrap_or_default();
11158 let error = serde_json::from_str(&common::to_string(&bytes));
11159 let response = common::to_response(parts, bytes.into());
11160
11161 if let common::Retry::After(d) =
11162 dlg.http_failure(&response, error.as_ref().ok())
11163 {
11164 sleep(d).await;
11165 continue;
11166 }
11167
11168 dlg.finished(false);
11169
11170 return Err(match error {
11171 Ok(value) => common::Error::BadRequest(value),
11172 _ => common::Error::Failure(response),
11173 });
11174 }
11175 let response = {
11176 let bytes = common::to_bytes(body).await.unwrap_or_default();
11177 let encoded = common::to_string(&bytes);
11178 match serde_json::from_str(&encoded) {
11179 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11180 Err(error) => {
11181 dlg.response_json_decode_error(&encoded, &error);
11182 return Err(common::Error::JsonDecodeError(
11183 encoded.to_string(),
11184 error,
11185 ));
11186 }
11187 }
11188 };
11189
11190 dlg.finished(true);
11191 return Ok(response);
11192 }
11193 }
11194 }
11195 }
11196
11197 /// Required. The processor resource name to be deleted.
11198 ///
11199 /// Sets the *name* path property to the given value.
11200 ///
11201 /// Even though the property as already been set when instantiating this call,
11202 /// we provide this method for API completeness.
11203 pub fn name(mut self, new_value: &str) -> ProjectLocationProcessorDeleteCall<'a, C> {
11204 self._name = new_value.to_string();
11205 self
11206 }
11207 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11208 /// while executing the actual API request.
11209 ///
11210 /// ````text
11211 /// It should be used to handle progress information, and to implement a certain level of resilience.
11212 /// ````
11213 ///
11214 /// Sets the *delegate* property to the given value.
11215 pub fn delegate(
11216 mut self,
11217 new_value: &'a mut dyn common::Delegate,
11218 ) -> ProjectLocationProcessorDeleteCall<'a, C> {
11219 self._delegate = Some(new_value);
11220 self
11221 }
11222
11223 /// Set any additional parameter of the query string used in the request.
11224 /// It should be used to set parameters which are not yet available through their own
11225 /// setters.
11226 ///
11227 /// Please note that this method must not be used to set any of the known parameters
11228 /// which have their own setter method. If done anyway, the request will fail.
11229 ///
11230 /// # Additional Parameters
11231 ///
11232 /// * *$.xgafv* (query-string) - V1 error format.
11233 /// * *access_token* (query-string) - OAuth access token.
11234 /// * *alt* (query-string) - Data format for response.
11235 /// * *callback* (query-string) - JSONP
11236 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11237 /// * *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.
11238 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11239 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11240 /// * *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.
11241 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11242 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11243 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProcessorDeleteCall<'a, C>
11244 where
11245 T: AsRef<str>,
11246 {
11247 self._additional_params
11248 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11249 self
11250 }
11251
11252 /// Identifies the authorization scope for the method you are building.
11253 ///
11254 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11255 /// [`Scope::CloudPlatform`].
11256 ///
11257 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11258 /// tokens for more than one scope.
11259 ///
11260 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11261 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11262 /// sufficient, a read-write scope will do as well.
11263 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProcessorDeleteCall<'a, C>
11264 where
11265 St: AsRef<str>,
11266 {
11267 self._scopes.insert(String::from(scope.as_ref()));
11268 self
11269 }
11270 /// Identifies the authorization scope(s) for the method you are building.
11271 ///
11272 /// See [`Self::add_scope()`] for details.
11273 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProcessorDeleteCall<'a, C>
11274 where
11275 I: IntoIterator<Item = St>,
11276 St: AsRef<str>,
11277 {
11278 self._scopes
11279 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11280 self
11281 }
11282
11283 /// Removes all scopes, and no default scope will be used either.
11284 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11285 /// for details).
11286 pub fn clear_scopes(mut self) -> ProjectLocationProcessorDeleteCall<'a, C> {
11287 self._scopes.clear();
11288 self
11289 }
11290}
11291
11292/// Disables a processor
11293///
11294/// A builder for the *locations.processors.disable* method supported by a *project* resource.
11295/// It is not used directly, but through a [`ProjectMethods`] instance.
11296///
11297/// # Example
11298///
11299/// Instantiate a resource method builder
11300///
11301/// ```test_harness,no_run
11302/// # extern crate hyper;
11303/// # extern crate hyper_rustls;
11304/// # extern crate google_documentai1 as documentai1;
11305/// use documentai1::api::GoogleCloudDocumentaiV1DisableProcessorRequest;
11306/// # async fn dox() {
11307/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11308///
11309/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11310/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11311/// # .with_native_roots()
11312/// # .unwrap()
11313/// # .https_only()
11314/// # .enable_http2()
11315/// # .build();
11316///
11317/// # let executor = hyper_util::rt::TokioExecutor::new();
11318/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11319/// # secret,
11320/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11321/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11322/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11323/// # ),
11324/// # ).build().await.unwrap();
11325///
11326/// # let client = hyper_util::client::legacy::Client::builder(
11327/// # hyper_util::rt::TokioExecutor::new()
11328/// # )
11329/// # .build(
11330/// # hyper_rustls::HttpsConnectorBuilder::new()
11331/// # .with_native_roots()
11332/// # .unwrap()
11333/// # .https_or_http()
11334/// # .enable_http2()
11335/// # .build()
11336/// # );
11337/// # let mut hub = Document::new(client, auth);
11338/// // As the method needs a request, you would usually fill it with the desired information
11339/// // into the respective structure. Some of the parts shown here might not be applicable !
11340/// // Values shown here are possibly random and not representative !
11341/// let mut req = GoogleCloudDocumentaiV1DisableProcessorRequest::default();
11342///
11343/// // You can configure optional parameters by calling the respective setters at will, and
11344/// // execute the final call using `doit()`.
11345/// // Values shown here are possibly random and not representative !
11346/// let result = hub.projects().locations_processors_disable(req, "name")
11347/// .doit().await;
11348/// # }
11349/// ```
11350pub struct ProjectLocationProcessorDisableCall<'a, C>
11351where
11352 C: 'a,
11353{
11354 hub: &'a Document<C>,
11355 _request: GoogleCloudDocumentaiV1DisableProcessorRequest,
11356 _name: String,
11357 _delegate: Option<&'a mut dyn common::Delegate>,
11358 _additional_params: HashMap<String, String>,
11359 _scopes: BTreeSet<String>,
11360}
11361
11362impl<'a, C> common::CallBuilder for ProjectLocationProcessorDisableCall<'a, C> {}
11363
11364impl<'a, C> ProjectLocationProcessorDisableCall<'a, C>
11365where
11366 C: common::Connector,
11367{
11368 /// Perform the operation you have build so far.
11369 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
11370 use std::borrow::Cow;
11371 use std::io::{Read, Seek};
11372
11373 use common::{url::Params, ToParts};
11374 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11375
11376 let mut dd = common::DefaultDelegate;
11377 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11378 dlg.begin(common::MethodInfo {
11379 id: "documentai.projects.locations.processors.disable",
11380 http_method: hyper::Method::POST,
11381 });
11382
11383 for &field in ["alt", "name"].iter() {
11384 if self._additional_params.contains_key(field) {
11385 dlg.finished(false);
11386 return Err(common::Error::FieldClash(field));
11387 }
11388 }
11389
11390 let mut params = Params::with_capacity(4 + self._additional_params.len());
11391 params.push("name", self._name);
11392
11393 params.extend(self._additional_params.iter());
11394
11395 params.push("alt", "json");
11396 let mut url = self.hub._base_url.clone() + "v1/{+name}:disable";
11397 if self._scopes.is_empty() {
11398 self._scopes
11399 .insert(Scope::CloudPlatform.as_ref().to_string());
11400 }
11401
11402 #[allow(clippy::single_element_loop)]
11403 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11404 url = params.uri_replacement(url, param_name, find_this, true);
11405 }
11406 {
11407 let to_remove = ["name"];
11408 params.remove_params(&to_remove);
11409 }
11410
11411 let url = params.parse_with_url(&url);
11412
11413 let mut json_mime_type = mime::APPLICATION_JSON;
11414 let mut request_value_reader = {
11415 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11416 common::remove_json_null_values(&mut value);
11417 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11418 serde_json::to_writer(&mut dst, &value).unwrap();
11419 dst
11420 };
11421 let request_size = request_value_reader
11422 .seek(std::io::SeekFrom::End(0))
11423 .unwrap();
11424 request_value_reader
11425 .seek(std::io::SeekFrom::Start(0))
11426 .unwrap();
11427
11428 loop {
11429 let token = match self
11430 .hub
11431 .auth
11432 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11433 .await
11434 {
11435 Ok(token) => token,
11436 Err(e) => match dlg.token(e) {
11437 Ok(token) => token,
11438 Err(e) => {
11439 dlg.finished(false);
11440 return Err(common::Error::MissingToken(e));
11441 }
11442 },
11443 };
11444 request_value_reader
11445 .seek(std::io::SeekFrom::Start(0))
11446 .unwrap();
11447 let mut req_result = {
11448 let client = &self.hub.client;
11449 dlg.pre_request();
11450 let mut req_builder = hyper::Request::builder()
11451 .method(hyper::Method::POST)
11452 .uri(url.as_str())
11453 .header(USER_AGENT, self.hub._user_agent.clone());
11454
11455 if let Some(token) = token.as_ref() {
11456 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11457 }
11458
11459 let request = req_builder
11460 .header(CONTENT_TYPE, json_mime_type.to_string())
11461 .header(CONTENT_LENGTH, request_size as u64)
11462 .body(common::to_body(
11463 request_value_reader.get_ref().clone().into(),
11464 ));
11465
11466 client.request(request.unwrap()).await
11467 };
11468
11469 match req_result {
11470 Err(err) => {
11471 if let common::Retry::After(d) = dlg.http_error(&err) {
11472 sleep(d).await;
11473 continue;
11474 }
11475 dlg.finished(false);
11476 return Err(common::Error::HttpError(err));
11477 }
11478 Ok(res) => {
11479 let (mut parts, body) = res.into_parts();
11480 let mut body = common::Body::new(body);
11481 if !parts.status.is_success() {
11482 let bytes = common::to_bytes(body).await.unwrap_or_default();
11483 let error = serde_json::from_str(&common::to_string(&bytes));
11484 let response = common::to_response(parts, bytes.into());
11485
11486 if let common::Retry::After(d) =
11487 dlg.http_failure(&response, error.as_ref().ok())
11488 {
11489 sleep(d).await;
11490 continue;
11491 }
11492
11493 dlg.finished(false);
11494
11495 return Err(match error {
11496 Ok(value) => common::Error::BadRequest(value),
11497 _ => common::Error::Failure(response),
11498 });
11499 }
11500 let response = {
11501 let bytes = common::to_bytes(body).await.unwrap_or_default();
11502 let encoded = common::to_string(&bytes);
11503 match serde_json::from_str(&encoded) {
11504 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11505 Err(error) => {
11506 dlg.response_json_decode_error(&encoded, &error);
11507 return Err(common::Error::JsonDecodeError(
11508 encoded.to_string(),
11509 error,
11510 ));
11511 }
11512 }
11513 };
11514
11515 dlg.finished(true);
11516 return Ok(response);
11517 }
11518 }
11519 }
11520 }
11521
11522 ///
11523 /// Sets the *request* property to the given value.
11524 ///
11525 /// Even though the property as already been set when instantiating this call,
11526 /// we provide this method for API completeness.
11527 pub fn request(
11528 mut self,
11529 new_value: GoogleCloudDocumentaiV1DisableProcessorRequest,
11530 ) -> ProjectLocationProcessorDisableCall<'a, C> {
11531 self._request = new_value;
11532 self
11533 }
11534 /// Required. The processor resource name to be disabled.
11535 ///
11536 /// Sets the *name* path property to the given value.
11537 ///
11538 /// Even though the property as already been set when instantiating this call,
11539 /// we provide this method for API completeness.
11540 pub fn name(mut self, new_value: &str) -> ProjectLocationProcessorDisableCall<'a, C> {
11541 self._name = new_value.to_string();
11542 self
11543 }
11544 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11545 /// while executing the actual API request.
11546 ///
11547 /// ````text
11548 /// It should be used to handle progress information, and to implement a certain level of resilience.
11549 /// ````
11550 ///
11551 /// Sets the *delegate* property to the given value.
11552 pub fn delegate(
11553 mut self,
11554 new_value: &'a mut dyn common::Delegate,
11555 ) -> ProjectLocationProcessorDisableCall<'a, C> {
11556 self._delegate = Some(new_value);
11557 self
11558 }
11559
11560 /// Set any additional parameter of the query string used in the request.
11561 /// It should be used to set parameters which are not yet available through their own
11562 /// setters.
11563 ///
11564 /// Please note that this method must not be used to set any of the known parameters
11565 /// which have their own setter method. If done anyway, the request will fail.
11566 ///
11567 /// # Additional Parameters
11568 ///
11569 /// * *$.xgafv* (query-string) - V1 error format.
11570 /// * *access_token* (query-string) - OAuth access token.
11571 /// * *alt* (query-string) - Data format for response.
11572 /// * *callback* (query-string) - JSONP
11573 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11574 /// * *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.
11575 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11576 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11577 /// * *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.
11578 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11579 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11580 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProcessorDisableCall<'a, C>
11581 where
11582 T: AsRef<str>,
11583 {
11584 self._additional_params
11585 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11586 self
11587 }
11588
11589 /// Identifies the authorization scope for the method you are building.
11590 ///
11591 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11592 /// [`Scope::CloudPlatform`].
11593 ///
11594 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11595 /// tokens for more than one scope.
11596 ///
11597 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11598 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11599 /// sufficient, a read-write scope will do as well.
11600 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProcessorDisableCall<'a, C>
11601 where
11602 St: AsRef<str>,
11603 {
11604 self._scopes.insert(String::from(scope.as_ref()));
11605 self
11606 }
11607 /// Identifies the authorization scope(s) for the method you are building.
11608 ///
11609 /// See [`Self::add_scope()`] for details.
11610 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProcessorDisableCall<'a, C>
11611 where
11612 I: IntoIterator<Item = St>,
11613 St: AsRef<str>,
11614 {
11615 self._scopes
11616 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11617 self
11618 }
11619
11620 /// Removes all scopes, and no default scope will be used either.
11621 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11622 /// for details).
11623 pub fn clear_scopes(mut self) -> ProjectLocationProcessorDisableCall<'a, C> {
11624 self._scopes.clear();
11625 self
11626 }
11627}
11628
11629/// Enables a processor
11630///
11631/// A builder for the *locations.processors.enable* method supported by a *project* resource.
11632/// It is not used directly, but through a [`ProjectMethods`] instance.
11633///
11634/// # Example
11635///
11636/// Instantiate a resource method builder
11637///
11638/// ```test_harness,no_run
11639/// # extern crate hyper;
11640/// # extern crate hyper_rustls;
11641/// # extern crate google_documentai1 as documentai1;
11642/// use documentai1::api::GoogleCloudDocumentaiV1EnableProcessorRequest;
11643/// # async fn dox() {
11644/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11645///
11646/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11647/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11648/// # .with_native_roots()
11649/// # .unwrap()
11650/// # .https_only()
11651/// # .enable_http2()
11652/// # .build();
11653///
11654/// # let executor = hyper_util::rt::TokioExecutor::new();
11655/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11656/// # secret,
11657/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11658/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11659/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11660/// # ),
11661/// # ).build().await.unwrap();
11662///
11663/// # let client = hyper_util::client::legacy::Client::builder(
11664/// # hyper_util::rt::TokioExecutor::new()
11665/// # )
11666/// # .build(
11667/// # hyper_rustls::HttpsConnectorBuilder::new()
11668/// # .with_native_roots()
11669/// # .unwrap()
11670/// # .https_or_http()
11671/// # .enable_http2()
11672/// # .build()
11673/// # );
11674/// # let mut hub = Document::new(client, auth);
11675/// // As the method needs a request, you would usually fill it with the desired information
11676/// // into the respective structure. Some of the parts shown here might not be applicable !
11677/// // Values shown here are possibly random and not representative !
11678/// let mut req = GoogleCloudDocumentaiV1EnableProcessorRequest::default();
11679///
11680/// // You can configure optional parameters by calling the respective setters at will, and
11681/// // execute the final call using `doit()`.
11682/// // Values shown here are possibly random and not representative !
11683/// let result = hub.projects().locations_processors_enable(req, "name")
11684/// .doit().await;
11685/// # }
11686/// ```
11687pub struct ProjectLocationProcessorEnableCall<'a, C>
11688where
11689 C: 'a,
11690{
11691 hub: &'a Document<C>,
11692 _request: GoogleCloudDocumentaiV1EnableProcessorRequest,
11693 _name: String,
11694 _delegate: Option<&'a mut dyn common::Delegate>,
11695 _additional_params: HashMap<String, String>,
11696 _scopes: BTreeSet<String>,
11697}
11698
11699impl<'a, C> common::CallBuilder for ProjectLocationProcessorEnableCall<'a, C> {}
11700
11701impl<'a, C> ProjectLocationProcessorEnableCall<'a, C>
11702where
11703 C: common::Connector,
11704{
11705 /// Perform the operation you have build so far.
11706 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
11707 use std::borrow::Cow;
11708 use std::io::{Read, Seek};
11709
11710 use common::{url::Params, ToParts};
11711 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11712
11713 let mut dd = common::DefaultDelegate;
11714 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11715 dlg.begin(common::MethodInfo {
11716 id: "documentai.projects.locations.processors.enable",
11717 http_method: hyper::Method::POST,
11718 });
11719
11720 for &field in ["alt", "name"].iter() {
11721 if self._additional_params.contains_key(field) {
11722 dlg.finished(false);
11723 return Err(common::Error::FieldClash(field));
11724 }
11725 }
11726
11727 let mut params = Params::with_capacity(4 + self._additional_params.len());
11728 params.push("name", self._name);
11729
11730 params.extend(self._additional_params.iter());
11731
11732 params.push("alt", "json");
11733 let mut url = self.hub._base_url.clone() + "v1/{+name}:enable";
11734 if self._scopes.is_empty() {
11735 self._scopes
11736 .insert(Scope::CloudPlatform.as_ref().to_string());
11737 }
11738
11739 #[allow(clippy::single_element_loop)]
11740 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11741 url = params.uri_replacement(url, param_name, find_this, true);
11742 }
11743 {
11744 let to_remove = ["name"];
11745 params.remove_params(&to_remove);
11746 }
11747
11748 let url = params.parse_with_url(&url);
11749
11750 let mut json_mime_type = mime::APPLICATION_JSON;
11751 let mut request_value_reader = {
11752 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11753 common::remove_json_null_values(&mut value);
11754 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11755 serde_json::to_writer(&mut dst, &value).unwrap();
11756 dst
11757 };
11758 let request_size = request_value_reader
11759 .seek(std::io::SeekFrom::End(0))
11760 .unwrap();
11761 request_value_reader
11762 .seek(std::io::SeekFrom::Start(0))
11763 .unwrap();
11764
11765 loop {
11766 let token = match self
11767 .hub
11768 .auth
11769 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11770 .await
11771 {
11772 Ok(token) => token,
11773 Err(e) => match dlg.token(e) {
11774 Ok(token) => token,
11775 Err(e) => {
11776 dlg.finished(false);
11777 return Err(common::Error::MissingToken(e));
11778 }
11779 },
11780 };
11781 request_value_reader
11782 .seek(std::io::SeekFrom::Start(0))
11783 .unwrap();
11784 let mut req_result = {
11785 let client = &self.hub.client;
11786 dlg.pre_request();
11787 let mut req_builder = hyper::Request::builder()
11788 .method(hyper::Method::POST)
11789 .uri(url.as_str())
11790 .header(USER_AGENT, self.hub._user_agent.clone());
11791
11792 if let Some(token) = token.as_ref() {
11793 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11794 }
11795
11796 let request = req_builder
11797 .header(CONTENT_TYPE, json_mime_type.to_string())
11798 .header(CONTENT_LENGTH, request_size as u64)
11799 .body(common::to_body(
11800 request_value_reader.get_ref().clone().into(),
11801 ));
11802
11803 client.request(request.unwrap()).await
11804 };
11805
11806 match req_result {
11807 Err(err) => {
11808 if let common::Retry::After(d) = dlg.http_error(&err) {
11809 sleep(d).await;
11810 continue;
11811 }
11812 dlg.finished(false);
11813 return Err(common::Error::HttpError(err));
11814 }
11815 Ok(res) => {
11816 let (mut parts, body) = res.into_parts();
11817 let mut body = common::Body::new(body);
11818 if !parts.status.is_success() {
11819 let bytes = common::to_bytes(body).await.unwrap_or_default();
11820 let error = serde_json::from_str(&common::to_string(&bytes));
11821 let response = common::to_response(parts, bytes.into());
11822
11823 if let common::Retry::After(d) =
11824 dlg.http_failure(&response, error.as_ref().ok())
11825 {
11826 sleep(d).await;
11827 continue;
11828 }
11829
11830 dlg.finished(false);
11831
11832 return Err(match error {
11833 Ok(value) => common::Error::BadRequest(value),
11834 _ => common::Error::Failure(response),
11835 });
11836 }
11837 let response = {
11838 let bytes = common::to_bytes(body).await.unwrap_or_default();
11839 let encoded = common::to_string(&bytes);
11840 match serde_json::from_str(&encoded) {
11841 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11842 Err(error) => {
11843 dlg.response_json_decode_error(&encoded, &error);
11844 return Err(common::Error::JsonDecodeError(
11845 encoded.to_string(),
11846 error,
11847 ));
11848 }
11849 }
11850 };
11851
11852 dlg.finished(true);
11853 return Ok(response);
11854 }
11855 }
11856 }
11857 }
11858
11859 ///
11860 /// Sets the *request* property to the given value.
11861 ///
11862 /// Even though the property as already been set when instantiating this call,
11863 /// we provide this method for API completeness.
11864 pub fn request(
11865 mut self,
11866 new_value: GoogleCloudDocumentaiV1EnableProcessorRequest,
11867 ) -> ProjectLocationProcessorEnableCall<'a, C> {
11868 self._request = new_value;
11869 self
11870 }
11871 /// Required. The processor resource name to be enabled.
11872 ///
11873 /// Sets the *name* path property to the given value.
11874 ///
11875 /// Even though the property as already been set when instantiating this call,
11876 /// we provide this method for API completeness.
11877 pub fn name(mut self, new_value: &str) -> ProjectLocationProcessorEnableCall<'a, C> {
11878 self._name = new_value.to_string();
11879 self
11880 }
11881 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11882 /// while executing the actual API request.
11883 ///
11884 /// ````text
11885 /// It should be used to handle progress information, and to implement a certain level of resilience.
11886 /// ````
11887 ///
11888 /// Sets the *delegate* property to the given value.
11889 pub fn delegate(
11890 mut self,
11891 new_value: &'a mut dyn common::Delegate,
11892 ) -> ProjectLocationProcessorEnableCall<'a, C> {
11893 self._delegate = Some(new_value);
11894 self
11895 }
11896
11897 /// Set any additional parameter of the query string used in the request.
11898 /// It should be used to set parameters which are not yet available through their own
11899 /// setters.
11900 ///
11901 /// Please note that this method must not be used to set any of the known parameters
11902 /// which have their own setter method. If done anyway, the request will fail.
11903 ///
11904 /// # Additional Parameters
11905 ///
11906 /// * *$.xgafv* (query-string) - V1 error format.
11907 /// * *access_token* (query-string) - OAuth access token.
11908 /// * *alt* (query-string) - Data format for response.
11909 /// * *callback* (query-string) - JSONP
11910 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11911 /// * *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.
11912 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11913 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11914 /// * *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.
11915 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11916 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11917 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProcessorEnableCall<'a, C>
11918 where
11919 T: AsRef<str>,
11920 {
11921 self._additional_params
11922 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11923 self
11924 }
11925
11926 /// Identifies the authorization scope for the method you are building.
11927 ///
11928 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11929 /// [`Scope::CloudPlatform`].
11930 ///
11931 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11932 /// tokens for more than one scope.
11933 ///
11934 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11935 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11936 /// sufficient, a read-write scope will do as well.
11937 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProcessorEnableCall<'a, C>
11938 where
11939 St: AsRef<str>,
11940 {
11941 self._scopes.insert(String::from(scope.as_ref()));
11942 self
11943 }
11944 /// Identifies the authorization scope(s) for the method you are building.
11945 ///
11946 /// See [`Self::add_scope()`] for details.
11947 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProcessorEnableCall<'a, C>
11948 where
11949 I: IntoIterator<Item = St>,
11950 St: AsRef<str>,
11951 {
11952 self._scopes
11953 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11954 self
11955 }
11956
11957 /// Removes all scopes, and no default scope will be used either.
11958 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11959 /// for details).
11960 pub fn clear_scopes(mut self) -> ProjectLocationProcessorEnableCall<'a, C> {
11961 self._scopes.clear();
11962 self
11963 }
11964}
11965
11966/// Gets a processor detail.
11967///
11968/// A builder for the *locations.processors.get* method supported by a *project* resource.
11969/// It is not used directly, but through a [`ProjectMethods`] instance.
11970///
11971/// # Example
11972///
11973/// Instantiate a resource method builder
11974///
11975/// ```test_harness,no_run
11976/// # extern crate hyper;
11977/// # extern crate hyper_rustls;
11978/// # extern crate google_documentai1 as documentai1;
11979/// # async fn dox() {
11980/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11981///
11982/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11983/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11984/// # .with_native_roots()
11985/// # .unwrap()
11986/// # .https_only()
11987/// # .enable_http2()
11988/// # .build();
11989///
11990/// # let executor = hyper_util::rt::TokioExecutor::new();
11991/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11992/// # secret,
11993/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11994/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11995/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11996/// # ),
11997/// # ).build().await.unwrap();
11998///
11999/// # let client = hyper_util::client::legacy::Client::builder(
12000/// # hyper_util::rt::TokioExecutor::new()
12001/// # )
12002/// # .build(
12003/// # hyper_rustls::HttpsConnectorBuilder::new()
12004/// # .with_native_roots()
12005/// # .unwrap()
12006/// # .https_or_http()
12007/// # .enable_http2()
12008/// # .build()
12009/// # );
12010/// # let mut hub = Document::new(client, auth);
12011/// // You can configure optional parameters by calling the respective setters at will, and
12012/// // execute the final call using `doit()`.
12013/// // Values shown here are possibly random and not representative !
12014/// let result = hub.projects().locations_processors_get("name")
12015/// .doit().await;
12016/// # }
12017/// ```
12018pub struct ProjectLocationProcessorGetCall<'a, C>
12019where
12020 C: 'a,
12021{
12022 hub: &'a Document<C>,
12023 _name: String,
12024 _delegate: Option<&'a mut dyn common::Delegate>,
12025 _additional_params: HashMap<String, String>,
12026 _scopes: BTreeSet<String>,
12027}
12028
12029impl<'a, C> common::CallBuilder for ProjectLocationProcessorGetCall<'a, C> {}
12030
12031impl<'a, C> ProjectLocationProcessorGetCall<'a, C>
12032where
12033 C: common::Connector,
12034{
12035 /// Perform the operation you have build so far.
12036 pub async fn doit(
12037 mut self,
12038 ) -> common::Result<(common::Response, GoogleCloudDocumentaiV1Processor)> {
12039 use std::borrow::Cow;
12040 use std::io::{Read, Seek};
12041
12042 use common::{url::Params, ToParts};
12043 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12044
12045 let mut dd = common::DefaultDelegate;
12046 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12047 dlg.begin(common::MethodInfo {
12048 id: "documentai.projects.locations.processors.get",
12049 http_method: hyper::Method::GET,
12050 });
12051
12052 for &field in ["alt", "name"].iter() {
12053 if self._additional_params.contains_key(field) {
12054 dlg.finished(false);
12055 return Err(common::Error::FieldClash(field));
12056 }
12057 }
12058
12059 let mut params = Params::with_capacity(3 + self._additional_params.len());
12060 params.push("name", self._name);
12061
12062 params.extend(self._additional_params.iter());
12063
12064 params.push("alt", "json");
12065 let mut url = self.hub._base_url.clone() + "v1/{+name}";
12066 if self._scopes.is_empty() {
12067 self._scopes
12068 .insert(Scope::CloudPlatform.as_ref().to_string());
12069 }
12070
12071 #[allow(clippy::single_element_loop)]
12072 for &(find_this, param_name) in [("{+name}", "name")].iter() {
12073 url = params.uri_replacement(url, param_name, find_this, true);
12074 }
12075 {
12076 let to_remove = ["name"];
12077 params.remove_params(&to_remove);
12078 }
12079
12080 let url = params.parse_with_url(&url);
12081
12082 loop {
12083 let token = match self
12084 .hub
12085 .auth
12086 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12087 .await
12088 {
12089 Ok(token) => token,
12090 Err(e) => match dlg.token(e) {
12091 Ok(token) => token,
12092 Err(e) => {
12093 dlg.finished(false);
12094 return Err(common::Error::MissingToken(e));
12095 }
12096 },
12097 };
12098 let mut req_result = {
12099 let client = &self.hub.client;
12100 dlg.pre_request();
12101 let mut req_builder = hyper::Request::builder()
12102 .method(hyper::Method::GET)
12103 .uri(url.as_str())
12104 .header(USER_AGENT, self.hub._user_agent.clone());
12105
12106 if let Some(token) = token.as_ref() {
12107 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12108 }
12109
12110 let request = req_builder
12111 .header(CONTENT_LENGTH, 0_u64)
12112 .body(common::to_body::<String>(None));
12113
12114 client.request(request.unwrap()).await
12115 };
12116
12117 match req_result {
12118 Err(err) => {
12119 if let common::Retry::After(d) = dlg.http_error(&err) {
12120 sleep(d).await;
12121 continue;
12122 }
12123 dlg.finished(false);
12124 return Err(common::Error::HttpError(err));
12125 }
12126 Ok(res) => {
12127 let (mut parts, body) = res.into_parts();
12128 let mut body = common::Body::new(body);
12129 if !parts.status.is_success() {
12130 let bytes = common::to_bytes(body).await.unwrap_or_default();
12131 let error = serde_json::from_str(&common::to_string(&bytes));
12132 let response = common::to_response(parts, bytes.into());
12133
12134 if let common::Retry::After(d) =
12135 dlg.http_failure(&response, error.as_ref().ok())
12136 {
12137 sleep(d).await;
12138 continue;
12139 }
12140
12141 dlg.finished(false);
12142
12143 return Err(match error {
12144 Ok(value) => common::Error::BadRequest(value),
12145 _ => common::Error::Failure(response),
12146 });
12147 }
12148 let response = {
12149 let bytes = common::to_bytes(body).await.unwrap_or_default();
12150 let encoded = common::to_string(&bytes);
12151 match serde_json::from_str(&encoded) {
12152 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12153 Err(error) => {
12154 dlg.response_json_decode_error(&encoded, &error);
12155 return Err(common::Error::JsonDecodeError(
12156 encoded.to_string(),
12157 error,
12158 ));
12159 }
12160 }
12161 };
12162
12163 dlg.finished(true);
12164 return Ok(response);
12165 }
12166 }
12167 }
12168 }
12169
12170 /// Required. The processor resource name.
12171 ///
12172 /// Sets the *name* path property to the given value.
12173 ///
12174 /// Even though the property as already been set when instantiating this call,
12175 /// we provide this method for API completeness.
12176 pub fn name(mut self, new_value: &str) -> ProjectLocationProcessorGetCall<'a, C> {
12177 self._name = new_value.to_string();
12178 self
12179 }
12180 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12181 /// while executing the actual API request.
12182 ///
12183 /// ````text
12184 /// It should be used to handle progress information, and to implement a certain level of resilience.
12185 /// ````
12186 ///
12187 /// Sets the *delegate* property to the given value.
12188 pub fn delegate(
12189 mut self,
12190 new_value: &'a mut dyn common::Delegate,
12191 ) -> ProjectLocationProcessorGetCall<'a, C> {
12192 self._delegate = Some(new_value);
12193 self
12194 }
12195
12196 /// Set any additional parameter of the query string used in the request.
12197 /// It should be used to set parameters which are not yet available through their own
12198 /// setters.
12199 ///
12200 /// Please note that this method must not be used to set any of the known parameters
12201 /// which have their own setter method. If done anyway, the request will fail.
12202 ///
12203 /// # Additional Parameters
12204 ///
12205 /// * *$.xgafv* (query-string) - V1 error format.
12206 /// * *access_token* (query-string) - OAuth access token.
12207 /// * *alt* (query-string) - Data format for response.
12208 /// * *callback* (query-string) - JSONP
12209 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12210 /// * *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.
12211 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12212 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12213 /// * *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.
12214 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12215 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12216 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProcessorGetCall<'a, C>
12217 where
12218 T: AsRef<str>,
12219 {
12220 self._additional_params
12221 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12222 self
12223 }
12224
12225 /// Identifies the authorization scope for the method you are building.
12226 ///
12227 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12228 /// [`Scope::CloudPlatform`].
12229 ///
12230 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12231 /// tokens for more than one scope.
12232 ///
12233 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12234 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12235 /// sufficient, a read-write scope will do as well.
12236 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProcessorGetCall<'a, C>
12237 where
12238 St: AsRef<str>,
12239 {
12240 self._scopes.insert(String::from(scope.as_ref()));
12241 self
12242 }
12243 /// Identifies the authorization scope(s) for the method you are building.
12244 ///
12245 /// See [`Self::add_scope()`] for details.
12246 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProcessorGetCall<'a, C>
12247 where
12248 I: IntoIterator<Item = St>,
12249 St: AsRef<str>,
12250 {
12251 self._scopes
12252 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12253 self
12254 }
12255
12256 /// Removes all scopes, and no default scope will be used either.
12257 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12258 /// for details).
12259 pub fn clear_scopes(mut self) -> ProjectLocationProcessorGetCall<'a, C> {
12260 self._scopes.clear();
12261 self
12262 }
12263}
12264
12265/// Lists all processors which belong to this project.
12266///
12267/// A builder for the *locations.processors.list* method supported by a *project* resource.
12268/// It is not used directly, but through a [`ProjectMethods`] instance.
12269///
12270/// # Example
12271///
12272/// Instantiate a resource method builder
12273///
12274/// ```test_harness,no_run
12275/// # extern crate hyper;
12276/// # extern crate hyper_rustls;
12277/// # extern crate google_documentai1 as documentai1;
12278/// # async fn dox() {
12279/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12280///
12281/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12282/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12283/// # .with_native_roots()
12284/// # .unwrap()
12285/// # .https_only()
12286/// # .enable_http2()
12287/// # .build();
12288///
12289/// # let executor = hyper_util::rt::TokioExecutor::new();
12290/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12291/// # secret,
12292/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12293/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12294/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12295/// # ),
12296/// # ).build().await.unwrap();
12297///
12298/// # let client = hyper_util::client::legacy::Client::builder(
12299/// # hyper_util::rt::TokioExecutor::new()
12300/// # )
12301/// # .build(
12302/// # hyper_rustls::HttpsConnectorBuilder::new()
12303/// # .with_native_roots()
12304/// # .unwrap()
12305/// # .https_or_http()
12306/// # .enable_http2()
12307/// # .build()
12308/// # );
12309/// # let mut hub = Document::new(client, auth);
12310/// // You can configure optional parameters by calling the respective setters at will, and
12311/// // execute the final call using `doit()`.
12312/// // Values shown here are possibly random and not representative !
12313/// let result = hub.projects().locations_processors_list("parent")
12314/// .page_token("sed")
12315/// .page_size(-70)
12316/// .doit().await;
12317/// # }
12318/// ```
12319pub struct ProjectLocationProcessorListCall<'a, C>
12320where
12321 C: 'a,
12322{
12323 hub: &'a Document<C>,
12324 _parent: String,
12325 _page_token: Option<String>,
12326 _page_size: Option<i32>,
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 ProjectLocationProcessorListCall<'a, C> {}
12333
12334impl<'a, C> ProjectLocationProcessorListCall<'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 GoogleCloudDocumentaiV1ListProcessorsResponse,
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.processors.list",
12355 http_method: hyper::Method::GET,
12356 });
12357
12358 for &field in ["alt", "parent", "pageToken", "pageSize"].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(5 + self._additional_params.len());
12366 params.push("parent", self._parent);
12367 if let Some(value) = self._page_token.as_ref() {
12368 params.push("pageToken", value);
12369 }
12370 if let Some(value) = self._page_size.as_ref() {
12371 params.push("pageSize", value.to_string());
12372 }
12373
12374 params.extend(self._additional_params.iter());
12375
12376 params.push("alt", "json");
12377 let mut url = self.hub._base_url.clone() + "v1/{+parent}/processors";
12378 if self._scopes.is_empty() {
12379 self._scopes
12380 .insert(Scope::CloudPlatform.as_ref().to_string());
12381 }
12382
12383 #[allow(clippy::single_element_loop)]
12384 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
12385 url = params.uri_replacement(url, param_name, find_this, true);
12386 }
12387 {
12388 let to_remove = ["parent"];
12389 params.remove_params(&to_remove);
12390 }
12391
12392 let url = params.parse_with_url(&url);
12393
12394 loop {
12395 let token = match self
12396 .hub
12397 .auth
12398 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12399 .await
12400 {
12401 Ok(token) => token,
12402 Err(e) => match dlg.token(e) {
12403 Ok(token) => token,
12404 Err(e) => {
12405 dlg.finished(false);
12406 return Err(common::Error::MissingToken(e));
12407 }
12408 },
12409 };
12410 let mut req_result = {
12411 let client = &self.hub.client;
12412 dlg.pre_request();
12413 let mut req_builder = hyper::Request::builder()
12414 .method(hyper::Method::GET)
12415 .uri(url.as_str())
12416 .header(USER_AGENT, self.hub._user_agent.clone());
12417
12418 if let Some(token) = token.as_ref() {
12419 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12420 }
12421
12422 let request = req_builder
12423 .header(CONTENT_LENGTH, 0_u64)
12424 .body(common::to_body::<String>(None));
12425
12426 client.request(request.unwrap()).await
12427 };
12428
12429 match req_result {
12430 Err(err) => {
12431 if let common::Retry::After(d) = dlg.http_error(&err) {
12432 sleep(d).await;
12433 continue;
12434 }
12435 dlg.finished(false);
12436 return Err(common::Error::HttpError(err));
12437 }
12438 Ok(res) => {
12439 let (mut parts, body) = res.into_parts();
12440 let mut body = common::Body::new(body);
12441 if !parts.status.is_success() {
12442 let bytes = common::to_bytes(body).await.unwrap_or_default();
12443 let error = serde_json::from_str(&common::to_string(&bytes));
12444 let response = common::to_response(parts, bytes.into());
12445
12446 if let common::Retry::After(d) =
12447 dlg.http_failure(&response, error.as_ref().ok())
12448 {
12449 sleep(d).await;
12450 continue;
12451 }
12452
12453 dlg.finished(false);
12454
12455 return Err(match error {
12456 Ok(value) => common::Error::BadRequest(value),
12457 _ => common::Error::Failure(response),
12458 });
12459 }
12460 let response = {
12461 let bytes = common::to_bytes(body).await.unwrap_or_default();
12462 let encoded = common::to_string(&bytes);
12463 match serde_json::from_str(&encoded) {
12464 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12465 Err(error) => {
12466 dlg.response_json_decode_error(&encoded, &error);
12467 return Err(common::Error::JsonDecodeError(
12468 encoded.to_string(),
12469 error,
12470 ));
12471 }
12472 }
12473 };
12474
12475 dlg.finished(true);
12476 return Ok(response);
12477 }
12478 }
12479 }
12480 }
12481
12482 /// Required. The parent (project and location) which owns this collection of Processors. Format: `projects/{project}/locations/{location}`
12483 ///
12484 /// Sets the *parent* path property to the given value.
12485 ///
12486 /// Even though the property as already been set when instantiating this call,
12487 /// we provide this method for API completeness.
12488 pub fn parent(mut self, new_value: &str) -> ProjectLocationProcessorListCall<'a, C> {
12489 self._parent = new_value.to_string();
12490 self
12491 }
12492 /// We will return the processors sorted by creation time. The page token will point to the next processor.
12493 ///
12494 /// Sets the *page token* query property to the given value.
12495 pub fn page_token(mut self, new_value: &str) -> ProjectLocationProcessorListCall<'a, C> {
12496 self._page_token = Some(new_value.to_string());
12497 self
12498 }
12499 /// 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`.
12500 ///
12501 /// Sets the *page size* query property to the given value.
12502 pub fn page_size(mut self, new_value: i32) -> ProjectLocationProcessorListCall<'a, C> {
12503 self._page_size = Some(new_value);
12504 self
12505 }
12506 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12507 /// while executing the actual API request.
12508 ///
12509 /// ````text
12510 /// It should be used to handle progress information, and to implement a certain level of resilience.
12511 /// ````
12512 ///
12513 /// Sets the *delegate* property to the given value.
12514 pub fn delegate(
12515 mut self,
12516 new_value: &'a mut dyn common::Delegate,
12517 ) -> ProjectLocationProcessorListCall<'a, C> {
12518 self._delegate = Some(new_value);
12519 self
12520 }
12521
12522 /// Set any additional parameter of the query string used in the request.
12523 /// It should be used to set parameters which are not yet available through their own
12524 /// setters.
12525 ///
12526 /// Please note that this method must not be used to set any of the known parameters
12527 /// which have their own setter method. If done anyway, the request will fail.
12528 ///
12529 /// # Additional Parameters
12530 ///
12531 /// * *$.xgafv* (query-string) - V1 error format.
12532 /// * *access_token* (query-string) - OAuth access token.
12533 /// * *alt* (query-string) - Data format for response.
12534 /// * *callback* (query-string) - JSONP
12535 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12536 /// * *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.
12537 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12538 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12539 /// * *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.
12540 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12541 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12542 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProcessorListCall<'a, C>
12543 where
12544 T: AsRef<str>,
12545 {
12546 self._additional_params
12547 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12548 self
12549 }
12550
12551 /// Identifies the authorization scope for the method you are building.
12552 ///
12553 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12554 /// [`Scope::CloudPlatform`].
12555 ///
12556 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12557 /// tokens for more than one scope.
12558 ///
12559 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12560 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12561 /// sufficient, a read-write scope will do as well.
12562 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProcessorListCall<'a, C>
12563 where
12564 St: AsRef<str>,
12565 {
12566 self._scopes.insert(String::from(scope.as_ref()));
12567 self
12568 }
12569 /// Identifies the authorization scope(s) for the method you are building.
12570 ///
12571 /// See [`Self::add_scope()`] for details.
12572 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProcessorListCall<'a, C>
12573 where
12574 I: IntoIterator<Item = St>,
12575 St: AsRef<str>,
12576 {
12577 self._scopes
12578 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12579 self
12580 }
12581
12582 /// Removes all scopes, and no default scope will be used either.
12583 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12584 /// for details).
12585 pub fn clear_scopes(mut self) -> ProjectLocationProcessorListCall<'a, C> {
12586 self._scopes.clear();
12587 self
12588 }
12589}
12590
12591/// Processes a single document.
12592///
12593/// A builder for the *locations.processors.process* method supported by a *project* resource.
12594/// It is not used directly, but through a [`ProjectMethods`] instance.
12595///
12596/// # Example
12597///
12598/// Instantiate a resource method builder
12599///
12600/// ```test_harness,no_run
12601/// # extern crate hyper;
12602/// # extern crate hyper_rustls;
12603/// # extern crate google_documentai1 as documentai1;
12604/// use documentai1::api::GoogleCloudDocumentaiV1ProcessRequest;
12605/// # async fn dox() {
12606/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12607///
12608/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12609/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12610/// # .with_native_roots()
12611/// # .unwrap()
12612/// # .https_only()
12613/// # .enable_http2()
12614/// # .build();
12615///
12616/// # let executor = hyper_util::rt::TokioExecutor::new();
12617/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12618/// # secret,
12619/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12620/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12621/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12622/// # ),
12623/// # ).build().await.unwrap();
12624///
12625/// # let client = hyper_util::client::legacy::Client::builder(
12626/// # hyper_util::rt::TokioExecutor::new()
12627/// # )
12628/// # .build(
12629/// # hyper_rustls::HttpsConnectorBuilder::new()
12630/// # .with_native_roots()
12631/// # .unwrap()
12632/// # .https_or_http()
12633/// # .enable_http2()
12634/// # .build()
12635/// # );
12636/// # let mut hub = Document::new(client, auth);
12637/// // As the method needs a request, you would usually fill it with the desired information
12638/// // into the respective structure. Some of the parts shown here might not be applicable !
12639/// // Values shown here are possibly random and not representative !
12640/// let mut req = GoogleCloudDocumentaiV1ProcessRequest::default();
12641///
12642/// // You can configure optional parameters by calling the respective setters at will, and
12643/// // execute the final call using `doit()`.
12644/// // Values shown here are possibly random and not representative !
12645/// let result = hub.projects().locations_processors_process(req, "name")
12646/// .doit().await;
12647/// # }
12648/// ```
12649pub struct ProjectLocationProcessorProcesCall<'a, C>
12650where
12651 C: 'a,
12652{
12653 hub: &'a Document<C>,
12654 _request: GoogleCloudDocumentaiV1ProcessRequest,
12655 _name: String,
12656 _delegate: Option<&'a mut dyn common::Delegate>,
12657 _additional_params: HashMap<String, String>,
12658 _scopes: BTreeSet<String>,
12659}
12660
12661impl<'a, C> common::CallBuilder for ProjectLocationProcessorProcesCall<'a, C> {}
12662
12663impl<'a, C> ProjectLocationProcessorProcesCall<'a, C>
12664where
12665 C: common::Connector,
12666{
12667 /// Perform the operation you have build so far.
12668 pub async fn doit(
12669 mut self,
12670 ) -> common::Result<(common::Response, GoogleCloudDocumentaiV1ProcessResponse)> {
12671 use std::borrow::Cow;
12672 use std::io::{Read, Seek};
12673
12674 use common::{url::Params, ToParts};
12675 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12676
12677 let mut dd = common::DefaultDelegate;
12678 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12679 dlg.begin(common::MethodInfo {
12680 id: "documentai.projects.locations.processors.process",
12681 http_method: hyper::Method::POST,
12682 });
12683
12684 for &field in ["alt", "name"].iter() {
12685 if self._additional_params.contains_key(field) {
12686 dlg.finished(false);
12687 return Err(common::Error::FieldClash(field));
12688 }
12689 }
12690
12691 let mut params = Params::with_capacity(4 + self._additional_params.len());
12692 params.push("name", self._name);
12693
12694 params.extend(self._additional_params.iter());
12695
12696 params.push("alt", "json");
12697 let mut url = self.hub._base_url.clone() + "v1/{+name}:process";
12698 if self._scopes.is_empty() {
12699 self._scopes
12700 .insert(Scope::CloudPlatform.as_ref().to_string());
12701 }
12702
12703 #[allow(clippy::single_element_loop)]
12704 for &(find_this, param_name) in [("{+name}", "name")].iter() {
12705 url = params.uri_replacement(url, param_name, find_this, true);
12706 }
12707 {
12708 let to_remove = ["name"];
12709 params.remove_params(&to_remove);
12710 }
12711
12712 let url = params.parse_with_url(&url);
12713
12714 let mut json_mime_type = mime::APPLICATION_JSON;
12715 let mut request_value_reader = {
12716 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12717 common::remove_json_null_values(&mut value);
12718 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12719 serde_json::to_writer(&mut dst, &value).unwrap();
12720 dst
12721 };
12722 let request_size = request_value_reader
12723 .seek(std::io::SeekFrom::End(0))
12724 .unwrap();
12725 request_value_reader
12726 .seek(std::io::SeekFrom::Start(0))
12727 .unwrap();
12728
12729 loop {
12730 let token = match self
12731 .hub
12732 .auth
12733 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12734 .await
12735 {
12736 Ok(token) => token,
12737 Err(e) => match dlg.token(e) {
12738 Ok(token) => token,
12739 Err(e) => {
12740 dlg.finished(false);
12741 return Err(common::Error::MissingToken(e));
12742 }
12743 },
12744 };
12745 request_value_reader
12746 .seek(std::io::SeekFrom::Start(0))
12747 .unwrap();
12748 let mut req_result = {
12749 let client = &self.hub.client;
12750 dlg.pre_request();
12751 let mut req_builder = hyper::Request::builder()
12752 .method(hyper::Method::POST)
12753 .uri(url.as_str())
12754 .header(USER_AGENT, self.hub._user_agent.clone());
12755
12756 if let Some(token) = token.as_ref() {
12757 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12758 }
12759
12760 let request = req_builder
12761 .header(CONTENT_TYPE, json_mime_type.to_string())
12762 .header(CONTENT_LENGTH, request_size as u64)
12763 .body(common::to_body(
12764 request_value_reader.get_ref().clone().into(),
12765 ));
12766
12767 client.request(request.unwrap()).await
12768 };
12769
12770 match req_result {
12771 Err(err) => {
12772 if let common::Retry::After(d) = dlg.http_error(&err) {
12773 sleep(d).await;
12774 continue;
12775 }
12776 dlg.finished(false);
12777 return Err(common::Error::HttpError(err));
12778 }
12779 Ok(res) => {
12780 let (mut parts, body) = res.into_parts();
12781 let mut body = common::Body::new(body);
12782 if !parts.status.is_success() {
12783 let bytes = common::to_bytes(body).await.unwrap_or_default();
12784 let error = serde_json::from_str(&common::to_string(&bytes));
12785 let response = common::to_response(parts, bytes.into());
12786
12787 if let common::Retry::After(d) =
12788 dlg.http_failure(&response, error.as_ref().ok())
12789 {
12790 sleep(d).await;
12791 continue;
12792 }
12793
12794 dlg.finished(false);
12795
12796 return Err(match error {
12797 Ok(value) => common::Error::BadRequest(value),
12798 _ => common::Error::Failure(response),
12799 });
12800 }
12801 let response = {
12802 let bytes = common::to_bytes(body).await.unwrap_or_default();
12803 let encoded = common::to_string(&bytes);
12804 match serde_json::from_str(&encoded) {
12805 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12806 Err(error) => {
12807 dlg.response_json_decode_error(&encoded, &error);
12808 return Err(common::Error::JsonDecodeError(
12809 encoded.to_string(),
12810 error,
12811 ));
12812 }
12813 }
12814 };
12815
12816 dlg.finished(true);
12817 return Ok(response);
12818 }
12819 }
12820 }
12821 }
12822
12823 ///
12824 /// Sets the *request* property to the given value.
12825 ///
12826 /// Even though the property as already been set when instantiating this call,
12827 /// we provide this method for API completeness.
12828 pub fn request(
12829 mut self,
12830 new_value: GoogleCloudDocumentaiV1ProcessRequest,
12831 ) -> ProjectLocationProcessorProcesCall<'a, C> {
12832 self._request = new_value;
12833 self
12834 }
12835 /// 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}`
12836 ///
12837 /// Sets the *name* path property to the given value.
12838 ///
12839 /// Even though the property as already been set when instantiating this call,
12840 /// we provide this method for API completeness.
12841 pub fn name(mut self, new_value: &str) -> ProjectLocationProcessorProcesCall<'a, C> {
12842 self._name = new_value.to_string();
12843 self
12844 }
12845 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12846 /// while executing the actual API request.
12847 ///
12848 /// ````text
12849 /// It should be used to handle progress information, and to implement a certain level of resilience.
12850 /// ````
12851 ///
12852 /// Sets the *delegate* property to the given value.
12853 pub fn delegate(
12854 mut self,
12855 new_value: &'a mut dyn common::Delegate,
12856 ) -> ProjectLocationProcessorProcesCall<'a, C> {
12857 self._delegate = Some(new_value);
12858 self
12859 }
12860
12861 /// Set any additional parameter of the query string used in the request.
12862 /// It should be used to set parameters which are not yet available through their own
12863 /// setters.
12864 ///
12865 /// Please note that this method must not be used to set any of the known parameters
12866 /// which have their own setter method. If done anyway, the request will fail.
12867 ///
12868 /// # Additional Parameters
12869 ///
12870 /// * *$.xgafv* (query-string) - V1 error format.
12871 /// * *access_token* (query-string) - OAuth access token.
12872 /// * *alt* (query-string) - Data format for response.
12873 /// * *callback* (query-string) - JSONP
12874 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12875 /// * *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.
12876 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12877 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12878 /// * *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.
12879 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12880 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12881 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProcessorProcesCall<'a, C>
12882 where
12883 T: AsRef<str>,
12884 {
12885 self._additional_params
12886 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12887 self
12888 }
12889
12890 /// Identifies the authorization scope for the method you are building.
12891 ///
12892 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12893 /// [`Scope::CloudPlatform`].
12894 ///
12895 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12896 /// tokens for more than one scope.
12897 ///
12898 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12899 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12900 /// sufficient, a read-write scope will do as well.
12901 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProcessorProcesCall<'a, C>
12902 where
12903 St: AsRef<str>,
12904 {
12905 self._scopes.insert(String::from(scope.as_ref()));
12906 self
12907 }
12908 /// Identifies the authorization scope(s) for the method you are building.
12909 ///
12910 /// See [`Self::add_scope()`] for details.
12911 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProcessorProcesCall<'a, C>
12912 where
12913 I: IntoIterator<Item = St>,
12914 St: AsRef<str>,
12915 {
12916 self._scopes
12917 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12918 self
12919 }
12920
12921 /// Removes all scopes, and no default scope will be used either.
12922 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12923 /// for details).
12924 pub fn clear_scopes(mut self) -> ProjectLocationProcessorProcesCall<'a, C> {
12925 self._scopes.clear();
12926 self
12927 }
12928}
12929
12930/// Set the default (active) version of a Processor that will be used in ProcessDocument and BatchProcessDocuments.
12931///
12932/// A builder for the *locations.processors.setDefaultProcessorVersion* method supported by a *project* resource.
12933/// It is not used directly, but through a [`ProjectMethods`] instance.
12934///
12935/// # Example
12936///
12937/// Instantiate a resource method builder
12938///
12939/// ```test_harness,no_run
12940/// # extern crate hyper;
12941/// # extern crate hyper_rustls;
12942/// # extern crate google_documentai1 as documentai1;
12943/// use documentai1::api::GoogleCloudDocumentaiV1SetDefaultProcessorVersionRequest;
12944/// # async fn dox() {
12945/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12946///
12947/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12948/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12949/// # .with_native_roots()
12950/// # .unwrap()
12951/// # .https_only()
12952/// # .enable_http2()
12953/// # .build();
12954///
12955/// # let executor = hyper_util::rt::TokioExecutor::new();
12956/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12957/// # secret,
12958/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12959/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12960/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12961/// # ),
12962/// # ).build().await.unwrap();
12963///
12964/// # let client = hyper_util::client::legacy::Client::builder(
12965/// # hyper_util::rt::TokioExecutor::new()
12966/// # )
12967/// # .build(
12968/// # hyper_rustls::HttpsConnectorBuilder::new()
12969/// # .with_native_roots()
12970/// # .unwrap()
12971/// # .https_or_http()
12972/// # .enable_http2()
12973/// # .build()
12974/// # );
12975/// # let mut hub = Document::new(client, auth);
12976/// // As the method needs a request, you would usually fill it with the desired information
12977/// // into the respective structure. Some of the parts shown here might not be applicable !
12978/// // Values shown here are possibly random and not representative !
12979/// let mut req = GoogleCloudDocumentaiV1SetDefaultProcessorVersionRequest::default();
12980///
12981/// // You can configure optional parameters by calling the respective setters at will, and
12982/// // execute the final call using `doit()`.
12983/// // Values shown here are possibly random and not representative !
12984/// let result = hub.projects().locations_processors_set_default_processor_version(req, "processor")
12985/// .doit().await;
12986/// # }
12987/// ```
12988pub struct ProjectLocationProcessorSetDefaultProcessorVersionCall<'a, C>
12989where
12990 C: 'a,
12991{
12992 hub: &'a Document<C>,
12993 _request: GoogleCloudDocumentaiV1SetDefaultProcessorVersionRequest,
12994 _processor: String,
12995 _delegate: Option<&'a mut dyn common::Delegate>,
12996 _additional_params: HashMap<String, String>,
12997 _scopes: BTreeSet<String>,
12998}
12999
13000impl<'a, C> common::CallBuilder for ProjectLocationProcessorSetDefaultProcessorVersionCall<'a, C> {}
13001
13002impl<'a, C> ProjectLocationProcessorSetDefaultProcessorVersionCall<'a, C>
13003where
13004 C: common::Connector,
13005{
13006 /// Perform the operation you have build so far.
13007 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
13008 use std::borrow::Cow;
13009 use std::io::{Read, Seek};
13010
13011 use common::{url::Params, ToParts};
13012 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13013
13014 let mut dd = common::DefaultDelegate;
13015 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13016 dlg.begin(common::MethodInfo {
13017 id: "documentai.projects.locations.processors.setDefaultProcessorVersion",
13018 http_method: hyper::Method::POST,
13019 });
13020
13021 for &field in ["alt", "processor"].iter() {
13022 if self._additional_params.contains_key(field) {
13023 dlg.finished(false);
13024 return Err(common::Error::FieldClash(field));
13025 }
13026 }
13027
13028 let mut params = Params::with_capacity(4 + self._additional_params.len());
13029 params.push("processor", self._processor);
13030
13031 params.extend(self._additional_params.iter());
13032
13033 params.push("alt", "json");
13034 let mut url = self.hub._base_url.clone() + "v1/{+processor}:setDefaultProcessorVersion";
13035 if self._scopes.is_empty() {
13036 self._scopes
13037 .insert(Scope::CloudPlatform.as_ref().to_string());
13038 }
13039
13040 #[allow(clippy::single_element_loop)]
13041 for &(find_this, param_name) in [("{+processor}", "processor")].iter() {
13042 url = params.uri_replacement(url, param_name, find_this, true);
13043 }
13044 {
13045 let to_remove = ["processor"];
13046 params.remove_params(&to_remove);
13047 }
13048
13049 let url = params.parse_with_url(&url);
13050
13051 let mut json_mime_type = mime::APPLICATION_JSON;
13052 let mut request_value_reader = {
13053 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13054 common::remove_json_null_values(&mut value);
13055 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13056 serde_json::to_writer(&mut dst, &value).unwrap();
13057 dst
13058 };
13059 let request_size = request_value_reader
13060 .seek(std::io::SeekFrom::End(0))
13061 .unwrap();
13062 request_value_reader
13063 .seek(std::io::SeekFrom::Start(0))
13064 .unwrap();
13065
13066 loop {
13067 let token = match self
13068 .hub
13069 .auth
13070 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13071 .await
13072 {
13073 Ok(token) => token,
13074 Err(e) => match dlg.token(e) {
13075 Ok(token) => token,
13076 Err(e) => {
13077 dlg.finished(false);
13078 return Err(common::Error::MissingToken(e));
13079 }
13080 },
13081 };
13082 request_value_reader
13083 .seek(std::io::SeekFrom::Start(0))
13084 .unwrap();
13085 let mut req_result = {
13086 let client = &self.hub.client;
13087 dlg.pre_request();
13088 let mut req_builder = hyper::Request::builder()
13089 .method(hyper::Method::POST)
13090 .uri(url.as_str())
13091 .header(USER_AGENT, self.hub._user_agent.clone());
13092
13093 if let Some(token) = token.as_ref() {
13094 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13095 }
13096
13097 let request = req_builder
13098 .header(CONTENT_TYPE, json_mime_type.to_string())
13099 .header(CONTENT_LENGTH, request_size as u64)
13100 .body(common::to_body(
13101 request_value_reader.get_ref().clone().into(),
13102 ));
13103
13104 client.request(request.unwrap()).await
13105 };
13106
13107 match req_result {
13108 Err(err) => {
13109 if let common::Retry::After(d) = dlg.http_error(&err) {
13110 sleep(d).await;
13111 continue;
13112 }
13113 dlg.finished(false);
13114 return Err(common::Error::HttpError(err));
13115 }
13116 Ok(res) => {
13117 let (mut parts, body) = res.into_parts();
13118 let mut body = common::Body::new(body);
13119 if !parts.status.is_success() {
13120 let bytes = common::to_bytes(body).await.unwrap_or_default();
13121 let error = serde_json::from_str(&common::to_string(&bytes));
13122 let response = common::to_response(parts, bytes.into());
13123
13124 if let common::Retry::After(d) =
13125 dlg.http_failure(&response, error.as_ref().ok())
13126 {
13127 sleep(d).await;
13128 continue;
13129 }
13130
13131 dlg.finished(false);
13132
13133 return Err(match error {
13134 Ok(value) => common::Error::BadRequest(value),
13135 _ => common::Error::Failure(response),
13136 });
13137 }
13138 let response = {
13139 let bytes = common::to_bytes(body).await.unwrap_or_default();
13140 let encoded = common::to_string(&bytes);
13141 match serde_json::from_str(&encoded) {
13142 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13143 Err(error) => {
13144 dlg.response_json_decode_error(&encoded, &error);
13145 return Err(common::Error::JsonDecodeError(
13146 encoded.to_string(),
13147 error,
13148 ));
13149 }
13150 }
13151 };
13152
13153 dlg.finished(true);
13154 return Ok(response);
13155 }
13156 }
13157 }
13158 }
13159
13160 ///
13161 /// Sets the *request* property to the given value.
13162 ///
13163 /// Even though the property as already been set when instantiating this call,
13164 /// we provide this method for API completeness.
13165 pub fn request(
13166 mut self,
13167 new_value: GoogleCloudDocumentaiV1SetDefaultProcessorVersionRequest,
13168 ) -> ProjectLocationProcessorSetDefaultProcessorVersionCall<'a, C> {
13169 self._request = new_value;
13170 self
13171 }
13172 /// Required. The resource name of the Processor to change default version.
13173 ///
13174 /// Sets the *processor* path property to the given value.
13175 ///
13176 /// Even though the property as already been set when instantiating this call,
13177 /// we provide this method for API completeness.
13178 pub fn processor(
13179 mut self,
13180 new_value: &str,
13181 ) -> ProjectLocationProcessorSetDefaultProcessorVersionCall<'a, C> {
13182 self._processor = new_value.to_string();
13183 self
13184 }
13185 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13186 /// while executing the actual API request.
13187 ///
13188 /// ````text
13189 /// It should be used to handle progress information, and to implement a certain level of resilience.
13190 /// ````
13191 ///
13192 /// Sets the *delegate* property to the given value.
13193 pub fn delegate(
13194 mut self,
13195 new_value: &'a mut dyn common::Delegate,
13196 ) -> ProjectLocationProcessorSetDefaultProcessorVersionCall<'a, C> {
13197 self._delegate = Some(new_value);
13198 self
13199 }
13200
13201 /// Set any additional parameter of the query string used in the request.
13202 /// It should be used to set parameters which are not yet available through their own
13203 /// setters.
13204 ///
13205 /// Please note that this method must not be used to set any of the known parameters
13206 /// which have their own setter method. If done anyway, the request will fail.
13207 ///
13208 /// # Additional Parameters
13209 ///
13210 /// * *$.xgafv* (query-string) - V1 error format.
13211 /// * *access_token* (query-string) - OAuth access token.
13212 /// * *alt* (query-string) - Data format for response.
13213 /// * *callback* (query-string) - JSONP
13214 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13215 /// * *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.
13216 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13217 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13218 /// * *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.
13219 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13220 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13221 pub fn param<T>(
13222 mut self,
13223 name: T,
13224 value: T,
13225 ) -> ProjectLocationProcessorSetDefaultProcessorVersionCall<'a, C>
13226 where
13227 T: AsRef<str>,
13228 {
13229 self._additional_params
13230 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13231 self
13232 }
13233
13234 /// Identifies the authorization scope for the method you are building.
13235 ///
13236 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13237 /// [`Scope::CloudPlatform`].
13238 ///
13239 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13240 /// tokens for more than one scope.
13241 ///
13242 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13243 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13244 /// sufficient, a read-write scope will do as well.
13245 pub fn add_scope<St>(
13246 mut self,
13247 scope: St,
13248 ) -> ProjectLocationProcessorSetDefaultProcessorVersionCall<'a, C>
13249 where
13250 St: AsRef<str>,
13251 {
13252 self._scopes.insert(String::from(scope.as_ref()));
13253 self
13254 }
13255 /// Identifies the authorization scope(s) for the method you are building.
13256 ///
13257 /// See [`Self::add_scope()`] for details.
13258 pub fn add_scopes<I, St>(
13259 mut self,
13260 scopes: I,
13261 ) -> ProjectLocationProcessorSetDefaultProcessorVersionCall<'a, C>
13262 where
13263 I: IntoIterator<Item = St>,
13264 St: AsRef<str>,
13265 {
13266 self._scopes
13267 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13268 self
13269 }
13270
13271 /// Removes all scopes, and no default scope will be used either.
13272 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13273 /// for details).
13274 pub fn clear_scopes(mut self) -> ProjectLocationProcessorSetDefaultProcessorVersionCall<'a, C> {
13275 self._scopes.clear();
13276 self
13277 }
13278}
13279
13280/// Creates a schema version.
13281///
13282/// A builder for the *locations.schemas.schemaVersions.create* method supported by a *project* resource.
13283/// It is not used directly, but through a [`ProjectMethods`] instance.
13284///
13285/// # Example
13286///
13287/// Instantiate a resource method builder
13288///
13289/// ```test_harness,no_run
13290/// # extern crate hyper;
13291/// # extern crate hyper_rustls;
13292/// # extern crate google_documentai1 as documentai1;
13293/// use documentai1::api::GoogleCloudDocumentaiV1SchemaVersion;
13294/// # async fn dox() {
13295/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13296///
13297/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13298/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13299/// # .with_native_roots()
13300/// # .unwrap()
13301/// # .https_only()
13302/// # .enable_http2()
13303/// # .build();
13304///
13305/// # let executor = hyper_util::rt::TokioExecutor::new();
13306/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13307/// # secret,
13308/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13309/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13310/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13311/// # ),
13312/// # ).build().await.unwrap();
13313///
13314/// # let client = hyper_util::client::legacy::Client::builder(
13315/// # hyper_util::rt::TokioExecutor::new()
13316/// # )
13317/// # .build(
13318/// # hyper_rustls::HttpsConnectorBuilder::new()
13319/// # .with_native_roots()
13320/// # .unwrap()
13321/// # .https_or_http()
13322/// # .enable_http2()
13323/// # .build()
13324/// # );
13325/// # let mut hub = Document::new(client, auth);
13326/// // As the method needs a request, you would usually fill it with the desired information
13327/// // into the respective structure. Some of the parts shown here might not be applicable !
13328/// // Values shown here are possibly random and not representative !
13329/// let mut req = GoogleCloudDocumentaiV1SchemaVersion::default();
13330///
13331/// // You can configure optional parameters by calling the respective setters at will, and
13332/// // execute the final call using `doit()`.
13333/// // Values shown here are possibly random and not representative !
13334/// let result = hub.projects().locations_schemas_schema_versions_create(req, "parent")
13335/// .doit().await;
13336/// # }
13337/// ```
13338pub struct ProjectLocationSchemaSchemaVersionCreateCall<'a, C>
13339where
13340 C: 'a,
13341{
13342 hub: &'a Document<C>,
13343 _request: GoogleCloudDocumentaiV1SchemaVersion,
13344 _parent: String,
13345 _delegate: Option<&'a mut dyn common::Delegate>,
13346 _additional_params: HashMap<String, String>,
13347 _scopes: BTreeSet<String>,
13348}
13349
13350impl<'a, C> common::CallBuilder for ProjectLocationSchemaSchemaVersionCreateCall<'a, C> {}
13351
13352impl<'a, C> ProjectLocationSchemaSchemaVersionCreateCall<'a, C>
13353where
13354 C: common::Connector,
13355{
13356 /// Perform the operation you have build so far.
13357 pub async fn doit(
13358 mut self,
13359 ) -> common::Result<(common::Response, GoogleCloudDocumentaiV1SchemaVersion)> {
13360 use std::borrow::Cow;
13361 use std::io::{Read, Seek};
13362
13363 use common::{url::Params, ToParts};
13364 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13365
13366 let mut dd = common::DefaultDelegate;
13367 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13368 dlg.begin(common::MethodInfo {
13369 id: "documentai.projects.locations.schemas.schemaVersions.create",
13370 http_method: hyper::Method::POST,
13371 });
13372
13373 for &field in ["alt", "parent"].iter() {
13374 if self._additional_params.contains_key(field) {
13375 dlg.finished(false);
13376 return Err(common::Error::FieldClash(field));
13377 }
13378 }
13379
13380 let mut params = Params::with_capacity(4 + self._additional_params.len());
13381 params.push("parent", self._parent);
13382
13383 params.extend(self._additional_params.iter());
13384
13385 params.push("alt", "json");
13386 let mut url = self.hub._base_url.clone() + "v1/{+parent}/schemaVersions";
13387 if self._scopes.is_empty() {
13388 self._scopes
13389 .insert(Scope::CloudPlatform.as_ref().to_string());
13390 }
13391
13392 #[allow(clippy::single_element_loop)]
13393 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
13394 url = params.uri_replacement(url, param_name, find_this, true);
13395 }
13396 {
13397 let to_remove = ["parent"];
13398 params.remove_params(&to_remove);
13399 }
13400
13401 let url = params.parse_with_url(&url);
13402
13403 let mut json_mime_type = mime::APPLICATION_JSON;
13404 let mut request_value_reader = {
13405 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13406 common::remove_json_null_values(&mut value);
13407 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13408 serde_json::to_writer(&mut dst, &value).unwrap();
13409 dst
13410 };
13411 let request_size = request_value_reader
13412 .seek(std::io::SeekFrom::End(0))
13413 .unwrap();
13414 request_value_reader
13415 .seek(std::io::SeekFrom::Start(0))
13416 .unwrap();
13417
13418 loop {
13419 let token = match self
13420 .hub
13421 .auth
13422 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13423 .await
13424 {
13425 Ok(token) => token,
13426 Err(e) => match dlg.token(e) {
13427 Ok(token) => token,
13428 Err(e) => {
13429 dlg.finished(false);
13430 return Err(common::Error::MissingToken(e));
13431 }
13432 },
13433 };
13434 request_value_reader
13435 .seek(std::io::SeekFrom::Start(0))
13436 .unwrap();
13437 let mut req_result = {
13438 let client = &self.hub.client;
13439 dlg.pre_request();
13440 let mut req_builder = hyper::Request::builder()
13441 .method(hyper::Method::POST)
13442 .uri(url.as_str())
13443 .header(USER_AGENT, self.hub._user_agent.clone());
13444
13445 if let Some(token) = token.as_ref() {
13446 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13447 }
13448
13449 let request = req_builder
13450 .header(CONTENT_TYPE, json_mime_type.to_string())
13451 .header(CONTENT_LENGTH, request_size as u64)
13452 .body(common::to_body(
13453 request_value_reader.get_ref().clone().into(),
13454 ));
13455
13456 client.request(request.unwrap()).await
13457 };
13458
13459 match req_result {
13460 Err(err) => {
13461 if let common::Retry::After(d) = dlg.http_error(&err) {
13462 sleep(d).await;
13463 continue;
13464 }
13465 dlg.finished(false);
13466 return Err(common::Error::HttpError(err));
13467 }
13468 Ok(res) => {
13469 let (mut parts, body) = res.into_parts();
13470 let mut body = common::Body::new(body);
13471 if !parts.status.is_success() {
13472 let bytes = common::to_bytes(body).await.unwrap_or_default();
13473 let error = serde_json::from_str(&common::to_string(&bytes));
13474 let response = common::to_response(parts, bytes.into());
13475
13476 if let common::Retry::After(d) =
13477 dlg.http_failure(&response, error.as_ref().ok())
13478 {
13479 sleep(d).await;
13480 continue;
13481 }
13482
13483 dlg.finished(false);
13484
13485 return Err(match error {
13486 Ok(value) => common::Error::BadRequest(value),
13487 _ => common::Error::Failure(response),
13488 });
13489 }
13490 let response = {
13491 let bytes = common::to_bytes(body).await.unwrap_or_default();
13492 let encoded = common::to_string(&bytes);
13493 match serde_json::from_str(&encoded) {
13494 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13495 Err(error) => {
13496 dlg.response_json_decode_error(&encoded, &error);
13497 return Err(common::Error::JsonDecodeError(
13498 encoded.to_string(),
13499 error,
13500 ));
13501 }
13502 }
13503 };
13504
13505 dlg.finished(true);
13506 return Ok(response);
13507 }
13508 }
13509 }
13510 }
13511
13512 ///
13513 /// Sets the *request* property to the given value.
13514 ///
13515 /// Even though the property as already been set when instantiating this call,
13516 /// we provide this method for API completeness.
13517 pub fn request(
13518 mut self,
13519 new_value: GoogleCloudDocumentaiV1SchemaVersion,
13520 ) -> ProjectLocationSchemaSchemaVersionCreateCall<'a, C> {
13521 self._request = new_value;
13522 self
13523 }
13524 /// Required. The parent (project and location) under which to create the SchemaVersion. Format: `projects/{project}/locations/{location}/schemas/{schema}`
13525 ///
13526 /// Sets the *parent* path property to the given value.
13527 ///
13528 /// Even though the property as already been set when instantiating this call,
13529 /// we provide this method for API completeness.
13530 pub fn parent(
13531 mut self,
13532 new_value: &str,
13533 ) -> ProjectLocationSchemaSchemaVersionCreateCall<'a, C> {
13534 self._parent = new_value.to_string();
13535 self
13536 }
13537 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13538 /// while executing the actual API request.
13539 ///
13540 /// ````text
13541 /// It should be used to handle progress information, and to implement a certain level of resilience.
13542 /// ````
13543 ///
13544 /// Sets the *delegate* property to the given value.
13545 pub fn delegate(
13546 mut self,
13547 new_value: &'a mut dyn common::Delegate,
13548 ) -> ProjectLocationSchemaSchemaVersionCreateCall<'a, C> {
13549 self._delegate = Some(new_value);
13550 self
13551 }
13552
13553 /// Set any additional parameter of the query string used in the request.
13554 /// It should be used to set parameters which are not yet available through their own
13555 /// setters.
13556 ///
13557 /// Please note that this method must not be used to set any of the known parameters
13558 /// which have their own setter method. If done anyway, the request will fail.
13559 ///
13560 /// # Additional Parameters
13561 ///
13562 /// * *$.xgafv* (query-string) - V1 error format.
13563 /// * *access_token* (query-string) - OAuth access token.
13564 /// * *alt* (query-string) - Data format for response.
13565 /// * *callback* (query-string) - JSONP
13566 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13567 /// * *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.
13568 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13569 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13570 /// * *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.
13571 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13572 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13573 pub fn param<T>(
13574 mut self,
13575 name: T,
13576 value: T,
13577 ) -> ProjectLocationSchemaSchemaVersionCreateCall<'a, C>
13578 where
13579 T: AsRef<str>,
13580 {
13581 self._additional_params
13582 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13583 self
13584 }
13585
13586 /// Identifies the authorization scope for the method you are building.
13587 ///
13588 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13589 /// [`Scope::CloudPlatform`].
13590 ///
13591 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13592 /// tokens for more than one scope.
13593 ///
13594 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13595 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13596 /// sufficient, a read-write scope will do as well.
13597 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSchemaSchemaVersionCreateCall<'a, C>
13598 where
13599 St: AsRef<str>,
13600 {
13601 self._scopes.insert(String::from(scope.as_ref()));
13602 self
13603 }
13604 /// Identifies the authorization scope(s) for the method you are building.
13605 ///
13606 /// See [`Self::add_scope()`] for details.
13607 pub fn add_scopes<I, St>(
13608 mut self,
13609 scopes: I,
13610 ) -> ProjectLocationSchemaSchemaVersionCreateCall<'a, C>
13611 where
13612 I: IntoIterator<Item = St>,
13613 St: AsRef<str>,
13614 {
13615 self._scopes
13616 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13617 self
13618 }
13619
13620 /// Removes all scopes, and no default scope will be used either.
13621 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13622 /// for details).
13623 pub fn clear_scopes(mut self) -> ProjectLocationSchemaSchemaVersionCreateCall<'a, C> {
13624 self._scopes.clear();
13625 self
13626 }
13627}
13628
13629/// Deletes a schema version.
13630///
13631/// A builder for the *locations.schemas.schemaVersions.delete* method supported by a *project* resource.
13632/// It is not used directly, but through a [`ProjectMethods`] instance.
13633///
13634/// # Example
13635///
13636/// Instantiate a resource method builder
13637///
13638/// ```test_harness,no_run
13639/// # extern crate hyper;
13640/// # extern crate hyper_rustls;
13641/// # extern crate google_documentai1 as documentai1;
13642/// # async fn dox() {
13643/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13644///
13645/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13646/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13647/// # .with_native_roots()
13648/// # .unwrap()
13649/// # .https_only()
13650/// # .enable_http2()
13651/// # .build();
13652///
13653/// # let executor = hyper_util::rt::TokioExecutor::new();
13654/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13655/// # secret,
13656/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13657/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13658/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13659/// # ),
13660/// # ).build().await.unwrap();
13661///
13662/// # let client = hyper_util::client::legacy::Client::builder(
13663/// # hyper_util::rt::TokioExecutor::new()
13664/// # )
13665/// # .build(
13666/// # hyper_rustls::HttpsConnectorBuilder::new()
13667/// # .with_native_roots()
13668/// # .unwrap()
13669/// # .https_or_http()
13670/// # .enable_http2()
13671/// # .build()
13672/// # );
13673/// # let mut hub = Document::new(client, auth);
13674/// // You can configure optional parameters by calling the respective setters at will, and
13675/// // execute the final call using `doit()`.
13676/// // Values shown here are possibly random and not representative !
13677/// let result = hub.projects().locations_schemas_schema_versions_delete("name")
13678/// .doit().await;
13679/// # }
13680/// ```
13681pub struct ProjectLocationSchemaSchemaVersionDeleteCall<'a, C>
13682where
13683 C: 'a,
13684{
13685 hub: &'a Document<C>,
13686 _name: String,
13687 _delegate: Option<&'a mut dyn common::Delegate>,
13688 _additional_params: HashMap<String, String>,
13689 _scopes: BTreeSet<String>,
13690}
13691
13692impl<'a, C> common::CallBuilder for ProjectLocationSchemaSchemaVersionDeleteCall<'a, C> {}
13693
13694impl<'a, C> ProjectLocationSchemaSchemaVersionDeleteCall<'a, C>
13695where
13696 C: common::Connector,
13697{
13698 /// Perform the operation you have build so far.
13699 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
13700 use std::borrow::Cow;
13701 use std::io::{Read, Seek};
13702
13703 use common::{url::Params, ToParts};
13704 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13705
13706 let mut dd = common::DefaultDelegate;
13707 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13708 dlg.begin(common::MethodInfo {
13709 id: "documentai.projects.locations.schemas.schemaVersions.delete",
13710 http_method: hyper::Method::DELETE,
13711 });
13712
13713 for &field in ["alt", "name"].iter() {
13714 if self._additional_params.contains_key(field) {
13715 dlg.finished(false);
13716 return Err(common::Error::FieldClash(field));
13717 }
13718 }
13719
13720 let mut params = Params::with_capacity(3 + self._additional_params.len());
13721 params.push("name", self._name);
13722
13723 params.extend(self._additional_params.iter());
13724
13725 params.push("alt", "json");
13726 let mut url = self.hub._base_url.clone() + "v1/{+name}";
13727 if self._scopes.is_empty() {
13728 self._scopes
13729 .insert(Scope::CloudPlatform.as_ref().to_string());
13730 }
13731
13732 #[allow(clippy::single_element_loop)]
13733 for &(find_this, param_name) in [("{+name}", "name")].iter() {
13734 url = params.uri_replacement(url, param_name, find_this, true);
13735 }
13736 {
13737 let to_remove = ["name"];
13738 params.remove_params(&to_remove);
13739 }
13740
13741 let url = params.parse_with_url(&url);
13742
13743 loop {
13744 let token = match self
13745 .hub
13746 .auth
13747 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13748 .await
13749 {
13750 Ok(token) => token,
13751 Err(e) => match dlg.token(e) {
13752 Ok(token) => token,
13753 Err(e) => {
13754 dlg.finished(false);
13755 return Err(common::Error::MissingToken(e));
13756 }
13757 },
13758 };
13759 let mut req_result = {
13760 let client = &self.hub.client;
13761 dlg.pre_request();
13762 let mut req_builder = hyper::Request::builder()
13763 .method(hyper::Method::DELETE)
13764 .uri(url.as_str())
13765 .header(USER_AGENT, self.hub._user_agent.clone());
13766
13767 if let Some(token) = token.as_ref() {
13768 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13769 }
13770
13771 let request = req_builder
13772 .header(CONTENT_LENGTH, 0_u64)
13773 .body(common::to_body::<String>(None));
13774
13775 client.request(request.unwrap()).await
13776 };
13777
13778 match req_result {
13779 Err(err) => {
13780 if let common::Retry::After(d) = dlg.http_error(&err) {
13781 sleep(d).await;
13782 continue;
13783 }
13784 dlg.finished(false);
13785 return Err(common::Error::HttpError(err));
13786 }
13787 Ok(res) => {
13788 let (mut parts, body) = res.into_parts();
13789 let mut body = common::Body::new(body);
13790 if !parts.status.is_success() {
13791 let bytes = common::to_bytes(body).await.unwrap_or_default();
13792 let error = serde_json::from_str(&common::to_string(&bytes));
13793 let response = common::to_response(parts, bytes.into());
13794
13795 if let common::Retry::After(d) =
13796 dlg.http_failure(&response, error.as_ref().ok())
13797 {
13798 sleep(d).await;
13799 continue;
13800 }
13801
13802 dlg.finished(false);
13803
13804 return Err(match error {
13805 Ok(value) => common::Error::BadRequest(value),
13806 _ => common::Error::Failure(response),
13807 });
13808 }
13809 let response = {
13810 let bytes = common::to_bytes(body).await.unwrap_or_default();
13811 let encoded = common::to_string(&bytes);
13812 match serde_json::from_str(&encoded) {
13813 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13814 Err(error) => {
13815 dlg.response_json_decode_error(&encoded, &error);
13816 return Err(common::Error::JsonDecodeError(
13817 encoded.to_string(),
13818 error,
13819 ));
13820 }
13821 }
13822 };
13823
13824 dlg.finished(true);
13825 return Ok(response);
13826 }
13827 }
13828 }
13829 }
13830
13831 /// Required. The name of the SchemaVersion to delete. Format: `projects/{project}/locations/{location}/schemas/{schema}/schemaVersions/{schema_version}`
13832 ///
13833 /// Sets the *name* path property to the given value.
13834 ///
13835 /// Even though the property as already been set when instantiating this call,
13836 /// we provide this method for API completeness.
13837 pub fn name(mut self, new_value: &str) -> ProjectLocationSchemaSchemaVersionDeleteCall<'a, C> {
13838 self._name = new_value.to_string();
13839 self
13840 }
13841 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13842 /// while executing the actual API request.
13843 ///
13844 /// ````text
13845 /// It should be used to handle progress information, and to implement a certain level of resilience.
13846 /// ````
13847 ///
13848 /// Sets the *delegate* property to the given value.
13849 pub fn delegate(
13850 mut self,
13851 new_value: &'a mut dyn common::Delegate,
13852 ) -> ProjectLocationSchemaSchemaVersionDeleteCall<'a, C> {
13853 self._delegate = Some(new_value);
13854 self
13855 }
13856
13857 /// Set any additional parameter of the query string used in the request.
13858 /// It should be used to set parameters which are not yet available through their own
13859 /// setters.
13860 ///
13861 /// Please note that this method must not be used to set any of the known parameters
13862 /// which have their own setter method. If done anyway, the request will fail.
13863 ///
13864 /// # Additional Parameters
13865 ///
13866 /// * *$.xgafv* (query-string) - V1 error format.
13867 /// * *access_token* (query-string) - OAuth access token.
13868 /// * *alt* (query-string) - Data format for response.
13869 /// * *callback* (query-string) - JSONP
13870 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13871 /// * *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.
13872 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13873 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13874 /// * *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.
13875 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13876 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13877 pub fn param<T>(
13878 mut self,
13879 name: T,
13880 value: T,
13881 ) -> ProjectLocationSchemaSchemaVersionDeleteCall<'a, C>
13882 where
13883 T: AsRef<str>,
13884 {
13885 self._additional_params
13886 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13887 self
13888 }
13889
13890 /// Identifies the authorization scope for the method you are building.
13891 ///
13892 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13893 /// [`Scope::CloudPlatform`].
13894 ///
13895 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13896 /// tokens for more than one scope.
13897 ///
13898 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13899 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13900 /// sufficient, a read-write scope will do as well.
13901 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSchemaSchemaVersionDeleteCall<'a, C>
13902 where
13903 St: AsRef<str>,
13904 {
13905 self._scopes.insert(String::from(scope.as_ref()));
13906 self
13907 }
13908 /// Identifies the authorization scope(s) for the method you are building.
13909 ///
13910 /// See [`Self::add_scope()`] for details.
13911 pub fn add_scopes<I, St>(
13912 mut self,
13913 scopes: I,
13914 ) -> ProjectLocationSchemaSchemaVersionDeleteCall<'a, C>
13915 where
13916 I: IntoIterator<Item = St>,
13917 St: AsRef<str>,
13918 {
13919 self._scopes
13920 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13921 self
13922 }
13923
13924 /// Removes all scopes, and no default scope will be used either.
13925 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13926 /// for details).
13927 pub fn clear_scopes(mut self) -> ProjectLocationSchemaSchemaVersionDeleteCall<'a, C> {
13928 self._scopes.clear();
13929 self
13930 }
13931}
13932
13933/// Generates a schema version.
13934///
13935/// A builder for the *locations.schemas.schemaVersions.generate* method supported by a *project* resource.
13936/// It is not used directly, but through a [`ProjectMethods`] instance.
13937///
13938/// # Example
13939///
13940/// Instantiate a resource method builder
13941///
13942/// ```test_harness,no_run
13943/// # extern crate hyper;
13944/// # extern crate hyper_rustls;
13945/// # extern crate google_documentai1 as documentai1;
13946/// use documentai1::api::GoogleCloudDocumentaiV1GenerateSchemaVersionRequest;
13947/// # async fn dox() {
13948/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13949///
13950/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13951/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13952/// # .with_native_roots()
13953/// # .unwrap()
13954/// # .https_only()
13955/// # .enable_http2()
13956/// # .build();
13957///
13958/// # let executor = hyper_util::rt::TokioExecutor::new();
13959/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13960/// # secret,
13961/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13962/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13963/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13964/// # ),
13965/// # ).build().await.unwrap();
13966///
13967/// # let client = hyper_util::client::legacy::Client::builder(
13968/// # hyper_util::rt::TokioExecutor::new()
13969/// # )
13970/// # .build(
13971/// # hyper_rustls::HttpsConnectorBuilder::new()
13972/// # .with_native_roots()
13973/// # .unwrap()
13974/// # .https_or_http()
13975/// # .enable_http2()
13976/// # .build()
13977/// # );
13978/// # let mut hub = Document::new(client, auth);
13979/// // As the method needs a request, you would usually fill it with the desired information
13980/// // into the respective structure. Some of the parts shown here might not be applicable !
13981/// // Values shown here are possibly random and not representative !
13982/// let mut req = GoogleCloudDocumentaiV1GenerateSchemaVersionRequest::default();
13983///
13984/// // You can configure optional parameters by calling the respective setters at will, and
13985/// // execute the final call using `doit()`.
13986/// // Values shown here are possibly random and not representative !
13987/// let result = hub.projects().locations_schemas_schema_versions_generate(req, "parent")
13988/// .doit().await;
13989/// # }
13990/// ```
13991pub struct ProjectLocationSchemaSchemaVersionGenerateCall<'a, C>
13992where
13993 C: 'a,
13994{
13995 hub: &'a Document<C>,
13996 _request: GoogleCloudDocumentaiV1GenerateSchemaVersionRequest,
13997 _parent: String,
13998 _delegate: Option<&'a mut dyn common::Delegate>,
13999 _additional_params: HashMap<String, String>,
14000 _scopes: BTreeSet<String>,
14001}
14002
14003impl<'a, C> common::CallBuilder for ProjectLocationSchemaSchemaVersionGenerateCall<'a, C> {}
14004
14005impl<'a, C> ProjectLocationSchemaSchemaVersionGenerateCall<'a, C>
14006where
14007 C: common::Connector,
14008{
14009 /// Perform the operation you have build so far.
14010 pub async fn doit(
14011 mut self,
14012 ) -> common::Result<(
14013 common::Response,
14014 GoogleCloudDocumentaiV1GenerateSchemaVersionResponse,
14015 )> {
14016 use std::borrow::Cow;
14017 use std::io::{Read, Seek};
14018
14019 use common::{url::Params, ToParts};
14020 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14021
14022 let mut dd = common::DefaultDelegate;
14023 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14024 dlg.begin(common::MethodInfo {
14025 id: "documentai.projects.locations.schemas.schemaVersions.generate",
14026 http_method: hyper::Method::POST,
14027 });
14028
14029 for &field in ["alt", "parent"].iter() {
14030 if self._additional_params.contains_key(field) {
14031 dlg.finished(false);
14032 return Err(common::Error::FieldClash(field));
14033 }
14034 }
14035
14036 let mut params = Params::with_capacity(4 + self._additional_params.len());
14037 params.push("parent", self._parent);
14038
14039 params.extend(self._additional_params.iter());
14040
14041 params.push("alt", "json");
14042 let mut url = self.hub._base_url.clone() + "v1/{+parent}/schemaVersions:generate";
14043 if self._scopes.is_empty() {
14044 self._scopes
14045 .insert(Scope::CloudPlatform.as_ref().to_string());
14046 }
14047
14048 #[allow(clippy::single_element_loop)]
14049 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
14050 url = params.uri_replacement(url, param_name, find_this, true);
14051 }
14052 {
14053 let to_remove = ["parent"];
14054 params.remove_params(&to_remove);
14055 }
14056
14057 let url = params.parse_with_url(&url);
14058
14059 let mut json_mime_type = mime::APPLICATION_JSON;
14060 let mut request_value_reader = {
14061 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14062 common::remove_json_null_values(&mut value);
14063 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14064 serde_json::to_writer(&mut dst, &value).unwrap();
14065 dst
14066 };
14067 let request_size = request_value_reader
14068 .seek(std::io::SeekFrom::End(0))
14069 .unwrap();
14070 request_value_reader
14071 .seek(std::io::SeekFrom::Start(0))
14072 .unwrap();
14073
14074 loop {
14075 let token = match self
14076 .hub
14077 .auth
14078 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14079 .await
14080 {
14081 Ok(token) => token,
14082 Err(e) => match dlg.token(e) {
14083 Ok(token) => token,
14084 Err(e) => {
14085 dlg.finished(false);
14086 return Err(common::Error::MissingToken(e));
14087 }
14088 },
14089 };
14090 request_value_reader
14091 .seek(std::io::SeekFrom::Start(0))
14092 .unwrap();
14093 let mut req_result = {
14094 let client = &self.hub.client;
14095 dlg.pre_request();
14096 let mut req_builder = hyper::Request::builder()
14097 .method(hyper::Method::POST)
14098 .uri(url.as_str())
14099 .header(USER_AGENT, self.hub._user_agent.clone());
14100
14101 if let Some(token) = token.as_ref() {
14102 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14103 }
14104
14105 let request = req_builder
14106 .header(CONTENT_TYPE, json_mime_type.to_string())
14107 .header(CONTENT_LENGTH, request_size as u64)
14108 .body(common::to_body(
14109 request_value_reader.get_ref().clone().into(),
14110 ));
14111
14112 client.request(request.unwrap()).await
14113 };
14114
14115 match req_result {
14116 Err(err) => {
14117 if let common::Retry::After(d) = dlg.http_error(&err) {
14118 sleep(d).await;
14119 continue;
14120 }
14121 dlg.finished(false);
14122 return Err(common::Error::HttpError(err));
14123 }
14124 Ok(res) => {
14125 let (mut parts, body) = res.into_parts();
14126 let mut body = common::Body::new(body);
14127 if !parts.status.is_success() {
14128 let bytes = common::to_bytes(body).await.unwrap_or_default();
14129 let error = serde_json::from_str(&common::to_string(&bytes));
14130 let response = common::to_response(parts, bytes.into());
14131
14132 if let common::Retry::After(d) =
14133 dlg.http_failure(&response, error.as_ref().ok())
14134 {
14135 sleep(d).await;
14136 continue;
14137 }
14138
14139 dlg.finished(false);
14140
14141 return Err(match error {
14142 Ok(value) => common::Error::BadRequest(value),
14143 _ => common::Error::Failure(response),
14144 });
14145 }
14146 let response = {
14147 let bytes = common::to_bytes(body).await.unwrap_or_default();
14148 let encoded = common::to_string(&bytes);
14149 match serde_json::from_str(&encoded) {
14150 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14151 Err(error) => {
14152 dlg.response_json_decode_error(&encoded, &error);
14153 return Err(common::Error::JsonDecodeError(
14154 encoded.to_string(),
14155 error,
14156 ));
14157 }
14158 }
14159 };
14160
14161 dlg.finished(true);
14162 return Ok(response);
14163 }
14164 }
14165 }
14166 }
14167
14168 ///
14169 /// Sets the *request* property to the given value.
14170 ///
14171 /// Even though the property as already been set when instantiating this call,
14172 /// we provide this method for API completeness.
14173 pub fn request(
14174 mut self,
14175 new_value: GoogleCloudDocumentaiV1GenerateSchemaVersionRequest,
14176 ) -> ProjectLocationSchemaSchemaVersionGenerateCall<'a, C> {
14177 self._request = new_value;
14178 self
14179 }
14180 /// Required. The parent (project, location and schema) under which to generate the SchemaVersion. Format: `projects/{project}/locations/{location}/schemas/{schema}`
14181 ///
14182 /// Sets the *parent* path property to the given value.
14183 ///
14184 /// Even though the property as already been set when instantiating this call,
14185 /// we provide this method for API completeness.
14186 pub fn parent(
14187 mut self,
14188 new_value: &str,
14189 ) -> ProjectLocationSchemaSchemaVersionGenerateCall<'a, C> {
14190 self._parent = new_value.to_string();
14191 self
14192 }
14193 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14194 /// while executing the actual API request.
14195 ///
14196 /// ````text
14197 /// It should be used to handle progress information, and to implement a certain level of resilience.
14198 /// ````
14199 ///
14200 /// Sets the *delegate* property to the given value.
14201 pub fn delegate(
14202 mut self,
14203 new_value: &'a mut dyn common::Delegate,
14204 ) -> ProjectLocationSchemaSchemaVersionGenerateCall<'a, C> {
14205 self._delegate = Some(new_value);
14206 self
14207 }
14208
14209 /// Set any additional parameter of the query string used in the request.
14210 /// It should be used to set parameters which are not yet available through their own
14211 /// setters.
14212 ///
14213 /// Please note that this method must not be used to set any of the known parameters
14214 /// which have their own setter method. If done anyway, the request will fail.
14215 ///
14216 /// # Additional Parameters
14217 ///
14218 /// * *$.xgafv* (query-string) - V1 error format.
14219 /// * *access_token* (query-string) - OAuth access token.
14220 /// * *alt* (query-string) - Data format for response.
14221 /// * *callback* (query-string) - JSONP
14222 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14223 /// * *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.
14224 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14225 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14226 /// * *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.
14227 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14228 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14229 pub fn param<T>(
14230 mut self,
14231 name: T,
14232 value: T,
14233 ) -> ProjectLocationSchemaSchemaVersionGenerateCall<'a, C>
14234 where
14235 T: AsRef<str>,
14236 {
14237 self._additional_params
14238 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14239 self
14240 }
14241
14242 /// Identifies the authorization scope for the method you are building.
14243 ///
14244 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14245 /// [`Scope::CloudPlatform`].
14246 ///
14247 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14248 /// tokens for more than one scope.
14249 ///
14250 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14251 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14252 /// sufficient, a read-write scope will do as well.
14253 pub fn add_scope<St>(
14254 mut self,
14255 scope: St,
14256 ) -> ProjectLocationSchemaSchemaVersionGenerateCall<'a, C>
14257 where
14258 St: AsRef<str>,
14259 {
14260 self._scopes.insert(String::from(scope.as_ref()));
14261 self
14262 }
14263 /// Identifies the authorization scope(s) for the method you are building.
14264 ///
14265 /// See [`Self::add_scope()`] for details.
14266 pub fn add_scopes<I, St>(
14267 mut self,
14268 scopes: I,
14269 ) -> ProjectLocationSchemaSchemaVersionGenerateCall<'a, C>
14270 where
14271 I: IntoIterator<Item = St>,
14272 St: AsRef<str>,
14273 {
14274 self._scopes
14275 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14276 self
14277 }
14278
14279 /// Removes all scopes, and no default scope will be used either.
14280 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14281 /// for details).
14282 pub fn clear_scopes(mut self) -> ProjectLocationSchemaSchemaVersionGenerateCall<'a, C> {
14283 self._scopes.clear();
14284 self
14285 }
14286}
14287
14288/// Gets a schema version.
14289///
14290/// A builder for the *locations.schemas.schemaVersions.get* method supported by a *project* resource.
14291/// It is not used directly, but through a [`ProjectMethods`] instance.
14292///
14293/// # Example
14294///
14295/// Instantiate a resource method builder
14296///
14297/// ```test_harness,no_run
14298/// # extern crate hyper;
14299/// # extern crate hyper_rustls;
14300/// # extern crate google_documentai1 as documentai1;
14301/// # async fn dox() {
14302/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14303///
14304/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14305/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14306/// # .with_native_roots()
14307/// # .unwrap()
14308/// # .https_only()
14309/// # .enable_http2()
14310/// # .build();
14311///
14312/// # let executor = hyper_util::rt::TokioExecutor::new();
14313/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14314/// # secret,
14315/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14316/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14317/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14318/// # ),
14319/// # ).build().await.unwrap();
14320///
14321/// # let client = hyper_util::client::legacy::Client::builder(
14322/// # hyper_util::rt::TokioExecutor::new()
14323/// # )
14324/// # .build(
14325/// # hyper_rustls::HttpsConnectorBuilder::new()
14326/// # .with_native_roots()
14327/// # .unwrap()
14328/// # .https_or_http()
14329/// # .enable_http2()
14330/// # .build()
14331/// # );
14332/// # let mut hub = Document::new(client, auth);
14333/// // You can configure optional parameters by calling the respective setters at will, and
14334/// // execute the final call using `doit()`.
14335/// // Values shown here are possibly random and not representative !
14336/// let result = hub.projects().locations_schemas_schema_versions_get("name")
14337/// .doit().await;
14338/// # }
14339/// ```
14340pub struct ProjectLocationSchemaSchemaVersionGetCall<'a, C>
14341where
14342 C: 'a,
14343{
14344 hub: &'a Document<C>,
14345 _name: String,
14346 _delegate: Option<&'a mut dyn common::Delegate>,
14347 _additional_params: HashMap<String, String>,
14348 _scopes: BTreeSet<String>,
14349}
14350
14351impl<'a, C> common::CallBuilder for ProjectLocationSchemaSchemaVersionGetCall<'a, C> {}
14352
14353impl<'a, C> ProjectLocationSchemaSchemaVersionGetCall<'a, C>
14354where
14355 C: common::Connector,
14356{
14357 /// Perform the operation you have build so far.
14358 pub async fn doit(
14359 mut self,
14360 ) -> common::Result<(common::Response, GoogleCloudDocumentaiV1SchemaVersion)> {
14361 use std::borrow::Cow;
14362 use std::io::{Read, Seek};
14363
14364 use common::{url::Params, ToParts};
14365 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14366
14367 let mut dd = common::DefaultDelegate;
14368 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14369 dlg.begin(common::MethodInfo {
14370 id: "documentai.projects.locations.schemas.schemaVersions.get",
14371 http_method: hyper::Method::GET,
14372 });
14373
14374 for &field in ["alt", "name"].iter() {
14375 if self._additional_params.contains_key(field) {
14376 dlg.finished(false);
14377 return Err(common::Error::FieldClash(field));
14378 }
14379 }
14380
14381 let mut params = Params::with_capacity(3 + self._additional_params.len());
14382 params.push("name", self._name);
14383
14384 params.extend(self._additional_params.iter());
14385
14386 params.push("alt", "json");
14387 let mut url = self.hub._base_url.clone() + "v1/{+name}";
14388 if self._scopes.is_empty() {
14389 self._scopes
14390 .insert(Scope::CloudPlatform.as_ref().to_string());
14391 }
14392
14393 #[allow(clippy::single_element_loop)]
14394 for &(find_this, param_name) in [("{+name}", "name")].iter() {
14395 url = params.uri_replacement(url, param_name, find_this, true);
14396 }
14397 {
14398 let to_remove = ["name"];
14399 params.remove_params(&to_remove);
14400 }
14401
14402 let url = params.parse_with_url(&url);
14403
14404 loop {
14405 let token = match self
14406 .hub
14407 .auth
14408 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14409 .await
14410 {
14411 Ok(token) => token,
14412 Err(e) => match dlg.token(e) {
14413 Ok(token) => token,
14414 Err(e) => {
14415 dlg.finished(false);
14416 return Err(common::Error::MissingToken(e));
14417 }
14418 },
14419 };
14420 let mut req_result = {
14421 let client = &self.hub.client;
14422 dlg.pre_request();
14423 let mut req_builder = hyper::Request::builder()
14424 .method(hyper::Method::GET)
14425 .uri(url.as_str())
14426 .header(USER_AGENT, self.hub._user_agent.clone());
14427
14428 if let Some(token) = token.as_ref() {
14429 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14430 }
14431
14432 let request = req_builder
14433 .header(CONTENT_LENGTH, 0_u64)
14434 .body(common::to_body::<String>(None));
14435
14436 client.request(request.unwrap()).await
14437 };
14438
14439 match req_result {
14440 Err(err) => {
14441 if let common::Retry::After(d) = dlg.http_error(&err) {
14442 sleep(d).await;
14443 continue;
14444 }
14445 dlg.finished(false);
14446 return Err(common::Error::HttpError(err));
14447 }
14448 Ok(res) => {
14449 let (mut parts, body) = res.into_parts();
14450 let mut body = common::Body::new(body);
14451 if !parts.status.is_success() {
14452 let bytes = common::to_bytes(body).await.unwrap_or_default();
14453 let error = serde_json::from_str(&common::to_string(&bytes));
14454 let response = common::to_response(parts, bytes.into());
14455
14456 if let common::Retry::After(d) =
14457 dlg.http_failure(&response, error.as_ref().ok())
14458 {
14459 sleep(d).await;
14460 continue;
14461 }
14462
14463 dlg.finished(false);
14464
14465 return Err(match error {
14466 Ok(value) => common::Error::BadRequest(value),
14467 _ => common::Error::Failure(response),
14468 });
14469 }
14470 let response = {
14471 let bytes = common::to_bytes(body).await.unwrap_or_default();
14472 let encoded = common::to_string(&bytes);
14473 match serde_json::from_str(&encoded) {
14474 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14475 Err(error) => {
14476 dlg.response_json_decode_error(&encoded, &error);
14477 return Err(common::Error::JsonDecodeError(
14478 encoded.to_string(),
14479 error,
14480 ));
14481 }
14482 }
14483 };
14484
14485 dlg.finished(true);
14486 return Ok(response);
14487 }
14488 }
14489 }
14490 }
14491
14492 /// Required. The name of the SchemaVersion to get. Format: `projects/{project}/locations/{location}/schemas/{schema}/schemaVersions/{schema_version}`
14493 ///
14494 /// Sets the *name* path property to the given value.
14495 ///
14496 /// Even though the property as already been set when instantiating this call,
14497 /// we provide this method for API completeness.
14498 pub fn name(mut self, new_value: &str) -> ProjectLocationSchemaSchemaVersionGetCall<'a, C> {
14499 self._name = new_value.to_string();
14500 self
14501 }
14502 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14503 /// while executing the actual API request.
14504 ///
14505 /// ````text
14506 /// It should be used to handle progress information, and to implement a certain level of resilience.
14507 /// ````
14508 ///
14509 /// Sets the *delegate* property to the given value.
14510 pub fn delegate(
14511 mut self,
14512 new_value: &'a mut dyn common::Delegate,
14513 ) -> ProjectLocationSchemaSchemaVersionGetCall<'a, C> {
14514 self._delegate = Some(new_value);
14515 self
14516 }
14517
14518 /// Set any additional parameter of the query string used in the request.
14519 /// It should be used to set parameters which are not yet available through their own
14520 /// setters.
14521 ///
14522 /// Please note that this method must not be used to set any of the known parameters
14523 /// which have their own setter method. If done anyway, the request will fail.
14524 ///
14525 /// # Additional Parameters
14526 ///
14527 /// * *$.xgafv* (query-string) - V1 error format.
14528 /// * *access_token* (query-string) - OAuth access token.
14529 /// * *alt* (query-string) - Data format for response.
14530 /// * *callback* (query-string) - JSONP
14531 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14532 /// * *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.
14533 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14534 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14535 /// * *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.
14536 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14537 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14538 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSchemaSchemaVersionGetCall<'a, C>
14539 where
14540 T: AsRef<str>,
14541 {
14542 self._additional_params
14543 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14544 self
14545 }
14546
14547 /// Identifies the authorization scope for the method you are building.
14548 ///
14549 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14550 /// [`Scope::CloudPlatform`].
14551 ///
14552 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14553 /// tokens for more than one scope.
14554 ///
14555 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14556 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14557 /// sufficient, a read-write scope will do as well.
14558 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSchemaSchemaVersionGetCall<'a, C>
14559 where
14560 St: AsRef<str>,
14561 {
14562 self._scopes.insert(String::from(scope.as_ref()));
14563 self
14564 }
14565 /// Identifies the authorization scope(s) for the method you are building.
14566 ///
14567 /// See [`Self::add_scope()`] for details.
14568 pub fn add_scopes<I, St>(
14569 mut self,
14570 scopes: I,
14571 ) -> ProjectLocationSchemaSchemaVersionGetCall<'a, C>
14572 where
14573 I: IntoIterator<Item = St>,
14574 St: AsRef<str>,
14575 {
14576 self._scopes
14577 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14578 self
14579 }
14580
14581 /// Removes all scopes, and no default scope will be used either.
14582 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14583 /// for details).
14584 pub fn clear_scopes(mut self) -> ProjectLocationSchemaSchemaVersionGetCall<'a, C> {
14585 self._scopes.clear();
14586 self
14587 }
14588}
14589
14590/// Lists SchemaVersions.
14591///
14592/// A builder for the *locations.schemas.schemaVersions.list* method supported by a *project* resource.
14593/// It is not used directly, but through a [`ProjectMethods`] instance.
14594///
14595/// # Example
14596///
14597/// Instantiate a resource method builder
14598///
14599/// ```test_harness,no_run
14600/// # extern crate hyper;
14601/// # extern crate hyper_rustls;
14602/// # extern crate google_documentai1 as documentai1;
14603/// # async fn dox() {
14604/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14605///
14606/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14607/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14608/// # .with_native_roots()
14609/// # .unwrap()
14610/// # .https_only()
14611/// # .enable_http2()
14612/// # .build();
14613///
14614/// # let executor = hyper_util::rt::TokioExecutor::new();
14615/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14616/// # secret,
14617/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14618/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14619/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14620/// # ),
14621/// # ).build().await.unwrap();
14622///
14623/// # let client = hyper_util::client::legacy::Client::builder(
14624/// # hyper_util::rt::TokioExecutor::new()
14625/// # )
14626/// # .build(
14627/// # hyper_rustls::HttpsConnectorBuilder::new()
14628/// # .with_native_roots()
14629/// # .unwrap()
14630/// # .https_or_http()
14631/// # .enable_http2()
14632/// # .build()
14633/// # );
14634/// # let mut hub = Document::new(client, auth);
14635/// // You can configure optional parameters by calling the respective setters at will, and
14636/// // execute the final call using `doit()`.
14637/// // Values shown here are possibly random and not representative !
14638/// let result = hub.projects().locations_schemas_schema_versions_list("parent")
14639/// .page_token("et")
14640/// .page_size(-76)
14641/// .doit().await;
14642/// # }
14643/// ```
14644pub struct ProjectLocationSchemaSchemaVersionListCall<'a, C>
14645where
14646 C: 'a,
14647{
14648 hub: &'a Document<C>,
14649 _parent: String,
14650 _page_token: Option<String>,
14651 _page_size: Option<i32>,
14652 _delegate: Option<&'a mut dyn common::Delegate>,
14653 _additional_params: HashMap<String, String>,
14654 _scopes: BTreeSet<String>,
14655}
14656
14657impl<'a, C> common::CallBuilder for ProjectLocationSchemaSchemaVersionListCall<'a, C> {}
14658
14659impl<'a, C> ProjectLocationSchemaSchemaVersionListCall<'a, C>
14660where
14661 C: common::Connector,
14662{
14663 /// Perform the operation you have build so far.
14664 pub async fn doit(
14665 mut self,
14666 ) -> common::Result<(
14667 common::Response,
14668 GoogleCloudDocumentaiV1ListSchemaVersionsResponse,
14669 )> {
14670 use std::borrow::Cow;
14671 use std::io::{Read, Seek};
14672
14673 use common::{url::Params, ToParts};
14674 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14675
14676 let mut dd = common::DefaultDelegate;
14677 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14678 dlg.begin(common::MethodInfo {
14679 id: "documentai.projects.locations.schemas.schemaVersions.list",
14680 http_method: hyper::Method::GET,
14681 });
14682
14683 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
14684 if self._additional_params.contains_key(field) {
14685 dlg.finished(false);
14686 return Err(common::Error::FieldClash(field));
14687 }
14688 }
14689
14690 let mut params = Params::with_capacity(5 + self._additional_params.len());
14691 params.push("parent", self._parent);
14692 if let Some(value) = self._page_token.as_ref() {
14693 params.push("pageToken", value);
14694 }
14695 if let Some(value) = self._page_size.as_ref() {
14696 params.push("pageSize", value.to_string());
14697 }
14698
14699 params.extend(self._additional_params.iter());
14700
14701 params.push("alt", "json");
14702 let mut url = self.hub._base_url.clone() + "v1/{+parent}/schemaVersions";
14703 if self._scopes.is_empty() {
14704 self._scopes
14705 .insert(Scope::CloudPlatform.as_ref().to_string());
14706 }
14707
14708 #[allow(clippy::single_element_loop)]
14709 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
14710 url = params.uri_replacement(url, param_name, find_this, true);
14711 }
14712 {
14713 let to_remove = ["parent"];
14714 params.remove_params(&to_remove);
14715 }
14716
14717 let url = params.parse_with_url(&url);
14718
14719 loop {
14720 let token = match self
14721 .hub
14722 .auth
14723 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14724 .await
14725 {
14726 Ok(token) => token,
14727 Err(e) => match dlg.token(e) {
14728 Ok(token) => token,
14729 Err(e) => {
14730 dlg.finished(false);
14731 return Err(common::Error::MissingToken(e));
14732 }
14733 },
14734 };
14735 let mut req_result = {
14736 let client = &self.hub.client;
14737 dlg.pre_request();
14738 let mut req_builder = hyper::Request::builder()
14739 .method(hyper::Method::GET)
14740 .uri(url.as_str())
14741 .header(USER_AGENT, self.hub._user_agent.clone());
14742
14743 if let Some(token) = token.as_ref() {
14744 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14745 }
14746
14747 let request = req_builder
14748 .header(CONTENT_LENGTH, 0_u64)
14749 .body(common::to_body::<String>(None));
14750
14751 client.request(request.unwrap()).await
14752 };
14753
14754 match req_result {
14755 Err(err) => {
14756 if let common::Retry::After(d) = dlg.http_error(&err) {
14757 sleep(d).await;
14758 continue;
14759 }
14760 dlg.finished(false);
14761 return Err(common::Error::HttpError(err));
14762 }
14763 Ok(res) => {
14764 let (mut parts, body) = res.into_parts();
14765 let mut body = common::Body::new(body);
14766 if !parts.status.is_success() {
14767 let bytes = common::to_bytes(body).await.unwrap_or_default();
14768 let error = serde_json::from_str(&common::to_string(&bytes));
14769 let response = common::to_response(parts, bytes.into());
14770
14771 if let common::Retry::After(d) =
14772 dlg.http_failure(&response, error.as_ref().ok())
14773 {
14774 sleep(d).await;
14775 continue;
14776 }
14777
14778 dlg.finished(false);
14779
14780 return Err(match error {
14781 Ok(value) => common::Error::BadRequest(value),
14782 _ => common::Error::Failure(response),
14783 });
14784 }
14785 let response = {
14786 let bytes = common::to_bytes(body).await.unwrap_or_default();
14787 let encoded = common::to_string(&bytes);
14788 match serde_json::from_str(&encoded) {
14789 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14790 Err(error) => {
14791 dlg.response_json_decode_error(&encoded, &error);
14792 return Err(common::Error::JsonDecodeError(
14793 encoded.to_string(),
14794 error,
14795 ));
14796 }
14797 }
14798 };
14799
14800 dlg.finished(true);
14801 return Ok(response);
14802 }
14803 }
14804 }
14805 }
14806
14807 /// Required. Format: `projects/{project}/locations/{location}/schemas/{schema}`
14808 ///
14809 /// Sets the *parent* path property to the given value.
14810 ///
14811 /// Even though the property as already been set when instantiating this call,
14812 /// we provide this method for API completeness.
14813 pub fn parent(mut self, new_value: &str) -> ProjectLocationSchemaSchemaVersionListCall<'a, C> {
14814 self._parent = new_value.to_string();
14815 self
14816 }
14817 /// Optional. We will return the SchemaVersion sorted by creation time. The page token will point to the next SchemaVersion.
14818 ///
14819 /// Sets the *page token* query property to the given value.
14820 pub fn page_token(
14821 mut self,
14822 new_value: &str,
14823 ) -> ProjectLocationSchemaSchemaVersionListCall<'a, C> {
14824 self._page_token = Some(new_value.to_string());
14825 self
14826 }
14827 /// Optional. The maximum number of SchemaVersion to return. If unspecified, at most `10` SchemaVersion will be returned. The maximum value is `20`. Values above `20` will be coerced to `20`.
14828 ///
14829 /// Sets the *page size* query property to the given value.
14830 pub fn page_size(
14831 mut self,
14832 new_value: i32,
14833 ) -> ProjectLocationSchemaSchemaVersionListCall<'a, C> {
14834 self._page_size = Some(new_value);
14835 self
14836 }
14837 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14838 /// while executing the actual API request.
14839 ///
14840 /// ````text
14841 /// It should be used to handle progress information, and to implement a certain level of resilience.
14842 /// ````
14843 ///
14844 /// Sets the *delegate* property to the given value.
14845 pub fn delegate(
14846 mut self,
14847 new_value: &'a mut dyn common::Delegate,
14848 ) -> ProjectLocationSchemaSchemaVersionListCall<'a, C> {
14849 self._delegate = Some(new_value);
14850 self
14851 }
14852
14853 /// Set any additional parameter of the query string used in the request.
14854 /// It should be used to set parameters which are not yet available through their own
14855 /// setters.
14856 ///
14857 /// Please note that this method must not be used to set any of the known parameters
14858 /// which have their own setter method. If done anyway, the request will fail.
14859 ///
14860 /// # Additional Parameters
14861 ///
14862 /// * *$.xgafv* (query-string) - V1 error format.
14863 /// * *access_token* (query-string) - OAuth access token.
14864 /// * *alt* (query-string) - Data format for response.
14865 /// * *callback* (query-string) - JSONP
14866 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14867 /// * *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.
14868 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14869 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14870 /// * *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.
14871 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14872 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14873 pub fn param<T>(
14874 mut self,
14875 name: T,
14876 value: T,
14877 ) -> ProjectLocationSchemaSchemaVersionListCall<'a, C>
14878 where
14879 T: AsRef<str>,
14880 {
14881 self._additional_params
14882 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14883 self
14884 }
14885
14886 /// Identifies the authorization scope for the method you are building.
14887 ///
14888 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14889 /// [`Scope::CloudPlatform`].
14890 ///
14891 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14892 /// tokens for more than one scope.
14893 ///
14894 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14895 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14896 /// sufficient, a read-write scope will do as well.
14897 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSchemaSchemaVersionListCall<'a, C>
14898 where
14899 St: AsRef<str>,
14900 {
14901 self._scopes.insert(String::from(scope.as_ref()));
14902 self
14903 }
14904 /// Identifies the authorization scope(s) for the method you are building.
14905 ///
14906 /// See [`Self::add_scope()`] for details.
14907 pub fn add_scopes<I, St>(
14908 mut self,
14909 scopes: I,
14910 ) -> ProjectLocationSchemaSchemaVersionListCall<'a, C>
14911 where
14912 I: IntoIterator<Item = St>,
14913 St: AsRef<str>,
14914 {
14915 self._scopes
14916 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14917 self
14918 }
14919
14920 /// Removes all scopes, and no default scope will be used either.
14921 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14922 /// for details).
14923 pub fn clear_scopes(mut self) -> ProjectLocationSchemaSchemaVersionListCall<'a, C> {
14924 self._scopes.clear();
14925 self
14926 }
14927}
14928
14929/// Updates a schema version. Editable fields are: - `display_name` - `labels`
14930///
14931/// A builder for the *locations.schemas.schemaVersions.patch* method supported by a *project* resource.
14932/// It is not used directly, but through a [`ProjectMethods`] instance.
14933///
14934/// # Example
14935///
14936/// Instantiate a resource method builder
14937///
14938/// ```test_harness,no_run
14939/// # extern crate hyper;
14940/// # extern crate hyper_rustls;
14941/// # extern crate google_documentai1 as documentai1;
14942/// use documentai1::api::GoogleCloudDocumentaiV1SchemaVersion;
14943/// # async fn dox() {
14944/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14945///
14946/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14947/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14948/// # .with_native_roots()
14949/// # .unwrap()
14950/// # .https_only()
14951/// # .enable_http2()
14952/// # .build();
14953///
14954/// # let executor = hyper_util::rt::TokioExecutor::new();
14955/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14956/// # secret,
14957/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14958/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14959/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14960/// # ),
14961/// # ).build().await.unwrap();
14962///
14963/// # let client = hyper_util::client::legacy::Client::builder(
14964/// # hyper_util::rt::TokioExecutor::new()
14965/// # )
14966/// # .build(
14967/// # hyper_rustls::HttpsConnectorBuilder::new()
14968/// # .with_native_roots()
14969/// # .unwrap()
14970/// # .https_or_http()
14971/// # .enable_http2()
14972/// # .build()
14973/// # );
14974/// # let mut hub = Document::new(client, auth);
14975/// // As the method needs a request, you would usually fill it with the desired information
14976/// // into the respective structure. Some of the parts shown here might not be applicable !
14977/// // Values shown here are possibly random and not representative !
14978/// let mut req = GoogleCloudDocumentaiV1SchemaVersion::default();
14979///
14980/// // You can configure optional parameters by calling the respective setters at will, and
14981/// // execute the final call using `doit()`.
14982/// // Values shown here are possibly random and not representative !
14983/// let result = hub.projects().locations_schemas_schema_versions_patch(req, "name")
14984/// .update_mask(FieldMask::new::<&str>(&[]))
14985/// .doit().await;
14986/// # }
14987/// ```
14988pub struct ProjectLocationSchemaSchemaVersionPatchCall<'a, C>
14989where
14990 C: 'a,
14991{
14992 hub: &'a Document<C>,
14993 _request: GoogleCloudDocumentaiV1SchemaVersion,
14994 _name: String,
14995 _update_mask: Option<common::FieldMask>,
14996 _delegate: Option<&'a mut dyn common::Delegate>,
14997 _additional_params: HashMap<String, String>,
14998 _scopes: BTreeSet<String>,
14999}
15000
15001impl<'a, C> common::CallBuilder for ProjectLocationSchemaSchemaVersionPatchCall<'a, C> {}
15002
15003impl<'a, C> ProjectLocationSchemaSchemaVersionPatchCall<'a, C>
15004where
15005 C: common::Connector,
15006{
15007 /// Perform the operation you have build so far.
15008 pub async fn doit(
15009 mut self,
15010 ) -> common::Result<(common::Response, GoogleCloudDocumentaiV1SchemaVersion)> {
15011 use std::borrow::Cow;
15012 use std::io::{Read, Seek};
15013
15014 use common::{url::Params, ToParts};
15015 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15016
15017 let mut dd = common::DefaultDelegate;
15018 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15019 dlg.begin(common::MethodInfo {
15020 id: "documentai.projects.locations.schemas.schemaVersions.patch",
15021 http_method: hyper::Method::PATCH,
15022 });
15023
15024 for &field in ["alt", "name", "updateMask"].iter() {
15025 if self._additional_params.contains_key(field) {
15026 dlg.finished(false);
15027 return Err(common::Error::FieldClash(field));
15028 }
15029 }
15030
15031 let mut params = Params::with_capacity(5 + self._additional_params.len());
15032 params.push("name", self._name);
15033 if let Some(value) = self._update_mask.as_ref() {
15034 params.push("updateMask", value.to_string());
15035 }
15036
15037 params.extend(self._additional_params.iter());
15038
15039 params.push("alt", "json");
15040 let mut url = self.hub._base_url.clone() + "v1/{+name}";
15041 if self._scopes.is_empty() {
15042 self._scopes
15043 .insert(Scope::CloudPlatform.as_ref().to_string());
15044 }
15045
15046 #[allow(clippy::single_element_loop)]
15047 for &(find_this, param_name) in [("{+name}", "name")].iter() {
15048 url = params.uri_replacement(url, param_name, find_this, true);
15049 }
15050 {
15051 let to_remove = ["name"];
15052 params.remove_params(&to_remove);
15053 }
15054
15055 let url = params.parse_with_url(&url);
15056
15057 let mut json_mime_type = mime::APPLICATION_JSON;
15058 let mut request_value_reader = {
15059 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15060 common::remove_json_null_values(&mut value);
15061 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15062 serde_json::to_writer(&mut dst, &value).unwrap();
15063 dst
15064 };
15065 let request_size = request_value_reader
15066 .seek(std::io::SeekFrom::End(0))
15067 .unwrap();
15068 request_value_reader
15069 .seek(std::io::SeekFrom::Start(0))
15070 .unwrap();
15071
15072 loop {
15073 let token = match self
15074 .hub
15075 .auth
15076 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15077 .await
15078 {
15079 Ok(token) => token,
15080 Err(e) => match dlg.token(e) {
15081 Ok(token) => token,
15082 Err(e) => {
15083 dlg.finished(false);
15084 return Err(common::Error::MissingToken(e));
15085 }
15086 },
15087 };
15088 request_value_reader
15089 .seek(std::io::SeekFrom::Start(0))
15090 .unwrap();
15091 let mut req_result = {
15092 let client = &self.hub.client;
15093 dlg.pre_request();
15094 let mut req_builder = hyper::Request::builder()
15095 .method(hyper::Method::PATCH)
15096 .uri(url.as_str())
15097 .header(USER_AGENT, self.hub._user_agent.clone());
15098
15099 if let Some(token) = token.as_ref() {
15100 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15101 }
15102
15103 let request = req_builder
15104 .header(CONTENT_TYPE, json_mime_type.to_string())
15105 .header(CONTENT_LENGTH, request_size as u64)
15106 .body(common::to_body(
15107 request_value_reader.get_ref().clone().into(),
15108 ));
15109
15110 client.request(request.unwrap()).await
15111 };
15112
15113 match req_result {
15114 Err(err) => {
15115 if let common::Retry::After(d) = dlg.http_error(&err) {
15116 sleep(d).await;
15117 continue;
15118 }
15119 dlg.finished(false);
15120 return Err(common::Error::HttpError(err));
15121 }
15122 Ok(res) => {
15123 let (mut parts, body) = res.into_parts();
15124 let mut body = common::Body::new(body);
15125 if !parts.status.is_success() {
15126 let bytes = common::to_bytes(body).await.unwrap_or_default();
15127 let error = serde_json::from_str(&common::to_string(&bytes));
15128 let response = common::to_response(parts, bytes.into());
15129
15130 if let common::Retry::After(d) =
15131 dlg.http_failure(&response, error.as_ref().ok())
15132 {
15133 sleep(d).await;
15134 continue;
15135 }
15136
15137 dlg.finished(false);
15138
15139 return Err(match error {
15140 Ok(value) => common::Error::BadRequest(value),
15141 _ => common::Error::Failure(response),
15142 });
15143 }
15144 let response = {
15145 let bytes = common::to_bytes(body).await.unwrap_or_default();
15146 let encoded = common::to_string(&bytes);
15147 match serde_json::from_str(&encoded) {
15148 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15149 Err(error) => {
15150 dlg.response_json_decode_error(&encoded, &error);
15151 return Err(common::Error::JsonDecodeError(
15152 encoded.to_string(),
15153 error,
15154 ));
15155 }
15156 }
15157 };
15158
15159 dlg.finished(true);
15160 return Ok(response);
15161 }
15162 }
15163 }
15164 }
15165
15166 ///
15167 /// Sets the *request* property to the given value.
15168 ///
15169 /// Even though the property as already been set when instantiating this call,
15170 /// we provide this method for API completeness.
15171 pub fn request(
15172 mut self,
15173 new_value: GoogleCloudDocumentaiV1SchemaVersion,
15174 ) -> ProjectLocationSchemaSchemaVersionPatchCall<'a, C> {
15175 self._request = new_value;
15176 self
15177 }
15178 /// Identifier. The resource name of the SchemaVersion. Format: `projects/{project}/locations/{location}/schemas/{schema}/schemaVersions/{schema_version}`
15179 ///
15180 /// Sets the *name* path property to the given value.
15181 ///
15182 /// Even though the property as already been set when instantiating this call,
15183 /// we provide this method for API completeness.
15184 pub fn name(mut self, new_value: &str) -> ProjectLocationSchemaSchemaVersionPatchCall<'a, C> {
15185 self._name = new_value.to_string();
15186 self
15187 }
15188 /// Optional. The update mask to apply to the resource. **Note:** Only the following fields can be updated: - display_name. - labels.
15189 ///
15190 /// Sets the *update mask* query property to the given value.
15191 pub fn update_mask(
15192 mut self,
15193 new_value: common::FieldMask,
15194 ) -> ProjectLocationSchemaSchemaVersionPatchCall<'a, C> {
15195 self._update_mask = Some(new_value);
15196 self
15197 }
15198 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15199 /// while executing the actual API request.
15200 ///
15201 /// ````text
15202 /// It should be used to handle progress information, and to implement a certain level of resilience.
15203 /// ````
15204 ///
15205 /// Sets the *delegate* property to the given value.
15206 pub fn delegate(
15207 mut self,
15208 new_value: &'a mut dyn common::Delegate,
15209 ) -> ProjectLocationSchemaSchemaVersionPatchCall<'a, C> {
15210 self._delegate = Some(new_value);
15211 self
15212 }
15213
15214 /// Set any additional parameter of the query string used in the request.
15215 /// It should be used to set parameters which are not yet available through their own
15216 /// setters.
15217 ///
15218 /// Please note that this method must not be used to set any of the known parameters
15219 /// which have their own setter method. If done anyway, the request will fail.
15220 ///
15221 /// # Additional Parameters
15222 ///
15223 /// * *$.xgafv* (query-string) - V1 error format.
15224 /// * *access_token* (query-string) - OAuth access token.
15225 /// * *alt* (query-string) - Data format for response.
15226 /// * *callback* (query-string) - JSONP
15227 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15228 /// * *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.
15229 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15230 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15231 /// * *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.
15232 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15233 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15234 pub fn param<T>(
15235 mut self,
15236 name: T,
15237 value: T,
15238 ) -> ProjectLocationSchemaSchemaVersionPatchCall<'a, C>
15239 where
15240 T: AsRef<str>,
15241 {
15242 self._additional_params
15243 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15244 self
15245 }
15246
15247 /// Identifies the authorization scope for the method you are building.
15248 ///
15249 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15250 /// [`Scope::CloudPlatform`].
15251 ///
15252 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15253 /// tokens for more than one scope.
15254 ///
15255 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15256 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15257 /// sufficient, a read-write scope will do as well.
15258 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSchemaSchemaVersionPatchCall<'a, C>
15259 where
15260 St: AsRef<str>,
15261 {
15262 self._scopes.insert(String::from(scope.as_ref()));
15263 self
15264 }
15265 /// Identifies the authorization scope(s) for the method you are building.
15266 ///
15267 /// See [`Self::add_scope()`] for details.
15268 pub fn add_scopes<I, St>(
15269 mut self,
15270 scopes: I,
15271 ) -> ProjectLocationSchemaSchemaVersionPatchCall<'a, C>
15272 where
15273 I: IntoIterator<Item = St>,
15274 St: AsRef<str>,
15275 {
15276 self._scopes
15277 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15278 self
15279 }
15280
15281 /// Removes all scopes, and no default scope will be used either.
15282 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15283 /// for details).
15284 pub fn clear_scopes(mut self) -> ProjectLocationSchemaSchemaVersionPatchCall<'a, C> {
15285 self._scopes.clear();
15286 self
15287 }
15288}
15289
15290/// Creates a schema.
15291///
15292/// A builder for the *locations.schemas.create* method supported by a *project* resource.
15293/// It is not used directly, but through a [`ProjectMethods`] instance.
15294///
15295/// # Example
15296///
15297/// Instantiate a resource method builder
15298///
15299/// ```test_harness,no_run
15300/// # extern crate hyper;
15301/// # extern crate hyper_rustls;
15302/// # extern crate google_documentai1 as documentai1;
15303/// use documentai1::api::GoogleCloudDocumentaiV1NextSchema;
15304/// # async fn dox() {
15305/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15306///
15307/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15308/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15309/// # .with_native_roots()
15310/// # .unwrap()
15311/// # .https_only()
15312/// # .enable_http2()
15313/// # .build();
15314///
15315/// # let executor = hyper_util::rt::TokioExecutor::new();
15316/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15317/// # secret,
15318/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15319/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15320/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15321/// # ),
15322/// # ).build().await.unwrap();
15323///
15324/// # let client = hyper_util::client::legacy::Client::builder(
15325/// # hyper_util::rt::TokioExecutor::new()
15326/// # )
15327/// # .build(
15328/// # hyper_rustls::HttpsConnectorBuilder::new()
15329/// # .with_native_roots()
15330/// # .unwrap()
15331/// # .https_or_http()
15332/// # .enable_http2()
15333/// # .build()
15334/// # );
15335/// # let mut hub = Document::new(client, auth);
15336/// // As the method needs a request, you would usually fill it with the desired information
15337/// // into the respective structure. Some of the parts shown here might not be applicable !
15338/// // Values shown here are possibly random and not representative !
15339/// let mut req = GoogleCloudDocumentaiV1NextSchema::default();
15340///
15341/// // You can configure optional parameters by calling the respective setters at will, and
15342/// // execute the final call using `doit()`.
15343/// // Values shown here are possibly random and not representative !
15344/// let result = hub.projects().locations_schemas_create(req, "parent")
15345/// .doit().await;
15346/// # }
15347/// ```
15348pub struct ProjectLocationSchemaCreateCall<'a, C>
15349where
15350 C: 'a,
15351{
15352 hub: &'a Document<C>,
15353 _request: GoogleCloudDocumentaiV1NextSchema,
15354 _parent: String,
15355 _delegate: Option<&'a mut dyn common::Delegate>,
15356 _additional_params: HashMap<String, String>,
15357 _scopes: BTreeSet<String>,
15358}
15359
15360impl<'a, C> common::CallBuilder for ProjectLocationSchemaCreateCall<'a, C> {}
15361
15362impl<'a, C> ProjectLocationSchemaCreateCall<'a, C>
15363where
15364 C: common::Connector,
15365{
15366 /// Perform the operation you have build so far.
15367 pub async fn doit(
15368 mut self,
15369 ) -> common::Result<(common::Response, GoogleCloudDocumentaiV1NextSchema)> {
15370 use std::borrow::Cow;
15371 use std::io::{Read, Seek};
15372
15373 use common::{url::Params, ToParts};
15374 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15375
15376 let mut dd = common::DefaultDelegate;
15377 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15378 dlg.begin(common::MethodInfo {
15379 id: "documentai.projects.locations.schemas.create",
15380 http_method: hyper::Method::POST,
15381 });
15382
15383 for &field in ["alt", "parent"].iter() {
15384 if self._additional_params.contains_key(field) {
15385 dlg.finished(false);
15386 return Err(common::Error::FieldClash(field));
15387 }
15388 }
15389
15390 let mut params = Params::with_capacity(4 + self._additional_params.len());
15391 params.push("parent", self._parent);
15392
15393 params.extend(self._additional_params.iter());
15394
15395 params.push("alt", "json");
15396 let mut url = self.hub._base_url.clone() + "v1/{+parent}/schemas";
15397 if self._scopes.is_empty() {
15398 self._scopes
15399 .insert(Scope::CloudPlatform.as_ref().to_string());
15400 }
15401
15402 #[allow(clippy::single_element_loop)]
15403 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
15404 url = params.uri_replacement(url, param_name, find_this, true);
15405 }
15406 {
15407 let to_remove = ["parent"];
15408 params.remove_params(&to_remove);
15409 }
15410
15411 let url = params.parse_with_url(&url);
15412
15413 let mut json_mime_type = mime::APPLICATION_JSON;
15414 let mut request_value_reader = {
15415 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15416 common::remove_json_null_values(&mut value);
15417 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15418 serde_json::to_writer(&mut dst, &value).unwrap();
15419 dst
15420 };
15421 let request_size = request_value_reader
15422 .seek(std::io::SeekFrom::End(0))
15423 .unwrap();
15424 request_value_reader
15425 .seek(std::io::SeekFrom::Start(0))
15426 .unwrap();
15427
15428 loop {
15429 let token = match self
15430 .hub
15431 .auth
15432 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15433 .await
15434 {
15435 Ok(token) => token,
15436 Err(e) => match dlg.token(e) {
15437 Ok(token) => token,
15438 Err(e) => {
15439 dlg.finished(false);
15440 return Err(common::Error::MissingToken(e));
15441 }
15442 },
15443 };
15444 request_value_reader
15445 .seek(std::io::SeekFrom::Start(0))
15446 .unwrap();
15447 let mut req_result = {
15448 let client = &self.hub.client;
15449 dlg.pre_request();
15450 let mut req_builder = hyper::Request::builder()
15451 .method(hyper::Method::POST)
15452 .uri(url.as_str())
15453 .header(USER_AGENT, self.hub._user_agent.clone());
15454
15455 if let Some(token) = token.as_ref() {
15456 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15457 }
15458
15459 let request = req_builder
15460 .header(CONTENT_TYPE, json_mime_type.to_string())
15461 .header(CONTENT_LENGTH, request_size as u64)
15462 .body(common::to_body(
15463 request_value_reader.get_ref().clone().into(),
15464 ));
15465
15466 client.request(request.unwrap()).await
15467 };
15468
15469 match req_result {
15470 Err(err) => {
15471 if let common::Retry::After(d) = dlg.http_error(&err) {
15472 sleep(d).await;
15473 continue;
15474 }
15475 dlg.finished(false);
15476 return Err(common::Error::HttpError(err));
15477 }
15478 Ok(res) => {
15479 let (mut parts, body) = res.into_parts();
15480 let mut body = common::Body::new(body);
15481 if !parts.status.is_success() {
15482 let bytes = common::to_bytes(body).await.unwrap_or_default();
15483 let error = serde_json::from_str(&common::to_string(&bytes));
15484 let response = common::to_response(parts, bytes.into());
15485
15486 if let common::Retry::After(d) =
15487 dlg.http_failure(&response, error.as_ref().ok())
15488 {
15489 sleep(d).await;
15490 continue;
15491 }
15492
15493 dlg.finished(false);
15494
15495 return Err(match error {
15496 Ok(value) => common::Error::BadRequest(value),
15497 _ => common::Error::Failure(response),
15498 });
15499 }
15500 let response = {
15501 let bytes = common::to_bytes(body).await.unwrap_or_default();
15502 let encoded = common::to_string(&bytes);
15503 match serde_json::from_str(&encoded) {
15504 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15505 Err(error) => {
15506 dlg.response_json_decode_error(&encoded, &error);
15507 return Err(common::Error::JsonDecodeError(
15508 encoded.to_string(),
15509 error,
15510 ));
15511 }
15512 }
15513 };
15514
15515 dlg.finished(true);
15516 return Ok(response);
15517 }
15518 }
15519 }
15520 }
15521
15522 ///
15523 /// Sets the *request* property to the given value.
15524 ///
15525 /// Even though the property as already been set when instantiating this call,
15526 /// we provide this method for API completeness.
15527 pub fn request(
15528 mut self,
15529 new_value: GoogleCloudDocumentaiV1NextSchema,
15530 ) -> ProjectLocationSchemaCreateCall<'a, C> {
15531 self._request = new_value;
15532 self
15533 }
15534 /// Required. The parent (project and location) under which to create the Schema. Format: `projects/{project}/locations/{location}`
15535 ///
15536 /// Sets the *parent* path property to the given value.
15537 ///
15538 /// Even though the property as already been set when instantiating this call,
15539 /// we provide this method for API completeness.
15540 pub fn parent(mut self, new_value: &str) -> ProjectLocationSchemaCreateCall<'a, C> {
15541 self._parent = new_value.to_string();
15542 self
15543 }
15544 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15545 /// while executing the actual API request.
15546 ///
15547 /// ````text
15548 /// It should be used to handle progress information, and to implement a certain level of resilience.
15549 /// ````
15550 ///
15551 /// Sets the *delegate* property to the given value.
15552 pub fn delegate(
15553 mut self,
15554 new_value: &'a mut dyn common::Delegate,
15555 ) -> ProjectLocationSchemaCreateCall<'a, C> {
15556 self._delegate = Some(new_value);
15557 self
15558 }
15559
15560 /// Set any additional parameter of the query string used in the request.
15561 /// It should be used to set parameters which are not yet available through their own
15562 /// setters.
15563 ///
15564 /// Please note that this method must not be used to set any of the known parameters
15565 /// which have their own setter method. If done anyway, the request will fail.
15566 ///
15567 /// # Additional Parameters
15568 ///
15569 /// * *$.xgafv* (query-string) - V1 error format.
15570 /// * *access_token* (query-string) - OAuth access token.
15571 /// * *alt* (query-string) - Data format for response.
15572 /// * *callback* (query-string) - JSONP
15573 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15574 /// * *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.
15575 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15576 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15577 /// * *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.
15578 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15579 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15580 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSchemaCreateCall<'a, C>
15581 where
15582 T: AsRef<str>,
15583 {
15584 self._additional_params
15585 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15586 self
15587 }
15588
15589 /// Identifies the authorization scope for the method you are building.
15590 ///
15591 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15592 /// [`Scope::CloudPlatform`].
15593 ///
15594 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15595 /// tokens for more than one scope.
15596 ///
15597 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15598 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15599 /// sufficient, a read-write scope will do as well.
15600 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSchemaCreateCall<'a, C>
15601 where
15602 St: AsRef<str>,
15603 {
15604 self._scopes.insert(String::from(scope.as_ref()));
15605 self
15606 }
15607 /// Identifies the authorization scope(s) for the method you are building.
15608 ///
15609 /// See [`Self::add_scope()`] for details.
15610 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSchemaCreateCall<'a, C>
15611 where
15612 I: IntoIterator<Item = St>,
15613 St: AsRef<str>,
15614 {
15615 self._scopes
15616 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15617 self
15618 }
15619
15620 /// Removes all scopes, and no default scope will be used either.
15621 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15622 /// for details).
15623 pub fn clear_scopes(mut self) -> ProjectLocationSchemaCreateCall<'a, C> {
15624 self._scopes.clear();
15625 self
15626 }
15627}
15628
15629/// Deletes a schema.
15630///
15631/// A builder for the *locations.schemas.delete* method supported by a *project* resource.
15632/// It is not used directly, but through a [`ProjectMethods`] instance.
15633///
15634/// # Example
15635///
15636/// Instantiate a resource method builder
15637///
15638/// ```test_harness,no_run
15639/// # extern crate hyper;
15640/// # extern crate hyper_rustls;
15641/// # extern crate google_documentai1 as documentai1;
15642/// # async fn dox() {
15643/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15644///
15645/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15646/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15647/// # .with_native_roots()
15648/// # .unwrap()
15649/// # .https_only()
15650/// # .enable_http2()
15651/// # .build();
15652///
15653/// # let executor = hyper_util::rt::TokioExecutor::new();
15654/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15655/// # secret,
15656/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15657/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15658/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15659/// # ),
15660/// # ).build().await.unwrap();
15661///
15662/// # let client = hyper_util::client::legacy::Client::builder(
15663/// # hyper_util::rt::TokioExecutor::new()
15664/// # )
15665/// # .build(
15666/// # hyper_rustls::HttpsConnectorBuilder::new()
15667/// # .with_native_roots()
15668/// # .unwrap()
15669/// # .https_or_http()
15670/// # .enable_http2()
15671/// # .build()
15672/// # );
15673/// # let mut hub = Document::new(client, auth);
15674/// // You can configure optional parameters by calling the respective setters at will, and
15675/// // execute the final call using `doit()`.
15676/// // Values shown here are possibly random and not representative !
15677/// let result = hub.projects().locations_schemas_delete("name")
15678/// .force(false)
15679/// .doit().await;
15680/// # }
15681/// ```
15682pub struct ProjectLocationSchemaDeleteCall<'a, C>
15683where
15684 C: 'a,
15685{
15686 hub: &'a Document<C>,
15687 _name: String,
15688 _force: Option<bool>,
15689 _delegate: Option<&'a mut dyn common::Delegate>,
15690 _additional_params: HashMap<String, String>,
15691 _scopes: BTreeSet<String>,
15692}
15693
15694impl<'a, C> common::CallBuilder for ProjectLocationSchemaDeleteCall<'a, C> {}
15695
15696impl<'a, C> ProjectLocationSchemaDeleteCall<'a, C>
15697where
15698 C: common::Connector,
15699{
15700 /// Perform the operation you have build so far.
15701 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
15702 use std::borrow::Cow;
15703 use std::io::{Read, Seek};
15704
15705 use common::{url::Params, ToParts};
15706 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15707
15708 let mut dd = common::DefaultDelegate;
15709 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15710 dlg.begin(common::MethodInfo {
15711 id: "documentai.projects.locations.schemas.delete",
15712 http_method: hyper::Method::DELETE,
15713 });
15714
15715 for &field in ["alt", "name", "force"].iter() {
15716 if self._additional_params.contains_key(field) {
15717 dlg.finished(false);
15718 return Err(common::Error::FieldClash(field));
15719 }
15720 }
15721
15722 let mut params = Params::with_capacity(4 + self._additional_params.len());
15723 params.push("name", self._name);
15724 if let Some(value) = self._force.as_ref() {
15725 params.push("force", value.to_string());
15726 }
15727
15728 params.extend(self._additional_params.iter());
15729
15730 params.push("alt", "json");
15731 let mut url = self.hub._base_url.clone() + "v1/{+name}";
15732 if self._scopes.is_empty() {
15733 self._scopes
15734 .insert(Scope::CloudPlatform.as_ref().to_string());
15735 }
15736
15737 #[allow(clippy::single_element_loop)]
15738 for &(find_this, param_name) in [("{+name}", "name")].iter() {
15739 url = params.uri_replacement(url, param_name, find_this, true);
15740 }
15741 {
15742 let to_remove = ["name"];
15743 params.remove_params(&to_remove);
15744 }
15745
15746 let url = params.parse_with_url(&url);
15747
15748 loop {
15749 let token = match self
15750 .hub
15751 .auth
15752 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15753 .await
15754 {
15755 Ok(token) => token,
15756 Err(e) => match dlg.token(e) {
15757 Ok(token) => token,
15758 Err(e) => {
15759 dlg.finished(false);
15760 return Err(common::Error::MissingToken(e));
15761 }
15762 },
15763 };
15764 let mut req_result = {
15765 let client = &self.hub.client;
15766 dlg.pre_request();
15767 let mut req_builder = hyper::Request::builder()
15768 .method(hyper::Method::DELETE)
15769 .uri(url.as_str())
15770 .header(USER_AGENT, self.hub._user_agent.clone());
15771
15772 if let Some(token) = token.as_ref() {
15773 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15774 }
15775
15776 let request = req_builder
15777 .header(CONTENT_LENGTH, 0_u64)
15778 .body(common::to_body::<String>(None));
15779
15780 client.request(request.unwrap()).await
15781 };
15782
15783 match req_result {
15784 Err(err) => {
15785 if let common::Retry::After(d) = dlg.http_error(&err) {
15786 sleep(d).await;
15787 continue;
15788 }
15789 dlg.finished(false);
15790 return Err(common::Error::HttpError(err));
15791 }
15792 Ok(res) => {
15793 let (mut parts, body) = res.into_parts();
15794 let mut body = common::Body::new(body);
15795 if !parts.status.is_success() {
15796 let bytes = common::to_bytes(body).await.unwrap_or_default();
15797 let error = serde_json::from_str(&common::to_string(&bytes));
15798 let response = common::to_response(parts, bytes.into());
15799
15800 if let common::Retry::After(d) =
15801 dlg.http_failure(&response, error.as_ref().ok())
15802 {
15803 sleep(d).await;
15804 continue;
15805 }
15806
15807 dlg.finished(false);
15808
15809 return Err(match error {
15810 Ok(value) => common::Error::BadRequest(value),
15811 _ => common::Error::Failure(response),
15812 });
15813 }
15814 let response = {
15815 let bytes = common::to_bytes(body).await.unwrap_or_default();
15816 let encoded = common::to_string(&bytes);
15817 match serde_json::from_str(&encoded) {
15818 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15819 Err(error) => {
15820 dlg.response_json_decode_error(&encoded, &error);
15821 return Err(common::Error::JsonDecodeError(
15822 encoded.to_string(),
15823 error,
15824 ));
15825 }
15826 }
15827 };
15828
15829 dlg.finished(true);
15830 return Ok(response);
15831 }
15832 }
15833 }
15834 }
15835
15836 /// Required. The name of the Schema to be deleted. Format: `projects/{project}/locations/{location}/schemas/{schema}`
15837 ///
15838 /// Sets the *name* path property to the given value.
15839 ///
15840 /// Even though the property as already been set when instantiating this call,
15841 /// we provide this method for API completeness.
15842 pub fn name(mut self, new_value: &str) -> ProjectLocationSchemaDeleteCall<'a, C> {
15843 self._name = new_value.to_string();
15844 self
15845 }
15846 /// Optional. If set to true, any child resources of this Schema will also be deleted. (Otherwise, the request will only work if the Schema has no child resources.)
15847 ///
15848 /// Sets the *force* query property to the given value.
15849 pub fn force(mut self, new_value: bool) -> ProjectLocationSchemaDeleteCall<'a, C> {
15850 self._force = Some(new_value);
15851 self
15852 }
15853 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15854 /// while executing the actual API request.
15855 ///
15856 /// ````text
15857 /// It should be used to handle progress information, and to implement a certain level of resilience.
15858 /// ````
15859 ///
15860 /// Sets the *delegate* property to the given value.
15861 pub fn delegate(
15862 mut self,
15863 new_value: &'a mut dyn common::Delegate,
15864 ) -> ProjectLocationSchemaDeleteCall<'a, C> {
15865 self._delegate = Some(new_value);
15866 self
15867 }
15868
15869 /// Set any additional parameter of the query string used in the request.
15870 /// It should be used to set parameters which are not yet available through their own
15871 /// setters.
15872 ///
15873 /// Please note that this method must not be used to set any of the known parameters
15874 /// which have their own setter method. If done anyway, the request will fail.
15875 ///
15876 /// # Additional Parameters
15877 ///
15878 /// * *$.xgafv* (query-string) - V1 error format.
15879 /// * *access_token* (query-string) - OAuth access token.
15880 /// * *alt* (query-string) - Data format for response.
15881 /// * *callback* (query-string) - JSONP
15882 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15883 /// * *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.
15884 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15885 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15886 /// * *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.
15887 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15888 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15889 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSchemaDeleteCall<'a, C>
15890 where
15891 T: AsRef<str>,
15892 {
15893 self._additional_params
15894 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15895 self
15896 }
15897
15898 /// Identifies the authorization scope for the method you are building.
15899 ///
15900 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15901 /// [`Scope::CloudPlatform`].
15902 ///
15903 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15904 /// tokens for more than one scope.
15905 ///
15906 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15907 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15908 /// sufficient, a read-write scope will do as well.
15909 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSchemaDeleteCall<'a, C>
15910 where
15911 St: AsRef<str>,
15912 {
15913 self._scopes.insert(String::from(scope.as_ref()));
15914 self
15915 }
15916 /// Identifies the authorization scope(s) for the method you are building.
15917 ///
15918 /// See [`Self::add_scope()`] for details.
15919 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSchemaDeleteCall<'a, C>
15920 where
15921 I: IntoIterator<Item = St>,
15922 St: AsRef<str>,
15923 {
15924 self._scopes
15925 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15926 self
15927 }
15928
15929 /// Removes all scopes, and no default scope will be used either.
15930 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15931 /// for details).
15932 pub fn clear_scopes(mut self) -> ProjectLocationSchemaDeleteCall<'a, C> {
15933 self._scopes.clear();
15934 self
15935 }
15936}
15937
15938/// Gets a schema.
15939///
15940/// A builder for the *locations.schemas.get* method supported by a *project* resource.
15941/// It is not used directly, but through a [`ProjectMethods`] instance.
15942///
15943/// # Example
15944///
15945/// Instantiate a resource method builder
15946///
15947/// ```test_harness,no_run
15948/// # extern crate hyper;
15949/// # extern crate hyper_rustls;
15950/// # extern crate google_documentai1 as documentai1;
15951/// # async fn dox() {
15952/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15953///
15954/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15955/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15956/// # .with_native_roots()
15957/// # .unwrap()
15958/// # .https_only()
15959/// # .enable_http2()
15960/// # .build();
15961///
15962/// # let executor = hyper_util::rt::TokioExecutor::new();
15963/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15964/// # secret,
15965/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15966/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15967/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15968/// # ),
15969/// # ).build().await.unwrap();
15970///
15971/// # let client = hyper_util::client::legacy::Client::builder(
15972/// # hyper_util::rt::TokioExecutor::new()
15973/// # )
15974/// # .build(
15975/// # hyper_rustls::HttpsConnectorBuilder::new()
15976/// # .with_native_roots()
15977/// # .unwrap()
15978/// # .https_or_http()
15979/// # .enable_http2()
15980/// # .build()
15981/// # );
15982/// # let mut hub = Document::new(client, auth);
15983/// // You can configure optional parameters by calling the respective setters at will, and
15984/// // execute the final call using `doit()`.
15985/// // Values shown here are possibly random and not representative !
15986/// let result = hub.projects().locations_schemas_get("name")
15987/// .doit().await;
15988/// # }
15989/// ```
15990pub struct ProjectLocationSchemaGetCall<'a, C>
15991where
15992 C: 'a,
15993{
15994 hub: &'a Document<C>,
15995 _name: String,
15996 _delegate: Option<&'a mut dyn common::Delegate>,
15997 _additional_params: HashMap<String, String>,
15998 _scopes: BTreeSet<String>,
15999}
16000
16001impl<'a, C> common::CallBuilder for ProjectLocationSchemaGetCall<'a, C> {}
16002
16003impl<'a, C> ProjectLocationSchemaGetCall<'a, C>
16004where
16005 C: common::Connector,
16006{
16007 /// Perform the operation you have build so far.
16008 pub async fn doit(
16009 mut self,
16010 ) -> common::Result<(common::Response, GoogleCloudDocumentaiV1NextSchema)> {
16011 use std::borrow::Cow;
16012 use std::io::{Read, Seek};
16013
16014 use common::{url::Params, ToParts};
16015 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16016
16017 let mut dd = common::DefaultDelegate;
16018 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16019 dlg.begin(common::MethodInfo {
16020 id: "documentai.projects.locations.schemas.get",
16021 http_method: hyper::Method::GET,
16022 });
16023
16024 for &field in ["alt", "name"].iter() {
16025 if self._additional_params.contains_key(field) {
16026 dlg.finished(false);
16027 return Err(common::Error::FieldClash(field));
16028 }
16029 }
16030
16031 let mut params = Params::with_capacity(3 + self._additional_params.len());
16032 params.push("name", self._name);
16033
16034 params.extend(self._additional_params.iter());
16035
16036 params.push("alt", "json");
16037 let mut url = self.hub._base_url.clone() + "v1/{+name}";
16038 if self._scopes.is_empty() {
16039 self._scopes
16040 .insert(Scope::CloudPlatform.as_ref().to_string());
16041 }
16042
16043 #[allow(clippy::single_element_loop)]
16044 for &(find_this, param_name) in [("{+name}", "name")].iter() {
16045 url = params.uri_replacement(url, param_name, find_this, true);
16046 }
16047 {
16048 let to_remove = ["name"];
16049 params.remove_params(&to_remove);
16050 }
16051
16052 let url = params.parse_with_url(&url);
16053
16054 loop {
16055 let token = match self
16056 .hub
16057 .auth
16058 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16059 .await
16060 {
16061 Ok(token) => token,
16062 Err(e) => match dlg.token(e) {
16063 Ok(token) => token,
16064 Err(e) => {
16065 dlg.finished(false);
16066 return Err(common::Error::MissingToken(e));
16067 }
16068 },
16069 };
16070 let mut req_result = {
16071 let client = &self.hub.client;
16072 dlg.pre_request();
16073 let mut req_builder = hyper::Request::builder()
16074 .method(hyper::Method::GET)
16075 .uri(url.as_str())
16076 .header(USER_AGENT, self.hub._user_agent.clone());
16077
16078 if let Some(token) = token.as_ref() {
16079 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16080 }
16081
16082 let request = req_builder
16083 .header(CONTENT_LENGTH, 0_u64)
16084 .body(common::to_body::<String>(None));
16085
16086 client.request(request.unwrap()).await
16087 };
16088
16089 match req_result {
16090 Err(err) => {
16091 if let common::Retry::After(d) = dlg.http_error(&err) {
16092 sleep(d).await;
16093 continue;
16094 }
16095 dlg.finished(false);
16096 return Err(common::Error::HttpError(err));
16097 }
16098 Ok(res) => {
16099 let (mut parts, body) = res.into_parts();
16100 let mut body = common::Body::new(body);
16101 if !parts.status.is_success() {
16102 let bytes = common::to_bytes(body).await.unwrap_or_default();
16103 let error = serde_json::from_str(&common::to_string(&bytes));
16104 let response = common::to_response(parts, bytes.into());
16105
16106 if let common::Retry::After(d) =
16107 dlg.http_failure(&response, error.as_ref().ok())
16108 {
16109 sleep(d).await;
16110 continue;
16111 }
16112
16113 dlg.finished(false);
16114
16115 return Err(match error {
16116 Ok(value) => common::Error::BadRequest(value),
16117 _ => common::Error::Failure(response),
16118 });
16119 }
16120 let response = {
16121 let bytes = common::to_bytes(body).await.unwrap_or_default();
16122 let encoded = common::to_string(&bytes);
16123 match serde_json::from_str(&encoded) {
16124 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16125 Err(error) => {
16126 dlg.response_json_decode_error(&encoded, &error);
16127 return Err(common::Error::JsonDecodeError(
16128 encoded.to_string(),
16129 error,
16130 ));
16131 }
16132 }
16133 };
16134
16135 dlg.finished(true);
16136 return Ok(response);
16137 }
16138 }
16139 }
16140 }
16141
16142 /// Required. The name of the Schema to get. Format: `projects/{project}/locations/{location}/schemas/{schema}`
16143 ///
16144 /// Sets the *name* path property to the given value.
16145 ///
16146 /// Even though the property as already been set when instantiating this call,
16147 /// we provide this method for API completeness.
16148 pub fn name(mut self, new_value: &str) -> ProjectLocationSchemaGetCall<'a, C> {
16149 self._name = new_value.to_string();
16150 self
16151 }
16152 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16153 /// while executing the actual API request.
16154 ///
16155 /// ````text
16156 /// It should be used to handle progress information, and to implement a certain level of resilience.
16157 /// ````
16158 ///
16159 /// Sets the *delegate* property to the given value.
16160 pub fn delegate(
16161 mut self,
16162 new_value: &'a mut dyn common::Delegate,
16163 ) -> ProjectLocationSchemaGetCall<'a, C> {
16164 self._delegate = Some(new_value);
16165 self
16166 }
16167
16168 /// Set any additional parameter of the query string used in the request.
16169 /// It should be used to set parameters which are not yet available through their own
16170 /// setters.
16171 ///
16172 /// Please note that this method must not be used to set any of the known parameters
16173 /// which have their own setter method. If done anyway, the request will fail.
16174 ///
16175 /// # Additional Parameters
16176 ///
16177 /// * *$.xgafv* (query-string) - V1 error format.
16178 /// * *access_token* (query-string) - OAuth access token.
16179 /// * *alt* (query-string) - Data format for response.
16180 /// * *callback* (query-string) - JSONP
16181 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16182 /// * *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.
16183 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16184 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16185 /// * *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.
16186 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16187 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16188 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSchemaGetCall<'a, C>
16189 where
16190 T: AsRef<str>,
16191 {
16192 self._additional_params
16193 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16194 self
16195 }
16196
16197 /// Identifies the authorization scope for the method you are building.
16198 ///
16199 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16200 /// [`Scope::CloudPlatform`].
16201 ///
16202 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16203 /// tokens for more than one scope.
16204 ///
16205 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16206 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16207 /// sufficient, a read-write scope will do as well.
16208 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSchemaGetCall<'a, C>
16209 where
16210 St: AsRef<str>,
16211 {
16212 self._scopes.insert(String::from(scope.as_ref()));
16213 self
16214 }
16215 /// Identifies the authorization scope(s) for the method you are building.
16216 ///
16217 /// See [`Self::add_scope()`] for details.
16218 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSchemaGetCall<'a, C>
16219 where
16220 I: IntoIterator<Item = St>,
16221 St: AsRef<str>,
16222 {
16223 self._scopes
16224 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16225 self
16226 }
16227
16228 /// Removes all scopes, and no default scope will be used either.
16229 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16230 /// for details).
16231 pub fn clear_scopes(mut self) -> ProjectLocationSchemaGetCall<'a, C> {
16232 self._scopes.clear();
16233 self
16234 }
16235}
16236
16237/// Lists Schemas.
16238///
16239/// A builder for the *locations.schemas.list* method supported by a *project* resource.
16240/// It is not used directly, but through a [`ProjectMethods`] instance.
16241///
16242/// # Example
16243///
16244/// Instantiate a resource method builder
16245///
16246/// ```test_harness,no_run
16247/// # extern crate hyper;
16248/// # extern crate hyper_rustls;
16249/// # extern crate google_documentai1 as documentai1;
16250/// # async fn dox() {
16251/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16252///
16253/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16254/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16255/// # .with_native_roots()
16256/// # .unwrap()
16257/// # .https_only()
16258/// # .enable_http2()
16259/// # .build();
16260///
16261/// # let executor = hyper_util::rt::TokioExecutor::new();
16262/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16263/// # secret,
16264/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16265/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16266/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16267/// # ),
16268/// # ).build().await.unwrap();
16269///
16270/// # let client = hyper_util::client::legacy::Client::builder(
16271/// # hyper_util::rt::TokioExecutor::new()
16272/// # )
16273/// # .build(
16274/// # hyper_rustls::HttpsConnectorBuilder::new()
16275/// # .with_native_roots()
16276/// # .unwrap()
16277/// # .https_or_http()
16278/// # .enable_http2()
16279/// # .build()
16280/// # );
16281/// # let mut hub = Document::new(client, auth);
16282/// // You can configure optional parameters by calling the respective setters at will, and
16283/// // execute the final call using `doit()`.
16284/// // Values shown here are possibly random and not representative !
16285/// let result = hub.projects().locations_schemas_list("parent")
16286/// .page_token("et")
16287/// .page_size(-22)
16288/// .doit().await;
16289/// # }
16290/// ```
16291pub struct ProjectLocationSchemaListCall<'a, C>
16292where
16293 C: 'a,
16294{
16295 hub: &'a Document<C>,
16296 _parent: String,
16297 _page_token: Option<String>,
16298 _page_size: Option<i32>,
16299 _delegate: Option<&'a mut dyn common::Delegate>,
16300 _additional_params: HashMap<String, String>,
16301 _scopes: BTreeSet<String>,
16302}
16303
16304impl<'a, C> common::CallBuilder for ProjectLocationSchemaListCall<'a, C> {}
16305
16306impl<'a, C> ProjectLocationSchemaListCall<'a, C>
16307where
16308 C: common::Connector,
16309{
16310 /// Perform the operation you have build so far.
16311 pub async fn doit(
16312 mut self,
16313 ) -> common::Result<(common::Response, GoogleCloudDocumentaiV1ListSchemasResponse)> {
16314 use std::borrow::Cow;
16315 use std::io::{Read, Seek};
16316
16317 use common::{url::Params, ToParts};
16318 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16319
16320 let mut dd = common::DefaultDelegate;
16321 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16322 dlg.begin(common::MethodInfo {
16323 id: "documentai.projects.locations.schemas.list",
16324 http_method: hyper::Method::GET,
16325 });
16326
16327 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
16328 if self._additional_params.contains_key(field) {
16329 dlg.finished(false);
16330 return Err(common::Error::FieldClash(field));
16331 }
16332 }
16333
16334 let mut params = Params::with_capacity(5 + self._additional_params.len());
16335 params.push("parent", self._parent);
16336 if let Some(value) = self._page_token.as_ref() {
16337 params.push("pageToken", value);
16338 }
16339 if let Some(value) = self._page_size.as_ref() {
16340 params.push("pageSize", value.to_string());
16341 }
16342
16343 params.extend(self._additional_params.iter());
16344
16345 params.push("alt", "json");
16346 let mut url = self.hub._base_url.clone() + "v1/{+parent}/schemas";
16347 if self._scopes.is_empty() {
16348 self._scopes
16349 .insert(Scope::CloudPlatform.as_ref().to_string());
16350 }
16351
16352 #[allow(clippy::single_element_loop)]
16353 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
16354 url = params.uri_replacement(url, param_name, find_this, true);
16355 }
16356 {
16357 let to_remove = ["parent"];
16358 params.remove_params(&to_remove);
16359 }
16360
16361 let url = params.parse_with_url(&url);
16362
16363 loop {
16364 let token = match self
16365 .hub
16366 .auth
16367 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16368 .await
16369 {
16370 Ok(token) => token,
16371 Err(e) => match dlg.token(e) {
16372 Ok(token) => token,
16373 Err(e) => {
16374 dlg.finished(false);
16375 return Err(common::Error::MissingToken(e));
16376 }
16377 },
16378 };
16379 let mut req_result = {
16380 let client = &self.hub.client;
16381 dlg.pre_request();
16382 let mut req_builder = hyper::Request::builder()
16383 .method(hyper::Method::GET)
16384 .uri(url.as_str())
16385 .header(USER_AGENT, self.hub._user_agent.clone());
16386
16387 if let Some(token) = token.as_ref() {
16388 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16389 }
16390
16391 let request = req_builder
16392 .header(CONTENT_LENGTH, 0_u64)
16393 .body(common::to_body::<String>(None));
16394
16395 client.request(request.unwrap()).await
16396 };
16397
16398 match req_result {
16399 Err(err) => {
16400 if let common::Retry::After(d) = dlg.http_error(&err) {
16401 sleep(d).await;
16402 continue;
16403 }
16404 dlg.finished(false);
16405 return Err(common::Error::HttpError(err));
16406 }
16407 Ok(res) => {
16408 let (mut parts, body) = res.into_parts();
16409 let mut body = common::Body::new(body);
16410 if !parts.status.is_success() {
16411 let bytes = common::to_bytes(body).await.unwrap_or_default();
16412 let error = serde_json::from_str(&common::to_string(&bytes));
16413 let response = common::to_response(parts, bytes.into());
16414
16415 if let common::Retry::After(d) =
16416 dlg.http_failure(&response, error.as_ref().ok())
16417 {
16418 sleep(d).await;
16419 continue;
16420 }
16421
16422 dlg.finished(false);
16423
16424 return Err(match error {
16425 Ok(value) => common::Error::BadRequest(value),
16426 _ => common::Error::Failure(response),
16427 });
16428 }
16429 let response = {
16430 let bytes = common::to_bytes(body).await.unwrap_or_default();
16431 let encoded = common::to_string(&bytes);
16432 match serde_json::from_str(&encoded) {
16433 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16434 Err(error) => {
16435 dlg.response_json_decode_error(&encoded, &error);
16436 return Err(common::Error::JsonDecodeError(
16437 encoded.to_string(),
16438 error,
16439 ));
16440 }
16441 }
16442 };
16443
16444 dlg.finished(true);
16445 return Ok(response);
16446 }
16447 }
16448 }
16449 }
16450
16451 /// Required. Format: `projects/{project}/locations/{location}`
16452 ///
16453 /// Sets the *parent* path property to the given value.
16454 ///
16455 /// Even though the property as already been set when instantiating this call,
16456 /// we provide this method for API completeness.
16457 pub fn parent(mut self, new_value: &str) -> ProjectLocationSchemaListCall<'a, C> {
16458 self._parent = new_value.to_string();
16459 self
16460 }
16461 /// Optional. We will return the schema groups sorted by creation time. The page token will point to the next Schema.
16462 ///
16463 /// Sets the *page token* query property to the given value.
16464 pub fn page_token(mut self, new_value: &str) -> ProjectLocationSchemaListCall<'a, C> {
16465 self._page_token = Some(new_value.to_string());
16466 self
16467 }
16468 /// Optional. The maximum number of schema groups to return. If unspecified, at most `10` Schema will be returned. The maximum value is `20`. Values above `20` will be coerced to `20`.
16469 ///
16470 /// Sets the *page size* query property to the given value.
16471 pub fn page_size(mut self, new_value: i32) -> ProjectLocationSchemaListCall<'a, C> {
16472 self._page_size = Some(new_value);
16473 self
16474 }
16475 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16476 /// while executing the actual API request.
16477 ///
16478 /// ````text
16479 /// It should be used to handle progress information, and to implement a certain level of resilience.
16480 /// ````
16481 ///
16482 /// Sets the *delegate* property to the given value.
16483 pub fn delegate(
16484 mut self,
16485 new_value: &'a mut dyn common::Delegate,
16486 ) -> ProjectLocationSchemaListCall<'a, C> {
16487 self._delegate = Some(new_value);
16488 self
16489 }
16490
16491 /// Set any additional parameter of the query string used in the request.
16492 /// It should be used to set parameters which are not yet available through their own
16493 /// setters.
16494 ///
16495 /// Please note that this method must not be used to set any of the known parameters
16496 /// which have their own setter method. If done anyway, the request will fail.
16497 ///
16498 /// # Additional Parameters
16499 ///
16500 /// * *$.xgafv* (query-string) - V1 error format.
16501 /// * *access_token* (query-string) - OAuth access token.
16502 /// * *alt* (query-string) - Data format for response.
16503 /// * *callback* (query-string) - JSONP
16504 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16505 /// * *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.
16506 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16507 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16508 /// * *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.
16509 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16510 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16511 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSchemaListCall<'a, C>
16512 where
16513 T: AsRef<str>,
16514 {
16515 self._additional_params
16516 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16517 self
16518 }
16519
16520 /// Identifies the authorization scope for the method you are building.
16521 ///
16522 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16523 /// [`Scope::CloudPlatform`].
16524 ///
16525 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16526 /// tokens for more than one scope.
16527 ///
16528 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16529 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16530 /// sufficient, a read-write scope will do as well.
16531 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSchemaListCall<'a, C>
16532 where
16533 St: AsRef<str>,
16534 {
16535 self._scopes.insert(String::from(scope.as_ref()));
16536 self
16537 }
16538 /// Identifies the authorization scope(s) for the method you are building.
16539 ///
16540 /// See [`Self::add_scope()`] for details.
16541 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSchemaListCall<'a, C>
16542 where
16543 I: IntoIterator<Item = St>,
16544 St: AsRef<str>,
16545 {
16546 self._scopes
16547 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16548 self
16549 }
16550
16551 /// Removes all scopes, and no default scope will be used either.
16552 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16553 /// for details).
16554 pub fn clear_scopes(mut self) -> ProjectLocationSchemaListCall<'a, C> {
16555 self._scopes.clear();
16556 self
16557 }
16558}
16559
16560/// Updates a schema. Editable fields are: - `display_name` - `labels`
16561///
16562/// A builder for the *locations.schemas.patch* method supported by a *project* resource.
16563/// It is not used directly, but through a [`ProjectMethods`] instance.
16564///
16565/// # Example
16566///
16567/// Instantiate a resource method builder
16568///
16569/// ```test_harness,no_run
16570/// # extern crate hyper;
16571/// # extern crate hyper_rustls;
16572/// # extern crate google_documentai1 as documentai1;
16573/// use documentai1::api::GoogleCloudDocumentaiV1NextSchema;
16574/// # async fn dox() {
16575/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16576///
16577/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16578/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16579/// # .with_native_roots()
16580/// # .unwrap()
16581/// # .https_only()
16582/// # .enable_http2()
16583/// # .build();
16584///
16585/// # let executor = hyper_util::rt::TokioExecutor::new();
16586/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16587/// # secret,
16588/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16589/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16590/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16591/// # ),
16592/// # ).build().await.unwrap();
16593///
16594/// # let client = hyper_util::client::legacy::Client::builder(
16595/// # hyper_util::rt::TokioExecutor::new()
16596/// # )
16597/// # .build(
16598/// # hyper_rustls::HttpsConnectorBuilder::new()
16599/// # .with_native_roots()
16600/// # .unwrap()
16601/// # .https_or_http()
16602/// # .enable_http2()
16603/// # .build()
16604/// # );
16605/// # let mut hub = Document::new(client, auth);
16606/// // As the method needs a request, you would usually fill it with the desired information
16607/// // into the respective structure. Some of the parts shown here might not be applicable !
16608/// // Values shown here are possibly random and not representative !
16609/// let mut req = GoogleCloudDocumentaiV1NextSchema::default();
16610///
16611/// // You can configure optional parameters by calling the respective setters at will, and
16612/// // execute the final call using `doit()`.
16613/// // Values shown here are possibly random and not representative !
16614/// let result = hub.projects().locations_schemas_patch(req, "name")
16615/// .update_mask(FieldMask::new::<&str>(&[]))
16616/// .doit().await;
16617/// # }
16618/// ```
16619pub struct ProjectLocationSchemaPatchCall<'a, C>
16620where
16621 C: 'a,
16622{
16623 hub: &'a Document<C>,
16624 _request: GoogleCloudDocumentaiV1NextSchema,
16625 _name: String,
16626 _update_mask: Option<common::FieldMask>,
16627 _delegate: Option<&'a mut dyn common::Delegate>,
16628 _additional_params: HashMap<String, String>,
16629 _scopes: BTreeSet<String>,
16630}
16631
16632impl<'a, C> common::CallBuilder for ProjectLocationSchemaPatchCall<'a, C> {}
16633
16634impl<'a, C> ProjectLocationSchemaPatchCall<'a, C>
16635where
16636 C: common::Connector,
16637{
16638 /// Perform the operation you have build so far.
16639 pub async fn doit(
16640 mut self,
16641 ) -> common::Result<(common::Response, GoogleCloudDocumentaiV1NextSchema)> {
16642 use std::borrow::Cow;
16643 use std::io::{Read, Seek};
16644
16645 use common::{url::Params, ToParts};
16646 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16647
16648 let mut dd = common::DefaultDelegate;
16649 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16650 dlg.begin(common::MethodInfo {
16651 id: "documentai.projects.locations.schemas.patch",
16652 http_method: hyper::Method::PATCH,
16653 });
16654
16655 for &field in ["alt", "name", "updateMask"].iter() {
16656 if self._additional_params.contains_key(field) {
16657 dlg.finished(false);
16658 return Err(common::Error::FieldClash(field));
16659 }
16660 }
16661
16662 let mut params = Params::with_capacity(5 + self._additional_params.len());
16663 params.push("name", self._name);
16664 if let Some(value) = self._update_mask.as_ref() {
16665 params.push("updateMask", value.to_string());
16666 }
16667
16668 params.extend(self._additional_params.iter());
16669
16670 params.push("alt", "json");
16671 let mut url = self.hub._base_url.clone() + "v1/{+name}";
16672 if self._scopes.is_empty() {
16673 self._scopes
16674 .insert(Scope::CloudPlatform.as_ref().to_string());
16675 }
16676
16677 #[allow(clippy::single_element_loop)]
16678 for &(find_this, param_name) in [("{+name}", "name")].iter() {
16679 url = params.uri_replacement(url, param_name, find_this, true);
16680 }
16681 {
16682 let to_remove = ["name"];
16683 params.remove_params(&to_remove);
16684 }
16685
16686 let url = params.parse_with_url(&url);
16687
16688 let mut json_mime_type = mime::APPLICATION_JSON;
16689 let mut request_value_reader = {
16690 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16691 common::remove_json_null_values(&mut value);
16692 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16693 serde_json::to_writer(&mut dst, &value).unwrap();
16694 dst
16695 };
16696 let request_size = request_value_reader
16697 .seek(std::io::SeekFrom::End(0))
16698 .unwrap();
16699 request_value_reader
16700 .seek(std::io::SeekFrom::Start(0))
16701 .unwrap();
16702
16703 loop {
16704 let token = match self
16705 .hub
16706 .auth
16707 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16708 .await
16709 {
16710 Ok(token) => token,
16711 Err(e) => match dlg.token(e) {
16712 Ok(token) => token,
16713 Err(e) => {
16714 dlg.finished(false);
16715 return Err(common::Error::MissingToken(e));
16716 }
16717 },
16718 };
16719 request_value_reader
16720 .seek(std::io::SeekFrom::Start(0))
16721 .unwrap();
16722 let mut req_result = {
16723 let client = &self.hub.client;
16724 dlg.pre_request();
16725 let mut req_builder = hyper::Request::builder()
16726 .method(hyper::Method::PATCH)
16727 .uri(url.as_str())
16728 .header(USER_AGENT, self.hub._user_agent.clone());
16729
16730 if let Some(token) = token.as_ref() {
16731 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16732 }
16733
16734 let request = req_builder
16735 .header(CONTENT_TYPE, json_mime_type.to_string())
16736 .header(CONTENT_LENGTH, request_size as u64)
16737 .body(common::to_body(
16738 request_value_reader.get_ref().clone().into(),
16739 ));
16740
16741 client.request(request.unwrap()).await
16742 };
16743
16744 match req_result {
16745 Err(err) => {
16746 if let common::Retry::After(d) = dlg.http_error(&err) {
16747 sleep(d).await;
16748 continue;
16749 }
16750 dlg.finished(false);
16751 return Err(common::Error::HttpError(err));
16752 }
16753 Ok(res) => {
16754 let (mut parts, body) = res.into_parts();
16755 let mut body = common::Body::new(body);
16756 if !parts.status.is_success() {
16757 let bytes = common::to_bytes(body).await.unwrap_or_default();
16758 let error = serde_json::from_str(&common::to_string(&bytes));
16759 let response = common::to_response(parts, bytes.into());
16760
16761 if let common::Retry::After(d) =
16762 dlg.http_failure(&response, error.as_ref().ok())
16763 {
16764 sleep(d).await;
16765 continue;
16766 }
16767
16768 dlg.finished(false);
16769
16770 return Err(match error {
16771 Ok(value) => common::Error::BadRequest(value),
16772 _ => common::Error::Failure(response),
16773 });
16774 }
16775 let response = {
16776 let bytes = common::to_bytes(body).await.unwrap_or_default();
16777 let encoded = common::to_string(&bytes);
16778 match serde_json::from_str(&encoded) {
16779 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16780 Err(error) => {
16781 dlg.response_json_decode_error(&encoded, &error);
16782 return Err(common::Error::JsonDecodeError(
16783 encoded.to_string(),
16784 error,
16785 ));
16786 }
16787 }
16788 };
16789
16790 dlg.finished(true);
16791 return Ok(response);
16792 }
16793 }
16794 }
16795 }
16796
16797 ///
16798 /// Sets the *request* property to the given value.
16799 ///
16800 /// Even though the property as already been set when instantiating this call,
16801 /// we provide this method for API completeness.
16802 pub fn request(
16803 mut self,
16804 new_value: GoogleCloudDocumentaiV1NextSchema,
16805 ) -> ProjectLocationSchemaPatchCall<'a, C> {
16806 self._request = new_value;
16807 self
16808 }
16809 /// Identifier. The resource name of the Schema. Format: `projects/{project}/locations/{location}/schemas/{schema}`
16810 ///
16811 /// Sets the *name* path property to the given value.
16812 ///
16813 /// Even though the property as already been set when instantiating this call,
16814 /// we provide this method for API completeness.
16815 pub fn name(mut self, new_value: &str) -> ProjectLocationSchemaPatchCall<'a, C> {
16816 self._name = new_value.to_string();
16817 self
16818 }
16819 /// Optional. The update mask to apply to the resource. **Note:** Only the following fields can be updated: - display_name. - labels.
16820 ///
16821 /// Sets the *update mask* query property to the given value.
16822 pub fn update_mask(
16823 mut self,
16824 new_value: common::FieldMask,
16825 ) -> ProjectLocationSchemaPatchCall<'a, C> {
16826 self._update_mask = Some(new_value);
16827 self
16828 }
16829 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16830 /// while executing the actual API request.
16831 ///
16832 /// ````text
16833 /// It should be used to handle progress information, and to implement a certain level of resilience.
16834 /// ````
16835 ///
16836 /// Sets the *delegate* property to the given value.
16837 pub fn delegate(
16838 mut self,
16839 new_value: &'a mut dyn common::Delegate,
16840 ) -> ProjectLocationSchemaPatchCall<'a, C> {
16841 self._delegate = Some(new_value);
16842 self
16843 }
16844
16845 /// Set any additional parameter of the query string used in the request.
16846 /// It should be used to set parameters which are not yet available through their own
16847 /// setters.
16848 ///
16849 /// Please note that this method must not be used to set any of the known parameters
16850 /// which have their own setter method. If done anyway, the request will fail.
16851 ///
16852 /// # Additional Parameters
16853 ///
16854 /// * *$.xgafv* (query-string) - V1 error format.
16855 /// * *access_token* (query-string) - OAuth access token.
16856 /// * *alt* (query-string) - Data format for response.
16857 /// * *callback* (query-string) - JSONP
16858 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16859 /// * *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.
16860 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16861 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16862 /// * *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.
16863 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16864 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16865 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSchemaPatchCall<'a, C>
16866 where
16867 T: AsRef<str>,
16868 {
16869 self._additional_params
16870 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16871 self
16872 }
16873
16874 /// Identifies the authorization scope for the method you are building.
16875 ///
16876 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16877 /// [`Scope::CloudPlatform`].
16878 ///
16879 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16880 /// tokens for more than one scope.
16881 ///
16882 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16883 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16884 /// sufficient, a read-write scope will do as well.
16885 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSchemaPatchCall<'a, C>
16886 where
16887 St: AsRef<str>,
16888 {
16889 self._scopes.insert(String::from(scope.as_ref()));
16890 self
16891 }
16892 /// Identifies the authorization scope(s) for the method you are building.
16893 ///
16894 /// See [`Self::add_scope()`] for details.
16895 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSchemaPatchCall<'a, C>
16896 where
16897 I: IntoIterator<Item = St>,
16898 St: AsRef<str>,
16899 {
16900 self._scopes
16901 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16902 self
16903 }
16904
16905 /// Removes all scopes, and no default scope will be used either.
16906 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16907 /// for details).
16908 pub fn clear_scopes(mut self) -> ProjectLocationSchemaPatchCall<'a, C> {
16909 self._scopes.clear();
16910 self
16911 }
16912}
16913
16914/// Fetches processor types. Note that we don't use ListProcessorTypes here, because it isn't paginated.
16915///
16916/// A builder for the *locations.fetchProcessorTypes* method supported by a *project* resource.
16917/// It is not used directly, but through a [`ProjectMethods`] instance.
16918///
16919/// # Example
16920///
16921/// Instantiate a resource method builder
16922///
16923/// ```test_harness,no_run
16924/// # extern crate hyper;
16925/// # extern crate hyper_rustls;
16926/// # extern crate google_documentai1 as documentai1;
16927/// # async fn dox() {
16928/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16929///
16930/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16931/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16932/// # .with_native_roots()
16933/// # .unwrap()
16934/// # .https_only()
16935/// # .enable_http2()
16936/// # .build();
16937///
16938/// # let executor = hyper_util::rt::TokioExecutor::new();
16939/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16940/// # secret,
16941/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16942/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16943/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16944/// # ),
16945/// # ).build().await.unwrap();
16946///
16947/// # let client = hyper_util::client::legacy::Client::builder(
16948/// # hyper_util::rt::TokioExecutor::new()
16949/// # )
16950/// # .build(
16951/// # hyper_rustls::HttpsConnectorBuilder::new()
16952/// # .with_native_roots()
16953/// # .unwrap()
16954/// # .https_or_http()
16955/// # .enable_http2()
16956/// # .build()
16957/// # );
16958/// # let mut hub = Document::new(client, auth);
16959/// // You can configure optional parameters by calling the respective setters at will, and
16960/// // execute the final call using `doit()`.
16961/// // Values shown here are possibly random and not representative !
16962/// let result = hub.projects().locations_fetch_processor_types("parent")
16963/// .doit().await;
16964/// # }
16965/// ```
16966pub struct ProjectLocationFetchProcessorTypeCall<'a, C>
16967where
16968 C: 'a,
16969{
16970 hub: &'a Document<C>,
16971 _parent: String,
16972 _delegate: Option<&'a mut dyn common::Delegate>,
16973 _additional_params: HashMap<String, String>,
16974 _scopes: BTreeSet<String>,
16975}
16976
16977impl<'a, C> common::CallBuilder for ProjectLocationFetchProcessorTypeCall<'a, C> {}
16978
16979impl<'a, C> ProjectLocationFetchProcessorTypeCall<'a, C>
16980where
16981 C: common::Connector,
16982{
16983 /// Perform the operation you have build so far.
16984 pub async fn doit(
16985 mut self,
16986 ) -> common::Result<(
16987 common::Response,
16988 GoogleCloudDocumentaiV1FetchProcessorTypesResponse,
16989 )> {
16990 use std::borrow::Cow;
16991 use std::io::{Read, Seek};
16992
16993 use common::{url::Params, ToParts};
16994 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16995
16996 let mut dd = common::DefaultDelegate;
16997 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16998 dlg.begin(common::MethodInfo {
16999 id: "documentai.projects.locations.fetchProcessorTypes",
17000 http_method: hyper::Method::GET,
17001 });
17002
17003 for &field in ["alt", "parent"].iter() {
17004 if self._additional_params.contains_key(field) {
17005 dlg.finished(false);
17006 return Err(common::Error::FieldClash(field));
17007 }
17008 }
17009
17010 let mut params = Params::with_capacity(3 + self._additional_params.len());
17011 params.push("parent", self._parent);
17012
17013 params.extend(self._additional_params.iter());
17014
17015 params.push("alt", "json");
17016 let mut url = self.hub._base_url.clone() + "v1/{+parent}:fetchProcessorTypes";
17017 if self._scopes.is_empty() {
17018 self._scopes
17019 .insert(Scope::CloudPlatform.as_ref().to_string());
17020 }
17021
17022 #[allow(clippy::single_element_loop)]
17023 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
17024 url = params.uri_replacement(url, param_name, find_this, true);
17025 }
17026 {
17027 let to_remove = ["parent"];
17028 params.remove_params(&to_remove);
17029 }
17030
17031 let url = params.parse_with_url(&url);
17032
17033 loop {
17034 let token = match self
17035 .hub
17036 .auth
17037 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17038 .await
17039 {
17040 Ok(token) => token,
17041 Err(e) => match dlg.token(e) {
17042 Ok(token) => token,
17043 Err(e) => {
17044 dlg.finished(false);
17045 return Err(common::Error::MissingToken(e));
17046 }
17047 },
17048 };
17049 let mut req_result = {
17050 let client = &self.hub.client;
17051 dlg.pre_request();
17052 let mut req_builder = hyper::Request::builder()
17053 .method(hyper::Method::GET)
17054 .uri(url.as_str())
17055 .header(USER_AGENT, self.hub._user_agent.clone());
17056
17057 if let Some(token) = token.as_ref() {
17058 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17059 }
17060
17061 let request = req_builder
17062 .header(CONTENT_LENGTH, 0_u64)
17063 .body(common::to_body::<String>(None));
17064
17065 client.request(request.unwrap()).await
17066 };
17067
17068 match req_result {
17069 Err(err) => {
17070 if let common::Retry::After(d) = dlg.http_error(&err) {
17071 sleep(d).await;
17072 continue;
17073 }
17074 dlg.finished(false);
17075 return Err(common::Error::HttpError(err));
17076 }
17077 Ok(res) => {
17078 let (mut parts, body) = res.into_parts();
17079 let mut body = common::Body::new(body);
17080 if !parts.status.is_success() {
17081 let bytes = common::to_bytes(body).await.unwrap_or_default();
17082 let error = serde_json::from_str(&common::to_string(&bytes));
17083 let response = common::to_response(parts, bytes.into());
17084
17085 if let common::Retry::After(d) =
17086 dlg.http_failure(&response, error.as_ref().ok())
17087 {
17088 sleep(d).await;
17089 continue;
17090 }
17091
17092 dlg.finished(false);
17093
17094 return Err(match error {
17095 Ok(value) => common::Error::BadRequest(value),
17096 _ => common::Error::Failure(response),
17097 });
17098 }
17099 let response = {
17100 let bytes = common::to_bytes(body).await.unwrap_or_default();
17101 let encoded = common::to_string(&bytes);
17102 match serde_json::from_str(&encoded) {
17103 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17104 Err(error) => {
17105 dlg.response_json_decode_error(&encoded, &error);
17106 return Err(common::Error::JsonDecodeError(
17107 encoded.to_string(),
17108 error,
17109 ));
17110 }
17111 }
17112 };
17113
17114 dlg.finished(true);
17115 return Ok(response);
17116 }
17117 }
17118 }
17119 }
17120
17121 /// Required. The location of processor types to list. Format: `projects/{project}/locations/{location}`.
17122 ///
17123 /// Sets the *parent* path property to the given value.
17124 ///
17125 /// Even though the property as already been set when instantiating this call,
17126 /// we provide this method for API completeness.
17127 pub fn parent(mut self, new_value: &str) -> ProjectLocationFetchProcessorTypeCall<'a, C> {
17128 self._parent = new_value.to_string();
17129 self
17130 }
17131 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17132 /// while executing the actual API request.
17133 ///
17134 /// ````text
17135 /// It should be used to handle progress information, and to implement a certain level of resilience.
17136 /// ````
17137 ///
17138 /// Sets the *delegate* property to the given value.
17139 pub fn delegate(
17140 mut self,
17141 new_value: &'a mut dyn common::Delegate,
17142 ) -> ProjectLocationFetchProcessorTypeCall<'a, C> {
17143 self._delegate = Some(new_value);
17144 self
17145 }
17146
17147 /// Set any additional parameter of the query string used in the request.
17148 /// It should be used to set parameters which are not yet available through their own
17149 /// setters.
17150 ///
17151 /// Please note that this method must not be used to set any of the known parameters
17152 /// which have their own setter method. If done anyway, the request will fail.
17153 ///
17154 /// # Additional Parameters
17155 ///
17156 /// * *$.xgafv* (query-string) - V1 error format.
17157 /// * *access_token* (query-string) - OAuth access token.
17158 /// * *alt* (query-string) - Data format for response.
17159 /// * *callback* (query-string) - JSONP
17160 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17161 /// * *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.
17162 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17163 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17164 /// * *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.
17165 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17166 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17167 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationFetchProcessorTypeCall<'a, C>
17168 where
17169 T: AsRef<str>,
17170 {
17171 self._additional_params
17172 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17173 self
17174 }
17175
17176 /// Identifies the authorization scope for the method you are building.
17177 ///
17178 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17179 /// [`Scope::CloudPlatform`].
17180 ///
17181 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17182 /// tokens for more than one scope.
17183 ///
17184 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17185 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17186 /// sufficient, a read-write scope will do as well.
17187 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationFetchProcessorTypeCall<'a, C>
17188 where
17189 St: AsRef<str>,
17190 {
17191 self._scopes.insert(String::from(scope.as_ref()));
17192 self
17193 }
17194 /// Identifies the authorization scope(s) for the method you are building.
17195 ///
17196 /// See [`Self::add_scope()`] for details.
17197 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationFetchProcessorTypeCall<'a, C>
17198 where
17199 I: IntoIterator<Item = St>,
17200 St: AsRef<str>,
17201 {
17202 self._scopes
17203 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17204 self
17205 }
17206
17207 /// Removes all scopes, and no default scope will be used either.
17208 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17209 /// for details).
17210 pub fn clear_scopes(mut self) -> ProjectLocationFetchProcessorTypeCall<'a, C> {
17211 self._scopes.clear();
17212 self
17213 }
17214}
17215
17216/// Gets information about a location.
17217///
17218/// A builder for the *locations.get* method supported by a *project* resource.
17219/// It is not used directly, but through a [`ProjectMethods`] instance.
17220///
17221/// # Example
17222///
17223/// Instantiate a resource method builder
17224///
17225/// ```test_harness,no_run
17226/// # extern crate hyper;
17227/// # extern crate hyper_rustls;
17228/// # extern crate google_documentai1 as documentai1;
17229/// # async fn dox() {
17230/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17231///
17232/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17233/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17234/// # .with_native_roots()
17235/// # .unwrap()
17236/// # .https_only()
17237/// # .enable_http2()
17238/// # .build();
17239///
17240/// # let executor = hyper_util::rt::TokioExecutor::new();
17241/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17242/// # secret,
17243/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17244/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17245/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17246/// # ),
17247/// # ).build().await.unwrap();
17248///
17249/// # let client = hyper_util::client::legacy::Client::builder(
17250/// # hyper_util::rt::TokioExecutor::new()
17251/// # )
17252/// # .build(
17253/// # hyper_rustls::HttpsConnectorBuilder::new()
17254/// # .with_native_roots()
17255/// # .unwrap()
17256/// # .https_or_http()
17257/// # .enable_http2()
17258/// # .build()
17259/// # );
17260/// # let mut hub = Document::new(client, auth);
17261/// // You can configure optional parameters by calling the respective setters at will, and
17262/// // execute the final call using `doit()`.
17263/// // Values shown here are possibly random and not representative !
17264/// let result = hub.projects().locations_get("name")
17265/// .doit().await;
17266/// # }
17267/// ```
17268pub struct ProjectLocationGetCall<'a, C>
17269where
17270 C: 'a,
17271{
17272 hub: &'a Document<C>,
17273 _name: String,
17274 _delegate: Option<&'a mut dyn common::Delegate>,
17275 _additional_params: HashMap<String, String>,
17276 _scopes: BTreeSet<String>,
17277}
17278
17279impl<'a, C> common::CallBuilder for ProjectLocationGetCall<'a, C> {}
17280
17281impl<'a, C> ProjectLocationGetCall<'a, C>
17282where
17283 C: common::Connector,
17284{
17285 /// Perform the operation you have build so far.
17286 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleCloudLocationLocation)> {
17287 use std::borrow::Cow;
17288 use std::io::{Read, Seek};
17289
17290 use common::{url::Params, ToParts};
17291 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17292
17293 let mut dd = common::DefaultDelegate;
17294 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17295 dlg.begin(common::MethodInfo {
17296 id: "documentai.projects.locations.get",
17297 http_method: hyper::Method::GET,
17298 });
17299
17300 for &field in ["alt", "name"].iter() {
17301 if self._additional_params.contains_key(field) {
17302 dlg.finished(false);
17303 return Err(common::Error::FieldClash(field));
17304 }
17305 }
17306
17307 let mut params = Params::with_capacity(3 + self._additional_params.len());
17308 params.push("name", self._name);
17309
17310 params.extend(self._additional_params.iter());
17311
17312 params.push("alt", "json");
17313 let mut url = self.hub._base_url.clone() + "v1/{+name}";
17314 if self._scopes.is_empty() {
17315 self._scopes
17316 .insert(Scope::CloudPlatform.as_ref().to_string());
17317 }
17318
17319 #[allow(clippy::single_element_loop)]
17320 for &(find_this, param_name) in [("{+name}", "name")].iter() {
17321 url = params.uri_replacement(url, param_name, find_this, true);
17322 }
17323 {
17324 let to_remove = ["name"];
17325 params.remove_params(&to_remove);
17326 }
17327
17328 let url = params.parse_with_url(&url);
17329
17330 loop {
17331 let token = match self
17332 .hub
17333 .auth
17334 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17335 .await
17336 {
17337 Ok(token) => token,
17338 Err(e) => match dlg.token(e) {
17339 Ok(token) => token,
17340 Err(e) => {
17341 dlg.finished(false);
17342 return Err(common::Error::MissingToken(e));
17343 }
17344 },
17345 };
17346 let mut req_result = {
17347 let client = &self.hub.client;
17348 dlg.pre_request();
17349 let mut req_builder = hyper::Request::builder()
17350 .method(hyper::Method::GET)
17351 .uri(url.as_str())
17352 .header(USER_AGENT, self.hub._user_agent.clone());
17353
17354 if let Some(token) = token.as_ref() {
17355 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17356 }
17357
17358 let request = req_builder
17359 .header(CONTENT_LENGTH, 0_u64)
17360 .body(common::to_body::<String>(None));
17361
17362 client.request(request.unwrap()).await
17363 };
17364
17365 match req_result {
17366 Err(err) => {
17367 if let common::Retry::After(d) = dlg.http_error(&err) {
17368 sleep(d).await;
17369 continue;
17370 }
17371 dlg.finished(false);
17372 return Err(common::Error::HttpError(err));
17373 }
17374 Ok(res) => {
17375 let (mut parts, body) = res.into_parts();
17376 let mut body = common::Body::new(body);
17377 if !parts.status.is_success() {
17378 let bytes = common::to_bytes(body).await.unwrap_or_default();
17379 let error = serde_json::from_str(&common::to_string(&bytes));
17380 let response = common::to_response(parts, bytes.into());
17381
17382 if let common::Retry::After(d) =
17383 dlg.http_failure(&response, error.as_ref().ok())
17384 {
17385 sleep(d).await;
17386 continue;
17387 }
17388
17389 dlg.finished(false);
17390
17391 return Err(match error {
17392 Ok(value) => common::Error::BadRequest(value),
17393 _ => common::Error::Failure(response),
17394 });
17395 }
17396 let response = {
17397 let bytes = common::to_bytes(body).await.unwrap_or_default();
17398 let encoded = common::to_string(&bytes);
17399 match serde_json::from_str(&encoded) {
17400 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17401 Err(error) => {
17402 dlg.response_json_decode_error(&encoded, &error);
17403 return Err(common::Error::JsonDecodeError(
17404 encoded.to_string(),
17405 error,
17406 ));
17407 }
17408 }
17409 };
17410
17411 dlg.finished(true);
17412 return Ok(response);
17413 }
17414 }
17415 }
17416 }
17417
17418 /// Resource name for the location.
17419 ///
17420 /// Sets the *name* path property to the given value.
17421 ///
17422 /// Even though the property as already been set when instantiating this call,
17423 /// we provide this method for API completeness.
17424 pub fn name(mut self, new_value: &str) -> ProjectLocationGetCall<'a, C> {
17425 self._name = new_value.to_string();
17426 self
17427 }
17428 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17429 /// while executing the actual API request.
17430 ///
17431 /// ````text
17432 /// It should be used to handle progress information, and to implement a certain level of resilience.
17433 /// ````
17434 ///
17435 /// Sets the *delegate* property to the given value.
17436 pub fn delegate(
17437 mut self,
17438 new_value: &'a mut dyn common::Delegate,
17439 ) -> ProjectLocationGetCall<'a, C> {
17440 self._delegate = Some(new_value);
17441 self
17442 }
17443
17444 /// Set any additional parameter of the query string used in the request.
17445 /// It should be used to set parameters which are not yet available through their own
17446 /// setters.
17447 ///
17448 /// Please note that this method must not be used to set any of the known parameters
17449 /// which have their own setter method. If done anyway, the request will fail.
17450 ///
17451 /// # Additional Parameters
17452 ///
17453 /// * *$.xgafv* (query-string) - V1 error format.
17454 /// * *access_token* (query-string) - OAuth access token.
17455 /// * *alt* (query-string) - Data format for response.
17456 /// * *callback* (query-string) - JSONP
17457 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17458 /// * *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.
17459 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17460 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17461 /// * *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.
17462 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17463 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17464 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCall<'a, C>
17465 where
17466 T: AsRef<str>,
17467 {
17468 self._additional_params
17469 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17470 self
17471 }
17472
17473 /// Identifies the authorization scope for the method you are building.
17474 ///
17475 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17476 /// [`Scope::CloudPlatform`].
17477 ///
17478 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17479 /// tokens for more than one scope.
17480 ///
17481 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17482 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17483 /// sufficient, a read-write scope will do as well.
17484 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCall<'a, C>
17485 where
17486 St: AsRef<str>,
17487 {
17488 self._scopes.insert(String::from(scope.as_ref()));
17489 self
17490 }
17491 /// Identifies the authorization scope(s) for the method you are building.
17492 ///
17493 /// See [`Self::add_scope()`] for details.
17494 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCall<'a, C>
17495 where
17496 I: IntoIterator<Item = St>,
17497 St: AsRef<str>,
17498 {
17499 self._scopes
17500 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17501 self
17502 }
17503
17504 /// Removes all scopes, and no default scope will be used either.
17505 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17506 /// for details).
17507 pub fn clear_scopes(mut self) -> ProjectLocationGetCall<'a, C> {
17508 self._scopes.clear();
17509 self
17510 }
17511}
17512
17513/// Lists information about the supported locations for this service.
17514///
17515/// A builder for the *locations.list* method supported by a *project* resource.
17516/// It is not used directly, but through a [`ProjectMethods`] instance.
17517///
17518/// # Example
17519///
17520/// Instantiate a resource method builder
17521///
17522/// ```test_harness,no_run
17523/// # extern crate hyper;
17524/// # extern crate hyper_rustls;
17525/// # extern crate google_documentai1 as documentai1;
17526/// # async fn dox() {
17527/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17528///
17529/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17530/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17531/// # .with_native_roots()
17532/// # .unwrap()
17533/// # .https_only()
17534/// # .enable_http2()
17535/// # .build();
17536///
17537/// # let executor = hyper_util::rt::TokioExecutor::new();
17538/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17539/// # secret,
17540/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17541/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17542/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17543/// # ),
17544/// # ).build().await.unwrap();
17545///
17546/// # let client = hyper_util::client::legacy::Client::builder(
17547/// # hyper_util::rt::TokioExecutor::new()
17548/// # )
17549/// # .build(
17550/// # hyper_rustls::HttpsConnectorBuilder::new()
17551/// # .with_native_roots()
17552/// # .unwrap()
17553/// # .https_or_http()
17554/// # .enable_http2()
17555/// # .build()
17556/// # );
17557/// # let mut hub = Document::new(client, auth);
17558/// // You can configure optional parameters by calling the respective setters at will, and
17559/// // execute the final call using `doit()`.
17560/// // Values shown here are possibly random and not representative !
17561/// let result = hub.projects().locations_list("name")
17562/// .page_token("vero")
17563/// .page_size(-76)
17564/// .filter("invidunt")
17565/// .add_extra_location_types("Stet")
17566/// .doit().await;
17567/// # }
17568/// ```
17569pub struct ProjectLocationListCall<'a, C>
17570where
17571 C: 'a,
17572{
17573 hub: &'a Document<C>,
17574 _name: String,
17575 _page_token: Option<String>,
17576 _page_size: Option<i32>,
17577 _filter: Option<String>,
17578 _extra_location_types: Vec<String>,
17579 _delegate: Option<&'a mut dyn common::Delegate>,
17580 _additional_params: HashMap<String, String>,
17581 _scopes: BTreeSet<String>,
17582}
17583
17584impl<'a, C> common::CallBuilder for ProjectLocationListCall<'a, C> {}
17585
17586impl<'a, C> ProjectLocationListCall<'a, C>
17587where
17588 C: common::Connector,
17589{
17590 /// Perform the operation you have build so far.
17591 pub async fn doit(
17592 mut self,
17593 ) -> common::Result<(common::Response, GoogleCloudLocationListLocationsResponse)> {
17594 use std::borrow::Cow;
17595 use std::io::{Read, Seek};
17596
17597 use common::{url::Params, ToParts};
17598 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17599
17600 let mut dd = common::DefaultDelegate;
17601 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17602 dlg.begin(common::MethodInfo {
17603 id: "documentai.projects.locations.list",
17604 http_method: hyper::Method::GET,
17605 });
17606
17607 for &field in [
17608 "alt",
17609 "name",
17610 "pageToken",
17611 "pageSize",
17612 "filter",
17613 "extraLocationTypes",
17614 ]
17615 .iter()
17616 {
17617 if self._additional_params.contains_key(field) {
17618 dlg.finished(false);
17619 return Err(common::Error::FieldClash(field));
17620 }
17621 }
17622
17623 let mut params = Params::with_capacity(7 + self._additional_params.len());
17624 params.push("name", self._name);
17625 if let Some(value) = self._page_token.as_ref() {
17626 params.push("pageToken", value);
17627 }
17628 if let Some(value) = self._page_size.as_ref() {
17629 params.push("pageSize", value.to_string());
17630 }
17631 if let Some(value) = self._filter.as_ref() {
17632 params.push("filter", value);
17633 }
17634 if !self._extra_location_types.is_empty() {
17635 for f in self._extra_location_types.iter() {
17636 params.push("extraLocationTypes", f);
17637 }
17638 }
17639
17640 params.extend(self._additional_params.iter());
17641
17642 params.push("alt", "json");
17643 let mut url = self.hub._base_url.clone() + "v1/{+name}/locations";
17644 if self._scopes.is_empty() {
17645 self._scopes
17646 .insert(Scope::CloudPlatform.as_ref().to_string());
17647 }
17648
17649 #[allow(clippy::single_element_loop)]
17650 for &(find_this, param_name) in [("{+name}", "name")].iter() {
17651 url = params.uri_replacement(url, param_name, find_this, true);
17652 }
17653 {
17654 let to_remove = ["name"];
17655 params.remove_params(&to_remove);
17656 }
17657
17658 let url = params.parse_with_url(&url);
17659
17660 loop {
17661 let token = match self
17662 .hub
17663 .auth
17664 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17665 .await
17666 {
17667 Ok(token) => token,
17668 Err(e) => match dlg.token(e) {
17669 Ok(token) => token,
17670 Err(e) => {
17671 dlg.finished(false);
17672 return Err(common::Error::MissingToken(e));
17673 }
17674 },
17675 };
17676 let mut req_result = {
17677 let client = &self.hub.client;
17678 dlg.pre_request();
17679 let mut req_builder = hyper::Request::builder()
17680 .method(hyper::Method::GET)
17681 .uri(url.as_str())
17682 .header(USER_AGENT, self.hub._user_agent.clone());
17683
17684 if let Some(token) = token.as_ref() {
17685 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17686 }
17687
17688 let request = req_builder
17689 .header(CONTENT_LENGTH, 0_u64)
17690 .body(common::to_body::<String>(None));
17691
17692 client.request(request.unwrap()).await
17693 };
17694
17695 match req_result {
17696 Err(err) => {
17697 if let common::Retry::After(d) = dlg.http_error(&err) {
17698 sleep(d).await;
17699 continue;
17700 }
17701 dlg.finished(false);
17702 return Err(common::Error::HttpError(err));
17703 }
17704 Ok(res) => {
17705 let (mut parts, body) = res.into_parts();
17706 let mut body = common::Body::new(body);
17707 if !parts.status.is_success() {
17708 let bytes = common::to_bytes(body).await.unwrap_or_default();
17709 let error = serde_json::from_str(&common::to_string(&bytes));
17710 let response = common::to_response(parts, bytes.into());
17711
17712 if let common::Retry::After(d) =
17713 dlg.http_failure(&response, error.as_ref().ok())
17714 {
17715 sleep(d).await;
17716 continue;
17717 }
17718
17719 dlg.finished(false);
17720
17721 return Err(match error {
17722 Ok(value) => common::Error::BadRequest(value),
17723 _ => common::Error::Failure(response),
17724 });
17725 }
17726 let response = {
17727 let bytes = common::to_bytes(body).await.unwrap_or_default();
17728 let encoded = common::to_string(&bytes);
17729 match serde_json::from_str(&encoded) {
17730 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17731 Err(error) => {
17732 dlg.response_json_decode_error(&encoded, &error);
17733 return Err(common::Error::JsonDecodeError(
17734 encoded.to_string(),
17735 error,
17736 ));
17737 }
17738 }
17739 };
17740
17741 dlg.finished(true);
17742 return Ok(response);
17743 }
17744 }
17745 }
17746 }
17747
17748 /// The resource that owns the locations collection, if applicable.
17749 ///
17750 /// Sets the *name* path property to the given value.
17751 ///
17752 /// Even though the property as already been set when instantiating this call,
17753 /// we provide this method for API completeness.
17754 pub fn name(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
17755 self._name = new_value.to_string();
17756 self
17757 }
17758 /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
17759 ///
17760 /// Sets the *page token* query property to the given value.
17761 pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
17762 self._page_token = Some(new_value.to_string());
17763 self
17764 }
17765 /// The maximum number of results to return. If not set, the service selects a default.
17766 ///
17767 /// Sets the *page size* query property to the given value.
17768 pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C> {
17769 self._page_size = Some(new_value);
17770 self
17771 }
17772 /// 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).
17773 ///
17774 /// Sets the *filter* query property to the given value.
17775 pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
17776 self._filter = Some(new_value.to_string());
17777 self
17778 }
17779 /// Optional. Do not use this field. It is unsupported and is ignored unless explicitly documented otherwise. This is primarily for internal usage.
17780 ///
17781 /// Append the given value to the *extra location types* query property.
17782 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
17783 pub fn add_extra_location_types(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
17784 self._extra_location_types.push(new_value.to_string());
17785 self
17786 }
17787 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17788 /// while executing the actual API request.
17789 ///
17790 /// ````text
17791 /// It should be used to handle progress information, and to implement a certain level of resilience.
17792 /// ````
17793 ///
17794 /// Sets the *delegate* property to the given value.
17795 pub fn delegate(
17796 mut self,
17797 new_value: &'a mut dyn common::Delegate,
17798 ) -> ProjectLocationListCall<'a, C> {
17799 self._delegate = Some(new_value);
17800 self
17801 }
17802
17803 /// Set any additional parameter of the query string used in the request.
17804 /// It should be used to set parameters which are not yet available through their own
17805 /// setters.
17806 ///
17807 /// Please note that this method must not be used to set any of the known parameters
17808 /// which have their own setter method. If done anyway, the request will fail.
17809 ///
17810 /// # Additional Parameters
17811 ///
17812 /// * *$.xgafv* (query-string) - V1 error format.
17813 /// * *access_token* (query-string) - OAuth access token.
17814 /// * *alt* (query-string) - Data format for response.
17815 /// * *callback* (query-string) - JSONP
17816 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17817 /// * *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.
17818 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17819 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17820 /// * *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.
17821 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17822 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17823 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C>
17824 where
17825 T: AsRef<str>,
17826 {
17827 self._additional_params
17828 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17829 self
17830 }
17831
17832 /// Identifies the authorization scope for the method you are building.
17833 ///
17834 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17835 /// [`Scope::CloudPlatform`].
17836 ///
17837 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17838 /// tokens for more than one scope.
17839 ///
17840 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17841 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17842 /// sufficient, a read-write scope will do as well.
17843 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationListCall<'a, C>
17844 where
17845 St: AsRef<str>,
17846 {
17847 self._scopes.insert(String::from(scope.as_ref()));
17848 self
17849 }
17850 /// Identifies the authorization scope(s) for the method you are building.
17851 ///
17852 /// See [`Self::add_scope()`] for details.
17853 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationListCall<'a, C>
17854 where
17855 I: IntoIterator<Item = St>,
17856 St: AsRef<str>,
17857 {
17858 self._scopes
17859 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17860 self
17861 }
17862
17863 /// Removes all scopes, and no default scope will be used either.
17864 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17865 /// for details).
17866 pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, C> {
17867 self._scopes.clear();
17868 self
17869 }
17870}
17871
17872/// 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.
17873///
17874/// A builder for the *operations.get* method supported by a *project* resource.
17875/// It is not used directly, but through a [`ProjectMethods`] instance.
17876///
17877/// # Example
17878///
17879/// Instantiate a resource method builder
17880///
17881/// ```test_harness,no_run
17882/// # extern crate hyper;
17883/// # extern crate hyper_rustls;
17884/// # extern crate google_documentai1 as documentai1;
17885/// # async fn dox() {
17886/// # use documentai1::{Document, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17887///
17888/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17889/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17890/// # .with_native_roots()
17891/// # .unwrap()
17892/// # .https_only()
17893/// # .enable_http2()
17894/// # .build();
17895///
17896/// # let executor = hyper_util::rt::TokioExecutor::new();
17897/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17898/// # secret,
17899/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17900/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17901/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17902/// # ),
17903/// # ).build().await.unwrap();
17904///
17905/// # let client = hyper_util::client::legacy::Client::builder(
17906/// # hyper_util::rt::TokioExecutor::new()
17907/// # )
17908/// # .build(
17909/// # hyper_rustls::HttpsConnectorBuilder::new()
17910/// # .with_native_roots()
17911/// # .unwrap()
17912/// # .https_or_http()
17913/// # .enable_http2()
17914/// # .build()
17915/// # );
17916/// # let mut hub = Document::new(client, auth);
17917/// // You can configure optional parameters by calling the respective setters at will, and
17918/// // execute the final call using `doit()`.
17919/// // Values shown here are possibly random and not representative !
17920/// let result = hub.projects().operations_get("name")
17921/// .doit().await;
17922/// # }
17923/// ```
17924pub struct ProjectOperationGetCall<'a, C>
17925where
17926 C: 'a,
17927{
17928 hub: &'a Document<C>,
17929 _name: String,
17930 _delegate: Option<&'a mut dyn common::Delegate>,
17931 _additional_params: HashMap<String, String>,
17932 _scopes: BTreeSet<String>,
17933}
17934
17935impl<'a, C> common::CallBuilder for ProjectOperationGetCall<'a, C> {}
17936
17937impl<'a, C> ProjectOperationGetCall<'a, C>
17938where
17939 C: common::Connector,
17940{
17941 /// Perform the operation you have build so far.
17942 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
17943 use std::borrow::Cow;
17944 use std::io::{Read, Seek};
17945
17946 use common::{url::Params, ToParts};
17947 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17948
17949 let mut dd = common::DefaultDelegate;
17950 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17951 dlg.begin(common::MethodInfo {
17952 id: "documentai.projects.operations.get",
17953 http_method: hyper::Method::GET,
17954 });
17955
17956 for &field in ["alt", "name"].iter() {
17957 if self._additional_params.contains_key(field) {
17958 dlg.finished(false);
17959 return Err(common::Error::FieldClash(field));
17960 }
17961 }
17962
17963 let mut params = Params::with_capacity(3 + self._additional_params.len());
17964 params.push("name", self._name);
17965
17966 params.extend(self._additional_params.iter());
17967
17968 params.push("alt", "json");
17969 let mut url = self.hub._base_url.clone() + "v1/{+name}";
17970 if self._scopes.is_empty() {
17971 self._scopes
17972 .insert(Scope::CloudPlatform.as_ref().to_string());
17973 }
17974
17975 #[allow(clippy::single_element_loop)]
17976 for &(find_this, param_name) in [("{+name}", "name")].iter() {
17977 url = params.uri_replacement(url, param_name, find_this, true);
17978 }
17979 {
17980 let to_remove = ["name"];
17981 params.remove_params(&to_remove);
17982 }
17983
17984 let url = params.parse_with_url(&url);
17985
17986 loop {
17987 let token = match self
17988 .hub
17989 .auth
17990 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17991 .await
17992 {
17993 Ok(token) => token,
17994 Err(e) => match dlg.token(e) {
17995 Ok(token) => token,
17996 Err(e) => {
17997 dlg.finished(false);
17998 return Err(common::Error::MissingToken(e));
17999 }
18000 },
18001 };
18002 let mut req_result = {
18003 let client = &self.hub.client;
18004 dlg.pre_request();
18005 let mut req_builder = hyper::Request::builder()
18006 .method(hyper::Method::GET)
18007 .uri(url.as_str())
18008 .header(USER_AGENT, self.hub._user_agent.clone());
18009
18010 if let Some(token) = token.as_ref() {
18011 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18012 }
18013
18014 let request = req_builder
18015 .header(CONTENT_LENGTH, 0_u64)
18016 .body(common::to_body::<String>(None));
18017
18018 client.request(request.unwrap()).await
18019 };
18020
18021 match req_result {
18022 Err(err) => {
18023 if let common::Retry::After(d) = dlg.http_error(&err) {
18024 sleep(d).await;
18025 continue;
18026 }
18027 dlg.finished(false);
18028 return Err(common::Error::HttpError(err));
18029 }
18030 Ok(res) => {
18031 let (mut parts, body) = res.into_parts();
18032 let mut body = common::Body::new(body);
18033 if !parts.status.is_success() {
18034 let bytes = common::to_bytes(body).await.unwrap_or_default();
18035 let error = serde_json::from_str(&common::to_string(&bytes));
18036 let response = common::to_response(parts, bytes.into());
18037
18038 if let common::Retry::After(d) =
18039 dlg.http_failure(&response, error.as_ref().ok())
18040 {
18041 sleep(d).await;
18042 continue;
18043 }
18044
18045 dlg.finished(false);
18046
18047 return Err(match error {
18048 Ok(value) => common::Error::BadRequest(value),
18049 _ => common::Error::Failure(response),
18050 });
18051 }
18052 let response = {
18053 let bytes = common::to_bytes(body).await.unwrap_or_default();
18054 let encoded = common::to_string(&bytes);
18055 match serde_json::from_str(&encoded) {
18056 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18057 Err(error) => {
18058 dlg.response_json_decode_error(&encoded, &error);
18059 return Err(common::Error::JsonDecodeError(
18060 encoded.to_string(),
18061 error,
18062 ));
18063 }
18064 }
18065 };
18066
18067 dlg.finished(true);
18068 return Ok(response);
18069 }
18070 }
18071 }
18072 }
18073
18074 /// The name of the operation resource.
18075 ///
18076 /// Sets the *name* path property to the given value.
18077 ///
18078 /// Even though the property as already been set when instantiating this call,
18079 /// we provide this method for API completeness.
18080 pub fn name(mut self, new_value: &str) -> ProjectOperationGetCall<'a, C> {
18081 self._name = new_value.to_string();
18082 self
18083 }
18084 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18085 /// while executing the actual API request.
18086 ///
18087 /// ````text
18088 /// It should be used to handle progress information, and to implement a certain level of resilience.
18089 /// ````
18090 ///
18091 /// Sets the *delegate* property to the given value.
18092 pub fn delegate(
18093 mut self,
18094 new_value: &'a mut dyn common::Delegate,
18095 ) -> ProjectOperationGetCall<'a, C> {
18096 self._delegate = Some(new_value);
18097 self
18098 }
18099
18100 /// Set any additional parameter of the query string used in the request.
18101 /// It should be used to set parameters which are not yet available through their own
18102 /// setters.
18103 ///
18104 /// Please note that this method must not be used to set any of the known parameters
18105 /// which have their own setter method. If done anyway, the request will fail.
18106 ///
18107 /// # Additional Parameters
18108 ///
18109 /// * *$.xgafv* (query-string) - V1 error format.
18110 /// * *access_token* (query-string) - OAuth access token.
18111 /// * *alt* (query-string) - Data format for response.
18112 /// * *callback* (query-string) - JSONP
18113 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18114 /// * *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.
18115 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18116 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18117 /// * *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.
18118 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18119 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18120 pub fn param<T>(mut self, name: T, value: T) -> ProjectOperationGetCall<'a, C>
18121 where
18122 T: AsRef<str>,
18123 {
18124 self._additional_params
18125 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18126 self
18127 }
18128
18129 /// Identifies the authorization scope for the method you are building.
18130 ///
18131 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18132 /// [`Scope::CloudPlatform`].
18133 ///
18134 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18135 /// tokens for more than one scope.
18136 ///
18137 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18138 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18139 /// sufficient, a read-write scope will do as well.
18140 pub fn add_scope<St>(mut self, scope: St) -> ProjectOperationGetCall<'a, C>
18141 where
18142 St: AsRef<str>,
18143 {
18144 self._scopes.insert(String::from(scope.as_ref()));
18145 self
18146 }
18147 /// Identifies the authorization scope(s) for the method you are building.
18148 ///
18149 /// See [`Self::add_scope()`] for details.
18150 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOperationGetCall<'a, C>
18151 where
18152 I: IntoIterator<Item = St>,
18153 St: AsRef<str>,
18154 {
18155 self._scopes
18156 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18157 self
18158 }
18159
18160 /// Removes all scopes, and no default scope will be used either.
18161 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18162 /// for details).
18163 pub fn clear_scopes(mut self) -> ProjectOperationGetCall<'a, C> {
18164 self._scopes.clear();
18165 self
18166 }
18167}