google_vision1/
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    /// Apply machine learning models to understand and label images
20    CloudVision,
21}
22
23impl AsRef<str> for Scope {
24    fn as_ref(&self) -> &str {
25        match *self {
26            Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
27            Scope::CloudVision => "https://www.googleapis.com/auth/cloud-vision",
28        }
29    }
30}
31
32#[allow(clippy::derivable_impls)]
33impl Default for Scope {
34    fn default() -> Scope {
35        Scope::CloudVision
36    }
37}
38
39// ########
40// HUB ###
41// ######
42
43/// Central instance to access all Vision related resource activities
44///
45/// # Examples
46///
47/// Instantiate a new hub
48///
49/// ```test_harness,no_run
50/// extern crate hyper;
51/// extern crate hyper_rustls;
52/// extern crate google_vision1 as vision1;
53/// use vision1::{Result, Error};
54/// # async fn dox() {
55/// use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
56///
57/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
58/// // `client_secret`, among other things.
59/// let secret: yup_oauth2::ApplicationSecret = Default::default();
60/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
61/// // unless you replace  `None` with the desired Flow.
62/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
63/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
64/// // retrieve them from storage.
65/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
66///     .with_native_roots()
67///     .unwrap()
68///     .https_only()
69///     .enable_http2()
70///     .build();
71///
72/// let executor = hyper_util::rt::TokioExecutor::new();
73/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
74///     secret,
75///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
76///     yup_oauth2::client::CustomHyperClientBuilder::from(
77///         hyper_util::client::legacy::Client::builder(executor).build(connector),
78///     ),
79/// ).build().await.unwrap();
80///
81/// let client = hyper_util::client::legacy::Client::builder(
82///     hyper_util::rt::TokioExecutor::new()
83/// )
84/// .build(
85///     hyper_rustls::HttpsConnectorBuilder::new()
86///         .with_native_roots()
87///         .unwrap()
88///         .https_or_http()
89///         .enable_http2()
90///         .build()
91/// );
92/// let mut hub = Vision::new(client, auth);
93/// // You can configure optional parameters by calling the respective setters at will, and
94/// // execute the final call using `doit()`.
95/// // Values shown here are possibly random and not representative !
96/// let result = hub.operations().list("name")
97///              .return_partial_success(true)
98///              .page_token("gubergren")
99///              .page_size(-75)
100///              .filter("dolor")
101///              .doit().await;
102///
103/// match result {
104///     Err(e) => match e {
105///         // The Error enum provides details about what exactly happened.
106///         // You can also just use its `Debug`, `Display` or `Error` traits
107///          Error::HttpError(_)
108///         |Error::Io(_)
109///         |Error::MissingAPIKey
110///         |Error::MissingToken(_)
111///         |Error::Cancelled
112///         |Error::UploadSizeLimitExceeded(_, _)
113///         |Error::Failure(_)
114///         |Error::BadRequest(_)
115///         |Error::FieldClash(_)
116///         |Error::JsonDecodeError(_, _) => println!("{}", e),
117///     },
118///     Ok(res) => println!("Success: {:?}", res),
119/// }
120/// # }
121/// ```
122#[derive(Clone)]
123pub struct Vision<C> {
124    pub client: common::Client<C>,
125    pub auth: Box<dyn common::GetToken>,
126    _user_agent: String,
127    _base_url: String,
128    _root_url: String,
129}
130
131impl<C> common::Hub for Vision<C> {}
132
133impl<'a, C> Vision<C> {
134    pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Vision<C> {
135        Vision {
136            client,
137            auth: Box::new(auth),
138            _user_agent: "google-api-rust-client/7.0.0".to_string(),
139            _base_url: "https://vision.googleapis.com/".to_string(),
140            _root_url: "https://vision.googleapis.com/".to_string(),
141        }
142    }
143
144    pub fn files(&'a self) -> FileMethods<'a, C> {
145        FileMethods { hub: self }
146    }
147    pub fn images(&'a self) -> ImageMethods<'a, C> {
148        ImageMethods { hub: self }
149    }
150    pub fn locations(&'a self) -> LocationMethods<'a, C> {
151        LocationMethods { hub: self }
152    }
153    pub fn operations(&'a self) -> OperationMethods<'a, C> {
154        OperationMethods { hub: self }
155    }
156    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
157        ProjectMethods { hub: self }
158    }
159
160    /// Set the user-agent header field to use in all requests to the server.
161    /// It defaults to `google-api-rust-client/7.0.0`.
162    ///
163    /// Returns the previously set user-agent.
164    pub fn user_agent(&mut self, agent_name: String) -> String {
165        std::mem::replace(&mut self._user_agent, agent_name)
166    }
167
168    /// Set the base url to use in all requests to the server.
169    /// It defaults to `https://vision.googleapis.com/`.
170    ///
171    /// Returns the previously set base url.
172    pub fn base_url(&mut self, new_base_url: String) -> String {
173        std::mem::replace(&mut self._base_url, new_base_url)
174    }
175
176    /// Set the root url to use in all requests to the server.
177    /// It defaults to `https://vision.googleapis.com/`.
178    ///
179    /// Returns the previously set root url.
180    pub fn root_url(&mut self, new_root_url: String) -> String {
181        std::mem::replace(&mut self._root_url, new_root_url)
182    }
183}
184
185// ############
186// SCHEMAS ###
187// ##########
188/// Request message for the `AddProductToProductSet` method.
189///
190/// # Activities
191///
192/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
193/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
194///
195/// * [locations product sets add product projects](ProjectLocationProductSetAddProductCall) (request)
196#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
197#[serde_with::serde_as]
198#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
199pub struct AddProductToProductSetRequest {
200    /// Required. The resource name for the Product to be added to this ProductSet. Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
201    pub product: Option<String>,
202}
203
204impl common::RequestValue for AddProductToProductSetRequest {}
205
206/// A request to annotate one single file, e.g. a PDF, TIFF or GIF file.
207///
208/// This type is not used in any activity, and only used as *part* of another schema.
209///
210#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
211#[serde_with::serde_as]
212#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
213pub struct AnnotateFileRequest {
214    /// Required. Requested features.
215    pub features: Option<Vec<Feature>>,
216    /// Additional context that may accompany the image(s) in the file.
217    #[serde(rename = "imageContext")]
218    pub image_context: Option<ImageContext>,
219    /// Required. Information about the input file.
220    #[serde(rename = "inputConfig")]
221    pub input_config: Option<InputConfig>,
222    /// Pages of the file to perform image annotation. Pages starts from 1, we assume the first page of the file is page 1. At most 5 pages are supported per request. Pages can be negative. Page 1 means the first page. Page 2 means the second page. Page -1 means the last page. Page -2 means the second to the last page. If the file is GIF instead of PDF or TIFF, page refers to GIF frames. If this field is empty, by default the service performs image annotation for the first 5 pages of the file.
223    pub pages: Option<Vec<i32>>,
224}
225
226impl common::Part for AnnotateFileRequest {}
227
228/// Response to a single file annotation request. A file may contain one or more images, which individually have their own responses.
229///
230/// This type is not used in any activity, and only used as *part* of another schema.
231///
232#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
233#[serde_with::serde_as]
234#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
235pub struct AnnotateFileResponse {
236    /// If set, represents the error message for the failed request. The `responses` field will not be set in this case.
237    pub error: Option<Status>,
238    /// Information about the file for which this response is generated.
239    #[serde(rename = "inputConfig")]
240    pub input_config: Option<InputConfig>,
241    /// Individual responses to images found within the file. This field will be empty if the `error` field is set.
242    pub responses: Option<Vec<AnnotateImageResponse>>,
243    /// This field gives the total number of pages in the file.
244    #[serde(rename = "totalPages")]
245    pub total_pages: Option<i32>,
246}
247
248impl common::Part for AnnotateFileResponse {}
249
250/// Request for performing Google Cloud Vision API tasks over a user-provided image, with user-requested features, and with context information.
251///
252/// This type is not used in any activity, and only used as *part* of another schema.
253///
254#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
255#[serde_with::serde_as]
256#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
257pub struct AnnotateImageRequest {
258    /// Requested features.
259    pub features: Option<Vec<Feature>>,
260    /// The image to be processed.
261    pub image: Option<Image>,
262    /// Additional context that may accompany the image.
263    #[serde(rename = "imageContext")]
264    pub image_context: Option<ImageContext>,
265}
266
267impl common::Part for AnnotateImageRequest {}
268
269/// Response to an image annotation request.
270///
271/// This type is not used in any activity, and only used as *part* of another schema.
272///
273#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
274#[serde_with::serde_as]
275#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
276pub struct AnnotateImageResponse {
277    /// If present, contextual information is needed to understand where this image comes from.
278    pub context: Option<ImageAnnotationContext>,
279    /// If present, crop hints have completed successfully.
280    #[serde(rename = "cropHintsAnnotation")]
281    pub crop_hints_annotation: Option<CropHintsAnnotation>,
282    /// If set, represents the error message for the operation. Note that filled-in image annotations are guaranteed to be correct, even when `error` is set.
283    pub error: Option<Status>,
284    /// If present, face detection has completed successfully.
285    #[serde(rename = "faceAnnotations")]
286    pub face_annotations: Option<Vec<FaceAnnotation>>,
287    /// If present, text (OCR) detection or document (OCR) text detection has completed successfully. This annotation provides the structural hierarchy for the OCR detected text.
288    #[serde(rename = "fullTextAnnotation")]
289    pub full_text_annotation: Option<TextAnnotation>,
290    /// If present, image properties were extracted successfully.
291    #[serde(rename = "imagePropertiesAnnotation")]
292    pub image_properties_annotation: Option<ImageProperties>,
293    /// If present, label detection has completed successfully.
294    #[serde(rename = "labelAnnotations")]
295    pub label_annotations: Option<Vec<EntityAnnotation>>,
296    /// If present, landmark detection has completed successfully.
297    #[serde(rename = "landmarkAnnotations")]
298    pub landmark_annotations: Option<Vec<EntityAnnotation>>,
299    /// If present, localized object detection has completed successfully. This will be sorted descending by confidence score.
300    #[serde(rename = "localizedObjectAnnotations")]
301    pub localized_object_annotations: Option<Vec<LocalizedObjectAnnotation>>,
302    /// If present, logo detection has completed successfully.
303    #[serde(rename = "logoAnnotations")]
304    pub logo_annotations: Option<Vec<EntityAnnotation>>,
305    /// If present, product search has completed successfully.
306    #[serde(rename = "productSearchResults")]
307    pub product_search_results: Option<ProductSearchResults>,
308    /// If present, safe-search annotation has completed successfully.
309    #[serde(rename = "safeSearchAnnotation")]
310    pub safe_search_annotation: Option<SafeSearchAnnotation>,
311    /// If present, text (OCR) detection has completed successfully.
312    #[serde(rename = "textAnnotations")]
313    pub text_annotations: Option<Vec<EntityAnnotation>>,
314    /// If present, web detection has completed successfully.
315    #[serde(rename = "webDetection")]
316    pub web_detection: Option<WebDetection>,
317}
318
319impl common::Part for AnnotateImageResponse {}
320
321/// An offline file annotation request.
322///
323/// This type is not used in any activity, and only used as *part* of another schema.
324///
325#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
326#[serde_with::serde_as]
327#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
328pub struct AsyncAnnotateFileRequest {
329    /// Required. Requested features.
330    pub features: Option<Vec<Feature>>,
331    /// Additional context that may accompany the image(s) in the file.
332    #[serde(rename = "imageContext")]
333    pub image_context: Option<ImageContext>,
334    /// Required. Information about the input file.
335    #[serde(rename = "inputConfig")]
336    pub input_config: Option<InputConfig>,
337    /// Required. The desired output location and metadata (e.g. format).
338    #[serde(rename = "outputConfig")]
339    pub output_config: Option<OutputConfig>,
340}
341
342impl common::Part for AsyncAnnotateFileRequest {}
343
344/// Multiple async file annotation requests are batched into a single service call.
345///
346/// # Activities
347///
348/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
349/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
350///
351/// * [async batch annotate files](FileAsyncBatchAnnotateCall) (request)
352/// * [files async batch annotate projects](ProjectFileAsyncBatchAnnotateCall) (request)
353/// * [locations files async batch annotate projects](ProjectLocationFileAsyncBatchAnnotateCall) (request)
354#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
355#[serde_with::serde_as]
356#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
357pub struct AsyncBatchAnnotateFilesRequest {
358    /// Optional. The labels with user-defined metadata for the request. Label keys and values can be no longer than 63 characters (Unicode codepoints), 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.
359    pub labels: Option<HashMap<String, String>>,
360    /// Optional. Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no parent is specified, a region will be chosen automatically. Supported location-ids: `us`: USA country only, `asia`: East asia areas, like Japan, Taiwan, `eu`: The European Union. Example: `projects/project-A/locations/eu`.
361    pub parent: Option<String>,
362    /// Required. Individual async file annotation requests for this batch.
363    pub requests: Option<Vec<AsyncAnnotateFileRequest>>,
364}
365
366impl common::RequestValue for AsyncBatchAnnotateFilesRequest {}
367
368/// Request for async image annotation for a list of images.
369///
370/// # Activities
371///
372/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
373/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
374///
375/// * [async batch annotate images](ImageAsyncBatchAnnotateCall) (request)
376/// * [images async batch annotate projects](ProjectImageAsyncBatchAnnotateCall) (request)
377/// * [locations images async batch annotate projects](ProjectLocationImageAsyncBatchAnnotateCall) (request)
378#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
379#[serde_with::serde_as]
380#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
381pub struct AsyncBatchAnnotateImagesRequest {
382    /// Optional. The labels with user-defined metadata for the request. Label keys and values can be no longer than 63 characters (Unicode codepoints), 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.
383    pub labels: Option<HashMap<String, String>>,
384    /// Required. The desired output location and metadata (e.g. format).
385    #[serde(rename = "outputConfig")]
386    pub output_config: Option<OutputConfig>,
387    /// Optional. Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no parent is specified, a region will be chosen automatically. Supported location-ids: `us`: USA country only, `asia`: East asia areas, like Japan, Taiwan, `eu`: The European Union. Example: `projects/project-A/locations/eu`.
388    pub parent: Option<String>,
389    /// Required. Individual image annotation requests for this batch.
390    pub requests: Option<Vec<AnnotateImageRequest>>,
391}
392
393impl common::RequestValue for AsyncBatchAnnotateImagesRequest {}
394
395/// A list of requests to annotate files using the BatchAnnotateFiles API.
396///
397/// # Activities
398///
399/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
400/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
401///
402/// * [annotate files](FileAnnotateCall) (request)
403/// * [files annotate projects](ProjectFileAnnotateCall) (request)
404/// * [locations files annotate projects](ProjectLocationFileAnnotateCall) (request)
405#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
406#[serde_with::serde_as]
407#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
408pub struct BatchAnnotateFilesRequest {
409    /// Optional. The labels with user-defined metadata for the request. Label keys and values can be no longer than 63 characters (Unicode codepoints), 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.
410    pub labels: Option<HashMap<String, String>>,
411    /// Optional. Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no parent is specified, a region will be chosen automatically. Supported location-ids: `us`: USA country only, `asia`: East asia areas, like Japan, Taiwan, `eu`: The European Union. Example: `projects/project-A/locations/eu`.
412    pub parent: Option<String>,
413    /// Required. The list of file annotation requests. Right now we support only one AnnotateFileRequest in BatchAnnotateFilesRequest.
414    pub requests: Option<Vec<AnnotateFileRequest>>,
415}
416
417impl common::RequestValue for BatchAnnotateFilesRequest {}
418
419/// A list of file annotation responses.
420///
421/// # Activities
422///
423/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
424/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
425///
426/// * [annotate files](FileAnnotateCall) (response)
427/// * [files annotate projects](ProjectFileAnnotateCall) (response)
428/// * [locations files annotate projects](ProjectLocationFileAnnotateCall) (response)
429#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
430#[serde_with::serde_as]
431#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
432pub struct BatchAnnotateFilesResponse {
433    /// The list of file annotation responses, each response corresponding to each AnnotateFileRequest in BatchAnnotateFilesRequest.
434    pub responses: Option<Vec<AnnotateFileResponse>>,
435}
436
437impl common::ResponseResult for BatchAnnotateFilesResponse {}
438
439/// Multiple image annotation requests are batched into a single service call.
440///
441/// # Activities
442///
443/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
444/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
445///
446/// * [annotate images](ImageAnnotateCall) (request)
447/// * [images annotate projects](ProjectImageAnnotateCall) (request)
448/// * [locations images annotate projects](ProjectLocationImageAnnotateCall) (request)
449#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
450#[serde_with::serde_as]
451#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
452pub struct BatchAnnotateImagesRequest {
453    /// Optional. The labels with user-defined metadata for the request. Label keys and values can be no longer than 63 characters (Unicode codepoints), 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.
454    pub labels: Option<HashMap<String, String>>,
455    /// Optional. Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no parent is specified, a region will be chosen automatically. Supported location-ids: `us`: USA country only, `asia`: East asia areas, like Japan, Taiwan, `eu`: The European Union. Example: `projects/project-A/locations/eu`.
456    pub parent: Option<String>,
457    /// Required. Individual image annotation requests for this batch.
458    pub requests: Option<Vec<AnnotateImageRequest>>,
459}
460
461impl common::RequestValue for BatchAnnotateImagesRequest {}
462
463/// Response to a batch image annotation request.
464///
465/// # Activities
466///
467/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
468/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
469///
470/// * [annotate images](ImageAnnotateCall) (response)
471/// * [images annotate projects](ProjectImageAnnotateCall) (response)
472/// * [locations images annotate projects](ProjectLocationImageAnnotateCall) (response)
473#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
474#[serde_with::serde_as]
475#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
476pub struct BatchAnnotateImagesResponse {
477    /// Individual responses to image annotation requests within the batch.
478    pub responses: Option<Vec<AnnotateImageResponse>>,
479}
480
481impl common::ResponseResult for BatchAnnotateImagesResponse {}
482
483/// Logical element on the page.
484///
485/// This type is not used in any activity, and only used as *part* of another schema.
486///
487#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
488#[serde_with::serde_as]
489#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
490pub struct Block {
491    /// Detected block type (text, image etc) for this block.
492    #[serde(rename = "blockType")]
493    pub block_type: Option<String>,
494    /// The bounding box for the block. The vertices are in the order of top-left, top-right, bottom-right, bottom-left. When a rotation of the bounding box is detected the rotation is represented as around the top-left corner as defined when the text is read in the 'natural' orientation. For example: * when the text is horizontal it might look like: 0----1 | | 3----2 * when it's rotated 180 degrees around the top-left corner it becomes: 2----3 | | 1----0 and the vertex order will still be (0, 1, 2, 3).
495    #[serde(rename = "boundingBox")]
496    pub bounding_box: Option<BoundingPoly>,
497    /// Confidence of the OCR results on the block. Range [0, 1].
498    pub confidence: Option<f32>,
499    /// List of paragraphs in this block (if this blocks is of type text).
500    pub paragraphs: Option<Vec<Paragraph>>,
501    /// Additional information detected for the block.
502    pub property: Option<TextProperty>,
503}
504
505impl common::Part for Block {}
506
507/// A bounding polygon for the detected image annotation.
508///
509/// This type is not used in any activity, and only used as *part* of another schema.
510///
511#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
512#[serde_with::serde_as]
513#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
514pub struct BoundingPoly {
515    /// The bounding polygon normalized vertices.
516    #[serde(rename = "normalizedVertices")]
517    pub normalized_vertices: Option<Vec<NormalizedVertex>>,
518    /// The bounding polygon vertices.
519    pub vertices: Option<Vec<Vertex>>,
520}
521
522impl common::Part for BoundingPoly {}
523
524/// The request message for Operations.CancelOperation.
525///
526/// # Activities
527///
528/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
529/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
530///
531/// * [cancel operations](OperationCancelCall) (request)
532#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
533#[serde_with::serde_as]
534#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
535pub struct CancelOperationRequest {
536    _never_set: Option<bool>,
537}
538
539impl common::RequestValue for CancelOperationRequest {}
540
541/// 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(''); }; // ...
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 Color {
549    /// 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).
550    pub alpha: Option<f32>,
551    /// The amount of blue in the color as a value in the interval [0, 1].
552    pub blue: Option<f32>,
553    /// The amount of green in the color as a value in the interval [0, 1].
554    pub green: Option<f32>,
555    /// The amount of red in the color as a value in the interval [0, 1].
556    pub red: Option<f32>,
557}
558
559impl common::Part for Color {}
560
561/// Color information consists of RGB channels, score, and the fraction of the image that the color occupies in the image.
562///
563/// This type is not used in any activity, and only used as *part* of another schema.
564///
565#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
566#[serde_with::serde_as]
567#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
568pub struct ColorInfo {
569    /// RGB components of the color.
570    pub color: Option<Color>,
571    /// The fraction of pixels the color occupies in the image. Value in range [0, 1].
572    #[serde(rename = "pixelFraction")]
573    pub pixel_fraction: Option<f32>,
574    /// Image-specific score for this color. Value in range [0, 1].
575    pub score: Option<f32>,
576}
577
578impl common::Part for ColorInfo {}
579
580/// Single crop hint that is used to generate a new crop when serving an image.
581///
582/// This type is not used in any activity, and only used as *part* of another schema.
583///
584#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
585#[serde_with::serde_as]
586#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
587pub struct CropHint {
588    /// The bounding polygon for the crop region. The coordinates of the bounding box are in the original image's scale.
589    #[serde(rename = "boundingPoly")]
590    pub bounding_poly: Option<BoundingPoly>,
591    /// Confidence of this being a salient region. Range [0, 1].
592    pub confidence: Option<f32>,
593    /// Fraction of importance of this salient region with respect to the original image.
594    #[serde(rename = "importanceFraction")]
595    pub importance_fraction: Option<f32>,
596}
597
598impl common::Part for CropHint {}
599
600/// Set of crop hints that are used to generate new crops when serving images.
601///
602/// This type is not used in any activity, and only used as *part* of another schema.
603///
604#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
605#[serde_with::serde_as]
606#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
607pub struct CropHintsAnnotation {
608    /// Crop hint results.
609    #[serde(rename = "cropHints")]
610    pub crop_hints: Option<Vec<CropHint>>,
611}
612
613impl common::Part for CropHintsAnnotation {}
614
615/// Parameters for crop hints annotation request.
616///
617/// This type is not used in any activity, and only used as *part* of another schema.
618///
619#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
620#[serde_with::serde_as]
621#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
622pub struct CropHintsParams {
623    /// Aspect ratios in floats, representing the ratio of the width to the height of the image. For example, if the desired aspect ratio is 4/3, the corresponding float value should be 1.33333. If not specified, the best possible crop is returned. The number of provided aspect ratios is limited to a maximum of 16; any aspect ratios provided after the 16th are ignored.
624    #[serde(rename = "aspectRatios")]
625    pub aspect_ratios: Option<Vec<f32>>,
626}
627
628impl common::Part for CropHintsParams {}
629
630/// Detected start or end of a structural component.
631///
632/// This type is not used in any activity, and only used as *part* of another schema.
633///
634#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
635#[serde_with::serde_as]
636#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
637pub struct DetectedBreak {
638    /// True if break prepends the element.
639    #[serde(rename = "isPrefix")]
640    pub is_prefix: Option<bool>,
641    /// Detected break type.
642    #[serde(rename = "type")]
643    pub type_: Option<String>,
644}
645
646impl common::Part for DetectedBreak {}
647
648/// Detected language for a structural component.
649///
650/// This type is not used in any activity, and only used as *part* of another schema.
651///
652#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
653#[serde_with::serde_as]
654#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
655pub struct DetectedLanguage {
656    /// Confidence of detected language. Range [0, 1].
657    pub confidence: Option<f32>,
658    /// The BCP-47 language code, such as "en-US" or "sr-Latn". For more information, see http://www.unicode.org/reports/tr35/#Unicode_locale_identifier.
659    #[serde(rename = "languageCode")]
660    pub language_code: Option<String>,
661}
662
663impl common::Part for DetectedLanguage {}
664
665/// Set of dominant colors and their corresponding scores.
666///
667/// This type is not used in any activity, and only used as *part* of another schema.
668///
669#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
670#[serde_with::serde_as]
671#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
672pub struct DominantColorsAnnotation {
673    /// RGB color values with their score and pixel fraction.
674    pub colors: Option<Vec<ColorInfo>>,
675}
676
677impl common::Part for DominantColorsAnnotation {}
678
679/// 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); }
680///
681/// # Activities
682///
683/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
684/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
685///
686/// * [cancel operations](OperationCancelCall) (response)
687/// * [delete operations](OperationDeleteCall) (response)
688/// * [locations product sets add product projects](ProjectLocationProductSetAddProductCall) (response)
689/// * [locations product sets delete projects](ProjectLocationProductSetDeleteCall) (response)
690/// * [locations product sets remove product projects](ProjectLocationProductSetRemoveProductCall) (response)
691/// * [locations products reference images delete projects](ProjectLocationProductReferenceImageDeleteCall) (response)
692/// * [locations products delete projects](ProjectLocationProductDeleteCall) (response)
693#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
694#[serde_with::serde_as]
695#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
696pub struct Empty {
697    _never_set: Option<bool>,
698}
699
700impl common::ResponseResult for Empty {}
701
702/// Set of detected entity features.
703///
704/// This type is not used in any activity, and only used as *part* of another schema.
705///
706#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
707#[serde_with::serde_as]
708#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
709pub struct EntityAnnotation {
710    /// Image region to which this entity belongs. Not produced for `LABEL_DETECTION` features.
711    #[serde(rename = "boundingPoly")]
712    pub bounding_poly: Option<BoundingPoly>,
713    /// **Deprecated. Use `score` instead.** The accuracy of the entity detection in an image. For example, for an image in which the "Eiffel Tower" entity is detected, this field represents the confidence that there is a tower in the query image. Range [0, 1].
714    pub confidence: Option<f32>,
715    /// Entity textual description, expressed in its `locale` language.
716    pub description: Option<String>,
717    /// The language code for the locale in which the entity textual `description` is expressed.
718    pub locale: Option<String>,
719    /// The location information for the detected entity. Multiple `LocationInfo` elements can be present because one location may indicate the location of the scene in the image, and another location may indicate the location of the place where the image was taken. Location information is usually present for landmarks.
720    pub locations: Option<Vec<LocationInfo>>,
721    /// Opaque entity ID. Some IDs may be available in [Google Knowledge Graph Search API](https://developers.google.com/knowledge-graph/).
722    pub mid: Option<String>,
723    /// Some entities may have optional user-supplied `Property` (name/value) fields, such a score or string that qualifies the entity.
724    pub properties: Option<Vec<Property>>,
725    /// Overall score of the result. Range [0, 1].
726    pub score: Option<f32>,
727    /// The relevancy of the ICA (Image Content Annotation) label to the image. For example, the relevancy of "tower" is likely higher to an image containing the detected "Eiffel Tower" than to an image containing a detected distant towering building, even though the confidence that there is a tower in each image may be the same. Range [0, 1].
728    pub topicality: Option<f32>,
729}
730
731impl common::Part for EntityAnnotation {}
732
733/// A face annotation object contains the results of face detection.
734///
735/// This type is not used in any activity, and only used as *part* of another schema.
736///
737#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
738#[serde_with::serde_as]
739#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
740pub struct FaceAnnotation {
741    /// Anger likelihood.
742    #[serde(rename = "angerLikelihood")]
743    pub anger_likelihood: Option<String>,
744    /// Blurred likelihood.
745    #[serde(rename = "blurredLikelihood")]
746    pub blurred_likelihood: Option<String>,
747    /// The bounding polygon around the face. The coordinates of the bounding box are in the original image's scale. The bounding box is computed to "frame" the face in accordance with human expectations. It is based on the landmarker results. Note that one or more x and/or y coordinates may not be generated in the `BoundingPoly` (the polygon will be unbounded) if only a partial face appears in the image to be annotated.
748    #[serde(rename = "boundingPoly")]
749    pub bounding_poly: Option<BoundingPoly>,
750    /// Detection confidence. Range [0, 1].
751    #[serde(rename = "detectionConfidence")]
752    pub detection_confidence: Option<f32>,
753    /// The `fd_bounding_poly` bounding polygon is tighter than the `boundingPoly`, and encloses only the skin part of the face. Typically, it is used to eliminate the face from any image analysis that detects the "amount of skin" visible in an image. It is not based on the landmarker results, only on the initial face detection, hence the fd (face detection) prefix.
754    #[serde(rename = "fdBoundingPoly")]
755    pub fd_bounding_poly: Option<BoundingPoly>,
756    /// Headwear likelihood.
757    #[serde(rename = "headwearLikelihood")]
758    pub headwear_likelihood: Option<String>,
759    /// Joy likelihood.
760    #[serde(rename = "joyLikelihood")]
761    pub joy_likelihood: Option<String>,
762    /// Face landmarking confidence. Range [0, 1].
763    #[serde(rename = "landmarkingConfidence")]
764    pub landmarking_confidence: Option<f32>,
765    /// Detected face landmarks.
766    pub landmarks: Option<Vec<Landmark>>,
767    /// Yaw angle, which indicates the leftward/rightward angle that the face is pointing relative to the vertical plane perpendicular to the image. Range [-180,180].
768    #[serde(rename = "panAngle")]
769    pub pan_angle: Option<f32>,
770    /// Roll angle, which indicates the amount of clockwise/anti-clockwise rotation of the face relative to the image vertical about the axis perpendicular to the face. Range [-180,180].
771    #[serde(rename = "rollAngle")]
772    pub roll_angle: Option<f32>,
773    /// Sorrow likelihood.
774    #[serde(rename = "sorrowLikelihood")]
775    pub sorrow_likelihood: Option<String>,
776    /// Surprise likelihood.
777    #[serde(rename = "surpriseLikelihood")]
778    pub surprise_likelihood: Option<String>,
779    /// Pitch angle, which indicates the upwards/downwards angle that the face is pointing relative to the image's horizontal plane. Range [-180,180].
780    #[serde(rename = "tiltAngle")]
781    pub tilt_angle: Option<f32>,
782    /// Under-exposed likelihood.
783    #[serde(rename = "underExposedLikelihood")]
784    pub under_exposed_likelihood: Option<String>,
785}
786
787impl common::Part for FaceAnnotation {}
788
789/// The type of Google Cloud Vision API detection to perform, and the maximum number of results to return for that type. Multiple `Feature` objects can be specified in the `features` list.
790///
791/// This type is not used in any activity, and only used as *part* of another schema.
792///
793#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
794#[serde_with::serde_as]
795#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
796pub struct Feature {
797    /// Maximum number of results of this type. Does not apply to `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`.
798    #[serde(rename = "maxResults")]
799    pub max_results: Option<i32>,
800    /// Model to use for the feature. Supported values: "builtin/stable" (the default if unset) and "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also support "builtin/rc" for the latest release candidate.
801    pub model: Option<String>,
802    /// The feature type.
803    #[serde(rename = "type")]
804    pub type_: Option<String>,
805}
806
807impl common::Part for Feature {}
808
809/// The Google Cloud Storage location where the output will be written to.
810///
811/// This type is not used in any activity, and only used as *part* of another schema.
812///
813#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
814#[serde_with::serde_as]
815#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
816pub struct GcsDestination {
817    /// Google Cloud Storage URI prefix where the results will be stored. Results will be in JSON format and preceded by its corresponding input URI prefix. This field can either represent a gcs file prefix or gcs directory. In either case, the uri should be unique because in order to get all of the output files, you will need to do a wildcard gcs search on the uri prefix you provide. Examples: * File Prefix: gs://bucket-name/here/filenameprefix The output files will be created in gs://bucket-name/here/ and the names of the output files will begin with "filenameprefix". * Directory Prefix: gs://bucket-name/some/location/ The output files will be created in gs://bucket-name/some/location/ and the names of the output files could be anything because there was no filename prefix specified. If multiple outputs, each response is still AnnotateFileResponse, each of which contains some subset of the full list of AnnotateImageResponse. Multiple outputs can happen if, for example, the output JSON is too large and overflows into multiple sharded files.
818    pub uri: Option<String>,
819}
820
821impl common::Part for GcsDestination {}
822
823/// The Google Cloud Storage location where the input will be read from.
824///
825/// This type is not used in any activity, and only used as *part* of another schema.
826///
827#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
828#[serde_with::serde_as]
829#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
830pub struct GcsSource {
831    /// Google Cloud Storage URI for the input file. This must only be a Google Cloud Storage object. Wildcards are not currently supported.
832    pub uri: Option<String>,
833}
834
835impl common::Part for GcsSource {}
836
837/// Information about the products similar to a single product in a query image.
838///
839/// This type is not used in any activity, and only used as *part* of another schema.
840///
841#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
842#[serde_with::serde_as]
843#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
844pub struct GroupedResult {
845    /// The bounding polygon around the product detected in the query image.
846    #[serde(rename = "boundingPoly")]
847    pub bounding_poly: Option<BoundingPoly>,
848    /// List of generic predictions for the object in the bounding box.
849    #[serde(rename = "objectAnnotations")]
850    pub object_annotations: Option<Vec<ObjectAnnotation>>,
851    /// List of results, one for each product match.
852    pub results: Option<Vec<Result>>,
853}
854
855impl common::Part for GroupedResult {}
856
857/// Client image to perform Google Cloud Vision API tasks over.
858///
859/// # Activities
860///
861/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
862/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
863///
864/// * [annotate images](ImageAnnotateCall) (none)
865/// * [async batch annotate images](ImageAsyncBatchAnnotateCall) (none)
866#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
867#[serde_with::serde_as]
868#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
869pub struct Image {
870    /// Image content, represented as a stream of bytes. Note: As with all `bytes` fields, protobuffers use a pure binary representation, whereas JSON representations use base64. Currently, this field only works for BatchAnnotateImages requests. It does not work for AsyncBatchAnnotateImages requests.
871    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
872    pub content: Option<Vec<u8>>,
873    /// Google Cloud Storage image location, or publicly-accessible image URL. If both `content` and `source` are provided for an image, `content` takes precedence and is used to perform the image annotation request.
874    pub source: Option<ImageSource>,
875}
876
877impl common::Resource for Image {}
878
879/// If an image was produced from a file (e.g. a PDF), this message gives information about the source of that image.
880///
881/// This type is not used in any activity, and only used as *part* of another schema.
882///
883#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
884#[serde_with::serde_as]
885#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
886pub struct ImageAnnotationContext {
887    /// If the file was a PDF or TIFF, this field gives the page number within the file used to produce the image.
888    #[serde(rename = "pageNumber")]
889    pub page_number: Option<i32>,
890    /// The URI of the file used to produce the image.
891    pub uri: Option<String>,
892}
893
894impl common::Part for ImageAnnotationContext {}
895
896/// Image context and/or feature-specific parameters.
897///
898/// This type is not used in any activity, and only used as *part* of another schema.
899///
900#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
901#[serde_with::serde_as]
902#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
903pub struct ImageContext {
904    /// Parameters for crop hints annotation request.
905    #[serde(rename = "cropHintsParams")]
906    pub crop_hints_params: Option<CropHintsParams>,
907    /// List of languages to use for TEXT_DETECTION. In most cases, an empty value yields the best results since it enables automatic language detection. For languages based on the Latin alphabet, setting `language_hints` is not needed. In rare cases, when the language of the text in the image is known, setting a hint will help get better results (although it will be a significant hindrance if the hint is wrong). Text detection returns an error if one or more of the specified languages is not one of the [supported languages](https://cloud.google.com/vision/docs/languages).
908    #[serde(rename = "languageHints")]
909    pub language_hints: Option<Vec<String>>,
910    /// Not used.
911    #[serde(rename = "latLongRect")]
912    pub lat_long_rect: Option<LatLongRect>,
913    /// Parameters for product search.
914    #[serde(rename = "productSearchParams")]
915    pub product_search_params: Option<ProductSearchParams>,
916    /// Parameters for text detection and document text detection.
917    #[serde(rename = "textDetectionParams")]
918    pub text_detection_params: Option<TextDetectionParams>,
919    /// Parameters for web detection.
920    #[serde(rename = "webDetectionParams")]
921    pub web_detection_params: Option<WebDetectionParams>,
922}
923
924impl common::Part for ImageContext {}
925
926/// Stores image properties, such as dominant colors.
927///
928/// This type is not used in any activity, and only used as *part* of another schema.
929///
930#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
931#[serde_with::serde_as]
932#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
933pub struct ImageProperties {
934    /// If present, dominant colors completed successfully.
935    #[serde(rename = "dominantColors")]
936    pub dominant_colors: Option<DominantColorsAnnotation>,
937}
938
939impl common::Part for ImageProperties {}
940
941/// External image source (Google Cloud Storage or web URL image location).
942///
943/// This type is not used in any activity, and only used as *part* of another schema.
944///
945#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
946#[serde_with::serde_as]
947#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
948pub struct ImageSource {
949    /// **Use `image_uri` instead.** The Google Cloud Storage URI of the form `gs://bucket_name/object_name`. Object versioning is not supported. See [Google Cloud Storage Request URIs](https://cloud.google.com/storage/docs/reference-uris) for more info.
950    #[serde(rename = "gcsImageUri")]
951    pub gcs_image_uri: Option<String>,
952    /// The URI of the source image. Can be either: 1. A Google Cloud Storage URI of the form `gs://bucket_name/object_name`. Object versioning is not supported. See [Google Cloud Storage Request URIs](https://cloud.google.com/storage/docs/reference-uris) for more info. 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from HTTP/HTTPS URLs, Google cannot guarantee that the request will be completed. Your request may fail if the specified host denies the request (e.g. due to request throttling or DOS prevention), or if Google throttles requests to the site for abuse prevention. You should not depend on externally-hosted images for production applications. When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes precedence.
953    #[serde(rename = "imageUri")]
954    pub image_uri: Option<String>,
955}
956
957impl common::Part for ImageSource {}
958
959/// The Google Cloud Storage location for a csv file which preserves a list of ImportProductSetRequests in each line.
960///
961/// This type is not used in any activity, and only used as *part* of another schema.
962///
963#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
964#[serde_with::serde_as]
965#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
966pub struct ImportProductSetsGcsSource {
967    /// The Google Cloud Storage URI of the input csv file. The URI must start with `gs://`. The format of the input csv file should be one image per line. In each line, there are 8 columns. 1. image-uri 2. image-id 3. product-set-id 4. product-id 5. product-category 6. product-display-name 7. labels 8. bounding-poly The `image-uri`, `product-set-id`, `product-id`, and `product-category` columns are required. All other columns are optional. If the `ProductSet` or `Product` specified by the `product-set-id` and `product-id` values does not exist, then the system will create a new `ProductSet` or `Product` for the image. In this case, the `product-display-name` column refers to display_name, the `product-category` column refers to product_category, and the `labels` column refers to product_labels. The `image-id` column is optional but must be unique if provided. If it is empty, the system will automatically assign a unique id to the image. The `product-display-name` column is optional. If it is empty, the system sets the display_name field for the product to a space (" "). You can update the `display_name` later by using the API. If a `Product` with the specified `product-id` already exists, then the system ignores the `product-display-name`, `product-category`, and `labels` columns. The `labels` column (optional) is a line containing a list of comma-separated key-value pairs, in the following format: "key_1=value_1,key_2=value_2,...,key_n=value_n" The `bounding-poly` column (optional) identifies one region of interest from the image in the same manner as `CreateReferenceImage`. If you do not specify the `bounding-poly` column, then the system will try to detect regions of interest automatically. At most one `bounding-poly` column is allowed per line. If the image contains multiple regions of interest, add a line to the CSV file that includes the same product information, and the `bounding-poly` values for each region of interest. The `bounding-poly` column must contain an even number of comma-separated numbers, in the format "p1_x,p1_y,p2_x,p2_y,...,pn_x,pn_y". Use non-negative integers for absolute bounding polygons, and float values in [0, 1] for normalized bounding polygons. The system will resize the image if the image resolution is too large to process (larger than 20MP).
968    #[serde(rename = "csvFileUri")]
969    pub csv_file_uri: Option<String>,
970}
971
972impl common::Part for ImportProductSetsGcsSource {}
973
974/// The input content for the `ImportProductSets` method.
975///
976/// This type is not used in any activity, and only used as *part* of another schema.
977///
978#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
979#[serde_with::serde_as]
980#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
981pub struct ImportProductSetsInputConfig {
982    /// The Google Cloud Storage location for a csv file which preserves a list of ImportProductSetRequests in each line.
983    #[serde(rename = "gcsSource")]
984    pub gcs_source: Option<ImportProductSetsGcsSource>,
985}
986
987impl common::Part for ImportProductSetsInputConfig {}
988
989/// Request message for the `ImportProductSets` method.
990///
991/// # Activities
992///
993/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
994/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
995///
996/// * [locations product sets import projects](ProjectLocationProductSetImportCall) (request)
997#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
998#[serde_with::serde_as]
999#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1000pub struct ImportProductSetsRequest {
1001    /// Required. The input content for the list of requests.
1002    #[serde(rename = "inputConfig")]
1003    pub input_config: Option<ImportProductSetsInputConfig>,
1004}
1005
1006impl common::RequestValue for ImportProductSetsRequest {}
1007
1008/// The desired input location and metadata.
1009///
1010/// This type is not used in any activity, and only used as *part* of another schema.
1011///
1012#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1013#[serde_with::serde_as]
1014#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1015pub struct InputConfig {
1016    /// File content, represented as a stream of bytes. Note: As with all `bytes` fields, protobuffers use a pure binary representation, whereas JSON representations use base64. Currently, this field only works for BatchAnnotateFiles requests. It does not work for AsyncBatchAnnotateFiles requests.
1017    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1018    pub content: Option<Vec<u8>>,
1019    /// The Google Cloud Storage location to read the input from.
1020    #[serde(rename = "gcsSource")]
1021    pub gcs_source: Option<GcsSource>,
1022    /// The type of the file. Currently only "application/pdf", "image/tiff" and "image/gif" are supported. Wildcards are not supported.
1023    #[serde(rename = "mimeType")]
1024    pub mime_type: Option<String>,
1025}
1026
1027impl common::Part for InputConfig {}
1028
1029/// A product label represented as a key-value pair.
1030///
1031/// This type is not used in any activity, and only used as *part* of another schema.
1032///
1033#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1034#[serde_with::serde_as]
1035#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1036pub struct KeyValue {
1037    /// The key of the label attached to the product. Cannot be empty and cannot exceed 128 bytes.
1038    pub key: Option<String>,
1039    /// The value of the label attached to the product. Cannot be empty and cannot exceed 128 bytes.
1040    pub value: Option<String>,
1041}
1042
1043impl common::Part for KeyValue {}
1044
1045/// A face-specific landmark (for example, a face feature). Landmark positions may fall outside the bounds of the image if the face is near one or more edges of the image. Therefore it is NOT guaranteed that `0 <= x < width` or `0 <= y < height`.
1046///
1047/// This type is not used in any activity, and only used as *part* of another schema.
1048///
1049#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1050#[serde_with::serde_as]
1051#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1052pub struct Landmark {
1053    /// Face landmark position.
1054    pub position: Option<Position>,
1055    /// Face landmark type.
1056    #[serde(rename = "type")]
1057    pub type_: Option<String>,
1058}
1059
1060impl common::Part for Landmark {}
1061
1062/// An object that represents a latitude/longitude pair. This is expressed as a pair of doubles to represent degrees latitude and degrees longitude. Unless specified otherwise, this object must conform to the WGS84 standard. Values must be within normalized ranges.
1063///
1064/// This type is not used in any activity, and only used as *part* of another schema.
1065///
1066#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1067#[serde_with::serde_as]
1068#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1069pub struct LatLng {
1070    /// The latitude in degrees. It must be in the range [-90.0, +90.0].
1071    pub latitude: Option<f64>,
1072    /// The longitude in degrees. It must be in the range [-180.0, +180.0].
1073    pub longitude: Option<f64>,
1074}
1075
1076impl common::Part for LatLng {}
1077
1078/// Rectangle determined by min and max `LatLng` pairs.
1079///
1080/// This type is not used in any activity, and only used as *part* of another schema.
1081///
1082#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1083#[serde_with::serde_as]
1084#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1085pub struct LatLongRect {
1086    /// Max lat/long pair.
1087    #[serde(rename = "maxLatLng")]
1088    pub max_lat_lng: Option<LatLng>,
1089    /// Min lat/long pair.
1090    #[serde(rename = "minLatLng")]
1091    pub min_lat_lng: Option<LatLng>,
1092}
1093
1094impl common::Part for LatLongRect {}
1095
1096/// The response message for Operations.ListOperations.
1097///
1098/// # Activities
1099///
1100/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1101/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1102///
1103/// * [list operations](OperationListCall) (response)
1104#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1105#[serde_with::serde_as]
1106#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1107pub struct ListOperationsResponse {
1108    /// The standard List next-page token.
1109    #[serde(rename = "nextPageToken")]
1110    pub next_page_token: Option<String>,
1111    /// A list of operations that matches the specified filter in the request.
1112    pub operations: Option<Vec<Operation>>,
1113    /// 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.
1114    pub unreachable: Option<Vec<String>>,
1115}
1116
1117impl common::ResponseResult for ListOperationsResponse {}
1118
1119/// Response message for the `ListProductSets` method.
1120///
1121/// # Activities
1122///
1123/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1124/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1125///
1126/// * [locations product sets list projects](ProjectLocationProductSetListCall) (response)
1127#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1128#[serde_with::serde_as]
1129#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1130pub struct ListProductSetsResponse {
1131    /// Token to retrieve the next page of results, or empty if there are no more results in the list.
1132    #[serde(rename = "nextPageToken")]
1133    pub next_page_token: Option<String>,
1134    /// List of ProductSets.
1135    #[serde(rename = "productSets")]
1136    pub product_sets: Option<Vec<ProductSet>>,
1137}
1138
1139impl common::ResponseResult for ListProductSetsResponse {}
1140
1141/// Response message for the `ListProductsInProductSet` method.
1142///
1143/// # Activities
1144///
1145/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1146/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1147///
1148/// * [locations product sets products list projects](ProjectLocationProductSetProductListCall) (response)
1149#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1150#[serde_with::serde_as]
1151#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1152pub struct ListProductsInProductSetResponse {
1153    /// Token to retrieve the next page of results, or empty if there are no more results in the list.
1154    #[serde(rename = "nextPageToken")]
1155    pub next_page_token: Option<String>,
1156    /// The list of Products.
1157    pub products: Option<Vec<Product>>,
1158}
1159
1160impl common::ResponseResult for ListProductsInProductSetResponse {}
1161
1162/// Response message for the `ListProducts` method.
1163///
1164/// # Activities
1165///
1166/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1167/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1168///
1169/// * [locations products list projects](ProjectLocationProductListCall) (response)
1170#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1171#[serde_with::serde_as]
1172#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1173pub struct ListProductsResponse {
1174    /// Token to retrieve the next page of results, or empty if there are no more results in the list.
1175    #[serde(rename = "nextPageToken")]
1176    pub next_page_token: Option<String>,
1177    /// List of products.
1178    pub products: Option<Vec<Product>>,
1179}
1180
1181impl common::ResponseResult for ListProductsResponse {}
1182
1183/// Response message for the `ListReferenceImages` method.
1184///
1185/// # Activities
1186///
1187/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1188/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1189///
1190/// * [locations products reference images list projects](ProjectLocationProductReferenceImageListCall) (response)
1191#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1192#[serde_with::serde_as]
1193#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1194pub struct ListReferenceImagesResponse {
1195    /// The next_page_token returned from a previous List request, if any.
1196    #[serde(rename = "nextPageToken")]
1197    pub next_page_token: Option<String>,
1198    /// The maximum number of items to return. Default 10, maximum 100.
1199    #[serde(rename = "pageSize")]
1200    pub page_size: Option<i32>,
1201    /// The list of reference images.
1202    #[serde(rename = "referenceImages")]
1203    pub reference_images: Option<Vec<ReferenceImage>>,
1204}
1205
1206impl common::ResponseResult for ListReferenceImagesResponse {}
1207
1208/// Set of detected objects with bounding boxes.
1209///
1210/// This type is not used in any activity, and only used as *part* of another schema.
1211///
1212#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1213#[serde_with::serde_as]
1214#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1215pub struct LocalizedObjectAnnotation {
1216    /// Image region to which this object belongs. This must be populated.
1217    #[serde(rename = "boundingPoly")]
1218    pub bounding_poly: Option<BoundingPoly>,
1219    /// The BCP-47 language code, such as "en-US" or "sr-Latn". For more information, see http://www.unicode.org/reports/tr35/#Unicode_locale_identifier.
1220    #[serde(rename = "languageCode")]
1221    pub language_code: Option<String>,
1222    /// Object ID that should align with EntityAnnotation mid.
1223    pub mid: Option<String>,
1224    /// Object name, expressed in its `language_code` language.
1225    pub name: Option<String>,
1226    /// Score of the result. Range [0, 1].
1227    pub score: Option<f32>,
1228}
1229
1230impl common::Part for LocalizedObjectAnnotation {}
1231
1232/// Detected entity location information.
1233///
1234/// This type is not used in any activity, and only used as *part* of another schema.
1235///
1236#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1237#[serde_with::serde_as]
1238#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1239pub struct LocationInfo {
1240    /// lat/long location coordinates.
1241    #[serde(rename = "latLng")]
1242    pub lat_lng: Option<LatLng>,
1243}
1244
1245impl common::Part for LocationInfo {}
1246
1247/// 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.
1248///
1249/// This type is not used in any activity, and only used as *part* of another schema.
1250///
1251#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1252#[serde_with::serde_as]
1253#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1254pub struct NormalizedVertex {
1255    /// X coordinate.
1256    pub x: Option<f32>,
1257    /// Y coordinate.
1258    pub y: Option<f32>,
1259}
1260
1261impl common::Part for NormalizedVertex {}
1262
1263/// Prediction for what the object in the bounding box is.
1264///
1265/// This type is not used in any activity, and only used as *part* of another schema.
1266///
1267#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1268#[serde_with::serde_as]
1269#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1270pub struct ObjectAnnotation {
1271    /// The BCP-47 language code, such as "en-US" or "sr-Latn". For more information, see http://www.unicode.org/reports/tr35/#Unicode_locale_identifier.
1272    #[serde(rename = "languageCode")]
1273    pub language_code: Option<String>,
1274    /// Object ID that should align with EntityAnnotation mid.
1275    pub mid: Option<String>,
1276    /// Object name, expressed in its `language_code` language.
1277    pub name: Option<String>,
1278    /// Score of the result. Range [0, 1].
1279    pub score: Option<f32>,
1280}
1281
1282impl common::Part for ObjectAnnotation {}
1283
1284/// This resource represents a long-running operation that is the result of a network API call.
1285///
1286/// # Activities
1287///
1288/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1289/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1290///
1291/// * [async batch annotate files](FileAsyncBatchAnnotateCall) (response)
1292/// * [async batch annotate images](ImageAsyncBatchAnnotateCall) (response)
1293/// * [operations get locations](LocationOperationGetCall) (response)
1294/// * [cancel operations](OperationCancelCall) (none)
1295/// * [delete operations](OperationDeleteCall) (none)
1296/// * [get operations](OperationGetCall) (response)
1297/// * [list operations](OperationListCall) (none)
1298/// * [files async batch annotate projects](ProjectFileAsyncBatchAnnotateCall) (response)
1299/// * [images async batch annotate projects](ProjectImageAsyncBatchAnnotateCall) (response)
1300/// * [locations files async batch annotate projects](ProjectLocationFileAsyncBatchAnnotateCall) (response)
1301/// * [locations images async batch annotate projects](ProjectLocationImageAsyncBatchAnnotateCall) (response)
1302/// * [locations operations get projects](ProjectLocationOperationGetCall) (response)
1303/// * [locations product sets import projects](ProjectLocationProductSetImportCall) (response)
1304/// * [locations products purge projects](ProjectLocationProductPurgeCall) (response)
1305/// * [operations get projects](ProjectOperationGetCall) (response)
1306#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1307#[serde_with::serde_as]
1308#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1309pub struct Operation {
1310    /// 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.
1311    pub done: Option<bool>,
1312    /// The error result of the operation in case of failure or cancellation.
1313    pub error: Option<Status>,
1314    /// 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.
1315    pub metadata: Option<HashMap<String, serde_json::Value>>,
1316    /// 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}`.
1317    pub name: Option<String>,
1318    /// 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`.
1319    pub response: Option<HashMap<String, serde_json::Value>>,
1320}
1321
1322impl common::Resource for Operation {}
1323impl common::ResponseResult for Operation {}
1324
1325/// The desired output location and metadata.
1326///
1327/// This type is not used in any activity, and only used as *part* of another schema.
1328///
1329#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1330#[serde_with::serde_as]
1331#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1332pub struct OutputConfig {
1333    /// The max number of response protos to put into each output JSON file on Google Cloud Storage. The valid range is [1, 100]. If not specified, the default value is 20. For example, for one pdf file with 100 pages, 100 response protos will be generated. If `batch_size` = 20, then 5 json files each containing 20 response protos will be written under the prefix `gcs_destination`.`uri`. Currently, batch_size only applies to GcsDestination, with potential future support for other output configurations.
1334    #[serde(rename = "batchSize")]
1335    pub batch_size: Option<i32>,
1336    /// The Google Cloud Storage location to write the output(s) to.
1337    #[serde(rename = "gcsDestination")]
1338    pub gcs_destination: Option<GcsDestination>,
1339}
1340
1341impl common::Part for OutputConfig {}
1342
1343/// Detected page from OCR.
1344///
1345/// This type is not used in any activity, and only used as *part* of another schema.
1346///
1347#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1348#[serde_with::serde_as]
1349#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1350pub struct Page {
1351    /// List of blocks of text, images etc on this page.
1352    pub blocks: Option<Vec<Block>>,
1353    /// Confidence of the OCR results on the page. Range [0, 1].
1354    pub confidence: Option<f32>,
1355    /// Page height. For PDFs the unit is points. For images (including TIFFs) the unit is pixels.
1356    pub height: Option<i32>,
1357    /// Additional information detected on the page.
1358    pub property: Option<TextProperty>,
1359    /// Page width. For PDFs the unit is points. For images (including TIFFs) the unit is pixels.
1360    pub width: Option<i32>,
1361}
1362
1363impl common::Part for Page {}
1364
1365/// Structural unit of text representing a number of words in certain order.
1366///
1367/// This type is not used in any activity, and only used as *part* of another schema.
1368///
1369#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1370#[serde_with::serde_as]
1371#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1372pub struct Paragraph {
1373    /// The bounding box for the paragraph. The vertices are in the order of top-left, top-right, bottom-right, bottom-left. When a rotation of the bounding box is detected the rotation is represented as around the top-left corner as defined when the text is read in the 'natural' orientation. For example: * when the text is horizontal it might look like: 0----1 | | 3----2 * when it's rotated 180 degrees around the top-left corner it becomes: 2----3 | | 1----0 and the vertex order will still be (0, 1, 2, 3).
1374    #[serde(rename = "boundingBox")]
1375    pub bounding_box: Option<BoundingPoly>,
1376    /// Confidence of the OCR results for the paragraph. Range [0, 1].
1377    pub confidence: Option<f32>,
1378    /// Additional information detected for the paragraph.
1379    pub property: Option<TextProperty>,
1380    /// List of all words in this paragraph.
1381    pub words: Option<Vec<Word>>,
1382}
1383
1384impl common::Part for Paragraph {}
1385
1386/// A 3D position in the image, used primarily for Face detection landmarks. A valid Position must have both x and y coordinates. The position coordinates are in the same scale as the original image.
1387///
1388/// This type is not used in any activity, and only used as *part* of another schema.
1389///
1390#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1391#[serde_with::serde_as]
1392#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1393pub struct Position {
1394    /// X coordinate.
1395    pub x: Option<f32>,
1396    /// Y coordinate.
1397    pub y: Option<f32>,
1398    /// Z coordinate (or depth).
1399    pub z: Option<f32>,
1400}
1401
1402impl common::Part for Position {}
1403
1404/// A Product contains ReferenceImages.
1405///
1406/// # Activities
1407///
1408/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1409/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1410///
1411/// * [locations products create projects](ProjectLocationProductCreateCall) (request|response)
1412/// * [locations products get projects](ProjectLocationProductGetCall) (response)
1413/// * [locations products patch projects](ProjectLocationProductPatchCall) (request|response)
1414#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1415#[serde_with::serde_as]
1416#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1417pub struct Product {
1418    /// User-provided metadata to be stored with this product. Must be at most 4096 characters long.
1419    pub description: Option<String>,
1420    /// The user-provided name for this Product. Must not be empty. Must be at most 4096 characters long.
1421    #[serde(rename = "displayName")]
1422    pub display_name: Option<String>,
1423    /// The resource name of the product. Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. This field is ignored when creating a product.
1424    pub name: Option<String>,
1425    /// Immutable. The category for the product identified by the reference image. This should be one of "homegoods-v2", "apparel-v2", "toys-v2", "packagedgoods-v1" or "general-v1". The legacy categories "homegoods", "apparel", and "toys" are still supported, but these should not be used for new products.
1426    #[serde(rename = "productCategory")]
1427    pub product_category: Option<String>,
1428    /// Key-value pairs that can be attached to a product. At query time, constraints can be specified based on the product_labels. Note that integer values can be provided as strings, e.g. "1199". Only strings with integer values can match a range-based restriction which is to be supported soon. Multiple values can be assigned to the same key. One product may have up to 500 product_labels. Notice that the total number of distinct product_labels over all products in one ProductSet cannot exceed 1M, otherwise the product search pipeline will refuse to work for that ProductSet.
1429    #[serde(rename = "productLabels")]
1430    pub product_labels: Option<Vec<KeyValue>>,
1431}
1432
1433impl common::RequestValue for Product {}
1434impl common::ResponseResult for Product {}
1435
1436/// Parameters for a product search request.
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 ProductSearchParams {
1444    /// The bounding polygon around the area of interest in the image. If it is not specified, system discretion will be applied.
1445    #[serde(rename = "boundingPoly")]
1446    pub bounding_poly: Option<BoundingPoly>,
1447    /// The filtering expression. This can be used to restrict search results based on Product labels. We currently support an AND of OR of key-value expressions, where each expression within an OR must have the same key. An '=' should be used to connect the key and value. For example, "(color = red OR color = blue) AND brand = Google" is acceptable, but "(color = red OR brand = Google)" is not acceptable. "color: red" is not acceptable because it uses a ':' instead of an '='.
1448    pub filter: Option<String>,
1449    /// The list of product categories to search in. Currently, we only consider the first category, and either "homegoods-v2", "apparel-v2", "toys-v2", "packagedgoods-v1", or "general-v1" should be specified. The legacy categories "homegoods", "apparel", and "toys" are still supported but will be deprecated. For new products, please use "homegoods-v2", "apparel-v2", or "toys-v2" for better product search accuracy. It is recommended to migrate existing products to these categories as well.
1450    #[serde(rename = "productCategories")]
1451    pub product_categories: Option<Vec<String>>,
1452    /// The resource name of a ProductSet to be searched for similar images. Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`.
1453    #[serde(rename = "productSet")]
1454    pub product_set: Option<String>,
1455}
1456
1457impl common::Part for ProductSearchParams {}
1458
1459/// Results for a product search request.
1460///
1461/// This type is not used in any activity, and only used as *part* of another schema.
1462///
1463#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1464#[serde_with::serde_as]
1465#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1466pub struct ProductSearchResults {
1467    /// Timestamp of the index which provided these results. Products added to the product set and products removed from the product set after this time are not reflected in the current results.
1468    #[serde(rename = "indexTime")]
1469    pub index_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1470    /// List of results grouped by products detected in the query image. Each entry corresponds to one bounding polygon in the query image, and contains the matching products specific to that region. There may be duplicate product matches in the union of all the per-product results.
1471    #[serde(rename = "productGroupedResults")]
1472    pub product_grouped_results: Option<Vec<GroupedResult>>,
1473    /// List of results, one for each product match.
1474    pub results: Option<Vec<Result>>,
1475}
1476
1477impl common::Part for ProductSearchResults {}
1478
1479/// A ProductSet contains Products. A ProductSet can contain a maximum of 1 million reference images. If the limit is exceeded, periodic indexing will fail.
1480///
1481/// # Activities
1482///
1483/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1484/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1485///
1486/// * [locations product sets create projects](ProjectLocationProductSetCreateCall) (request|response)
1487/// * [locations product sets get projects](ProjectLocationProductSetGetCall) (response)
1488/// * [locations product sets patch projects](ProjectLocationProductSetPatchCall) (request|response)
1489#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1490#[serde_with::serde_as]
1491#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1492pub struct ProductSet {
1493    /// The user-provided name for this ProductSet. Must not be empty. Must be at most 4096 characters long.
1494    #[serde(rename = "displayName")]
1495    pub display_name: Option<String>,
1496    /// Output only. If there was an error with indexing the product set, the field is populated. This field is ignored when creating a ProductSet.
1497    #[serde(rename = "indexError")]
1498    pub index_error: Option<Status>,
1499    /// Output only. The time at which this ProductSet was last indexed. Query results will reflect all updates before this time. If this ProductSet has never been indexed, this timestamp is the default value "1970-01-01T00:00:00Z". This field is ignored when creating a ProductSet.
1500    #[serde(rename = "indexTime")]
1501    pub index_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1502    /// The resource name of the ProductSet. Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. This field is ignored when creating a ProductSet.
1503    pub name: Option<String>,
1504}
1505
1506impl common::RequestValue for ProductSet {}
1507impl common::ResponseResult for ProductSet {}
1508
1509/// Config to control which ProductSet contains the Products to be deleted.
1510///
1511/// This type is not used in any activity, and only used as *part* of another schema.
1512///
1513#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1514#[serde_with::serde_as]
1515#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1516pub struct ProductSetPurgeConfig {
1517    /// The ProductSet that contains the Products to delete. If a Product is a member of product_set_id in addition to other ProductSets, the Product will still be deleted.
1518    #[serde(rename = "productSetId")]
1519    pub product_set_id: Option<String>,
1520}
1521
1522impl common::Part for ProductSetPurgeConfig {}
1523
1524/// A `Property` consists of a user-supplied name/value pair.
1525///
1526/// This type is not used in any activity, and only used as *part* of another schema.
1527///
1528#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1529#[serde_with::serde_as]
1530#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1531pub struct Property {
1532    /// Name of the property.
1533    pub name: Option<String>,
1534    /// Value of numeric properties.
1535    #[serde(rename = "uint64Value")]
1536    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1537    pub uint64_value: Option<u64>,
1538    /// Value of the property.
1539    pub value: Option<String>,
1540}
1541
1542impl common::Part for Property {}
1543
1544/// Request message for the `PurgeProducts` method.
1545///
1546/// # Activities
1547///
1548/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1549/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1550///
1551/// * [locations products purge projects](ProjectLocationProductPurgeCall) (request)
1552#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1553#[serde_with::serde_as]
1554#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1555pub struct PurgeProductsRequest {
1556    /// If delete_orphan_products is true, all Products that are not in any ProductSet will be deleted.
1557    #[serde(rename = "deleteOrphanProducts")]
1558    pub delete_orphan_products: Option<bool>,
1559    /// The default value is false. Override this value to true to actually perform the purge.
1560    pub force: Option<bool>,
1561    /// Specify which ProductSet contains the Products to be deleted.
1562    #[serde(rename = "productSetPurgeConfig")]
1563    pub product_set_purge_config: Option<ProductSetPurgeConfig>,
1564}
1565
1566impl common::RequestValue for PurgeProductsRequest {}
1567
1568/// A `ReferenceImage` represents a product image and its associated metadata, such as bounding boxes.
1569///
1570/// # Activities
1571///
1572/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1573/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1574///
1575/// * [locations products reference images create projects](ProjectLocationProductReferenceImageCreateCall) (request|response)
1576/// * [locations products reference images get projects](ProjectLocationProductReferenceImageGetCall) (response)
1577#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1578#[serde_with::serde_as]
1579#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1580pub struct ReferenceImage {
1581    /// Optional. Bounding polygons around the areas of interest in the reference image. If this field is empty, the system will try to detect regions of interest. At most 10 bounding polygons will be used. The provided shape is converted into a non-rotated rectangle. Once converted, the small edge of the rectangle must be greater than or equal to 300 pixels. The aspect ratio must be 1:4 or less (i.e. 1:3 is ok; 1:5 is not).
1582    #[serde(rename = "boundingPolys")]
1583    pub bounding_polys: Option<Vec<BoundingPoly>>,
1584    /// The resource name of the reference image. Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`. This field is ignored when creating a reference image.
1585    pub name: Option<String>,
1586    /// Required. The Google Cloud Storage URI of the reference image. The URI must start with `gs://`.
1587    pub uri: Option<String>,
1588}
1589
1590impl common::RequestValue for ReferenceImage {}
1591impl common::ResponseResult for ReferenceImage {}
1592
1593/// Request message for the `RemoveProductFromProductSet` method.
1594///
1595/// # Activities
1596///
1597/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1598/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1599///
1600/// * [locations product sets remove product projects](ProjectLocationProductSetRemoveProductCall) (request)
1601#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1602#[serde_with::serde_as]
1603#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1604pub struct RemoveProductFromProductSetRequest {
1605    /// Required. The resource name for the Product to be removed from this ProductSet. Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
1606    pub product: Option<String>,
1607}
1608
1609impl common::RequestValue for RemoveProductFromProductSetRequest {}
1610
1611/// Information about a product.
1612///
1613/// This type is not used in any activity, and only used as *part* of another schema.
1614///
1615#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1616#[serde_with::serde_as]
1617#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1618pub struct Result {
1619    /// The resource name of the image from the product that is the closest match to the query.
1620    pub image: Option<String>,
1621    /// The Product.
1622    pub product: Option<Product>,
1623    /// A confidence level on the match, ranging from 0 (no confidence) to 1 (full confidence).
1624    pub score: Option<f32>,
1625}
1626
1627impl common::Part for Result {}
1628
1629/// Set of features pertaining to the image, computed by computer vision methods over safe-search verticals (for example, adult, spoof, medical, violence).
1630///
1631/// This type is not used in any activity, and only used as *part* of another schema.
1632///
1633#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1634#[serde_with::serde_as]
1635#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1636pub struct SafeSearchAnnotation {
1637    /// Represents the adult content likelihood for the image. Adult content may contain elements such as nudity, pornographic images or cartoons, or sexual activities.
1638    pub adult: Option<String>,
1639    /// Likelihood that this is a medical image.
1640    pub medical: Option<String>,
1641    /// Likelihood that the request image contains racy content. Racy content may include (but is not limited to) skimpy or sheer clothing, strategically covered nudity, lewd or provocative poses, or close-ups of sensitive body areas.
1642    pub racy: Option<String>,
1643    /// Spoof likelihood. The likelihood that an modification was made to the image's canonical version to make it appear funny or offensive.
1644    pub spoof: Option<String>,
1645    /// Likelihood that this image contains violent content. Violent content may include death, serious harm, or injury to individuals or groups of individuals.
1646    pub violence: Option<String>,
1647}
1648
1649impl common::Part for SafeSearchAnnotation {}
1650
1651/// 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).
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 Status {
1659    /// The status code, which should be an enum value of google.rpc.Code.
1660    pub code: Option<i32>,
1661    /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
1662    pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
1663    /// 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.
1664    pub message: Option<String>,
1665}
1666
1667impl common::Part for Status {}
1668
1669/// A single symbol representation.
1670///
1671/// This type is not used in any activity, and only used as *part* of another schema.
1672///
1673#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1674#[serde_with::serde_as]
1675#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1676pub struct Symbol {
1677    /// The bounding box for the symbol. The vertices are in the order of top-left, top-right, bottom-right, bottom-left. When a rotation of the bounding box is detected the rotation is represented as around the top-left corner as defined when the text is read in the 'natural' orientation. For example: * when the text is horizontal it might look like: 0----1 | | 3----2 * when it's rotated 180 degrees around the top-left corner it becomes: 2----3 | | 1----0 and the vertex order will still be (0, 1, 2, 3).
1678    #[serde(rename = "boundingBox")]
1679    pub bounding_box: Option<BoundingPoly>,
1680    /// Confidence of the OCR results for the symbol. Range [0, 1].
1681    pub confidence: Option<f32>,
1682    /// Additional information detected for the symbol.
1683    pub property: Option<TextProperty>,
1684    /// The actual UTF-8 representation of the symbol.
1685    pub text: Option<String>,
1686}
1687
1688impl common::Part for Symbol {}
1689
1690/// TextAnnotation contains a structured representation of OCR extracted text. The hierarchy of an OCR extracted text structure is like this: TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol Each structural component, starting from Page, may further have their own properties. Properties describe detected languages, breaks etc.. Please refer to the TextAnnotation.TextProperty message definition below for more detail.
1691///
1692/// This type is not used in any activity, and only used as *part* of another schema.
1693///
1694#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1695#[serde_with::serde_as]
1696#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1697pub struct TextAnnotation {
1698    /// List of pages detected by OCR.
1699    pub pages: Option<Vec<Page>>,
1700    /// UTF-8 text detected on the pages.
1701    pub text: Option<String>,
1702}
1703
1704impl common::Part for TextAnnotation {}
1705
1706/// Parameters for text detections. This is used to control TEXT_DETECTION and DOCUMENT_TEXT_DETECTION features.
1707///
1708/// This type is not used in any activity, and only used as *part* of another schema.
1709///
1710#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1711#[serde_with::serde_as]
1712#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1713pub struct TextDetectionParams {
1714    /// 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.
1715    #[serde(rename = "advancedOcrOptions")]
1716    pub advanced_ocr_options: Option<Vec<String>>,
1717    /// By default, Cloud Vision API only includes confidence score for DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence score for TEXT_DETECTION as well.
1718    #[serde(rename = "enableTextDetectionConfidenceScore")]
1719    pub enable_text_detection_confidence_score: Option<bool>,
1720}
1721
1722impl common::Part for TextDetectionParams {}
1723
1724/// Additional information detected on the structural component.
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 TextProperty {
1732    /// Detected start or end of a text segment.
1733    #[serde(rename = "detectedBreak")]
1734    pub detected_break: Option<DetectedBreak>,
1735    /// A list of detected languages together with confidence.
1736    #[serde(rename = "detectedLanguages")]
1737    pub detected_languages: Option<Vec<DetectedLanguage>>,
1738}
1739
1740impl common::Part for TextProperty {}
1741
1742/// A vertex represents a 2D point in the image. NOTE: the vertex coordinates are in the same scale as the original image.
1743///
1744/// This type is not used in any activity, and only used as *part* of another schema.
1745///
1746#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1747#[serde_with::serde_as]
1748#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1749pub struct Vertex {
1750    /// X coordinate.
1751    pub x: Option<i32>,
1752    /// Y coordinate.
1753    pub y: Option<i32>,
1754}
1755
1756impl common::Part for Vertex {}
1757
1758/// Relevant information for the image from the Internet.
1759///
1760/// This type is not used in any activity, and only used as *part* of another schema.
1761///
1762#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1763#[serde_with::serde_as]
1764#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1765pub struct WebDetection {
1766    /// The service's best guess as to the topic of the request image. Inferred from similar images on the open web.
1767    #[serde(rename = "bestGuessLabels")]
1768    pub best_guess_labels: Option<Vec<WebLabel>>,
1769    /// Fully matching images from the Internet. Can include resized copies of the query image.
1770    #[serde(rename = "fullMatchingImages")]
1771    pub full_matching_images: Option<Vec<WebImage>>,
1772    /// Web pages containing the matching images from the Internet.
1773    #[serde(rename = "pagesWithMatchingImages")]
1774    pub pages_with_matching_images: Option<Vec<WebPage>>,
1775    /// Partial matching images from the Internet. Those images are similar enough to share some key-point features. For example an original image will likely have partial matching for its crops.
1776    #[serde(rename = "partialMatchingImages")]
1777    pub partial_matching_images: Option<Vec<WebImage>>,
1778    /// The visually similar image results.
1779    #[serde(rename = "visuallySimilarImages")]
1780    pub visually_similar_images: Option<Vec<WebImage>>,
1781    /// Deduced entities from similar images on the Internet.
1782    #[serde(rename = "webEntities")]
1783    pub web_entities: Option<Vec<WebEntity>>,
1784}
1785
1786impl common::Part for WebDetection {}
1787
1788/// Parameters for web detection request.
1789///
1790/// This type is not used in any activity, and only used as *part* of another schema.
1791///
1792#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1793#[serde_with::serde_as]
1794#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1795pub struct WebDetectionParams {
1796    /// This field has no effect on results.
1797    #[serde(rename = "includeGeoResults")]
1798    pub include_geo_results: Option<bool>,
1799}
1800
1801impl common::Part for WebDetectionParams {}
1802
1803/// Entity deduced from similar images on the Internet.
1804///
1805/// This type is not used in any activity, and only used as *part* of another schema.
1806///
1807#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1808#[serde_with::serde_as]
1809#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1810pub struct WebEntity {
1811    /// Canonical description of the entity, in English.
1812    pub description: Option<String>,
1813    /// Opaque entity ID.
1814    #[serde(rename = "entityId")]
1815    pub entity_id: Option<String>,
1816    /// Overall relevancy score for the entity. Not normalized and not comparable across different image queries.
1817    pub score: Option<f32>,
1818}
1819
1820impl common::Part for WebEntity {}
1821
1822/// Metadata for online images.
1823///
1824/// This type is not used in any activity, and only used as *part* of another schema.
1825///
1826#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1827#[serde_with::serde_as]
1828#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1829pub struct WebImage {
1830    /// (Deprecated) Overall relevancy score for the image.
1831    pub score: Option<f32>,
1832    /// The result image URL.
1833    pub url: Option<String>,
1834}
1835
1836impl common::Part for WebImage {}
1837
1838/// Label to provide extra metadata for the web detection.
1839///
1840/// This type is not used in any activity, and only used as *part* of another schema.
1841///
1842#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1843#[serde_with::serde_as]
1844#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1845pub struct WebLabel {
1846    /// Label for extra metadata.
1847    pub label: Option<String>,
1848    /// The BCP-47 language code for `label`, such as "en-US" or "sr-Latn". For more information, see http://www.unicode.org/reports/tr35/#Unicode_locale_identifier.
1849    #[serde(rename = "languageCode")]
1850    pub language_code: Option<String>,
1851}
1852
1853impl common::Part for WebLabel {}
1854
1855/// Metadata for web pages.
1856///
1857/// This type is not used in any activity, and only used as *part* of another schema.
1858///
1859#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1860#[serde_with::serde_as]
1861#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1862pub struct WebPage {
1863    /// Fully matching images on the page. Can include resized copies of the query image.
1864    #[serde(rename = "fullMatchingImages")]
1865    pub full_matching_images: Option<Vec<WebImage>>,
1866    /// Title for the web page, may contain HTML markups.
1867    #[serde(rename = "pageTitle")]
1868    pub page_title: Option<String>,
1869    /// Partial matching images on the page. Those images are similar enough to share some key-point features. For example an original image will likely have partial matching for its crops.
1870    #[serde(rename = "partialMatchingImages")]
1871    pub partial_matching_images: Option<Vec<WebImage>>,
1872    /// (Deprecated) Overall relevancy score for the web page.
1873    pub score: Option<f32>,
1874    /// The result web page URL.
1875    pub url: Option<String>,
1876}
1877
1878impl common::Part for WebPage {}
1879
1880/// A word representation.
1881///
1882/// This type is not used in any activity, and only used as *part* of another schema.
1883///
1884#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1885#[serde_with::serde_as]
1886#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1887pub struct Word {
1888    /// The bounding box for the word. The vertices are in the order of top-left, top-right, bottom-right, bottom-left. When a rotation of the bounding box is detected the rotation is represented as around the top-left corner as defined when the text is read in the 'natural' orientation. For example: * when the text is horizontal it might look like: 0----1 | | 3----2 * when it's rotated 180 degrees around the top-left corner it becomes: 2----3 | | 1----0 and the vertex order will still be (0, 1, 2, 3).
1889    #[serde(rename = "boundingBox")]
1890    pub bounding_box: Option<BoundingPoly>,
1891    /// Confidence of the OCR results for the word. Range [0, 1].
1892    pub confidence: Option<f32>,
1893    /// Additional information detected for the word.
1894    pub property: Option<TextProperty>,
1895    /// List of symbols in the word. The order of the symbols follows the natural reading order.
1896    pub symbols: Option<Vec<Symbol>>,
1897}
1898
1899impl common::Part for Word {}
1900
1901// ###################
1902// MethodBuilders ###
1903// #################
1904
1905/// A builder providing access to all methods supported on *file* resources.
1906/// It is not used directly, but through the [`Vision`] hub.
1907///
1908/// # Example
1909///
1910/// Instantiate a resource builder
1911///
1912/// ```test_harness,no_run
1913/// extern crate hyper;
1914/// extern crate hyper_rustls;
1915/// extern crate google_vision1 as vision1;
1916///
1917/// # async fn dox() {
1918/// use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1919///
1920/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1921/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1922///     .with_native_roots()
1923///     .unwrap()
1924///     .https_only()
1925///     .enable_http2()
1926///     .build();
1927///
1928/// let executor = hyper_util::rt::TokioExecutor::new();
1929/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1930///     secret,
1931///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1932///     yup_oauth2::client::CustomHyperClientBuilder::from(
1933///         hyper_util::client::legacy::Client::builder(executor).build(connector),
1934///     ),
1935/// ).build().await.unwrap();
1936///
1937/// let client = hyper_util::client::legacy::Client::builder(
1938///     hyper_util::rt::TokioExecutor::new()
1939/// )
1940/// .build(
1941///     hyper_rustls::HttpsConnectorBuilder::new()
1942///         .with_native_roots()
1943///         .unwrap()
1944///         .https_or_http()
1945///         .enable_http2()
1946///         .build()
1947/// );
1948/// let mut hub = Vision::new(client, auth);
1949/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1950/// // like `annotate(...)` and `async_batch_annotate(...)`
1951/// // to build up your call.
1952/// let rb = hub.files();
1953/// # }
1954/// ```
1955pub struct FileMethods<'a, C>
1956where
1957    C: 'a,
1958{
1959    hub: &'a Vision<C>,
1960}
1961
1962impl<'a, C> common::MethodsBuilder for FileMethods<'a, C> {}
1963
1964impl<'a, C> FileMethods<'a, C> {
1965    /// Create a builder to help you perform the following task:
1966    ///
1967    /// Service that performs image detection and annotation for a batch of files. Now only "application/pdf", "image/tiff" and "image/gif" are supported. This service will extract at most 5 (customers can specify which 5 in AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each file provided and perform detection and annotation for each image extracted.
1968    ///
1969    /// # Arguments
1970    ///
1971    /// * `request` - No description provided.
1972    pub fn annotate(&self, request: BatchAnnotateFilesRequest) -> FileAnnotateCall<'a, C> {
1973        FileAnnotateCall {
1974            hub: self.hub,
1975            _request: request,
1976            _delegate: Default::default(),
1977            _additional_params: Default::default(),
1978            _scopes: Default::default(),
1979        }
1980    }
1981
1982    /// Create a builder to help you perform the following task:
1983    ///
1984    /// Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).
1985    ///
1986    /// # Arguments
1987    ///
1988    /// * `request` - No description provided.
1989    pub fn async_batch_annotate(
1990        &self,
1991        request: AsyncBatchAnnotateFilesRequest,
1992    ) -> FileAsyncBatchAnnotateCall<'a, C> {
1993        FileAsyncBatchAnnotateCall {
1994            hub: self.hub,
1995            _request: request,
1996            _delegate: Default::default(),
1997            _additional_params: Default::default(),
1998            _scopes: Default::default(),
1999        }
2000    }
2001}
2002
2003/// A builder providing access to all methods supported on *image* resources.
2004/// It is not used directly, but through the [`Vision`] hub.
2005///
2006/// # Example
2007///
2008/// Instantiate a resource builder
2009///
2010/// ```test_harness,no_run
2011/// extern crate hyper;
2012/// extern crate hyper_rustls;
2013/// extern crate google_vision1 as vision1;
2014///
2015/// # async fn dox() {
2016/// use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2017///
2018/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2019/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2020///     .with_native_roots()
2021///     .unwrap()
2022///     .https_only()
2023///     .enable_http2()
2024///     .build();
2025///
2026/// let executor = hyper_util::rt::TokioExecutor::new();
2027/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2028///     secret,
2029///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2030///     yup_oauth2::client::CustomHyperClientBuilder::from(
2031///         hyper_util::client::legacy::Client::builder(executor).build(connector),
2032///     ),
2033/// ).build().await.unwrap();
2034///
2035/// let client = hyper_util::client::legacy::Client::builder(
2036///     hyper_util::rt::TokioExecutor::new()
2037/// )
2038/// .build(
2039///     hyper_rustls::HttpsConnectorBuilder::new()
2040///         .with_native_roots()
2041///         .unwrap()
2042///         .https_or_http()
2043///         .enable_http2()
2044///         .build()
2045/// );
2046/// let mut hub = Vision::new(client, auth);
2047/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2048/// // like `annotate(...)` and `async_batch_annotate(...)`
2049/// // to build up your call.
2050/// let rb = hub.images();
2051/// # }
2052/// ```
2053pub struct ImageMethods<'a, C>
2054where
2055    C: 'a,
2056{
2057    hub: &'a Vision<C>,
2058}
2059
2060impl<'a, C> common::MethodsBuilder for ImageMethods<'a, C> {}
2061
2062impl<'a, C> ImageMethods<'a, C> {
2063    /// Create a builder to help you perform the following task:
2064    ///
2065    /// Run image detection and annotation for a batch of images.
2066    ///
2067    /// # Arguments
2068    ///
2069    /// * `request` - No description provided.
2070    pub fn annotate(&self, request: BatchAnnotateImagesRequest) -> ImageAnnotateCall<'a, C> {
2071        ImageAnnotateCall {
2072            hub: self.hub,
2073            _request: request,
2074            _delegate: Default::default(),
2075            _additional_params: Default::default(),
2076            _scopes: Default::default(),
2077        }
2078    }
2079
2080    /// Create a builder to help you perform the following task:
2081    ///
2082    /// Run asynchronous image detection and annotation for a list of images. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). This service will write image annotation outputs to json files in customer GCS bucket, each json file containing BatchAnnotateImagesResponse proto.
2083    ///
2084    /// # Arguments
2085    ///
2086    /// * `request` - No description provided.
2087    pub fn async_batch_annotate(
2088        &self,
2089        request: AsyncBatchAnnotateImagesRequest,
2090    ) -> ImageAsyncBatchAnnotateCall<'a, C> {
2091        ImageAsyncBatchAnnotateCall {
2092            hub: self.hub,
2093            _request: request,
2094            _delegate: Default::default(),
2095            _additional_params: Default::default(),
2096            _scopes: Default::default(),
2097        }
2098    }
2099}
2100
2101/// A builder providing access to all methods supported on *location* resources.
2102/// It is not used directly, but through the [`Vision`] hub.
2103///
2104/// # Example
2105///
2106/// Instantiate a resource builder
2107///
2108/// ```test_harness,no_run
2109/// extern crate hyper;
2110/// extern crate hyper_rustls;
2111/// extern crate google_vision1 as vision1;
2112///
2113/// # async fn dox() {
2114/// use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2115///
2116/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2117/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2118///     .with_native_roots()
2119///     .unwrap()
2120///     .https_only()
2121///     .enable_http2()
2122///     .build();
2123///
2124/// let executor = hyper_util::rt::TokioExecutor::new();
2125/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2126///     secret,
2127///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2128///     yup_oauth2::client::CustomHyperClientBuilder::from(
2129///         hyper_util::client::legacy::Client::builder(executor).build(connector),
2130///     ),
2131/// ).build().await.unwrap();
2132///
2133/// let client = hyper_util::client::legacy::Client::builder(
2134///     hyper_util::rt::TokioExecutor::new()
2135/// )
2136/// .build(
2137///     hyper_rustls::HttpsConnectorBuilder::new()
2138///         .with_native_roots()
2139///         .unwrap()
2140///         .https_or_http()
2141///         .enable_http2()
2142///         .build()
2143/// );
2144/// let mut hub = Vision::new(client, auth);
2145/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2146/// // like `operations_get(...)`
2147/// // to build up your call.
2148/// let rb = hub.locations();
2149/// # }
2150/// ```
2151pub struct LocationMethods<'a, C>
2152where
2153    C: 'a,
2154{
2155    hub: &'a Vision<C>,
2156}
2157
2158impl<'a, C> common::MethodsBuilder for LocationMethods<'a, C> {}
2159
2160impl<'a, C> LocationMethods<'a, C> {
2161    /// Create a builder to help you perform the following task:
2162    ///
2163    /// 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.
2164    ///
2165    /// # Arguments
2166    ///
2167    /// * `name` - The name of the operation resource.
2168    pub fn operations_get(&self, name: &str) -> LocationOperationGetCall<'a, C> {
2169        LocationOperationGetCall {
2170            hub: self.hub,
2171            _name: name.to_string(),
2172            _delegate: Default::default(),
2173            _additional_params: Default::default(),
2174            _scopes: Default::default(),
2175        }
2176    }
2177}
2178
2179/// A builder providing access to all methods supported on *operation* resources.
2180/// It is not used directly, but through the [`Vision`] hub.
2181///
2182/// # Example
2183///
2184/// Instantiate a resource builder
2185///
2186/// ```test_harness,no_run
2187/// extern crate hyper;
2188/// extern crate hyper_rustls;
2189/// extern crate google_vision1 as vision1;
2190///
2191/// # async fn dox() {
2192/// use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2193///
2194/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2195/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2196///     .with_native_roots()
2197///     .unwrap()
2198///     .https_only()
2199///     .enable_http2()
2200///     .build();
2201///
2202/// let executor = hyper_util::rt::TokioExecutor::new();
2203/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2204///     secret,
2205///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2206///     yup_oauth2::client::CustomHyperClientBuilder::from(
2207///         hyper_util::client::legacy::Client::builder(executor).build(connector),
2208///     ),
2209/// ).build().await.unwrap();
2210///
2211/// let client = hyper_util::client::legacy::Client::builder(
2212///     hyper_util::rt::TokioExecutor::new()
2213/// )
2214/// .build(
2215///     hyper_rustls::HttpsConnectorBuilder::new()
2216///         .with_native_roots()
2217///         .unwrap()
2218///         .https_or_http()
2219///         .enable_http2()
2220///         .build()
2221/// );
2222/// let mut hub = Vision::new(client, auth);
2223/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2224/// // like `cancel(...)`, `delete(...)`, `get(...)` and `list(...)`
2225/// // to build up your call.
2226/// let rb = hub.operations();
2227/// # }
2228/// ```
2229pub struct OperationMethods<'a, C>
2230where
2231    C: 'a,
2232{
2233    hub: &'a Vision<C>,
2234}
2235
2236impl<'a, C> common::MethodsBuilder for OperationMethods<'a, C> {}
2237
2238impl<'a, C> OperationMethods<'a, C> {
2239    /// Create a builder to help you perform the following task:
2240    ///
2241    /// 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`.
2242    ///
2243    /// # Arguments
2244    ///
2245    /// * `request` - No description provided.
2246    /// * `name` - The name of the operation resource to be cancelled.
2247    pub fn cancel(
2248        &self,
2249        request: CancelOperationRequest,
2250        name: &str,
2251    ) -> OperationCancelCall<'a, C> {
2252        OperationCancelCall {
2253            hub: self.hub,
2254            _request: request,
2255            _name: name.to_string(),
2256            _delegate: Default::default(),
2257            _additional_params: Default::default(),
2258            _scopes: Default::default(),
2259        }
2260    }
2261
2262    /// Create a builder to help you perform the following task:
2263    ///
2264    /// 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`.
2265    ///
2266    /// # Arguments
2267    ///
2268    /// * `name` - The name of the operation resource to be deleted.
2269    pub fn delete(&self, name: &str) -> OperationDeleteCall<'a, C> {
2270        OperationDeleteCall {
2271            hub: self.hub,
2272            _name: name.to_string(),
2273            _delegate: Default::default(),
2274            _additional_params: Default::default(),
2275            _scopes: Default::default(),
2276        }
2277    }
2278
2279    /// Create a builder to help you perform the following task:
2280    ///
2281    /// 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.
2282    ///
2283    /// # Arguments
2284    ///
2285    /// * `name` - The name of the operation resource.
2286    pub fn get(&self, name: &str) -> OperationGetCall<'a, C> {
2287        OperationGetCall {
2288            hub: self.hub,
2289            _name: name.to_string(),
2290            _delegate: Default::default(),
2291            _additional_params: Default::default(),
2292            _scopes: Default::default(),
2293        }
2294    }
2295
2296    /// Create a builder to help you perform the following task:
2297    ///
2298    /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
2299    ///
2300    /// # Arguments
2301    ///
2302    /// * `name` - The name of the operation's parent resource.
2303    pub fn list(&self, name: &str) -> OperationListCall<'a, C> {
2304        OperationListCall {
2305            hub: self.hub,
2306            _name: name.to_string(),
2307            _return_partial_success: Default::default(),
2308            _page_token: Default::default(),
2309            _page_size: Default::default(),
2310            _filter: Default::default(),
2311            _delegate: Default::default(),
2312            _additional_params: Default::default(),
2313            _scopes: Default::default(),
2314        }
2315    }
2316}
2317
2318/// A builder providing access to all methods supported on *project* resources.
2319/// It is not used directly, but through the [`Vision`] hub.
2320///
2321/// # Example
2322///
2323/// Instantiate a resource builder
2324///
2325/// ```test_harness,no_run
2326/// extern crate hyper;
2327/// extern crate hyper_rustls;
2328/// extern crate google_vision1 as vision1;
2329///
2330/// # async fn dox() {
2331/// use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2332///
2333/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2334/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2335///     .with_native_roots()
2336///     .unwrap()
2337///     .https_only()
2338///     .enable_http2()
2339///     .build();
2340///
2341/// let executor = hyper_util::rt::TokioExecutor::new();
2342/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2343///     secret,
2344///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2345///     yup_oauth2::client::CustomHyperClientBuilder::from(
2346///         hyper_util::client::legacy::Client::builder(executor).build(connector),
2347///     ),
2348/// ).build().await.unwrap();
2349///
2350/// let client = hyper_util::client::legacy::Client::builder(
2351///     hyper_util::rt::TokioExecutor::new()
2352/// )
2353/// .build(
2354///     hyper_rustls::HttpsConnectorBuilder::new()
2355///         .with_native_roots()
2356///         .unwrap()
2357///         .https_or_http()
2358///         .enable_http2()
2359///         .build()
2360/// );
2361/// let mut hub = Vision::new(client, auth);
2362/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2363/// // like `files_annotate(...)`, `files_async_batch_annotate(...)`, `images_annotate(...)`, `images_async_batch_annotate(...)`, `locations_files_annotate(...)`, `locations_files_async_batch_annotate(...)`, `locations_images_annotate(...)`, `locations_images_async_batch_annotate(...)`, `locations_operations_get(...)`, `locations_product_sets_add_product(...)`, `locations_product_sets_create(...)`, `locations_product_sets_delete(...)`, `locations_product_sets_get(...)`, `locations_product_sets_import(...)`, `locations_product_sets_list(...)`, `locations_product_sets_patch(...)`, `locations_product_sets_products_list(...)`, `locations_product_sets_remove_product(...)`, `locations_products_create(...)`, `locations_products_delete(...)`, `locations_products_get(...)`, `locations_products_list(...)`, `locations_products_patch(...)`, `locations_products_purge(...)`, `locations_products_reference_images_create(...)`, `locations_products_reference_images_delete(...)`, `locations_products_reference_images_get(...)`, `locations_products_reference_images_list(...)` and `operations_get(...)`
2364/// // to build up your call.
2365/// let rb = hub.projects();
2366/// # }
2367/// ```
2368pub struct ProjectMethods<'a, C>
2369where
2370    C: 'a,
2371{
2372    hub: &'a Vision<C>,
2373}
2374
2375impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
2376
2377impl<'a, C> ProjectMethods<'a, C> {
2378    /// Create a builder to help you perform the following task:
2379    ///
2380    /// Service that performs image detection and annotation for a batch of files. Now only "application/pdf", "image/tiff" and "image/gif" are supported. This service will extract at most 5 (customers can specify which 5 in AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each file provided and perform detection and annotation for each image extracted.
2381    ///
2382    /// # Arguments
2383    ///
2384    /// * `request` - No description provided.
2385    /// * `parent` - Optional. Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no parent is specified, a region will be chosen automatically. Supported location-ids: `us`: USA country only, `asia`: East asia areas, like Japan, Taiwan, `eu`: The European Union. Example: `projects/project-A/locations/eu`.
2386    pub fn files_annotate(
2387        &self,
2388        request: BatchAnnotateFilesRequest,
2389        parent: &str,
2390    ) -> ProjectFileAnnotateCall<'a, C> {
2391        ProjectFileAnnotateCall {
2392            hub: self.hub,
2393            _request: request,
2394            _parent: parent.to_string(),
2395            _delegate: Default::default(),
2396            _additional_params: Default::default(),
2397            _scopes: Default::default(),
2398        }
2399    }
2400
2401    /// Create a builder to help you perform the following task:
2402    ///
2403    /// Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).
2404    ///
2405    /// # Arguments
2406    ///
2407    /// * `request` - No description provided.
2408    /// * `parent` - Optional. Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no parent is specified, a region will be chosen automatically. Supported location-ids: `us`: USA country only, `asia`: East asia areas, like Japan, Taiwan, `eu`: The European Union. Example: `projects/project-A/locations/eu`.
2409    pub fn files_async_batch_annotate(
2410        &self,
2411        request: AsyncBatchAnnotateFilesRequest,
2412        parent: &str,
2413    ) -> ProjectFileAsyncBatchAnnotateCall<'a, C> {
2414        ProjectFileAsyncBatchAnnotateCall {
2415            hub: self.hub,
2416            _request: request,
2417            _parent: parent.to_string(),
2418            _delegate: Default::default(),
2419            _additional_params: Default::default(),
2420            _scopes: Default::default(),
2421        }
2422    }
2423
2424    /// Create a builder to help you perform the following task:
2425    ///
2426    /// Run image detection and annotation for a batch of images.
2427    ///
2428    /// # Arguments
2429    ///
2430    /// * `request` - No description provided.
2431    /// * `parent` - Optional. Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no parent is specified, a region will be chosen automatically. Supported location-ids: `us`: USA country only, `asia`: East asia areas, like Japan, Taiwan, `eu`: The European Union. Example: `projects/project-A/locations/eu`.
2432    pub fn images_annotate(
2433        &self,
2434        request: BatchAnnotateImagesRequest,
2435        parent: &str,
2436    ) -> ProjectImageAnnotateCall<'a, C> {
2437        ProjectImageAnnotateCall {
2438            hub: self.hub,
2439            _request: request,
2440            _parent: parent.to_string(),
2441            _delegate: Default::default(),
2442            _additional_params: Default::default(),
2443            _scopes: Default::default(),
2444        }
2445    }
2446
2447    /// Create a builder to help you perform the following task:
2448    ///
2449    /// Run asynchronous image detection and annotation for a list of images. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). This service will write image annotation outputs to json files in customer GCS bucket, each json file containing BatchAnnotateImagesResponse proto.
2450    ///
2451    /// # Arguments
2452    ///
2453    /// * `request` - No description provided.
2454    /// * `parent` - Optional. Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no parent is specified, a region will be chosen automatically. Supported location-ids: `us`: USA country only, `asia`: East asia areas, like Japan, Taiwan, `eu`: The European Union. Example: `projects/project-A/locations/eu`.
2455    pub fn images_async_batch_annotate(
2456        &self,
2457        request: AsyncBatchAnnotateImagesRequest,
2458        parent: &str,
2459    ) -> ProjectImageAsyncBatchAnnotateCall<'a, C> {
2460        ProjectImageAsyncBatchAnnotateCall {
2461            hub: self.hub,
2462            _request: request,
2463            _parent: parent.to_string(),
2464            _delegate: Default::default(),
2465            _additional_params: Default::default(),
2466            _scopes: Default::default(),
2467        }
2468    }
2469
2470    /// Create a builder to help you perform the following task:
2471    ///
2472    /// Service that performs image detection and annotation for a batch of files. Now only "application/pdf", "image/tiff" and "image/gif" are supported. This service will extract at most 5 (customers can specify which 5 in AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each file provided and perform detection and annotation for each image extracted.
2473    ///
2474    /// # Arguments
2475    ///
2476    /// * `request` - No description provided.
2477    /// * `parent` - Optional. Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no parent is specified, a region will be chosen automatically. Supported location-ids: `us`: USA country only, `asia`: East asia areas, like Japan, Taiwan, `eu`: The European Union. Example: `projects/project-A/locations/eu`.
2478    pub fn locations_files_annotate(
2479        &self,
2480        request: BatchAnnotateFilesRequest,
2481        parent: &str,
2482    ) -> ProjectLocationFileAnnotateCall<'a, C> {
2483        ProjectLocationFileAnnotateCall {
2484            hub: self.hub,
2485            _request: request,
2486            _parent: parent.to_string(),
2487            _delegate: Default::default(),
2488            _additional_params: Default::default(),
2489            _scopes: Default::default(),
2490        }
2491    }
2492
2493    /// Create a builder to help you perform the following task:
2494    ///
2495    /// Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).
2496    ///
2497    /// # Arguments
2498    ///
2499    /// * `request` - No description provided.
2500    /// * `parent` - Optional. Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no parent is specified, a region will be chosen automatically. Supported location-ids: `us`: USA country only, `asia`: East asia areas, like Japan, Taiwan, `eu`: The European Union. Example: `projects/project-A/locations/eu`.
2501    pub fn locations_files_async_batch_annotate(
2502        &self,
2503        request: AsyncBatchAnnotateFilesRequest,
2504        parent: &str,
2505    ) -> ProjectLocationFileAsyncBatchAnnotateCall<'a, C> {
2506        ProjectLocationFileAsyncBatchAnnotateCall {
2507            hub: self.hub,
2508            _request: request,
2509            _parent: parent.to_string(),
2510            _delegate: Default::default(),
2511            _additional_params: Default::default(),
2512            _scopes: Default::default(),
2513        }
2514    }
2515
2516    /// Create a builder to help you perform the following task:
2517    ///
2518    /// Run image detection and annotation for a batch of images.
2519    ///
2520    /// # Arguments
2521    ///
2522    /// * `request` - No description provided.
2523    /// * `parent` - Optional. Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no parent is specified, a region will be chosen automatically. Supported location-ids: `us`: USA country only, `asia`: East asia areas, like Japan, Taiwan, `eu`: The European Union. Example: `projects/project-A/locations/eu`.
2524    pub fn locations_images_annotate(
2525        &self,
2526        request: BatchAnnotateImagesRequest,
2527        parent: &str,
2528    ) -> ProjectLocationImageAnnotateCall<'a, C> {
2529        ProjectLocationImageAnnotateCall {
2530            hub: self.hub,
2531            _request: request,
2532            _parent: parent.to_string(),
2533            _delegate: Default::default(),
2534            _additional_params: Default::default(),
2535            _scopes: Default::default(),
2536        }
2537    }
2538
2539    /// Create a builder to help you perform the following task:
2540    ///
2541    /// Run asynchronous image detection and annotation for a list of images. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). This service will write image annotation outputs to json files in customer GCS bucket, each json file containing BatchAnnotateImagesResponse proto.
2542    ///
2543    /// # Arguments
2544    ///
2545    /// * `request` - No description provided.
2546    /// * `parent` - Optional. Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no parent is specified, a region will be chosen automatically. Supported location-ids: `us`: USA country only, `asia`: East asia areas, like Japan, Taiwan, `eu`: The European Union. Example: `projects/project-A/locations/eu`.
2547    pub fn locations_images_async_batch_annotate(
2548        &self,
2549        request: AsyncBatchAnnotateImagesRequest,
2550        parent: &str,
2551    ) -> ProjectLocationImageAsyncBatchAnnotateCall<'a, C> {
2552        ProjectLocationImageAsyncBatchAnnotateCall {
2553            hub: self.hub,
2554            _request: request,
2555            _parent: parent.to_string(),
2556            _delegate: Default::default(),
2557            _additional_params: Default::default(),
2558            _scopes: Default::default(),
2559        }
2560    }
2561
2562    /// Create a builder to help you perform the following task:
2563    ///
2564    /// 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.
2565    ///
2566    /// # Arguments
2567    ///
2568    /// * `name` - The name of the operation resource.
2569    pub fn locations_operations_get(&self, name: &str) -> ProjectLocationOperationGetCall<'a, C> {
2570        ProjectLocationOperationGetCall {
2571            hub: self.hub,
2572            _name: name.to_string(),
2573            _delegate: Default::default(),
2574            _additional_params: Default::default(),
2575            _scopes: Default::default(),
2576        }
2577    }
2578
2579    /// Create a builder to help you perform the following task:
2580    ///
2581    /// Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the response will be empty. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.
2582    ///
2583    /// # Arguments
2584    ///
2585    /// * `name` - Required. The ProductSet resource for which to retrieve Products. Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
2586    pub fn locations_product_sets_products_list(
2587        &self,
2588        name: &str,
2589    ) -> ProjectLocationProductSetProductListCall<'a, C> {
2590        ProjectLocationProductSetProductListCall {
2591            hub: self.hub,
2592            _name: name.to_string(),
2593            _page_token: Default::default(),
2594            _page_size: Default::default(),
2595            _delegate: Default::default(),
2596            _additional_params: Default::default(),
2597            _scopes: Default::default(),
2598        }
2599    }
2600
2601    /// Create a builder to help you perform the following task:
2602    ///
2603    /// Adds a Product to the specified ProductSet. If the Product is already present, no change is made. One Product can be added to at most 100 ProductSets. Possible errors: * Returns NOT_FOUND if the Product or the ProductSet doesn't exist.
2604    ///
2605    /// # Arguments
2606    ///
2607    /// * `request` - No description provided.
2608    /// * `name` - Required. The resource name for the ProductSet to modify. Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
2609    pub fn locations_product_sets_add_product(
2610        &self,
2611        request: AddProductToProductSetRequest,
2612        name: &str,
2613    ) -> ProjectLocationProductSetAddProductCall<'a, C> {
2614        ProjectLocationProductSetAddProductCall {
2615            hub: self.hub,
2616            _request: request,
2617            _name: name.to_string(),
2618            _delegate: Default::default(),
2619            _additional_params: Default::default(),
2620            _scopes: Default::default(),
2621        }
2622    }
2623
2624    /// Create a builder to help you perform the following task:
2625    ///
2626    /// Creates and returns a new ProductSet resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.
2627    ///
2628    /// # Arguments
2629    ///
2630    /// * `request` - No description provided.
2631    /// * `parent` - Required. The project in which the ProductSet should be created. Format is `projects/PROJECT_ID/locations/LOC_ID`.
2632    pub fn locations_product_sets_create(
2633        &self,
2634        request: ProductSet,
2635        parent: &str,
2636    ) -> ProjectLocationProductSetCreateCall<'a, C> {
2637        ProjectLocationProductSetCreateCall {
2638            hub: self.hub,
2639            _request: request,
2640            _parent: parent.to_string(),
2641            _product_set_id: Default::default(),
2642            _delegate: Default::default(),
2643            _additional_params: Default::default(),
2644            _scopes: Default::default(),
2645        }
2646    }
2647
2648    /// Create a builder to help you perform the following task:
2649    ///
2650    /// Permanently deletes a ProductSet. Products and ReferenceImages in the ProductSet are not deleted. The actual image files are not deleted from Google Cloud Storage.
2651    ///
2652    /// # Arguments
2653    ///
2654    /// * `name` - Required. Resource name of the ProductSet to delete. Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
2655    pub fn locations_product_sets_delete(
2656        &self,
2657        name: &str,
2658    ) -> ProjectLocationProductSetDeleteCall<'a, C> {
2659        ProjectLocationProductSetDeleteCall {
2660            hub: self.hub,
2661            _name: name.to_string(),
2662            _delegate: Default::default(),
2663            _additional_params: Default::default(),
2664            _scopes: Default::default(),
2665        }
2666    }
2667
2668    /// Create a builder to help you perform the following task:
2669    ///
2670    /// Gets information associated with a ProductSet. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.
2671    ///
2672    /// # Arguments
2673    ///
2674    /// * `name` - Required. Resource name of the ProductSet to get. Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
2675    pub fn locations_product_sets_get(
2676        &self,
2677        name: &str,
2678    ) -> ProjectLocationProductSetGetCall<'a, C> {
2679        ProjectLocationProductSetGetCall {
2680            hub: self.hub,
2681            _name: name.to_string(),
2682            _delegate: Default::default(),
2683            _additional_params: Default::default(),
2684            _scopes: Default::default(),
2685        }
2686    }
2687
2688    /// Create a builder to help you perform the following task:
2689    ///
2690    /// Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. The google.longrunning.Operation API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. (results) The input source of this method is a csv file on Google Cloud Storage. For the format of the csv file please see ImportProductSetsGcsSource.csv_file_uri.
2691    ///
2692    /// # Arguments
2693    ///
2694    /// * `request` - No description provided.
2695    /// * `parent` - Required. The project in which the ProductSets should be imported. Format is `projects/PROJECT_ID/locations/LOC_ID`.
2696    pub fn locations_product_sets_import(
2697        &self,
2698        request: ImportProductSetsRequest,
2699        parent: &str,
2700    ) -> ProjectLocationProductSetImportCall<'a, C> {
2701        ProjectLocationProductSetImportCall {
2702            hub: self.hub,
2703            _request: request,
2704            _parent: parent.to_string(),
2705            _delegate: Default::default(),
2706            _additional_params: Default::default(),
2707            _scopes: Default::default(),
2708        }
2709    }
2710
2711    /// Create a builder to help you perform the following task:
2712    ///
2713    /// Lists ProductSets in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1.
2714    ///
2715    /// # Arguments
2716    ///
2717    /// * `parent` - Required. The project from which ProductSets should be listed. Format is `projects/PROJECT_ID/locations/LOC_ID`.
2718    pub fn locations_product_sets_list(
2719        &self,
2720        parent: &str,
2721    ) -> ProjectLocationProductSetListCall<'a, C> {
2722        ProjectLocationProductSetListCall {
2723            hub: self.hub,
2724            _parent: parent.to_string(),
2725            _page_token: Default::default(),
2726            _page_size: Default::default(),
2727            _delegate: Default::default(),
2728            _additional_params: Default::default(),
2729            _scopes: Default::default(),
2730        }
2731    }
2732
2733    /// Create a builder to help you perform the following task:
2734    ///
2735    /// Makes changes to a ProductSet resource. Only display_name can be updated currently. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but missing from the request or longer than 4096 characters.
2736    ///
2737    /// # Arguments
2738    ///
2739    /// * `request` - No description provided.
2740    /// * `name` - The resource name of the ProductSet. Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. This field is ignored when creating a ProductSet.
2741    pub fn locations_product_sets_patch(
2742        &self,
2743        request: ProductSet,
2744        name: &str,
2745    ) -> ProjectLocationProductSetPatchCall<'a, C> {
2746        ProjectLocationProductSetPatchCall {
2747            hub: self.hub,
2748            _request: request,
2749            _name: name.to_string(),
2750            _update_mask: Default::default(),
2751            _delegate: Default::default(),
2752            _additional_params: Default::default(),
2753            _scopes: Default::default(),
2754        }
2755    }
2756
2757    /// Create a builder to help you perform the following task:
2758    ///
2759    /// Removes a Product from the specified ProductSet.
2760    ///
2761    /// # Arguments
2762    ///
2763    /// * `request` - No description provided.
2764    /// * `name` - Required. The resource name for the ProductSet to modify. Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
2765    pub fn locations_product_sets_remove_product(
2766        &self,
2767        request: RemoveProductFromProductSetRequest,
2768        name: &str,
2769    ) -> ProjectLocationProductSetRemoveProductCall<'a, C> {
2770        ProjectLocationProductSetRemoveProductCall {
2771            hub: self.hub,
2772            _request: request,
2773            _name: name.to_string(),
2774            _delegate: Default::default(),
2775            _additional_params: Default::default(),
2776            _scopes: Default::default(),
2777        }
2778    }
2779
2780    /// Create a builder to help you perform the following task:
2781    ///
2782    /// Creates and returns a new ReferenceImage resource. The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will try to detect regions of interest in the image that are compatible with the product_category on the parent product. If it is specified, detection is ALWAYS skipped. The system converts polygons into non-rotated rectangles. Note that the pipeline will resize the image if the image resolution is too large to process (above 50MP). Possible errors: * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if the product does not exist. * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with the parent product's product_category is detected. * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.
2783    ///
2784    /// # Arguments
2785    ///
2786    /// * `request` - No description provided.
2787    /// * `parent` - Required. Resource name of the product in which to create the reference image. Format is `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`.
2788    pub fn locations_products_reference_images_create(
2789        &self,
2790        request: ReferenceImage,
2791        parent: &str,
2792    ) -> ProjectLocationProductReferenceImageCreateCall<'a, C> {
2793        ProjectLocationProductReferenceImageCreateCall {
2794            hub: self.hub,
2795            _request: request,
2796            _parent: parent.to_string(),
2797            _reference_image_id: Default::default(),
2798            _delegate: Default::default(),
2799            _additional_params: Default::default(),
2800            _scopes: Default::default(),
2801        }
2802    }
2803
2804    /// Create a builder to help you perform the following task:
2805    ///
2806    /// Permanently deletes a reference image. The image metadata will be deleted right away, but search queries against ProductSets containing the image may still work until all related caches are refreshed. The actual image files are not deleted from Google Cloud Storage.
2807    ///
2808    /// # Arguments
2809    ///
2810    /// * `name` - Required. The resource name of the reference image to delete. Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`
2811    pub fn locations_products_reference_images_delete(
2812        &self,
2813        name: &str,
2814    ) -> ProjectLocationProductReferenceImageDeleteCall<'a, C> {
2815        ProjectLocationProductReferenceImageDeleteCall {
2816            hub: self.hub,
2817            _name: name.to_string(),
2818            _delegate: Default::default(),
2819            _additional_params: Default::default(),
2820            _scopes: Default::default(),
2821        }
2822    }
2823
2824    /// Create a builder to help you perform the following task:
2825    ///
2826    /// Gets information associated with a ReferenceImage. Possible errors: * Returns NOT_FOUND if the specified image does not exist.
2827    ///
2828    /// # Arguments
2829    ///
2830    /// * `name` - Required. The resource name of the ReferenceImage to get. Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`.
2831    pub fn locations_products_reference_images_get(
2832        &self,
2833        name: &str,
2834    ) -> ProjectLocationProductReferenceImageGetCall<'a, C> {
2835        ProjectLocationProductReferenceImageGetCall {
2836            hub: self.hub,
2837            _name: name.to_string(),
2838            _delegate: Default::default(),
2839            _additional_params: Default::default(),
2840            _scopes: Default::default(),
2841        }
2842    }
2843
2844    /// Create a builder to help you perform the following task:
2845    ///
2846    /// Lists reference images. Possible errors: * Returns NOT_FOUND if the parent product does not exist. * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1.
2847    ///
2848    /// # Arguments
2849    ///
2850    /// * `parent` - Required. Resource name of the product containing the reference images. Format is `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`.
2851    pub fn locations_products_reference_images_list(
2852        &self,
2853        parent: &str,
2854    ) -> ProjectLocationProductReferenceImageListCall<'a, C> {
2855        ProjectLocationProductReferenceImageListCall {
2856            hub: self.hub,
2857            _parent: parent.to_string(),
2858            _page_token: Default::default(),
2859            _page_size: Default::default(),
2860            _delegate: Default::default(),
2861            _additional_params: Default::default(),
2862            _scopes: Default::default(),
2863        }
2864    }
2865
2866    /// Create a builder to help you perform the following task:
2867    ///
2868    /// Creates and returns a new product resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is missing or invalid.
2869    ///
2870    /// # Arguments
2871    ///
2872    /// * `request` - No description provided.
2873    /// * `parent` - Required. The project in which the Product should be created. Format is `projects/PROJECT_ID/locations/LOC_ID`.
2874    pub fn locations_products_create(
2875        &self,
2876        request: Product,
2877        parent: &str,
2878    ) -> ProjectLocationProductCreateCall<'a, C> {
2879        ProjectLocationProductCreateCall {
2880            hub: self.hub,
2881            _request: request,
2882            _parent: parent.to_string(),
2883            _product_id: Default::default(),
2884            _delegate: Default::default(),
2885            _additional_params: Default::default(),
2886            _scopes: Default::default(),
2887        }
2888    }
2889
2890    /// Create a builder to help you perform the following task:
2891    ///
2892    /// Permanently deletes a product and its reference images. Metadata of the product and all its images will be deleted right away, but search queries against ProductSets containing the product may still work until all related caches are refreshed.
2893    ///
2894    /// # Arguments
2895    ///
2896    /// * `name` - Required. Resource name of product to delete. Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
2897    pub fn locations_products_delete(&self, name: &str) -> ProjectLocationProductDeleteCall<'a, C> {
2898        ProjectLocationProductDeleteCall {
2899            hub: self.hub,
2900            _name: name.to_string(),
2901            _delegate: Default::default(),
2902            _additional_params: Default::default(),
2903            _scopes: Default::default(),
2904        }
2905    }
2906
2907    /// Create a builder to help you perform the following task:
2908    ///
2909    /// Gets information associated with a Product. Possible errors: * Returns NOT_FOUND if the Product does not exist.
2910    ///
2911    /// # Arguments
2912    ///
2913    /// * `name` - Required. Resource name of the Product to get. Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
2914    pub fn locations_products_get(&self, name: &str) -> ProjectLocationProductGetCall<'a, C> {
2915        ProjectLocationProductGetCall {
2916            hub: self.hub,
2917            _name: name.to_string(),
2918            _delegate: Default::default(),
2919            _additional_params: Default::default(),
2920            _scopes: Default::default(),
2921        }
2922    }
2923
2924    /// Create a builder to help you perform the following task:
2925    ///
2926    /// Lists products in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.
2927    ///
2928    /// # Arguments
2929    ///
2930    /// * `parent` - Required. The project OR ProductSet from which Products should be listed. Format: `projects/PROJECT_ID/locations/LOC_ID`
2931    pub fn locations_products_list(&self, parent: &str) -> ProjectLocationProductListCall<'a, C> {
2932        ProjectLocationProductListCall {
2933            hub: self.hub,
2934            _parent: parent.to_string(),
2935            _page_token: Default::default(),
2936            _page_size: Default::default(),
2937            _delegate: Default::default(),
2938            _additional_params: Default::default(),
2939            _scopes: Default::default(),
2940        }
2941    }
2942
2943    /// Create a builder to help you perform the following task:
2944    ///
2945    /// Makes changes to a Product resource. Only the `display_name`, `description`, and `labels` fields can be updated right now. If labels are updated, the change will not be reflected in queries until the next index time. Possible errors: * Returns NOT_FOUND if the Product does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but is missing from the request or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is present in update_mask but is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is present in update_mask.
2946    ///
2947    /// # Arguments
2948    ///
2949    /// * `request` - No description provided.
2950    /// * `name` - The resource name of the product. Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. This field is ignored when creating a product.
2951    pub fn locations_products_patch(
2952        &self,
2953        request: Product,
2954        name: &str,
2955    ) -> ProjectLocationProductPatchCall<'a, C> {
2956        ProjectLocationProductPatchCall {
2957            hub: self.hub,
2958            _request: request,
2959            _name: name.to_string(),
2960            _update_mask: Default::default(),
2961            _delegate: Default::default(),
2962            _additional_params: Default::default(),
2963            _scopes: Default::default(),
2964        }
2965    }
2966
2967    /// Create a builder to help you perform the following task:
2968    ///
2969    /// Asynchronous API to delete all Products in a ProductSet or all Products that are in no ProductSet. If a Product is a member of the specified ProductSet in addition to other ProductSets, the Product will still be deleted. It is recommended to not delete the specified ProductSet until after this operation has completed. It is also recommended to not add any of the Products involved in the batch delete to a new ProductSet while this operation is running because those Products may still end up deleted. It's not possible to undo the PurgeProducts operation. Therefore, it is recommended to keep the csv files used in ImportProductSets (if that was how you originally built the Product Set) before starting PurgeProducts, in case you need to re-import the data after deletion. If the plan is to purge all of the Products from a ProductSet and then re-use the empty ProductSet to re-import new Products into the empty ProductSet, you must wait until the PurgeProducts operation has finished for that ProductSet. The google.longrunning.Operation API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress)
2970    ///
2971    /// # Arguments
2972    ///
2973    /// * `request` - No description provided.
2974    /// * `parent` - Required. The project and location in which the Products should be deleted. Format is `projects/PROJECT_ID/locations/LOC_ID`.
2975    pub fn locations_products_purge(
2976        &self,
2977        request: PurgeProductsRequest,
2978        parent: &str,
2979    ) -> ProjectLocationProductPurgeCall<'a, C> {
2980        ProjectLocationProductPurgeCall {
2981            hub: self.hub,
2982            _request: request,
2983            _parent: parent.to_string(),
2984            _delegate: Default::default(),
2985            _additional_params: Default::default(),
2986            _scopes: Default::default(),
2987        }
2988    }
2989
2990    /// Create a builder to help you perform the following task:
2991    ///
2992    /// 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.
2993    ///
2994    /// # Arguments
2995    ///
2996    /// * `name` - The name of the operation resource.
2997    pub fn operations_get(&self, name: &str) -> ProjectOperationGetCall<'a, C> {
2998        ProjectOperationGetCall {
2999            hub: self.hub,
3000            _name: name.to_string(),
3001            _delegate: Default::default(),
3002            _additional_params: Default::default(),
3003            _scopes: Default::default(),
3004        }
3005    }
3006}
3007
3008// ###################
3009// CallBuilders   ###
3010// #################
3011
3012/// Service that performs image detection and annotation for a batch of files. Now only "application/pdf", "image/tiff" and "image/gif" are supported. This service will extract at most 5 (customers can specify which 5 in AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each file provided and perform detection and annotation for each image extracted.
3013///
3014/// A builder for the *annotate* method supported by a *file* resource.
3015/// It is not used directly, but through a [`FileMethods`] instance.
3016///
3017/// # Example
3018///
3019/// Instantiate a resource method builder
3020///
3021/// ```test_harness,no_run
3022/// # extern crate hyper;
3023/// # extern crate hyper_rustls;
3024/// # extern crate google_vision1 as vision1;
3025/// use vision1::api::BatchAnnotateFilesRequest;
3026/// # async fn dox() {
3027/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3028///
3029/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3030/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3031/// #     .with_native_roots()
3032/// #     .unwrap()
3033/// #     .https_only()
3034/// #     .enable_http2()
3035/// #     .build();
3036///
3037/// # let executor = hyper_util::rt::TokioExecutor::new();
3038/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3039/// #     secret,
3040/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3041/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3042/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3043/// #     ),
3044/// # ).build().await.unwrap();
3045///
3046/// # let client = hyper_util::client::legacy::Client::builder(
3047/// #     hyper_util::rt::TokioExecutor::new()
3048/// # )
3049/// # .build(
3050/// #     hyper_rustls::HttpsConnectorBuilder::new()
3051/// #         .with_native_roots()
3052/// #         .unwrap()
3053/// #         .https_or_http()
3054/// #         .enable_http2()
3055/// #         .build()
3056/// # );
3057/// # let mut hub = Vision::new(client, auth);
3058/// // As the method needs a request, you would usually fill it with the desired information
3059/// // into the respective structure. Some of the parts shown here might not be applicable !
3060/// // Values shown here are possibly random and not representative !
3061/// let mut req = BatchAnnotateFilesRequest::default();
3062///
3063/// // You can configure optional parameters by calling the respective setters at will, and
3064/// // execute the final call using `doit()`.
3065/// // Values shown here are possibly random and not representative !
3066/// let result = hub.files().annotate(req)
3067///              .doit().await;
3068/// # }
3069/// ```
3070pub struct FileAnnotateCall<'a, C>
3071where
3072    C: 'a,
3073{
3074    hub: &'a Vision<C>,
3075    _request: BatchAnnotateFilesRequest,
3076    _delegate: Option<&'a mut dyn common::Delegate>,
3077    _additional_params: HashMap<String, String>,
3078    _scopes: BTreeSet<String>,
3079}
3080
3081impl<'a, C> common::CallBuilder for FileAnnotateCall<'a, C> {}
3082
3083impl<'a, C> FileAnnotateCall<'a, C>
3084where
3085    C: common::Connector,
3086{
3087    /// Perform the operation you have build so far.
3088    pub async fn doit(mut self) -> common::Result<(common::Response, BatchAnnotateFilesResponse)> {
3089        use std::borrow::Cow;
3090        use std::io::{Read, Seek};
3091
3092        use common::{url::Params, ToParts};
3093        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3094
3095        let mut dd = common::DefaultDelegate;
3096        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3097        dlg.begin(common::MethodInfo {
3098            id: "vision.files.annotate",
3099            http_method: hyper::Method::POST,
3100        });
3101
3102        for &field in ["alt"].iter() {
3103            if self._additional_params.contains_key(field) {
3104                dlg.finished(false);
3105                return Err(common::Error::FieldClash(field));
3106            }
3107        }
3108
3109        let mut params = Params::with_capacity(3 + self._additional_params.len());
3110
3111        params.extend(self._additional_params.iter());
3112
3113        params.push("alt", "json");
3114        let mut url = self.hub._base_url.clone() + "v1/files:annotate";
3115        if self._scopes.is_empty() {
3116            self._scopes
3117                .insert(Scope::CloudPlatform.as_ref().to_string());
3118        }
3119
3120        let url = params.parse_with_url(&url);
3121
3122        let mut json_mime_type = mime::APPLICATION_JSON;
3123        let mut request_value_reader = {
3124            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3125            common::remove_json_null_values(&mut value);
3126            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3127            serde_json::to_writer(&mut dst, &value).unwrap();
3128            dst
3129        };
3130        let request_size = request_value_reader
3131            .seek(std::io::SeekFrom::End(0))
3132            .unwrap();
3133        request_value_reader
3134            .seek(std::io::SeekFrom::Start(0))
3135            .unwrap();
3136
3137        loop {
3138            let token = match self
3139                .hub
3140                .auth
3141                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3142                .await
3143            {
3144                Ok(token) => token,
3145                Err(e) => match dlg.token(e) {
3146                    Ok(token) => token,
3147                    Err(e) => {
3148                        dlg.finished(false);
3149                        return Err(common::Error::MissingToken(e));
3150                    }
3151                },
3152            };
3153            request_value_reader
3154                .seek(std::io::SeekFrom::Start(0))
3155                .unwrap();
3156            let mut req_result = {
3157                let client = &self.hub.client;
3158                dlg.pre_request();
3159                let mut req_builder = hyper::Request::builder()
3160                    .method(hyper::Method::POST)
3161                    .uri(url.as_str())
3162                    .header(USER_AGENT, self.hub._user_agent.clone());
3163
3164                if let Some(token) = token.as_ref() {
3165                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3166                }
3167
3168                let request = req_builder
3169                    .header(CONTENT_TYPE, json_mime_type.to_string())
3170                    .header(CONTENT_LENGTH, request_size as u64)
3171                    .body(common::to_body(
3172                        request_value_reader.get_ref().clone().into(),
3173                    ));
3174
3175                client.request(request.unwrap()).await
3176            };
3177
3178            match req_result {
3179                Err(err) => {
3180                    if let common::Retry::After(d) = dlg.http_error(&err) {
3181                        sleep(d).await;
3182                        continue;
3183                    }
3184                    dlg.finished(false);
3185                    return Err(common::Error::HttpError(err));
3186                }
3187                Ok(res) => {
3188                    let (mut parts, body) = res.into_parts();
3189                    let mut body = common::Body::new(body);
3190                    if !parts.status.is_success() {
3191                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3192                        let error = serde_json::from_str(&common::to_string(&bytes));
3193                        let response = common::to_response(parts, bytes.into());
3194
3195                        if let common::Retry::After(d) =
3196                            dlg.http_failure(&response, error.as_ref().ok())
3197                        {
3198                            sleep(d).await;
3199                            continue;
3200                        }
3201
3202                        dlg.finished(false);
3203
3204                        return Err(match error {
3205                            Ok(value) => common::Error::BadRequest(value),
3206                            _ => common::Error::Failure(response),
3207                        });
3208                    }
3209                    let response = {
3210                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3211                        let encoded = common::to_string(&bytes);
3212                        match serde_json::from_str(&encoded) {
3213                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3214                            Err(error) => {
3215                                dlg.response_json_decode_error(&encoded, &error);
3216                                return Err(common::Error::JsonDecodeError(
3217                                    encoded.to_string(),
3218                                    error,
3219                                ));
3220                            }
3221                        }
3222                    };
3223
3224                    dlg.finished(true);
3225                    return Ok(response);
3226                }
3227            }
3228        }
3229    }
3230
3231    ///
3232    /// Sets the *request* property to the given value.
3233    ///
3234    /// Even though the property as already been set when instantiating this call,
3235    /// we provide this method for API completeness.
3236    pub fn request(mut self, new_value: BatchAnnotateFilesRequest) -> FileAnnotateCall<'a, C> {
3237        self._request = new_value;
3238        self
3239    }
3240    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3241    /// while executing the actual API request.
3242    ///
3243    /// ````text
3244    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3245    /// ````
3246    ///
3247    /// Sets the *delegate* property to the given value.
3248    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FileAnnotateCall<'a, C> {
3249        self._delegate = Some(new_value);
3250        self
3251    }
3252
3253    /// Set any additional parameter of the query string used in the request.
3254    /// It should be used to set parameters which are not yet available through their own
3255    /// setters.
3256    ///
3257    /// Please note that this method must not be used to set any of the known parameters
3258    /// which have their own setter method. If done anyway, the request will fail.
3259    ///
3260    /// # Additional Parameters
3261    ///
3262    /// * *$.xgafv* (query-string) - V1 error format.
3263    /// * *access_token* (query-string) - OAuth access token.
3264    /// * *alt* (query-string) - Data format for response.
3265    /// * *callback* (query-string) - JSONP
3266    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3267    /// * *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.
3268    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3269    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3270    /// * *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.
3271    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3272    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3273    pub fn param<T>(mut self, name: T, value: T) -> FileAnnotateCall<'a, C>
3274    where
3275        T: AsRef<str>,
3276    {
3277        self._additional_params
3278            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3279        self
3280    }
3281
3282    /// Identifies the authorization scope for the method you are building.
3283    ///
3284    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3285    /// [`Scope::CloudPlatform`].
3286    ///
3287    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3288    /// tokens for more than one scope.
3289    ///
3290    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3291    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3292    /// sufficient, a read-write scope will do as well.
3293    pub fn add_scope<St>(mut self, scope: St) -> FileAnnotateCall<'a, C>
3294    where
3295        St: AsRef<str>,
3296    {
3297        self._scopes.insert(String::from(scope.as_ref()));
3298        self
3299    }
3300    /// Identifies the authorization scope(s) for the method you are building.
3301    ///
3302    /// See [`Self::add_scope()`] for details.
3303    pub fn add_scopes<I, St>(mut self, scopes: I) -> FileAnnotateCall<'a, C>
3304    where
3305        I: IntoIterator<Item = St>,
3306        St: AsRef<str>,
3307    {
3308        self._scopes
3309            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3310        self
3311    }
3312
3313    /// Removes all scopes, and no default scope will be used either.
3314    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3315    /// for details).
3316    pub fn clear_scopes(mut self) -> FileAnnotateCall<'a, C> {
3317        self._scopes.clear();
3318        self
3319    }
3320}
3321
3322/// Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).
3323///
3324/// A builder for the *asyncBatchAnnotate* method supported by a *file* resource.
3325/// It is not used directly, but through a [`FileMethods`] instance.
3326///
3327/// # Example
3328///
3329/// Instantiate a resource method builder
3330///
3331/// ```test_harness,no_run
3332/// # extern crate hyper;
3333/// # extern crate hyper_rustls;
3334/// # extern crate google_vision1 as vision1;
3335/// use vision1::api::AsyncBatchAnnotateFilesRequest;
3336/// # async fn dox() {
3337/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3338///
3339/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3340/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3341/// #     .with_native_roots()
3342/// #     .unwrap()
3343/// #     .https_only()
3344/// #     .enable_http2()
3345/// #     .build();
3346///
3347/// # let executor = hyper_util::rt::TokioExecutor::new();
3348/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3349/// #     secret,
3350/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3351/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3352/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3353/// #     ),
3354/// # ).build().await.unwrap();
3355///
3356/// # let client = hyper_util::client::legacy::Client::builder(
3357/// #     hyper_util::rt::TokioExecutor::new()
3358/// # )
3359/// # .build(
3360/// #     hyper_rustls::HttpsConnectorBuilder::new()
3361/// #         .with_native_roots()
3362/// #         .unwrap()
3363/// #         .https_or_http()
3364/// #         .enable_http2()
3365/// #         .build()
3366/// # );
3367/// # let mut hub = Vision::new(client, auth);
3368/// // As the method needs a request, you would usually fill it with the desired information
3369/// // into the respective structure. Some of the parts shown here might not be applicable !
3370/// // Values shown here are possibly random and not representative !
3371/// let mut req = AsyncBatchAnnotateFilesRequest::default();
3372///
3373/// // You can configure optional parameters by calling the respective setters at will, and
3374/// // execute the final call using `doit()`.
3375/// // Values shown here are possibly random and not representative !
3376/// let result = hub.files().async_batch_annotate(req)
3377///              .doit().await;
3378/// # }
3379/// ```
3380pub struct FileAsyncBatchAnnotateCall<'a, C>
3381where
3382    C: 'a,
3383{
3384    hub: &'a Vision<C>,
3385    _request: AsyncBatchAnnotateFilesRequest,
3386    _delegate: Option<&'a mut dyn common::Delegate>,
3387    _additional_params: HashMap<String, String>,
3388    _scopes: BTreeSet<String>,
3389}
3390
3391impl<'a, C> common::CallBuilder for FileAsyncBatchAnnotateCall<'a, C> {}
3392
3393impl<'a, C> FileAsyncBatchAnnotateCall<'a, C>
3394where
3395    C: common::Connector,
3396{
3397    /// Perform the operation you have build so far.
3398    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3399        use std::borrow::Cow;
3400        use std::io::{Read, Seek};
3401
3402        use common::{url::Params, ToParts};
3403        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3404
3405        let mut dd = common::DefaultDelegate;
3406        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3407        dlg.begin(common::MethodInfo {
3408            id: "vision.files.asyncBatchAnnotate",
3409            http_method: hyper::Method::POST,
3410        });
3411
3412        for &field in ["alt"].iter() {
3413            if self._additional_params.contains_key(field) {
3414                dlg.finished(false);
3415                return Err(common::Error::FieldClash(field));
3416            }
3417        }
3418
3419        let mut params = Params::with_capacity(3 + self._additional_params.len());
3420
3421        params.extend(self._additional_params.iter());
3422
3423        params.push("alt", "json");
3424        let mut url = self.hub._base_url.clone() + "v1/files:asyncBatchAnnotate";
3425        if self._scopes.is_empty() {
3426            self._scopes
3427                .insert(Scope::CloudPlatform.as_ref().to_string());
3428        }
3429
3430        let url = params.parse_with_url(&url);
3431
3432        let mut json_mime_type = mime::APPLICATION_JSON;
3433        let mut request_value_reader = {
3434            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3435            common::remove_json_null_values(&mut value);
3436            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3437            serde_json::to_writer(&mut dst, &value).unwrap();
3438            dst
3439        };
3440        let request_size = request_value_reader
3441            .seek(std::io::SeekFrom::End(0))
3442            .unwrap();
3443        request_value_reader
3444            .seek(std::io::SeekFrom::Start(0))
3445            .unwrap();
3446
3447        loop {
3448            let token = match self
3449                .hub
3450                .auth
3451                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3452                .await
3453            {
3454                Ok(token) => token,
3455                Err(e) => match dlg.token(e) {
3456                    Ok(token) => token,
3457                    Err(e) => {
3458                        dlg.finished(false);
3459                        return Err(common::Error::MissingToken(e));
3460                    }
3461                },
3462            };
3463            request_value_reader
3464                .seek(std::io::SeekFrom::Start(0))
3465                .unwrap();
3466            let mut req_result = {
3467                let client = &self.hub.client;
3468                dlg.pre_request();
3469                let mut req_builder = hyper::Request::builder()
3470                    .method(hyper::Method::POST)
3471                    .uri(url.as_str())
3472                    .header(USER_AGENT, self.hub._user_agent.clone());
3473
3474                if let Some(token) = token.as_ref() {
3475                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3476                }
3477
3478                let request = req_builder
3479                    .header(CONTENT_TYPE, json_mime_type.to_string())
3480                    .header(CONTENT_LENGTH, request_size as u64)
3481                    .body(common::to_body(
3482                        request_value_reader.get_ref().clone().into(),
3483                    ));
3484
3485                client.request(request.unwrap()).await
3486            };
3487
3488            match req_result {
3489                Err(err) => {
3490                    if let common::Retry::After(d) = dlg.http_error(&err) {
3491                        sleep(d).await;
3492                        continue;
3493                    }
3494                    dlg.finished(false);
3495                    return Err(common::Error::HttpError(err));
3496                }
3497                Ok(res) => {
3498                    let (mut parts, body) = res.into_parts();
3499                    let mut body = common::Body::new(body);
3500                    if !parts.status.is_success() {
3501                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3502                        let error = serde_json::from_str(&common::to_string(&bytes));
3503                        let response = common::to_response(parts, bytes.into());
3504
3505                        if let common::Retry::After(d) =
3506                            dlg.http_failure(&response, error.as_ref().ok())
3507                        {
3508                            sleep(d).await;
3509                            continue;
3510                        }
3511
3512                        dlg.finished(false);
3513
3514                        return Err(match error {
3515                            Ok(value) => common::Error::BadRequest(value),
3516                            _ => common::Error::Failure(response),
3517                        });
3518                    }
3519                    let response = {
3520                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3521                        let encoded = common::to_string(&bytes);
3522                        match serde_json::from_str(&encoded) {
3523                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3524                            Err(error) => {
3525                                dlg.response_json_decode_error(&encoded, &error);
3526                                return Err(common::Error::JsonDecodeError(
3527                                    encoded.to_string(),
3528                                    error,
3529                                ));
3530                            }
3531                        }
3532                    };
3533
3534                    dlg.finished(true);
3535                    return Ok(response);
3536                }
3537            }
3538        }
3539    }
3540
3541    ///
3542    /// Sets the *request* property to the given value.
3543    ///
3544    /// Even though the property as already been set when instantiating this call,
3545    /// we provide this method for API completeness.
3546    pub fn request(
3547        mut self,
3548        new_value: AsyncBatchAnnotateFilesRequest,
3549    ) -> FileAsyncBatchAnnotateCall<'a, C> {
3550        self._request = new_value;
3551        self
3552    }
3553    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3554    /// while executing the actual API request.
3555    ///
3556    /// ````text
3557    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3558    /// ````
3559    ///
3560    /// Sets the *delegate* property to the given value.
3561    pub fn delegate(
3562        mut self,
3563        new_value: &'a mut dyn common::Delegate,
3564    ) -> FileAsyncBatchAnnotateCall<'a, C> {
3565        self._delegate = Some(new_value);
3566        self
3567    }
3568
3569    /// Set any additional parameter of the query string used in the request.
3570    /// It should be used to set parameters which are not yet available through their own
3571    /// setters.
3572    ///
3573    /// Please note that this method must not be used to set any of the known parameters
3574    /// which have their own setter method. If done anyway, the request will fail.
3575    ///
3576    /// # Additional Parameters
3577    ///
3578    /// * *$.xgafv* (query-string) - V1 error format.
3579    /// * *access_token* (query-string) - OAuth access token.
3580    /// * *alt* (query-string) - Data format for response.
3581    /// * *callback* (query-string) - JSONP
3582    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3583    /// * *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.
3584    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3585    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3586    /// * *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.
3587    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3588    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3589    pub fn param<T>(mut self, name: T, value: T) -> FileAsyncBatchAnnotateCall<'a, C>
3590    where
3591        T: AsRef<str>,
3592    {
3593        self._additional_params
3594            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3595        self
3596    }
3597
3598    /// Identifies the authorization scope for the method you are building.
3599    ///
3600    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3601    /// [`Scope::CloudPlatform`].
3602    ///
3603    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3604    /// tokens for more than one scope.
3605    ///
3606    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3607    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3608    /// sufficient, a read-write scope will do as well.
3609    pub fn add_scope<St>(mut self, scope: St) -> FileAsyncBatchAnnotateCall<'a, C>
3610    where
3611        St: AsRef<str>,
3612    {
3613        self._scopes.insert(String::from(scope.as_ref()));
3614        self
3615    }
3616    /// Identifies the authorization scope(s) for the method you are building.
3617    ///
3618    /// See [`Self::add_scope()`] for details.
3619    pub fn add_scopes<I, St>(mut self, scopes: I) -> FileAsyncBatchAnnotateCall<'a, C>
3620    where
3621        I: IntoIterator<Item = St>,
3622        St: AsRef<str>,
3623    {
3624        self._scopes
3625            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3626        self
3627    }
3628
3629    /// Removes all scopes, and no default scope will be used either.
3630    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3631    /// for details).
3632    pub fn clear_scopes(mut self) -> FileAsyncBatchAnnotateCall<'a, C> {
3633        self._scopes.clear();
3634        self
3635    }
3636}
3637
3638/// Run image detection and annotation for a batch of images.
3639///
3640/// A builder for the *annotate* method supported by a *image* resource.
3641/// It is not used directly, but through a [`ImageMethods`] instance.
3642///
3643/// # Example
3644///
3645/// Instantiate a resource method builder
3646///
3647/// ```test_harness,no_run
3648/// # extern crate hyper;
3649/// # extern crate hyper_rustls;
3650/// # extern crate google_vision1 as vision1;
3651/// use vision1::api::BatchAnnotateImagesRequest;
3652/// # async fn dox() {
3653/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3654///
3655/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3656/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3657/// #     .with_native_roots()
3658/// #     .unwrap()
3659/// #     .https_only()
3660/// #     .enable_http2()
3661/// #     .build();
3662///
3663/// # let executor = hyper_util::rt::TokioExecutor::new();
3664/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3665/// #     secret,
3666/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3667/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3668/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3669/// #     ),
3670/// # ).build().await.unwrap();
3671///
3672/// # let client = hyper_util::client::legacy::Client::builder(
3673/// #     hyper_util::rt::TokioExecutor::new()
3674/// # )
3675/// # .build(
3676/// #     hyper_rustls::HttpsConnectorBuilder::new()
3677/// #         .with_native_roots()
3678/// #         .unwrap()
3679/// #         .https_or_http()
3680/// #         .enable_http2()
3681/// #         .build()
3682/// # );
3683/// # let mut hub = Vision::new(client, auth);
3684/// // As the method needs a request, you would usually fill it with the desired information
3685/// // into the respective structure. Some of the parts shown here might not be applicable !
3686/// // Values shown here are possibly random and not representative !
3687/// let mut req = BatchAnnotateImagesRequest::default();
3688///
3689/// // You can configure optional parameters by calling the respective setters at will, and
3690/// // execute the final call using `doit()`.
3691/// // Values shown here are possibly random and not representative !
3692/// let result = hub.images().annotate(req)
3693///              .doit().await;
3694/// # }
3695/// ```
3696pub struct ImageAnnotateCall<'a, C>
3697where
3698    C: 'a,
3699{
3700    hub: &'a Vision<C>,
3701    _request: BatchAnnotateImagesRequest,
3702    _delegate: Option<&'a mut dyn common::Delegate>,
3703    _additional_params: HashMap<String, String>,
3704    _scopes: BTreeSet<String>,
3705}
3706
3707impl<'a, C> common::CallBuilder for ImageAnnotateCall<'a, C> {}
3708
3709impl<'a, C> ImageAnnotateCall<'a, C>
3710where
3711    C: common::Connector,
3712{
3713    /// Perform the operation you have build so far.
3714    pub async fn doit(mut self) -> common::Result<(common::Response, BatchAnnotateImagesResponse)> {
3715        use std::borrow::Cow;
3716        use std::io::{Read, Seek};
3717
3718        use common::{url::Params, ToParts};
3719        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3720
3721        let mut dd = common::DefaultDelegate;
3722        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3723        dlg.begin(common::MethodInfo {
3724            id: "vision.images.annotate",
3725            http_method: hyper::Method::POST,
3726        });
3727
3728        for &field in ["alt"].iter() {
3729            if self._additional_params.contains_key(field) {
3730                dlg.finished(false);
3731                return Err(common::Error::FieldClash(field));
3732            }
3733        }
3734
3735        let mut params = Params::with_capacity(3 + self._additional_params.len());
3736
3737        params.extend(self._additional_params.iter());
3738
3739        params.push("alt", "json");
3740        let mut url = self.hub._base_url.clone() + "v1/images:annotate";
3741        if self._scopes.is_empty() {
3742            self._scopes
3743                .insert(Scope::CloudPlatform.as_ref().to_string());
3744        }
3745
3746        let url = params.parse_with_url(&url);
3747
3748        let mut json_mime_type = mime::APPLICATION_JSON;
3749        let mut request_value_reader = {
3750            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3751            common::remove_json_null_values(&mut value);
3752            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3753            serde_json::to_writer(&mut dst, &value).unwrap();
3754            dst
3755        };
3756        let request_size = request_value_reader
3757            .seek(std::io::SeekFrom::End(0))
3758            .unwrap();
3759        request_value_reader
3760            .seek(std::io::SeekFrom::Start(0))
3761            .unwrap();
3762
3763        loop {
3764            let token = match self
3765                .hub
3766                .auth
3767                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3768                .await
3769            {
3770                Ok(token) => token,
3771                Err(e) => match dlg.token(e) {
3772                    Ok(token) => token,
3773                    Err(e) => {
3774                        dlg.finished(false);
3775                        return Err(common::Error::MissingToken(e));
3776                    }
3777                },
3778            };
3779            request_value_reader
3780                .seek(std::io::SeekFrom::Start(0))
3781                .unwrap();
3782            let mut req_result = {
3783                let client = &self.hub.client;
3784                dlg.pre_request();
3785                let mut req_builder = hyper::Request::builder()
3786                    .method(hyper::Method::POST)
3787                    .uri(url.as_str())
3788                    .header(USER_AGENT, self.hub._user_agent.clone());
3789
3790                if let Some(token) = token.as_ref() {
3791                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3792                }
3793
3794                let request = req_builder
3795                    .header(CONTENT_TYPE, json_mime_type.to_string())
3796                    .header(CONTENT_LENGTH, request_size as u64)
3797                    .body(common::to_body(
3798                        request_value_reader.get_ref().clone().into(),
3799                    ));
3800
3801                client.request(request.unwrap()).await
3802            };
3803
3804            match req_result {
3805                Err(err) => {
3806                    if let common::Retry::After(d) = dlg.http_error(&err) {
3807                        sleep(d).await;
3808                        continue;
3809                    }
3810                    dlg.finished(false);
3811                    return Err(common::Error::HttpError(err));
3812                }
3813                Ok(res) => {
3814                    let (mut parts, body) = res.into_parts();
3815                    let mut body = common::Body::new(body);
3816                    if !parts.status.is_success() {
3817                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3818                        let error = serde_json::from_str(&common::to_string(&bytes));
3819                        let response = common::to_response(parts, bytes.into());
3820
3821                        if let common::Retry::After(d) =
3822                            dlg.http_failure(&response, error.as_ref().ok())
3823                        {
3824                            sleep(d).await;
3825                            continue;
3826                        }
3827
3828                        dlg.finished(false);
3829
3830                        return Err(match error {
3831                            Ok(value) => common::Error::BadRequest(value),
3832                            _ => common::Error::Failure(response),
3833                        });
3834                    }
3835                    let response = {
3836                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3837                        let encoded = common::to_string(&bytes);
3838                        match serde_json::from_str(&encoded) {
3839                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3840                            Err(error) => {
3841                                dlg.response_json_decode_error(&encoded, &error);
3842                                return Err(common::Error::JsonDecodeError(
3843                                    encoded.to_string(),
3844                                    error,
3845                                ));
3846                            }
3847                        }
3848                    };
3849
3850                    dlg.finished(true);
3851                    return Ok(response);
3852                }
3853            }
3854        }
3855    }
3856
3857    ///
3858    /// Sets the *request* property to the given value.
3859    ///
3860    /// Even though the property as already been set when instantiating this call,
3861    /// we provide this method for API completeness.
3862    pub fn request(mut self, new_value: BatchAnnotateImagesRequest) -> ImageAnnotateCall<'a, C> {
3863        self._request = new_value;
3864        self
3865    }
3866    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3867    /// while executing the actual API request.
3868    ///
3869    /// ````text
3870    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3871    /// ````
3872    ///
3873    /// Sets the *delegate* property to the given value.
3874    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ImageAnnotateCall<'a, C> {
3875        self._delegate = Some(new_value);
3876        self
3877    }
3878
3879    /// Set any additional parameter of the query string used in the request.
3880    /// It should be used to set parameters which are not yet available through their own
3881    /// setters.
3882    ///
3883    /// Please note that this method must not be used to set any of the known parameters
3884    /// which have their own setter method. If done anyway, the request will fail.
3885    ///
3886    /// # Additional Parameters
3887    ///
3888    /// * *$.xgafv* (query-string) - V1 error format.
3889    /// * *access_token* (query-string) - OAuth access token.
3890    /// * *alt* (query-string) - Data format for response.
3891    /// * *callback* (query-string) - JSONP
3892    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3893    /// * *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.
3894    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3895    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3896    /// * *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.
3897    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3898    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3899    pub fn param<T>(mut self, name: T, value: T) -> ImageAnnotateCall<'a, C>
3900    where
3901        T: AsRef<str>,
3902    {
3903        self._additional_params
3904            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3905        self
3906    }
3907
3908    /// Identifies the authorization scope for the method you are building.
3909    ///
3910    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3911    /// [`Scope::CloudPlatform`].
3912    ///
3913    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3914    /// tokens for more than one scope.
3915    ///
3916    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3917    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3918    /// sufficient, a read-write scope will do as well.
3919    pub fn add_scope<St>(mut self, scope: St) -> ImageAnnotateCall<'a, C>
3920    where
3921        St: AsRef<str>,
3922    {
3923        self._scopes.insert(String::from(scope.as_ref()));
3924        self
3925    }
3926    /// Identifies the authorization scope(s) for the method you are building.
3927    ///
3928    /// See [`Self::add_scope()`] for details.
3929    pub fn add_scopes<I, St>(mut self, scopes: I) -> ImageAnnotateCall<'a, C>
3930    where
3931        I: IntoIterator<Item = St>,
3932        St: AsRef<str>,
3933    {
3934        self._scopes
3935            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3936        self
3937    }
3938
3939    /// Removes all scopes, and no default scope will be used either.
3940    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3941    /// for details).
3942    pub fn clear_scopes(mut self) -> ImageAnnotateCall<'a, C> {
3943        self._scopes.clear();
3944        self
3945    }
3946}
3947
3948/// Run asynchronous image detection and annotation for a list of images. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). This service will write image annotation outputs to json files in customer GCS bucket, each json file containing BatchAnnotateImagesResponse proto.
3949///
3950/// A builder for the *asyncBatchAnnotate* method supported by a *image* resource.
3951/// It is not used directly, but through a [`ImageMethods`] instance.
3952///
3953/// # Example
3954///
3955/// Instantiate a resource method builder
3956///
3957/// ```test_harness,no_run
3958/// # extern crate hyper;
3959/// # extern crate hyper_rustls;
3960/// # extern crate google_vision1 as vision1;
3961/// use vision1::api::AsyncBatchAnnotateImagesRequest;
3962/// # async fn dox() {
3963/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3964///
3965/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3966/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3967/// #     .with_native_roots()
3968/// #     .unwrap()
3969/// #     .https_only()
3970/// #     .enable_http2()
3971/// #     .build();
3972///
3973/// # let executor = hyper_util::rt::TokioExecutor::new();
3974/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3975/// #     secret,
3976/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3977/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3978/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3979/// #     ),
3980/// # ).build().await.unwrap();
3981///
3982/// # let client = hyper_util::client::legacy::Client::builder(
3983/// #     hyper_util::rt::TokioExecutor::new()
3984/// # )
3985/// # .build(
3986/// #     hyper_rustls::HttpsConnectorBuilder::new()
3987/// #         .with_native_roots()
3988/// #         .unwrap()
3989/// #         .https_or_http()
3990/// #         .enable_http2()
3991/// #         .build()
3992/// # );
3993/// # let mut hub = Vision::new(client, auth);
3994/// // As the method needs a request, you would usually fill it with the desired information
3995/// // into the respective structure. Some of the parts shown here might not be applicable !
3996/// // Values shown here are possibly random and not representative !
3997/// let mut req = AsyncBatchAnnotateImagesRequest::default();
3998///
3999/// // You can configure optional parameters by calling the respective setters at will, and
4000/// // execute the final call using `doit()`.
4001/// // Values shown here are possibly random and not representative !
4002/// let result = hub.images().async_batch_annotate(req)
4003///              .doit().await;
4004/// # }
4005/// ```
4006pub struct ImageAsyncBatchAnnotateCall<'a, C>
4007where
4008    C: 'a,
4009{
4010    hub: &'a Vision<C>,
4011    _request: AsyncBatchAnnotateImagesRequest,
4012    _delegate: Option<&'a mut dyn common::Delegate>,
4013    _additional_params: HashMap<String, String>,
4014    _scopes: BTreeSet<String>,
4015}
4016
4017impl<'a, C> common::CallBuilder for ImageAsyncBatchAnnotateCall<'a, C> {}
4018
4019impl<'a, C> ImageAsyncBatchAnnotateCall<'a, C>
4020where
4021    C: common::Connector,
4022{
4023    /// Perform the operation you have build so far.
4024    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4025        use std::borrow::Cow;
4026        use std::io::{Read, Seek};
4027
4028        use common::{url::Params, ToParts};
4029        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4030
4031        let mut dd = common::DefaultDelegate;
4032        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4033        dlg.begin(common::MethodInfo {
4034            id: "vision.images.asyncBatchAnnotate",
4035            http_method: hyper::Method::POST,
4036        });
4037
4038        for &field in ["alt"].iter() {
4039            if self._additional_params.contains_key(field) {
4040                dlg.finished(false);
4041                return Err(common::Error::FieldClash(field));
4042            }
4043        }
4044
4045        let mut params = Params::with_capacity(3 + self._additional_params.len());
4046
4047        params.extend(self._additional_params.iter());
4048
4049        params.push("alt", "json");
4050        let mut url = self.hub._base_url.clone() + "v1/images:asyncBatchAnnotate";
4051        if self._scopes.is_empty() {
4052            self._scopes
4053                .insert(Scope::CloudPlatform.as_ref().to_string());
4054        }
4055
4056        let url = params.parse_with_url(&url);
4057
4058        let mut json_mime_type = mime::APPLICATION_JSON;
4059        let mut request_value_reader = {
4060            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4061            common::remove_json_null_values(&mut value);
4062            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4063            serde_json::to_writer(&mut dst, &value).unwrap();
4064            dst
4065        };
4066        let request_size = request_value_reader
4067            .seek(std::io::SeekFrom::End(0))
4068            .unwrap();
4069        request_value_reader
4070            .seek(std::io::SeekFrom::Start(0))
4071            .unwrap();
4072
4073        loop {
4074            let token = match self
4075                .hub
4076                .auth
4077                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4078                .await
4079            {
4080                Ok(token) => token,
4081                Err(e) => match dlg.token(e) {
4082                    Ok(token) => token,
4083                    Err(e) => {
4084                        dlg.finished(false);
4085                        return Err(common::Error::MissingToken(e));
4086                    }
4087                },
4088            };
4089            request_value_reader
4090                .seek(std::io::SeekFrom::Start(0))
4091                .unwrap();
4092            let mut req_result = {
4093                let client = &self.hub.client;
4094                dlg.pre_request();
4095                let mut req_builder = hyper::Request::builder()
4096                    .method(hyper::Method::POST)
4097                    .uri(url.as_str())
4098                    .header(USER_AGENT, self.hub._user_agent.clone());
4099
4100                if let Some(token) = token.as_ref() {
4101                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4102                }
4103
4104                let request = req_builder
4105                    .header(CONTENT_TYPE, json_mime_type.to_string())
4106                    .header(CONTENT_LENGTH, request_size as u64)
4107                    .body(common::to_body(
4108                        request_value_reader.get_ref().clone().into(),
4109                    ));
4110
4111                client.request(request.unwrap()).await
4112            };
4113
4114            match req_result {
4115                Err(err) => {
4116                    if let common::Retry::After(d) = dlg.http_error(&err) {
4117                        sleep(d).await;
4118                        continue;
4119                    }
4120                    dlg.finished(false);
4121                    return Err(common::Error::HttpError(err));
4122                }
4123                Ok(res) => {
4124                    let (mut parts, body) = res.into_parts();
4125                    let mut body = common::Body::new(body);
4126                    if !parts.status.is_success() {
4127                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4128                        let error = serde_json::from_str(&common::to_string(&bytes));
4129                        let response = common::to_response(parts, bytes.into());
4130
4131                        if let common::Retry::After(d) =
4132                            dlg.http_failure(&response, error.as_ref().ok())
4133                        {
4134                            sleep(d).await;
4135                            continue;
4136                        }
4137
4138                        dlg.finished(false);
4139
4140                        return Err(match error {
4141                            Ok(value) => common::Error::BadRequest(value),
4142                            _ => common::Error::Failure(response),
4143                        });
4144                    }
4145                    let response = {
4146                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4147                        let encoded = common::to_string(&bytes);
4148                        match serde_json::from_str(&encoded) {
4149                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4150                            Err(error) => {
4151                                dlg.response_json_decode_error(&encoded, &error);
4152                                return Err(common::Error::JsonDecodeError(
4153                                    encoded.to_string(),
4154                                    error,
4155                                ));
4156                            }
4157                        }
4158                    };
4159
4160                    dlg.finished(true);
4161                    return Ok(response);
4162                }
4163            }
4164        }
4165    }
4166
4167    ///
4168    /// Sets the *request* property to the given value.
4169    ///
4170    /// Even though the property as already been set when instantiating this call,
4171    /// we provide this method for API completeness.
4172    pub fn request(
4173        mut self,
4174        new_value: AsyncBatchAnnotateImagesRequest,
4175    ) -> ImageAsyncBatchAnnotateCall<'a, C> {
4176        self._request = new_value;
4177        self
4178    }
4179    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4180    /// while executing the actual API request.
4181    ///
4182    /// ````text
4183    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4184    /// ````
4185    ///
4186    /// Sets the *delegate* property to the given value.
4187    pub fn delegate(
4188        mut self,
4189        new_value: &'a mut dyn common::Delegate,
4190    ) -> ImageAsyncBatchAnnotateCall<'a, C> {
4191        self._delegate = Some(new_value);
4192        self
4193    }
4194
4195    /// Set any additional parameter of the query string used in the request.
4196    /// It should be used to set parameters which are not yet available through their own
4197    /// setters.
4198    ///
4199    /// Please note that this method must not be used to set any of the known parameters
4200    /// which have their own setter method. If done anyway, the request will fail.
4201    ///
4202    /// # Additional Parameters
4203    ///
4204    /// * *$.xgafv* (query-string) - V1 error format.
4205    /// * *access_token* (query-string) - OAuth access token.
4206    /// * *alt* (query-string) - Data format for response.
4207    /// * *callback* (query-string) - JSONP
4208    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4209    /// * *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.
4210    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4211    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4212    /// * *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.
4213    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4214    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4215    pub fn param<T>(mut self, name: T, value: T) -> ImageAsyncBatchAnnotateCall<'a, C>
4216    where
4217        T: AsRef<str>,
4218    {
4219        self._additional_params
4220            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4221        self
4222    }
4223
4224    /// Identifies the authorization scope for the method you are building.
4225    ///
4226    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4227    /// [`Scope::CloudPlatform`].
4228    ///
4229    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4230    /// tokens for more than one scope.
4231    ///
4232    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4233    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4234    /// sufficient, a read-write scope will do as well.
4235    pub fn add_scope<St>(mut self, scope: St) -> ImageAsyncBatchAnnotateCall<'a, C>
4236    where
4237        St: AsRef<str>,
4238    {
4239        self._scopes.insert(String::from(scope.as_ref()));
4240        self
4241    }
4242    /// Identifies the authorization scope(s) for the method you are building.
4243    ///
4244    /// See [`Self::add_scope()`] for details.
4245    pub fn add_scopes<I, St>(mut self, scopes: I) -> ImageAsyncBatchAnnotateCall<'a, C>
4246    where
4247        I: IntoIterator<Item = St>,
4248        St: AsRef<str>,
4249    {
4250        self._scopes
4251            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4252        self
4253    }
4254
4255    /// Removes all scopes, and no default scope will be used either.
4256    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4257    /// for details).
4258    pub fn clear_scopes(mut self) -> ImageAsyncBatchAnnotateCall<'a, C> {
4259        self._scopes.clear();
4260        self
4261    }
4262}
4263
4264/// 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.
4265///
4266/// A builder for the *operations.get* method supported by a *location* resource.
4267/// It is not used directly, but through a [`LocationMethods`] instance.
4268///
4269/// # Example
4270///
4271/// Instantiate a resource method builder
4272///
4273/// ```test_harness,no_run
4274/// # extern crate hyper;
4275/// # extern crate hyper_rustls;
4276/// # extern crate google_vision1 as vision1;
4277/// # async fn dox() {
4278/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4279///
4280/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4281/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4282/// #     .with_native_roots()
4283/// #     .unwrap()
4284/// #     .https_only()
4285/// #     .enable_http2()
4286/// #     .build();
4287///
4288/// # let executor = hyper_util::rt::TokioExecutor::new();
4289/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4290/// #     secret,
4291/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4292/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4293/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4294/// #     ),
4295/// # ).build().await.unwrap();
4296///
4297/// # let client = hyper_util::client::legacy::Client::builder(
4298/// #     hyper_util::rt::TokioExecutor::new()
4299/// # )
4300/// # .build(
4301/// #     hyper_rustls::HttpsConnectorBuilder::new()
4302/// #         .with_native_roots()
4303/// #         .unwrap()
4304/// #         .https_or_http()
4305/// #         .enable_http2()
4306/// #         .build()
4307/// # );
4308/// # let mut hub = Vision::new(client, auth);
4309/// // You can configure optional parameters by calling the respective setters at will, and
4310/// // execute the final call using `doit()`.
4311/// // Values shown here are possibly random and not representative !
4312/// let result = hub.locations().operations_get("name")
4313///              .doit().await;
4314/// # }
4315/// ```
4316pub struct LocationOperationGetCall<'a, C>
4317where
4318    C: 'a,
4319{
4320    hub: &'a Vision<C>,
4321    _name: String,
4322    _delegate: Option<&'a mut dyn common::Delegate>,
4323    _additional_params: HashMap<String, String>,
4324    _scopes: BTreeSet<String>,
4325}
4326
4327impl<'a, C> common::CallBuilder for LocationOperationGetCall<'a, C> {}
4328
4329impl<'a, C> LocationOperationGetCall<'a, C>
4330where
4331    C: common::Connector,
4332{
4333    /// Perform the operation you have build so far.
4334    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4335        use std::borrow::Cow;
4336        use std::io::{Read, Seek};
4337
4338        use common::{url::Params, ToParts};
4339        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4340
4341        let mut dd = common::DefaultDelegate;
4342        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4343        dlg.begin(common::MethodInfo {
4344            id: "vision.locations.operations.get",
4345            http_method: hyper::Method::GET,
4346        });
4347
4348        for &field in ["alt", "name"].iter() {
4349            if self._additional_params.contains_key(field) {
4350                dlg.finished(false);
4351                return Err(common::Error::FieldClash(field));
4352            }
4353        }
4354
4355        let mut params = Params::with_capacity(3 + self._additional_params.len());
4356        params.push("name", self._name);
4357
4358        params.extend(self._additional_params.iter());
4359
4360        params.push("alt", "json");
4361        let mut url = self.hub._base_url.clone() + "v1/{+name}";
4362        if self._scopes.is_empty() {
4363            self._scopes
4364                .insert(Scope::CloudPlatform.as_ref().to_string());
4365        }
4366
4367        #[allow(clippy::single_element_loop)]
4368        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4369            url = params.uri_replacement(url, param_name, find_this, true);
4370        }
4371        {
4372            let to_remove = ["name"];
4373            params.remove_params(&to_remove);
4374        }
4375
4376        let url = params.parse_with_url(&url);
4377
4378        loop {
4379            let token = match self
4380                .hub
4381                .auth
4382                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4383                .await
4384            {
4385                Ok(token) => token,
4386                Err(e) => match dlg.token(e) {
4387                    Ok(token) => token,
4388                    Err(e) => {
4389                        dlg.finished(false);
4390                        return Err(common::Error::MissingToken(e));
4391                    }
4392                },
4393            };
4394            let mut req_result = {
4395                let client = &self.hub.client;
4396                dlg.pre_request();
4397                let mut req_builder = hyper::Request::builder()
4398                    .method(hyper::Method::GET)
4399                    .uri(url.as_str())
4400                    .header(USER_AGENT, self.hub._user_agent.clone());
4401
4402                if let Some(token) = token.as_ref() {
4403                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4404                }
4405
4406                let request = req_builder
4407                    .header(CONTENT_LENGTH, 0_u64)
4408                    .body(common::to_body::<String>(None));
4409
4410                client.request(request.unwrap()).await
4411            };
4412
4413            match req_result {
4414                Err(err) => {
4415                    if let common::Retry::After(d) = dlg.http_error(&err) {
4416                        sleep(d).await;
4417                        continue;
4418                    }
4419                    dlg.finished(false);
4420                    return Err(common::Error::HttpError(err));
4421                }
4422                Ok(res) => {
4423                    let (mut parts, body) = res.into_parts();
4424                    let mut body = common::Body::new(body);
4425                    if !parts.status.is_success() {
4426                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4427                        let error = serde_json::from_str(&common::to_string(&bytes));
4428                        let response = common::to_response(parts, bytes.into());
4429
4430                        if let common::Retry::After(d) =
4431                            dlg.http_failure(&response, error.as_ref().ok())
4432                        {
4433                            sleep(d).await;
4434                            continue;
4435                        }
4436
4437                        dlg.finished(false);
4438
4439                        return Err(match error {
4440                            Ok(value) => common::Error::BadRequest(value),
4441                            _ => common::Error::Failure(response),
4442                        });
4443                    }
4444                    let response = {
4445                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4446                        let encoded = common::to_string(&bytes);
4447                        match serde_json::from_str(&encoded) {
4448                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4449                            Err(error) => {
4450                                dlg.response_json_decode_error(&encoded, &error);
4451                                return Err(common::Error::JsonDecodeError(
4452                                    encoded.to_string(),
4453                                    error,
4454                                ));
4455                            }
4456                        }
4457                    };
4458
4459                    dlg.finished(true);
4460                    return Ok(response);
4461                }
4462            }
4463        }
4464    }
4465
4466    /// The name of the operation resource.
4467    ///
4468    /// Sets the *name* path property to the given value.
4469    ///
4470    /// Even though the property as already been set when instantiating this call,
4471    /// we provide this method for API completeness.
4472    pub fn name(mut self, new_value: &str) -> LocationOperationGetCall<'a, C> {
4473        self._name = new_value.to_string();
4474        self
4475    }
4476    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4477    /// while executing the actual API request.
4478    ///
4479    /// ````text
4480    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4481    /// ````
4482    ///
4483    /// Sets the *delegate* property to the given value.
4484    pub fn delegate(
4485        mut self,
4486        new_value: &'a mut dyn common::Delegate,
4487    ) -> LocationOperationGetCall<'a, C> {
4488        self._delegate = Some(new_value);
4489        self
4490    }
4491
4492    /// Set any additional parameter of the query string used in the request.
4493    /// It should be used to set parameters which are not yet available through their own
4494    /// setters.
4495    ///
4496    /// Please note that this method must not be used to set any of the known parameters
4497    /// which have their own setter method. If done anyway, the request will fail.
4498    ///
4499    /// # Additional Parameters
4500    ///
4501    /// * *$.xgafv* (query-string) - V1 error format.
4502    /// * *access_token* (query-string) - OAuth access token.
4503    /// * *alt* (query-string) - Data format for response.
4504    /// * *callback* (query-string) - JSONP
4505    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4506    /// * *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.
4507    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4508    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4509    /// * *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.
4510    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4511    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4512    pub fn param<T>(mut self, name: T, value: T) -> LocationOperationGetCall<'a, C>
4513    where
4514        T: AsRef<str>,
4515    {
4516        self._additional_params
4517            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4518        self
4519    }
4520
4521    /// Identifies the authorization scope for the method you are building.
4522    ///
4523    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4524    /// [`Scope::CloudPlatform`].
4525    ///
4526    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4527    /// tokens for more than one scope.
4528    ///
4529    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4530    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4531    /// sufficient, a read-write scope will do as well.
4532    pub fn add_scope<St>(mut self, scope: St) -> LocationOperationGetCall<'a, C>
4533    where
4534        St: AsRef<str>,
4535    {
4536        self._scopes.insert(String::from(scope.as_ref()));
4537        self
4538    }
4539    /// Identifies the authorization scope(s) for the method you are building.
4540    ///
4541    /// See [`Self::add_scope()`] for details.
4542    pub fn add_scopes<I, St>(mut self, scopes: I) -> LocationOperationGetCall<'a, C>
4543    where
4544        I: IntoIterator<Item = St>,
4545        St: AsRef<str>,
4546    {
4547        self._scopes
4548            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4549        self
4550    }
4551
4552    /// Removes all scopes, and no default scope will be used either.
4553    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4554    /// for details).
4555    pub fn clear_scopes(mut self) -> LocationOperationGetCall<'a, C> {
4556        self._scopes.clear();
4557        self
4558    }
4559}
4560
4561/// 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`.
4562///
4563/// A builder for the *cancel* method supported by a *operation* resource.
4564/// It is not used directly, but through a [`OperationMethods`] instance.
4565///
4566/// # Example
4567///
4568/// Instantiate a resource method builder
4569///
4570/// ```test_harness,no_run
4571/// # extern crate hyper;
4572/// # extern crate hyper_rustls;
4573/// # extern crate google_vision1 as vision1;
4574/// use vision1::api::CancelOperationRequest;
4575/// # async fn dox() {
4576/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4577///
4578/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4579/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4580/// #     .with_native_roots()
4581/// #     .unwrap()
4582/// #     .https_only()
4583/// #     .enable_http2()
4584/// #     .build();
4585///
4586/// # let executor = hyper_util::rt::TokioExecutor::new();
4587/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4588/// #     secret,
4589/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4590/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4591/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4592/// #     ),
4593/// # ).build().await.unwrap();
4594///
4595/// # let client = hyper_util::client::legacy::Client::builder(
4596/// #     hyper_util::rt::TokioExecutor::new()
4597/// # )
4598/// # .build(
4599/// #     hyper_rustls::HttpsConnectorBuilder::new()
4600/// #         .with_native_roots()
4601/// #         .unwrap()
4602/// #         .https_or_http()
4603/// #         .enable_http2()
4604/// #         .build()
4605/// # );
4606/// # let mut hub = Vision::new(client, auth);
4607/// // As the method needs a request, you would usually fill it with the desired information
4608/// // into the respective structure. Some of the parts shown here might not be applicable !
4609/// // Values shown here are possibly random and not representative !
4610/// let mut req = CancelOperationRequest::default();
4611///
4612/// // You can configure optional parameters by calling the respective setters at will, and
4613/// // execute the final call using `doit()`.
4614/// // Values shown here are possibly random and not representative !
4615/// let result = hub.operations().cancel(req, "name")
4616///              .doit().await;
4617/// # }
4618/// ```
4619pub struct OperationCancelCall<'a, C>
4620where
4621    C: 'a,
4622{
4623    hub: &'a Vision<C>,
4624    _request: CancelOperationRequest,
4625    _name: String,
4626    _delegate: Option<&'a mut dyn common::Delegate>,
4627    _additional_params: HashMap<String, String>,
4628    _scopes: BTreeSet<String>,
4629}
4630
4631impl<'a, C> common::CallBuilder for OperationCancelCall<'a, C> {}
4632
4633impl<'a, C> OperationCancelCall<'a, C>
4634where
4635    C: common::Connector,
4636{
4637    /// Perform the operation you have build so far.
4638    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
4639        use std::borrow::Cow;
4640        use std::io::{Read, Seek};
4641
4642        use common::{url::Params, ToParts};
4643        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4644
4645        let mut dd = common::DefaultDelegate;
4646        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4647        dlg.begin(common::MethodInfo {
4648            id: "vision.operations.cancel",
4649            http_method: hyper::Method::POST,
4650        });
4651
4652        for &field in ["alt", "name"].iter() {
4653            if self._additional_params.contains_key(field) {
4654                dlg.finished(false);
4655                return Err(common::Error::FieldClash(field));
4656            }
4657        }
4658
4659        let mut params = Params::with_capacity(4 + self._additional_params.len());
4660        params.push("name", self._name);
4661
4662        params.extend(self._additional_params.iter());
4663
4664        params.push("alt", "json");
4665        let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
4666        if self._scopes.is_empty() {
4667            self._scopes
4668                .insert(Scope::CloudPlatform.as_ref().to_string());
4669        }
4670
4671        #[allow(clippy::single_element_loop)]
4672        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4673            url = params.uri_replacement(url, param_name, find_this, true);
4674        }
4675        {
4676            let to_remove = ["name"];
4677            params.remove_params(&to_remove);
4678        }
4679
4680        let url = params.parse_with_url(&url);
4681
4682        let mut json_mime_type = mime::APPLICATION_JSON;
4683        let mut request_value_reader = {
4684            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4685            common::remove_json_null_values(&mut value);
4686            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4687            serde_json::to_writer(&mut dst, &value).unwrap();
4688            dst
4689        };
4690        let request_size = request_value_reader
4691            .seek(std::io::SeekFrom::End(0))
4692            .unwrap();
4693        request_value_reader
4694            .seek(std::io::SeekFrom::Start(0))
4695            .unwrap();
4696
4697        loop {
4698            let token = match self
4699                .hub
4700                .auth
4701                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4702                .await
4703            {
4704                Ok(token) => token,
4705                Err(e) => match dlg.token(e) {
4706                    Ok(token) => token,
4707                    Err(e) => {
4708                        dlg.finished(false);
4709                        return Err(common::Error::MissingToken(e));
4710                    }
4711                },
4712            };
4713            request_value_reader
4714                .seek(std::io::SeekFrom::Start(0))
4715                .unwrap();
4716            let mut req_result = {
4717                let client = &self.hub.client;
4718                dlg.pre_request();
4719                let mut req_builder = hyper::Request::builder()
4720                    .method(hyper::Method::POST)
4721                    .uri(url.as_str())
4722                    .header(USER_AGENT, self.hub._user_agent.clone());
4723
4724                if let Some(token) = token.as_ref() {
4725                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4726                }
4727
4728                let request = req_builder
4729                    .header(CONTENT_TYPE, json_mime_type.to_string())
4730                    .header(CONTENT_LENGTH, request_size as u64)
4731                    .body(common::to_body(
4732                        request_value_reader.get_ref().clone().into(),
4733                    ));
4734
4735                client.request(request.unwrap()).await
4736            };
4737
4738            match req_result {
4739                Err(err) => {
4740                    if let common::Retry::After(d) = dlg.http_error(&err) {
4741                        sleep(d).await;
4742                        continue;
4743                    }
4744                    dlg.finished(false);
4745                    return Err(common::Error::HttpError(err));
4746                }
4747                Ok(res) => {
4748                    let (mut parts, body) = res.into_parts();
4749                    let mut body = common::Body::new(body);
4750                    if !parts.status.is_success() {
4751                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4752                        let error = serde_json::from_str(&common::to_string(&bytes));
4753                        let response = common::to_response(parts, bytes.into());
4754
4755                        if let common::Retry::After(d) =
4756                            dlg.http_failure(&response, error.as_ref().ok())
4757                        {
4758                            sleep(d).await;
4759                            continue;
4760                        }
4761
4762                        dlg.finished(false);
4763
4764                        return Err(match error {
4765                            Ok(value) => common::Error::BadRequest(value),
4766                            _ => common::Error::Failure(response),
4767                        });
4768                    }
4769                    let response = {
4770                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4771                        let encoded = common::to_string(&bytes);
4772                        match serde_json::from_str(&encoded) {
4773                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4774                            Err(error) => {
4775                                dlg.response_json_decode_error(&encoded, &error);
4776                                return Err(common::Error::JsonDecodeError(
4777                                    encoded.to_string(),
4778                                    error,
4779                                ));
4780                            }
4781                        }
4782                    };
4783
4784                    dlg.finished(true);
4785                    return Ok(response);
4786                }
4787            }
4788        }
4789    }
4790
4791    ///
4792    /// Sets the *request* property to the given value.
4793    ///
4794    /// Even though the property as already been set when instantiating this call,
4795    /// we provide this method for API completeness.
4796    pub fn request(mut self, new_value: CancelOperationRequest) -> OperationCancelCall<'a, C> {
4797        self._request = new_value;
4798        self
4799    }
4800    /// The name of the operation resource to be cancelled.
4801    ///
4802    /// Sets the *name* path property to the given value.
4803    ///
4804    /// Even though the property as already been set when instantiating this call,
4805    /// we provide this method for API completeness.
4806    pub fn name(mut self, new_value: &str) -> OperationCancelCall<'a, C> {
4807        self._name = new_value.to_string();
4808        self
4809    }
4810    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4811    /// while executing the actual API request.
4812    ///
4813    /// ````text
4814    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4815    /// ````
4816    ///
4817    /// Sets the *delegate* property to the given value.
4818    pub fn delegate(
4819        mut self,
4820        new_value: &'a mut dyn common::Delegate,
4821    ) -> OperationCancelCall<'a, C> {
4822        self._delegate = Some(new_value);
4823        self
4824    }
4825
4826    /// Set any additional parameter of the query string used in the request.
4827    /// It should be used to set parameters which are not yet available through their own
4828    /// setters.
4829    ///
4830    /// Please note that this method must not be used to set any of the known parameters
4831    /// which have their own setter method. If done anyway, the request will fail.
4832    ///
4833    /// # Additional Parameters
4834    ///
4835    /// * *$.xgafv* (query-string) - V1 error format.
4836    /// * *access_token* (query-string) - OAuth access token.
4837    /// * *alt* (query-string) - Data format for response.
4838    /// * *callback* (query-string) - JSONP
4839    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4840    /// * *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.
4841    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4842    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4843    /// * *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.
4844    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4845    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4846    pub fn param<T>(mut self, name: T, value: T) -> OperationCancelCall<'a, C>
4847    where
4848        T: AsRef<str>,
4849    {
4850        self._additional_params
4851            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4852        self
4853    }
4854
4855    /// Identifies the authorization scope for the method you are building.
4856    ///
4857    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4858    /// [`Scope::CloudPlatform`].
4859    ///
4860    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4861    /// tokens for more than one scope.
4862    ///
4863    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4864    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4865    /// sufficient, a read-write scope will do as well.
4866    pub fn add_scope<St>(mut self, scope: St) -> OperationCancelCall<'a, C>
4867    where
4868        St: AsRef<str>,
4869    {
4870        self._scopes.insert(String::from(scope.as_ref()));
4871        self
4872    }
4873    /// Identifies the authorization scope(s) for the method you are building.
4874    ///
4875    /// See [`Self::add_scope()`] for details.
4876    pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationCancelCall<'a, C>
4877    where
4878        I: IntoIterator<Item = St>,
4879        St: AsRef<str>,
4880    {
4881        self._scopes
4882            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4883        self
4884    }
4885
4886    /// Removes all scopes, and no default scope will be used either.
4887    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4888    /// for details).
4889    pub fn clear_scopes(mut self) -> OperationCancelCall<'a, C> {
4890        self._scopes.clear();
4891        self
4892    }
4893}
4894
4895/// 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`.
4896///
4897/// A builder for the *delete* method supported by a *operation* resource.
4898/// It is not used directly, but through a [`OperationMethods`] instance.
4899///
4900/// # Example
4901///
4902/// Instantiate a resource method builder
4903///
4904/// ```test_harness,no_run
4905/// # extern crate hyper;
4906/// # extern crate hyper_rustls;
4907/// # extern crate google_vision1 as vision1;
4908/// # async fn dox() {
4909/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4910///
4911/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4912/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4913/// #     .with_native_roots()
4914/// #     .unwrap()
4915/// #     .https_only()
4916/// #     .enable_http2()
4917/// #     .build();
4918///
4919/// # let executor = hyper_util::rt::TokioExecutor::new();
4920/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4921/// #     secret,
4922/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4923/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4924/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4925/// #     ),
4926/// # ).build().await.unwrap();
4927///
4928/// # let client = hyper_util::client::legacy::Client::builder(
4929/// #     hyper_util::rt::TokioExecutor::new()
4930/// # )
4931/// # .build(
4932/// #     hyper_rustls::HttpsConnectorBuilder::new()
4933/// #         .with_native_roots()
4934/// #         .unwrap()
4935/// #         .https_or_http()
4936/// #         .enable_http2()
4937/// #         .build()
4938/// # );
4939/// # let mut hub = Vision::new(client, auth);
4940/// // You can configure optional parameters by calling the respective setters at will, and
4941/// // execute the final call using `doit()`.
4942/// // Values shown here are possibly random and not representative !
4943/// let result = hub.operations().delete("name")
4944///              .doit().await;
4945/// # }
4946/// ```
4947pub struct OperationDeleteCall<'a, C>
4948where
4949    C: 'a,
4950{
4951    hub: &'a Vision<C>,
4952    _name: String,
4953    _delegate: Option<&'a mut dyn common::Delegate>,
4954    _additional_params: HashMap<String, String>,
4955    _scopes: BTreeSet<String>,
4956}
4957
4958impl<'a, C> common::CallBuilder for OperationDeleteCall<'a, C> {}
4959
4960impl<'a, C> OperationDeleteCall<'a, C>
4961where
4962    C: common::Connector,
4963{
4964    /// Perform the operation you have build so far.
4965    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
4966        use std::borrow::Cow;
4967        use std::io::{Read, Seek};
4968
4969        use common::{url::Params, ToParts};
4970        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4971
4972        let mut dd = common::DefaultDelegate;
4973        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4974        dlg.begin(common::MethodInfo {
4975            id: "vision.operations.delete",
4976            http_method: hyper::Method::DELETE,
4977        });
4978
4979        for &field in ["alt", "name"].iter() {
4980            if self._additional_params.contains_key(field) {
4981                dlg.finished(false);
4982                return Err(common::Error::FieldClash(field));
4983            }
4984        }
4985
4986        let mut params = Params::with_capacity(3 + self._additional_params.len());
4987        params.push("name", self._name);
4988
4989        params.extend(self._additional_params.iter());
4990
4991        params.push("alt", "json");
4992        let mut url = self.hub._base_url.clone() + "v1/{+name}";
4993        if self._scopes.is_empty() {
4994            self._scopes
4995                .insert(Scope::CloudPlatform.as_ref().to_string());
4996        }
4997
4998        #[allow(clippy::single_element_loop)]
4999        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5000            url = params.uri_replacement(url, param_name, find_this, true);
5001        }
5002        {
5003            let to_remove = ["name"];
5004            params.remove_params(&to_remove);
5005        }
5006
5007        let url = params.parse_with_url(&url);
5008
5009        loop {
5010            let token = match self
5011                .hub
5012                .auth
5013                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5014                .await
5015            {
5016                Ok(token) => token,
5017                Err(e) => match dlg.token(e) {
5018                    Ok(token) => token,
5019                    Err(e) => {
5020                        dlg.finished(false);
5021                        return Err(common::Error::MissingToken(e));
5022                    }
5023                },
5024            };
5025            let mut req_result = {
5026                let client = &self.hub.client;
5027                dlg.pre_request();
5028                let mut req_builder = hyper::Request::builder()
5029                    .method(hyper::Method::DELETE)
5030                    .uri(url.as_str())
5031                    .header(USER_AGENT, self.hub._user_agent.clone());
5032
5033                if let Some(token) = token.as_ref() {
5034                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5035                }
5036
5037                let request = req_builder
5038                    .header(CONTENT_LENGTH, 0_u64)
5039                    .body(common::to_body::<String>(None));
5040
5041                client.request(request.unwrap()).await
5042            };
5043
5044            match req_result {
5045                Err(err) => {
5046                    if let common::Retry::After(d) = dlg.http_error(&err) {
5047                        sleep(d).await;
5048                        continue;
5049                    }
5050                    dlg.finished(false);
5051                    return Err(common::Error::HttpError(err));
5052                }
5053                Ok(res) => {
5054                    let (mut parts, body) = res.into_parts();
5055                    let mut body = common::Body::new(body);
5056                    if !parts.status.is_success() {
5057                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5058                        let error = serde_json::from_str(&common::to_string(&bytes));
5059                        let response = common::to_response(parts, bytes.into());
5060
5061                        if let common::Retry::After(d) =
5062                            dlg.http_failure(&response, error.as_ref().ok())
5063                        {
5064                            sleep(d).await;
5065                            continue;
5066                        }
5067
5068                        dlg.finished(false);
5069
5070                        return Err(match error {
5071                            Ok(value) => common::Error::BadRequest(value),
5072                            _ => common::Error::Failure(response),
5073                        });
5074                    }
5075                    let response = {
5076                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5077                        let encoded = common::to_string(&bytes);
5078                        match serde_json::from_str(&encoded) {
5079                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5080                            Err(error) => {
5081                                dlg.response_json_decode_error(&encoded, &error);
5082                                return Err(common::Error::JsonDecodeError(
5083                                    encoded.to_string(),
5084                                    error,
5085                                ));
5086                            }
5087                        }
5088                    };
5089
5090                    dlg.finished(true);
5091                    return Ok(response);
5092                }
5093            }
5094        }
5095    }
5096
5097    /// The name of the operation resource to be deleted.
5098    ///
5099    /// Sets the *name* path property to the given value.
5100    ///
5101    /// Even though the property as already been set when instantiating this call,
5102    /// we provide this method for API completeness.
5103    pub fn name(mut self, new_value: &str) -> OperationDeleteCall<'a, C> {
5104        self._name = new_value.to_string();
5105        self
5106    }
5107    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5108    /// while executing the actual API request.
5109    ///
5110    /// ````text
5111    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5112    /// ````
5113    ///
5114    /// Sets the *delegate* property to the given value.
5115    pub fn delegate(
5116        mut self,
5117        new_value: &'a mut dyn common::Delegate,
5118    ) -> OperationDeleteCall<'a, C> {
5119        self._delegate = Some(new_value);
5120        self
5121    }
5122
5123    /// Set any additional parameter of the query string used in the request.
5124    /// It should be used to set parameters which are not yet available through their own
5125    /// setters.
5126    ///
5127    /// Please note that this method must not be used to set any of the known parameters
5128    /// which have their own setter method. If done anyway, the request will fail.
5129    ///
5130    /// # Additional Parameters
5131    ///
5132    /// * *$.xgafv* (query-string) - V1 error format.
5133    /// * *access_token* (query-string) - OAuth access token.
5134    /// * *alt* (query-string) - Data format for response.
5135    /// * *callback* (query-string) - JSONP
5136    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5137    /// * *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.
5138    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5139    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5140    /// * *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.
5141    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5142    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5143    pub fn param<T>(mut self, name: T, value: T) -> OperationDeleteCall<'a, C>
5144    where
5145        T: AsRef<str>,
5146    {
5147        self._additional_params
5148            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5149        self
5150    }
5151
5152    /// Identifies the authorization scope for the method you are building.
5153    ///
5154    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5155    /// [`Scope::CloudPlatform`].
5156    ///
5157    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5158    /// tokens for more than one scope.
5159    ///
5160    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5161    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5162    /// sufficient, a read-write scope will do as well.
5163    pub fn add_scope<St>(mut self, scope: St) -> OperationDeleteCall<'a, C>
5164    where
5165        St: AsRef<str>,
5166    {
5167        self._scopes.insert(String::from(scope.as_ref()));
5168        self
5169    }
5170    /// Identifies the authorization scope(s) for the method you are building.
5171    ///
5172    /// See [`Self::add_scope()`] for details.
5173    pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationDeleteCall<'a, C>
5174    where
5175        I: IntoIterator<Item = St>,
5176        St: AsRef<str>,
5177    {
5178        self._scopes
5179            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5180        self
5181    }
5182
5183    /// Removes all scopes, and no default scope will be used either.
5184    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5185    /// for details).
5186    pub fn clear_scopes(mut self) -> OperationDeleteCall<'a, C> {
5187        self._scopes.clear();
5188        self
5189    }
5190}
5191
5192/// 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.
5193///
5194/// A builder for the *get* method supported by a *operation* resource.
5195/// It is not used directly, but through a [`OperationMethods`] instance.
5196///
5197/// # Example
5198///
5199/// Instantiate a resource method builder
5200///
5201/// ```test_harness,no_run
5202/// # extern crate hyper;
5203/// # extern crate hyper_rustls;
5204/// # extern crate google_vision1 as vision1;
5205/// # async fn dox() {
5206/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5207///
5208/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5209/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5210/// #     .with_native_roots()
5211/// #     .unwrap()
5212/// #     .https_only()
5213/// #     .enable_http2()
5214/// #     .build();
5215///
5216/// # let executor = hyper_util::rt::TokioExecutor::new();
5217/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5218/// #     secret,
5219/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5220/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5221/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5222/// #     ),
5223/// # ).build().await.unwrap();
5224///
5225/// # let client = hyper_util::client::legacy::Client::builder(
5226/// #     hyper_util::rt::TokioExecutor::new()
5227/// # )
5228/// # .build(
5229/// #     hyper_rustls::HttpsConnectorBuilder::new()
5230/// #         .with_native_roots()
5231/// #         .unwrap()
5232/// #         .https_or_http()
5233/// #         .enable_http2()
5234/// #         .build()
5235/// # );
5236/// # let mut hub = Vision::new(client, auth);
5237/// // You can configure optional parameters by calling the respective setters at will, and
5238/// // execute the final call using `doit()`.
5239/// // Values shown here are possibly random and not representative !
5240/// let result = hub.operations().get("name")
5241///              .doit().await;
5242/// # }
5243/// ```
5244pub struct OperationGetCall<'a, C>
5245where
5246    C: 'a,
5247{
5248    hub: &'a Vision<C>,
5249    _name: String,
5250    _delegate: Option<&'a mut dyn common::Delegate>,
5251    _additional_params: HashMap<String, String>,
5252    _scopes: BTreeSet<String>,
5253}
5254
5255impl<'a, C> common::CallBuilder for OperationGetCall<'a, C> {}
5256
5257impl<'a, C> OperationGetCall<'a, C>
5258where
5259    C: common::Connector,
5260{
5261    /// Perform the operation you have build so far.
5262    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5263        use std::borrow::Cow;
5264        use std::io::{Read, Seek};
5265
5266        use common::{url::Params, ToParts};
5267        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5268
5269        let mut dd = common::DefaultDelegate;
5270        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5271        dlg.begin(common::MethodInfo {
5272            id: "vision.operations.get",
5273            http_method: hyper::Method::GET,
5274        });
5275
5276        for &field in ["alt", "name"].iter() {
5277            if self._additional_params.contains_key(field) {
5278                dlg.finished(false);
5279                return Err(common::Error::FieldClash(field));
5280            }
5281        }
5282
5283        let mut params = Params::with_capacity(3 + self._additional_params.len());
5284        params.push("name", self._name);
5285
5286        params.extend(self._additional_params.iter());
5287
5288        params.push("alt", "json");
5289        let mut url = self.hub._base_url.clone() + "v1/{+name}";
5290        if self._scopes.is_empty() {
5291            self._scopes
5292                .insert(Scope::CloudPlatform.as_ref().to_string());
5293        }
5294
5295        #[allow(clippy::single_element_loop)]
5296        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5297            url = params.uri_replacement(url, param_name, find_this, true);
5298        }
5299        {
5300            let to_remove = ["name"];
5301            params.remove_params(&to_remove);
5302        }
5303
5304        let url = params.parse_with_url(&url);
5305
5306        loop {
5307            let token = match self
5308                .hub
5309                .auth
5310                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5311                .await
5312            {
5313                Ok(token) => token,
5314                Err(e) => match dlg.token(e) {
5315                    Ok(token) => token,
5316                    Err(e) => {
5317                        dlg.finished(false);
5318                        return Err(common::Error::MissingToken(e));
5319                    }
5320                },
5321            };
5322            let mut req_result = {
5323                let client = &self.hub.client;
5324                dlg.pre_request();
5325                let mut req_builder = hyper::Request::builder()
5326                    .method(hyper::Method::GET)
5327                    .uri(url.as_str())
5328                    .header(USER_AGENT, self.hub._user_agent.clone());
5329
5330                if let Some(token) = token.as_ref() {
5331                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5332                }
5333
5334                let request = req_builder
5335                    .header(CONTENT_LENGTH, 0_u64)
5336                    .body(common::to_body::<String>(None));
5337
5338                client.request(request.unwrap()).await
5339            };
5340
5341            match req_result {
5342                Err(err) => {
5343                    if let common::Retry::After(d) = dlg.http_error(&err) {
5344                        sleep(d).await;
5345                        continue;
5346                    }
5347                    dlg.finished(false);
5348                    return Err(common::Error::HttpError(err));
5349                }
5350                Ok(res) => {
5351                    let (mut parts, body) = res.into_parts();
5352                    let mut body = common::Body::new(body);
5353                    if !parts.status.is_success() {
5354                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5355                        let error = serde_json::from_str(&common::to_string(&bytes));
5356                        let response = common::to_response(parts, bytes.into());
5357
5358                        if let common::Retry::After(d) =
5359                            dlg.http_failure(&response, error.as_ref().ok())
5360                        {
5361                            sleep(d).await;
5362                            continue;
5363                        }
5364
5365                        dlg.finished(false);
5366
5367                        return Err(match error {
5368                            Ok(value) => common::Error::BadRequest(value),
5369                            _ => common::Error::Failure(response),
5370                        });
5371                    }
5372                    let response = {
5373                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5374                        let encoded = common::to_string(&bytes);
5375                        match serde_json::from_str(&encoded) {
5376                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5377                            Err(error) => {
5378                                dlg.response_json_decode_error(&encoded, &error);
5379                                return Err(common::Error::JsonDecodeError(
5380                                    encoded.to_string(),
5381                                    error,
5382                                ));
5383                            }
5384                        }
5385                    };
5386
5387                    dlg.finished(true);
5388                    return Ok(response);
5389                }
5390            }
5391        }
5392    }
5393
5394    /// The name of the operation resource.
5395    ///
5396    /// Sets the *name* path property to the given value.
5397    ///
5398    /// Even though the property as already been set when instantiating this call,
5399    /// we provide this method for API completeness.
5400    pub fn name(mut self, new_value: &str) -> OperationGetCall<'a, C> {
5401        self._name = new_value.to_string();
5402        self
5403    }
5404    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5405    /// while executing the actual API request.
5406    ///
5407    /// ````text
5408    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5409    /// ````
5410    ///
5411    /// Sets the *delegate* property to the given value.
5412    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OperationGetCall<'a, C> {
5413        self._delegate = Some(new_value);
5414        self
5415    }
5416
5417    /// Set any additional parameter of the query string used in the request.
5418    /// It should be used to set parameters which are not yet available through their own
5419    /// setters.
5420    ///
5421    /// Please note that this method must not be used to set any of the known parameters
5422    /// which have their own setter method. If done anyway, the request will fail.
5423    ///
5424    /// # Additional Parameters
5425    ///
5426    /// * *$.xgafv* (query-string) - V1 error format.
5427    /// * *access_token* (query-string) - OAuth access token.
5428    /// * *alt* (query-string) - Data format for response.
5429    /// * *callback* (query-string) - JSONP
5430    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5431    /// * *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.
5432    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5433    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5434    /// * *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.
5435    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5436    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5437    pub fn param<T>(mut self, name: T, value: T) -> OperationGetCall<'a, C>
5438    where
5439        T: AsRef<str>,
5440    {
5441        self._additional_params
5442            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5443        self
5444    }
5445
5446    /// Identifies the authorization scope for the method you are building.
5447    ///
5448    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5449    /// [`Scope::CloudPlatform`].
5450    ///
5451    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5452    /// tokens for more than one scope.
5453    ///
5454    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5455    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5456    /// sufficient, a read-write scope will do as well.
5457    pub fn add_scope<St>(mut self, scope: St) -> OperationGetCall<'a, C>
5458    where
5459        St: AsRef<str>,
5460    {
5461        self._scopes.insert(String::from(scope.as_ref()));
5462        self
5463    }
5464    /// Identifies the authorization scope(s) for the method you are building.
5465    ///
5466    /// See [`Self::add_scope()`] for details.
5467    pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationGetCall<'a, C>
5468    where
5469        I: IntoIterator<Item = St>,
5470        St: AsRef<str>,
5471    {
5472        self._scopes
5473            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5474        self
5475    }
5476
5477    /// Removes all scopes, and no default scope will be used either.
5478    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5479    /// for details).
5480    pub fn clear_scopes(mut self) -> OperationGetCall<'a, C> {
5481        self._scopes.clear();
5482        self
5483    }
5484}
5485
5486/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
5487///
5488/// A builder for the *list* method supported by a *operation* resource.
5489/// It is not used directly, but through a [`OperationMethods`] instance.
5490///
5491/// # Example
5492///
5493/// Instantiate a resource method builder
5494///
5495/// ```test_harness,no_run
5496/// # extern crate hyper;
5497/// # extern crate hyper_rustls;
5498/// # extern crate google_vision1 as vision1;
5499/// # async fn dox() {
5500/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5501///
5502/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5503/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5504/// #     .with_native_roots()
5505/// #     .unwrap()
5506/// #     .https_only()
5507/// #     .enable_http2()
5508/// #     .build();
5509///
5510/// # let executor = hyper_util::rt::TokioExecutor::new();
5511/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5512/// #     secret,
5513/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5514/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5515/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5516/// #     ),
5517/// # ).build().await.unwrap();
5518///
5519/// # let client = hyper_util::client::legacy::Client::builder(
5520/// #     hyper_util::rt::TokioExecutor::new()
5521/// # )
5522/// # .build(
5523/// #     hyper_rustls::HttpsConnectorBuilder::new()
5524/// #         .with_native_roots()
5525/// #         .unwrap()
5526/// #         .https_or_http()
5527/// #         .enable_http2()
5528/// #         .build()
5529/// # );
5530/// # let mut hub = Vision::new(client, auth);
5531/// // You can configure optional parameters by calling the respective setters at will, and
5532/// // execute the final call using `doit()`.
5533/// // Values shown here are possibly random and not representative !
5534/// let result = hub.operations().list("name")
5535///              .return_partial_success(true)
5536///              .page_token("sed")
5537///              .page_size(-37)
5538///              .filter("gubergren")
5539///              .doit().await;
5540/// # }
5541/// ```
5542pub struct OperationListCall<'a, C>
5543where
5544    C: 'a,
5545{
5546    hub: &'a Vision<C>,
5547    _name: String,
5548    _return_partial_success: Option<bool>,
5549    _page_token: Option<String>,
5550    _page_size: Option<i32>,
5551    _filter: Option<String>,
5552    _delegate: Option<&'a mut dyn common::Delegate>,
5553    _additional_params: HashMap<String, String>,
5554    _scopes: BTreeSet<String>,
5555}
5556
5557impl<'a, C> common::CallBuilder for OperationListCall<'a, C> {}
5558
5559impl<'a, C> OperationListCall<'a, C>
5560where
5561    C: common::Connector,
5562{
5563    /// Perform the operation you have build so far.
5564    pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
5565        use std::borrow::Cow;
5566        use std::io::{Read, Seek};
5567
5568        use common::{url::Params, ToParts};
5569        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5570
5571        let mut dd = common::DefaultDelegate;
5572        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5573        dlg.begin(common::MethodInfo {
5574            id: "vision.operations.list",
5575            http_method: hyper::Method::GET,
5576        });
5577
5578        for &field in [
5579            "alt",
5580            "name",
5581            "returnPartialSuccess",
5582            "pageToken",
5583            "pageSize",
5584            "filter",
5585        ]
5586        .iter()
5587        {
5588            if self._additional_params.contains_key(field) {
5589                dlg.finished(false);
5590                return Err(common::Error::FieldClash(field));
5591            }
5592        }
5593
5594        let mut params = Params::with_capacity(7 + self._additional_params.len());
5595        params.push("name", self._name);
5596        if let Some(value) = self._return_partial_success.as_ref() {
5597            params.push("returnPartialSuccess", value.to_string());
5598        }
5599        if let Some(value) = self._page_token.as_ref() {
5600            params.push("pageToken", value);
5601        }
5602        if let Some(value) = self._page_size.as_ref() {
5603            params.push("pageSize", value.to_string());
5604        }
5605        if let Some(value) = self._filter.as_ref() {
5606            params.push("filter", value);
5607        }
5608
5609        params.extend(self._additional_params.iter());
5610
5611        params.push("alt", "json");
5612        let mut url = self.hub._base_url.clone() + "v1/{+name}";
5613        if self._scopes.is_empty() {
5614            self._scopes
5615                .insert(Scope::CloudPlatform.as_ref().to_string());
5616        }
5617
5618        #[allow(clippy::single_element_loop)]
5619        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5620            url = params.uri_replacement(url, param_name, find_this, true);
5621        }
5622        {
5623            let to_remove = ["name"];
5624            params.remove_params(&to_remove);
5625        }
5626
5627        let url = params.parse_with_url(&url);
5628
5629        loop {
5630            let token = match self
5631                .hub
5632                .auth
5633                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5634                .await
5635            {
5636                Ok(token) => token,
5637                Err(e) => match dlg.token(e) {
5638                    Ok(token) => token,
5639                    Err(e) => {
5640                        dlg.finished(false);
5641                        return Err(common::Error::MissingToken(e));
5642                    }
5643                },
5644            };
5645            let mut req_result = {
5646                let client = &self.hub.client;
5647                dlg.pre_request();
5648                let mut req_builder = hyper::Request::builder()
5649                    .method(hyper::Method::GET)
5650                    .uri(url.as_str())
5651                    .header(USER_AGENT, self.hub._user_agent.clone());
5652
5653                if let Some(token) = token.as_ref() {
5654                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5655                }
5656
5657                let request = req_builder
5658                    .header(CONTENT_LENGTH, 0_u64)
5659                    .body(common::to_body::<String>(None));
5660
5661                client.request(request.unwrap()).await
5662            };
5663
5664            match req_result {
5665                Err(err) => {
5666                    if let common::Retry::After(d) = dlg.http_error(&err) {
5667                        sleep(d).await;
5668                        continue;
5669                    }
5670                    dlg.finished(false);
5671                    return Err(common::Error::HttpError(err));
5672                }
5673                Ok(res) => {
5674                    let (mut parts, body) = res.into_parts();
5675                    let mut body = common::Body::new(body);
5676                    if !parts.status.is_success() {
5677                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5678                        let error = serde_json::from_str(&common::to_string(&bytes));
5679                        let response = common::to_response(parts, bytes.into());
5680
5681                        if let common::Retry::After(d) =
5682                            dlg.http_failure(&response, error.as_ref().ok())
5683                        {
5684                            sleep(d).await;
5685                            continue;
5686                        }
5687
5688                        dlg.finished(false);
5689
5690                        return Err(match error {
5691                            Ok(value) => common::Error::BadRequest(value),
5692                            _ => common::Error::Failure(response),
5693                        });
5694                    }
5695                    let response = {
5696                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5697                        let encoded = common::to_string(&bytes);
5698                        match serde_json::from_str(&encoded) {
5699                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5700                            Err(error) => {
5701                                dlg.response_json_decode_error(&encoded, &error);
5702                                return Err(common::Error::JsonDecodeError(
5703                                    encoded.to_string(),
5704                                    error,
5705                                ));
5706                            }
5707                        }
5708                    };
5709
5710                    dlg.finished(true);
5711                    return Ok(response);
5712                }
5713            }
5714        }
5715    }
5716
5717    /// The name of the operation's parent resource.
5718    ///
5719    /// Sets the *name* path property to the given value.
5720    ///
5721    /// Even though the property as already been set when instantiating this call,
5722    /// we provide this method for API completeness.
5723    pub fn name(mut self, new_value: &str) -> OperationListCall<'a, C> {
5724        self._name = new_value.to_string();
5725        self
5726    }
5727    /// 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.
5728    ///
5729    /// Sets the *return partial success* query property to the given value.
5730    pub fn return_partial_success(mut self, new_value: bool) -> OperationListCall<'a, C> {
5731        self._return_partial_success = Some(new_value);
5732        self
5733    }
5734    /// The standard list page token.
5735    ///
5736    /// Sets the *page token* query property to the given value.
5737    pub fn page_token(mut self, new_value: &str) -> OperationListCall<'a, C> {
5738        self._page_token = Some(new_value.to_string());
5739        self
5740    }
5741    /// The standard list page size.
5742    ///
5743    /// Sets the *page size* query property to the given value.
5744    pub fn page_size(mut self, new_value: i32) -> OperationListCall<'a, C> {
5745        self._page_size = Some(new_value);
5746        self
5747    }
5748    /// The standard list filter.
5749    ///
5750    /// Sets the *filter* query property to the given value.
5751    pub fn filter(mut self, new_value: &str) -> OperationListCall<'a, C> {
5752        self._filter = Some(new_value.to_string());
5753        self
5754    }
5755    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5756    /// while executing the actual API request.
5757    ///
5758    /// ````text
5759    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5760    /// ````
5761    ///
5762    /// Sets the *delegate* property to the given value.
5763    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OperationListCall<'a, C> {
5764        self._delegate = Some(new_value);
5765        self
5766    }
5767
5768    /// Set any additional parameter of the query string used in the request.
5769    /// It should be used to set parameters which are not yet available through their own
5770    /// setters.
5771    ///
5772    /// Please note that this method must not be used to set any of the known parameters
5773    /// which have their own setter method. If done anyway, the request will fail.
5774    ///
5775    /// # Additional Parameters
5776    ///
5777    /// * *$.xgafv* (query-string) - V1 error format.
5778    /// * *access_token* (query-string) - OAuth access token.
5779    /// * *alt* (query-string) - Data format for response.
5780    /// * *callback* (query-string) - JSONP
5781    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5782    /// * *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.
5783    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5784    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5785    /// * *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.
5786    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5787    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5788    pub fn param<T>(mut self, name: T, value: T) -> OperationListCall<'a, C>
5789    where
5790        T: AsRef<str>,
5791    {
5792        self._additional_params
5793            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5794        self
5795    }
5796
5797    /// Identifies the authorization scope for the method you are building.
5798    ///
5799    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5800    /// [`Scope::CloudPlatform`].
5801    ///
5802    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5803    /// tokens for more than one scope.
5804    ///
5805    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5806    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5807    /// sufficient, a read-write scope will do as well.
5808    pub fn add_scope<St>(mut self, scope: St) -> OperationListCall<'a, C>
5809    where
5810        St: AsRef<str>,
5811    {
5812        self._scopes.insert(String::from(scope.as_ref()));
5813        self
5814    }
5815    /// Identifies the authorization scope(s) for the method you are building.
5816    ///
5817    /// See [`Self::add_scope()`] for details.
5818    pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationListCall<'a, C>
5819    where
5820        I: IntoIterator<Item = St>,
5821        St: AsRef<str>,
5822    {
5823        self._scopes
5824            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5825        self
5826    }
5827
5828    /// Removes all scopes, and no default scope will be used either.
5829    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5830    /// for details).
5831    pub fn clear_scopes(mut self) -> OperationListCall<'a, C> {
5832        self._scopes.clear();
5833        self
5834    }
5835}
5836
5837/// Service that performs image detection and annotation for a batch of files. Now only "application/pdf", "image/tiff" and "image/gif" are supported. This service will extract at most 5 (customers can specify which 5 in AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each file provided and perform detection and annotation for each image extracted.
5838///
5839/// A builder for the *files.annotate* method supported by a *project* resource.
5840/// It is not used directly, but through a [`ProjectMethods`] instance.
5841///
5842/// # Example
5843///
5844/// Instantiate a resource method builder
5845///
5846/// ```test_harness,no_run
5847/// # extern crate hyper;
5848/// # extern crate hyper_rustls;
5849/// # extern crate google_vision1 as vision1;
5850/// use vision1::api::BatchAnnotateFilesRequest;
5851/// # async fn dox() {
5852/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5853///
5854/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5855/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5856/// #     .with_native_roots()
5857/// #     .unwrap()
5858/// #     .https_only()
5859/// #     .enable_http2()
5860/// #     .build();
5861///
5862/// # let executor = hyper_util::rt::TokioExecutor::new();
5863/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5864/// #     secret,
5865/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5866/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5867/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5868/// #     ),
5869/// # ).build().await.unwrap();
5870///
5871/// # let client = hyper_util::client::legacy::Client::builder(
5872/// #     hyper_util::rt::TokioExecutor::new()
5873/// # )
5874/// # .build(
5875/// #     hyper_rustls::HttpsConnectorBuilder::new()
5876/// #         .with_native_roots()
5877/// #         .unwrap()
5878/// #         .https_or_http()
5879/// #         .enable_http2()
5880/// #         .build()
5881/// # );
5882/// # let mut hub = Vision::new(client, auth);
5883/// // As the method needs a request, you would usually fill it with the desired information
5884/// // into the respective structure. Some of the parts shown here might not be applicable !
5885/// // Values shown here are possibly random and not representative !
5886/// let mut req = BatchAnnotateFilesRequest::default();
5887///
5888/// // You can configure optional parameters by calling the respective setters at will, and
5889/// // execute the final call using `doit()`.
5890/// // Values shown here are possibly random and not representative !
5891/// let result = hub.projects().files_annotate(req, "parent")
5892///              .doit().await;
5893/// # }
5894/// ```
5895pub struct ProjectFileAnnotateCall<'a, C>
5896where
5897    C: 'a,
5898{
5899    hub: &'a Vision<C>,
5900    _request: BatchAnnotateFilesRequest,
5901    _parent: String,
5902    _delegate: Option<&'a mut dyn common::Delegate>,
5903    _additional_params: HashMap<String, String>,
5904    _scopes: BTreeSet<String>,
5905}
5906
5907impl<'a, C> common::CallBuilder for ProjectFileAnnotateCall<'a, C> {}
5908
5909impl<'a, C> ProjectFileAnnotateCall<'a, C>
5910where
5911    C: common::Connector,
5912{
5913    /// Perform the operation you have build so far.
5914    pub async fn doit(mut self) -> common::Result<(common::Response, BatchAnnotateFilesResponse)> {
5915        use std::borrow::Cow;
5916        use std::io::{Read, Seek};
5917
5918        use common::{url::Params, ToParts};
5919        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5920
5921        let mut dd = common::DefaultDelegate;
5922        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5923        dlg.begin(common::MethodInfo {
5924            id: "vision.projects.files.annotate",
5925            http_method: hyper::Method::POST,
5926        });
5927
5928        for &field in ["alt", "parent"].iter() {
5929            if self._additional_params.contains_key(field) {
5930                dlg.finished(false);
5931                return Err(common::Error::FieldClash(field));
5932            }
5933        }
5934
5935        let mut params = Params::with_capacity(4 + self._additional_params.len());
5936        params.push("parent", self._parent);
5937
5938        params.extend(self._additional_params.iter());
5939
5940        params.push("alt", "json");
5941        let mut url = self.hub._base_url.clone() + "v1/{+parent}/files:annotate";
5942        if self._scopes.is_empty() {
5943            self._scopes
5944                .insert(Scope::CloudPlatform.as_ref().to_string());
5945        }
5946
5947        #[allow(clippy::single_element_loop)]
5948        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5949            url = params.uri_replacement(url, param_name, find_this, true);
5950        }
5951        {
5952            let to_remove = ["parent"];
5953            params.remove_params(&to_remove);
5954        }
5955
5956        let url = params.parse_with_url(&url);
5957
5958        let mut json_mime_type = mime::APPLICATION_JSON;
5959        let mut request_value_reader = {
5960            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5961            common::remove_json_null_values(&mut value);
5962            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5963            serde_json::to_writer(&mut dst, &value).unwrap();
5964            dst
5965        };
5966        let request_size = request_value_reader
5967            .seek(std::io::SeekFrom::End(0))
5968            .unwrap();
5969        request_value_reader
5970            .seek(std::io::SeekFrom::Start(0))
5971            .unwrap();
5972
5973        loop {
5974            let token = match self
5975                .hub
5976                .auth
5977                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5978                .await
5979            {
5980                Ok(token) => token,
5981                Err(e) => match dlg.token(e) {
5982                    Ok(token) => token,
5983                    Err(e) => {
5984                        dlg.finished(false);
5985                        return Err(common::Error::MissingToken(e));
5986                    }
5987                },
5988            };
5989            request_value_reader
5990                .seek(std::io::SeekFrom::Start(0))
5991                .unwrap();
5992            let mut req_result = {
5993                let client = &self.hub.client;
5994                dlg.pre_request();
5995                let mut req_builder = hyper::Request::builder()
5996                    .method(hyper::Method::POST)
5997                    .uri(url.as_str())
5998                    .header(USER_AGENT, self.hub._user_agent.clone());
5999
6000                if let Some(token) = token.as_ref() {
6001                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6002                }
6003
6004                let request = req_builder
6005                    .header(CONTENT_TYPE, json_mime_type.to_string())
6006                    .header(CONTENT_LENGTH, request_size as u64)
6007                    .body(common::to_body(
6008                        request_value_reader.get_ref().clone().into(),
6009                    ));
6010
6011                client.request(request.unwrap()).await
6012            };
6013
6014            match req_result {
6015                Err(err) => {
6016                    if let common::Retry::After(d) = dlg.http_error(&err) {
6017                        sleep(d).await;
6018                        continue;
6019                    }
6020                    dlg.finished(false);
6021                    return Err(common::Error::HttpError(err));
6022                }
6023                Ok(res) => {
6024                    let (mut parts, body) = res.into_parts();
6025                    let mut body = common::Body::new(body);
6026                    if !parts.status.is_success() {
6027                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6028                        let error = serde_json::from_str(&common::to_string(&bytes));
6029                        let response = common::to_response(parts, bytes.into());
6030
6031                        if let common::Retry::After(d) =
6032                            dlg.http_failure(&response, error.as_ref().ok())
6033                        {
6034                            sleep(d).await;
6035                            continue;
6036                        }
6037
6038                        dlg.finished(false);
6039
6040                        return Err(match error {
6041                            Ok(value) => common::Error::BadRequest(value),
6042                            _ => common::Error::Failure(response),
6043                        });
6044                    }
6045                    let response = {
6046                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6047                        let encoded = common::to_string(&bytes);
6048                        match serde_json::from_str(&encoded) {
6049                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6050                            Err(error) => {
6051                                dlg.response_json_decode_error(&encoded, &error);
6052                                return Err(common::Error::JsonDecodeError(
6053                                    encoded.to_string(),
6054                                    error,
6055                                ));
6056                            }
6057                        }
6058                    };
6059
6060                    dlg.finished(true);
6061                    return Ok(response);
6062                }
6063            }
6064        }
6065    }
6066
6067    ///
6068    /// Sets the *request* property to the given value.
6069    ///
6070    /// Even though the property as already been set when instantiating this call,
6071    /// we provide this method for API completeness.
6072    pub fn request(
6073        mut self,
6074        new_value: BatchAnnotateFilesRequest,
6075    ) -> ProjectFileAnnotateCall<'a, C> {
6076        self._request = new_value;
6077        self
6078    }
6079    /// Optional. Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no parent is specified, a region will be chosen automatically. Supported location-ids: `us`: USA country only, `asia`: East asia areas, like Japan, Taiwan, `eu`: The European Union. Example: `projects/project-A/locations/eu`.
6080    ///
6081    /// Sets the *parent* path property to the given value.
6082    ///
6083    /// Even though the property as already been set when instantiating this call,
6084    /// we provide this method for API completeness.
6085    pub fn parent(mut self, new_value: &str) -> ProjectFileAnnotateCall<'a, C> {
6086        self._parent = new_value.to_string();
6087        self
6088    }
6089    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6090    /// while executing the actual API request.
6091    ///
6092    /// ````text
6093    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6094    /// ````
6095    ///
6096    /// Sets the *delegate* property to the given value.
6097    pub fn delegate(
6098        mut self,
6099        new_value: &'a mut dyn common::Delegate,
6100    ) -> ProjectFileAnnotateCall<'a, C> {
6101        self._delegate = Some(new_value);
6102        self
6103    }
6104
6105    /// Set any additional parameter of the query string used in the request.
6106    /// It should be used to set parameters which are not yet available through their own
6107    /// setters.
6108    ///
6109    /// Please note that this method must not be used to set any of the known parameters
6110    /// which have their own setter method. If done anyway, the request will fail.
6111    ///
6112    /// # Additional Parameters
6113    ///
6114    /// * *$.xgafv* (query-string) - V1 error format.
6115    /// * *access_token* (query-string) - OAuth access token.
6116    /// * *alt* (query-string) - Data format for response.
6117    /// * *callback* (query-string) - JSONP
6118    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6119    /// * *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.
6120    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6121    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6122    /// * *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.
6123    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6124    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6125    pub fn param<T>(mut self, name: T, value: T) -> ProjectFileAnnotateCall<'a, C>
6126    where
6127        T: AsRef<str>,
6128    {
6129        self._additional_params
6130            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6131        self
6132    }
6133
6134    /// Identifies the authorization scope for the method you are building.
6135    ///
6136    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6137    /// [`Scope::CloudPlatform`].
6138    ///
6139    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6140    /// tokens for more than one scope.
6141    ///
6142    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6143    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6144    /// sufficient, a read-write scope will do as well.
6145    pub fn add_scope<St>(mut self, scope: St) -> ProjectFileAnnotateCall<'a, C>
6146    where
6147        St: AsRef<str>,
6148    {
6149        self._scopes.insert(String::from(scope.as_ref()));
6150        self
6151    }
6152    /// Identifies the authorization scope(s) for the method you are building.
6153    ///
6154    /// See [`Self::add_scope()`] for details.
6155    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectFileAnnotateCall<'a, C>
6156    where
6157        I: IntoIterator<Item = St>,
6158        St: AsRef<str>,
6159    {
6160        self._scopes
6161            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6162        self
6163    }
6164
6165    /// Removes all scopes, and no default scope will be used either.
6166    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6167    /// for details).
6168    pub fn clear_scopes(mut self) -> ProjectFileAnnotateCall<'a, C> {
6169        self._scopes.clear();
6170        self
6171    }
6172}
6173
6174/// Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).
6175///
6176/// A builder for the *files.asyncBatchAnnotate* method supported by a *project* resource.
6177/// It is not used directly, but through a [`ProjectMethods`] instance.
6178///
6179/// # Example
6180///
6181/// Instantiate a resource method builder
6182///
6183/// ```test_harness,no_run
6184/// # extern crate hyper;
6185/// # extern crate hyper_rustls;
6186/// # extern crate google_vision1 as vision1;
6187/// use vision1::api::AsyncBatchAnnotateFilesRequest;
6188/// # async fn dox() {
6189/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6190///
6191/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6192/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6193/// #     .with_native_roots()
6194/// #     .unwrap()
6195/// #     .https_only()
6196/// #     .enable_http2()
6197/// #     .build();
6198///
6199/// # let executor = hyper_util::rt::TokioExecutor::new();
6200/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6201/// #     secret,
6202/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6203/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6204/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6205/// #     ),
6206/// # ).build().await.unwrap();
6207///
6208/// # let client = hyper_util::client::legacy::Client::builder(
6209/// #     hyper_util::rt::TokioExecutor::new()
6210/// # )
6211/// # .build(
6212/// #     hyper_rustls::HttpsConnectorBuilder::new()
6213/// #         .with_native_roots()
6214/// #         .unwrap()
6215/// #         .https_or_http()
6216/// #         .enable_http2()
6217/// #         .build()
6218/// # );
6219/// # let mut hub = Vision::new(client, auth);
6220/// // As the method needs a request, you would usually fill it with the desired information
6221/// // into the respective structure. Some of the parts shown here might not be applicable !
6222/// // Values shown here are possibly random and not representative !
6223/// let mut req = AsyncBatchAnnotateFilesRequest::default();
6224///
6225/// // You can configure optional parameters by calling the respective setters at will, and
6226/// // execute the final call using `doit()`.
6227/// // Values shown here are possibly random and not representative !
6228/// let result = hub.projects().files_async_batch_annotate(req, "parent")
6229///              .doit().await;
6230/// # }
6231/// ```
6232pub struct ProjectFileAsyncBatchAnnotateCall<'a, C>
6233where
6234    C: 'a,
6235{
6236    hub: &'a Vision<C>,
6237    _request: AsyncBatchAnnotateFilesRequest,
6238    _parent: String,
6239    _delegate: Option<&'a mut dyn common::Delegate>,
6240    _additional_params: HashMap<String, String>,
6241    _scopes: BTreeSet<String>,
6242}
6243
6244impl<'a, C> common::CallBuilder for ProjectFileAsyncBatchAnnotateCall<'a, C> {}
6245
6246impl<'a, C> ProjectFileAsyncBatchAnnotateCall<'a, C>
6247where
6248    C: common::Connector,
6249{
6250    /// Perform the operation you have build so far.
6251    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6252        use std::borrow::Cow;
6253        use std::io::{Read, Seek};
6254
6255        use common::{url::Params, ToParts};
6256        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6257
6258        let mut dd = common::DefaultDelegate;
6259        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6260        dlg.begin(common::MethodInfo {
6261            id: "vision.projects.files.asyncBatchAnnotate",
6262            http_method: hyper::Method::POST,
6263        });
6264
6265        for &field in ["alt", "parent"].iter() {
6266            if self._additional_params.contains_key(field) {
6267                dlg.finished(false);
6268                return Err(common::Error::FieldClash(field));
6269            }
6270        }
6271
6272        let mut params = Params::with_capacity(4 + self._additional_params.len());
6273        params.push("parent", self._parent);
6274
6275        params.extend(self._additional_params.iter());
6276
6277        params.push("alt", "json");
6278        let mut url = self.hub._base_url.clone() + "v1/{+parent}/files:asyncBatchAnnotate";
6279        if self._scopes.is_empty() {
6280            self._scopes
6281                .insert(Scope::CloudPlatform.as_ref().to_string());
6282        }
6283
6284        #[allow(clippy::single_element_loop)]
6285        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6286            url = params.uri_replacement(url, param_name, find_this, true);
6287        }
6288        {
6289            let to_remove = ["parent"];
6290            params.remove_params(&to_remove);
6291        }
6292
6293        let url = params.parse_with_url(&url);
6294
6295        let mut json_mime_type = mime::APPLICATION_JSON;
6296        let mut request_value_reader = {
6297            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6298            common::remove_json_null_values(&mut value);
6299            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6300            serde_json::to_writer(&mut dst, &value).unwrap();
6301            dst
6302        };
6303        let request_size = request_value_reader
6304            .seek(std::io::SeekFrom::End(0))
6305            .unwrap();
6306        request_value_reader
6307            .seek(std::io::SeekFrom::Start(0))
6308            .unwrap();
6309
6310        loop {
6311            let token = match self
6312                .hub
6313                .auth
6314                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6315                .await
6316            {
6317                Ok(token) => token,
6318                Err(e) => match dlg.token(e) {
6319                    Ok(token) => token,
6320                    Err(e) => {
6321                        dlg.finished(false);
6322                        return Err(common::Error::MissingToken(e));
6323                    }
6324                },
6325            };
6326            request_value_reader
6327                .seek(std::io::SeekFrom::Start(0))
6328                .unwrap();
6329            let mut req_result = {
6330                let client = &self.hub.client;
6331                dlg.pre_request();
6332                let mut req_builder = hyper::Request::builder()
6333                    .method(hyper::Method::POST)
6334                    .uri(url.as_str())
6335                    .header(USER_AGENT, self.hub._user_agent.clone());
6336
6337                if let Some(token) = token.as_ref() {
6338                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6339                }
6340
6341                let request = req_builder
6342                    .header(CONTENT_TYPE, json_mime_type.to_string())
6343                    .header(CONTENT_LENGTH, request_size as u64)
6344                    .body(common::to_body(
6345                        request_value_reader.get_ref().clone().into(),
6346                    ));
6347
6348                client.request(request.unwrap()).await
6349            };
6350
6351            match req_result {
6352                Err(err) => {
6353                    if let common::Retry::After(d) = dlg.http_error(&err) {
6354                        sleep(d).await;
6355                        continue;
6356                    }
6357                    dlg.finished(false);
6358                    return Err(common::Error::HttpError(err));
6359                }
6360                Ok(res) => {
6361                    let (mut parts, body) = res.into_parts();
6362                    let mut body = common::Body::new(body);
6363                    if !parts.status.is_success() {
6364                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6365                        let error = serde_json::from_str(&common::to_string(&bytes));
6366                        let response = common::to_response(parts, bytes.into());
6367
6368                        if let common::Retry::After(d) =
6369                            dlg.http_failure(&response, error.as_ref().ok())
6370                        {
6371                            sleep(d).await;
6372                            continue;
6373                        }
6374
6375                        dlg.finished(false);
6376
6377                        return Err(match error {
6378                            Ok(value) => common::Error::BadRequest(value),
6379                            _ => common::Error::Failure(response),
6380                        });
6381                    }
6382                    let response = {
6383                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6384                        let encoded = common::to_string(&bytes);
6385                        match serde_json::from_str(&encoded) {
6386                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6387                            Err(error) => {
6388                                dlg.response_json_decode_error(&encoded, &error);
6389                                return Err(common::Error::JsonDecodeError(
6390                                    encoded.to_string(),
6391                                    error,
6392                                ));
6393                            }
6394                        }
6395                    };
6396
6397                    dlg.finished(true);
6398                    return Ok(response);
6399                }
6400            }
6401        }
6402    }
6403
6404    ///
6405    /// Sets the *request* property to the given value.
6406    ///
6407    /// Even though the property as already been set when instantiating this call,
6408    /// we provide this method for API completeness.
6409    pub fn request(
6410        mut self,
6411        new_value: AsyncBatchAnnotateFilesRequest,
6412    ) -> ProjectFileAsyncBatchAnnotateCall<'a, C> {
6413        self._request = new_value;
6414        self
6415    }
6416    /// Optional. Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no parent is specified, a region will be chosen automatically. Supported location-ids: `us`: USA country only, `asia`: East asia areas, like Japan, Taiwan, `eu`: The European Union. Example: `projects/project-A/locations/eu`.
6417    ///
6418    /// Sets the *parent* path property to the given value.
6419    ///
6420    /// Even though the property as already been set when instantiating this call,
6421    /// we provide this method for API completeness.
6422    pub fn parent(mut self, new_value: &str) -> ProjectFileAsyncBatchAnnotateCall<'a, C> {
6423        self._parent = new_value.to_string();
6424        self
6425    }
6426    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6427    /// while executing the actual API request.
6428    ///
6429    /// ````text
6430    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6431    /// ````
6432    ///
6433    /// Sets the *delegate* property to the given value.
6434    pub fn delegate(
6435        mut self,
6436        new_value: &'a mut dyn common::Delegate,
6437    ) -> ProjectFileAsyncBatchAnnotateCall<'a, C> {
6438        self._delegate = Some(new_value);
6439        self
6440    }
6441
6442    /// Set any additional parameter of the query string used in the request.
6443    /// It should be used to set parameters which are not yet available through their own
6444    /// setters.
6445    ///
6446    /// Please note that this method must not be used to set any of the known parameters
6447    /// which have their own setter method. If done anyway, the request will fail.
6448    ///
6449    /// # Additional Parameters
6450    ///
6451    /// * *$.xgafv* (query-string) - V1 error format.
6452    /// * *access_token* (query-string) - OAuth access token.
6453    /// * *alt* (query-string) - Data format for response.
6454    /// * *callback* (query-string) - JSONP
6455    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6456    /// * *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.
6457    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6458    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6459    /// * *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.
6460    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6461    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6462    pub fn param<T>(mut self, name: T, value: T) -> ProjectFileAsyncBatchAnnotateCall<'a, C>
6463    where
6464        T: AsRef<str>,
6465    {
6466        self._additional_params
6467            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6468        self
6469    }
6470
6471    /// Identifies the authorization scope for the method you are building.
6472    ///
6473    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6474    /// [`Scope::CloudPlatform`].
6475    ///
6476    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6477    /// tokens for more than one scope.
6478    ///
6479    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6480    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6481    /// sufficient, a read-write scope will do as well.
6482    pub fn add_scope<St>(mut self, scope: St) -> ProjectFileAsyncBatchAnnotateCall<'a, C>
6483    where
6484        St: AsRef<str>,
6485    {
6486        self._scopes.insert(String::from(scope.as_ref()));
6487        self
6488    }
6489    /// Identifies the authorization scope(s) for the method you are building.
6490    ///
6491    /// See [`Self::add_scope()`] for details.
6492    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectFileAsyncBatchAnnotateCall<'a, C>
6493    where
6494        I: IntoIterator<Item = St>,
6495        St: AsRef<str>,
6496    {
6497        self._scopes
6498            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6499        self
6500    }
6501
6502    /// Removes all scopes, and no default scope will be used either.
6503    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6504    /// for details).
6505    pub fn clear_scopes(mut self) -> ProjectFileAsyncBatchAnnotateCall<'a, C> {
6506        self._scopes.clear();
6507        self
6508    }
6509}
6510
6511/// Run image detection and annotation for a batch of images.
6512///
6513/// A builder for the *images.annotate* method supported by a *project* resource.
6514/// It is not used directly, but through a [`ProjectMethods`] instance.
6515///
6516/// # Example
6517///
6518/// Instantiate a resource method builder
6519///
6520/// ```test_harness,no_run
6521/// # extern crate hyper;
6522/// # extern crate hyper_rustls;
6523/// # extern crate google_vision1 as vision1;
6524/// use vision1::api::BatchAnnotateImagesRequest;
6525/// # async fn dox() {
6526/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6527///
6528/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6529/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6530/// #     .with_native_roots()
6531/// #     .unwrap()
6532/// #     .https_only()
6533/// #     .enable_http2()
6534/// #     .build();
6535///
6536/// # let executor = hyper_util::rt::TokioExecutor::new();
6537/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6538/// #     secret,
6539/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6540/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6541/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6542/// #     ),
6543/// # ).build().await.unwrap();
6544///
6545/// # let client = hyper_util::client::legacy::Client::builder(
6546/// #     hyper_util::rt::TokioExecutor::new()
6547/// # )
6548/// # .build(
6549/// #     hyper_rustls::HttpsConnectorBuilder::new()
6550/// #         .with_native_roots()
6551/// #         .unwrap()
6552/// #         .https_or_http()
6553/// #         .enable_http2()
6554/// #         .build()
6555/// # );
6556/// # let mut hub = Vision::new(client, auth);
6557/// // As the method needs a request, you would usually fill it with the desired information
6558/// // into the respective structure. Some of the parts shown here might not be applicable !
6559/// // Values shown here are possibly random and not representative !
6560/// let mut req = BatchAnnotateImagesRequest::default();
6561///
6562/// // You can configure optional parameters by calling the respective setters at will, and
6563/// // execute the final call using `doit()`.
6564/// // Values shown here are possibly random and not representative !
6565/// let result = hub.projects().images_annotate(req, "parent")
6566///              .doit().await;
6567/// # }
6568/// ```
6569pub struct ProjectImageAnnotateCall<'a, C>
6570where
6571    C: 'a,
6572{
6573    hub: &'a Vision<C>,
6574    _request: BatchAnnotateImagesRequest,
6575    _parent: String,
6576    _delegate: Option<&'a mut dyn common::Delegate>,
6577    _additional_params: HashMap<String, String>,
6578    _scopes: BTreeSet<String>,
6579}
6580
6581impl<'a, C> common::CallBuilder for ProjectImageAnnotateCall<'a, C> {}
6582
6583impl<'a, C> ProjectImageAnnotateCall<'a, C>
6584where
6585    C: common::Connector,
6586{
6587    /// Perform the operation you have build so far.
6588    pub async fn doit(mut self) -> common::Result<(common::Response, BatchAnnotateImagesResponse)> {
6589        use std::borrow::Cow;
6590        use std::io::{Read, Seek};
6591
6592        use common::{url::Params, ToParts};
6593        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6594
6595        let mut dd = common::DefaultDelegate;
6596        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6597        dlg.begin(common::MethodInfo {
6598            id: "vision.projects.images.annotate",
6599            http_method: hyper::Method::POST,
6600        });
6601
6602        for &field in ["alt", "parent"].iter() {
6603            if self._additional_params.contains_key(field) {
6604                dlg.finished(false);
6605                return Err(common::Error::FieldClash(field));
6606            }
6607        }
6608
6609        let mut params = Params::with_capacity(4 + self._additional_params.len());
6610        params.push("parent", self._parent);
6611
6612        params.extend(self._additional_params.iter());
6613
6614        params.push("alt", "json");
6615        let mut url = self.hub._base_url.clone() + "v1/{+parent}/images:annotate";
6616        if self._scopes.is_empty() {
6617            self._scopes
6618                .insert(Scope::CloudPlatform.as_ref().to_string());
6619        }
6620
6621        #[allow(clippy::single_element_loop)]
6622        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6623            url = params.uri_replacement(url, param_name, find_this, true);
6624        }
6625        {
6626            let to_remove = ["parent"];
6627            params.remove_params(&to_remove);
6628        }
6629
6630        let url = params.parse_with_url(&url);
6631
6632        let mut json_mime_type = mime::APPLICATION_JSON;
6633        let mut request_value_reader = {
6634            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6635            common::remove_json_null_values(&mut value);
6636            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6637            serde_json::to_writer(&mut dst, &value).unwrap();
6638            dst
6639        };
6640        let request_size = request_value_reader
6641            .seek(std::io::SeekFrom::End(0))
6642            .unwrap();
6643        request_value_reader
6644            .seek(std::io::SeekFrom::Start(0))
6645            .unwrap();
6646
6647        loop {
6648            let token = match self
6649                .hub
6650                .auth
6651                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6652                .await
6653            {
6654                Ok(token) => token,
6655                Err(e) => match dlg.token(e) {
6656                    Ok(token) => token,
6657                    Err(e) => {
6658                        dlg.finished(false);
6659                        return Err(common::Error::MissingToken(e));
6660                    }
6661                },
6662            };
6663            request_value_reader
6664                .seek(std::io::SeekFrom::Start(0))
6665                .unwrap();
6666            let mut req_result = {
6667                let client = &self.hub.client;
6668                dlg.pre_request();
6669                let mut req_builder = hyper::Request::builder()
6670                    .method(hyper::Method::POST)
6671                    .uri(url.as_str())
6672                    .header(USER_AGENT, self.hub._user_agent.clone());
6673
6674                if let Some(token) = token.as_ref() {
6675                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6676                }
6677
6678                let request = req_builder
6679                    .header(CONTENT_TYPE, json_mime_type.to_string())
6680                    .header(CONTENT_LENGTH, request_size as u64)
6681                    .body(common::to_body(
6682                        request_value_reader.get_ref().clone().into(),
6683                    ));
6684
6685                client.request(request.unwrap()).await
6686            };
6687
6688            match req_result {
6689                Err(err) => {
6690                    if let common::Retry::After(d) = dlg.http_error(&err) {
6691                        sleep(d).await;
6692                        continue;
6693                    }
6694                    dlg.finished(false);
6695                    return Err(common::Error::HttpError(err));
6696                }
6697                Ok(res) => {
6698                    let (mut parts, body) = res.into_parts();
6699                    let mut body = common::Body::new(body);
6700                    if !parts.status.is_success() {
6701                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6702                        let error = serde_json::from_str(&common::to_string(&bytes));
6703                        let response = common::to_response(parts, bytes.into());
6704
6705                        if let common::Retry::After(d) =
6706                            dlg.http_failure(&response, error.as_ref().ok())
6707                        {
6708                            sleep(d).await;
6709                            continue;
6710                        }
6711
6712                        dlg.finished(false);
6713
6714                        return Err(match error {
6715                            Ok(value) => common::Error::BadRequest(value),
6716                            _ => common::Error::Failure(response),
6717                        });
6718                    }
6719                    let response = {
6720                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6721                        let encoded = common::to_string(&bytes);
6722                        match serde_json::from_str(&encoded) {
6723                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6724                            Err(error) => {
6725                                dlg.response_json_decode_error(&encoded, &error);
6726                                return Err(common::Error::JsonDecodeError(
6727                                    encoded.to_string(),
6728                                    error,
6729                                ));
6730                            }
6731                        }
6732                    };
6733
6734                    dlg.finished(true);
6735                    return Ok(response);
6736                }
6737            }
6738        }
6739    }
6740
6741    ///
6742    /// Sets the *request* property to the given value.
6743    ///
6744    /// Even though the property as already been set when instantiating this call,
6745    /// we provide this method for API completeness.
6746    pub fn request(
6747        mut self,
6748        new_value: BatchAnnotateImagesRequest,
6749    ) -> ProjectImageAnnotateCall<'a, C> {
6750        self._request = new_value;
6751        self
6752    }
6753    /// Optional. Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no parent is specified, a region will be chosen automatically. Supported location-ids: `us`: USA country only, `asia`: East asia areas, like Japan, Taiwan, `eu`: The European Union. Example: `projects/project-A/locations/eu`.
6754    ///
6755    /// Sets the *parent* path property to the given value.
6756    ///
6757    /// Even though the property as already been set when instantiating this call,
6758    /// we provide this method for API completeness.
6759    pub fn parent(mut self, new_value: &str) -> ProjectImageAnnotateCall<'a, C> {
6760        self._parent = new_value.to_string();
6761        self
6762    }
6763    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6764    /// while executing the actual API request.
6765    ///
6766    /// ````text
6767    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6768    /// ````
6769    ///
6770    /// Sets the *delegate* property to the given value.
6771    pub fn delegate(
6772        mut self,
6773        new_value: &'a mut dyn common::Delegate,
6774    ) -> ProjectImageAnnotateCall<'a, C> {
6775        self._delegate = Some(new_value);
6776        self
6777    }
6778
6779    /// Set any additional parameter of the query string used in the request.
6780    /// It should be used to set parameters which are not yet available through their own
6781    /// setters.
6782    ///
6783    /// Please note that this method must not be used to set any of the known parameters
6784    /// which have their own setter method. If done anyway, the request will fail.
6785    ///
6786    /// # Additional Parameters
6787    ///
6788    /// * *$.xgafv* (query-string) - V1 error format.
6789    /// * *access_token* (query-string) - OAuth access token.
6790    /// * *alt* (query-string) - Data format for response.
6791    /// * *callback* (query-string) - JSONP
6792    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6793    /// * *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.
6794    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6795    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6796    /// * *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.
6797    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6798    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6799    pub fn param<T>(mut self, name: T, value: T) -> ProjectImageAnnotateCall<'a, C>
6800    where
6801        T: AsRef<str>,
6802    {
6803        self._additional_params
6804            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6805        self
6806    }
6807
6808    /// Identifies the authorization scope for the method you are building.
6809    ///
6810    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6811    /// [`Scope::CloudPlatform`].
6812    ///
6813    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6814    /// tokens for more than one scope.
6815    ///
6816    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6817    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6818    /// sufficient, a read-write scope will do as well.
6819    pub fn add_scope<St>(mut self, scope: St) -> ProjectImageAnnotateCall<'a, C>
6820    where
6821        St: AsRef<str>,
6822    {
6823        self._scopes.insert(String::from(scope.as_ref()));
6824        self
6825    }
6826    /// Identifies the authorization scope(s) for the method you are building.
6827    ///
6828    /// See [`Self::add_scope()`] for details.
6829    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectImageAnnotateCall<'a, C>
6830    where
6831        I: IntoIterator<Item = St>,
6832        St: AsRef<str>,
6833    {
6834        self._scopes
6835            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6836        self
6837    }
6838
6839    /// Removes all scopes, and no default scope will be used either.
6840    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6841    /// for details).
6842    pub fn clear_scopes(mut self) -> ProjectImageAnnotateCall<'a, C> {
6843        self._scopes.clear();
6844        self
6845    }
6846}
6847
6848/// Run asynchronous image detection and annotation for a list of images. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). This service will write image annotation outputs to json files in customer GCS bucket, each json file containing BatchAnnotateImagesResponse proto.
6849///
6850/// A builder for the *images.asyncBatchAnnotate* method supported by a *project* resource.
6851/// It is not used directly, but through a [`ProjectMethods`] instance.
6852///
6853/// # Example
6854///
6855/// Instantiate a resource method builder
6856///
6857/// ```test_harness,no_run
6858/// # extern crate hyper;
6859/// # extern crate hyper_rustls;
6860/// # extern crate google_vision1 as vision1;
6861/// use vision1::api::AsyncBatchAnnotateImagesRequest;
6862/// # async fn dox() {
6863/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6864///
6865/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6866/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6867/// #     .with_native_roots()
6868/// #     .unwrap()
6869/// #     .https_only()
6870/// #     .enable_http2()
6871/// #     .build();
6872///
6873/// # let executor = hyper_util::rt::TokioExecutor::new();
6874/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6875/// #     secret,
6876/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6877/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6878/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6879/// #     ),
6880/// # ).build().await.unwrap();
6881///
6882/// # let client = hyper_util::client::legacy::Client::builder(
6883/// #     hyper_util::rt::TokioExecutor::new()
6884/// # )
6885/// # .build(
6886/// #     hyper_rustls::HttpsConnectorBuilder::new()
6887/// #         .with_native_roots()
6888/// #         .unwrap()
6889/// #         .https_or_http()
6890/// #         .enable_http2()
6891/// #         .build()
6892/// # );
6893/// # let mut hub = Vision::new(client, auth);
6894/// // As the method needs a request, you would usually fill it with the desired information
6895/// // into the respective structure. Some of the parts shown here might not be applicable !
6896/// // Values shown here are possibly random and not representative !
6897/// let mut req = AsyncBatchAnnotateImagesRequest::default();
6898///
6899/// // You can configure optional parameters by calling the respective setters at will, and
6900/// // execute the final call using `doit()`.
6901/// // Values shown here are possibly random and not representative !
6902/// let result = hub.projects().images_async_batch_annotate(req, "parent")
6903///              .doit().await;
6904/// # }
6905/// ```
6906pub struct ProjectImageAsyncBatchAnnotateCall<'a, C>
6907where
6908    C: 'a,
6909{
6910    hub: &'a Vision<C>,
6911    _request: AsyncBatchAnnotateImagesRequest,
6912    _parent: String,
6913    _delegate: Option<&'a mut dyn common::Delegate>,
6914    _additional_params: HashMap<String, String>,
6915    _scopes: BTreeSet<String>,
6916}
6917
6918impl<'a, C> common::CallBuilder for ProjectImageAsyncBatchAnnotateCall<'a, C> {}
6919
6920impl<'a, C> ProjectImageAsyncBatchAnnotateCall<'a, C>
6921where
6922    C: common::Connector,
6923{
6924    /// Perform the operation you have build so far.
6925    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6926        use std::borrow::Cow;
6927        use std::io::{Read, Seek};
6928
6929        use common::{url::Params, ToParts};
6930        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6931
6932        let mut dd = common::DefaultDelegate;
6933        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6934        dlg.begin(common::MethodInfo {
6935            id: "vision.projects.images.asyncBatchAnnotate",
6936            http_method: hyper::Method::POST,
6937        });
6938
6939        for &field in ["alt", "parent"].iter() {
6940            if self._additional_params.contains_key(field) {
6941                dlg.finished(false);
6942                return Err(common::Error::FieldClash(field));
6943            }
6944        }
6945
6946        let mut params = Params::with_capacity(4 + self._additional_params.len());
6947        params.push("parent", self._parent);
6948
6949        params.extend(self._additional_params.iter());
6950
6951        params.push("alt", "json");
6952        let mut url = self.hub._base_url.clone() + "v1/{+parent}/images:asyncBatchAnnotate";
6953        if self._scopes.is_empty() {
6954            self._scopes
6955                .insert(Scope::CloudPlatform.as_ref().to_string());
6956        }
6957
6958        #[allow(clippy::single_element_loop)]
6959        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6960            url = params.uri_replacement(url, param_name, find_this, true);
6961        }
6962        {
6963            let to_remove = ["parent"];
6964            params.remove_params(&to_remove);
6965        }
6966
6967        let url = params.parse_with_url(&url);
6968
6969        let mut json_mime_type = mime::APPLICATION_JSON;
6970        let mut request_value_reader = {
6971            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6972            common::remove_json_null_values(&mut value);
6973            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6974            serde_json::to_writer(&mut dst, &value).unwrap();
6975            dst
6976        };
6977        let request_size = request_value_reader
6978            .seek(std::io::SeekFrom::End(0))
6979            .unwrap();
6980        request_value_reader
6981            .seek(std::io::SeekFrom::Start(0))
6982            .unwrap();
6983
6984        loop {
6985            let token = match self
6986                .hub
6987                .auth
6988                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6989                .await
6990            {
6991                Ok(token) => token,
6992                Err(e) => match dlg.token(e) {
6993                    Ok(token) => token,
6994                    Err(e) => {
6995                        dlg.finished(false);
6996                        return Err(common::Error::MissingToken(e));
6997                    }
6998                },
6999            };
7000            request_value_reader
7001                .seek(std::io::SeekFrom::Start(0))
7002                .unwrap();
7003            let mut req_result = {
7004                let client = &self.hub.client;
7005                dlg.pre_request();
7006                let mut req_builder = hyper::Request::builder()
7007                    .method(hyper::Method::POST)
7008                    .uri(url.as_str())
7009                    .header(USER_AGENT, self.hub._user_agent.clone());
7010
7011                if let Some(token) = token.as_ref() {
7012                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7013                }
7014
7015                let request = req_builder
7016                    .header(CONTENT_TYPE, json_mime_type.to_string())
7017                    .header(CONTENT_LENGTH, request_size as u64)
7018                    .body(common::to_body(
7019                        request_value_reader.get_ref().clone().into(),
7020                    ));
7021
7022                client.request(request.unwrap()).await
7023            };
7024
7025            match req_result {
7026                Err(err) => {
7027                    if let common::Retry::After(d) = dlg.http_error(&err) {
7028                        sleep(d).await;
7029                        continue;
7030                    }
7031                    dlg.finished(false);
7032                    return Err(common::Error::HttpError(err));
7033                }
7034                Ok(res) => {
7035                    let (mut parts, body) = res.into_parts();
7036                    let mut body = common::Body::new(body);
7037                    if !parts.status.is_success() {
7038                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7039                        let error = serde_json::from_str(&common::to_string(&bytes));
7040                        let response = common::to_response(parts, bytes.into());
7041
7042                        if let common::Retry::After(d) =
7043                            dlg.http_failure(&response, error.as_ref().ok())
7044                        {
7045                            sleep(d).await;
7046                            continue;
7047                        }
7048
7049                        dlg.finished(false);
7050
7051                        return Err(match error {
7052                            Ok(value) => common::Error::BadRequest(value),
7053                            _ => common::Error::Failure(response),
7054                        });
7055                    }
7056                    let response = {
7057                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7058                        let encoded = common::to_string(&bytes);
7059                        match serde_json::from_str(&encoded) {
7060                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7061                            Err(error) => {
7062                                dlg.response_json_decode_error(&encoded, &error);
7063                                return Err(common::Error::JsonDecodeError(
7064                                    encoded.to_string(),
7065                                    error,
7066                                ));
7067                            }
7068                        }
7069                    };
7070
7071                    dlg.finished(true);
7072                    return Ok(response);
7073                }
7074            }
7075        }
7076    }
7077
7078    ///
7079    /// Sets the *request* property to the given value.
7080    ///
7081    /// Even though the property as already been set when instantiating this call,
7082    /// we provide this method for API completeness.
7083    pub fn request(
7084        mut self,
7085        new_value: AsyncBatchAnnotateImagesRequest,
7086    ) -> ProjectImageAsyncBatchAnnotateCall<'a, C> {
7087        self._request = new_value;
7088        self
7089    }
7090    /// Optional. Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no parent is specified, a region will be chosen automatically. Supported location-ids: `us`: USA country only, `asia`: East asia areas, like Japan, Taiwan, `eu`: The European Union. Example: `projects/project-A/locations/eu`.
7091    ///
7092    /// Sets the *parent* path property to the given value.
7093    ///
7094    /// Even though the property as already been set when instantiating this call,
7095    /// we provide this method for API completeness.
7096    pub fn parent(mut self, new_value: &str) -> ProjectImageAsyncBatchAnnotateCall<'a, C> {
7097        self._parent = new_value.to_string();
7098        self
7099    }
7100    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7101    /// while executing the actual API request.
7102    ///
7103    /// ````text
7104    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7105    /// ````
7106    ///
7107    /// Sets the *delegate* property to the given value.
7108    pub fn delegate(
7109        mut self,
7110        new_value: &'a mut dyn common::Delegate,
7111    ) -> ProjectImageAsyncBatchAnnotateCall<'a, C> {
7112        self._delegate = Some(new_value);
7113        self
7114    }
7115
7116    /// Set any additional parameter of the query string used in the request.
7117    /// It should be used to set parameters which are not yet available through their own
7118    /// setters.
7119    ///
7120    /// Please note that this method must not be used to set any of the known parameters
7121    /// which have their own setter method. If done anyway, the request will fail.
7122    ///
7123    /// # Additional Parameters
7124    ///
7125    /// * *$.xgafv* (query-string) - V1 error format.
7126    /// * *access_token* (query-string) - OAuth access token.
7127    /// * *alt* (query-string) - Data format for response.
7128    /// * *callback* (query-string) - JSONP
7129    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7130    /// * *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.
7131    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7132    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7133    /// * *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.
7134    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7135    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7136    pub fn param<T>(mut self, name: T, value: T) -> ProjectImageAsyncBatchAnnotateCall<'a, C>
7137    where
7138        T: AsRef<str>,
7139    {
7140        self._additional_params
7141            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7142        self
7143    }
7144
7145    /// Identifies the authorization scope for the method you are building.
7146    ///
7147    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7148    /// [`Scope::CloudPlatform`].
7149    ///
7150    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7151    /// tokens for more than one scope.
7152    ///
7153    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7154    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7155    /// sufficient, a read-write scope will do as well.
7156    pub fn add_scope<St>(mut self, scope: St) -> ProjectImageAsyncBatchAnnotateCall<'a, C>
7157    where
7158        St: AsRef<str>,
7159    {
7160        self._scopes.insert(String::from(scope.as_ref()));
7161        self
7162    }
7163    /// Identifies the authorization scope(s) for the method you are building.
7164    ///
7165    /// See [`Self::add_scope()`] for details.
7166    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectImageAsyncBatchAnnotateCall<'a, C>
7167    where
7168        I: IntoIterator<Item = St>,
7169        St: AsRef<str>,
7170    {
7171        self._scopes
7172            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7173        self
7174    }
7175
7176    /// Removes all scopes, and no default scope will be used either.
7177    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7178    /// for details).
7179    pub fn clear_scopes(mut self) -> ProjectImageAsyncBatchAnnotateCall<'a, C> {
7180        self._scopes.clear();
7181        self
7182    }
7183}
7184
7185/// Service that performs image detection and annotation for a batch of files. Now only "application/pdf", "image/tiff" and "image/gif" are supported. This service will extract at most 5 (customers can specify which 5 in AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each file provided and perform detection and annotation for each image extracted.
7186///
7187/// A builder for the *locations.files.annotate* method supported by a *project* resource.
7188/// It is not used directly, but through a [`ProjectMethods`] instance.
7189///
7190/// # Example
7191///
7192/// Instantiate a resource method builder
7193///
7194/// ```test_harness,no_run
7195/// # extern crate hyper;
7196/// # extern crate hyper_rustls;
7197/// # extern crate google_vision1 as vision1;
7198/// use vision1::api::BatchAnnotateFilesRequest;
7199/// # async fn dox() {
7200/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7201///
7202/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7203/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7204/// #     .with_native_roots()
7205/// #     .unwrap()
7206/// #     .https_only()
7207/// #     .enable_http2()
7208/// #     .build();
7209///
7210/// # let executor = hyper_util::rt::TokioExecutor::new();
7211/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7212/// #     secret,
7213/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7214/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7215/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7216/// #     ),
7217/// # ).build().await.unwrap();
7218///
7219/// # let client = hyper_util::client::legacy::Client::builder(
7220/// #     hyper_util::rt::TokioExecutor::new()
7221/// # )
7222/// # .build(
7223/// #     hyper_rustls::HttpsConnectorBuilder::new()
7224/// #         .with_native_roots()
7225/// #         .unwrap()
7226/// #         .https_or_http()
7227/// #         .enable_http2()
7228/// #         .build()
7229/// # );
7230/// # let mut hub = Vision::new(client, auth);
7231/// // As the method needs a request, you would usually fill it with the desired information
7232/// // into the respective structure. Some of the parts shown here might not be applicable !
7233/// // Values shown here are possibly random and not representative !
7234/// let mut req = BatchAnnotateFilesRequest::default();
7235///
7236/// // You can configure optional parameters by calling the respective setters at will, and
7237/// // execute the final call using `doit()`.
7238/// // Values shown here are possibly random and not representative !
7239/// let result = hub.projects().locations_files_annotate(req, "parent")
7240///              .doit().await;
7241/// # }
7242/// ```
7243pub struct ProjectLocationFileAnnotateCall<'a, C>
7244where
7245    C: 'a,
7246{
7247    hub: &'a Vision<C>,
7248    _request: BatchAnnotateFilesRequest,
7249    _parent: String,
7250    _delegate: Option<&'a mut dyn common::Delegate>,
7251    _additional_params: HashMap<String, String>,
7252    _scopes: BTreeSet<String>,
7253}
7254
7255impl<'a, C> common::CallBuilder for ProjectLocationFileAnnotateCall<'a, C> {}
7256
7257impl<'a, C> ProjectLocationFileAnnotateCall<'a, C>
7258where
7259    C: common::Connector,
7260{
7261    /// Perform the operation you have build so far.
7262    pub async fn doit(mut self) -> common::Result<(common::Response, BatchAnnotateFilesResponse)> {
7263        use std::borrow::Cow;
7264        use std::io::{Read, Seek};
7265
7266        use common::{url::Params, ToParts};
7267        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7268
7269        let mut dd = common::DefaultDelegate;
7270        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7271        dlg.begin(common::MethodInfo {
7272            id: "vision.projects.locations.files.annotate",
7273            http_method: hyper::Method::POST,
7274        });
7275
7276        for &field in ["alt", "parent"].iter() {
7277            if self._additional_params.contains_key(field) {
7278                dlg.finished(false);
7279                return Err(common::Error::FieldClash(field));
7280            }
7281        }
7282
7283        let mut params = Params::with_capacity(4 + self._additional_params.len());
7284        params.push("parent", self._parent);
7285
7286        params.extend(self._additional_params.iter());
7287
7288        params.push("alt", "json");
7289        let mut url = self.hub._base_url.clone() + "v1/{+parent}/files:annotate";
7290        if self._scopes.is_empty() {
7291            self._scopes
7292                .insert(Scope::CloudPlatform.as_ref().to_string());
7293        }
7294
7295        #[allow(clippy::single_element_loop)]
7296        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7297            url = params.uri_replacement(url, param_name, find_this, true);
7298        }
7299        {
7300            let to_remove = ["parent"];
7301            params.remove_params(&to_remove);
7302        }
7303
7304        let url = params.parse_with_url(&url);
7305
7306        let mut json_mime_type = mime::APPLICATION_JSON;
7307        let mut request_value_reader = {
7308            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7309            common::remove_json_null_values(&mut value);
7310            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7311            serde_json::to_writer(&mut dst, &value).unwrap();
7312            dst
7313        };
7314        let request_size = request_value_reader
7315            .seek(std::io::SeekFrom::End(0))
7316            .unwrap();
7317        request_value_reader
7318            .seek(std::io::SeekFrom::Start(0))
7319            .unwrap();
7320
7321        loop {
7322            let token = match self
7323                .hub
7324                .auth
7325                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7326                .await
7327            {
7328                Ok(token) => token,
7329                Err(e) => match dlg.token(e) {
7330                    Ok(token) => token,
7331                    Err(e) => {
7332                        dlg.finished(false);
7333                        return Err(common::Error::MissingToken(e));
7334                    }
7335                },
7336            };
7337            request_value_reader
7338                .seek(std::io::SeekFrom::Start(0))
7339                .unwrap();
7340            let mut req_result = {
7341                let client = &self.hub.client;
7342                dlg.pre_request();
7343                let mut req_builder = hyper::Request::builder()
7344                    .method(hyper::Method::POST)
7345                    .uri(url.as_str())
7346                    .header(USER_AGENT, self.hub._user_agent.clone());
7347
7348                if let Some(token) = token.as_ref() {
7349                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7350                }
7351
7352                let request = req_builder
7353                    .header(CONTENT_TYPE, json_mime_type.to_string())
7354                    .header(CONTENT_LENGTH, request_size as u64)
7355                    .body(common::to_body(
7356                        request_value_reader.get_ref().clone().into(),
7357                    ));
7358
7359                client.request(request.unwrap()).await
7360            };
7361
7362            match req_result {
7363                Err(err) => {
7364                    if let common::Retry::After(d) = dlg.http_error(&err) {
7365                        sleep(d).await;
7366                        continue;
7367                    }
7368                    dlg.finished(false);
7369                    return Err(common::Error::HttpError(err));
7370                }
7371                Ok(res) => {
7372                    let (mut parts, body) = res.into_parts();
7373                    let mut body = common::Body::new(body);
7374                    if !parts.status.is_success() {
7375                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7376                        let error = serde_json::from_str(&common::to_string(&bytes));
7377                        let response = common::to_response(parts, bytes.into());
7378
7379                        if let common::Retry::After(d) =
7380                            dlg.http_failure(&response, error.as_ref().ok())
7381                        {
7382                            sleep(d).await;
7383                            continue;
7384                        }
7385
7386                        dlg.finished(false);
7387
7388                        return Err(match error {
7389                            Ok(value) => common::Error::BadRequest(value),
7390                            _ => common::Error::Failure(response),
7391                        });
7392                    }
7393                    let response = {
7394                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7395                        let encoded = common::to_string(&bytes);
7396                        match serde_json::from_str(&encoded) {
7397                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7398                            Err(error) => {
7399                                dlg.response_json_decode_error(&encoded, &error);
7400                                return Err(common::Error::JsonDecodeError(
7401                                    encoded.to_string(),
7402                                    error,
7403                                ));
7404                            }
7405                        }
7406                    };
7407
7408                    dlg.finished(true);
7409                    return Ok(response);
7410                }
7411            }
7412        }
7413    }
7414
7415    ///
7416    /// Sets the *request* property to the given value.
7417    ///
7418    /// Even though the property as already been set when instantiating this call,
7419    /// we provide this method for API completeness.
7420    pub fn request(
7421        mut self,
7422        new_value: BatchAnnotateFilesRequest,
7423    ) -> ProjectLocationFileAnnotateCall<'a, C> {
7424        self._request = new_value;
7425        self
7426    }
7427    /// Optional. Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no parent is specified, a region will be chosen automatically. Supported location-ids: `us`: USA country only, `asia`: East asia areas, like Japan, Taiwan, `eu`: The European Union. Example: `projects/project-A/locations/eu`.
7428    ///
7429    /// Sets the *parent* path property to the given value.
7430    ///
7431    /// Even though the property as already been set when instantiating this call,
7432    /// we provide this method for API completeness.
7433    pub fn parent(mut self, new_value: &str) -> ProjectLocationFileAnnotateCall<'a, C> {
7434        self._parent = new_value.to_string();
7435        self
7436    }
7437    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7438    /// while executing the actual API request.
7439    ///
7440    /// ````text
7441    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7442    /// ````
7443    ///
7444    /// Sets the *delegate* property to the given value.
7445    pub fn delegate(
7446        mut self,
7447        new_value: &'a mut dyn common::Delegate,
7448    ) -> ProjectLocationFileAnnotateCall<'a, C> {
7449        self._delegate = Some(new_value);
7450        self
7451    }
7452
7453    /// Set any additional parameter of the query string used in the request.
7454    /// It should be used to set parameters which are not yet available through their own
7455    /// setters.
7456    ///
7457    /// Please note that this method must not be used to set any of the known parameters
7458    /// which have their own setter method. If done anyway, the request will fail.
7459    ///
7460    /// # Additional Parameters
7461    ///
7462    /// * *$.xgafv* (query-string) - V1 error format.
7463    /// * *access_token* (query-string) - OAuth access token.
7464    /// * *alt* (query-string) - Data format for response.
7465    /// * *callback* (query-string) - JSONP
7466    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7467    /// * *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.
7468    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7469    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7470    /// * *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.
7471    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7472    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7473    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationFileAnnotateCall<'a, C>
7474    where
7475        T: AsRef<str>,
7476    {
7477        self._additional_params
7478            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7479        self
7480    }
7481
7482    /// Identifies the authorization scope for the method you are building.
7483    ///
7484    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7485    /// [`Scope::CloudPlatform`].
7486    ///
7487    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7488    /// tokens for more than one scope.
7489    ///
7490    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7491    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7492    /// sufficient, a read-write scope will do as well.
7493    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationFileAnnotateCall<'a, C>
7494    where
7495        St: AsRef<str>,
7496    {
7497        self._scopes.insert(String::from(scope.as_ref()));
7498        self
7499    }
7500    /// Identifies the authorization scope(s) for the method you are building.
7501    ///
7502    /// See [`Self::add_scope()`] for details.
7503    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationFileAnnotateCall<'a, C>
7504    where
7505        I: IntoIterator<Item = St>,
7506        St: AsRef<str>,
7507    {
7508        self._scopes
7509            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7510        self
7511    }
7512
7513    /// Removes all scopes, and no default scope will be used either.
7514    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7515    /// for details).
7516    pub fn clear_scopes(mut self) -> ProjectLocationFileAnnotateCall<'a, C> {
7517        self._scopes.clear();
7518        self
7519    }
7520}
7521
7522/// Run asynchronous image detection and annotation for a list of generic files, such as PDF files, which may contain multiple pages and multiple images per page. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).
7523///
7524/// A builder for the *locations.files.asyncBatchAnnotate* method supported by a *project* resource.
7525/// It is not used directly, but through a [`ProjectMethods`] instance.
7526///
7527/// # Example
7528///
7529/// Instantiate a resource method builder
7530///
7531/// ```test_harness,no_run
7532/// # extern crate hyper;
7533/// # extern crate hyper_rustls;
7534/// # extern crate google_vision1 as vision1;
7535/// use vision1::api::AsyncBatchAnnotateFilesRequest;
7536/// # async fn dox() {
7537/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7538///
7539/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7540/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7541/// #     .with_native_roots()
7542/// #     .unwrap()
7543/// #     .https_only()
7544/// #     .enable_http2()
7545/// #     .build();
7546///
7547/// # let executor = hyper_util::rt::TokioExecutor::new();
7548/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7549/// #     secret,
7550/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7551/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7552/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7553/// #     ),
7554/// # ).build().await.unwrap();
7555///
7556/// # let client = hyper_util::client::legacy::Client::builder(
7557/// #     hyper_util::rt::TokioExecutor::new()
7558/// # )
7559/// # .build(
7560/// #     hyper_rustls::HttpsConnectorBuilder::new()
7561/// #         .with_native_roots()
7562/// #         .unwrap()
7563/// #         .https_or_http()
7564/// #         .enable_http2()
7565/// #         .build()
7566/// # );
7567/// # let mut hub = Vision::new(client, auth);
7568/// // As the method needs a request, you would usually fill it with the desired information
7569/// // into the respective structure. Some of the parts shown here might not be applicable !
7570/// // Values shown here are possibly random and not representative !
7571/// let mut req = AsyncBatchAnnotateFilesRequest::default();
7572///
7573/// // You can configure optional parameters by calling the respective setters at will, and
7574/// // execute the final call using `doit()`.
7575/// // Values shown here are possibly random and not representative !
7576/// let result = hub.projects().locations_files_async_batch_annotate(req, "parent")
7577///              .doit().await;
7578/// # }
7579/// ```
7580pub struct ProjectLocationFileAsyncBatchAnnotateCall<'a, C>
7581where
7582    C: 'a,
7583{
7584    hub: &'a Vision<C>,
7585    _request: AsyncBatchAnnotateFilesRequest,
7586    _parent: String,
7587    _delegate: Option<&'a mut dyn common::Delegate>,
7588    _additional_params: HashMap<String, String>,
7589    _scopes: BTreeSet<String>,
7590}
7591
7592impl<'a, C> common::CallBuilder for ProjectLocationFileAsyncBatchAnnotateCall<'a, C> {}
7593
7594impl<'a, C> ProjectLocationFileAsyncBatchAnnotateCall<'a, C>
7595where
7596    C: common::Connector,
7597{
7598    /// Perform the operation you have build so far.
7599    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
7600        use std::borrow::Cow;
7601        use std::io::{Read, Seek};
7602
7603        use common::{url::Params, ToParts};
7604        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7605
7606        let mut dd = common::DefaultDelegate;
7607        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7608        dlg.begin(common::MethodInfo {
7609            id: "vision.projects.locations.files.asyncBatchAnnotate",
7610            http_method: hyper::Method::POST,
7611        });
7612
7613        for &field in ["alt", "parent"].iter() {
7614            if self._additional_params.contains_key(field) {
7615                dlg.finished(false);
7616                return Err(common::Error::FieldClash(field));
7617            }
7618        }
7619
7620        let mut params = Params::with_capacity(4 + self._additional_params.len());
7621        params.push("parent", self._parent);
7622
7623        params.extend(self._additional_params.iter());
7624
7625        params.push("alt", "json");
7626        let mut url = self.hub._base_url.clone() + "v1/{+parent}/files:asyncBatchAnnotate";
7627        if self._scopes.is_empty() {
7628            self._scopes
7629                .insert(Scope::CloudPlatform.as_ref().to_string());
7630        }
7631
7632        #[allow(clippy::single_element_loop)]
7633        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7634            url = params.uri_replacement(url, param_name, find_this, true);
7635        }
7636        {
7637            let to_remove = ["parent"];
7638            params.remove_params(&to_remove);
7639        }
7640
7641        let url = params.parse_with_url(&url);
7642
7643        let mut json_mime_type = mime::APPLICATION_JSON;
7644        let mut request_value_reader = {
7645            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7646            common::remove_json_null_values(&mut value);
7647            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7648            serde_json::to_writer(&mut dst, &value).unwrap();
7649            dst
7650        };
7651        let request_size = request_value_reader
7652            .seek(std::io::SeekFrom::End(0))
7653            .unwrap();
7654        request_value_reader
7655            .seek(std::io::SeekFrom::Start(0))
7656            .unwrap();
7657
7658        loop {
7659            let token = match self
7660                .hub
7661                .auth
7662                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7663                .await
7664            {
7665                Ok(token) => token,
7666                Err(e) => match dlg.token(e) {
7667                    Ok(token) => token,
7668                    Err(e) => {
7669                        dlg.finished(false);
7670                        return Err(common::Error::MissingToken(e));
7671                    }
7672                },
7673            };
7674            request_value_reader
7675                .seek(std::io::SeekFrom::Start(0))
7676                .unwrap();
7677            let mut req_result = {
7678                let client = &self.hub.client;
7679                dlg.pre_request();
7680                let mut req_builder = hyper::Request::builder()
7681                    .method(hyper::Method::POST)
7682                    .uri(url.as_str())
7683                    .header(USER_AGENT, self.hub._user_agent.clone());
7684
7685                if let Some(token) = token.as_ref() {
7686                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7687                }
7688
7689                let request = req_builder
7690                    .header(CONTENT_TYPE, json_mime_type.to_string())
7691                    .header(CONTENT_LENGTH, request_size as u64)
7692                    .body(common::to_body(
7693                        request_value_reader.get_ref().clone().into(),
7694                    ));
7695
7696                client.request(request.unwrap()).await
7697            };
7698
7699            match req_result {
7700                Err(err) => {
7701                    if let common::Retry::After(d) = dlg.http_error(&err) {
7702                        sleep(d).await;
7703                        continue;
7704                    }
7705                    dlg.finished(false);
7706                    return Err(common::Error::HttpError(err));
7707                }
7708                Ok(res) => {
7709                    let (mut parts, body) = res.into_parts();
7710                    let mut body = common::Body::new(body);
7711                    if !parts.status.is_success() {
7712                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7713                        let error = serde_json::from_str(&common::to_string(&bytes));
7714                        let response = common::to_response(parts, bytes.into());
7715
7716                        if let common::Retry::After(d) =
7717                            dlg.http_failure(&response, error.as_ref().ok())
7718                        {
7719                            sleep(d).await;
7720                            continue;
7721                        }
7722
7723                        dlg.finished(false);
7724
7725                        return Err(match error {
7726                            Ok(value) => common::Error::BadRequest(value),
7727                            _ => common::Error::Failure(response),
7728                        });
7729                    }
7730                    let response = {
7731                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7732                        let encoded = common::to_string(&bytes);
7733                        match serde_json::from_str(&encoded) {
7734                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7735                            Err(error) => {
7736                                dlg.response_json_decode_error(&encoded, &error);
7737                                return Err(common::Error::JsonDecodeError(
7738                                    encoded.to_string(),
7739                                    error,
7740                                ));
7741                            }
7742                        }
7743                    };
7744
7745                    dlg.finished(true);
7746                    return Ok(response);
7747                }
7748            }
7749        }
7750    }
7751
7752    ///
7753    /// Sets the *request* property to the given value.
7754    ///
7755    /// Even though the property as already been set when instantiating this call,
7756    /// we provide this method for API completeness.
7757    pub fn request(
7758        mut self,
7759        new_value: AsyncBatchAnnotateFilesRequest,
7760    ) -> ProjectLocationFileAsyncBatchAnnotateCall<'a, C> {
7761        self._request = new_value;
7762        self
7763    }
7764    /// Optional. Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no parent is specified, a region will be chosen automatically. Supported location-ids: `us`: USA country only, `asia`: East asia areas, like Japan, Taiwan, `eu`: The European Union. Example: `projects/project-A/locations/eu`.
7765    ///
7766    /// Sets the *parent* path property to the given value.
7767    ///
7768    /// Even though the property as already been set when instantiating this call,
7769    /// we provide this method for API completeness.
7770    pub fn parent(mut self, new_value: &str) -> ProjectLocationFileAsyncBatchAnnotateCall<'a, C> {
7771        self._parent = new_value.to_string();
7772        self
7773    }
7774    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7775    /// while executing the actual API request.
7776    ///
7777    /// ````text
7778    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7779    /// ````
7780    ///
7781    /// Sets the *delegate* property to the given value.
7782    pub fn delegate(
7783        mut self,
7784        new_value: &'a mut dyn common::Delegate,
7785    ) -> ProjectLocationFileAsyncBatchAnnotateCall<'a, C> {
7786        self._delegate = Some(new_value);
7787        self
7788    }
7789
7790    /// Set any additional parameter of the query string used in the request.
7791    /// It should be used to set parameters which are not yet available through their own
7792    /// setters.
7793    ///
7794    /// Please note that this method must not be used to set any of the known parameters
7795    /// which have their own setter method. If done anyway, the request will fail.
7796    ///
7797    /// # Additional Parameters
7798    ///
7799    /// * *$.xgafv* (query-string) - V1 error format.
7800    /// * *access_token* (query-string) - OAuth access token.
7801    /// * *alt* (query-string) - Data format for response.
7802    /// * *callback* (query-string) - JSONP
7803    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7804    /// * *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.
7805    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7806    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7807    /// * *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.
7808    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7809    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7810    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationFileAsyncBatchAnnotateCall<'a, C>
7811    where
7812        T: AsRef<str>,
7813    {
7814        self._additional_params
7815            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7816        self
7817    }
7818
7819    /// Identifies the authorization scope for the method you are building.
7820    ///
7821    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7822    /// [`Scope::CloudPlatform`].
7823    ///
7824    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7825    /// tokens for more than one scope.
7826    ///
7827    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7828    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7829    /// sufficient, a read-write scope will do as well.
7830    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationFileAsyncBatchAnnotateCall<'a, C>
7831    where
7832        St: AsRef<str>,
7833    {
7834        self._scopes.insert(String::from(scope.as_ref()));
7835        self
7836    }
7837    /// Identifies the authorization scope(s) for the method you are building.
7838    ///
7839    /// See [`Self::add_scope()`] for details.
7840    pub fn add_scopes<I, St>(
7841        mut self,
7842        scopes: I,
7843    ) -> ProjectLocationFileAsyncBatchAnnotateCall<'a, C>
7844    where
7845        I: IntoIterator<Item = St>,
7846        St: AsRef<str>,
7847    {
7848        self._scopes
7849            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7850        self
7851    }
7852
7853    /// Removes all scopes, and no default scope will be used either.
7854    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7855    /// for details).
7856    pub fn clear_scopes(mut self) -> ProjectLocationFileAsyncBatchAnnotateCall<'a, C> {
7857        self._scopes.clear();
7858        self
7859    }
7860}
7861
7862/// Run image detection and annotation for a batch of images.
7863///
7864/// A builder for the *locations.images.annotate* method supported by a *project* resource.
7865/// It is not used directly, but through a [`ProjectMethods`] instance.
7866///
7867/// # Example
7868///
7869/// Instantiate a resource method builder
7870///
7871/// ```test_harness,no_run
7872/// # extern crate hyper;
7873/// # extern crate hyper_rustls;
7874/// # extern crate google_vision1 as vision1;
7875/// use vision1::api::BatchAnnotateImagesRequest;
7876/// # async fn dox() {
7877/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7878///
7879/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7880/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7881/// #     .with_native_roots()
7882/// #     .unwrap()
7883/// #     .https_only()
7884/// #     .enable_http2()
7885/// #     .build();
7886///
7887/// # let executor = hyper_util::rt::TokioExecutor::new();
7888/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7889/// #     secret,
7890/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7891/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7892/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7893/// #     ),
7894/// # ).build().await.unwrap();
7895///
7896/// # let client = hyper_util::client::legacy::Client::builder(
7897/// #     hyper_util::rt::TokioExecutor::new()
7898/// # )
7899/// # .build(
7900/// #     hyper_rustls::HttpsConnectorBuilder::new()
7901/// #         .with_native_roots()
7902/// #         .unwrap()
7903/// #         .https_or_http()
7904/// #         .enable_http2()
7905/// #         .build()
7906/// # );
7907/// # let mut hub = Vision::new(client, auth);
7908/// // As the method needs a request, you would usually fill it with the desired information
7909/// // into the respective structure. Some of the parts shown here might not be applicable !
7910/// // Values shown here are possibly random and not representative !
7911/// let mut req = BatchAnnotateImagesRequest::default();
7912///
7913/// // You can configure optional parameters by calling the respective setters at will, and
7914/// // execute the final call using `doit()`.
7915/// // Values shown here are possibly random and not representative !
7916/// let result = hub.projects().locations_images_annotate(req, "parent")
7917///              .doit().await;
7918/// # }
7919/// ```
7920pub struct ProjectLocationImageAnnotateCall<'a, C>
7921where
7922    C: 'a,
7923{
7924    hub: &'a Vision<C>,
7925    _request: BatchAnnotateImagesRequest,
7926    _parent: String,
7927    _delegate: Option<&'a mut dyn common::Delegate>,
7928    _additional_params: HashMap<String, String>,
7929    _scopes: BTreeSet<String>,
7930}
7931
7932impl<'a, C> common::CallBuilder for ProjectLocationImageAnnotateCall<'a, C> {}
7933
7934impl<'a, C> ProjectLocationImageAnnotateCall<'a, C>
7935where
7936    C: common::Connector,
7937{
7938    /// Perform the operation you have build so far.
7939    pub async fn doit(mut self) -> common::Result<(common::Response, BatchAnnotateImagesResponse)> {
7940        use std::borrow::Cow;
7941        use std::io::{Read, Seek};
7942
7943        use common::{url::Params, ToParts};
7944        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7945
7946        let mut dd = common::DefaultDelegate;
7947        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7948        dlg.begin(common::MethodInfo {
7949            id: "vision.projects.locations.images.annotate",
7950            http_method: hyper::Method::POST,
7951        });
7952
7953        for &field in ["alt", "parent"].iter() {
7954            if self._additional_params.contains_key(field) {
7955                dlg.finished(false);
7956                return Err(common::Error::FieldClash(field));
7957            }
7958        }
7959
7960        let mut params = Params::with_capacity(4 + self._additional_params.len());
7961        params.push("parent", self._parent);
7962
7963        params.extend(self._additional_params.iter());
7964
7965        params.push("alt", "json");
7966        let mut url = self.hub._base_url.clone() + "v1/{+parent}/images:annotate";
7967        if self._scopes.is_empty() {
7968            self._scopes
7969                .insert(Scope::CloudPlatform.as_ref().to_string());
7970        }
7971
7972        #[allow(clippy::single_element_loop)]
7973        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7974            url = params.uri_replacement(url, param_name, find_this, true);
7975        }
7976        {
7977            let to_remove = ["parent"];
7978            params.remove_params(&to_remove);
7979        }
7980
7981        let url = params.parse_with_url(&url);
7982
7983        let mut json_mime_type = mime::APPLICATION_JSON;
7984        let mut request_value_reader = {
7985            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7986            common::remove_json_null_values(&mut value);
7987            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7988            serde_json::to_writer(&mut dst, &value).unwrap();
7989            dst
7990        };
7991        let request_size = request_value_reader
7992            .seek(std::io::SeekFrom::End(0))
7993            .unwrap();
7994        request_value_reader
7995            .seek(std::io::SeekFrom::Start(0))
7996            .unwrap();
7997
7998        loop {
7999            let token = match self
8000                .hub
8001                .auth
8002                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8003                .await
8004            {
8005                Ok(token) => token,
8006                Err(e) => match dlg.token(e) {
8007                    Ok(token) => token,
8008                    Err(e) => {
8009                        dlg.finished(false);
8010                        return Err(common::Error::MissingToken(e));
8011                    }
8012                },
8013            };
8014            request_value_reader
8015                .seek(std::io::SeekFrom::Start(0))
8016                .unwrap();
8017            let mut req_result = {
8018                let client = &self.hub.client;
8019                dlg.pre_request();
8020                let mut req_builder = hyper::Request::builder()
8021                    .method(hyper::Method::POST)
8022                    .uri(url.as_str())
8023                    .header(USER_AGENT, self.hub._user_agent.clone());
8024
8025                if let Some(token) = token.as_ref() {
8026                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8027                }
8028
8029                let request = req_builder
8030                    .header(CONTENT_TYPE, json_mime_type.to_string())
8031                    .header(CONTENT_LENGTH, request_size as u64)
8032                    .body(common::to_body(
8033                        request_value_reader.get_ref().clone().into(),
8034                    ));
8035
8036                client.request(request.unwrap()).await
8037            };
8038
8039            match req_result {
8040                Err(err) => {
8041                    if let common::Retry::After(d) = dlg.http_error(&err) {
8042                        sleep(d).await;
8043                        continue;
8044                    }
8045                    dlg.finished(false);
8046                    return Err(common::Error::HttpError(err));
8047                }
8048                Ok(res) => {
8049                    let (mut parts, body) = res.into_parts();
8050                    let mut body = common::Body::new(body);
8051                    if !parts.status.is_success() {
8052                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8053                        let error = serde_json::from_str(&common::to_string(&bytes));
8054                        let response = common::to_response(parts, bytes.into());
8055
8056                        if let common::Retry::After(d) =
8057                            dlg.http_failure(&response, error.as_ref().ok())
8058                        {
8059                            sleep(d).await;
8060                            continue;
8061                        }
8062
8063                        dlg.finished(false);
8064
8065                        return Err(match error {
8066                            Ok(value) => common::Error::BadRequest(value),
8067                            _ => common::Error::Failure(response),
8068                        });
8069                    }
8070                    let response = {
8071                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8072                        let encoded = common::to_string(&bytes);
8073                        match serde_json::from_str(&encoded) {
8074                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8075                            Err(error) => {
8076                                dlg.response_json_decode_error(&encoded, &error);
8077                                return Err(common::Error::JsonDecodeError(
8078                                    encoded.to_string(),
8079                                    error,
8080                                ));
8081                            }
8082                        }
8083                    };
8084
8085                    dlg.finished(true);
8086                    return Ok(response);
8087                }
8088            }
8089        }
8090    }
8091
8092    ///
8093    /// Sets the *request* property to the given value.
8094    ///
8095    /// Even though the property as already been set when instantiating this call,
8096    /// we provide this method for API completeness.
8097    pub fn request(
8098        mut self,
8099        new_value: BatchAnnotateImagesRequest,
8100    ) -> ProjectLocationImageAnnotateCall<'a, C> {
8101        self._request = new_value;
8102        self
8103    }
8104    /// Optional. Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no parent is specified, a region will be chosen automatically. Supported location-ids: `us`: USA country only, `asia`: East asia areas, like Japan, Taiwan, `eu`: The European Union. Example: `projects/project-A/locations/eu`.
8105    ///
8106    /// Sets the *parent* path property to the given value.
8107    ///
8108    /// Even though the property as already been set when instantiating this call,
8109    /// we provide this method for API completeness.
8110    pub fn parent(mut self, new_value: &str) -> ProjectLocationImageAnnotateCall<'a, C> {
8111        self._parent = new_value.to_string();
8112        self
8113    }
8114    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8115    /// while executing the actual API request.
8116    ///
8117    /// ````text
8118    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8119    /// ````
8120    ///
8121    /// Sets the *delegate* property to the given value.
8122    pub fn delegate(
8123        mut self,
8124        new_value: &'a mut dyn common::Delegate,
8125    ) -> ProjectLocationImageAnnotateCall<'a, C> {
8126        self._delegate = Some(new_value);
8127        self
8128    }
8129
8130    /// Set any additional parameter of the query string used in the request.
8131    /// It should be used to set parameters which are not yet available through their own
8132    /// setters.
8133    ///
8134    /// Please note that this method must not be used to set any of the known parameters
8135    /// which have their own setter method. If done anyway, the request will fail.
8136    ///
8137    /// # Additional Parameters
8138    ///
8139    /// * *$.xgafv* (query-string) - V1 error format.
8140    /// * *access_token* (query-string) - OAuth access token.
8141    /// * *alt* (query-string) - Data format for response.
8142    /// * *callback* (query-string) - JSONP
8143    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8144    /// * *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.
8145    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8146    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8147    /// * *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.
8148    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8149    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8150    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationImageAnnotateCall<'a, C>
8151    where
8152        T: AsRef<str>,
8153    {
8154        self._additional_params
8155            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8156        self
8157    }
8158
8159    /// Identifies the authorization scope for the method you are building.
8160    ///
8161    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8162    /// [`Scope::CloudPlatform`].
8163    ///
8164    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8165    /// tokens for more than one scope.
8166    ///
8167    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8168    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8169    /// sufficient, a read-write scope will do as well.
8170    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationImageAnnotateCall<'a, C>
8171    where
8172        St: AsRef<str>,
8173    {
8174        self._scopes.insert(String::from(scope.as_ref()));
8175        self
8176    }
8177    /// Identifies the authorization scope(s) for the method you are building.
8178    ///
8179    /// See [`Self::add_scope()`] for details.
8180    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationImageAnnotateCall<'a, C>
8181    where
8182        I: IntoIterator<Item = St>,
8183        St: AsRef<str>,
8184    {
8185        self._scopes
8186            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8187        self
8188    }
8189
8190    /// Removes all scopes, and no default scope will be used either.
8191    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8192    /// for details).
8193    pub fn clear_scopes(mut self) -> ProjectLocationImageAnnotateCall<'a, C> {
8194        self._scopes.clear();
8195        self
8196    }
8197}
8198
8199/// Run asynchronous image detection and annotation for a list of images. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `OperationMetadata` (metadata). `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results). This service will write image annotation outputs to json files in customer GCS bucket, each json file containing BatchAnnotateImagesResponse proto.
8200///
8201/// A builder for the *locations.images.asyncBatchAnnotate* method supported by a *project* resource.
8202/// It is not used directly, but through a [`ProjectMethods`] instance.
8203///
8204/// # Example
8205///
8206/// Instantiate a resource method builder
8207///
8208/// ```test_harness,no_run
8209/// # extern crate hyper;
8210/// # extern crate hyper_rustls;
8211/// # extern crate google_vision1 as vision1;
8212/// use vision1::api::AsyncBatchAnnotateImagesRequest;
8213/// # async fn dox() {
8214/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8215///
8216/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8217/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8218/// #     .with_native_roots()
8219/// #     .unwrap()
8220/// #     .https_only()
8221/// #     .enable_http2()
8222/// #     .build();
8223///
8224/// # let executor = hyper_util::rt::TokioExecutor::new();
8225/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8226/// #     secret,
8227/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8228/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8229/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8230/// #     ),
8231/// # ).build().await.unwrap();
8232///
8233/// # let client = hyper_util::client::legacy::Client::builder(
8234/// #     hyper_util::rt::TokioExecutor::new()
8235/// # )
8236/// # .build(
8237/// #     hyper_rustls::HttpsConnectorBuilder::new()
8238/// #         .with_native_roots()
8239/// #         .unwrap()
8240/// #         .https_or_http()
8241/// #         .enable_http2()
8242/// #         .build()
8243/// # );
8244/// # let mut hub = Vision::new(client, auth);
8245/// // As the method needs a request, you would usually fill it with the desired information
8246/// // into the respective structure. Some of the parts shown here might not be applicable !
8247/// // Values shown here are possibly random and not representative !
8248/// let mut req = AsyncBatchAnnotateImagesRequest::default();
8249///
8250/// // You can configure optional parameters by calling the respective setters at will, and
8251/// // execute the final call using `doit()`.
8252/// // Values shown here are possibly random and not representative !
8253/// let result = hub.projects().locations_images_async_batch_annotate(req, "parent")
8254///              .doit().await;
8255/// # }
8256/// ```
8257pub struct ProjectLocationImageAsyncBatchAnnotateCall<'a, C>
8258where
8259    C: 'a,
8260{
8261    hub: &'a Vision<C>,
8262    _request: AsyncBatchAnnotateImagesRequest,
8263    _parent: String,
8264    _delegate: Option<&'a mut dyn common::Delegate>,
8265    _additional_params: HashMap<String, String>,
8266    _scopes: BTreeSet<String>,
8267}
8268
8269impl<'a, C> common::CallBuilder for ProjectLocationImageAsyncBatchAnnotateCall<'a, C> {}
8270
8271impl<'a, C> ProjectLocationImageAsyncBatchAnnotateCall<'a, C>
8272where
8273    C: common::Connector,
8274{
8275    /// Perform the operation you have build so far.
8276    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
8277        use std::borrow::Cow;
8278        use std::io::{Read, Seek};
8279
8280        use common::{url::Params, ToParts};
8281        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8282
8283        let mut dd = common::DefaultDelegate;
8284        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8285        dlg.begin(common::MethodInfo {
8286            id: "vision.projects.locations.images.asyncBatchAnnotate",
8287            http_method: hyper::Method::POST,
8288        });
8289
8290        for &field in ["alt", "parent"].iter() {
8291            if self._additional_params.contains_key(field) {
8292                dlg.finished(false);
8293                return Err(common::Error::FieldClash(field));
8294            }
8295        }
8296
8297        let mut params = Params::with_capacity(4 + self._additional_params.len());
8298        params.push("parent", self._parent);
8299
8300        params.extend(self._additional_params.iter());
8301
8302        params.push("alt", "json");
8303        let mut url = self.hub._base_url.clone() + "v1/{+parent}/images:asyncBatchAnnotate";
8304        if self._scopes.is_empty() {
8305            self._scopes
8306                .insert(Scope::CloudPlatform.as_ref().to_string());
8307        }
8308
8309        #[allow(clippy::single_element_loop)]
8310        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8311            url = params.uri_replacement(url, param_name, find_this, true);
8312        }
8313        {
8314            let to_remove = ["parent"];
8315            params.remove_params(&to_remove);
8316        }
8317
8318        let url = params.parse_with_url(&url);
8319
8320        let mut json_mime_type = mime::APPLICATION_JSON;
8321        let mut request_value_reader = {
8322            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8323            common::remove_json_null_values(&mut value);
8324            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8325            serde_json::to_writer(&mut dst, &value).unwrap();
8326            dst
8327        };
8328        let request_size = request_value_reader
8329            .seek(std::io::SeekFrom::End(0))
8330            .unwrap();
8331        request_value_reader
8332            .seek(std::io::SeekFrom::Start(0))
8333            .unwrap();
8334
8335        loop {
8336            let token = match self
8337                .hub
8338                .auth
8339                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8340                .await
8341            {
8342                Ok(token) => token,
8343                Err(e) => match dlg.token(e) {
8344                    Ok(token) => token,
8345                    Err(e) => {
8346                        dlg.finished(false);
8347                        return Err(common::Error::MissingToken(e));
8348                    }
8349                },
8350            };
8351            request_value_reader
8352                .seek(std::io::SeekFrom::Start(0))
8353                .unwrap();
8354            let mut req_result = {
8355                let client = &self.hub.client;
8356                dlg.pre_request();
8357                let mut req_builder = hyper::Request::builder()
8358                    .method(hyper::Method::POST)
8359                    .uri(url.as_str())
8360                    .header(USER_AGENT, self.hub._user_agent.clone());
8361
8362                if let Some(token) = token.as_ref() {
8363                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8364                }
8365
8366                let request = req_builder
8367                    .header(CONTENT_TYPE, json_mime_type.to_string())
8368                    .header(CONTENT_LENGTH, request_size as u64)
8369                    .body(common::to_body(
8370                        request_value_reader.get_ref().clone().into(),
8371                    ));
8372
8373                client.request(request.unwrap()).await
8374            };
8375
8376            match req_result {
8377                Err(err) => {
8378                    if let common::Retry::After(d) = dlg.http_error(&err) {
8379                        sleep(d).await;
8380                        continue;
8381                    }
8382                    dlg.finished(false);
8383                    return Err(common::Error::HttpError(err));
8384                }
8385                Ok(res) => {
8386                    let (mut parts, body) = res.into_parts();
8387                    let mut body = common::Body::new(body);
8388                    if !parts.status.is_success() {
8389                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8390                        let error = serde_json::from_str(&common::to_string(&bytes));
8391                        let response = common::to_response(parts, bytes.into());
8392
8393                        if let common::Retry::After(d) =
8394                            dlg.http_failure(&response, error.as_ref().ok())
8395                        {
8396                            sleep(d).await;
8397                            continue;
8398                        }
8399
8400                        dlg.finished(false);
8401
8402                        return Err(match error {
8403                            Ok(value) => common::Error::BadRequest(value),
8404                            _ => common::Error::Failure(response),
8405                        });
8406                    }
8407                    let response = {
8408                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8409                        let encoded = common::to_string(&bytes);
8410                        match serde_json::from_str(&encoded) {
8411                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8412                            Err(error) => {
8413                                dlg.response_json_decode_error(&encoded, &error);
8414                                return Err(common::Error::JsonDecodeError(
8415                                    encoded.to_string(),
8416                                    error,
8417                                ));
8418                            }
8419                        }
8420                    };
8421
8422                    dlg.finished(true);
8423                    return Ok(response);
8424                }
8425            }
8426        }
8427    }
8428
8429    ///
8430    /// Sets the *request* property to the given value.
8431    ///
8432    /// Even though the property as already been set when instantiating this call,
8433    /// we provide this method for API completeness.
8434    pub fn request(
8435        mut self,
8436        new_value: AsyncBatchAnnotateImagesRequest,
8437    ) -> ProjectLocationImageAsyncBatchAnnotateCall<'a, C> {
8438        self._request = new_value;
8439        self
8440    }
8441    /// Optional. Target project and location to make a call. Format: `projects/{project-id}/locations/{location-id}`. If no parent is specified, a region will be chosen automatically. Supported location-ids: `us`: USA country only, `asia`: East asia areas, like Japan, Taiwan, `eu`: The European Union. Example: `projects/project-A/locations/eu`.
8442    ///
8443    /// Sets the *parent* path property to the given value.
8444    ///
8445    /// Even though the property as already been set when instantiating this call,
8446    /// we provide this method for API completeness.
8447    pub fn parent(mut self, new_value: &str) -> ProjectLocationImageAsyncBatchAnnotateCall<'a, C> {
8448        self._parent = new_value.to_string();
8449        self
8450    }
8451    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8452    /// while executing the actual API request.
8453    ///
8454    /// ````text
8455    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8456    /// ````
8457    ///
8458    /// Sets the *delegate* property to the given value.
8459    pub fn delegate(
8460        mut self,
8461        new_value: &'a mut dyn common::Delegate,
8462    ) -> ProjectLocationImageAsyncBatchAnnotateCall<'a, C> {
8463        self._delegate = Some(new_value);
8464        self
8465    }
8466
8467    /// Set any additional parameter of the query string used in the request.
8468    /// It should be used to set parameters which are not yet available through their own
8469    /// setters.
8470    ///
8471    /// Please note that this method must not be used to set any of the known parameters
8472    /// which have their own setter method. If done anyway, the request will fail.
8473    ///
8474    /// # Additional Parameters
8475    ///
8476    /// * *$.xgafv* (query-string) - V1 error format.
8477    /// * *access_token* (query-string) - OAuth access token.
8478    /// * *alt* (query-string) - Data format for response.
8479    /// * *callback* (query-string) - JSONP
8480    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8481    /// * *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.
8482    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8483    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8484    /// * *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.
8485    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8486    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8487    pub fn param<T>(
8488        mut self,
8489        name: T,
8490        value: T,
8491    ) -> ProjectLocationImageAsyncBatchAnnotateCall<'a, C>
8492    where
8493        T: AsRef<str>,
8494    {
8495        self._additional_params
8496            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8497        self
8498    }
8499
8500    /// Identifies the authorization scope for the method you are building.
8501    ///
8502    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8503    /// [`Scope::CloudPlatform`].
8504    ///
8505    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8506    /// tokens for more than one scope.
8507    ///
8508    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8509    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8510    /// sufficient, a read-write scope will do as well.
8511    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationImageAsyncBatchAnnotateCall<'a, C>
8512    where
8513        St: AsRef<str>,
8514    {
8515        self._scopes.insert(String::from(scope.as_ref()));
8516        self
8517    }
8518    /// Identifies the authorization scope(s) for the method you are building.
8519    ///
8520    /// See [`Self::add_scope()`] for details.
8521    pub fn add_scopes<I, St>(
8522        mut self,
8523        scopes: I,
8524    ) -> ProjectLocationImageAsyncBatchAnnotateCall<'a, C>
8525    where
8526        I: IntoIterator<Item = St>,
8527        St: AsRef<str>,
8528    {
8529        self._scopes
8530            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8531        self
8532    }
8533
8534    /// Removes all scopes, and no default scope will be used either.
8535    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8536    /// for details).
8537    pub fn clear_scopes(mut self) -> ProjectLocationImageAsyncBatchAnnotateCall<'a, C> {
8538        self._scopes.clear();
8539        self
8540    }
8541}
8542
8543/// 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.
8544///
8545/// A builder for the *locations.operations.get* method supported by a *project* resource.
8546/// It is not used directly, but through a [`ProjectMethods`] instance.
8547///
8548/// # Example
8549///
8550/// Instantiate a resource method builder
8551///
8552/// ```test_harness,no_run
8553/// # extern crate hyper;
8554/// # extern crate hyper_rustls;
8555/// # extern crate google_vision1 as vision1;
8556/// # async fn dox() {
8557/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8558///
8559/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8560/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8561/// #     .with_native_roots()
8562/// #     .unwrap()
8563/// #     .https_only()
8564/// #     .enable_http2()
8565/// #     .build();
8566///
8567/// # let executor = hyper_util::rt::TokioExecutor::new();
8568/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8569/// #     secret,
8570/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8571/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8572/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8573/// #     ),
8574/// # ).build().await.unwrap();
8575///
8576/// # let client = hyper_util::client::legacy::Client::builder(
8577/// #     hyper_util::rt::TokioExecutor::new()
8578/// # )
8579/// # .build(
8580/// #     hyper_rustls::HttpsConnectorBuilder::new()
8581/// #         .with_native_roots()
8582/// #         .unwrap()
8583/// #         .https_or_http()
8584/// #         .enable_http2()
8585/// #         .build()
8586/// # );
8587/// # let mut hub = Vision::new(client, auth);
8588/// // You can configure optional parameters by calling the respective setters at will, and
8589/// // execute the final call using `doit()`.
8590/// // Values shown here are possibly random and not representative !
8591/// let result = hub.projects().locations_operations_get("name")
8592///              .doit().await;
8593/// # }
8594/// ```
8595pub struct ProjectLocationOperationGetCall<'a, C>
8596where
8597    C: 'a,
8598{
8599    hub: &'a Vision<C>,
8600    _name: String,
8601    _delegate: Option<&'a mut dyn common::Delegate>,
8602    _additional_params: HashMap<String, String>,
8603    _scopes: BTreeSet<String>,
8604}
8605
8606impl<'a, C> common::CallBuilder for ProjectLocationOperationGetCall<'a, C> {}
8607
8608impl<'a, C> ProjectLocationOperationGetCall<'a, C>
8609where
8610    C: common::Connector,
8611{
8612    /// Perform the operation you have build so far.
8613    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
8614        use std::borrow::Cow;
8615        use std::io::{Read, Seek};
8616
8617        use common::{url::Params, ToParts};
8618        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8619
8620        let mut dd = common::DefaultDelegate;
8621        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8622        dlg.begin(common::MethodInfo {
8623            id: "vision.projects.locations.operations.get",
8624            http_method: hyper::Method::GET,
8625        });
8626
8627        for &field in ["alt", "name"].iter() {
8628            if self._additional_params.contains_key(field) {
8629                dlg.finished(false);
8630                return Err(common::Error::FieldClash(field));
8631            }
8632        }
8633
8634        let mut params = Params::with_capacity(3 + self._additional_params.len());
8635        params.push("name", self._name);
8636
8637        params.extend(self._additional_params.iter());
8638
8639        params.push("alt", "json");
8640        let mut url = self.hub._base_url.clone() + "v1/{+name}";
8641        if self._scopes.is_empty() {
8642            self._scopes
8643                .insert(Scope::CloudPlatform.as_ref().to_string());
8644        }
8645
8646        #[allow(clippy::single_element_loop)]
8647        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8648            url = params.uri_replacement(url, param_name, find_this, true);
8649        }
8650        {
8651            let to_remove = ["name"];
8652            params.remove_params(&to_remove);
8653        }
8654
8655        let url = params.parse_with_url(&url);
8656
8657        loop {
8658            let token = match self
8659                .hub
8660                .auth
8661                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8662                .await
8663            {
8664                Ok(token) => token,
8665                Err(e) => match dlg.token(e) {
8666                    Ok(token) => token,
8667                    Err(e) => {
8668                        dlg.finished(false);
8669                        return Err(common::Error::MissingToken(e));
8670                    }
8671                },
8672            };
8673            let mut req_result = {
8674                let client = &self.hub.client;
8675                dlg.pre_request();
8676                let mut req_builder = hyper::Request::builder()
8677                    .method(hyper::Method::GET)
8678                    .uri(url.as_str())
8679                    .header(USER_AGENT, self.hub._user_agent.clone());
8680
8681                if let Some(token) = token.as_ref() {
8682                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8683                }
8684
8685                let request = req_builder
8686                    .header(CONTENT_LENGTH, 0_u64)
8687                    .body(common::to_body::<String>(None));
8688
8689                client.request(request.unwrap()).await
8690            };
8691
8692            match req_result {
8693                Err(err) => {
8694                    if let common::Retry::After(d) = dlg.http_error(&err) {
8695                        sleep(d).await;
8696                        continue;
8697                    }
8698                    dlg.finished(false);
8699                    return Err(common::Error::HttpError(err));
8700                }
8701                Ok(res) => {
8702                    let (mut parts, body) = res.into_parts();
8703                    let mut body = common::Body::new(body);
8704                    if !parts.status.is_success() {
8705                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8706                        let error = serde_json::from_str(&common::to_string(&bytes));
8707                        let response = common::to_response(parts, bytes.into());
8708
8709                        if let common::Retry::After(d) =
8710                            dlg.http_failure(&response, error.as_ref().ok())
8711                        {
8712                            sleep(d).await;
8713                            continue;
8714                        }
8715
8716                        dlg.finished(false);
8717
8718                        return Err(match error {
8719                            Ok(value) => common::Error::BadRequest(value),
8720                            _ => common::Error::Failure(response),
8721                        });
8722                    }
8723                    let response = {
8724                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8725                        let encoded = common::to_string(&bytes);
8726                        match serde_json::from_str(&encoded) {
8727                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8728                            Err(error) => {
8729                                dlg.response_json_decode_error(&encoded, &error);
8730                                return Err(common::Error::JsonDecodeError(
8731                                    encoded.to_string(),
8732                                    error,
8733                                ));
8734                            }
8735                        }
8736                    };
8737
8738                    dlg.finished(true);
8739                    return Ok(response);
8740                }
8741            }
8742        }
8743    }
8744
8745    /// The name of the operation resource.
8746    ///
8747    /// Sets the *name* path property to the given value.
8748    ///
8749    /// Even though the property as already been set when instantiating this call,
8750    /// we provide this method for API completeness.
8751    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationGetCall<'a, C> {
8752        self._name = new_value.to_string();
8753        self
8754    }
8755    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8756    /// while executing the actual API request.
8757    ///
8758    /// ````text
8759    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8760    /// ````
8761    ///
8762    /// Sets the *delegate* property to the given value.
8763    pub fn delegate(
8764        mut self,
8765        new_value: &'a mut dyn common::Delegate,
8766    ) -> ProjectLocationOperationGetCall<'a, C> {
8767        self._delegate = Some(new_value);
8768        self
8769    }
8770
8771    /// Set any additional parameter of the query string used in the request.
8772    /// It should be used to set parameters which are not yet available through their own
8773    /// setters.
8774    ///
8775    /// Please note that this method must not be used to set any of the known parameters
8776    /// which have their own setter method. If done anyway, the request will fail.
8777    ///
8778    /// # Additional Parameters
8779    ///
8780    /// * *$.xgafv* (query-string) - V1 error format.
8781    /// * *access_token* (query-string) - OAuth access token.
8782    /// * *alt* (query-string) - Data format for response.
8783    /// * *callback* (query-string) - JSONP
8784    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8785    /// * *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.
8786    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8787    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8788    /// * *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.
8789    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8790    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8791    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationGetCall<'a, C>
8792    where
8793        T: AsRef<str>,
8794    {
8795        self._additional_params
8796            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8797        self
8798    }
8799
8800    /// Identifies the authorization scope for the method you are building.
8801    ///
8802    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8803    /// [`Scope::CloudPlatform`].
8804    ///
8805    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8806    /// tokens for more than one scope.
8807    ///
8808    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8809    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8810    /// sufficient, a read-write scope will do as well.
8811    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationGetCall<'a, C>
8812    where
8813        St: AsRef<str>,
8814    {
8815        self._scopes.insert(String::from(scope.as_ref()));
8816        self
8817    }
8818    /// Identifies the authorization scope(s) for the method you are building.
8819    ///
8820    /// See [`Self::add_scope()`] for details.
8821    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationGetCall<'a, C>
8822    where
8823        I: IntoIterator<Item = St>,
8824        St: AsRef<str>,
8825    {
8826        self._scopes
8827            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8828        self
8829    }
8830
8831    /// Removes all scopes, and no default scope will be used either.
8832    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8833    /// for details).
8834    pub fn clear_scopes(mut self) -> ProjectLocationOperationGetCall<'a, C> {
8835        self._scopes.clear();
8836        self
8837    }
8838}
8839
8840/// Lists the Products in a ProductSet, in an unspecified order. If the ProductSet does not exist, the products field of the response will be empty. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.
8841///
8842/// A builder for the *locations.productSets.products.list* method supported by a *project* resource.
8843/// It is not used directly, but through a [`ProjectMethods`] instance.
8844///
8845/// # Example
8846///
8847/// Instantiate a resource method builder
8848///
8849/// ```test_harness,no_run
8850/// # extern crate hyper;
8851/// # extern crate hyper_rustls;
8852/// # extern crate google_vision1 as vision1;
8853/// # async fn dox() {
8854/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8855///
8856/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8857/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8858/// #     .with_native_roots()
8859/// #     .unwrap()
8860/// #     .https_only()
8861/// #     .enable_http2()
8862/// #     .build();
8863///
8864/// # let executor = hyper_util::rt::TokioExecutor::new();
8865/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8866/// #     secret,
8867/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8868/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8869/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8870/// #     ),
8871/// # ).build().await.unwrap();
8872///
8873/// # let client = hyper_util::client::legacy::Client::builder(
8874/// #     hyper_util::rt::TokioExecutor::new()
8875/// # )
8876/// # .build(
8877/// #     hyper_rustls::HttpsConnectorBuilder::new()
8878/// #         .with_native_roots()
8879/// #         .unwrap()
8880/// #         .https_or_http()
8881/// #         .enable_http2()
8882/// #         .build()
8883/// # );
8884/// # let mut hub = Vision::new(client, auth);
8885/// // You can configure optional parameters by calling the respective setters at will, and
8886/// // execute the final call using `doit()`.
8887/// // Values shown here are possibly random and not representative !
8888/// let result = hub.projects().locations_product_sets_products_list("name")
8889///              .page_token("labore")
8890///              .page_size(-43)
8891///              .doit().await;
8892/// # }
8893/// ```
8894pub struct ProjectLocationProductSetProductListCall<'a, C>
8895where
8896    C: 'a,
8897{
8898    hub: &'a Vision<C>,
8899    _name: String,
8900    _page_token: Option<String>,
8901    _page_size: Option<i32>,
8902    _delegate: Option<&'a mut dyn common::Delegate>,
8903    _additional_params: HashMap<String, String>,
8904    _scopes: BTreeSet<String>,
8905}
8906
8907impl<'a, C> common::CallBuilder for ProjectLocationProductSetProductListCall<'a, C> {}
8908
8909impl<'a, C> ProjectLocationProductSetProductListCall<'a, C>
8910where
8911    C: common::Connector,
8912{
8913    /// Perform the operation you have build so far.
8914    pub async fn doit(
8915        mut self,
8916    ) -> common::Result<(common::Response, ListProductsInProductSetResponse)> {
8917        use std::borrow::Cow;
8918        use std::io::{Read, Seek};
8919
8920        use common::{url::Params, ToParts};
8921        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8922
8923        let mut dd = common::DefaultDelegate;
8924        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8925        dlg.begin(common::MethodInfo {
8926            id: "vision.projects.locations.productSets.products.list",
8927            http_method: hyper::Method::GET,
8928        });
8929
8930        for &field in ["alt", "name", "pageToken", "pageSize"].iter() {
8931            if self._additional_params.contains_key(field) {
8932                dlg.finished(false);
8933                return Err(common::Error::FieldClash(field));
8934            }
8935        }
8936
8937        let mut params = Params::with_capacity(5 + self._additional_params.len());
8938        params.push("name", self._name);
8939        if let Some(value) = self._page_token.as_ref() {
8940            params.push("pageToken", value);
8941        }
8942        if let Some(value) = self._page_size.as_ref() {
8943            params.push("pageSize", value.to_string());
8944        }
8945
8946        params.extend(self._additional_params.iter());
8947
8948        params.push("alt", "json");
8949        let mut url = self.hub._base_url.clone() + "v1/{+name}/products";
8950        if self._scopes.is_empty() {
8951            self._scopes
8952                .insert(Scope::CloudPlatform.as_ref().to_string());
8953        }
8954
8955        #[allow(clippy::single_element_loop)]
8956        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8957            url = params.uri_replacement(url, param_name, find_this, true);
8958        }
8959        {
8960            let to_remove = ["name"];
8961            params.remove_params(&to_remove);
8962        }
8963
8964        let url = params.parse_with_url(&url);
8965
8966        loop {
8967            let token = match self
8968                .hub
8969                .auth
8970                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8971                .await
8972            {
8973                Ok(token) => token,
8974                Err(e) => match dlg.token(e) {
8975                    Ok(token) => token,
8976                    Err(e) => {
8977                        dlg.finished(false);
8978                        return Err(common::Error::MissingToken(e));
8979                    }
8980                },
8981            };
8982            let mut req_result = {
8983                let client = &self.hub.client;
8984                dlg.pre_request();
8985                let mut req_builder = hyper::Request::builder()
8986                    .method(hyper::Method::GET)
8987                    .uri(url.as_str())
8988                    .header(USER_AGENT, self.hub._user_agent.clone());
8989
8990                if let Some(token) = token.as_ref() {
8991                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8992                }
8993
8994                let request = req_builder
8995                    .header(CONTENT_LENGTH, 0_u64)
8996                    .body(common::to_body::<String>(None));
8997
8998                client.request(request.unwrap()).await
8999            };
9000
9001            match req_result {
9002                Err(err) => {
9003                    if let common::Retry::After(d) = dlg.http_error(&err) {
9004                        sleep(d).await;
9005                        continue;
9006                    }
9007                    dlg.finished(false);
9008                    return Err(common::Error::HttpError(err));
9009                }
9010                Ok(res) => {
9011                    let (mut parts, body) = res.into_parts();
9012                    let mut body = common::Body::new(body);
9013                    if !parts.status.is_success() {
9014                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9015                        let error = serde_json::from_str(&common::to_string(&bytes));
9016                        let response = common::to_response(parts, bytes.into());
9017
9018                        if let common::Retry::After(d) =
9019                            dlg.http_failure(&response, error.as_ref().ok())
9020                        {
9021                            sleep(d).await;
9022                            continue;
9023                        }
9024
9025                        dlg.finished(false);
9026
9027                        return Err(match error {
9028                            Ok(value) => common::Error::BadRequest(value),
9029                            _ => common::Error::Failure(response),
9030                        });
9031                    }
9032                    let response = {
9033                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9034                        let encoded = common::to_string(&bytes);
9035                        match serde_json::from_str(&encoded) {
9036                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9037                            Err(error) => {
9038                                dlg.response_json_decode_error(&encoded, &error);
9039                                return Err(common::Error::JsonDecodeError(
9040                                    encoded.to_string(),
9041                                    error,
9042                                ));
9043                            }
9044                        }
9045                    };
9046
9047                    dlg.finished(true);
9048                    return Ok(response);
9049                }
9050            }
9051        }
9052    }
9053
9054    /// Required. The ProductSet resource for which to retrieve Products. Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
9055    ///
9056    /// Sets the *name* path property to the given value.
9057    ///
9058    /// Even though the property as already been set when instantiating this call,
9059    /// we provide this method for API completeness.
9060    pub fn name(mut self, new_value: &str) -> ProjectLocationProductSetProductListCall<'a, C> {
9061        self._name = new_value.to_string();
9062        self
9063    }
9064    /// The next_page_token returned from a previous List request, if any.
9065    ///
9066    /// Sets the *page token* query property to the given value.
9067    pub fn page_token(
9068        mut self,
9069        new_value: &str,
9070    ) -> ProjectLocationProductSetProductListCall<'a, C> {
9071        self._page_token = Some(new_value.to_string());
9072        self
9073    }
9074    /// The maximum number of items to return. Default 10, maximum 100.
9075    ///
9076    /// Sets the *page size* query property to the given value.
9077    pub fn page_size(mut self, new_value: i32) -> ProjectLocationProductSetProductListCall<'a, C> {
9078        self._page_size = Some(new_value);
9079        self
9080    }
9081    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9082    /// while executing the actual API request.
9083    ///
9084    /// ````text
9085    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9086    /// ````
9087    ///
9088    /// Sets the *delegate* property to the given value.
9089    pub fn delegate(
9090        mut self,
9091        new_value: &'a mut dyn common::Delegate,
9092    ) -> ProjectLocationProductSetProductListCall<'a, C> {
9093        self._delegate = Some(new_value);
9094        self
9095    }
9096
9097    /// Set any additional parameter of the query string used in the request.
9098    /// It should be used to set parameters which are not yet available through their own
9099    /// setters.
9100    ///
9101    /// Please note that this method must not be used to set any of the known parameters
9102    /// which have their own setter method. If done anyway, the request will fail.
9103    ///
9104    /// # Additional Parameters
9105    ///
9106    /// * *$.xgafv* (query-string) - V1 error format.
9107    /// * *access_token* (query-string) - OAuth access token.
9108    /// * *alt* (query-string) - Data format for response.
9109    /// * *callback* (query-string) - JSONP
9110    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9111    /// * *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.
9112    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9113    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9114    /// * *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.
9115    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9116    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9117    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProductSetProductListCall<'a, C>
9118    where
9119        T: AsRef<str>,
9120    {
9121        self._additional_params
9122            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9123        self
9124    }
9125
9126    /// Identifies the authorization scope for the method you are building.
9127    ///
9128    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9129    /// [`Scope::CloudPlatform`].
9130    ///
9131    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9132    /// tokens for more than one scope.
9133    ///
9134    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9135    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9136    /// sufficient, a read-write scope will do as well.
9137    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProductSetProductListCall<'a, C>
9138    where
9139        St: AsRef<str>,
9140    {
9141        self._scopes.insert(String::from(scope.as_ref()));
9142        self
9143    }
9144    /// Identifies the authorization scope(s) for the method you are building.
9145    ///
9146    /// See [`Self::add_scope()`] for details.
9147    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProductSetProductListCall<'a, C>
9148    where
9149        I: IntoIterator<Item = St>,
9150        St: AsRef<str>,
9151    {
9152        self._scopes
9153            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9154        self
9155    }
9156
9157    /// Removes all scopes, and no default scope will be used either.
9158    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9159    /// for details).
9160    pub fn clear_scopes(mut self) -> ProjectLocationProductSetProductListCall<'a, C> {
9161        self._scopes.clear();
9162        self
9163    }
9164}
9165
9166/// Adds a Product to the specified ProductSet. If the Product is already present, no change is made. One Product can be added to at most 100 ProductSets. Possible errors: * Returns NOT_FOUND if the Product or the ProductSet doesn't exist.
9167///
9168/// A builder for the *locations.productSets.addProduct* method supported by a *project* resource.
9169/// It is not used directly, but through a [`ProjectMethods`] instance.
9170///
9171/// # Example
9172///
9173/// Instantiate a resource method builder
9174///
9175/// ```test_harness,no_run
9176/// # extern crate hyper;
9177/// # extern crate hyper_rustls;
9178/// # extern crate google_vision1 as vision1;
9179/// use vision1::api::AddProductToProductSetRequest;
9180/// # async fn dox() {
9181/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9182///
9183/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9184/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9185/// #     .with_native_roots()
9186/// #     .unwrap()
9187/// #     .https_only()
9188/// #     .enable_http2()
9189/// #     .build();
9190///
9191/// # let executor = hyper_util::rt::TokioExecutor::new();
9192/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9193/// #     secret,
9194/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9195/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9196/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9197/// #     ),
9198/// # ).build().await.unwrap();
9199///
9200/// # let client = hyper_util::client::legacy::Client::builder(
9201/// #     hyper_util::rt::TokioExecutor::new()
9202/// # )
9203/// # .build(
9204/// #     hyper_rustls::HttpsConnectorBuilder::new()
9205/// #         .with_native_roots()
9206/// #         .unwrap()
9207/// #         .https_or_http()
9208/// #         .enable_http2()
9209/// #         .build()
9210/// # );
9211/// # let mut hub = Vision::new(client, auth);
9212/// // As the method needs a request, you would usually fill it with the desired information
9213/// // into the respective structure. Some of the parts shown here might not be applicable !
9214/// // Values shown here are possibly random and not representative !
9215/// let mut req = AddProductToProductSetRequest::default();
9216///
9217/// // You can configure optional parameters by calling the respective setters at will, and
9218/// // execute the final call using `doit()`.
9219/// // Values shown here are possibly random and not representative !
9220/// let result = hub.projects().locations_product_sets_add_product(req, "name")
9221///              .doit().await;
9222/// # }
9223/// ```
9224pub struct ProjectLocationProductSetAddProductCall<'a, C>
9225where
9226    C: 'a,
9227{
9228    hub: &'a Vision<C>,
9229    _request: AddProductToProductSetRequest,
9230    _name: String,
9231    _delegate: Option<&'a mut dyn common::Delegate>,
9232    _additional_params: HashMap<String, String>,
9233    _scopes: BTreeSet<String>,
9234}
9235
9236impl<'a, C> common::CallBuilder for ProjectLocationProductSetAddProductCall<'a, C> {}
9237
9238impl<'a, C> ProjectLocationProductSetAddProductCall<'a, C>
9239where
9240    C: common::Connector,
9241{
9242    /// Perform the operation you have build so far.
9243    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
9244        use std::borrow::Cow;
9245        use std::io::{Read, Seek};
9246
9247        use common::{url::Params, ToParts};
9248        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9249
9250        let mut dd = common::DefaultDelegate;
9251        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9252        dlg.begin(common::MethodInfo {
9253            id: "vision.projects.locations.productSets.addProduct",
9254            http_method: hyper::Method::POST,
9255        });
9256
9257        for &field in ["alt", "name"].iter() {
9258            if self._additional_params.contains_key(field) {
9259                dlg.finished(false);
9260                return Err(common::Error::FieldClash(field));
9261            }
9262        }
9263
9264        let mut params = Params::with_capacity(4 + self._additional_params.len());
9265        params.push("name", self._name);
9266
9267        params.extend(self._additional_params.iter());
9268
9269        params.push("alt", "json");
9270        let mut url = self.hub._base_url.clone() + "v1/{+name}:addProduct";
9271        if self._scopes.is_empty() {
9272            self._scopes
9273                .insert(Scope::CloudPlatform.as_ref().to_string());
9274        }
9275
9276        #[allow(clippy::single_element_loop)]
9277        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9278            url = params.uri_replacement(url, param_name, find_this, true);
9279        }
9280        {
9281            let to_remove = ["name"];
9282            params.remove_params(&to_remove);
9283        }
9284
9285        let url = params.parse_with_url(&url);
9286
9287        let mut json_mime_type = mime::APPLICATION_JSON;
9288        let mut request_value_reader = {
9289            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9290            common::remove_json_null_values(&mut value);
9291            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9292            serde_json::to_writer(&mut dst, &value).unwrap();
9293            dst
9294        };
9295        let request_size = request_value_reader
9296            .seek(std::io::SeekFrom::End(0))
9297            .unwrap();
9298        request_value_reader
9299            .seek(std::io::SeekFrom::Start(0))
9300            .unwrap();
9301
9302        loop {
9303            let token = match self
9304                .hub
9305                .auth
9306                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9307                .await
9308            {
9309                Ok(token) => token,
9310                Err(e) => match dlg.token(e) {
9311                    Ok(token) => token,
9312                    Err(e) => {
9313                        dlg.finished(false);
9314                        return Err(common::Error::MissingToken(e));
9315                    }
9316                },
9317            };
9318            request_value_reader
9319                .seek(std::io::SeekFrom::Start(0))
9320                .unwrap();
9321            let mut req_result = {
9322                let client = &self.hub.client;
9323                dlg.pre_request();
9324                let mut req_builder = hyper::Request::builder()
9325                    .method(hyper::Method::POST)
9326                    .uri(url.as_str())
9327                    .header(USER_AGENT, self.hub._user_agent.clone());
9328
9329                if let Some(token) = token.as_ref() {
9330                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9331                }
9332
9333                let request = req_builder
9334                    .header(CONTENT_TYPE, json_mime_type.to_string())
9335                    .header(CONTENT_LENGTH, request_size as u64)
9336                    .body(common::to_body(
9337                        request_value_reader.get_ref().clone().into(),
9338                    ));
9339
9340                client.request(request.unwrap()).await
9341            };
9342
9343            match req_result {
9344                Err(err) => {
9345                    if let common::Retry::After(d) = dlg.http_error(&err) {
9346                        sleep(d).await;
9347                        continue;
9348                    }
9349                    dlg.finished(false);
9350                    return Err(common::Error::HttpError(err));
9351                }
9352                Ok(res) => {
9353                    let (mut parts, body) = res.into_parts();
9354                    let mut body = common::Body::new(body);
9355                    if !parts.status.is_success() {
9356                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9357                        let error = serde_json::from_str(&common::to_string(&bytes));
9358                        let response = common::to_response(parts, bytes.into());
9359
9360                        if let common::Retry::After(d) =
9361                            dlg.http_failure(&response, error.as_ref().ok())
9362                        {
9363                            sleep(d).await;
9364                            continue;
9365                        }
9366
9367                        dlg.finished(false);
9368
9369                        return Err(match error {
9370                            Ok(value) => common::Error::BadRequest(value),
9371                            _ => common::Error::Failure(response),
9372                        });
9373                    }
9374                    let response = {
9375                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9376                        let encoded = common::to_string(&bytes);
9377                        match serde_json::from_str(&encoded) {
9378                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9379                            Err(error) => {
9380                                dlg.response_json_decode_error(&encoded, &error);
9381                                return Err(common::Error::JsonDecodeError(
9382                                    encoded.to_string(),
9383                                    error,
9384                                ));
9385                            }
9386                        }
9387                    };
9388
9389                    dlg.finished(true);
9390                    return Ok(response);
9391                }
9392            }
9393        }
9394    }
9395
9396    ///
9397    /// Sets the *request* property to the given value.
9398    ///
9399    /// Even though the property as already been set when instantiating this call,
9400    /// we provide this method for API completeness.
9401    pub fn request(
9402        mut self,
9403        new_value: AddProductToProductSetRequest,
9404    ) -> ProjectLocationProductSetAddProductCall<'a, C> {
9405        self._request = new_value;
9406        self
9407    }
9408    /// Required. The resource name for the ProductSet to modify. Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
9409    ///
9410    /// Sets the *name* path property to the given value.
9411    ///
9412    /// Even though the property as already been set when instantiating this call,
9413    /// we provide this method for API completeness.
9414    pub fn name(mut self, new_value: &str) -> ProjectLocationProductSetAddProductCall<'a, C> {
9415        self._name = new_value.to_string();
9416        self
9417    }
9418    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9419    /// while executing the actual API request.
9420    ///
9421    /// ````text
9422    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9423    /// ````
9424    ///
9425    /// Sets the *delegate* property to the given value.
9426    pub fn delegate(
9427        mut self,
9428        new_value: &'a mut dyn common::Delegate,
9429    ) -> ProjectLocationProductSetAddProductCall<'a, C> {
9430        self._delegate = Some(new_value);
9431        self
9432    }
9433
9434    /// Set any additional parameter of the query string used in the request.
9435    /// It should be used to set parameters which are not yet available through their own
9436    /// setters.
9437    ///
9438    /// Please note that this method must not be used to set any of the known parameters
9439    /// which have their own setter method. If done anyway, the request will fail.
9440    ///
9441    /// # Additional Parameters
9442    ///
9443    /// * *$.xgafv* (query-string) - V1 error format.
9444    /// * *access_token* (query-string) - OAuth access token.
9445    /// * *alt* (query-string) - Data format for response.
9446    /// * *callback* (query-string) - JSONP
9447    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9448    /// * *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.
9449    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9450    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9451    /// * *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.
9452    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9453    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9454    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProductSetAddProductCall<'a, C>
9455    where
9456        T: AsRef<str>,
9457    {
9458        self._additional_params
9459            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9460        self
9461    }
9462
9463    /// Identifies the authorization scope for the method you are building.
9464    ///
9465    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9466    /// [`Scope::CloudPlatform`].
9467    ///
9468    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9469    /// tokens for more than one scope.
9470    ///
9471    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9472    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9473    /// sufficient, a read-write scope will do as well.
9474    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProductSetAddProductCall<'a, C>
9475    where
9476        St: AsRef<str>,
9477    {
9478        self._scopes.insert(String::from(scope.as_ref()));
9479        self
9480    }
9481    /// Identifies the authorization scope(s) for the method you are building.
9482    ///
9483    /// See [`Self::add_scope()`] for details.
9484    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProductSetAddProductCall<'a, C>
9485    where
9486        I: IntoIterator<Item = St>,
9487        St: AsRef<str>,
9488    {
9489        self._scopes
9490            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9491        self
9492    }
9493
9494    /// Removes all scopes, and no default scope will be used either.
9495    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9496    /// for details).
9497    pub fn clear_scopes(mut self) -> ProjectLocationProductSetAddProductCall<'a, C> {
9498        self._scopes.clear();
9499        self
9500    }
9501}
9502
9503/// Creates and returns a new ProductSet resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing, or is longer than 4096 characters.
9504///
9505/// A builder for the *locations.productSets.create* method supported by a *project* resource.
9506/// It is not used directly, but through a [`ProjectMethods`] instance.
9507///
9508/// # Example
9509///
9510/// Instantiate a resource method builder
9511///
9512/// ```test_harness,no_run
9513/// # extern crate hyper;
9514/// # extern crate hyper_rustls;
9515/// # extern crate google_vision1 as vision1;
9516/// use vision1::api::ProductSet;
9517/// # async fn dox() {
9518/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9519///
9520/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9521/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9522/// #     .with_native_roots()
9523/// #     .unwrap()
9524/// #     .https_only()
9525/// #     .enable_http2()
9526/// #     .build();
9527///
9528/// # let executor = hyper_util::rt::TokioExecutor::new();
9529/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9530/// #     secret,
9531/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9532/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9533/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9534/// #     ),
9535/// # ).build().await.unwrap();
9536///
9537/// # let client = hyper_util::client::legacy::Client::builder(
9538/// #     hyper_util::rt::TokioExecutor::new()
9539/// # )
9540/// # .build(
9541/// #     hyper_rustls::HttpsConnectorBuilder::new()
9542/// #         .with_native_roots()
9543/// #         .unwrap()
9544/// #         .https_or_http()
9545/// #         .enable_http2()
9546/// #         .build()
9547/// # );
9548/// # let mut hub = Vision::new(client, auth);
9549/// // As the method needs a request, you would usually fill it with the desired information
9550/// // into the respective structure. Some of the parts shown here might not be applicable !
9551/// // Values shown here are possibly random and not representative !
9552/// let mut req = ProductSet::default();
9553///
9554/// // You can configure optional parameters by calling the respective setters at will, and
9555/// // execute the final call using `doit()`.
9556/// // Values shown here are possibly random and not representative !
9557/// let result = hub.projects().locations_product_sets_create(req, "parent")
9558///              .product_set_id("no")
9559///              .doit().await;
9560/// # }
9561/// ```
9562pub struct ProjectLocationProductSetCreateCall<'a, C>
9563where
9564    C: 'a,
9565{
9566    hub: &'a Vision<C>,
9567    _request: ProductSet,
9568    _parent: String,
9569    _product_set_id: Option<String>,
9570    _delegate: Option<&'a mut dyn common::Delegate>,
9571    _additional_params: HashMap<String, String>,
9572    _scopes: BTreeSet<String>,
9573}
9574
9575impl<'a, C> common::CallBuilder for ProjectLocationProductSetCreateCall<'a, C> {}
9576
9577impl<'a, C> ProjectLocationProductSetCreateCall<'a, C>
9578where
9579    C: common::Connector,
9580{
9581    /// Perform the operation you have build so far.
9582    pub async fn doit(mut self) -> common::Result<(common::Response, ProductSet)> {
9583        use std::borrow::Cow;
9584        use std::io::{Read, Seek};
9585
9586        use common::{url::Params, ToParts};
9587        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9588
9589        let mut dd = common::DefaultDelegate;
9590        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9591        dlg.begin(common::MethodInfo {
9592            id: "vision.projects.locations.productSets.create",
9593            http_method: hyper::Method::POST,
9594        });
9595
9596        for &field in ["alt", "parent", "productSetId"].iter() {
9597            if self._additional_params.contains_key(field) {
9598                dlg.finished(false);
9599                return Err(common::Error::FieldClash(field));
9600            }
9601        }
9602
9603        let mut params = Params::with_capacity(5 + self._additional_params.len());
9604        params.push("parent", self._parent);
9605        if let Some(value) = self._product_set_id.as_ref() {
9606            params.push("productSetId", value);
9607        }
9608
9609        params.extend(self._additional_params.iter());
9610
9611        params.push("alt", "json");
9612        let mut url = self.hub._base_url.clone() + "v1/{+parent}/productSets";
9613        if self._scopes.is_empty() {
9614            self._scopes
9615                .insert(Scope::CloudPlatform.as_ref().to_string());
9616        }
9617
9618        #[allow(clippy::single_element_loop)]
9619        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9620            url = params.uri_replacement(url, param_name, find_this, true);
9621        }
9622        {
9623            let to_remove = ["parent"];
9624            params.remove_params(&to_remove);
9625        }
9626
9627        let url = params.parse_with_url(&url);
9628
9629        let mut json_mime_type = mime::APPLICATION_JSON;
9630        let mut request_value_reader = {
9631            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9632            common::remove_json_null_values(&mut value);
9633            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9634            serde_json::to_writer(&mut dst, &value).unwrap();
9635            dst
9636        };
9637        let request_size = request_value_reader
9638            .seek(std::io::SeekFrom::End(0))
9639            .unwrap();
9640        request_value_reader
9641            .seek(std::io::SeekFrom::Start(0))
9642            .unwrap();
9643
9644        loop {
9645            let token = match self
9646                .hub
9647                .auth
9648                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9649                .await
9650            {
9651                Ok(token) => token,
9652                Err(e) => match dlg.token(e) {
9653                    Ok(token) => token,
9654                    Err(e) => {
9655                        dlg.finished(false);
9656                        return Err(common::Error::MissingToken(e));
9657                    }
9658                },
9659            };
9660            request_value_reader
9661                .seek(std::io::SeekFrom::Start(0))
9662                .unwrap();
9663            let mut req_result = {
9664                let client = &self.hub.client;
9665                dlg.pre_request();
9666                let mut req_builder = hyper::Request::builder()
9667                    .method(hyper::Method::POST)
9668                    .uri(url.as_str())
9669                    .header(USER_AGENT, self.hub._user_agent.clone());
9670
9671                if let Some(token) = token.as_ref() {
9672                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9673                }
9674
9675                let request = req_builder
9676                    .header(CONTENT_TYPE, json_mime_type.to_string())
9677                    .header(CONTENT_LENGTH, request_size as u64)
9678                    .body(common::to_body(
9679                        request_value_reader.get_ref().clone().into(),
9680                    ));
9681
9682                client.request(request.unwrap()).await
9683            };
9684
9685            match req_result {
9686                Err(err) => {
9687                    if let common::Retry::After(d) = dlg.http_error(&err) {
9688                        sleep(d).await;
9689                        continue;
9690                    }
9691                    dlg.finished(false);
9692                    return Err(common::Error::HttpError(err));
9693                }
9694                Ok(res) => {
9695                    let (mut parts, body) = res.into_parts();
9696                    let mut body = common::Body::new(body);
9697                    if !parts.status.is_success() {
9698                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9699                        let error = serde_json::from_str(&common::to_string(&bytes));
9700                        let response = common::to_response(parts, bytes.into());
9701
9702                        if let common::Retry::After(d) =
9703                            dlg.http_failure(&response, error.as_ref().ok())
9704                        {
9705                            sleep(d).await;
9706                            continue;
9707                        }
9708
9709                        dlg.finished(false);
9710
9711                        return Err(match error {
9712                            Ok(value) => common::Error::BadRequest(value),
9713                            _ => common::Error::Failure(response),
9714                        });
9715                    }
9716                    let response = {
9717                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9718                        let encoded = common::to_string(&bytes);
9719                        match serde_json::from_str(&encoded) {
9720                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9721                            Err(error) => {
9722                                dlg.response_json_decode_error(&encoded, &error);
9723                                return Err(common::Error::JsonDecodeError(
9724                                    encoded.to_string(),
9725                                    error,
9726                                ));
9727                            }
9728                        }
9729                    };
9730
9731                    dlg.finished(true);
9732                    return Ok(response);
9733                }
9734            }
9735        }
9736    }
9737
9738    ///
9739    /// Sets the *request* property to the given value.
9740    ///
9741    /// Even though the property as already been set when instantiating this call,
9742    /// we provide this method for API completeness.
9743    pub fn request(mut self, new_value: ProductSet) -> ProjectLocationProductSetCreateCall<'a, C> {
9744        self._request = new_value;
9745        self
9746    }
9747    /// Required. The project in which the ProductSet should be created. Format is `projects/PROJECT_ID/locations/LOC_ID`.
9748    ///
9749    /// Sets the *parent* path property to the given value.
9750    ///
9751    /// Even though the property as already been set when instantiating this call,
9752    /// we provide this method for API completeness.
9753    pub fn parent(mut self, new_value: &str) -> ProjectLocationProductSetCreateCall<'a, C> {
9754        self._parent = new_value.to_string();
9755        self
9756    }
9757    /// A user-supplied resource id for this ProductSet. If set, the server will attempt to use this value as the resource id. If it is already in use, an error is returned with code ALREADY_EXISTS. Must be at most 128 characters long. It cannot contain the character `/`.
9758    ///
9759    /// Sets the *product set id* query property to the given value.
9760    pub fn product_set_id(mut self, new_value: &str) -> ProjectLocationProductSetCreateCall<'a, C> {
9761        self._product_set_id = Some(new_value.to_string());
9762        self
9763    }
9764    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9765    /// while executing the actual API request.
9766    ///
9767    /// ````text
9768    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9769    /// ````
9770    ///
9771    /// Sets the *delegate* property to the given value.
9772    pub fn delegate(
9773        mut self,
9774        new_value: &'a mut dyn common::Delegate,
9775    ) -> ProjectLocationProductSetCreateCall<'a, C> {
9776        self._delegate = Some(new_value);
9777        self
9778    }
9779
9780    /// Set any additional parameter of the query string used in the request.
9781    /// It should be used to set parameters which are not yet available through their own
9782    /// setters.
9783    ///
9784    /// Please note that this method must not be used to set any of the known parameters
9785    /// which have their own setter method. If done anyway, the request will fail.
9786    ///
9787    /// # Additional Parameters
9788    ///
9789    /// * *$.xgafv* (query-string) - V1 error format.
9790    /// * *access_token* (query-string) - OAuth access token.
9791    /// * *alt* (query-string) - Data format for response.
9792    /// * *callback* (query-string) - JSONP
9793    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9794    /// * *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.
9795    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9796    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9797    /// * *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.
9798    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9799    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9800    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProductSetCreateCall<'a, C>
9801    where
9802        T: AsRef<str>,
9803    {
9804        self._additional_params
9805            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9806        self
9807    }
9808
9809    /// Identifies the authorization scope for the method you are building.
9810    ///
9811    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9812    /// [`Scope::CloudPlatform`].
9813    ///
9814    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9815    /// tokens for more than one scope.
9816    ///
9817    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9818    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9819    /// sufficient, a read-write scope will do as well.
9820    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProductSetCreateCall<'a, C>
9821    where
9822        St: AsRef<str>,
9823    {
9824        self._scopes.insert(String::from(scope.as_ref()));
9825        self
9826    }
9827    /// Identifies the authorization scope(s) for the method you are building.
9828    ///
9829    /// See [`Self::add_scope()`] for details.
9830    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProductSetCreateCall<'a, C>
9831    where
9832        I: IntoIterator<Item = St>,
9833        St: AsRef<str>,
9834    {
9835        self._scopes
9836            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9837        self
9838    }
9839
9840    /// Removes all scopes, and no default scope will be used either.
9841    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9842    /// for details).
9843    pub fn clear_scopes(mut self) -> ProjectLocationProductSetCreateCall<'a, C> {
9844        self._scopes.clear();
9845        self
9846    }
9847}
9848
9849/// Permanently deletes a ProductSet. Products and ReferenceImages in the ProductSet are not deleted. The actual image files are not deleted from Google Cloud Storage.
9850///
9851/// A builder for the *locations.productSets.delete* method supported by a *project* resource.
9852/// It is not used directly, but through a [`ProjectMethods`] instance.
9853///
9854/// # Example
9855///
9856/// Instantiate a resource method builder
9857///
9858/// ```test_harness,no_run
9859/// # extern crate hyper;
9860/// # extern crate hyper_rustls;
9861/// # extern crate google_vision1 as vision1;
9862/// # async fn dox() {
9863/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9864///
9865/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9866/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9867/// #     .with_native_roots()
9868/// #     .unwrap()
9869/// #     .https_only()
9870/// #     .enable_http2()
9871/// #     .build();
9872///
9873/// # let executor = hyper_util::rt::TokioExecutor::new();
9874/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9875/// #     secret,
9876/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9877/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9878/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9879/// #     ),
9880/// # ).build().await.unwrap();
9881///
9882/// # let client = hyper_util::client::legacy::Client::builder(
9883/// #     hyper_util::rt::TokioExecutor::new()
9884/// # )
9885/// # .build(
9886/// #     hyper_rustls::HttpsConnectorBuilder::new()
9887/// #         .with_native_roots()
9888/// #         .unwrap()
9889/// #         .https_or_http()
9890/// #         .enable_http2()
9891/// #         .build()
9892/// # );
9893/// # let mut hub = Vision::new(client, auth);
9894/// // You can configure optional parameters by calling the respective setters at will, and
9895/// // execute the final call using `doit()`.
9896/// // Values shown here are possibly random and not representative !
9897/// let result = hub.projects().locations_product_sets_delete("name")
9898///              .doit().await;
9899/// # }
9900/// ```
9901pub struct ProjectLocationProductSetDeleteCall<'a, C>
9902where
9903    C: 'a,
9904{
9905    hub: &'a Vision<C>,
9906    _name: String,
9907    _delegate: Option<&'a mut dyn common::Delegate>,
9908    _additional_params: HashMap<String, String>,
9909    _scopes: BTreeSet<String>,
9910}
9911
9912impl<'a, C> common::CallBuilder for ProjectLocationProductSetDeleteCall<'a, C> {}
9913
9914impl<'a, C> ProjectLocationProductSetDeleteCall<'a, C>
9915where
9916    C: common::Connector,
9917{
9918    /// Perform the operation you have build so far.
9919    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
9920        use std::borrow::Cow;
9921        use std::io::{Read, Seek};
9922
9923        use common::{url::Params, ToParts};
9924        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9925
9926        let mut dd = common::DefaultDelegate;
9927        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9928        dlg.begin(common::MethodInfo {
9929            id: "vision.projects.locations.productSets.delete",
9930            http_method: hyper::Method::DELETE,
9931        });
9932
9933        for &field in ["alt", "name"].iter() {
9934            if self._additional_params.contains_key(field) {
9935                dlg.finished(false);
9936                return Err(common::Error::FieldClash(field));
9937            }
9938        }
9939
9940        let mut params = Params::with_capacity(3 + self._additional_params.len());
9941        params.push("name", self._name);
9942
9943        params.extend(self._additional_params.iter());
9944
9945        params.push("alt", "json");
9946        let mut url = self.hub._base_url.clone() + "v1/{+name}";
9947        if self._scopes.is_empty() {
9948            self._scopes
9949                .insert(Scope::CloudPlatform.as_ref().to_string());
9950        }
9951
9952        #[allow(clippy::single_element_loop)]
9953        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9954            url = params.uri_replacement(url, param_name, find_this, true);
9955        }
9956        {
9957            let to_remove = ["name"];
9958            params.remove_params(&to_remove);
9959        }
9960
9961        let url = params.parse_with_url(&url);
9962
9963        loop {
9964            let token = match self
9965                .hub
9966                .auth
9967                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9968                .await
9969            {
9970                Ok(token) => token,
9971                Err(e) => match dlg.token(e) {
9972                    Ok(token) => token,
9973                    Err(e) => {
9974                        dlg.finished(false);
9975                        return Err(common::Error::MissingToken(e));
9976                    }
9977                },
9978            };
9979            let mut req_result = {
9980                let client = &self.hub.client;
9981                dlg.pre_request();
9982                let mut req_builder = hyper::Request::builder()
9983                    .method(hyper::Method::DELETE)
9984                    .uri(url.as_str())
9985                    .header(USER_AGENT, self.hub._user_agent.clone());
9986
9987                if let Some(token) = token.as_ref() {
9988                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9989                }
9990
9991                let request = req_builder
9992                    .header(CONTENT_LENGTH, 0_u64)
9993                    .body(common::to_body::<String>(None));
9994
9995                client.request(request.unwrap()).await
9996            };
9997
9998            match req_result {
9999                Err(err) => {
10000                    if let common::Retry::After(d) = dlg.http_error(&err) {
10001                        sleep(d).await;
10002                        continue;
10003                    }
10004                    dlg.finished(false);
10005                    return Err(common::Error::HttpError(err));
10006                }
10007                Ok(res) => {
10008                    let (mut parts, body) = res.into_parts();
10009                    let mut body = common::Body::new(body);
10010                    if !parts.status.is_success() {
10011                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10012                        let error = serde_json::from_str(&common::to_string(&bytes));
10013                        let response = common::to_response(parts, bytes.into());
10014
10015                        if let common::Retry::After(d) =
10016                            dlg.http_failure(&response, error.as_ref().ok())
10017                        {
10018                            sleep(d).await;
10019                            continue;
10020                        }
10021
10022                        dlg.finished(false);
10023
10024                        return Err(match error {
10025                            Ok(value) => common::Error::BadRequest(value),
10026                            _ => common::Error::Failure(response),
10027                        });
10028                    }
10029                    let response = {
10030                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10031                        let encoded = common::to_string(&bytes);
10032                        match serde_json::from_str(&encoded) {
10033                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10034                            Err(error) => {
10035                                dlg.response_json_decode_error(&encoded, &error);
10036                                return Err(common::Error::JsonDecodeError(
10037                                    encoded.to_string(),
10038                                    error,
10039                                ));
10040                            }
10041                        }
10042                    };
10043
10044                    dlg.finished(true);
10045                    return Ok(response);
10046                }
10047            }
10048        }
10049    }
10050
10051    /// Required. Resource name of the ProductSet to delete. Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
10052    ///
10053    /// Sets the *name* path property to the given value.
10054    ///
10055    /// Even though the property as already been set when instantiating this call,
10056    /// we provide this method for API completeness.
10057    pub fn name(mut self, new_value: &str) -> ProjectLocationProductSetDeleteCall<'a, C> {
10058        self._name = new_value.to_string();
10059        self
10060    }
10061    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10062    /// while executing the actual API request.
10063    ///
10064    /// ````text
10065    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10066    /// ````
10067    ///
10068    /// Sets the *delegate* property to the given value.
10069    pub fn delegate(
10070        mut self,
10071        new_value: &'a mut dyn common::Delegate,
10072    ) -> ProjectLocationProductSetDeleteCall<'a, C> {
10073        self._delegate = Some(new_value);
10074        self
10075    }
10076
10077    /// Set any additional parameter of the query string used in the request.
10078    /// It should be used to set parameters which are not yet available through their own
10079    /// setters.
10080    ///
10081    /// Please note that this method must not be used to set any of the known parameters
10082    /// which have their own setter method. If done anyway, the request will fail.
10083    ///
10084    /// # Additional Parameters
10085    ///
10086    /// * *$.xgafv* (query-string) - V1 error format.
10087    /// * *access_token* (query-string) - OAuth access token.
10088    /// * *alt* (query-string) - Data format for response.
10089    /// * *callback* (query-string) - JSONP
10090    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10091    /// * *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.
10092    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10093    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10094    /// * *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.
10095    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10096    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10097    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProductSetDeleteCall<'a, C>
10098    where
10099        T: AsRef<str>,
10100    {
10101        self._additional_params
10102            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10103        self
10104    }
10105
10106    /// Identifies the authorization scope for the method you are building.
10107    ///
10108    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10109    /// [`Scope::CloudPlatform`].
10110    ///
10111    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10112    /// tokens for more than one scope.
10113    ///
10114    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10115    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10116    /// sufficient, a read-write scope will do as well.
10117    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProductSetDeleteCall<'a, C>
10118    where
10119        St: AsRef<str>,
10120    {
10121        self._scopes.insert(String::from(scope.as_ref()));
10122        self
10123    }
10124    /// Identifies the authorization scope(s) for the method you are building.
10125    ///
10126    /// See [`Self::add_scope()`] for details.
10127    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProductSetDeleteCall<'a, C>
10128    where
10129        I: IntoIterator<Item = St>,
10130        St: AsRef<str>,
10131    {
10132        self._scopes
10133            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10134        self
10135    }
10136
10137    /// Removes all scopes, and no default scope will be used either.
10138    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10139    /// for details).
10140    pub fn clear_scopes(mut self) -> ProjectLocationProductSetDeleteCall<'a, C> {
10141        self._scopes.clear();
10142        self
10143    }
10144}
10145
10146/// Gets information associated with a ProductSet. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist.
10147///
10148/// A builder for the *locations.productSets.get* method supported by a *project* resource.
10149/// It is not used directly, but through a [`ProjectMethods`] instance.
10150///
10151/// # Example
10152///
10153/// Instantiate a resource method builder
10154///
10155/// ```test_harness,no_run
10156/// # extern crate hyper;
10157/// # extern crate hyper_rustls;
10158/// # extern crate google_vision1 as vision1;
10159/// # async fn dox() {
10160/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10161///
10162/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10163/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10164/// #     .with_native_roots()
10165/// #     .unwrap()
10166/// #     .https_only()
10167/// #     .enable_http2()
10168/// #     .build();
10169///
10170/// # let executor = hyper_util::rt::TokioExecutor::new();
10171/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10172/// #     secret,
10173/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10174/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10175/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10176/// #     ),
10177/// # ).build().await.unwrap();
10178///
10179/// # let client = hyper_util::client::legacy::Client::builder(
10180/// #     hyper_util::rt::TokioExecutor::new()
10181/// # )
10182/// # .build(
10183/// #     hyper_rustls::HttpsConnectorBuilder::new()
10184/// #         .with_native_roots()
10185/// #         .unwrap()
10186/// #         .https_or_http()
10187/// #         .enable_http2()
10188/// #         .build()
10189/// # );
10190/// # let mut hub = Vision::new(client, auth);
10191/// // You can configure optional parameters by calling the respective setters at will, and
10192/// // execute the final call using `doit()`.
10193/// // Values shown here are possibly random and not representative !
10194/// let result = hub.projects().locations_product_sets_get("name")
10195///              .doit().await;
10196/// # }
10197/// ```
10198pub struct ProjectLocationProductSetGetCall<'a, C>
10199where
10200    C: 'a,
10201{
10202    hub: &'a Vision<C>,
10203    _name: String,
10204    _delegate: Option<&'a mut dyn common::Delegate>,
10205    _additional_params: HashMap<String, String>,
10206    _scopes: BTreeSet<String>,
10207}
10208
10209impl<'a, C> common::CallBuilder for ProjectLocationProductSetGetCall<'a, C> {}
10210
10211impl<'a, C> ProjectLocationProductSetGetCall<'a, C>
10212where
10213    C: common::Connector,
10214{
10215    /// Perform the operation you have build so far.
10216    pub async fn doit(mut self) -> common::Result<(common::Response, ProductSet)> {
10217        use std::borrow::Cow;
10218        use std::io::{Read, Seek};
10219
10220        use common::{url::Params, ToParts};
10221        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10222
10223        let mut dd = common::DefaultDelegate;
10224        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10225        dlg.begin(common::MethodInfo {
10226            id: "vision.projects.locations.productSets.get",
10227            http_method: hyper::Method::GET,
10228        });
10229
10230        for &field in ["alt", "name"].iter() {
10231            if self._additional_params.contains_key(field) {
10232                dlg.finished(false);
10233                return Err(common::Error::FieldClash(field));
10234            }
10235        }
10236
10237        let mut params = Params::with_capacity(3 + self._additional_params.len());
10238        params.push("name", self._name);
10239
10240        params.extend(self._additional_params.iter());
10241
10242        params.push("alt", "json");
10243        let mut url = self.hub._base_url.clone() + "v1/{+name}";
10244        if self._scopes.is_empty() {
10245            self._scopes
10246                .insert(Scope::CloudPlatform.as_ref().to_string());
10247        }
10248
10249        #[allow(clippy::single_element_loop)]
10250        for &(find_this, param_name) in [("{+name}", "name")].iter() {
10251            url = params.uri_replacement(url, param_name, find_this, true);
10252        }
10253        {
10254            let to_remove = ["name"];
10255            params.remove_params(&to_remove);
10256        }
10257
10258        let url = params.parse_with_url(&url);
10259
10260        loop {
10261            let token = match self
10262                .hub
10263                .auth
10264                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10265                .await
10266            {
10267                Ok(token) => token,
10268                Err(e) => match dlg.token(e) {
10269                    Ok(token) => token,
10270                    Err(e) => {
10271                        dlg.finished(false);
10272                        return Err(common::Error::MissingToken(e));
10273                    }
10274                },
10275            };
10276            let mut req_result = {
10277                let client = &self.hub.client;
10278                dlg.pre_request();
10279                let mut req_builder = hyper::Request::builder()
10280                    .method(hyper::Method::GET)
10281                    .uri(url.as_str())
10282                    .header(USER_AGENT, self.hub._user_agent.clone());
10283
10284                if let Some(token) = token.as_ref() {
10285                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10286                }
10287
10288                let request = req_builder
10289                    .header(CONTENT_LENGTH, 0_u64)
10290                    .body(common::to_body::<String>(None));
10291
10292                client.request(request.unwrap()).await
10293            };
10294
10295            match req_result {
10296                Err(err) => {
10297                    if let common::Retry::After(d) = dlg.http_error(&err) {
10298                        sleep(d).await;
10299                        continue;
10300                    }
10301                    dlg.finished(false);
10302                    return Err(common::Error::HttpError(err));
10303                }
10304                Ok(res) => {
10305                    let (mut parts, body) = res.into_parts();
10306                    let mut body = common::Body::new(body);
10307                    if !parts.status.is_success() {
10308                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10309                        let error = serde_json::from_str(&common::to_string(&bytes));
10310                        let response = common::to_response(parts, bytes.into());
10311
10312                        if let common::Retry::After(d) =
10313                            dlg.http_failure(&response, error.as_ref().ok())
10314                        {
10315                            sleep(d).await;
10316                            continue;
10317                        }
10318
10319                        dlg.finished(false);
10320
10321                        return Err(match error {
10322                            Ok(value) => common::Error::BadRequest(value),
10323                            _ => common::Error::Failure(response),
10324                        });
10325                    }
10326                    let response = {
10327                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10328                        let encoded = common::to_string(&bytes);
10329                        match serde_json::from_str(&encoded) {
10330                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10331                            Err(error) => {
10332                                dlg.response_json_decode_error(&encoded, &error);
10333                                return Err(common::Error::JsonDecodeError(
10334                                    encoded.to_string(),
10335                                    error,
10336                                ));
10337                            }
10338                        }
10339                    };
10340
10341                    dlg.finished(true);
10342                    return Ok(response);
10343                }
10344            }
10345        }
10346    }
10347
10348    /// Required. Resource name of the ProductSet to get. Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
10349    ///
10350    /// Sets the *name* path property to the given value.
10351    ///
10352    /// Even though the property as already been set when instantiating this call,
10353    /// we provide this method for API completeness.
10354    pub fn name(mut self, new_value: &str) -> ProjectLocationProductSetGetCall<'a, C> {
10355        self._name = new_value.to_string();
10356        self
10357    }
10358    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10359    /// while executing the actual API request.
10360    ///
10361    /// ````text
10362    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10363    /// ````
10364    ///
10365    /// Sets the *delegate* property to the given value.
10366    pub fn delegate(
10367        mut self,
10368        new_value: &'a mut dyn common::Delegate,
10369    ) -> ProjectLocationProductSetGetCall<'a, C> {
10370        self._delegate = Some(new_value);
10371        self
10372    }
10373
10374    /// Set any additional parameter of the query string used in the request.
10375    /// It should be used to set parameters which are not yet available through their own
10376    /// setters.
10377    ///
10378    /// Please note that this method must not be used to set any of the known parameters
10379    /// which have their own setter method. If done anyway, the request will fail.
10380    ///
10381    /// # Additional Parameters
10382    ///
10383    /// * *$.xgafv* (query-string) - V1 error format.
10384    /// * *access_token* (query-string) - OAuth access token.
10385    /// * *alt* (query-string) - Data format for response.
10386    /// * *callback* (query-string) - JSONP
10387    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10388    /// * *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.
10389    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10390    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10391    /// * *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.
10392    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10393    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10394    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProductSetGetCall<'a, C>
10395    where
10396        T: AsRef<str>,
10397    {
10398        self._additional_params
10399            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10400        self
10401    }
10402
10403    /// Identifies the authorization scope for the method you are building.
10404    ///
10405    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10406    /// [`Scope::CloudPlatform`].
10407    ///
10408    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10409    /// tokens for more than one scope.
10410    ///
10411    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10412    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10413    /// sufficient, a read-write scope will do as well.
10414    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProductSetGetCall<'a, C>
10415    where
10416        St: AsRef<str>,
10417    {
10418        self._scopes.insert(String::from(scope.as_ref()));
10419        self
10420    }
10421    /// Identifies the authorization scope(s) for the method you are building.
10422    ///
10423    /// See [`Self::add_scope()`] for details.
10424    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProductSetGetCall<'a, C>
10425    where
10426        I: IntoIterator<Item = St>,
10427        St: AsRef<str>,
10428    {
10429        self._scopes
10430            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10431        self
10432    }
10433
10434    /// Removes all scopes, and no default scope will be used either.
10435    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10436    /// for details).
10437    pub fn clear_scopes(mut self) -> ProjectLocationProductSetGetCall<'a, C> {
10438        self._scopes.clear();
10439        self
10440    }
10441}
10442
10443/// Asynchronous API that imports a list of reference images to specified product sets based on a list of image information. The google.longrunning.Operation API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress) `Operation.response` contains `ImportProductSetsResponse`. (results) The input source of this method is a csv file on Google Cloud Storage. For the format of the csv file please see ImportProductSetsGcsSource.csv_file_uri.
10444///
10445/// A builder for the *locations.productSets.import* method supported by a *project* resource.
10446/// It is not used directly, but through a [`ProjectMethods`] instance.
10447///
10448/// # Example
10449///
10450/// Instantiate a resource method builder
10451///
10452/// ```test_harness,no_run
10453/// # extern crate hyper;
10454/// # extern crate hyper_rustls;
10455/// # extern crate google_vision1 as vision1;
10456/// use vision1::api::ImportProductSetsRequest;
10457/// # async fn dox() {
10458/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10459///
10460/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10461/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10462/// #     .with_native_roots()
10463/// #     .unwrap()
10464/// #     .https_only()
10465/// #     .enable_http2()
10466/// #     .build();
10467///
10468/// # let executor = hyper_util::rt::TokioExecutor::new();
10469/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10470/// #     secret,
10471/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10472/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10473/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10474/// #     ),
10475/// # ).build().await.unwrap();
10476///
10477/// # let client = hyper_util::client::legacy::Client::builder(
10478/// #     hyper_util::rt::TokioExecutor::new()
10479/// # )
10480/// # .build(
10481/// #     hyper_rustls::HttpsConnectorBuilder::new()
10482/// #         .with_native_roots()
10483/// #         .unwrap()
10484/// #         .https_or_http()
10485/// #         .enable_http2()
10486/// #         .build()
10487/// # );
10488/// # let mut hub = Vision::new(client, auth);
10489/// // As the method needs a request, you would usually fill it with the desired information
10490/// // into the respective structure. Some of the parts shown here might not be applicable !
10491/// // Values shown here are possibly random and not representative !
10492/// let mut req = ImportProductSetsRequest::default();
10493///
10494/// // You can configure optional parameters by calling the respective setters at will, and
10495/// // execute the final call using `doit()`.
10496/// // Values shown here are possibly random and not representative !
10497/// let result = hub.projects().locations_product_sets_import(req, "parent")
10498///              .doit().await;
10499/// # }
10500/// ```
10501pub struct ProjectLocationProductSetImportCall<'a, C>
10502where
10503    C: 'a,
10504{
10505    hub: &'a Vision<C>,
10506    _request: ImportProductSetsRequest,
10507    _parent: String,
10508    _delegate: Option<&'a mut dyn common::Delegate>,
10509    _additional_params: HashMap<String, String>,
10510    _scopes: BTreeSet<String>,
10511}
10512
10513impl<'a, C> common::CallBuilder for ProjectLocationProductSetImportCall<'a, C> {}
10514
10515impl<'a, C> ProjectLocationProductSetImportCall<'a, C>
10516where
10517    C: common::Connector,
10518{
10519    /// Perform the operation you have build so far.
10520    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
10521        use std::borrow::Cow;
10522        use std::io::{Read, Seek};
10523
10524        use common::{url::Params, ToParts};
10525        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10526
10527        let mut dd = common::DefaultDelegate;
10528        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10529        dlg.begin(common::MethodInfo {
10530            id: "vision.projects.locations.productSets.import",
10531            http_method: hyper::Method::POST,
10532        });
10533
10534        for &field in ["alt", "parent"].iter() {
10535            if self._additional_params.contains_key(field) {
10536                dlg.finished(false);
10537                return Err(common::Error::FieldClash(field));
10538            }
10539        }
10540
10541        let mut params = Params::with_capacity(4 + self._additional_params.len());
10542        params.push("parent", self._parent);
10543
10544        params.extend(self._additional_params.iter());
10545
10546        params.push("alt", "json");
10547        let mut url = self.hub._base_url.clone() + "v1/{+parent}/productSets:import";
10548        if self._scopes.is_empty() {
10549            self._scopes
10550                .insert(Scope::CloudPlatform.as_ref().to_string());
10551        }
10552
10553        #[allow(clippy::single_element_loop)]
10554        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
10555            url = params.uri_replacement(url, param_name, find_this, true);
10556        }
10557        {
10558            let to_remove = ["parent"];
10559            params.remove_params(&to_remove);
10560        }
10561
10562        let url = params.parse_with_url(&url);
10563
10564        let mut json_mime_type = mime::APPLICATION_JSON;
10565        let mut request_value_reader = {
10566            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10567            common::remove_json_null_values(&mut value);
10568            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10569            serde_json::to_writer(&mut dst, &value).unwrap();
10570            dst
10571        };
10572        let request_size = request_value_reader
10573            .seek(std::io::SeekFrom::End(0))
10574            .unwrap();
10575        request_value_reader
10576            .seek(std::io::SeekFrom::Start(0))
10577            .unwrap();
10578
10579        loop {
10580            let token = match self
10581                .hub
10582                .auth
10583                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10584                .await
10585            {
10586                Ok(token) => token,
10587                Err(e) => match dlg.token(e) {
10588                    Ok(token) => token,
10589                    Err(e) => {
10590                        dlg.finished(false);
10591                        return Err(common::Error::MissingToken(e));
10592                    }
10593                },
10594            };
10595            request_value_reader
10596                .seek(std::io::SeekFrom::Start(0))
10597                .unwrap();
10598            let mut req_result = {
10599                let client = &self.hub.client;
10600                dlg.pre_request();
10601                let mut req_builder = hyper::Request::builder()
10602                    .method(hyper::Method::POST)
10603                    .uri(url.as_str())
10604                    .header(USER_AGENT, self.hub._user_agent.clone());
10605
10606                if let Some(token) = token.as_ref() {
10607                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10608                }
10609
10610                let request = req_builder
10611                    .header(CONTENT_TYPE, json_mime_type.to_string())
10612                    .header(CONTENT_LENGTH, request_size as u64)
10613                    .body(common::to_body(
10614                        request_value_reader.get_ref().clone().into(),
10615                    ));
10616
10617                client.request(request.unwrap()).await
10618            };
10619
10620            match req_result {
10621                Err(err) => {
10622                    if let common::Retry::After(d) = dlg.http_error(&err) {
10623                        sleep(d).await;
10624                        continue;
10625                    }
10626                    dlg.finished(false);
10627                    return Err(common::Error::HttpError(err));
10628                }
10629                Ok(res) => {
10630                    let (mut parts, body) = res.into_parts();
10631                    let mut body = common::Body::new(body);
10632                    if !parts.status.is_success() {
10633                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10634                        let error = serde_json::from_str(&common::to_string(&bytes));
10635                        let response = common::to_response(parts, bytes.into());
10636
10637                        if let common::Retry::After(d) =
10638                            dlg.http_failure(&response, error.as_ref().ok())
10639                        {
10640                            sleep(d).await;
10641                            continue;
10642                        }
10643
10644                        dlg.finished(false);
10645
10646                        return Err(match error {
10647                            Ok(value) => common::Error::BadRequest(value),
10648                            _ => common::Error::Failure(response),
10649                        });
10650                    }
10651                    let response = {
10652                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10653                        let encoded = common::to_string(&bytes);
10654                        match serde_json::from_str(&encoded) {
10655                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10656                            Err(error) => {
10657                                dlg.response_json_decode_error(&encoded, &error);
10658                                return Err(common::Error::JsonDecodeError(
10659                                    encoded.to_string(),
10660                                    error,
10661                                ));
10662                            }
10663                        }
10664                    };
10665
10666                    dlg.finished(true);
10667                    return Ok(response);
10668                }
10669            }
10670        }
10671    }
10672
10673    ///
10674    /// Sets the *request* property to the given value.
10675    ///
10676    /// Even though the property as already been set when instantiating this call,
10677    /// we provide this method for API completeness.
10678    pub fn request(
10679        mut self,
10680        new_value: ImportProductSetsRequest,
10681    ) -> ProjectLocationProductSetImportCall<'a, C> {
10682        self._request = new_value;
10683        self
10684    }
10685    /// Required. The project in which the ProductSets should be imported. Format is `projects/PROJECT_ID/locations/LOC_ID`.
10686    ///
10687    /// Sets the *parent* path property to the given value.
10688    ///
10689    /// Even though the property as already been set when instantiating this call,
10690    /// we provide this method for API completeness.
10691    pub fn parent(mut self, new_value: &str) -> ProjectLocationProductSetImportCall<'a, C> {
10692        self._parent = new_value.to_string();
10693        self
10694    }
10695    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10696    /// while executing the actual API request.
10697    ///
10698    /// ````text
10699    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10700    /// ````
10701    ///
10702    /// Sets the *delegate* property to the given value.
10703    pub fn delegate(
10704        mut self,
10705        new_value: &'a mut dyn common::Delegate,
10706    ) -> ProjectLocationProductSetImportCall<'a, C> {
10707        self._delegate = Some(new_value);
10708        self
10709    }
10710
10711    /// Set any additional parameter of the query string used in the request.
10712    /// It should be used to set parameters which are not yet available through their own
10713    /// setters.
10714    ///
10715    /// Please note that this method must not be used to set any of the known parameters
10716    /// which have their own setter method. If done anyway, the request will fail.
10717    ///
10718    /// # Additional Parameters
10719    ///
10720    /// * *$.xgafv* (query-string) - V1 error format.
10721    /// * *access_token* (query-string) - OAuth access token.
10722    /// * *alt* (query-string) - Data format for response.
10723    /// * *callback* (query-string) - JSONP
10724    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10725    /// * *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.
10726    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10727    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10728    /// * *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.
10729    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10730    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10731    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProductSetImportCall<'a, C>
10732    where
10733        T: AsRef<str>,
10734    {
10735        self._additional_params
10736            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10737        self
10738    }
10739
10740    /// Identifies the authorization scope for the method you are building.
10741    ///
10742    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10743    /// [`Scope::CloudPlatform`].
10744    ///
10745    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10746    /// tokens for more than one scope.
10747    ///
10748    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10749    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10750    /// sufficient, a read-write scope will do as well.
10751    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProductSetImportCall<'a, C>
10752    where
10753        St: AsRef<str>,
10754    {
10755        self._scopes.insert(String::from(scope.as_ref()));
10756        self
10757    }
10758    /// Identifies the authorization scope(s) for the method you are building.
10759    ///
10760    /// See [`Self::add_scope()`] for details.
10761    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProductSetImportCall<'a, C>
10762    where
10763        I: IntoIterator<Item = St>,
10764        St: AsRef<str>,
10765    {
10766        self._scopes
10767            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10768        self
10769    }
10770
10771    /// Removes all scopes, and no default scope will be used either.
10772    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10773    /// for details).
10774    pub fn clear_scopes(mut self) -> ProjectLocationProductSetImportCall<'a, C> {
10775        self._scopes.clear();
10776        self
10777    }
10778}
10779
10780/// Lists ProductSets in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100, or less than 1.
10781///
10782/// A builder for the *locations.productSets.list* method supported by a *project* resource.
10783/// It is not used directly, but through a [`ProjectMethods`] instance.
10784///
10785/// # Example
10786///
10787/// Instantiate a resource method builder
10788///
10789/// ```test_harness,no_run
10790/// # extern crate hyper;
10791/// # extern crate hyper_rustls;
10792/// # extern crate google_vision1 as vision1;
10793/// # async fn dox() {
10794/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10795///
10796/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10797/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10798/// #     .with_native_roots()
10799/// #     .unwrap()
10800/// #     .https_only()
10801/// #     .enable_http2()
10802/// #     .build();
10803///
10804/// # let executor = hyper_util::rt::TokioExecutor::new();
10805/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10806/// #     secret,
10807/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10808/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10809/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10810/// #     ),
10811/// # ).build().await.unwrap();
10812///
10813/// # let client = hyper_util::client::legacy::Client::builder(
10814/// #     hyper_util::rt::TokioExecutor::new()
10815/// # )
10816/// # .build(
10817/// #     hyper_rustls::HttpsConnectorBuilder::new()
10818/// #         .with_native_roots()
10819/// #         .unwrap()
10820/// #         .https_or_http()
10821/// #         .enable_http2()
10822/// #         .build()
10823/// # );
10824/// # let mut hub = Vision::new(client, auth);
10825/// // You can configure optional parameters by calling the respective setters at will, and
10826/// // execute the final call using `doit()`.
10827/// // Values shown here are possibly random and not representative !
10828/// let result = hub.projects().locations_product_sets_list("parent")
10829///              .page_token("et")
10830///              .page_size(-68)
10831///              .doit().await;
10832/// # }
10833/// ```
10834pub struct ProjectLocationProductSetListCall<'a, C>
10835where
10836    C: 'a,
10837{
10838    hub: &'a Vision<C>,
10839    _parent: String,
10840    _page_token: Option<String>,
10841    _page_size: Option<i32>,
10842    _delegate: Option<&'a mut dyn common::Delegate>,
10843    _additional_params: HashMap<String, String>,
10844    _scopes: BTreeSet<String>,
10845}
10846
10847impl<'a, C> common::CallBuilder for ProjectLocationProductSetListCall<'a, C> {}
10848
10849impl<'a, C> ProjectLocationProductSetListCall<'a, C>
10850where
10851    C: common::Connector,
10852{
10853    /// Perform the operation you have build so far.
10854    pub async fn doit(mut self) -> common::Result<(common::Response, ListProductSetsResponse)> {
10855        use std::borrow::Cow;
10856        use std::io::{Read, Seek};
10857
10858        use common::{url::Params, ToParts};
10859        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10860
10861        let mut dd = common::DefaultDelegate;
10862        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10863        dlg.begin(common::MethodInfo {
10864            id: "vision.projects.locations.productSets.list",
10865            http_method: hyper::Method::GET,
10866        });
10867
10868        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
10869            if self._additional_params.contains_key(field) {
10870                dlg.finished(false);
10871                return Err(common::Error::FieldClash(field));
10872            }
10873        }
10874
10875        let mut params = Params::with_capacity(5 + self._additional_params.len());
10876        params.push("parent", self._parent);
10877        if let Some(value) = self._page_token.as_ref() {
10878            params.push("pageToken", value);
10879        }
10880        if let Some(value) = self._page_size.as_ref() {
10881            params.push("pageSize", value.to_string());
10882        }
10883
10884        params.extend(self._additional_params.iter());
10885
10886        params.push("alt", "json");
10887        let mut url = self.hub._base_url.clone() + "v1/{+parent}/productSets";
10888        if self._scopes.is_empty() {
10889            self._scopes
10890                .insert(Scope::CloudPlatform.as_ref().to_string());
10891        }
10892
10893        #[allow(clippy::single_element_loop)]
10894        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
10895            url = params.uri_replacement(url, param_name, find_this, true);
10896        }
10897        {
10898            let to_remove = ["parent"];
10899            params.remove_params(&to_remove);
10900        }
10901
10902        let url = params.parse_with_url(&url);
10903
10904        loop {
10905            let token = match self
10906                .hub
10907                .auth
10908                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10909                .await
10910            {
10911                Ok(token) => token,
10912                Err(e) => match dlg.token(e) {
10913                    Ok(token) => token,
10914                    Err(e) => {
10915                        dlg.finished(false);
10916                        return Err(common::Error::MissingToken(e));
10917                    }
10918                },
10919            };
10920            let mut req_result = {
10921                let client = &self.hub.client;
10922                dlg.pre_request();
10923                let mut req_builder = hyper::Request::builder()
10924                    .method(hyper::Method::GET)
10925                    .uri(url.as_str())
10926                    .header(USER_AGENT, self.hub._user_agent.clone());
10927
10928                if let Some(token) = token.as_ref() {
10929                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10930                }
10931
10932                let request = req_builder
10933                    .header(CONTENT_LENGTH, 0_u64)
10934                    .body(common::to_body::<String>(None));
10935
10936                client.request(request.unwrap()).await
10937            };
10938
10939            match req_result {
10940                Err(err) => {
10941                    if let common::Retry::After(d) = dlg.http_error(&err) {
10942                        sleep(d).await;
10943                        continue;
10944                    }
10945                    dlg.finished(false);
10946                    return Err(common::Error::HttpError(err));
10947                }
10948                Ok(res) => {
10949                    let (mut parts, body) = res.into_parts();
10950                    let mut body = common::Body::new(body);
10951                    if !parts.status.is_success() {
10952                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10953                        let error = serde_json::from_str(&common::to_string(&bytes));
10954                        let response = common::to_response(parts, bytes.into());
10955
10956                        if let common::Retry::After(d) =
10957                            dlg.http_failure(&response, error.as_ref().ok())
10958                        {
10959                            sleep(d).await;
10960                            continue;
10961                        }
10962
10963                        dlg.finished(false);
10964
10965                        return Err(match error {
10966                            Ok(value) => common::Error::BadRequest(value),
10967                            _ => common::Error::Failure(response),
10968                        });
10969                    }
10970                    let response = {
10971                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10972                        let encoded = common::to_string(&bytes);
10973                        match serde_json::from_str(&encoded) {
10974                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10975                            Err(error) => {
10976                                dlg.response_json_decode_error(&encoded, &error);
10977                                return Err(common::Error::JsonDecodeError(
10978                                    encoded.to_string(),
10979                                    error,
10980                                ));
10981                            }
10982                        }
10983                    };
10984
10985                    dlg.finished(true);
10986                    return Ok(response);
10987                }
10988            }
10989        }
10990    }
10991
10992    /// Required. The project from which ProductSets should be listed. Format is `projects/PROJECT_ID/locations/LOC_ID`.
10993    ///
10994    /// Sets the *parent* path property to the given value.
10995    ///
10996    /// Even though the property as already been set when instantiating this call,
10997    /// we provide this method for API completeness.
10998    pub fn parent(mut self, new_value: &str) -> ProjectLocationProductSetListCall<'a, C> {
10999        self._parent = new_value.to_string();
11000        self
11001    }
11002    /// The next_page_token returned from a previous List request, if any.
11003    ///
11004    /// Sets the *page token* query property to the given value.
11005    pub fn page_token(mut self, new_value: &str) -> ProjectLocationProductSetListCall<'a, C> {
11006        self._page_token = Some(new_value.to_string());
11007        self
11008    }
11009    /// The maximum number of items to return. Default 10, maximum 100.
11010    ///
11011    /// Sets the *page size* query property to the given value.
11012    pub fn page_size(mut self, new_value: i32) -> ProjectLocationProductSetListCall<'a, C> {
11013        self._page_size = Some(new_value);
11014        self
11015    }
11016    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11017    /// while executing the actual API request.
11018    ///
11019    /// ````text
11020    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11021    /// ````
11022    ///
11023    /// Sets the *delegate* property to the given value.
11024    pub fn delegate(
11025        mut self,
11026        new_value: &'a mut dyn common::Delegate,
11027    ) -> ProjectLocationProductSetListCall<'a, C> {
11028        self._delegate = Some(new_value);
11029        self
11030    }
11031
11032    /// Set any additional parameter of the query string used in the request.
11033    /// It should be used to set parameters which are not yet available through their own
11034    /// setters.
11035    ///
11036    /// Please note that this method must not be used to set any of the known parameters
11037    /// which have their own setter method. If done anyway, the request will fail.
11038    ///
11039    /// # Additional Parameters
11040    ///
11041    /// * *$.xgafv* (query-string) - V1 error format.
11042    /// * *access_token* (query-string) - OAuth access token.
11043    /// * *alt* (query-string) - Data format for response.
11044    /// * *callback* (query-string) - JSONP
11045    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11046    /// * *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.
11047    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11048    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11049    /// * *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.
11050    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11051    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11052    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProductSetListCall<'a, C>
11053    where
11054        T: AsRef<str>,
11055    {
11056        self._additional_params
11057            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11058        self
11059    }
11060
11061    /// Identifies the authorization scope for the method you are building.
11062    ///
11063    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11064    /// [`Scope::CloudPlatform`].
11065    ///
11066    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11067    /// tokens for more than one scope.
11068    ///
11069    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11070    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11071    /// sufficient, a read-write scope will do as well.
11072    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProductSetListCall<'a, C>
11073    where
11074        St: AsRef<str>,
11075    {
11076        self._scopes.insert(String::from(scope.as_ref()));
11077        self
11078    }
11079    /// Identifies the authorization scope(s) for the method you are building.
11080    ///
11081    /// See [`Self::add_scope()`] for details.
11082    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProductSetListCall<'a, C>
11083    where
11084        I: IntoIterator<Item = St>,
11085        St: AsRef<str>,
11086    {
11087        self._scopes
11088            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11089        self
11090    }
11091
11092    /// Removes all scopes, and no default scope will be used either.
11093    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11094    /// for details).
11095    pub fn clear_scopes(mut self) -> ProjectLocationProductSetListCall<'a, C> {
11096        self._scopes.clear();
11097        self
11098    }
11099}
11100
11101/// Makes changes to a ProductSet resource. Only display_name can be updated currently. Possible errors: * Returns NOT_FOUND if the ProductSet does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but missing from the request or longer than 4096 characters.
11102///
11103/// A builder for the *locations.productSets.patch* method supported by a *project* resource.
11104/// It is not used directly, but through a [`ProjectMethods`] instance.
11105///
11106/// # Example
11107///
11108/// Instantiate a resource method builder
11109///
11110/// ```test_harness,no_run
11111/// # extern crate hyper;
11112/// # extern crate hyper_rustls;
11113/// # extern crate google_vision1 as vision1;
11114/// use vision1::api::ProductSet;
11115/// # async fn dox() {
11116/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11117///
11118/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11119/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11120/// #     .with_native_roots()
11121/// #     .unwrap()
11122/// #     .https_only()
11123/// #     .enable_http2()
11124/// #     .build();
11125///
11126/// # let executor = hyper_util::rt::TokioExecutor::new();
11127/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11128/// #     secret,
11129/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11130/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11131/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11132/// #     ),
11133/// # ).build().await.unwrap();
11134///
11135/// # let client = hyper_util::client::legacy::Client::builder(
11136/// #     hyper_util::rt::TokioExecutor::new()
11137/// # )
11138/// # .build(
11139/// #     hyper_rustls::HttpsConnectorBuilder::new()
11140/// #         .with_native_roots()
11141/// #         .unwrap()
11142/// #         .https_or_http()
11143/// #         .enable_http2()
11144/// #         .build()
11145/// # );
11146/// # let mut hub = Vision::new(client, auth);
11147/// // As the method needs a request, you would usually fill it with the desired information
11148/// // into the respective structure. Some of the parts shown here might not be applicable !
11149/// // Values shown here are possibly random and not representative !
11150/// let mut req = ProductSet::default();
11151///
11152/// // You can configure optional parameters by calling the respective setters at will, and
11153/// // execute the final call using `doit()`.
11154/// // Values shown here are possibly random and not representative !
11155/// let result = hub.projects().locations_product_sets_patch(req, "name")
11156///              .update_mask(FieldMask::new::<&str>(&[]))
11157///              .doit().await;
11158/// # }
11159/// ```
11160pub struct ProjectLocationProductSetPatchCall<'a, C>
11161where
11162    C: 'a,
11163{
11164    hub: &'a Vision<C>,
11165    _request: ProductSet,
11166    _name: String,
11167    _update_mask: Option<common::FieldMask>,
11168    _delegate: Option<&'a mut dyn common::Delegate>,
11169    _additional_params: HashMap<String, String>,
11170    _scopes: BTreeSet<String>,
11171}
11172
11173impl<'a, C> common::CallBuilder for ProjectLocationProductSetPatchCall<'a, C> {}
11174
11175impl<'a, C> ProjectLocationProductSetPatchCall<'a, C>
11176where
11177    C: common::Connector,
11178{
11179    /// Perform the operation you have build so far.
11180    pub async fn doit(mut self) -> common::Result<(common::Response, ProductSet)> {
11181        use std::borrow::Cow;
11182        use std::io::{Read, Seek};
11183
11184        use common::{url::Params, ToParts};
11185        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11186
11187        let mut dd = common::DefaultDelegate;
11188        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11189        dlg.begin(common::MethodInfo {
11190            id: "vision.projects.locations.productSets.patch",
11191            http_method: hyper::Method::PATCH,
11192        });
11193
11194        for &field in ["alt", "name", "updateMask"].iter() {
11195            if self._additional_params.contains_key(field) {
11196                dlg.finished(false);
11197                return Err(common::Error::FieldClash(field));
11198            }
11199        }
11200
11201        let mut params = Params::with_capacity(5 + self._additional_params.len());
11202        params.push("name", self._name);
11203        if let Some(value) = self._update_mask.as_ref() {
11204            params.push("updateMask", value.to_string());
11205        }
11206
11207        params.extend(self._additional_params.iter());
11208
11209        params.push("alt", "json");
11210        let mut url = self.hub._base_url.clone() + "v1/{+name}";
11211        if self._scopes.is_empty() {
11212            self._scopes
11213                .insert(Scope::CloudPlatform.as_ref().to_string());
11214        }
11215
11216        #[allow(clippy::single_element_loop)]
11217        for &(find_this, param_name) in [("{+name}", "name")].iter() {
11218            url = params.uri_replacement(url, param_name, find_this, true);
11219        }
11220        {
11221            let to_remove = ["name"];
11222            params.remove_params(&to_remove);
11223        }
11224
11225        let url = params.parse_with_url(&url);
11226
11227        let mut json_mime_type = mime::APPLICATION_JSON;
11228        let mut request_value_reader = {
11229            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11230            common::remove_json_null_values(&mut value);
11231            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11232            serde_json::to_writer(&mut dst, &value).unwrap();
11233            dst
11234        };
11235        let request_size = request_value_reader
11236            .seek(std::io::SeekFrom::End(0))
11237            .unwrap();
11238        request_value_reader
11239            .seek(std::io::SeekFrom::Start(0))
11240            .unwrap();
11241
11242        loop {
11243            let token = match self
11244                .hub
11245                .auth
11246                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11247                .await
11248            {
11249                Ok(token) => token,
11250                Err(e) => match dlg.token(e) {
11251                    Ok(token) => token,
11252                    Err(e) => {
11253                        dlg.finished(false);
11254                        return Err(common::Error::MissingToken(e));
11255                    }
11256                },
11257            };
11258            request_value_reader
11259                .seek(std::io::SeekFrom::Start(0))
11260                .unwrap();
11261            let mut req_result = {
11262                let client = &self.hub.client;
11263                dlg.pre_request();
11264                let mut req_builder = hyper::Request::builder()
11265                    .method(hyper::Method::PATCH)
11266                    .uri(url.as_str())
11267                    .header(USER_AGENT, self.hub._user_agent.clone());
11268
11269                if let Some(token) = token.as_ref() {
11270                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11271                }
11272
11273                let request = req_builder
11274                    .header(CONTENT_TYPE, json_mime_type.to_string())
11275                    .header(CONTENT_LENGTH, request_size as u64)
11276                    .body(common::to_body(
11277                        request_value_reader.get_ref().clone().into(),
11278                    ));
11279
11280                client.request(request.unwrap()).await
11281            };
11282
11283            match req_result {
11284                Err(err) => {
11285                    if let common::Retry::After(d) = dlg.http_error(&err) {
11286                        sleep(d).await;
11287                        continue;
11288                    }
11289                    dlg.finished(false);
11290                    return Err(common::Error::HttpError(err));
11291                }
11292                Ok(res) => {
11293                    let (mut parts, body) = res.into_parts();
11294                    let mut body = common::Body::new(body);
11295                    if !parts.status.is_success() {
11296                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11297                        let error = serde_json::from_str(&common::to_string(&bytes));
11298                        let response = common::to_response(parts, bytes.into());
11299
11300                        if let common::Retry::After(d) =
11301                            dlg.http_failure(&response, error.as_ref().ok())
11302                        {
11303                            sleep(d).await;
11304                            continue;
11305                        }
11306
11307                        dlg.finished(false);
11308
11309                        return Err(match error {
11310                            Ok(value) => common::Error::BadRequest(value),
11311                            _ => common::Error::Failure(response),
11312                        });
11313                    }
11314                    let response = {
11315                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11316                        let encoded = common::to_string(&bytes);
11317                        match serde_json::from_str(&encoded) {
11318                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11319                            Err(error) => {
11320                                dlg.response_json_decode_error(&encoded, &error);
11321                                return Err(common::Error::JsonDecodeError(
11322                                    encoded.to_string(),
11323                                    error,
11324                                ));
11325                            }
11326                        }
11327                    };
11328
11329                    dlg.finished(true);
11330                    return Ok(response);
11331                }
11332            }
11333        }
11334    }
11335
11336    ///
11337    /// Sets the *request* property to the given value.
11338    ///
11339    /// Even though the property as already been set when instantiating this call,
11340    /// we provide this method for API completeness.
11341    pub fn request(mut self, new_value: ProductSet) -> ProjectLocationProductSetPatchCall<'a, C> {
11342        self._request = new_value;
11343        self
11344    }
11345    /// The resource name of the ProductSet. Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`. This field is ignored when creating a ProductSet.
11346    ///
11347    /// Sets the *name* path property to the given value.
11348    ///
11349    /// Even though the property as already been set when instantiating this call,
11350    /// we provide this method for API completeness.
11351    pub fn name(mut self, new_value: &str) -> ProjectLocationProductSetPatchCall<'a, C> {
11352        self._name = new_value.to_string();
11353        self
11354    }
11355    /// The FieldMask that specifies which fields to update. If update_mask isn't specified, all mutable fields are to be updated. Valid mask path is `display_name`.
11356    ///
11357    /// Sets the *update mask* query property to the given value.
11358    pub fn update_mask(
11359        mut self,
11360        new_value: common::FieldMask,
11361    ) -> ProjectLocationProductSetPatchCall<'a, C> {
11362        self._update_mask = Some(new_value);
11363        self
11364    }
11365    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11366    /// while executing the actual API request.
11367    ///
11368    /// ````text
11369    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11370    /// ````
11371    ///
11372    /// Sets the *delegate* property to the given value.
11373    pub fn delegate(
11374        mut self,
11375        new_value: &'a mut dyn common::Delegate,
11376    ) -> ProjectLocationProductSetPatchCall<'a, C> {
11377        self._delegate = Some(new_value);
11378        self
11379    }
11380
11381    /// Set any additional parameter of the query string used in the request.
11382    /// It should be used to set parameters which are not yet available through their own
11383    /// setters.
11384    ///
11385    /// Please note that this method must not be used to set any of the known parameters
11386    /// which have their own setter method. If done anyway, the request will fail.
11387    ///
11388    /// # Additional Parameters
11389    ///
11390    /// * *$.xgafv* (query-string) - V1 error format.
11391    /// * *access_token* (query-string) - OAuth access token.
11392    /// * *alt* (query-string) - Data format for response.
11393    /// * *callback* (query-string) - JSONP
11394    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11395    /// * *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.
11396    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11397    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11398    /// * *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.
11399    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11400    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11401    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProductSetPatchCall<'a, C>
11402    where
11403        T: AsRef<str>,
11404    {
11405        self._additional_params
11406            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11407        self
11408    }
11409
11410    /// Identifies the authorization scope for the method you are building.
11411    ///
11412    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11413    /// [`Scope::CloudPlatform`].
11414    ///
11415    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11416    /// tokens for more than one scope.
11417    ///
11418    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11419    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11420    /// sufficient, a read-write scope will do as well.
11421    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProductSetPatchCall<'a, C>
11422    where
11423        St: AsRef<str>,
11424    {
11425        self._scopes.insert(String::from(scope.as_ref()));
11426        self
11427    }
11428    /// Identifies the authorization scope(s) for the method you are building.
11429    ///
11430    /// See [`Self::add_scope()`] for details.
11431    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProductSetPatchCall<'a, C>
11432    where
11433        I: IntoIterator<Item = St>,
11434        St: AsRef<str>,
11435    {
11436        self._scopes
11437            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11438        self
11439    }
11440
11441    /// Removes all scopes, and no default scope will be used either.
11442    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11443    /// for details).
11444    pub fn clear_scopes(mut self) -> ProjectLocationProductSetPatchCall<'a, C> {
11445        self._scopes.clear();
11446        self
11447    }
11448}
11449
11450/// Removes a Product from the specified ProductSet.
11451///
11452/// A builder for the *locations.productSets.removeProduct* method supported by a *project* resource.
11453/// It is not used directly, but through a [`ProjectMethods`] instance.
11454///
11455/// # Example
11456///
11457/// Instantiate a resource method builder
11458///
11459/// ```test_harness,no_run
11460/// # extern crate hyper;
11461/// # extern crate hyper_rustls;
11462/// # extern crate google_vision1 as vision1;
11463/// use vision1::api::RemoveProductFromProductSetRequest;
11464/// # async fn dox() {
11465/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11466///
11467/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11468/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11469/// #     .with_native_roots()
11470/// #     .unwrap()
11471/// #     .https_only()
11472/// #     .enable_http2()
11473/// #     .build();
11474///
11475/// # let executor = hyper_util::rt::TokioExecutor::new();
11476/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11477/// #     secret,
11478/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11479/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11480/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11481/// #     ),
11482/// # ).build().await.unwrap();
11483///
11484/// # let client = hyper_util::client::legacy::Client::builder(
11485/// #     hyper_util::rt::TokioExecutor::new()
11486/// # )
11487/// # .build(
11488/// #     hyper_rustls::HttpsConnectorBuilder::new()
11489/// #         .with_native_roots()
11490/// #         .unwrap()
11491/// #         .https_or_http()
11492/// #         .enable_http2()
11493/// #         .build()
11494/// # );
11495/// # let mut hub = Vision::new(client, auth);
11496/// // As the method needs a request, you would usually fill it with the desired information
11497/// // into the respective structure. Some of the parts shown here might not be applicable !
11498/// // Values shown here are possibly random and not representative !
11499/// let mut req = RemoveProductFromProductSetRequest::default();
11500///
11501/// // You can configure optional parameters by calling the respective setters at will, and
11502/// // execute the final call using `doit()`.
11503/// // Values shown here are possibly random and not representative !
11504/// let result = hub.projects().locations_product_sets_remove_product(req, "name")
11505///              .doit().await;
11506/// # }
11507/// ```
11508pub struct ProjectLocationProductSetRemoveProductCall<'a, C>
11509where
11510    C: 'a,
11511{
11512    hub: &'a Vision<C>,
11513    _request: RemoveProductFromProductSetRequest,
11514    _name: String,
11515    _delegate: Option<&'a mut dyn common::Delegate>,
11516    _additional_params: HashMap<String, String>,
11517    _scopes: BTreeSet<String>,
11518}
11519
11520impl<'a, C> common::CallBuilder for ProjectLocationProductSetRemoveProductCall<'a, C> {}
11521
11522impl<'a, C> ProjectLocationProductSetRemoveProductCall<'a, C>
11523where
11524    C: common::Connector,
11525{
11526    /// Perform the operation you have build so far.
11527    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
11528        use std::borrow::Cow;
11529        use std::io::{Read, Seek};
11530
11531        use common::{url::Params, ToParts};
11532        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11533
11534        let mut dd = common::DefaultDelegate;
11535        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11536        dlg.begin(common::MethodInfo {
11537            id: "vision.projects.locations.productSets.removeProduct",
11538            http_method: hyper::Method::POST,
11539        });
11540
11541        for &field in ["alt", "name"].iter() {
11542            if self._additional_params.contains_key(field) {
11543                dlg.finished(false);
11544                return Err(common::Error::FieldClash(field));
11545            }
11546        }
11547
11548        let mut params = Params::with_capacity(4 + self._additional_params.len());
11549        params.push("name", self._name);
11550
11551        params.extend(self._additional_params.iter());
11552
11553        params.push("alt", "json");
11554        let mut url = self.hub._base_url.clone() + "v1/{+name}:removeProduct";
11555        if self._scopes.is_empty() {
11556            self._scopes
11557                .insert(Scope::CloudPlatform.as_ref().to_string());
11558        }
11559
11560        #[allow(clippy::single_element_loop)]
11561        for &(find_this, param_name) in [("{+name}", "name")].iter() {
11562            url = params.uri_replacement(url, param_name, find_this, true);
11563        }
11564        {
11565            let to_remove = ["name"];
11566            params.remove_params(&to_remove);
11567        }
11568
11569        let url = params.parse_with_url(&url);
11570
11571        let mut json_mime_type = mime::APPLICATION_JSON;
11572        let mut request_value_reader = {
11573            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11574            common::remove_json_null_values(&mut value);
11575            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11576            serde_json::to_writer(&mut dst, &value).unwrap();
11577            dst
11578        };
11579        let request_size = request_value_reader
11580            .seek(std::io::SeekFrom::End(0))
11581            .unwrap();
11582        request_value_reader
11583            .seek(std::io::SeekFrom::Start(0))
11584            .unwrap();
11585
11586        loop {
11587            let token = match self
11588                .hub
11589                .auth
11590                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11591                .await
11592            {
11593                Ok(token) => token,
11594                Err(e) => match dlg.token(e) {
11595                    Ok(token) => token,
11596                    Err(e) => {
11597                        dlg.finished(false);
11598                        return Err(common::Error::MissingToken(e));
11599                    }
11600                },
11601            };
11602            request_value_reader
11603                .seek(std::io::SeekFrom::Start(0))
11604                .unwrap();
11605            let mut req_result = {
11606                let client = &self.hub.client;
11607                dlg.pre_request();
11608                let mut req_builder = hyper::Request::builder()
11609                    .method(hyper::Method::POST)
11610                    .uri(url.as_str())
11611                    .header(USER_AGENT, self.hub._user_agent.clone());
11612
11613                if let Some(token) = token.as_ref() {
11614                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11615                }
11616
11617                let request = req_builder
11618                    .header(CONTENT_TYPE, json_mime_type.to_string())
11619                    .header(CONTENT_LENGTH, request_size as u64)
11620                    .body(common::to_body(
11621                        request_value_reader.get_ref().clone().into(),
11622                    ));
11623
11624                client.request(request.unwrap()).await
11625            };
11626
11627            match req_result {
11628                Err(err) => {
11629                    if let common::Retry::After(d) = dlg.http_error(&err) {
11630                        sleep(d).await;
11631                        continue;
11632                    }
11633                    dlg.finished(false);
11634                    return Err(common::Error::HttpError(err));
11635                }
11636                Ok(res) => {
11637                    let (mut parts, body) = res.into_parts();
11638                    let mut body = common::Body::new(body);
11639                    if !parts.status.is_success() {
11640                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11641                        let error = serde_json::from_str(&common::to_string(&bytes));
11642                        let response = common::to_response(parts, bytes.into());
11643
11644                        if let common::Retry::After(d) =
11645                            dlg.http_failure(&response, error.as_ref().ok())
11646                        {
11647                            sleep(d).await;
11648                            continue;
11649                        }
11650
11651                        dlg.finished(false);
11652
11653                        return Err(match error {
11654                            Ok(value) => common::Error::BadRequest(value),
11655                            _ => common::Error::Failure(response),
11656                        });
11657                    }
11658                    let response = {
11659                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11660                        let encoded = common::to_string(&bytes);
11661                        match serde_json::from_str(&encoded) {
11662                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11663                            Err(error) => {
11664                                dlg.response_json_decode_error(&encoded, &error);
11665                                return Err(common::Error::JsonDecodeError(
11666                                    encoded.to_string(),
11667                                    error,
11668                                ));
11669                            }
11670                        }
11671                    };
11672
11673                    dlg.finished(true);
11674                    return Ok(response);
11675                }
11676            }
11677        }
11678    }
11679
11680    ///
11681    /// Sets the *request* property to the given value.
11682    ///
11683    /// Even though the property as already been set when instantiating this call,
11684    /// we provide this method for API completeness.
11685    pub fn request(
11686        mut self,
11687        new_value: RemoveProductFromProductSetRequest,
11688    ) -> ProjectLocationProductSetRemoveProductCall<'a, C> {
11689        self._request = new_value;
11690        self
11691    }
11692    /// Required. The resource name for the ProductSet to modify. Format is: `projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID`
11693    ///
11694    /// Sets the *name* path property to the given value.
11695    ///
11696    /// Even though the property as already been set when instantiating this call,
11697    /// we provide this method for API completeness.
11698    pub fn name(mut self, new_value: &str) -> ProjectLocationProductSetRemoveProductCall<'a, C> {
11699        self._name = new_value.to_string();
11700        self
11701    }
11702    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11703    /// while executing the actual API request.
11704    ///
11705    /// ````text
11706    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11707    /// ````
11708    ///
11709    /// Sets the *delegate* property to the given value.
11710    pub fn delegate(
11711        mut self,
11712        new_value: &'a mut dyn common::Delegate,
11713    ) -> ProjectLocationProductSetRemoveProductCall<'a, C> {
11714        self._delegate = Some(new_value);
11715        self
11716    }
11717
11718    /// Set any additional parameter of the query string used in the request.
11719    /// It should be used to set parameters which are not yet available through their own
11720    /// setters.
11721    ///
11722    /// Please note that this method must not be used to set any of the known parameters
11723    /// which have their own setter method. If done anyway, the request will fail.
11724    ///
11725    /// # Additional Parameters
11726    ///
11727    /// * *$.xgafv* (query-string) - V1 error format.
11728    /// * *access_token* (query-string) - OAuth access token.
11729    /// * *alt* (query-string) - Data format for response.
11730    /// * *callback* (query-string) - JSONP
11731    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11732    /// * *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.
11733    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11734    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11735    /// * *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.
11736    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11737    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11738    pub fn param<T>(
11739        mut self,
11740        name: T,
11741        value: T,
11742    ) -> ProjectLocationProductSetRemoveProductCall<'a, C>
11743    where
11744        T: AsRef<str>,
11745    {
11746        self._additional_params
11747            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11748        self
11749    }
11750
11751    /// Identifies the authorization scope for the method you are building.
11752    ///
11753    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11754    /// [`Scope::CloudPlatform`].
11755    ///
11756    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11757    /// tokens for more than one scope.
11758    ///
11759    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11760    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11761    /// sufficient, a read-write scope will do as well.
11762    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProductSetRemoveProductCall<'a, C>
11763    where
11764        St: AsRef<str>,
11765    {
11766        self._scopes.insert(String::from(scope.as_ref()));
11767        self
11768    }
11769    /// Identifies the authorization scope(s) for the method you are building.
11770    ///
11771    /// See [`Self::add_scope()`] for details.
11772    pub fn add_scopes<I, St>(
11773        mut self,
11774        scopes: I,
11775    ) -> ProjectLocationProductSetRemoveProductCall<'a, C>
11776    where
11777        I: IntoIterator<Item = St>,
11778        St: AsRef<str>,
11779    {
11780        self._scopes
11781            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11782        self
11783    }
11784
11785    /// Removes all scopes, and no default scope will be used either.
11786    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11787    /// for details).
11788    pub fn clear_scopes(mut self) -> ProjectLocationProductSetRemoveProductCall<'a, C> {
11789        self._scopes.clear();
11790        self
11791    }
11792}
11793
11794/// Creates and returns a new ReferenceImage resource. The `bounding_poly` field is optional. If `bounding_poly` is not specified, the system will try to detect regions of interest in the image that are compatible with the product_category on the parent product. If it is specified, detection is ALWAYS skipped. The system converts polygons into non-rotated rectangles. Note that the pipeline will resize the image if the image resolution is too large to process (above 50MP). Possible errors: * Returns INVALID_ARGUMENT if the image_uri is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if the product does not exist. * Returns INVALID_ARGUMENT if bounding_poly is not provided, and nothing compatible with the parent product's product_category is detected. * Returns INVALID_ARGUMENT if bounding_poly contains more than 10 polygons.
11795///
11796/// A builder for the *locations.products.referenceImages.create* method supported by a *project* resource.
11797/// It is not used directly, but through a [`ProjectMethods`] instance.
11798///
11799/// # Example
11800///
11801/// Instantiate a resource method builder
11802///
11803/// ```test_harness,no_run
11804/// # extern crate hyper;
11805/// # extern crate hyper_rustls;
11806/// # extern crate google_vision1 as vision1;
11807/// use vision1::api::ReferenceImage;
11808/// # async fn dox() {
11809/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11810///
11811/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11812/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11813/// #     .with_native_roots()
11814/// #     .unwrap()
11815/// #     .https_only()
11816/// #     .enable_http2()
11817/// #     .build();
11818///
11819/// # let executor = hyper_util::rt::TokioExecutor::new();
11820/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11821/// #     secret,
11822/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11823/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11824/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11825/// #     ),
11826/// # ).build().await.unwrap();
11827///
11828/// # let client = hyper_util::client::legacy::Client::builder(
11829/// #     hyper_util::rt::TokioExecutor::new()
11830/// # )
11831/// # .build(
11832/// #     hyper_rustls::HttpsConnectorBuilder::new()
11833/// #         .with_native_roots()
11834/// #         .unwrap()
11835/// #         .https_or_http()
11836/// #         .enable_http2()
11837/// #         .build()
11838/// # );
11839/// # let mut hub = Vision::new(client, auth);
11840/// // As the method needs a request, you would usually fill it with the desired information
11841/// // into the respective structure. Some of the parts shown here might not be applicable !
11842/// // Values shown here are possibly random and not representative !
11843/// let mut req = ReferenceImage::default();
11844///
11845/// // You can configure optional parameters by calling the respective setters at will, and
11846/// // execute the final call using `doit()`.
11847/// // Values shown here are possibly random and not representative !
11848/// let result = hub.projects().locations_products_reference_images_create(req, "parent")
11849///              .reference_image_id("duo")
11850///              .doit().await;
11851/// # }
11852/// ```
11853pub struct ProjectLocationProductReferenceImageCreateCall<'a, C>
11854where
11855    C: 'a,
11856{
11857    hub: &'a Vision<C>,
11858    _request: ReferenceImage,
11859    _parent: String,
11860    _reference_image_id: Option<String>,
11861    _delegate: Option<&'a mut dyn common::Delegate>,
11862    _additional_params: HashMap<String, String>,
11863    _scopes: BTreeSet<String>,
11864}
11865
11866impl<'a, C> common::CallBuilder for ProjectLocationProductReferenceImageCreateCall<'a, C> {}
11867
11868impl<'a, C> ProjectLocationProductReferenceImageCreateCall<'a, C>
11869where
11870    C: common::Connector,
11871{
11872    /// Perform the operation you have build so far.
11873    pub async fn doit(mut self) -> common::Result<(common::Response, ReferenceImage)> {
11874        use std::borrow::Cow;
11875        use std::io::{Read, Seek};
11876
11877        use common::{url::Params, ToParts};
11878        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11879
11880        let mut dd = common::DefaultDelegate;
11881        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11882        dlg.begin(common::MethodInfo {
11883            id: "vision.projects.locations.products.referenceImages.create",
11884            http_method: hyper::Method::POST,
11885        });
11886
11887        for &field in ["alt", "parent", "referenceImageId"].iter() {
11888            if self._additional_params.contains_key(field) {
11889                dlg.finished(false);
11890                return Err(common::Error::FieldClash(field));
11891            }
11892        }
11893
11894        let mut params = Params::with_capacity(5 + self._additional_params.len());
11895        params.push("parent", self._parent);
11896        if let Some(value) = self._reference_image_id.as_ref() {
11897            params.push("referenceImageId", value);
11898        }
11899
11900        params.extend(self._additional_params.iter());
11901
11902        params.push("alt", "json");
11903        let mut url = self.hub._base_url.clone() + "v1/{+parent}/referenceImages";
11904        if self._scopes.is_empty() {
11905            self._scopes
11906                .insert(Scope::CloudPlatform.as_ref().to_string());
11907        }
11908
11909        #[allow(clippy::single_element_loop)]
11910        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
11911            url = params.uri_replacement(url, param_name, find_this, true);
11912        }
11913        {
11914            let to_remove = ["parent"];
11915            params.remove_params(&to_remove);
11916        }
11917
11918        let url = params.parse_with_url(&url);
11919
11920        let mut json_mime_type = mime::APPLICATION_JSON;
11921        let mut request_value_reader = {
11922            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11923            common::remove_json_null_values(&mut value);
11924            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11925            serde_json::to_writer(&mut dst, &value).unwrap();
11926            dst
11927        };
11928        let request_size = request_value_reader
11929            .seek(std::io::SeekFrom::End(0))
11930            .unwrap();
11931        request_value_reader
11932            .seek(std::io::SeekFrom::Start(0))
11933            .unwrap();
11934
11935        loop {
11936            let token = match self
11937                .hub
11938                .auth
11939                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11940                .await
11941            {
11942                Ok(token) => token,
11943                Err(e) => match dlg.token(e) {
11944                    Ok(token) => token,
11945                    Err(e) => {
11946                        dlg.finished(false);
11947                        return Err(common::Error::MissingToken(e));
11948                    }
11949                },
11950            };
11951            request_value_reader
11952                .seek(std::io::SeekFrom::Start(0))
11953                .unwrap();
11954            let mut req_result = {
11955                let client = &self.hub.client;
11956                dlg.pre_request();
11957                let mut req_builder = hyper::Request::builder()
11958                    .method(hyper::Method::POST)
11959                    .uri(url.as_str())
11960                    .header(USER_AGENT, self.hub._user_agent.clone());
11961
11962                if let Some(token) = token.as_ref() {
11963                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11964                }
11965
11966                let request = req_builder
11967                    .header(CONTENT_TYPE, json_mime_type.to_string())
11968                    .header(CONTENT_LENGTH, request_size as u64)
11969                    .body(common::to_body(
11970                        request_value_reader.get_ref().clone().into(),
11971                    ));
11972
11973                client.request(request.unwrap()).await
11974            };
11975
11976            match req_result {
11977                Err(err) => {
11978                    if let common::Retry::After(d) = dlg.http_error(&err) {
11979                        sleep(d).await;
11980                        continue;
11981                    }
11982                    dlg.finished(false);
11983                    return Err(common::Error::HttpError(err));
11984                }
11985                Ok(res) => {
11986                    let (mut parts, body) = res.into_parts();
11987                    let mut body = common::Body::new(body);
11988                    if !parts.status.is_success() {
11989                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11990                        let error = serde_json::from_str(&common::to_string(&bytes));
11991                        let response = common::to_response(parts, bytes.into());
11992
11993                        if let common::Retry::After(d) =
11994                            dlg.http_failure(&response, error.as_ref().ok())
11995                        {
11996                            sleep(d).await;
11997                            continue;
11998                        }
11999
12000                        dlg.finished(false);
12001
12002                        return Err(match error {
12003                            Ok(value) => common::Error::BadRequest(value),
12004                            _ => common::Error::Failure(response),
12005                        });
12006                    }
12007                    let response = {
12008                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12009                        let encoded = common::to_string(&bytes);
12010                        match serde_json::from_str(&encoded) {
12011                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12012                            Err(error) => {
12013                                dlg.response_json_decode_error(&encoded, &error);
12014                                return Err(common::Error::JsonDecodeError(
12015                                    encoded.to_string(),
12016                                    error,
12017                                ));
12018                            }
12019                        }
12020                    };
12021
12022                    dlg.finished(true);
12023                    return Ok(response);
12024                }
12025            }
12026        }
12027    }
12028
12029    ///
12030    /// Sets the *request* property to the given value.
12031    ///
12032    /// Even though the property as already been set when instantiating this call,
12033    /// we provide this method for API completeness.
12034    pub fn request(
12035        mut self,
12036        new_value: ReferenceImage,
12037    ) -> ProjectLocationProductReferenceImageCreateCall<'a, C> {
12038        self._request = new_value;
12039        self
12040    }
12041    /// Required. Resource name of the product in which to create the reference image. Format is `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`.
12042    ///
12043    /// Sets the *parent* path property to the given value.
12044    ///
12045    /// Even though the property as already been set when instantiating this call,
12046    /// we provide this method for API completeness.
12047    pub fn parent(
12048        mut self,
12049        new_value: &str,
12050    ) -> ProjectLocationProductReferenceImageCreateCall<'a, C> {
12051        self._parent = new_value.to_string();
12052        self
12053    }
12054    /// A user-supplied resource id for the ReferenceImage to be added. If set, the server will attempt to use this value as the resource id. If it is already in use, an error is returned with code ALREADY_EXISTS. Must be at most 128 characters long. It cannot contain the character `/`.
12055    ///
12056    /// Sets the *reference image id* query property to the given value.
12057    pub fn reference_image_id(
12058        mut self,
12059        new_value: &str,
12060    ) -> ProjectLocationProductReferenceImageCreateCall<'a, C> {
12061        self._reference_image_id = Some(new_value.to_string());
12062        self
12063    }
12064    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12065    /// while executing the actual API request.
12066    ///
12067    /// ````text
12068    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12069    /// ````
12070    ///
12071    /// Sets the *delegate* property to the given value.
12072    pub fn delegate(
12073        mut self,
12074        new_value: &'a mut dyn common::Delegate,
12075    ) -> ProjectLocationProductReferenceImageCreateCall<'a, C> {
12076        self._delegate = Some(new_value);
12077        self
12078    }
12079
12080    /// Set any additional parameter of the query string used in the request.
12081    /// It should be used to set parameters which are not yet available through their own
12082    /// setters.
12083    ///
12084    /// Please note that this method must not be used to set any of the known parameters
12085    /// which have their own setter method. If done anyway, the request will fail.
12086    ///
12087    /// # Additional Parameters
12088    ///
12089    /// * *$.xgafv* (query-string) - V1 error format.
12090    /// * *access_token* (query-string) - OAuth access token.
12091    /// * *alt* (query-string) - Data format for response.
12092    /// * *callback* (query-string) - JSONP
12093    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12094    /// * *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.
12095    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12096    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12097    /// * *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.
12098    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12099    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12100    pub fn param<T>(
12101        mut self,
12102        name: T,
12103        value: T,
12104    ) -> ProjectLocationProductReferenceImageCreateCall<'a, C>
12105    where
12106        T: AsRef<str>,
12107    {
12108        self._additional_params
12109            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12110        self
12111    }
12112
12113    /// Identifies the authorization scope for the method you are building.
12114    ///
12115    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12116    /// [`Scope::CloudPlatform`].
12117    ///
12118    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12119    /// tokens for more than one scope.
12120    ///
12121    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12122    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12123    /// sufficient, a read-write scope will do as well.
12124    pub fn add_scope<St>(
12125        mut self,
12126        scope: St,
12127    ) -> ProjectLocationProductReferenceImageCreateCall<'a, C>
12128    where
12129        St: AsRef<str>,
12130    {
12131        self._scopes.insert(String::from(scope.as_ref()));
12132        self
12133    }
12134    /// Identifies the authorization scope(s) for the method you are building.
12135    ///
12136    /// See [`Self::add_scope()`] for details.
12137    pub fn add_scopes<I, St>(
12138        mut self,
12139        scopes: I,
12140    ) -> ProjectLocationProductReferenceImageCreateCall<'a, C>
12141    where
12142        I: IntoIterator<Item = St>,
12143        St: AsRef<str>,
12144    {
12145        self._scopes
12146            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12147        self
12148    }
12149
12150    /// Removes all scopes, and no default scope will be used either.
12151    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12152    /// for details).
12153    pub fn clear_scopes(mut self) -> ProjectLocationProductReferenceImageCreateCall<'a, C> {
12154        self._scopes.clear();
12155        self
12156    }
12157}
12158
12159/// Permanently deletes a reference image. The image metadata will be deleted right away, but search queries against ProductSets containing the image may still work until all related caches are refreshed. The actual image files are not deleted from Google Cloud Storage.
12160///
12161/// A builder for the *locations.products.referenceImages.delete* method supported by a *project* resource.
12162/// It is not used directly, but through a [`ProjectMethods`] instance.
12163///
12164/// # Example
12165///
12166/// Instantiate a resource method builder
12167///
12168/// ```test_harness,no_run
12169/// # extern crate hyper;
12170/// # extern crate hyper_rustls;
12171/// # extern crate google_vision1 as vision1;
12172/// # async fn dox() {
12173/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12174///
12175/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12176/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12177/// #     .with_native_roots()
12178/// #     .unwrap()
12179/// #     .https_only()
12180/// #     .enable_http2()
12181/// #     .build();
12182///
12183/// # let executor = hyper_util::rt::TokioExecutor::new();
12184/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12185/// #     secret,
12186/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12187/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12188/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12189/// #     ),
12190/// # ).build().await.unwrap();
12191///
12192/// # let client = hyper_util::client::legacy::Client::builder(
12193/// #     hyper_util::rt::TokioExecutor::new()
12194/// # )
12195/// # .build(
12196/// #     hyper_rustls::HttpsConnectorBuilder::new()
12197/// #         .with_native_roots()
12198/// #         .unwrap()
12199/// #         .https_or_http()
12200/// #         .enable_http2()
12201/// #         .build()
12202/// # );
12203/// # let mut hub = Vision::new(client, auth);
12204/// // You can configure optional parameters by calling the respective setters at will, and
12205/// // execute the final call using `doit()`.
12206/// // Values shown here are possibly random and not representative !
12207/// let result = hub.projects().locations_products_reference_images_delete("name")
12208///              .doit().await;
12209/// # }
12210/// ```
12211pub struct ProjectLocationProductReferenceImageDeleteCall<'a, C>
12212where
12213    C: 'a,
12214{
12215    hub: &'a Vision<C>,
12216    _name: String,
12217    _delegate: Option<&'a mut dyn common::Delegate>,
12218    _additional_params: HashMap<String, String>,
12219    _scopes: BTreeSet<String>,
12220}
12221
12222impl<'a, C> common::CallBuilder for ProjectLocationProductReferenceImageDeleteCall<'a, C> {}
12223
12224impl<'a, C> ProjectLocationProductReferenceImageDeleteCall<'a, C>
12225where
12226    C: common::Connector,
12227{
12228    /// Perform the operation you have build so far.
12229    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
12230        use std::borrow::Cow;
12231        use std::io::{Read, Seek};
12232
12233        use common::{url::Params, ToParts};
12234        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12235
12236        let mut dd = common::DefaultDelegate;
12237        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12238        dlg.begin(common::MethodInfo {
12239            id: "vision.projects.locations.products.referenceImages.delete",
12240            http_method: hyper::Method::DELETE,
12241        });
12242
12243        for &field in ["alt", "name"].iter() {
12244            if self._additional_params.contains_key(field) {
12245                dlg.finished(false);
12246                return Err(common::Error::FieldClash(field));
12247            }
12248        }
12249
12250        let mut params = Params::with_capacity(3 + self._additional_params.len());
12251        params.push("name", self._name);
12252
12253        params.extend(self._additional_params.iter());
12254
12255        params.push("alt", "json");
12256        let mut url = self.hub._base_url.clone() + "v1/{+name}";
12257        if self._scopes.is_empty() {
12258            self._scopes
12259                .insert(Scope::CloudPlatform.as_ref().to_string());
12260        }
12261
12262        #[allow(clippy::single_element_loop)]
12263        for &(find_this, param_name) in [("{+name}", "name")].iter() {
12264            url = params.uri_replacement(url, param_name, find_this, true);
12265        }
12266        {
12267            let to_remove = ["name"];
12268            params.remove_params(&to_remove);
12269        }
12270
12271        let url = params.parse_with_url(&url);
12272
12273        loop {
12274            let token = match self
12275                .hub
12276                .auth
12277                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12278                .await
12279            {
12280                Ok(token) => token,
12281                Err(e) => match dlg.token(e) {
12282                    Ok(token) => token,
12283                    Err(e) => {
12284                        dlg.finished(false);
12285                        return Err(common::Error::MissingToken(e));
12286                    }
12287                },
12288            };
12289            let mut req_result = {
12290                let client = &self.hub.client;
12291                dlg.pre_request();
12292                let mut req_builder = hyper::Request::builder()
12293                    .method(hyper::Method::DELETE)
12294                    .uri(url.as_str())
12295                    .header(USER_AGENT, self.hub._user_agent.clone());
12296
12297                if let Some(token) = token.as_ref() {
12298                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12299                }
12300
12301                let request = req_builder
12302                    .header(CONTENT_LENGTH, 0_u64)
12303                    .body(common::to_body::<String>(None));
12304
12305                client.request(request.unwrap()).await
12306            };
12307
12308            match req_result {
12309                Err(err) => {
12310                    if let common::Retry::After(d) = dlg.http_error(&err) {
12311                        sleep(d).await;
12312                        continue;
12313                    }
12314                    dlg.finished(false);
12315                    return Err(common::Error::HttpError(err));
12316                }
12317                Ok(res) => {
12318                    let (mut parts, body) = res.into_parts();
12319                    let mut body = common::Body::new(body);
12320                    if !parts.status.is_success() {
12321                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12322                        let error = serde_json::from_str(&common::to_string(&bytes));
12323                        let response = common::to_response(parts, bytes.into());
12324
12325                        if let common::Retry::After(d) =
12326                            dlg.http_failure(&response, error.as_ref().ok())
12327                        {
12328                            sleep(d).await;
12329                            continue;
12330                        }
12331
12332                        dlg.finished(false);
12333
12334                        return Err(match error {
12335                            Ok(value) => common::Error::BadRequest(value),
12336                            _ => common::Error::Failure(response),
12337                        });
12338                    }
12339                    let response = {
12340                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12341                        let encoded = common::to_string(&bytes);
12342                        match serde_json::from_str(&encoded) {
12343                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12344                            Err(error) => {
12345                                dlg.response_json_decode_error(&encoded, &error);
12346                                return Err(common::Error::JsonDecodeError(
12347                                    encoded.to_string(),
12348                                    error,
12349                                ));
12350                            }
12351                        }
12352                    };
12353
12354                    dlg.finished(true);
12355                    return Ok(response);
12356                }
12357            }
12358        }
12359    }
12360
12361    /// Required. The resource name of the reference image to delete. Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`
12362    ///
12363    /// Sets the *name* path property to the given value.
12364    ///
12365    /// Even though the property as already been set when instantiating this call,
12366    /// we provide this method for API completeness.
12367    pub fn name(
12368        mut self,
12369        new_value: &str,
12370    ) -> ProjectLocationProductReferenceImageDeleteCall<'a, C> {
12371        self._name = new_value.to_string();
12372        self
12373    }
12374    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12375    /// while executing the actual API request.
12376    ///
12377    /// ````text
12378    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12379    /// ````
12380    ///
12381    /// Sets the *delegate* property to the given value.
12382    pub fn delegate(
12383        mut self,
12384        new_value: &'a mut dyn common::Delegate,
12385    ) -> ProjectLocationProductReferenceImageDeleteCall<'a, C> {
12386        self._delegate = Some(new_value);
12387        self
12388    }
12389
12390    /// Set any additional parameter of the query string used in the request.
12391    /// It should be used to set parameters which are not yet available through their own
12392    /// setters.
12393    ///
12394    /// Please note that this method must not be used to set any of the known parameters
12395    /// which have their own setter method. If done anyway, the request will fail.
12396    ///
12397    /// # Additional Parameters
12398    ///
12399    /// * *$.xgafv* (query-string) - V1 error format.
12400    /// * *access_token* (query-string) - OAuth access token.
12401    /// * *alt* (query-string) - Data format for response.
12402    /// * *callback* (query-string) - JSONP
12403    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12404    /// * *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.
12405    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12406    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12407    /// * *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.
12408    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12409    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12410    pub fn param<T>(
12411        mut self,
12412        name: T,
12413        value: T,
12414    ) -> ProjectLocationProductReferenceImageDeleteCall<'a, C>
12415    where
12416        T: AsRef<str>,
12417    {
12418        self._additional_params
12419            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12420        self
12421    }
12422
12423    /// Identifies the authorization scope for the method you are building.
12424    ///
12425    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12426    /// [`Scope::CloudPlatform`].
12427    ///
12428    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12429    /// tokens for more than one scope.
12430    ///
12431    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12432    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12433    /// sufficient, a read-write scope will do as well.
12434    pub fn add_scope<St>(
12435        mut self,
12436        scope: St,
12437    ) -> ProjectLocationProductReferenceImageDeleteCall<'a, C>
12438    where
12439        St: AsRef<str>,
12440    {
12441        self._scopes.insert(String::from(scope.as_ref()));
12442        self
12443    }
12444    /// Identifies the authorization scope(s) for the method you are building.
12445    ///
12446    /// See [`Self::add_scope()`] for details.
12447    pub fn add_scopes<I, St>(
12448        mut self,
12449        scopes: I,
12450    ) -> ProjectLocationProductReferenceImageDeleteCall<'a, C>
12451    where
12452        I: IntoIterator<Item = St>,
12453        St: AsRef<str>,
12454    {
12455        self._scopes
12456            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12457        self
12458    }
12459
12460    /// Removes all scopes, and no default scope will be used either.
12461    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12462    /// for details).
12463    pub fn clear_scopes(mut self) -> ProjectLocationProductReferenceImageDeleteCall<'a, C> {
12464        self._scopes.clear();
12465        self
12466    }
12467}
12468
12469/// Gets information associated with a ReferenceImage. Possible errors: * Returns NOT_FOUND if the specified image does not exist.
12470///
12471/// A builder for the *locations.products.referenceImages.get* method supported by a *project* resource.
12472/// It is not used directly, but through a [`ProjectMethods`] instance.
12473///
12474/// # Example
12475///
12476/// Instantiate a resource method builder
12477///
12478/// ```test_harness,no_run
12479/// # extern crate hyper;
12480/// # extern crate hyper_rustls;
12481/// # extern crate google_vision1 as vision1;
12482/// # async fn dox() {
12483/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12484///
12485/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12486/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12487/// #     .with_native_roots()
12488/// #     .unwrap()
12489/// #     .https_only()
12490/// #     .enable_http2()
12491/// #     .build();
12492///
12493/// # let executor = hyper_util::rt::TokioExecutor::new();
12494/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12495/// #     secret,
12496/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12497/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12498/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12499/// #     ),
12500/// # ).build().await.unwrap();
12501///
12502/// # let client = hyper_util::client::legacy::Client::builder(
12503/// #     hyper_util::rt::TokioExecutor::new()
12504/// # )
12505/// # .build(
12506/// #     hyper_rustls::HttpsConnectorBuilder::new()
12507/// #         .with_native_roots()
12508/// #         .unwrap()
12509/// #         .https_or_http()
12510/// #         .enable_http2()
12511/// #         .build()
12512/// # );
12513/// # let mut hub = Vision::new(client, auth);
12514/// // You can configure optional parameters by calling the respective setters at will, and
12515/// // execute the final call using `doit()`.
12516/// // Values shown here are possibly random and not representative !
12517/// let result = hub.projects().locations_products_reference_images_get("name")
12518///              .doit().await;
12519/// # }
12520/// ```
12521pub struct ProjectLocationProductReferenceImageGetCall<'a, C>
12522where
12523    C: 'a,
12524{
12525    hub: &'a Vision<C>,
12526    _name: String,
12527    _delegate: Option<&'a mut dyn common::Delegate>,
12528    _additional_params: HashMap<String, String>,
12529    _scopes: BTreeSet<String>,
12530}
12531
12532impl<'a, C> common::CallBuilder for ProjectLocationProductReferenceImageGetCall<'a, C> {}
12533
12534impl<'a, C> ProjectLocationProductReferenceImageGetCall<'a, C>
12535where
12536    C: common::Connector,
12537{
12538    /// Perform the operation you have build so far.
12539    pub async fn doit(mut self) -> common::Result<(common::Response, ReferenceImage)> {
12540        use std::borrow::Cow;
12541        use std::io::{Read, Seek};
12542
12543        use common::{url::Params, ToParts};
12544        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12545
12546        let mut dd = common::DefaultDelegate;
12547        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12548        dlg.begin(common::MethodInfo {
12549            id: "vision.projects.locations.products.referenceImages.get",
12550            http_method: hyper::Method::GET,
12551        });
12552
12553        for &field in ["alt", "name"].iter() {
12554            if self._additional_params.contains_key(field) {
12555                dlg.finished(false);
12556                return Err(common::Error::FieldClash(field));
12557            }
12558        }
12559
12560        let mut params = Params::with_capacity(3 + self._additional_params.len());
12561        params.push("name", self._name);
12562
12563        params.extend(self._additional_params.iter());
12564
12565        params.push("alt", "json");
12566        let mut url = self.hub._base_url.clone() + "v1/{+name}";
12567        if self._scopes.is_empty() {
12568            self._scopes
12569                .insert(Scope::CloudPlatform.as_ref().to_string());
12570        }
12571
12572        #[allow(clippy::single_element_loop)]
12573        for &(find_this, param_name) in [("{+name}", "name")].iter() {
12574            url = params.uri_replacement(url, param_name, find_this, true);
12575        }
12576        {
12577            let to_remove = ["name"];
12578            params.remove_params(&to_remove);
12579        }
12580
12581        let url = params.parse_with_url(&url);
12582
12583        loop {
12584            let token = match self
12585                .hub
12586                .auth
12587                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12588                .await
12589            {
12590                Ok(token) => token,
12591                Err(e) => match dlg.token(e) {
12592                    Ok(token) => token,
12593                    Err(e) => {
12594                        dlg.finished(false);
12595                        return Err(common::Error::MissingToken(e));
12596                    }
12597                },
12598            };
12599            let mut req_result = {
12600                let client = &self.hub.client;
12601                dlg.pre_request();
12602                let mut req_builder = hyper::Request::builder()
12603                    .method(hyper::Method::GET)
12604                    .uri(url.as_str())
12605                    .header(USER_AGENT, self.hub._user_agent.clone());
12606
12607                if let Some(token) = token.as_ref() {
12608                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12609                }
12610
12611                let request = req_builder
12612                    .header(CONTENT_LENGTH, 0_u64)
12613                    .body(common::to_body::<String>(None));
12614
12615                client.request(request.unwrap()).await
12616            };
12617
12618            match req_result {
12619                Err(err) => {
12620                    if let common::Retry::After(d) = dlg.http_error(&err) {
12621                        sleep(d).await;
12622                        continue;
12623                    }
12624                    dlg.finished(false);
12625                    return Err(common::Error::HttpError(err));
12626                }
12627                Ok(res) => {
12628                    let (mut parts, body) = res.into_parts();
12629                    let mut body = common::Body::new(body);
12630                    if !parts.status.is_success() {
12631                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12632                        let error = serde_json::from_str(&common::to_string(&bytes));
12633                        let response = common::to_response(parts, bytes.into());
12634
12635                        if let common::Retry::After(d) =
12636                            dlg.http_failure(&response, error.as_ref().ok())
12637                        {
12638                            sleep(d).await;
12639                            continue;
12640                        }
12641
12642                        dlg.finished(false);
12643
12644                        return Err(match error {
12645                            Ok(value) => common::Error::BadRequest(value),
12646                            _ => common::Error::Failure(response),
12647                        });
12648                    }
12649                    let response = {
12650                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12651                        let encoded = common::to_string(&bytes);
12652                        match serde_json::from_str(&encoded) {
12653                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12654                            Err(error) => {
12655                                dlg.response_json_decode_error(&encoded, &error);
12656                                return Err(common::Error::JsonDecodeError(
12657                                    encoded.to_string(),
12658                                    error,
12659                                ));
12660                            }
12661                        }
12662                    };
12663
12664                    dlg.finished(true);
12665                    return Ok(response);
12666                }
12667            }
12668        }
12669    }
12670
12671    /// Required. The resource name of the ReferenceImage to get. Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID/referenceImages/IMAGE_ID`.
12672    ///
12673    /// Sets the *name* path property to the given value.
12674    ///
12675    /// Even though the property as already been set when instantiating this call,
12676    /// we provide this method for API completeness.
12677    pub fn name(mut self, new_value: &str) -> ProjectLocationProductReferenceImageGetCall<'a, C> {
12678        self._name = new_value.to_string();
12679        self
12680    }
12681    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12682    /// while executing the actual API request.
12683    ///
12684    /// ````text
12685    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12686    /// ````
12687    ///
12688    /// Sets the *delegate* property to the given value.
12689    pub fn delegate(
12690        mut self,
12691        new_value: &'a mut dyn common::Delegate,
12692    ) -> ProjectLocationProductReferenceImageGetCall<'a, C> {
12693        self._delegate = Some(new_value);
12694        self
12695    }
12696
12697    /// Set any additional parameter of the query string used in the request.
12698    /// It should be used to set parameters which are not yet available through their own
12699    /// setters.
12700    ///
12701    /// Please note that this method must not be used to set any of the known parameters
12702    /// which have their own setter method. If done anyway, the request will fail.
12703    ///
12704    /// # Additional Parameters
12705    ///
12706    /// * *$.xgafv* (query-string) - V1 error format.
12707    /// * *access_token* (query-string) - OAuth access token.
12708    /// * *alt* (query-string) - Data format for response.
12709    /// * *callback* (query-string) - JSONP
12710    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12711    /// * *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.
12712    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12713    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12714    /// * *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.
12715    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12716    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12717    pub fn param<T>(
12718        mut self,
12719        name: T,
12720        value: T,
12721    ) -> ProjectLocationProductReferenceImageGetCall<'a, C>
12722    where
12723        T: AsRef<str>,
12724    {
12725        self._additional_params
12726            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12727        self
12728    }
12729
12730    /// Identifies the authorization scope for the method you are building.
12731    ///
12732    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12733    /// [`Scope::CloudPlatform`].
12734    ///
12735    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12736    /// tokens for more than one scope.
12737    ///
12738    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12739    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12740    /// sufficient, a read-write scope will do as well.
12741    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProductReferenceImageGetCall<'a, C>
12742    where
12743        St: AsRef<str>,
12744    {
12745        self._scopes.insert(String::from(scope.as_ref()));
12746        self
12747    }
12748    /// Identifies the authorization scope(s) for the method you are building.
12749    ///
12750    /// See [`Self::add_scope()`] for details.
12751    pub fn add_scopes<I, St>(
12752        mut self,
12753        scopes: I,
12754    ) -> ProjectLocationProductReferenceImageGetCall<'a, C>
12755    where
12756        I: IntoIterator<Item = St>,
12757        St: AsRef<str>,
12758    {
12759        self._scopes
12760            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12761        self
12762    }
12763
12764    /// Removes all scopes, and no default scope will be used either.
12765    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12766    /// for details).
12767    pub fn clear_scopes(mut self) -> ProjectLocationProductReferenceImageGetCall<'a, C> {
12768        self._scopes.clear();
12769        self
12770    }
12771}
12772
12773/// Lists reference images. Possible errors: * Returns NOT_FOUND if the parent product does not exist. * Returns INVALID_ARGUMENT if the page_size is greater than 100, or less than 1.
12774///
12775/// A builder for the *locations.products.referenceImages.list* method supported by a *project* resource.
12776/// It is not used directly, but through a [`ProjectMethods`] instance.
12777///
12778/// # Example
12779///
12780/// Instantiate a resource method builder
12781///
12782/// ```test_harness,no_run
12783/// # extern crate hyper;
12784/// # extern crate hyper_rustls;
12785/// # extern crate google_vision1 as vision1;
12786/// # async fn dox() {
12787/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12788///
12789/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12790/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12791/// #     .with_native_roots()
12792/// #     .unwrap()
12793/// #     .https_only()
12794/// #     .enable_http2()
12795/// #     .build();
12796///
12797/// # let executor = hyper_util::rt::TokioExecutor::new();
12798/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12799/// #     secret,
12800/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12801/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12802/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12803/// #     ),
12804/// # ).build().await.unwrap();
12805///
12806/// # let client = hyper_util::client::legacy::Client::builder(
12807/// #     hyper_util::rt::TokioExecutor::new()
12808/// # )
12809/// # .build(
12810/// #     hyper_rustls::HttpsConnectorBuilder::new()
12811/// #         .with_native_roots()
12812/// #         .unwrap()
12813/// #         .https_or_http()
12814/// #         .enable_http2()
12815/// #         .build()
12816/// # );
12817/// # let mut hub = Vision::new(client, auth);
12818/// // You can configure optional parameters by calling the respective setters at will, and
12819/// // execute the final call using `doit()`.
12820/// // Values shown here are possibly random and not representative !
12821/// let result = hub.projects().locations_products_reference_images_list("parent")
12822///              .page_token("amet.")
12823///              .page_size(-96)
12824///              .doit().await;
12825/// # }
12826/// ```
12827pub struct ProjectLocationProductReferenceImageListCall<'a, C>
12828where
12829    C: 'a,
12830{
12831    hub: &'a Vision<C>,
12832    _parent: String,
12833    _page_token: Option<String>,
12834    _page_size: Option<i32>,
12835    _delegate: Option<&'a mut dyn common::Delegate>,
12836    _additional_params: HashMap<String, String>,
12837    _scopes: BTreeSet<String>,
12838}
12839
12840impl<'a, C> common::CallBuilder for ProjectLocationProductReferenceImageListCall<'a, C> {}
12841
12842impl<'a, C> ProjectLocationProductReferenceImageListCall<'a, C>
12843where
12844    C: common::Connector,
12845{
12846    /// Perform the operation you have build so far.
12847    pub async fn doit(mut self) -> common::Result<(common::Response, ListReferenceImagesResponse)> {
12848        use std::borrow::Cow;
12849        use std::io::{Read, Seek};
12850
12851        use common::{url::Params, ToParts};
12852        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12853
12854        let mut dd = common::DefaultDelegate;
12855        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12856        dlg.begin(common::MethodInfo {
12857            id: "vision.projects.locations.products.referenceImages.list",
12858            http_method: hyper::Method::GET,
12859        });
12860
12861        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
12862            if self._additional_params.contains_key(field) {
12863                dlg.finished(false);
12864                return Err(common::Error::FieldClash(field));
12865            }
12866        }
12867
12868        let mut params = Params::with_capacity(5 + self._additional_params.len());
12869        params.push("parent", self._parent);
12870        if let Some(value) = self._page_token.as_ref() {
12871            params.push("pageToken", value);
12872        }
12873        if let Some(value) = self._page_size.as_ref() {
12874            params.push("pageSize", value.to_string());
12875        }
12876
12877        params.extend(self._additional_params.iter());
12878
12879        params.push("alt", "json");
12880        let mut url = self.hub._base_url.clone() + "v1/{+parent}/referenceImages";
12881        if self._scopes.is_empty() {
12882            self._scopes
12883                .insert(Scope::CloudPlatform.as_ref().to_string());
12884        }
12885
12886        #[allow(clippy::single_element_loop)]
12887        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
12888            url = params.uri_replacement(url, param_name, find_this, true);
12889        }
12890        {
12891            let to_remove = ["parent"];
12892            params.remove_params(&to_remove);
12893        }
12894
12895        let url = params.parse_with_url(&url);
12896
12897        loop {
12898            let token = match self
12899                .hub
12900                .auth
12901                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12902                .await
12903            {
12904                Ok(token) => token,
12905                Err(e) => match dlg.token(e) {
12906                    Ok(token) => token,
12907                    Err(e) => {
12908                        dlg.finished(false);
12909                        return Err(common::Error::MissingToken(e));
12910                    }
12911                },
12912            };
12913            let mut req_result = {
12914                let client = &self.hub.client;
12915                dlg.pre_request();
12916                let mut req_builder = hyper::Request::builder()
12917                    .method(hyper::Method::GET)
12918                    .uri(url.as_str())
12919                    .header(USER_AGENT, self.hub._user_agent.clone());
12920
12921                if let Some(token) = token.as_ref() {
12922                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12923                }
12924
12925                let request = req_builder
12926                    .header(CONTENT_LENGTH, 0_u64)
12927                    .body(common::to_body::<String>(None));
12928
12929                client.request(request.unwrap()).await
12930            };
12931
12932            match req_result {
12933                Err(err) => {
12934                    if let common::Retry::After(d) = dlg.http_error(&err) {
12935                        sleep(d).await;
12936                        continue;
12937                    }
12938                    dlg.finished(false);
12939                    return Err(common::Error::HttpError(err));
12940                }
12941                Ok(res) => {
12942                    let (mut parts, body) = res.into_parts();
12943                    let mut body = common::Body::new(body);
12944                    if !parts.status.is_success() {
12945                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12946                        let error = serde_json::from_str(&common::to_string(&bytes));
12947                        let response = common::to_response(parts, bytes.into());
12948
12949                        if let common::Retry::After(d) =
12950                            dlg.http_failure(&response, error.as_ref().ok())
12951                        {
12952                            sleep(d).await;
12953                            continue;
12954                        }
12955
12956                        dlg.finished(false);
12957
12958                        return Err(match error {
12959                            Ok(value) => common::Error::BadRequest(value),
12960                            _ => common::Error::Failure(response),
12961                        });
12962                    }
12963                    let response = {
12964                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12965                        let encoded = common::to_string(&bytes);
12966                        match serde_json::from_str(&encoded) {
12967                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12968                            Err(error) => {
12969                                dlg.response_json_decode_error(&encoded, &error);
12970                                return Err(common::Error::JsonDecodeError(
12971                                    encoded.to_string(),
12972                                    error,
12973                                ));
12974                            }
12975                        }
12976                    };
12977
12978                    dlg.finished(true);
12979                    return Ok(response);
12980                }
12981            }
12982        }
12983    }
12984
12985    /// Required. Resource name of the product containing the reference images. Format is `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`.
12986    ///
12987    /// Sets the *parent* path property to the given value.
12988    ///
12989    /// Even though the property as already been set when instantiating this call,
12990    /// we provide this method for API completeness.
12991    pub fn parent(
12992        mut self,
12993        new_value: &str,
12994    ) -> ProjectLocationProductReferenceImageListCall<'a, C> {
12995        self._parent = new_value.to_string();
12996        self
12997    }
12998    /// A token identifying a page of results to be returned. This is the value of `nextPageToken` returned in a previous reference image list request. Defaults to the first page if not specified.
12999    ///
13000    /// Sets the *page token* query property to the given value.
13001    pub fn page_token(
13002        mut self,
13003        new_value: &str,
13004    ) -> ProjectLocationProductReferenceImageListCall<'a, C> {
13005        self._page_token = Some(new_value.to_string());
13006        self
13007    }
13008    /// The maximum number of items to return. Default 10, maximum 100.
13009    ///
13010    /// Sets the *page size* query property to the given value.
13011    pub fn page_size(
13012        mut self,
13013        new_value: i32,
13014    ) -> ProjectLocationProductReferenceImageListCall<'a, C> {
13015        self._page_size = Some(new_value);
13016        self
13017    }
13018    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13019    /// while executing the actual API request.
13020    ///
13021    /// ````text
13022    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13023    /// ````
13024    ///
13025    /// Sets the *delegate* property to the given value.
13026    pub fn delegate(
13027        mut self,
13028        new_value: &'a mut dyn common::Delegate,
13029    ) -> ProjectLocationProductReferenceImageListCall<'a, C> {
13030        self._delegate = Some(new_value);
13031        self
13032    }
13033
13034    /// Set any additional parameter of the query string used in the request.
13035    /// It should be used to set parameters which are not yet available through their own
13036    /// setters.
13037    ///
13038    /// Please note that this method must not be used to set any of the known parameters
13039    /// which have their own setter method. If done anyway, the request will fail.
13040    ///
13041    /// # Additional Parameters
13042    ///
13043    /// * *$.xgafv* (query-string) - V1 error format.
13044    /// * *access_token* (query-string) - OAuth access token.
13045    /// * *alt* (query-string) - Data format for response.
13046    /// * *callback* (query-string) - JSONP
13047    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13048    /// * *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.
13049    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13050    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13051    /// * *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.
13052    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13053    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13054    pub fn param<T>(
13055        mut self,
13056        name: T,
13057        value: T,
13058    ) -> ProjectLocationProductReferenceImageListCall<'a, C>
13059    where
13060        T: AsRef<str>,
13061    {
13062        self._additional_params
13063            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13064        self
13065    }
13066
13067    /// Identifies the authorization scope for the method you are building.
13068    ///
13069    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13070    /// [`Scope::CloudPlatform`].
13071    ///
13072    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13073    /// tokens for more than one scope.
13074    ///
13075    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13076    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13077    /// sufficient, a read-write scope will do as well.
13078    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProductReferenceImageListCall<'a, C>
13079    where
13080        St: AsRef<str>,
13081    {
13082        self._scopes.insert(String::from(scope.as_ref()));
13083        self
13084    }
13085    /// Identifies the authorization scope(s) for the method you are building.
13086    ///
13087    /// See [`Self::add_scope()`] for details.
13088    pub fn add_scopes<I, St>(
13089        mut self,
13090        scopes: I,
13091    ) -> ProjectLocationProductReferenceImageListCall<'a, C>
13092    where
13093        I: IntoIterator<Item = St>,
13094        St: AsRef<str>,
13095    {
13096        self._scopes
13097            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13098        self
13099    }
13100
13101    /// Removes all scopes, and no default scope will be used either.
13102    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13103    /// for details).
13104    pub fn clear_scopes(mut self) -> ProjectLocationProductReferenceImageListCall<'a, C> {
13105        self._scopes.clear();
13106        self
13107    }
13108}
13109
13110/// Creates and returns a new product resource. Possible errors: * Returns INVALID_ARGUMENT if display_name is missing or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is missing or invalid.
13111///
13112/// A builder for the *locations.products.create* method supported by a *project* resource.
13113/// It is not used directly, but through a [`ProjectMethods`] instance.
13114///
13115/// # Example
13116///
13117/// Instantiate a resource method builder
13118///
13119/// ```test_harness,no_run
13120/// # extern crate hyper;
13121/// # extern crate hyper_rustls;
13122/// # extern crate google_vision1 as vision1;
13123/// use vision1::api::Product;
13124/// # async fn dox() {
13125/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13126///
13127/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13128/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13129/// #     .with_native_roots()
13130/// #     .unwrap()
13131/// #     .https_only()
13132/// #     .enable_http2()
13133/// #     .build();
13134///
13135/// # let executor = hyper_util::rt::TokioExecutor::new();
13136/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13137/// #     secret,
13138/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13139/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13140/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13141/// #     ),
13142/// # ).build().await.unwrap();
13143///
13144/// # let client = hyper_util::client::legacy::Client::builder(
13145/// #     hyper_util::rt::TokioExecutor::new()
13146/// # )
13147/// # .build(
13148/// #     hyper_rustls::HttpsConnectorBuilder::new()
13149/// #         .with_native_roots()
13150/// #         .unwrap()
13151/// #         .https_or_http()
13152/// #         .enable_http2()
13153/// #         .build()
13154/// # );
13155/// # let mut hub = Vision::new(client, auth);
13156/// // As the method needs a request, you would usually fill it with the desired information
13157/// // into the respective structure. Some of the parts shown here might not be applicable !
13158/// // Values shown here are possibly random and not representative !
13159/// let mut req = Product::default();
13160///
13161/// // You can configure optional parameters by calling the respective setters at will, and
13162/// // execute the final call using `doit()`.
13163/// // Values shown here are possibly random and not representative !
13164/// let result = hub.projects().locations_products_create(req, "parent")
13165///              .product_id("dolor")
13166///              .doit().await;
13167/// # }
13168/// ```
13169pub struct ProjectLocationProductCreateCall<'a, C>
13170where
13171    C: 'a,
13172{
13173    hub: &'a Vision<C>,
13174    _request: Product,
13175    _parent: String,
13176    _product_id: Option<String>,
13177    _delegate: Option<&'a mut dyn common::Delegate>,
13178    _additional_params: HashMap<String, String>,
13179    _scopes: BTreeSet<String>,
13180}
13181
13182impl<'a, C> common::CallBuilder for ProjectLocationProductCreateCall<'a, C> {}
13183
13184impl<'a, C> ProjectLocationProductCreateCall<'a, C>
13185where
13186    C: common::Connector,
13187{
13188    /// Perform the operation you have build so far.
13189    pub async fn doit(mut self) -> common::Result<(common::Response, Product)> {
13190        use std::borrow::Cow;
13191        use std::io::{Read, Seek};
13192
13193        use common::{url::Params, ToParts};
13194        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13195
13196        let mut dd = common::DefaultDelegate;
13197        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13198        dlg.begin(common::MethodInfo {
13199            id: "vision.projects.locations.products.create",
13200            http_method: hyper::Method::POST,
13201        });
13202
13203        for &field in ["alt", "parent", "productId"].iter() {
13204            if self._additional_params.contains_key(field) {
13205                dlg.finished(false);
13206                return Err(common::Error::FieldClash(field));
13207            }
13208        }
13209
13210        let mut params = Params::with_capacity(5 + self._additional_params.len());
13211        params.push("parent", self._parent);
13212        if let Some(value) = self._product_id.as_ref() {
13213            params.push("productId", value);
13214        }
13215
13216        params.extend(self._additional_params.iter());
13217
13218        params.push("alt", "json");
13219        let mut url = self.hub._base_url.clone() + "v1/{+parent}/products";
13220        if self._scopes.is_empty() {
13221            self._scopes
13222                .insert(Scope::CloudPlatform.as_ref().to_string());
13223        }
13224
13225        #[allow(clippy::single_element_loop)]
13226        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
13227            url = params.uri_replacement(url, param_name, find_this, true);
13228        }
13229        {
13230            let to_remove = ["parent"];
13231            params.remove_params(&to_remove);
13232        }
13233
13234        let url = params.parse_with_url(&url);
13235
13236        let mut json_mime_type = mime::APPLICATION_JSON;
13237        let mut request_value_reader = {
13238            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13239            common::remove_json_null_values(&mut value);
13240            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13241            serde_json::to_writer(&mut dst, &value).unwrap();
13242            dst
13243        };
13244        let request_size = request_value_reader
13245            .seek(std::io::SeekFrom::End(0))
13246            .unwrap();
13247        request_value_reader
13248            .seek(std::io::SeekFrom::Start(0))
13249            .unwrap();
13250
13251        loop {
13252            let token = match self
13253                .hub
13254                .auth
13255                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13256                .await
13257            {
13258                Ok(token) => token,
13259                Err(e) => match dlg.token(e) {
13260                    Ok(token) => token,
13261                    Err(e) => {
13262                        dlg.finished(false);
13263                        return Err(common::Error::MissingToken(e));
13264                    }
13265                },
13266            };
13267            request_value_reader
13268                .seek(std::io::SeekFrom::Start(0))
13269                .unwrap();
13270            let mut req_result = {
13271                let client = &self.hub.client;
13272                dlg.pre_request();
13273                let mut req_builder = hyper::Request::builder()
13274                    .method(hyper::Method::POST)
13275                    .uri(url.as_str())
13276                    .header(USER_AGENT, self.hub._user_agent.clone());
13277
13278                if let Some(token) = token.as_ref() {
13279                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13280                }
13281
13282                let request = req_builder
13283                    .header(CONTENT_TYPE, json_mime_type.to_string())
13284                    .header(CONTENT_LENGTH, request_size as u64)
13285                    .body(common::to_body(
13286                        request_value_reader.get_ref().clone().into(),
13287                    ));
13288
13289                client.request(request.unwrap()).await
13290            };
13291
13292            match req_result {
13293                Err(err) => {
13294                    if let common::Retry::After(d) = dlg.http_error(&err) {
13295                        sleep(d).await;
13296                        continue;
13297                    }
13298                    dlg.finished(false);
13299                    return Err(common::Error::HttpError(err));
13300                }
13301                Ok(res) => {
13302                    let (mut parts, body) = res.into_parts();
13303                    let mut body = common::Body::new(body);
13304                    if !parts.status.is_success() {
13305                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13306                        let error = serde_json::from_str(&common::to_string(&bytes));
13307                        let response = common::to_response(parts, bytes.into());
13308
13309                        if let common::Retry::After(d) =
13310                            dlg.http_failure(&response, error.as_ref().ok())
13311                        {
13312                            sleep(d).await;
13313                            continue;
13314                        }
13315
13316                        dlg.finished(false);
13317
13318                        return Err(match error {
13319                            Ok(value) => common::Error::BadRequest(value),
13320                            _ => common::Error::Failure(response),
13321                        });
13322                    }
13323                    let response = {
13324                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13325                        let encoded = common::to_string(&bytes);
13326                        match serde_json::from_str(&encoded) {
13327                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13328                            Err(error) => {
13329                                dlg.response_json_decode_error(&encoded, &error);
13330                                return Err(common::Error::JsonDecodeError(
13331                                    encoded.to_string(),
13332                                    error,
13333                                ));
13334                            }
13335                        }
13336                    };
13337
13338                    dlg.finished(true);
13339                    return Ok(response);
13340                }
13341            }
13342        }
13343    }
13344
13345    ///
13346    /// Sets the *request* property to the given value.
13347    ///
13348    /// Even though the property as already been set when instantiating this call,
13349    /// we provide this method for API completeness.
13350    pub fn request(mut self, new_value: Product) -> ProjectLocationProductCreateCall<'a, C> {
13351        self._request = new_value;
13352        self
13353    }
13354    /// Required. The project in which the Product should be created. Format is `projects/PROJECT_ID/locations/LOC_ID`.
13355    ///
13356    /// Sets the *parent* path property to the given value.
13357    ///
13358    /// Even though the property as already been set when instantiating this call,
13359    /// we provide this method for API completeness.
13360    pub fn parent(mut self, new_value: &str) -> ProjectLocationProductCreateCall<'a, C> {
13361        self._parent = new_value.to_string();
13362        self
13363    }
13364    /// A user-supplied resource id for this Product. If set, the server will attempt to use this value as the resource id. If it is already in use, an error is returned with code ALREADY_EXISTS. Must be at most 128 characters long. It cannot contain the character `/`.
13365    ///
13366    /// Sets the *product id* query property to the given value.
13367    pub fn product_id(mut self, new_value: &str) -> ProjectLocationProductCreateCall<'a, C> {
13368        self._product_id = Some(new_value.to_string());
13369        self
13370    }
13371    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13372    /// while executing the actual API request.
13373    ///
13374    /// ````text
13375    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13376    /// ````
13377    ///
13378    /// Sets the *delegate* property to the given value.
13379    pub fn delegate(
13380        mut self,
13381        new_value: &'a mut dyn common::Delegate,
13382    ) -> ProjectLocationProductCreateCall<'a, C> {
13383        self._delegate = Some(new_value);
13384        self
13385    }
13386
13387    /// Set any additional parameter of the query string used in the request.
13388    /// It should be used to set parameters which are not yet available through their own
13389    /// setters.
13390    ///
13391    /// Please note that this method must not be used to set any of the known parameters
13392    /// which have their own setter method. If done anyway, the request will fail.
13393    ///
13394    /// # Additional Parameters
13395    ///
13396    /// * *$.xgafv* (query-string) - V1 error format.
13397    /// * *access_token* (query-string) - OAuth access token.
13398    /// * *alt* (query-string) - Data format for response.
13399    /// * *callback* (query-string) - JSONP
13400    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13401    /// * *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.
13402    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13403    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13404    /// * *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.
13405    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13406    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13407    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProductCreateCall<'a, C>
13408    where
13409        T: AsRef<str>,
13410    {
13411        self._additional_params
13412            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13413        self
13414    }
13415
13416    /// Identifies the authorization scope for the method you are building.
13417    ///
13418    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13419    /// [`Scope::CloudPlatform`].
13420    ///
13421    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13422    /// tokens for more than one scope.
13423    ///
13424    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13425    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13426    /// sufficient, a read-write scope will do as well.
13427    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProductCreateCall<'a, C>
13428    where
13429        St: AsRef<str>,
13430    {
13431        self._scopes.insert(String::from(scope.as_ref()));
13432        self
13433    }
13434    /// Identifies the authorization scope(s) for the method you are building.
13435    ///
13436    /// See [`Self::add_scope()`] for details.
13437    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProductCreateCall<'a, C>
13438    where
13439        I: IntoIterator<Item = St>,
13440        St: AsRef<str>,
13441    {
13442        self._scopes
13443            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13444        self
13445    }
13446
13447    /// Removes all scopes, and no default scope will be used either.
13448    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13449    /// for details).
13450    pub fn clear_scopes(mut self) -> ProjectLocationProductCreateCall<'a, C> {
13451        self._scopes.clear();
13452        self
13453    }
13454}
13455
13456/// Permanently deletes a product and its reference images. Metadata of the product and all its images will be deleted right away, but search queries against ProductSets containing the product may still work until all related caches are refreshed.
13457///
13458/// A builder for the *locations.products.delete* method supported by a *project* resource.
13459/// It is not used directly, but through a [`ProjectMethods`] instance.
13460///
13461/// # Example
13462///
13463/// Instantiate a resource method builder
13464///
13465/// ```test_harness,no_run
13466/// # extern crate hyper;
13467/// # extern crate hyper_rustls;
13468/// # extern crate google_vision1 as vision1;
13469/// # async fn dox() {
13470/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13471///
13472/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13473/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13474/// #     .with_native_roots()
13475/// #     .unwrap()
13476/// #     .https_only()
13477/// #     .enable_http2()
13478/// #     .build();
13479///
13480/// # let executor = hyper_util::rt::TokioExecutor::new();
13481/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13482/// #     secret,
13483/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13484/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13485/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13486/// #     ),
13487/// # ).build().await.unwrap();
13488///
13489/// # let client = hyper_util::client::legacy::Client::builder(
13490/// #     hyper_util::rt::TokioExecutor::new()
13491/// # )
13492/// # .build(
13493/// #     hyper_rustls::HttpsConnectorBuilder::new()
13494/// #         .with_native_roots()
13495/// #         .unwrap()
13496/// #         .https_or_http()
13497/// #         .enable_http2()
13498/// #         .build()
13499/// # );
13500/// # let mut hub = Vision::new(client, auth);
13501/// // You can configure optional parameters by calling the respective setters at will, and
13502/// // execute the final call using `doit()`.
13503/// // Values shown here are possibly random and not representative !
13504/// let result = hub.projects().locations_products_delete("name")
13505///              .doit().await;
13506/// # }
13507/// ```
13508pub struct ProjectLocationProductDeleteCall<'a, C>
13509where
13510    C: 'a,
13511{
13512    hub: &'a Vision<C>,
13513    _name: String,
13514    _delegate: Option<&'a mut dyn common::Delegate>,
13515    _additional_params: HashMap<String, String>,
13516    _scopes: BTreeSet<String>,
13517}
13518
13519impl<'a, C> common::CallBuilder for ProjectLocationProductDeleteCall<'a, C> {}
13520
13521impl<'a, C> ProjectLocationProductDeleteCall<'a, C>
13522where
13523    C: common::Connector,
13524{
13525    /// Perform the operation you have build so far.
13526    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
13527        use std::borrow::Cow;
13528        use std::io::{Read, Seek};
13529
13530        use common::{url::Params, ToParts};
13531        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13532
13533        let mut dd = common::DefaultDelegate;
13534        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13535        dlg.begin(common::MethodInfo {
13536            id: "vision.projects.locations.products.delete",
13537            http_method: hyper::Method::DELETE,
13538        });
13539
13540        for &field in ["alt", "name"].iter() {
13541            if self._additional_params.contains_key(field) {
13542                dlg.finished(false);
13543                return Err(common::Error::FieldClash(field));
13544            }
13545        }
13546
13547        let mut params = Params::with_capacity(3 + self._additional_params.len());
13548        params.push("name", self._name);
13549
13550        params.extend(self._additional_params.iter());
13551
13552        params.push("alt", "json");
13553        let mut url = self.hub._base_url.clone() + "v1/{+name}";
13554        if self._scopes.is_empty() {
13555            self._scopes
13556                .insert(Scope::CloudPlatform.as_ref().to_string());
13557        }
13558
13559        #[allow(clippy::single_element_loop)]
13560        for &(find_this, param_name) in [("{+name}", "name")].iter() {
13561            url = params.uri_replacement(url, param_name, find_this, true);
13562        }
13563        {
13564            let to_remove = ["name"];
13565            params.remove_params(&to_remove);
13566        }
13567
13568        let url = params.parse_with_url(&url);
13569
13570        loop {
13571            let token = match self
13572                .hub
13573                .auth
13574                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13575                .await
13576            {
13577                Ok(token) => token,
13578                Err(e) => match dlg.token(e) {
13579                    Ok(token) => token,
13580                    Err(e) => {
13581                        dlg.finished(false);
13582                        return Err(common::Error::MissingToken(e));
13583                    }
13584                },
13585            };
13586            let mut req_result = {
13587                let client = &self.hub.client;
13588                dlg.pre_request();
13589                let mut req_builder = hyper::Request::builder()
13590                    .method(hyper::Method::DELETE)
13591                    .uri(url.as_str())
13592                    .header(USER_AGENT, self.hub._user_agent.clone());
13593
13594                if let Some(token) = token.as_ref() {
13595                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13596                }
13597
13598                let request = req_builder
13599                    .header(CONTENT_LENGTH, 0_u64)
13600                    .body(common::to_body::<String>(None));
13601
13602                client.request(request.unwrap()).await
13603            };
13604
13605            match req_result {
13606                Err(err) => {
13607                    if let common::Retry::After(d) = dlg.http_error(&err) {
13608                        sleep(d).await;
13609                        continue;
13610                    }
13611                    dlg.finished(false);
13612                    return Err(common::Error::HttpError(err));
13613                }
13614                Ok(res) => {
13615                    let (mut parts, body) = res.into_parts();
13616                    let mut body = common::Body::new(body);
13617                    if !parts.status.is_success() {
13618                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13619                        let error = serde_json::from_str(&common::to_string(&bytes));
13620                        let response = common::to_response(parts, bytes.into());
13621
13622                        if let common::Retry::After(d) =
13623                            dlg.http_failure(&response, error.as_ref().ok())
13624                        {
13625                            sleep(d).await;
13626                            continue;
13627                        }
13628
13629                        dlg.finished(false);
13630
13631                        return Err(match error {
13632                            Ok(value) => common::Error::BadRequest(value),
13633                            _ => common::Error::Failure(response),
13634                        });
13635                    }
13636                    let response = {
13637                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13638                        let encoded = common::to_string(&bytes);
13639                        match serde_json::from_str(&encoded) {
13640                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13641                            Err(error) => {
13642                                dlg.response_json_decode_error(&encoded, &error);
13643                                return Err(common::Error::JsonDecodeError(
13644                                    encoded.to_string(),
13645                                    error,
13646                                ));
13647                            }
13648                        }
13649                    };
13650
13651                    dlg.finished(true);
13652                    return Ok(response);
13653                }
13654            }
13655        }
13656    }
13657
13658    /// Required. Resource name of product to delete. Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
13659    ///
13660    /// Sets the *name* path property to the given value.
13661    ///
13662    /// Even though the property as already been set when instantiating this call,
13663    /// we provide this method for API completeness.
13664    pub fn name(mut self, new_value: &str) -> ProjectLocationProductDeleteCall<'a, C> {
13665        self._name = new_value.to_string();
13666        self
13667    }
13668    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13669    /// while executing the actual API request.
13670    ///
13671    /// ````text
13672    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13673    /// ````
13674    ///
13675    /// Sets the *delegate* property to the given value.
13676    pub fn delegate(
13677        mut self,
13678        new_value: &'a mut dyn common::Delegate,
13679    ) -> ProjectLocationProductDeleteCall<'a, C> {
13680        self._delegate = Some(new_value);
13681        self
13682    }
13683
13684    /// Set any additional parameter of the query string used in the request.
13685    /// It should be used to set parameters which are not yet available through their own
13686    /// setters.
13687    ///
13688    /// Please note that this method must not be used to set any of the known parameters
13689    /// which have their own setter method. If done anyway, the request will fail.
13690    ///
13691    /// # Additional Parameters
13692    ///
13693    /// * *$.xgafv* (query-string) - V1 error format.
13694    /// * *access_token* (query-string) - OAuth access token.
13695    /// * *alt* (query-string) - Data format for response.
13696    /// * *callback* (query-string) - JSONP
13697    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13698    /// * *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.
13699    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13700    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13701    /// * *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.
13702    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13703    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13704    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProductDeleteCall<'a, C>
13705    where
13706        T: AsRef<str>,
13707    {
13708        self._additional_params
13709            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13710        self
13711    }
13712
13713    /// Identifies the authorization scope for the method you are building.
13714    ///
13715    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13716    /// [`Scope::CloudPlatform`].
13717    ///
13718    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13719    /// tokens for more than one scope.
13720    ///
13721    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13722    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13723    /// sufficient, a read-write scope will do as well.
13724    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProductDeleteCall<'a, C>
13725    where
13726        St: AsRef<str>,
13727    {
13728        self._scopes.insert(String::from(scope.as_ref()));
13729        self
13730    }
13731    /// Identifies the authorization scope(s) for the method you are building.
13732    ///
13733    /// See [`Self::add_scope()`] for details.
13734    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProductDeleteCall<'a, C>
13735    where
13736        I: IntoIterator<Item = St>,
13737        St: AsRef<str>,
13738    {
13739        self._scopes
13740            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13741        self
13742    }
13743
13744    /// Removes all scopes, and no default scope will be used either.
13745    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13746    /// for details).
13747    pub fn clear_scopes(mut self) -> ProjectLocationProductDeleteCall<'a, C> {
13748        self._scopes.clear();
13749        self
13750    }
13751}
13752
13753/// Gets information associated with a Product. Possible errors: * Returns NOT_FOUND if the Product does not exist.
13754///
13755/// A builder for the *locations.products.get* method supported by a *project* resource.
13756/// It is not used directly, but through a [`ProjectMethods`] instance.
13757///
13758/// # Example
13759///
13760/// Instantiate a resource method builder
13761///
13762/// ```test_harness,no_run
13763/// # extern crate hyper;
13764/// # extern crate hyper_rustls;
13765/// # extern crate google_vision1 as vision1;
13766/// # async fn dox() {
13767/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13768///
13769/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13770/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13771/// #     .with_native_roots()
13772/// #     .unwrap()
13773/// #     .https_only()
13774/// #     .enable_http2()
13775/// #     .build();
13776///
13777/// # let executor = hyper_util::rt::TokioExecutor::new();
13778/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13779/// #     secret,
13780/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13781/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13782/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13783/// #     ),
13784/// # ).build().await.unwrap();
13785///
13786/// # let client = hyper_util::client::legacy::Client::builder(
13787/// #     hyper_util::rt::TokioExecutor::new()
13788/// # )
13789/// # .build(
13790/// #     hyper_rustls::HttpsConnectorBuilder::new()
13791/// #         .with_native_roots()
13792/// #         .unwrap()
13793/// #         .https_or_http()
13794/// #         .enable_http2()
13795/// #         .build()
13796/// # );
13797/// # let mut hub = Vision::new(client, auth);
13798/// // You can configure optional parameters by calling the respective setters at will, and
13799/// // execute the final call using `doit()`.
13800/// // Values shown here are possibly random and not representative !
13801/// let result = hub.projects().locations_products_get("name")
13802///              .doit().await;
13803/// # }
13804/// ```
13805pub struct ProjectLocationProductGetCall<'a, C>
13806where
13807    C: 'a,
13808{
13809    hub: &'a Vision<C>,
13810    _name: String,
13811    _delegate: Option<&'a mut dyn common::Delegate>,
13812    _additional_params: HashMap<String, String>,
13813    _scopes: BTreeSet<String>,
13814}
13815
13816impl<'a, C> common::CallBuilder for ProjectLocationProductGetCall<'a, C> {}
13817
13818impl<'a, C> ProjectLocationProductGetCall<'a, C>
13819where
13820    C: common::Connector,
13821{
13822    /// Perform the operation you have build so far.
13823    pub async fn doit(mut self) -> common::Result<(common::Response, Product)> {
13824        use std::borrow::Cow;
13825        use std::io::{Read, Seek};
13826
13827        use common::{url::Params, ToParts};
13828        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13829
13830        let mut dd = common::DefaultDelegate;
13831        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13832        dlg.begin(common::MethodInfo {
13833            id: "vision.projects.locations.products.get",
13834            http_method: hyper::Method::GET,
13835        });
13836
13837        for &field in ["alt", "name"].iter() {
13838            if self._additional_params.contains_key(field) {
13839                dlg.finished(false);
13840                return Err(common::Error::FieldClash(field));
13841            }
13842        }
13843
13844        let mut params = Params::with_capacity(3 + self._additional_params.len());
13845        params.push("name", self._name);
13846
13847        params.extend(self._additional_params.iter());
13848
13849        params.push("alt", "json");
13850        let mut url = self.hub._base_url.clone() + "v1/{+name}";
13851        if self._scopes.is_empty() {
13852            self._scopes
13853                .insert(Scope::CloudPlatform.as_ref().to_string());
13854        }
13855
13856        #[allow(clippy::single_element_loop)]
13857        for &(find_this, param_name) in [("{+name}", "name")].iter() {
13858            url = params.uri_replacement(url, param_name, find_this, true);
13859        }
13860        {
13861            let to_remove = ["name"];
13862            params.remove_params(&to_remove);
13863        }
13864
13865        let url = params.parse_with_url(&url);
13866
13867        loop {
13868            let token = match self
13869                .hub
13870                .auth
13871                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13872                .await
13873            {
13874                Ok(token) => token,
13875                Err(e) => match dlg.token(e) {
13876                    Ok(token) => token,
13877                    Err(e) => {
13878                        dlg.finished(false);
13879                        return Err(common::Error::MissingToken(e));
13880                    }
13881                },
13882            };
13883            let mut req_result = {
13884                let client = &self.hub.client;
13885                dlg.pre_request();
13886                let mut req_builder = hyper::Request::builder()
13887                    .method(hyper::Method::GET)
13888                    .uri(url.as_str())
13889                    .header(USER_AGENT, self.hub._user_agent.clone());
13890
13891                if let Some(token) = token.as_ref() {
13892                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13893                }
13894
13895                let request = req_builder
13896                    .header(CONTENT_LENGTH, 0_u64)
13897                    .body(common::to_body::<String>(None));
13898
13899                client.request(request.unwrap()).await
13900            };
13901
13902            match req_result {
13903                Err(err) => {
13904                    if let common::Retry::After(d) = dlg.http_error(&err) {
13905                        sleep(d).await;
13906                        continue;
13907                    }
13908                    dlg.finished(false);
13909                    return Err(common::Error::HttpError(err));
13910                }
13911                Ok(res) => {
13912                    let (mut parts, body) = res.into_parts();
13913                    let mut body = common::Body::new(body);
13914                    if !parts.status.is_success() {
13915                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13916                        let error = serde_json::from_str(&common::to_string(&bytes));
13917                        let response = common::to_response(parts, bytes.into());
13918
13919                        if let common::Retry::After(d) =
13920                            dlg.http_failure(&response, error.as_ref().ok())
13921                        {
13922                            sleep(d).await;
13923                            continue;
13924                        }
13925
13926                        dlg.finished(false);
13927
13928                        return Err(match error {
13929                            Ok(value) => common::Error::BadRequest(value),
13930                            _ => common::Error::Failure(response),
13931                        });
13932                    }
13933                    let response = {
13934                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13935                        let encoded = common::to_string(&bytes);
13936                        match serde_json::from_str(&encoded) {
13937                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13938                            Err(error) => {
13939                                dlg.response_json_decode_error(&encoded, &error);
13940                                return Err(common::Error::JsonDecodeError(
13941                                    encoded.to_string(),
13942                                    error,
13943                                ));
13944                            }
13945                        }
13946                    };
13947
13948                    dlg.finished(true);
13949                    return Ok(response);
13950                }
13951            }
13952        }
13953    }
13954
13955    /// Required. Resource name of the Product to get. Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`
13956    ///
13957    /// Sets the *name* path property to the given value.
13958    ///
13959    /// Even though the property as already been set when instantiating this call,
13960    /// we provide this method for API completeness.
13961    pub fn name(mut self, new_value: &str) -> ProjectLocationProductGetCall<'a, C> {
13962        self._name = new_value.to_string();
13963        self
13964    }
13965    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13966    /// while executing the actual API request.
13967    ///
13968    /// ````text
13969    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13970    /// ````
13971    ///
13972    /// Sets the *delegate* property to the given value.
13973    pub fn delegate(
13974        mut self,
13975        new_value: &'a mut dyn common::Delegate,
13976    ) -> ProjectLocationProductGetCall<'a, C> {
13977        self._delegate = Some(new_value);
13978        self
13979    }
13980
13981    /// Set any additional parameter of the query string used in the request.
13982    /// It should be used to set parameters which are not yet available through their own
13983    /// setters.
13984    ///
13985    /// Please note that this method must not be used to set any of the known parameters
13986    /// which have their own setter method. If done anyway, the request will fail.
13987    ///
13988    /// # Additional Parameters
13989    ///
13990    /// * *$.xgafv* (query-string) - V1 error format.
13991    /// * *access_token* (query-string) - OAuth access token.
13992    /// * *alt* (query-string) - Data format for response.
13993    /// * *callback* (query-string) - JSONP
13994    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13995    /// * *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.
13996    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13997    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13998    /// * *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.
13999    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14000    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14001    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProductGetCall<'a, C>
14002    where
14003        T: AsRef<str>,
14004    {
14005        self._additional_params
14006            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14007        self
14008    }
14009
14010    /// Identifies the authorization scope for the method you are building.
14011    ///
14012    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14013    /// [`Scope::CloudPlatform`].
14014    ///
14015    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14016    /// tokens for more than one scope.
14017    ///
14018    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14019    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14020    /// sufficient, a read-write scope will do as well.
14021    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProductGetCall<'a, C>
14022    where
14023        St: AsRef<str>,
14024    {
14025        self._scopes.insert(String::from(scope.as_ref()));
14026        self
14027    }
14028    /// Identifies the authorization scope(s) for the method you are building.
14029    ///
14030    /// See [`Self::add_scope()`] for details.
14031    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProductGetCall<'a, C>
14032    where
14033        I: IntoIterator<Item = St>,
14034        St: AsRef<str>,
14035    {
14036        self._scopes
14037            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14038        self
14039    }
14040
14041    /// Removes all scopes, and no default scope will be used either.
14042    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14043    /// for details).
14044    pub fn clear_scopes(mut self) -> ProjectLocationProductGetCall<'a, C> {
14045        self._scopes.clear();
14046        self
14047    }
14048}
14049
14050/// Lists products in an unspecified order. Possible errors: * Returns INVALID_ARGUMENT if page_size is greater than 100 or less than 1.
14051///
14052/// A builder for the *locations.products.list* method supported by a *project* resource.
14053/// It is not used directly, but through a [`ProjectMethods`] instance.
14054///
14055/// # Example
14056///
14057/// Instantiate a resource method builder
14058///
14059/// ```test_harness,no_run
14060/// # extern crate hyper;
14061/// # extern crate hyper_rustls;
14062/// # extern crate google_vision1 as vision1;
14063/// # async fn dox() {
14064/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14065///
14066/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14067/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14068/// #     .with_native_roots()
14069/// #     .unwrap()
14070/// #     .https_only()
14071/// #     .enable_http2()
14072/// #     .build();
14073///
14074/// # let executor = hyper_util::rt::TokioExecutor::new();
14075/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14076/// #     secret,
14077/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14078/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14079/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14080/// #     ),
14081/// # ).build().await.unwrap();
14082///
14083/// # let client = hyper_util::client::legacy::Client::builder(
14084/// #     hyper_util::rt::TokioExecutor::new()
14085/// # )
14086/// # .build(
14087/// #     hyper_rustls::HttpsConnectorBuilder::new()
14088/// #         .with_native_roots()
14089/// #         .unwrap()
14090/// #         .https_or_http()
14091/// #         .enable_http2()
14092/// #         .build()
14093/// # );
14094/// # let mut hub = Vision::new(client, auth);
14095/// // You can configure optional parameters by calling the respective setters at will, and
14096/// // execute the final call using `doit()`.
14097/// // Values shown here are possibly random and not representative !
14098/// let result = hub.projects().locations_products_list("parent")
14099///              .page_token("Stet")
14100///              .page_size(-99)
14101///              .doit().await;
14102/// # }
14103/// ```
14104pub struct ProjectLocationProductListCall<'a, C>
14105where
14106    C: 'a,
14107{
14108    hub: &'a Vision<C>,
14109    _parent: String,
14110    _page_token: Option<String>,
14111    _page_size: Option<i32>,
14112    _delegate: Option<&'a mut dyn common::Delegate>,
14113    _additional_params: HashMap<String, String>,
14114    _scopes: BTreeSet<String>,
14115}
14116
14117impl<'a, C> common::CallBuilder for ProjectLocationProductListCall<'a, C> {}
14118
14119impl<'a, C> ProjectLocationProductListCall<'a, C>
14120where
14121    C: common::Connector,
14122{
14123    /// Perform the operation you have build so far.
14124    pub async fn doit(mut self) -> common::Result<(common::Response, ListProductsResponse)> {
14125        use std::borrow::Cow;
14126        use std::io::{Read, Seek};
14127
14128        use common::{url::Params, ToParts};
14129        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14130
14131        let mut dd = common::DefaultDelegate;
14132        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14133        dlg.begin(common::MethodInfo {
14134            id: "vision.projects.locations.products.list",
14135            http_method: hyper::Method::GET,
14136        });
14137
14138        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
14139            if self._additional_params.contains_key(field) {
14140                dlg.finished(false);
14141                return Err(common::Error::FieldClash(field));
14142            }
14143        }
14144
14145        let mut params = Params::with_capacity(5 + self._additional_params.len());
14146        params.push("parent", self._parent);
14147        if let Some(value) = self._page_token.as_ref() {
14148            params.push("pageToken", value);
14149        }
14150        if let Some(value) = self._page_size.as_ref() {
14151            params.push("pageSize", value.to_string());
14152        }
14153
14154        params.extend(self._additional_params.iter());
14155
14156        params.push("alt", "json");
14157        let mut url = self.hub._base_url.clone() + "v1/{+parent}/products";
14158        if self._scopes.is_empty() {
14159            self._scopes
14160                .insert(Scope::CloudPlatform.as_ref().to_string());
14161        }
14162
14163        #[allow(clippy::single_element_loop)]
14164        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
14165            url = params.uri_replacement(url, param_name, find_this, true);
14166        }
14167        {
14168            let to_remove = ["parent"];
14169            params.remove_params(&to_remove);
14170        }
14171
14172        let url = params.parse_with_url(&url);
14173
14174        loop {
14175            let token = match self
14176                .hub
14177                .auth
14178                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14179                .await
14180            {
14181                Ok(token) => token,
14182                Err(e) => match dlg.token(e) {
14183                    Ok(token) => token,
14184                    Err(e) => {
14185                        dlg.finished(false);
14186                        return Err(common::Error::MissingToken(e));
14187                    }
14188                },
14189            };
14190            let mut req_result = {
14191                let client = &self.hub.client;
14192                dlg.pre_request();
14193                let mut req_builder = hyper::Request::builder()
14194                    .method(hyper::Method::GET)
14195                    .uri(url.as_str())
14196                    .header(USER_AGENT, self.hub._user_agent.clone());
14197
14198                if let Some(token) = token.as_ref() {
14199                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14200                }
14201
14202                let request = req_builder
14203                    .header(CONTENT_LENGTH, 0_u64)
14204                    .body(common::to_body::<String>(None));
14205
14206                client.request(request.unwrap()).await
14207            };
14208
14209            match req_result {
14210                Err(err) => {
14211                    if let common::Retry::After(d) = dlg.http_error(&err) {
14212                        sleep(d).await;
14213                        continue;
14214                    }
14215                    dlg.finished(false);
14216                    return Err(common::Error::HttpError(err));
14217                }
14218                Ok(res) => {
14219                    let (mut parts, body) = res.into_parts();
14220                    let mut body = common::Body::new(body);
14221                    if !parts.status.is_success() {
14222                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14223                        let error = serde_json::from_str(&common::to_string(&bytes));
14224                        let response = common::to_response(parts, bytes.into());
14225
14226                        if let common::Retry::After(d) =
14227                            dlg.http_failure(&response, error.as_ref().ok())
14228                        {
14229                            sleep(d).await;
14230                            continue;
14231                        }
14232
14233                        dlg.finished(false);
14234
14235                        return Err(match error {
14236                            Ok(value) => common::Error::BadRequest(value),
14237                            _ => common::Error::Failure(response),
14238                        });
14239                    }
14240                    let response = {
14241                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14242                        let encoded = common::to_string(&bytes);
14243                        match serde_json::from_str(&encoded) {
14244                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14245                            Err(error) => {
14246                                dlg.response_json_decode_error(&encoded, &error);
14247                                return Err(common::Error::JsonDecodeError(
14248                                    encoded.to_string(),
14249                                    error,
14250                                ));
14251                            }
14252                        }
14253                    };
14254
14255                    dlg.finished(true);
14256                    return Ok(response);
14257                }
14258            }
14259        }
14260    }
14261
14262    /// Required. The project OR ProductSet from which Products should be listed. Format: `projects/PROJECT_ID/locations/LOC_ID`
14263    ///
14264    /// Sets the *parent* path property to the given value.
14265    ///
14266    /// Even though the property as already been set when instantiating this call,
14267    /// we provide this method for API completeness.
14268    pub fn parent(mut self, new_value: &str) -> ProjectLocationProductListCall<'a, C> {
14269        self._parent = new_value.to_string();
14270        self
14271    }
14272    /// The next_page_token returned from a previous List request, if any.
14273    ///
14274    /// Sets the *page token* query property to the given value.
14275    pub fn page_token(mut self, new_value: &str) -> ProjectLocationProductListCall<'a, C> {
14276        self._page_token = Some(new_value.to_string());
14277        self
14278    }
14279    /// The maximum number of items to return. Default 10, maximum 100.
14280    ///
14281    /// Sets the *page size* query property to the given value.
14282    pub fn page_size(mut self, new_value: i32) -> ProjectLocationProductListCall<'a, C> {
14283        self._page_size = Some(new_value);
14284        self
14285    }
14286    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14287    /// while executing the actual API request.
14288    ///
14289    /// ````text
14290    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14291    /// ````
14292    ///
14293    /// Sets the *delegate* property to the given value.
14294    pub fn delegate(
14295        mut self,
14296        new_value: &'a mut dyn common::Delegate,
14297    ) -> ProjectLocationProductListCall<'a, C> {
14298        self._delegate = Some(new_value);
14299        self
14300    }
14301
14302    /// Set any additional parameter of the query string used in the request.
14303    /// It should be used to set parameters which are not yet available through their own
14304    /// setters.
14305    ///
14306    /// Please note that this method must not be used to set any of the known parameters
14307    /// which have their own setter method. If done anyway, the request will fail.
14308    ///
14309    /// # Additional Parameters
14310    ///
14311    /// * *$.xgafv* (query-string) - V1 error format.
14312    /// * *access_token* (query-string) - OAuth access token.
14313    /// * *alt* (query-string) - Data format for response.
14314    /// * *callback* (query-string) - JSONP
14315    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14316    /// * *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.
14317    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14318    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14319    /// * *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.
14320    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14321    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14322    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProductListCall<'a, C>
14323    where
14324        T: AsRef<str>,
14325    {
14326        self._additional_params
14327            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14328        self
14329    }
14330
14331    /// Identifies the authorization scope for the method you are building.
14332    ///
14333    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14334    /// [`Scope::CloudPlatform`].
14335    ///
14336    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14337    /// tokens for more than one scope.
14338    ///
14339    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14340    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14341    /// sufficient, a read-write scope will do as well.
14342    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProductListCall<'a, C>
14343    where
14344        St: AsRef<str>,
14345    {
14346        self._scopes.insert(String::from(scope.as_ref()));
14347        self
14348    }
14349    /// Identifies the authorization scope(s) for the method you are building.
14350    ///
14351    /// See [`Self::add_scope()`] for details.
14352    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProductListCall<'a, C>
14353    where
14354        I: IntoIterator<Item = St>,
14355        St: AsRef<str>,
14356    {
14357        self._scopes
14358            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14359        self
14360    }
14361
14362    /// Removes all scopes, and no default scope will be used either.
14363    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14364    /// for details).
14365    pub fn clear_scopes(mut self) -> ProjectLocationProductListCall<'a, C> {
14366        self._scopes.clear();
14367        self
14368    }
14369}
14370
14371/// Makes changes to a Product resource. Only the `display_name`, `description`, and `labels` fields can be updated right now. If labels are updated, the change will not be reflected in queries until the next index time. Possible errors: * Returns NOT_FOUND if the Product does not exist. * Returns INVALID_ARGUMENT if display_name is present in update_mask but is missing from the request or longer than 4096 characters. * Returns INVALID_ARGUMENT if description is present in update_mask but is longer than 4096 characters. * Returns INVALID_ARGUMENT if product_category is present in update_mask.
14372///
14373/// A builder for the *locations.products.patch* method supported by a *project* resource.
14374/// It is not used directly, but through a [`ProjectMethods`] instance.
14375///
14376/// # Example
14377///
14378/// Instantiate a resource method builder
14379///
14380/// ```test_harness,no_run
14381/// # extern crate hyper;
14382/// # extern crate hyper_rustls;
14383/// # extern crate google_vision1 as vision1;
14384/// use vision1::api::Product;
14385/// # async fn dox() {
14386/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14387///
14388/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14389/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14390/// #     .with_native_roots()
14391/// #     .unwrap()
14392/// #     .https_only()
14393/// #     .enable_http2()
14394/// #     .build();
14395///
14396/// # let executor = hyper_util::rt::TokioExecutor::new();
14397/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14398/// #     secret,
14399/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14400/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14401/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14402/// #     ),
14403/// # ).build().await.unwrap();
14404///
14405/// # let client = hyper_util::client::legacy::Client::builder(
14406/// #     hyper_util::rt::TokioExecutor::new()
14407/// # )
14408/// # .build(
14409/// #     hyper_rustls::HttpsConnectorBuilder::new()
14410/// #         .with_native_roots()
14411/// #         .unwrap()
14412/// #         .https_or_http()
14413/// #         .enable_http2()
14414/// #         .build()
14415/// # );
14416/// # let mut hub = Vision::new(client, auth);
14417/// // As the method needs a request, you would usually fill it with the desired information
14418/// // into the respective structure. Some of the parts shown here might not be applicable !
14419/// // Values shown here are possibly random and not representative !
14420/// let mut req = Product::default();
14421///
14422/// // You can configure optional parameters by calling the respective setters at will, and
14423/// // execute the final call using `doit()`.
14424/// // Values shown here are possibly random and not representative !
14425/// let result = hub.projects().locations_products_patch(req, "name")
14426///              .update_mask(FieldMask::new::<&str>(&[]))
14427///              .doit().await;
14428/// # }
14429/// ```
14430pub struct ProjectLocationProductPatchCall<'a, C>
14431where
14432    C: 'a,
14433{
14434    hub: &'a Vision<C>,
14435    _request: Product,
14436    _name: String,
14437    _update_mask: Option<common::FieldMask>,
14438    _delegate: Option<&'a mut dyn common::Delegate>,
14439    _additional_params: HashMap<String, String>,
14440    _scopes: BTreeSet<String>,
14441}
14442
14443impl<'a, C> common::CallBuilder for ProjectLocationProductPatchCall<'a, C> {}
14444
14445impl<'a, C> ProjectLocationProductPatchCall<'a, C>
14446where
14447    C: common::Connector,
14448{
14449    /// Perform the operation you have build so far.
14450    pub async fn doit(mut self) -> common::Result<(common::Response, Product)> {
14451        use std::borrow::Cow;
14452        use std::io::{Read, Seek};
14453
14454        use common::{url::Params, ToParts};
14455        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14456
14457        let mut dd = common::DefaultDelegate;
14458        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14459        dlg.begin(common::MethodInfo {
14460            id: "vision.projects.locations.products.patch",
14461            http_method: hyper::Method::PATCH,
14462        });
14463
14464        for &field in ["alt", "name", "updateMask"].iter() {
14465            if self._additional_params.contains_key(field) {
14466                dlg.finished(false);
14467                return Err(common::Error::FieldClash(field));
14468            }
14469        }
14470
14471        let mut params = Params::with_capacity(5 + self._additional_params.len());
14472        params.push("name", self._name);
14473        if let Some(value) = self._update_mask.as_ref() {
14474            params.push("updateMask", value.to_string());
14475        }
14476
14477        params.extend(self._additional_params.iter());
14478
14479        params.push("alt", "json");
14480        let mut url = self.hub._base_url.clone() + "v1/{+name}";
14481        if self._scopes.is_empty() {
14482            self._scopes
14483                .insert(Scope::CloudPlatform.as_ref().to_string());
14484        }
14485
14486        #[allow(clippy::single_element_loop)]
14487        for &(find_this, param_name) in [("{+name}", "name")].iter() {
14488            url = params.uri_replacement(url, param_name, find_this, true);
14489        }
14490        {
14491            let to_remove = ["name"];
14492            params.remove_params(&to_remove);
14493        }
14494
14495        let url = params.parse_with_url(&url);
14496
14497        let mut json_mime_type = mime::APPLICATION_JSON;
14498        let mut request_value_reader = {
14499            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14500            common::remove_json_null_values(&mut value);
14501            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14502            serde_json::to_writer(&mut dst, &value).unwrap();
14503            dst
14504        };
14505        let request_size = request_value_reader
14506            .seek(std::io::SeekFrom::End(0))
14507            .unwrap();
14508        request_value_reader
14509            .seek(std::io::SeekFrom::Start(0))
14510            .unwrap();
14511
14512        loop {
14513            let token = match self
14514                .hub
14515                .auth
14516                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14517                .await
14518            {
14519                Ok(token) => token,
14520                Err(e) => match dlg.token(e) {
14521                    Ok(token) => token,
14522                    Err(e) => {
14523                        dlg.finished(false);
14524                        return Err(common::Error::MissingToken(e));
14525                    }
14526                },
14527            };
14528            request_value_reader
14529                .seek(std::io::SeekFrom::Start(0))
14530                .unwrap();
14531            let mut req_result = {
14532                let client = &self.hub.client;
14533                dlg.pre_request();
14534                let mut req_builder = hyper::Request::builder()
14535                    .method(hyper::Method::PATCH)
14536                    .uri(url.as_str())
14537                    .header(USER_AGENT, self.hub._user_agent.clone());
14538
14539                if let Some(token) = token.as_ref() {
14540                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14541                }
14542
14543                let request = req_builder
14544                    .header(CONTENT_TYPE, json_mime_type.to_string())
14545                    .header(CONTENT_LENGTH, request_size as u64)
14546                    .body(common::to_body(
14547                        request_value_reader.get_ref().clone().into(),
14548                    ));
14549
14550                client.request(request.unwrap()).await
14551            };
14552
14553            match req_result {
14554                Err(err) => {
14555                    if let common::Retry::After(d) = dlg.http_error(&err) {
14556                        sleep(d).await;
14557                        continue;
14558                    }
14559                    dlg.finished(false);
14560                    return Err(common::Error::HttpError(err));
14561                }
14562                Ok(res) => {
14563                    let (mut parts, body) = res.into_parts();
14564                    let mut body = common::Body::new(body);
14565                    if !parts.status.is_success() {
14566                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14567                        let error = serde_json::from_str(&common::to_string(&bytes));
14568                        let response = common::to_response(parts, bytes.into());
14569
14570                        if let common::Retry::After(d) =
14571                            dlg.http_failure(&response, error.as_ref().ok())
14572                        {
14573                            sleep(d).await;
14574                            continue;
14575                        }
14576
14577                        dlg.finished(false);
14578
14579                        return Err(match error {
14580                            Ok(value) => common::Error::BadRequest(value),
14581                            _ => common::Error::Failure(response),
14582                        });
14583                    }
14584                    let response = {
14585                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14586                        let encoded = common::to_string(&bytes);
14587                        match serde_json::from_str(&encoded) {
14588                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14589                            Err(error) => {
14590                                dlg.response_json_decode_error(&encoded, &error);
14591                                return Err(common::Error::JsonDecodeError(
14592                                    encoded.to_string(),
14593                                    error,
14594                                ));
14595                            }
14596                        }
14597                    };
14598
14599                    dlg.finished(true);
14600                    return Ok(response);
14601                }
14602            }
14603        }
14604    }
14605
14606    ///
14607    /// Sets the *request* property to the given value.
14608    ///
14609    /// Even though the property as already been set when instantiating this call,
14610    /// we provide this method for API completeness.
14611    pub fn request(mut self, new_value: Product) -> ProjectLocationProductPatchCall<'a, C> {
14612        self._request = new_value;
14613        self
14614    }
14615    /// The resource name of the product. Format is: `projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID`. This field is ignored when creating a product.
14616    ///
14617    /// Sets the *name* path property to the given value.
14618    ///
14619    /// Even though the property as already been set when instantiating this call,
14620    /// we provide this method for API completeness.
14621    pub fn name(mut self, new_value: &str) -> ProjectLocationProductPatchCall<'a, C> {
14622        self._name = new_value.to_string();
14623        self
14624    }
14625    /// The FieldMask that specifies which fields to update. If update_mask isn't specified, all mutable fields are to be updated. Valid mask paths include `product_labels`, `display_name`, and `description`.
14626    ///
14627    /// Sets the *update mask* query property to the given value.
14628    pub fn update_mask(
14629        mut self,
14630        new_value: common::FieldMask,
14631    ) -> ProjectLocationProductPatchCall<'a, C> {
14632        self._update_mask = Some(new_value);
14633        self
14634    }
14635    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14636    /// while executing the actual API request.
14637    ///
14638    /// ````text
14639    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14640    /// ````
14641    ///
14642    /// Sets the *delegate* property to the given value.
14643    pub fn delegate(
14644        mut self,
14645        new_value: &'a mut dyn common::Delegate,
14646    ) -> ProjectLocationProductPatchCall<'a, C> {
14647        self._delegate = Some(new_value);
14648        self
14649    }
14650
14651    /// Set any additional parameter of the query string used in the request.
14652    /// It should be used to set parameters which are not yet available through their own
14653    /// setters.
14654    ///
14655    /// Please note that this method must not be used to set any of the known parameters
14656    /// which have their own setter method. If done anyway, the request will fail.
14657    ///
14658    /// # Additional Parameters
14659    ///
14660    /// * *$.xgafv* (query-string) - V1 error format.
14661    /// * *access_token* (query-string) - OAuth access token.
14662    /// * *alt* (query-string) - Data format for response.
14663    /// * *callback* (query-string) - JSONP
14664    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14665    /// * *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.
14666    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14667    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14668    /// * *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.
14669    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14670    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14671    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProductPatchCall<'a, C>
14672    where
14673        T: AsRef<str>,
14674    {
14675        self._additional_params
14676            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14677        self
14678    }
14679
14680    /// Identifies the authorization scope for the method you are building.
14681    ///
14682    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14683    /// [`Scope::CloudPlatform`].
14684    ///
14685    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14686    /// tokens for more than one scope.
14687    ///
14688    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14689    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14690    /// sufficient, a read-write scope will do as well.
14691    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProductPatchCall<'a, C>
14692    where
14693        St: AsRef<str>,
14694    {
14695        self._scopes.insert(String::from(scope.as_ref()));
14696        self
14697    }
14698    /// Identifies the authorization scope(s) for the method you are building.
14699    ///
14700    /// See [`Self::add_scope()`] for details.
14701    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProductPatchCall<'a, C>
14702    where
14703        I: IntoIterator<Item = St>,
14704        St: AsRef<str>,
14705    {
14706        self._scopes
14707            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14708        self
14709    }
14710
14711    /// Removes all scopes, and no default scope will be used either.
14712    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14713    /// for details).
14714    pub fn clear_scopes(mut self) -> ProjectLocationProductPatchCall<'a, C> {
14715        self._scopes.clear();
14716        self
14717    }
14718}
14719
14720/// Asynchronous API to delete all Products in a ProductSet or all Products that are in no ProductSet. If a Product is a member of the specified ProductSet in addition to other ProductSets, the Product will still be deleted. It is recommended to not delete the specified ProductSet until after this operation has completed. It is also recommended to not add any of the Products involved in the batch delete to a new ProductSet while this operation is running because those Products may still end up deleted. It's not possible to undo the PurgeProducts operation. Therefore, it is recommended to keep the csv files used in ImportProductSets (if that was how you originally built the Product Set) before starting PurgeProducts, in case you need to re-import the data after deletion. If the plan is to purge all of the Products from a ProductSet and then re-use the empty ProductSet to re-import new Products into the empty ProductSet, you must wait until the PurgeProducts operation has finished for that ProductSet. The google.longrunning.Operation API can be used to keep track of the progress and results of the request. `Operation.metadata` contains `BatchOperationMetadata`. (progress)
14721///
14722/// A builder for the *locations.products.purge* method supported by a *project* resource.
14723/// It is not used directly, but through a [`ProjectMethods`] instance.
14724///
14725/// # Example
14726///
14727/// Instantiate a resource method builder
14728///
14729/// ```test_harness,no_run
14730/// # extern crate hyper;
14731/// # extern crate hyper_rustls;
14732/// # extern crate google_vision1 as vision1;
14733/// use vision1::api::PurgeProductsRequest;
14734/// # async fn dox() {
14735/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14736///
14737/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14738/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14739/// #     .with_native_roots()
14740/// #     .unwrap()
14741/// #     .https_only()
14742/// #     .enable_http2()
14743/// #     .build();
14744///
14745/// # let executor = hyper_util::rt::TokioExecutor::new();
14746/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14747/// #     secret,
14748/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14749/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14750/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14751/// #     ),
14752/// # ).build().await.unwrap();
14753///
14754/// # let client = hyper_util::client::legacy::Client::builder(
14755/// #     hyper_util::rt::TokioExecutor::new()
14756/// # )
14757/// # .build(
14758/// #     hyper_rustls::HttpsConnectorBuilder::new()
14759/// #         .with_native_roots()
14760/// #         .unwrap()
14761/// #         .https_or_http()
14762/// #         .enable_http2()
14763/// #         .build()
14764/// # );
14765/// # let mut hub = Vision::new(client, auth);
14766/// // As the method needs a request, you would usually fill it with the desired information
14767/// // into the respective structure. Some of the parts shown here might not be applicable !
14768/// // Values shown here are possibly random and not representative !
14769/// let mut req = PurgeProductsRequest::default();
14770///
14771/// // You can configure optional parameters by calling the respective setters at will, and
14772/// // execute the final call using `doit()`.
14773/// // Values shown here are possibly random and not representative !
14774/// let result = hub.projects().locations_products_purge(req, "parent")
14775///              .doit().await;
14776/// # }
14777/// ```
14778pub struct ProjectLocationProductPurgeCall<'a, C>
14779where
14780    C: 'a,
14781{
14782    hub: &'a Vision<C>,
14783    _request: PurgeProductsRequest,
14784    _parent: String,
14785    _delegate: Option<&'a mut dyn common::Delegate>,
14786    _additional_params: HashMap<String, String>,
14787    _scopes: BTreeSet<String>,
14788}
14789
14790impl<'a, C> common::CallBuilder for ProjectLocationProductPurgeCall<'a, C> {}
14791
14792impl<'a, C> ProjectLocationProductPurgeCall<'a, C>
14793where
14794    C: common::Connector,
14795{
14796    /// Perform the operation you have build so far.
14797    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
14798        use std::borrow::Cow;
14799        use std::io::{Read, Seek};
14800
14801        use common::{url::Params, ToParts};
14802        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14803
14804        let mut dd = common::DefaultDelegate;
14805        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14806        dlg.begin(common::MethodInfo {
14807            id: "vision.projects.locations.products.purge",
14808            http_method: hyper::Method::POST,
14809        });
14810
14811        for &field in ["alt", "parent"].iter() {
14812            if self._additional_params.contains_key(field) {
14813                dlg.finished(false);
14814                return Err(common::Error::FieldClash(field));
14815            }
14816        }
14817
14818        let mut params = Params::with_capacity(4 + self._additional_params.len());
14819        params.push("parent", self._parent);
14820
14821        params.extend(self._additional_params.iter());
14822
14823        params.push("alt", "json");
14824        let mut url = self.hub._base_url.clone() + "v1/{+parent}/products:purge";
14825        if self._scopes.is_empty() {
14826            self._scopes
14827                .insert(Scope::CloudPlatform.as_ref().to_string());
14828        }
14829
14830        #[allow(clippy::single_element_loop)]
14831        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
14832            url = params.uri_replacement(url, param_name, find_this, true);
14833        }
14834        {
14835            let to_remove = ["parent"];
14836            params.remove_params(&to_remove);
14837        }
14838
14839        let url = params.parse_with_url(&url);
14840
14841        let mut json_mime_type = mime::APPLICATION_JSON;
14842        let mut request_value_reader = {
14843            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14844            common::remove_json_null_values(&mut value);
14845            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14846            serde_json::to_writer(&mut dst, &value).unwrap();
14847            dst
14848        };
14849        let request_size = request_value_reader
14850            .seek(std::io::SeekFrom::End(0))
14851            .unwrap();
14852        request_value_reader
14853            .seek(std::io::SeekFrom::Start(0))
14854            .unwrap();
14855
14856        loop {
14857            let token = match self
14858                .hub
14859                .auth
14860                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14861                .await
14862            {
14863                Ok(token) => token,
14864                Err(e) => match dlg.token(e) {
14865                    Ok(token) => token,
14866                    Err(e) => {
14867                        dlg.finished(false);
14868                        return Err(common::Error::MissingToken(e));
14869                    }
14870                },
14871            };
14872            request_value_reader
14873                .seek(std::io::SeekFrom::Start(0))
14874                .unwrap();
14875            let mut req_result = {
14876                let client = &self.hub.client;
14877                dlg.pre_request();
14878                let mut req_builder = hyper::Request::builder()
14879                    .method(hyper::Method::POST)
14880                    .uri(url.as_str())
14881                    .header(USER_AGENT, self.hub._user_agent.clone());
14882
14883                if let Some(token) = token.as_ref() {
14884                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14885                }
14886
14887                let request = req_builder
14888                    .header(CONTENT_TYPE, json_mime_type.to_string())
14889                    .header(CONTENT_LENGTH, request_size as u64)
14890                    .body(common::to_body(
14891                        request_value_reader.get_ref().clone().into(),
14892                    ));
14893
14894                client.request(request.unwrap()).await
14895            };
14896
14897            match req_result {
14898                Err(err) => {
14899                    if let common::Retry::After(d) = dlg.http_error(&err) {
14900                        sleep(d).await;
14901                        continue;
14902                    }
14903                    dlg.finished(false);
14904                    return Err(common::Error::HttpError(err));
14905                }
14906                Ok(res) => {
14907                    let (mut parts, body) = res.into_parts();
14908                    let mut body = common::Body::new(body);
14909                    if !parts.status.is_success() {
14910                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14911                        let error = serde_json::from_str(&common::to_string(&bytes));
14912                        let response = common::to_response(parts, bytes.into());
14913
14914                        if let common::Retry::After(d) =
14915                            dlg.http_failure(&response, error.as_ref().ok())
14916                        {
14917                            sleep(d).await;
14918                            continue;
14919                        }
14920
14921                        dlg.finished(false);
14922
14923                        return Err(match error {
14924                            Ok(value) => common::Error::BadRequest(value),
14925                            _ => common::Error::Failure(response),
14926                        });
14927                    }
14928                    let response = {
14929                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14930                        let encoded = common::to_string(&bytes);
14931                        match serde_json::from_str(&encoded) {
14932                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14933                            Err(error) => {
14934                                dlg.response_json_decode_error(&encoded, &error);
14935                                return Err(common::Error::JsonDecodeError(
14936                                    encoded.to_string(),
14937                                    error,
14938                                ));
14939                            }
14940                        }
14941                    };
14942
14943                    dlg.finished(true);
14944                    return Ok(response);
14945                }
14946            }
14947        }
14948    }
14949
14950    ///
14951    /// Sets the *request* property to the given value.
14952    ///
14953    /// Even though the property as already been set when instantiating this call,
14954    /// we provide this method for API completeness.
14955    pub fn request(
14956        mut self,
14957        new_value: PurgeProductsRequest,
14958    ) -> ProjectLocationProductPurgeCall<'a, C> {
14959        self._request = new_value;
14960        self
14961    }
14962    /// Required. The project and location in which the Products should be deleted. Format is `projects/PROJECT_ID/locations/LOC_ID`.
14963    ///
14964    /// Sets the *parent* path property to the given value.
14965    ///
14966    /// Even though the property as already been set when instantiating this call,
14967    /// we provide this method for API completeness.
14968    pub fn parent(mut self, new_value: &str) -> ProjectLocationProductPurgeCall<'a, C> {
14969        self._parent = new_value.to_string();
14970        self
14971    }
14972    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14973    /// while executing the actual API request.
14974    ///
14975    /// ````text
14976    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14977    /// ````
14978    ///
14979    /// Sets the *delegate* property to the given value.
14980    pub fn delegate(
14981        mut self,
14982        new_value: &'a mut dyn common::Delegate,
14983    ) -> ProjectLocationProductPurgeCall<'a, C> {
14984        self._delegate = Some(new_value);
14985        self
14986    }
14987
14988    /// Set any additional parameter of the query string used in the request.
14989    /// It should be used to set parameters which are not yet available through their own
14990    /// setters.
14991    ///
14992    /// Please note that this method must not be used to set any of the known parameters
14993    /// which have their own setter method. If done anyway, the request will fail.
14994    ///
14995    /// # Additional Parameters
14996    ///
14997    /// * *$.xgafv* (query-string) - V1 error format.
14998    /// * *access_token* (query-string) - OAuth access token.
14999    /// * *alt* (query-string) - Data format for response.
15000    /// * *callback* (query-string) - JSONP
15001    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15002    /// * *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.
15003    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15004    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15005    /// * *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.
15006    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15007    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15008    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationProductPurgeCall<'a, C>
15009    where
15010        T: AsRef<str>,
15011    {
15012        self._additional_params
15013            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15014        self
15015    }
15016
15017    /// Identifies the authorization scope for the method you are building.
15018    ///
15019    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15020    /// [`Scope::CloudPlatform`].
15021    ///
15022    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15023    /// tokens for more than one scope.
15024    ///
15025    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15026    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15027    /// sufficient, a read-write scope will do as well.
15028    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationProductPurgeCall<'a, C>
15029    where
15030        St: AsRef<str>,
15031    {
15032        self._scopes.insert(String::from(scope.as_ref()));
15033        self
15034    }
15035    /// Identifies the authorization scope(s) for the method you are building.
15036    ///
15037    /// See [`Self::add_scope()`] for details.
15038    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationProductPurgeCall<'a, C>
15039    where
15040        I: IntoIterator<Item = St>,
15041        St: AsRef<str>,
15042    {
15043        self._scopes
15044            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15045        self
15046    }
15047
15048    /// Removes all scopes, and no default scope will be used either.
15049    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15050    /// for details).
15051    pub fn clear_scopes(mut self) -> ProjectLocationProductPurgeCall<'a, C> {
15052        self._scopes.clear();
15053        self
15054    }
15055}
15056
15057/// 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.
15058///
15059/// A builder for the *operations.get* method supported by a *project* resource.
15060/// It is not used directly, but through a [`ProjectMethods`] instance.
15061///
15062/// # Example
15063///
15064/// Instantiate a resource method builder
15065///
15066/// ```test_harness,no_run
15067/// # extern crate hyper;
15068/// # extern crate hyper_rustls;
15069/// # extern crate google_vision1 as vision1;
15070/// # async fn dox() {
15071/// # use vision1::{Vision, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15072///
15073/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15074/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15075/// #     .with_native_roots()
15076/// #     .unwrap()
15077/// #     .https_only()
15078/// #     .enable_http2()
15079/// #     .build();
15080///
15081/// # let executor = hyper_util::rt::TokioExecutor::new();
15082/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15083/// #     secret,
15084/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15085/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15086/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15087/// #     ),
15088/// # ).build().await.unwrap();
15089///
15090/// # let client = hyper_util::client::legacy::Client::builder(
15091/// #     hyper_util::rt::TokioExecutor::new()
15092/// # )
15093/// # .build(
15094/// #     hyper_rustls::HttpsConnectorBuilder::new()
15095/// #         .with_native_roots()
15096/// #         .unwrap()
15097/// #         .https_or_http()
15098/// #         .enable_http2()
15099/// #         .build()
15100/// # );
15101/// # let mut hub = Vision::new(client, auth);
15102/// // You can configure optional parameters by calling the respective setters at will, and
15103/// // execute the final call using `doit()`.
15104/// // Values shown here are possibly random and not representative !
15105/// let result = hub.projects().operations_get("name")
15106///              .doit().await;
15107/// # }
15108/// ```
15109pub struct ProjectOperationGetCall<'a, C>
15110where
15111    C: 'a,
15112{
15113    hub: &'a Vision<C>,
15114    _name: String,
15115    _delegate: Option<&'a mut dyn common::Delegate>,
15116    _additional_params: HashMap<String, String>,
15117    _scopes: BTreeSet<String>,
15118}
15119
15120impl<'a, C> common::CallBuilder for ProjectOperationGetCall<'a, C> {}
15121
15122impl<'a, C> ProjectOperationGetCall<'a, C>
15123where
15124    C: common::Connector,
15125{
15126    /// Perform the operation you have build so far.
15127    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
15128        use std::borrow::Cow;
15129        use std::io::{Read, Seek};
15130
15131        use common::{url::Params, ToParts};
15132        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15133
15134        let mut dd = common::DefaultDelegate;
15135        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15136        dlg.begin(common::MethodInfo {
15137            id: "vision.projects.operations.get",
15138            http_method: hyper::Method::GET,
15139        });
15140
15141        for &field in ["alt", "name"].iter() {
15142            if self._additional_params.contains_key(field) {
15143                dlg.finished(false);
15144                return Err(common::Error::FieldClash(field));
15145            }
15146        }
15147
15148        let mut params = Params::with_capacity(3 + self._additional_params.len());
15149        params.push("name", self._name);
15150
15151        params.extend(self._additional_params.iter());
15152
15153        params.push("alt", "json");
15154        let mut url = self.hub._base_url.clone() + "v1/{+name}";
15155        if self._scopes.is_empty() {
15156            self._scopes
15157                .insert(Scope::CloudPlatform.as_ref().to_string());
15158        }
15159
15160        #[allow(clippy::single_element_loop)]
15161        for &(find_this, param_name) in [("{+name}", "name")].iter() {
15162            url = params.uri_replacement(url, param_name, find_this, true);
15163        }
15164        {
15165            let to_remove = ["name"];
15166            params.remove_params(&to_remove);
15167        }
15168
15169        let url = params.parse_with_url(&url);
15170
15171        loop {
15172            let token = match self
15173                .hub
15174                .auth
15175                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15176                .await
15177            {
15178                Ok(token) => token,
15179                Err(e) => match dlg.token(e) {
15180                    Ok(token) => token,
15181                    Err(e) => {
15182                        dlg.finished(false);
15183                        return Err(common::Error::MissingToken(e));
15184                    }
15185                },
15186            };
15187            let mut req_result = {
15188                let client = &self.hub.client;
15189                dlg.pre_request();
15190                let mut req_builder = hyper::Request::builder()
15191                    .method(hyper::Method::GET)
15192                    .uri(url.as_str())
15193                    .header(USER_AGENT, self.hub._user_agent.clone());
15194
15195                if let Some(token) = token.as_ref() {
15196                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15197                }
15198
15199                let request = req_builder
15200                    .header(CONTENT_LENGTH, 0_u64)
15201                    .body(common::to_body::<String>(None));
15202
15203                client.request(request.unwrap()).await
15204            };
15205
15206            match req_result {
15207                Err(err) => {
15208                    if let common::Retry::After(d) = dlg.http_error(&err) {
15209                        sleep(d).await;
15210                        continue;
15211                    }
15212                    dlg.finished(false);
15213                    return Err(common::Error::HttpError(err));
15214                }
15215                Ok(res) => {
15216                    let (mut parts, body) = res.into_parts();
15217                    let mut body = common::Body::new(body);
15218                    if !parts.status.is_success() {
15219                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15220                        let error = serde_json::from_str(&common::to_string(&bytes));
15221                        let response = common::to_response(parts, bytes.into());
15222
15223                        if let common::Retry::After(d) =
15224                            dlg.http_failure(&response, error.as_ref().ok())
15225                        {
15226                            sleep(d).await;
15227                            continue;
15228                        }
15229
15230                        dlg.finished(false);
15231
15232                        return Err(match error {
15233                            Ok(value) => common::Error::BadRequest(value),
15234                            _ => common::Error::Failure(response),
15235                        });
15236                    }
15237                    let response = {
15238                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15239                        let encoded = common::to_string(&bytes);
15240                        match serde_json::from_str(&encoded) {
15241                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15242                            Err(error) => {
15243                                dlg.response_json_decode_error(&encoded, &error);
15244                                return Err(common::Error::JsonDecodeError(
15245                                    encoded.to_string(),
15246                                    error,
15247                                ));
15248                            }
15249                        }
15250                    };
15251
15252                    dlg.finished(true);
15253                    return Ok(response);
15254                }
15255            }
15256        }
15257    }
15258
15259    /// The name of the operation resource.
15260    ///
15261    /// Sets the *name* path property to the given value.
15262    ///
15263    /// Even though the property as already been set when instantiating this call,
15264    /// we provide this method for API completeness.
15265    pub fn name(mut self, new_value: &str) -> ProjectOperationGetCall<'a, C> {
15266        self._name = new_value.to_string();
15267        self
15268    }
15269    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15270    /// while executing the actual API request.
15271    ///
15272    /// ````text
15273    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15274    /// ````
15275    ///
15276    /// Sets the *delegate* property to the given value.
15277    pub fn delegate(
15278        mut self,
15279        new_value: &'a mut dyn common::Delegate,
15280    ) -> ProjectOperationGetCall<'a, C> {
15281        self._delegate = Some(new_value);
15282        self
15283    }
15284
15285    /// Set any additional parameter of the query string used in the request.
15286    /// It should be used to set parameters which are not yet available through their own
15287    /// setters.
15288    ///
15289    /// Please note that this method must not be used to set any of the known parameters
15290    /// which have their own setter method. If done anyway, the request will fail.
15291    ///
15292    /// # Additional Parameters
15293    ///
15294    /// * *$.xgafv* (query-string) - V1 error format.
15295    /// * *access_token* (query-string) - OAuth access token.
15296    /// * *alt* (query-string) - Data format for response.
15297    /// * *callback* (query-string) - JSONP
15298    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15299    /// * *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.
15300    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15301    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15302    /// * *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.
15303    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15304    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15305    pub fn param<T>(mut self, name: T, value: T) -> ProjectOperationGetCall<'a, C>
15306    where
15307        T: AsRef<str>,
15308    {
15309        self._additional_params
15310            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15311        self
15312    }
15313
15314    /// Identifies the authorization scope for the method you are building.
15315    ///
15316    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15317    /// [`Scope::CloudPlatform`].
15318    ///
15319    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15320    /// tokens for more than one scope.
15321    ///
15322    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15323    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15324    /// sufficient, a read-write scope will do as well.
15325    pub fn add_scope<St>(mut self, scope: St) -> ProjectOperationGetCall<'a, C>
15326    where
15327        St: AsRef<str>,
15328    {
15329        self._scopes.insert(String::from(scope.as_ref()));
15330        self
15331    }
15332    /// Identifies the authorization scope(s) for the method you are building.
15333    ///
15334    /// See [`Self::add_scope()`] for details.
15335    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOperationGetCall<'a, C>
15336    where
15337        I: IntoIterator<Item = St>,
15338        St: AsRef<str>,
15339    {
15340        self._scopes
15341            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15342        self
15343    }
15344
15345    /// Removes all scopes, and no default scope will be used either.
15346    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15347    /// for details).
15348    pub fn clear_scopes(mut self) -> ProjectOperationGetCall<'a, C> {
15349        self._scopes.clear();
15350        self
15351    }
15352}