google_videointelligence1/
api.rs

1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16    /// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
17    CloudPlatform,
18}
19
20impl AsRef<str> for Scope {
21    fn as_ref(&self) -> &str {
22        match *self {
23            Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
24        }
25    }
26}
27
28#[allow(clippy::derivable_impls)]
29impl Default for Scope {
30    fn default() -> Scope {
31        Scope::CloudPlatform
32    }
33}
34
35// ########
36// HUB ###
37// ######
38
39/// Central instance to access all CloudVideoIntelligence related resource activities
40///
41/// # Examples
42///
43/// Instantiate a new hub
44///
45/// ```test_harness,no_run
46/// extern crate hyper;
47/// extern crate hyper_rustls;
48/// extern crate google_videointelligence1 as videointelligence1;
49/// use videointelligence1::api::GoogleLongrunning_CancelOperationRequest;
50/// use videointelligence1::{Result, Error};
51/// # async fn dox() {
52/// use videointelligence1::{CloudVideoIntelligence, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
53///
54/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
55/// // `client_secret`, among other things.
56/// let secret: yup_oauth2::ApplicationSecret = Default::default();
57/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
58/// // unless you replace  `None` with the desired Flow.
59/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
60/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
61/// // retrieve them from storage.
62/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
63///     .with_native_roots()
64///     .unwrap()
65///     .https_only()
66///     .enable_http2()
67///     .build();
68///
69/// let executor = hyper_util::rt::TokioExecutor::new();
70/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
71///     secret,
72///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
73///     yup_oauth2::client::CustomHyperClientBuilder::from(
74///         hyper_util::client::legacy::Client::builder(executor).build(connector),
75///     ),
76/// ).build().await.unwrap();
77///
78/// let client = hyper_util::client::legacy::Client::builder(
79///     hyper_util::rt::TokioExecutor::new()
80/// )
81/// .build(
82///     hyper_rustls::HttpsConnectorBuilder::new()
83///         .with_native_roots()
84///         .unwrap()
85///         .https_or_http()
86///         .enable_http2()
87///         .build()
88/// );
89/// let mut hub = CloudVideoIntelligence::new(client, auth);
90/// // As the method needs a request, you would usually fill it with the desired information
91/// // into the respective structure. Some of the parts shown here might not be applicable !
92/// // Values shown here are possibly random and not representative !
93/// let mut req = GoogleLongrunning_CancelOperationRequest::default();
94///
95/// // You can configure optional parameters by calling the respective setters at will, and
96/// // execute the final call using `doit()`.
97/// // Values shown here are possibly random and not representative !
98/// let result = hub.projects().locations_operations_cancel(req, "name")
99///              .doit().await;
100///
101/// match result {
102///     Err(e) => match e {
103///         // The Error enum provides details about what exactly happened.
104///         // You can also just use its `Debug`, `Display` or `Error` traits
105///          Error::HttpError(_)
106///         |Error::Io(_)
107///         |Error::MissingAPIKey
108///         |Error::MissingToken(_)
109///         |Error::Cancelled
110///         |Error::UploadSizeLimitExceeded(_, _)
111///         |Error::Failure(_)
112///         |Error::BadRequest(_)
113///         |Error::FieldClash(_)
114///         |Error::JsonDecodeError(_, _) => println!("{}", e),
115///     },
116///     Ok(res) => println!("Success: {:?}", res),
117/// }
118/// # }
119/// ```
120#[derive(Clone)]
121pub struct CloudVideoIntelligence<C> {
122    pub client: common::Client<C>,
123    pub auth: Box<dyn common::GetToken>,
124    _user_agent: String,
125    _base_url: String,
126    _root_url: String,
127}
128
129impl<C> common::Hub for CloudVideoIntelligence<C> {}
130
131impl<'a, C> CloudVideoIntelligence<C> {
132    pub fn new<A: 'static + common::GetToken>(
133        client: common::Client<C>,
134        auth: A,
135    ) -> CloudVideoIntelligence<C> {
136        CloudVideoIntelligence {
137            client,
138            auth: Box::new(auth),
139            _user_agent: "google-api-rust-client/7.0.0".to_string(),
140            _base_url: "https://videointelligence.googleapis.com/".to_string(),
141            _root_url: "https://videointelligence.googleapis.com/".to_string(),
142        }
143    }
144
145    pub fn operations(&'a self) -> OperationMethods<'a, C> {
146        OperationMethods { hub: self }
147    }
148    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
149        ProjectMethods { hub: self }
150    }
151    pub fn videos(&'a self) -> VideoMethods<'a, C> {
152        VideoMethods { hub: self }
153    }
154
155    /// Set the user-agent header field to use in all requests to the server.
156    /// It defaults to `google-api-rust-client/7.0.0`.
157    ///
158    /// Returns the previously set user-agent.
159    pub fn user_agent(&mut self, agent_name: String) -> String {
160        std::mem::replace(&mut self._user_agent, agent_name)
161    }
162
163    /// Set the base url to use in all requests to the server.
164    /// It defaults to `https://videointelligence.googleapis.com/`.
165    ///
166    /// Returns the previously set base url.
167    pub fn base_url(&mut self, new_base_url: String) -> String {
168        std::mem::replace(&mut self._base_url, new_base_url)
169    }
170
171    /// Set the root url to use in all requests to the server.
172    /// It defaults to `https://videointelligence.googleapis.com/`.
173    ///
174    /// Returns the previously set root url.
175    pub fn root_url(&mut self, new_root_url: String) -> String {
176        std::mem::replace(&mut self._root_url, new_root_url)
177    }
178}
179
180// ############
181// SCHEMAS ###
182// ##########
183/// Video annotation request.
184///
185/// # Activities
186///
187/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
188/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
189///
190/// * [annotate videos](VideoAnnotateCall) (request)
191#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
192#[serde_with::serde_as]
193#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
194pub struct GoogleCloudVideointelligenceV1_AnnotateVideoRequest {
195    /// Required. Requested video annotation features.
196    pub features: Option<Vec<String>>,
197    /// The video data bytes. If unset, the input video(s) should be specified via the `input_uri`. If set, `input_uri` must be unset.
198    #[serde(rename = "inputContent")]
199    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
200    pub input_content: Option<Vec<u8>>,
201    /// Input video location. Currently, only [Cloud Storage](https://cloud.google.com/storage/) URIs are supported. URIs must be specified in the following format: `gs://bucket-id/object-id` (other URI formats return google.rpc.Code.INVALID_ARGUMENT). For more information, see [Request URIs](https://cloud.google.com/storage/docs/request-endpoints). To identify multiple videos, a video URI may include wildcards in the `object-id`. Supported wildcards: '*' to match 0 or more characters; '?' to match 1 character. If unset, the input video should be embedded in the request as `input_content`. If set, `input_content` must be unset.
202    #[serde(rename = "inputUri")]
203    pub input_uri: Option<String>,
204    /// Optional. Cloud region where annotation should take place. Supported cloud regions are: `us-east1`, `us-west1`, `europe-west1`, `asia-east1`. If no region is specified, the region will be determined based on video file location.
205    #[serde(rename = "locationId")]
206    pub location_id: Option<String>,
207    /// Optional. Location where the output (in JSON format) should be stored. Currently, only [Cloud Storage](https://cloud.google.com/storage/) URIs are supported. These must be specified in the following format: `gs://bucket-id/object-id` (other URI formats return google.rpc.Code.INVALID_ARGUMENT). For more information, see [Request URIs](https://cloud.google.com/storage/docs/request-endpoints).
208    #[serde(rename = "outputUri")]
209    pub output_uri: Option<String>,
210    /// Additional video context and/or feature-specific parameters.
211    #[serde(rename = "videoContext")]
212    pub video_context: Option<GoogleCloudVideointelligenceV1_VideoContext>,
213}
214
215impl common::RequestValue for GoogleCloudVideointelligenceV1_AnnotateVideoRequest {}
216
217/// Config for EXPLICIT_CONTENT_DETECTION.
218///
219/// This type is not used in any activity, and only used as *part* of another schema.
220///
221#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
222#[serde_with::serde_as]
223#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
224pub struct GoogleCloudVideointelligenceV1_ExplicitContentDetectionConfig {
225    /// Model to use for explicit content detection. Supported values: "builtin/stable" (the default if unset) and "builtin/latest".
226    pub model: Option<String>,
227}
228
229impl common::Part for GoogleCloudVideointelligenceV1_ExplicitContentDetectionConfig {}
230
231/// Config for FACE_DETECTION.
232///
233/// This type is not used in any activity, and only used as *part* of another schema.
234///
235#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
236#[serde_with::serde_as]
237#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
238pub struct GoogleCloudVideointelligenceV1_FaceDetectionConfig {
239    /// Whether to enable face attributes detection, such as glasses, dark_glasses, mouth_open etc. Ignored if 'include_bounding_boxes' is set to false.
240    #[serde(rename = "includeAttributes")]
241    pub include_attributes: Option<bool>,
242    /// Whether bounding boxes are included in the face annotation output.
243    #[serde(rename = "includeBoundingBoxes")]
244    pub include_bounding_boxes: Option<bool>,
245    /// Model to use for face detection. Supported values: "builtin/stable" (the default if unset) and "builtin/latest".
246    pub model: Option<String>,
247}
248
249impl common::Part for GoogleCloudVideointelligenceV1_FaceDetectionConfig {}
250
251/// Config for LABEL_DETECTION.
252///
253/// This type is not used in any activity, and only used as *part* of another schema.
254///
255#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
256#[serde_with::serde_as]
257#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
258pub struct GoogleCloudVideointelligenceV1_LabelDetectionConfig {
259    /// The confidence threshold we perform filtering on the labels from frame-level detection. If not set, it is set to 0.4 by default. The valid range for this threshold is [0.1, 0.9]. Any value set outside of this range will be clipped. Note: For best results, follow the default threshold. We will update the default threshold everytime when we release a new model.
260    #[serde(rename = "frameConfidenceThreshold")]
261    pub frame_confidence_threshold: Option<f32>,
262    /// What labels should be detected with LABEL_DETECTION, in addition to video-level labels or segment-level labels. If unspecified, defaults to `SHOT_MODE`.
263    #[serde(rename = "labelDetectionMode")]
264    pub label_detection_mode: Option<String>,
265    /// Model to use for label detection. Supported values: "builtin/stable" (the default if unset) and "builtin/latest".
266    pub model: Option<String>,
267    /// Whether the video has been shot from a stationary (i.e., non-moving) camera. When set to true, might improve detection accuracy for moving objects. Should be used with `SHOT_AND_FRAME_MODE` enabled.
268    #[serde(rename = "stationaryCamera")]
269    pub stationary_camera: Option<bool>,
270    /// The confidence threshold we perform filtering on the labels from video-level and shot-level detections. If not set, it's set to 0.3 by default. The valid range for this threshold is [0.1, 0.9]. Any value set outside of this range will be clipped. Note: For best results, follow the default threshold. We will update the default threshold everytime when we release a new model.
271    #[serde(rename = "videoConfidenceThreshold")]
272    pub video_confidence_threshold: Option<f32>,
273}
274
275impl common::Part for GoogleCloudVideointelligenceV1_LabelDetectionConfig {}
276
277/// Config for OBJECT_TRACKING.
278///
279/// This type is not used in any activity, and only used as *part* of another schema.
280///
281#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
282#[serde_with::serde_as]
283#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
284pub struct GoogleCloudVideointelligenceV1_ObjectTrackingConfig {
285    /// Model to use for object tracking. Supported values: "builtin/stable" (the default if unset) and "builtin/latest".
286    pub model: Option<String>,
287}
288
289impl common::Part for GoogleCloudVideointelligenceV1_ObjectTrackingConfig {}
290
291/// Config for PERSON_DETECTION.
292///
293/// This type is not used in any activity, and only used as *part* of another schema.
294///
295#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
296#[serde_with::serde_as]
297#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
298pub struct GoogleCloudVideointelligenceV1_PersonDetectionConfig {
299    /// Whether to enable person attributes detection, such as cloth color (black, blue, etc), type (coat, dress, etc), pattern (plain, floral, etc), hair, etc. Ignored if 'include_bounding_boxes' is set to false.
300    #[serde(rename = "includeAttributes")]
301    pub include_attributes: Option<bool>,
302    /// Whether bounding boxes are included in the person detection annotation output.
303    #[serde(rename = "includeBoundingBoxes")]
304    pub include_bounding_boxes: Option<bool>,
305    /// Whether to enable pose landmarks detection. Ignored if 'include_bounding_boxes' is set to false.
306    #[serde(rename = "includePoseLandmarks")]
307    pub include_pose_landmarks: Option<bool>,
308}
309
310impl common::Part for GoogleCloudVideointelligenceV1_PersonDetectionConfig {}
311
312/// Config for SHOT_CHANGE_DETECTION.
313///
314/// This type is not used in any activity, and only used as *part* of another schema.
315///
316#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
317#[serde_with::serde_as]
318#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
319pub struct GoogleCloudVideointelligenceV1_ShotChangeDetectionConfig {
320    /// Model to use for shot change detection. Supported values: "builtin/stable" (the default if unset), "builtin/latest", and "builtin/legacy".
321    pub model: Option<String>,
322}
323
324impl common::Part for GoogleCloudVideointelligenceV1_ShotChangeDetectionConfig {}
325
326/// Provides "hints" to the speech recognizer to favor specific words and phrases in the results.
327///
328/// This type is not used in any activity, and only used as *part* of another schema.
329///
330#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
331#[serde_with::serde_as]
332#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
333pub struct GoogleCloudVideointelligenceV1_SpeechContext {
334    /// Optional. A list of strings containing words and phrases "hints" so that the speech recognition is more likely to recognize them. This can be used to improve the accuracy for specific words and phrases, for example, if specific commands are typically spoken by the user. This can also be used to add additional words to the vocabulary of the recognizer. See [usage limits](https://cloud.google.com/speech/limits#content).
335    pub phrases: Option<Vec<String>>,
336}
337
338impl common::Part for GoogleCloudVideointelligenceV1_SpeechContext {}
339
340/// Config for SPEECH_TRANSCRIPTION.
341///
342/// This type is not used in any activity, and only used as *part* of another schema.
343///
344#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
345#[serde_with::serde_as]
346#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
347pub struct GoogleCloudVideointelligenceV1_SpeechTranscriptionConfig {
348    /// Optional. For file formats, such as MXF or MKV, supporting multiple audio tracks, specify up to two tracks. Default: track 0.
349    #[serde(rename = "audioTracks")]
350    pub audio_tracks: Option<Vec<i32>>,
351    /// Optional. If set, specifies the estimated number of speakers in the conversation. If not set, defaults to '2'. Ignored unless enable_speaker_diarization is set to true.
352    #[serde(rename = "diarizationSpeakerCount")]
353    pub diarization_speaker_count: Option<i32>,
354    /// Optional. If 'true', adds punctuation to recognition result hypotheses. This feature is only available in select languages. Setting this for requests in other languages has no effect at all. The default 'false' value does not add punctuation to result hypotheses. NOTE: "This is currently offered as an experimental service, complimentary to all users. In the future this may be exclusively available as a premium feature."
355    #[serde(rename = "enableAutomaticPunctuation")]
356    pub enable_automatic_punctuation: Option<bool>,
357    /// Optional. If 'true', enables speaker detection for each recognized word in the top alternative of the recognition result using a speaker_tag provided in the WordInfo. Note: When this is true, we send all the words from the beginning of the audio for the top alternative in every consecutive response. This is done in order to improve our speaker tags as our models learn to identify the speakers in the conversation over time.
358    #[serde(rename = "enableSpeakerDiarization")]
359    pub enable_speaker_diarization: Option<bool>,
360    /// Optional. If `true`, the top result includes a list of words and the confidence for those words. If `false`, no word-level confidence information is returned. The default is `false`.
361    #[serde(rename = "enableWordConfidence")]
362    pub enable_word_confidence: Option<bool>,
363    /// Optional. If set to `true`, the server will attempt to filter out profanities, replacing all but the initial character in each filtered word with asterisks, e.g. "f***". If set to `false` or omitted, profanities won't be filtered out.
364    #[serde(rename = "filterProfanity")]
365    pub filter_profanity: Option<bool>,
366    /// Required. *Required* The language of the supplied audio as a [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag. Example: "en-US". See [Language Support](https://cloud.google.com/speech/docs/languages) for a list of the currently supported language codes.
367    #[serde(rename = "languageCode")]
368    pub language_code: Option<String>,
369    /// Optional. Maximum number of recognition hypotheses to be returned. Specifically, the maximum number of `SpeechRecognitionAlternative` messages within each `SpeechTranscription`. The server may return fewer than `max_alternatives`. Valid values are `0`-`30`. A value of `0` or `1` will return a maximum of one. If omitted, will return a maximum of one.
370    #[serde(rename = "maxAlternatives")]
371    pub max_alternatives: Option<i32>,
372    /// Optional. A means to provide context to assist the speech recognition.
373    #[serde(rename = "speechContexts")]
374    pub speech_contexts: Option<Vec<GoogleCloudVideointelligenceV1_SpeechContext>>,
375}
376
377impl common::Part for GoogleCloudVideointelligenceV1_SpeechTranscriptionConfig {}
378
379/// Config for TEXT_DETECTION.
380///
381/// This type is not used in any activity, and only used as *part* of another schema.
382///
383#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
384#[serde_with::serde_as]
385#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
386pub struct GoogleCloudVideointelligenceV1_TextDetectionConfig {
387    /// Language hint can be specified if the language to be detected is known a priori. It can increase the accuracy of the detection. Language hint must be language code in BCP-47 format. Automatic language detection is performed if no hint is provided.
388    #[serde(rename = "languageHints")]
389    pub language_hints: Option<Vec<String>>,
390    /// Model to use for text detection. Supported values: "builtin/stable" (the default if unset) and "builtin/latest".
391    pub model: Option<String>,
392}
393
394impl common::Part for GoogleCloudVideointelligenceV1_TextDetectionConfig {}
395
396/// Video context and/or feature-specific parameters.
397///
398/// This type is not used in any activity, and only used as *part* of another schema.
399///
400#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
401#[serde_with::serde_as]
402#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
403pub struct GoogleCloudVideointelligenceV1_VideoContext {
404    /// Config for EXPLICIT_CONTENT_DETECTION.
405    #[serde(rename = "explicitContentDetectionConfig")]
406    pub explicit_content_detection_config:
407        Option<GoogleCloudVideointelligenceV1_ExplicitContentDetectionConfig>,
408    /// Config for FACE_DETECTION.
409    #[serde(rename = "faceDetectionConfig")]
410    pub face_detection_config: Option<GoogleCloudVideointelligenceV1_FaceDetectionConfig>,
411    /// Config for LABEL_DETECTION.
412    #[serde(rename = "labelDetectionConfig")]
413    pub label_detection_config: Option<GoogleCloudVideointelligenceV1_LabelDetectionConfig>,
414    /// Config for OBJECT_TRACKING.
415    #[serde(rename = "objectTrackingConfig")]
416    pub object_tracking_config: Option<GoogleCloudVideointelligenceV1_ObjectTrackingConfig>,
417    /// Config for PERSON_DETECTION.
418    #[serde(rename = "personDetectionConfig")]
419    pub person_detection_config: Option<GoogleCloudVideointelligenceV1_PersonDetectionConfig>,
420    /// Video segments to annotate. The segments may overlap and are not required to be contiguous or span the whole video. If unspecified, each video is treated as a single segment.
421    pub segments: Option<Vec<GoogleCloudVideointelligenceV1_VideoSegment>>,
422    /// Config for SHOT_CHANGE_DETECTION.
423    #[serde(rename = "shotChangeDetectionConfig")]
424    pub shot_change_detection_config:
425        Option<GoogleCloudVideointelligenceV1_ShotChangeDetectionConfig>,
426    /// Config for SPEECH_TRANSCRIPTION.
427    #[serde(rename = "speechTranscriptionConfig")]
428    pub speech_transcription_config:
429        Option<GoogleCloudVideointelligenceV1_SpeechTranscriptionConfig>,
430    /// Config for TEXT_DETECTION.
431    #[serde(rename = "textDetectionConfig")]
432    pub text_detection_config: Option<GoogleCloudVideointelligenceV1_TextDetectionConfig>,
433}
434
435impl common::Part for GoogleCloudVideointelligenceV1_VideoContext {}
436
437/// Video segment.
438///
439/// This type is not used in any activity, and only used as *part* of another schema.
440///
441#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
442#[serde_with::serde_as]
443#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
444pub struct GoogleCloudVideointelligenceV1_VideoSegment {
445    /// Time-offset, relative to the beginning of the video, corresponding to the end of the segment (inclusive).
446    #[serde(rename = "endTimeOffset")]
447    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
448    pub end_time_offset: Option<chrono::Duration>,
449    /// Time-offset, relative to the beginning of the video, corresponding to the start of the segment (inclusive).
450    #[serde(rename = "startTimeOffset")]
451    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
452    pub start_time_offset: Option<chrono::Duration>,
453}
454
455impl common::Part for GoogleCloudVideointelligenceV1_VideoSegment {}
456
457/// The request message for Operations.CancelOperation.
458///
459/// # Activities
460///
461/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
462/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
463///
464/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (request)
465#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
466#[serde_with::serde_as]
467#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
468pub struct GoogleLongrunning_CancelOperationRequest {
469    _never_set: Option<bool>,
470}
471
472impl common::RequestValue for GoogleLongrunning_CancelOperationRequest {}
473
474/// The response message for Operations.ListOperations.
475///
476/// # Activities
477///
478/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
479/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
480///
481/// * [locations operations list projects](ProjectLocationOperationListCall) (response)
482#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
483#[serde_with::serde_as]
484#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
485pub struct GoogleLongrunning_ListOperationsResponse {
486    /// The standard List next-page token.
487    #[serde(rename = "nextPageToken")]
488    pub next_page_token: Option<String>,
489    /// A list of operations that matches the specified filter in the request.
490    pub operations: Option<Vec<GoogleLongrunning_Operation>>,
491}
492
493impl common::ResponseResult for GoogleLongrunning_ListOperationsResponse {}
494
495/// This resource represents a long-running operation that is the result of a network API call.
496///
497/// # Activities
498///
499/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
500/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
501///
502/// * [projects locations operations get operations](OperationProjectLocationOperationGetCall) (response)
503/// * [locations operations get projects](ProjectLocationOperationGetCall) (response)
504/// * [annotate videos](VideoAnnotateCall) (response)
505#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
506#[serde_with::serde_as]
507#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
508pub struct GoogleLongrunning_Operation {
509    /// 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.
510    pub done: Option<bool>,
511    /// The error result of the operation in case of failure or cancellation.
512    pub error: Option<GoogleRpc_Status>,
513    /// 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.
514    pub metadata: Option<HashMap<String, serde_json::Value>>,
515    /// 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}`.
516    pub name: Option<String>,
517    /// 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`.
518    pub response: Option<HashMap<String, serde_json::Value>>,
519}
520
521impl common::ResponseResult for GoogleLongrunning_Operation {}
522
523/// 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); }
524///
525/// # Activities
526///
527/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
528/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
529///
530/// * [projects locations operations cancel operations](OperationProjectLocationOperationCancelCall) (response)
531/// * [projects locations operations delete operations](OperationProjectLocationOperationDeleteCall) (response)
532/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (response)
533/// * [locations operations delete projects](ProjectLocationOperationDeleteCall) (response)
534#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
535#[serde_with::serde_as]
536#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
537pub struct GoogleProtobuf_Empty {
538    _never_set: Option<bool>,
539}
540
541impl common::ResponseResult for GoogleProtobuf_Empty {}
542
543/// 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).
544///
545/// This type is not used in any activity, and only used as *part* of another schema.
546///
547#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
548#[serde_with::serde_as]
549#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
550pub struct GoogleRpc_Status {
551    /// The status code, which should be an enum value of google.rpc.Code.
552    pub code: Option<i32>,
553    /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
554    pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
555    /// 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.
556    pub message: Option<String>,
557}
558
559impl common::Part for GoogleRpc_Status {}
560
561// ###################
562// MethodBuilders ###
563// #################
564
565/// A builder providing access to all methods supported on *operation* resources.
566/// It is not used directly, but through the [`CloudVideoIntelligence`] hub.
567///
568/// # Example
569///
570/// Instantiate a resource builder
571///
572/// ```test_harness,no_run
573/// extern crate hyper;
574/// extern crate hyper_rustls;
575/// extern crate google_videointelligence1 as videointelligence1;
576///
577/// # async fn dox() {
578/// use videointelligence1::{CloudVideoIntelligence, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
579///
580/// let secret: yup_oauth2::ApplicationSecret = Default::default();
581/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
582///     .with_native_roots()
583///     .unwrap()
584///     .https_only()
585///     .enable_http2()
586///     .build();
587///
588/// let executor = hyper_util::rt::TokioExecutor::new();
589/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
590///     secret,
591///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
592///     yup_oauth2::client::CustomHyperClientBuilder::from(
593///         hyper_util::client::legacy::Client::builder(executor).build(connector),
594///     ),
595/// ).build().await.unwrap();
596///
597/// let client = hyper_util::client::legacy::Client::builder(
598///     hyper_util::rt::TokioExecutor::new()
599/// )
600/// .build(
601///     hyper_rustls::HttpsConnectorBuilder::new()
602///         .with_native_roots()
603///         .unwrap()
604///         .https_or_http()
605///         .enable_http2()
606///         .build()
607/// );
608/// let mut hub = CloudVideoIntelligence::new(client, auth);
609/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
610/// // like `projects_locations_operations_cancel(...)`, `projects_locations_operations_delete(...)` and `projects_locations_operations_get(...)`
611/// // to build up your call.
612/// let rb = hub.operations();
613/// # }
614/// ```
615pub struct OperationMethods<'a, C>
616where
617    C: 'a,
618{
619    hub: &'a CloudVideoIntelligence<C>,
620}
621
622impl<'a, C> common::MethodsBuilder for OperationMethods<'a, C> {}
623
624impl<'a, C> OperationMethods<'a, C> {
625    /// Create a builder to help you perform the following task:
626    ///
627    /// 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`.
628    ///
629    /// # Arguments
630    ///
631    /// * `name` - The name of the operation resource to be cancelled.
632    pub fn projects_locations_operations_cancel(
633        &self,
634        name: &str,
635    ) -> OperationProjectLocationOperationCancelCall<'a, C> {
636        OperationProjectLocationOperationCancelCall {
637            hub: self.hub,
638            _name: name.to_string(),
639            _delegate: Default::default(),
640            _additional_params: Default::default(),
641            _scopes: Default::default(),
642        }
643    }
644
645    /// Create a builder to help you perform the following task:
646    ///
647    /// 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`.
648    ///
649    /// # Arguments
650    ///
651    /// * `name` - The name of the operation resource to be deleted.
652    pub fn projects_locations_operations_delete(
653        &self,
654        name: &str,
655    ) -> OperationProjectLocationOperationDeleteCall<'a, C> {
656        OperationProjectLocationOperationDeleteCall {
657            hub: self.hub,
658            _name: name.to_string(),
659            _delegate: Default::default(),
660            _additional_params: Default::default(),
661            _scopes: Default::default(),
662        }
663    }
664
665    /// Create a builder to help you perform the following task:
666    ///
667    /// 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.
668    ///
669    /// # Arguments
670    ///
671    /// * `name` - The name of the operation resource.
672    pub fn projects_locations_operations_get(
673        &self,
674        name: &str,
675    ) -> OperationProjectLocationOperationGetCall<'a, C> {
676        OperationProjectLocationOperationGetCall {
677            hub: self.hub,
678            _name: name.to_string(),
679            _delegate: Default::default(),
680            _additional_params: Default::default(),
681            _scopes: Default::default(),
682        }
683    }
684}
685
686/// A builder providing access to all methods supported on *project* resources.
687/// It is not used directly, but through the [`CloudVideoIntelligence`] hub.
688///
689/// # Example
690///
691/// Instantiate a resource builder
692///
693/// ```test_harness,no_run
694/// extern crate hyper;
695/// extern crate hyper_rustls;
696/// extern crate google_videointelligence1 as videointelligence1;
697///
698/// # async fn dox() {
699/// use videointelligence1::{CloudVideoIntelligence, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
700///
701/// let secret: yup_oauth2::ApplicationSecret = Default::default();
702/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
703///     .with_native_roots()
704///     .unwrap()
705///     .https_only()
706///     .enable_http2()
707///     .build();
708///
709/// let executor = hyper_util::rt::TokioExecutor::new();
710/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
711///     secret,
712///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
713///     yup_oauth2::client::CustomHyperClientBuilder::from(
714///         hyper_util::client::legacy::Client::builder(executor).build(connector),
715///     ),
716/// ).build().await.unwrap();
717///
718/// let client = hyper_util::client::legacy::Client::builder(
719///     hyper_util::rt::TokioExecutor::new()
720/// )
721/// .build(
722///     hyper_rustls::HttpsConnectorBuilder::new()
723///         .with_native_roots()
724///         .unwrap()
725///         .https_or_http()
726///         .enable_http2()
727///         .build()
728/// );
729/// let mut hub = CloudVideoIntelligence::new(client, auth);
730/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
731/// // like `locations_operations_cancel(...)`, `locations_operations_delete(...)`, `locations_operations_get(...)` and `locations_operations_list(...)`
732/// // to build up your call.
733/// let rb = hub.projects();
734/// # }
735/// ```
736pub struct ProjectMethods<'a, C>
737where
738    C: 'a,
739{
740    hub: &'a CloudVideoIntelligence<C>,
741}
742
743impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
744
745impl<'a, C> ProjectMethods<'a, C> {
746    /// Create a builder to help you perform the following task:
747    ///
748    /// 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`.
749    ///
750    /// # Arguments
751    ///
752    /// * `request` - No description provided.
753    /// * `name` - The name of the operation resource to be cancelled.
754    pub fn locations_operations_cancel(
755        &self,
756        request: GoogleLongrunning_CancelOperationRequest,
757        name: &str,
758    ) -> ProjectLocationOperationCancelCall<'a, C> {
759        ProjectLocationOperationCancelCall {
760            hub: self.hub,
761            _request: request,
762            _name: name.to_string(),
763            _delegate: Default::default(),
764            _additional_params: Default::default(),
765            _scopes: Default::default(),
766        }
767    }
768
769    /// Create a builder to help you perform the following task:
770    ///
771    /// 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`.
772    ///
773    /// # Arguments
774    ///
775    /// * `name` - The name of the operation resource to be deleted.
776    pub fn locations_operations_delete(
777        &self,
778        name: &str,
779    ) -> ProjectLocationOperationDeleteCall<'a, C> {
780        ProjectLocationOperationDeleteCall {
781            hub: self.hub,
782            _name: name.to_string(),
783            _delegate: Default::default(),
784            _additional_params: Default::default(),
785            _scopes: Default::default(),
786        }
787    }
788
789    /// Create a builder to help you perform the following task:
790    ///
791    /// 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.
792    ///
793    /// # Arguments
794    ///
795    /// * `name` - The name of the operation resource.
796    pub fn locations_operations_get(&self, name: &str) -> ProjectLocationOperationGetCall<'a, C> {
797        ProjectLocationOperationGetCall {
798            hub: self.hub,
799            _name: name.to_string(),
800            _delegate: Default::default(),
801            _additional_params: Default::default(),
802            _scopes: Default::default(),
803        }
804    }
805
806    /// Create a builder to help you perform the following task:
807    ///
808    /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
809    ///
810    /// # Arguments
811    ///
812    /// * `name` - The name of the operation's parent resource.
813    pub fn locations_operations_list(&self, name: &str) -> ProjectLocationOperationListCall<'a, C> {
814        ProjectLocationOperationListCall {
815            hub: self.hub,
816            _name: name.to_string(),
817            _page_token: Default::default(),
818            _page_size: Default::default(),
819            _filter: Default::default(),
820            _delegate: Default::default(),
821            _additional_params: Default::default(),
822            _scopes: Default::default(),
823        }
824    }
825}
826
827/// A builder providing access to all methods supported on *video* resources.
828/// It is not used directly, but through the [`CloudVideoIntelligence`] hub.
829///
830/// # Example
831///
832/// Instantiate a resource builder
833///
834/// ```test_harness,no_run
835/// extern crate hyper;
836/// extern crate hyper_rustls;
837/// extern crate google_videointelligence1 as videointelligence1;
838///
839/// # async fn dox() {
840/// use videointelligence1::{CloudVideoIntelligence, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
841///
842/// let secret: yup_oauth2::ApplicationSecret = Default::default();
843/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
844///     .with_native_roots()
845///     .unwrap()
846///     .https_only()
847///     .enable_http2()
848///     .build();
849///
850/// let executor = hyper_util::rt::TokioExecutor::new();
851/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
852///     secret,
853///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
854///     yup_oauth2::client::CustomHyperClientBuilder::from(
855///         hyper_util::client::legacy::Client::builder(executor).build(connector),
856///     ),
857/// ).build().await.unwrap();
858///
859/// let client = hyper_util::client::legacy::Client::builder(
860///     hyper_util::rt::TokioExecutor::new()
861/// )
862/// .build(
863///     hyper_rustls::HttpsConnectorBuilder::new()
864///         .with_native_roots()
865///         .unwrap()
866///         .https_or_http()
867///         .enable_http2()
868///         .build()
869/// );
870/// let mut hub = CloudVideoIntelligence::new(client, auth);
871/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
872/// // like `annotate(...)`
873/// // to build up your call.
874/// let rb = hub.videos();
875/// # }
876/// ```
877pub struct VideoMethods<'a, C>
878where
879    C: 'a,
880{
881    hub: &'a CloudVideoIntelligence<C>,
882}
883
884impl<'a, C> common::MethodsBuilder for VideoMethods<'a, C> {}
885
886impl<'a, C> VideoMethods<'a, C> {
887    /// Create a builder to help you perform the following task:
888    ///
889    /// Performs asynchronous video annotation. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `AnnotateVideoProgress` (progress). `Operation.response` contains `AnnotateVideoResponse` (results).
890    ///
891    /// # Arguments
892    ///
893    /// * `request` - No description provided.
894    pub fn annotate(
895        &self,
896        request: GoogleCloudVideointelligenceV1_AnnotateVideoRequest,
897    ) -> VideoAnnotateCall<'a, C> {
898        VideoAnnotateCall {
899            hub: self.hub,
900            _request: request,
901            _delegate: Default::default(),
902            _additional_params: Default::default(),
903            _scopes: Default::default(),
904        }
905    }
906}
907
908// ###################
909// CallBuilders   ###
910// #################
911
912/// 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`.
913///
914/// A builder for the *projects.locations.operations.cancel* method supported by a *operation* resource.
915/// It is not used directly, but through a [`OperationMethods`] instance.
916///
917/// # Example
918///
919/// Instantiate a resource method builder
920///
921/// ```test_harness,no_run
922/// # extern crate hyper;
923/// # extern crate hyper_rustls;
924/// # extern crate google_videointelligence1 as videointelligence1;
925/// # async fn dox() {
926/// # use videointelligence1::{CloudVideoIntelligence, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
927///
928/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
929/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
930/// #     .with_native_roots()
931/// #     .unwrap()
932/// #     .https_only()
933/// #     .enable_http2()
934/// #     .build();
935///
936/// # let executor = hyper_util::rt::TokioExecutor::new();
937/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
938/// #     secret,
939/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
940/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
941/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
942/// #     ),
943/// # ).build().await.unwrap();
944///
945/// # let client = hyper_util::client::legacy::Client::builder(
946/// #     hyper_util::rt::TokioExecutor::new()
947/// # )
948/// # .build(
949/// #     hyper_rustls::HttpsConnectorBuilder::new()
950/// #         .with_native_roots()
951/// #         .unwrap()
952/// #         .https_or_http()
953/// #         .enable_http2()
954/// #         .build()
955/// # );
956/// # let mut hub = CloudVideoIntelligence::new(client, auth);
957/// // You can configure optional parameters by calling the respective setters at will, and
958/// // execute the final call using `doit()`.
959/// // Values shown here are possibly random and not representative !
960/// let result = hub.operations().projects_locations_operations_cancel("name")
961///              .doit().await;
962/// # }
963/// ```
964pub struct OperationProjectLocationOperationCancelCall<'a, C>
965where
966    C: 'a,
967{
968    hub: &'a CloudVideoIntelligence<C>,
969    _name: String,
970    _delegate: Option<&'a mut dyn common::Delegate>,
971    _additional_params: HashMap<String, String>,
972    _scopes: BTreeSet<String>,
973}
974
975impl<'a, C> common::CallBuilder for OperationProjectLocationOperationCancelCall<'a, C> {}
976
977impl<'a, C> OperationProjectLocationOperationCancelCall<'a, C>
978where
979    C: common::Connector,
980{
981    /// Perform the operation you have build so far.
982    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleProtobuf_Empty)> {
983        use std::borrow::Cow;
984        use std::io::{Read, Seek};
985
986        use common::{url::Params, ToParts};
987        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
988
989        let mut dd = common::DefaultDelegate;
990        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
991        dlg.begin(common::MethodInfo {
992            id: "videointelligence.operations.projects.locations.operations.cancel",
993            http_method: hyper::Method::POST,
994        });
995
996        for &field in ["alt", "name"].iter() {
997            if self._additional_params.contains_key(field) {
998                dlg.finished(false);
999                return Err(common::Error::FieldClash(field));
1000            }
1001        }
1002
1003        let mut params = Params::with_capacity(3 + self._additional_params.len());
1004        params.push("name", self._name);
1005
1006        params.extend(self._additional_params.iter());
1007
1008        params.push("alt", "json");
1009        let mut url = self.hub._base_url.clone() + "v1/operations/{+name}:cancel";
1010        if self._scopes.is_empty() {
1011            self._scopes
1012                .insert(Scope::CloudPlatform.as_ref().to_string());
1013        }
1014
1015        #[allow(clippy::single_element_loop)]
1016        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1017            url = params.uri_replacement(url, param_name, find_this, true);
1018        }
1019        {
1020            let to_remove = ["name"];
1021            params.remove_params(&to_remove);
1022        }
1023
1024        let url = params.parse_with_url(&url);
1025
1026        loop {
1027            let token = match self
1028                .hub
1029                .auth
1030                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1031                .await
1032            {
1033                Ok(token) => token,
1034                Err(e) => match dlg.token(e) {
1035                    Ok(token) => token,
1036                    Err(e) => {
1037                        dlg.finished(false);
1038                        return Err(common::Error::MissingToken(e));
1039                    }
1040                },
1041            };
1042            let mut req_result = {
1043                let client = &self.hub.client;
1044                dlg.pre_request();
1045                let mut req_builder = hyper::Request::builder()
1046                    .method(hyper::Method::POST)
1047                    .uri(url.as_str())
1048                    .header(USER_AGENT, self.hub._user_agent.clone());
1049
1050                if let Some(token) = token.as_ref() {
1051                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1052                }
1053
1054                let request = req_builder
1055                    .header(CONTENT_LENGTH, 0_u64)
1056                    .body(common::to_body::<String>(None));
1057
1058                client.request(request.unwrap()).await
1059            };
1060
1061            match req_result {
1062                Err(err) => {
1063                    if let common::Retry::After(d) = dlg.http_error(&err) {
1064                        sleep(d).await;
1065                        continue;
1066                    }
1067                    dlg.finished(false);
1068                    return Err(common::Error::HttpError(err));
1069                }
1070                Ok(res) => {
1071                    let (mut parts, body) = res.into_parts();
1072                    let mut body = common::Body::new(body);
1073                    if !parts.status.is_success() {
1074                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1075                        let error = serde_json::from_str(&common::to_string(&bytes));
1076                        let response = common::to_response(parts, bytes.into());
1077
1078                        if let common::Retry::After(d) =
1079                            dlg.http_failure(&response, error.as_ref().ok())
1080                        {
1081                            sleep(d).await;
1082                            continue;
1083                        }
1084
1085                        dlg.finished(false);
1086
1087                        return Err(match error {
1088                            Ok(value) => common::Error::BadRequest(value),
1089                            _ => common::Error::Failure(response),
1090                        });
1091                    }
1092                    let response = {
1093                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1094                        let encoded = common::to_string(&bytes);
1095                        match serde_json::from_str(&encoded) {
1096                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1097                            Err(error) => {
1098                                dlg.response_json_decode_error(&encoded, &error);
1099                                return Err(common::Error::JsonDecodeError(
1100                                    encoded.to_string(),
1101                                    error,
1102                                ));
1103                            }
1104                        }
1105                    };
1106
1107                    dlg.finished(true);
1108                    return Ok(response);
1109                }
1110            }
1111        }
1112    }
1113
1114    /// The name of the operation resource to be cancelled.
1115    ///
1116    /// Sets the *name* path property to the given value.
1117    ///
1118    /// Even though the property as already been set when instantiating this call,
1119    /// we provide this method for API completeness.
1120    pub fn name(mut self, new_value: &str) -> OperationProjectLocationOperationCancelCall<'a, C> {
1121        self._name = new_value.to_string();
1122        self
1123    }
1124    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1125    /// while executing the actual API request.
1126    ///
1127    /// ````text
1128    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1129    /// ````
1130    ///
1131    /// Sets the *delegate* property to the given value.
1132    pub fn delegate(
1133        mut self,
1134        new_value: &'a mut dyn common::Delegate,
1135    ) -> OperationProjectLocationOperationCancelCall<'a, C> {
1136        self._delegate = Some(new_value);
1137        self
1138    }
1139
1140    /// Set any additional parameter of the query string used in the request.
1141    /// It should be used to set parameters which are not yet available through their own
1142    /// setters.
1143    ///
1144    /// Please note that this method must not be used to set any of the known parameters
1145    /// which have their own setter method. If done anyway, the request will fail.
1146    ///
1147    /// # Additional Parameters
1148    ///
1149    /// * *$.xgafv* (query-string) - V1 error format.
1150    /// * *access_token* (query-string) - OAuth access token.
1151    /// * *alt* (query-string) - Data format for response.
1152    /// * *callback* (query-string) - JSONP
1153    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1154    /// * *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.
1155    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1156    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1157    /// * *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.
1158    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1159    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1160    pub fn param<T>(
1161        mut self,
1162        name: T,
1163        value: T,
1164    ) -> OperationProjectLocationOperationCancelCall<'a, C>
1165    where
1166        T: AsRef<str>,
1167    {
1168        self._additional_params
1169            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1170        self
1171    }
1172
1173    /// Identifies the authorization scope for the method you are building.
1174    ///
1175    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1176    /// [`Scope::CloudPlatform`].
1177    ///
1178    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1179    /// tokens for more than one scope.
1180    ///
1181    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1182    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1183    /// sufficient, a read-write scope will do as well.
1184    pub fn add_scope<St>(mut self, scope: St) -> OperationProjectLocationOperationCancelCall<'a, C>
1185    where
1186        St: AsRef<str>,
1187    {
1188        self._scopes.insert(String::from(scope.as_ref()));
1189        self
1190    }
1191    /// Identifies the authorization scope(s) for the method you are building.
1192    ///
1193    /// See [`Self::add_scope()`] for details.
1194    pub fn add_scopes<I, St>(
1195        mut self,
1196        scopes: I,
1197    ) -> OperationProjectLocationOperationCancelCall<'a, C>
1198    where
1199        I: IntoIterator<Item = St>,
1200        St: AsRef<str>,
1201    {
1202        self._scopes
1203            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1204        self
1205    }
1206
1207    /// Removes all scopes, and no default scope will be used either.
1208    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1209    /// for details).
1210    pub fn clear_scopes(mut self) -> OperationProjectLocationOperationCancelCall<'a, C> {
1211        self._scopes.clear();
1212        self
1213    }
1214}
1215
1216/// 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`.
1217///
1218/// A builder for the *projects.locations.operations.delete* method supported by a *operation* resource.
1219/// It is not used directly, but through a [`OperationMethods`] instance.
1220///
1221/// # Example
1222///
1223/// Instantiate a resource method builder
1224///
1225/// ```test_harness,no_run
1226/// # extern crate hyper;
1227/// # extern crate hyper_rustls;
1228/// # extern crate google_videointelligence1 as videointelligence1;
1229/// # async fn dox() {
1230/// # use videointelligence1::{CloudVideoIntelligence, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1231///
1232/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1233/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1234/// #     .with_native_roots()
1235/// #     .unwrap()
1236/// #     .https_only()
1237/// #     .enable_http2()
1238/// #     .build();
1239///
1240/// # let executor = hyper_util::rt::TokioExecutor::new();
1241/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1242/// #     secret,
1243/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1244/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1245/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1246/// #     ),
1247/// # ).build().await.unwrap();
1248///
1249/// # let client = hyper_util::client::legacy::Client::builder(
1250/// #     hyper_util::rt::TokioExecutor::new()
1251/// # )
1252/// # .build(
1253/// #     hyper_rustls::HttpsConnectorBuilder::new()
1254/// #         .with_native_roots()
1255/// #         .unwrap()
1256/// #         .https_or_http()
1257/// #         .enable_http2()
1258/// #         .build()
1259/// # );
1260/// # let mut hub = CloudVideoIntelligence::new(client, auth);
1261/// // You can configure optional parameters by calling the respective setters at will, and
1262/// // execute the final call using `doit()`.
1263/// // Values shown here are possibly random and not representative !
1264/// let result = hub.operations().projects_locations_operations_delete("name")
1265///              .doit().await;
1266/// # }
1267/// ```
1268pub struct OperationProjectLocationOperationDeleteCall<'a, C>
1269where
1270    C: 'a,
1271{
1272    hub: &'a CloudVideoIntelligence<C>,
1273    _name: String,
1274    _delegate: Option<&'a mut dyn common::Delegate>,
1275    _additional_params: HashMap<String, String>,
1276    _scopes: BTreeSet<String>,
1277}
1278
1279impl<'a, C> common::CallBuilder for OperationProjectLocationOperationDeleteCall<'a, C> {}
1280
1281impl<'a, C> OperationProjectLocationOperationDeleteCall<'a, C>
1282where
1283    C: common::Connector,
1284{
1285    /// Perform the operation you have build so far.
1286    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleProtobuf_Empty)> {
1287        use std::borrow::Cow;
1288        use std::io::{Read, Seek};
1289
1290        use common::{url::Params, ToParts};
1291        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1292
1293        let mut dd = common::DefaultDelegate;
1294        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1295        dlg.begin(common::MethodInfo {
1296            id: "videointelligence.operations.projects.locations.operations.delete",
1297            http_method: hyper::Method::DELETE,
1298        });
1299
1300        for &field in ["alt", "name"].iter() {
1301            if self._additional_params.contains_key(field) {
1302                dlg.finished(false);
1303                return Err(common::Error::FieldClash(field));
1304            }
1305        }
1306
1307        let mut params = Params::with_capacity(3 + self._additional_params.len());
1308        params.push("name", self._name);
1309
1310        params.extend(self._additional_params.iter());
1311
1312        params.push("alt", "json");
1313        let mut url = self.hub._base_url.clone() + "v1/operations/{+name}";
1314        if self._scopes.is_empty() {
1315            self._scopes
1316                .insert(Scope::CloudPlatform.as_ref().to_string());
1317        }
1318
1319        #[allow(clippy::single_element_loop)]
1320        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1321            url = params.uri_replacement(url, param_name, find_this, true);
1322        }
1323        {
1324            let to_remove = ["name"];
1325            params.remove_params(&to_remove);
1326        }
1327
1328        let url = params.parse_with_url(&url);
1329
1330        loop {
1331            let token = match self
1332                .hub
1333                .auth
1334                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1335                .await
1336            {
1337                Ok(token) => token,
1338                Err(e) => match dlg.token(e) {
1339                    Ok(token) => token,
1340                    Err(e) => {
1341                        dlg.finished(false);
1342                        return Err(common::Error::MissingToken(e));
1343                    }
1344                },
1345            };
1346            let mut req_result = {
1347                let client = &self.hub.client;
1348                dlg.pre_request();
1349                let mut req_builder = hyper::Request::builder()
1350                    .method(hyper::Method::DELETE)
1351                    .uri(url.as_str())
1352                    .header(USER_AGENT, self.hub._user_agent.clone());
1353
1354                if let Some(token) = token.as_ref() {
1355                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1356                }
1357
1358                let request = req_builder
1359                    .header(CONTENT_LENGTH, 0_u64)
1360                    .body(common::to_body::<String>(None));
1361
1362                client.request(request.unwrap()).await
1363            };
1364
1365            match req_result {
1366                Err(err) => {
1367                    if let common::Retry::After(d) = dlg.http_error(&err) {
1368                        sleep(d).await;
1369                        continue;
1370                    }
1371                    dlg.finished(false);
1372                    return Err(common::Error::HttpError(err));
1373                }
1374                Ok(res) => {
1375                    let (mut parts, body) = res.into_parts();
1376                    let mut body = common::Body::new(body);
1377                    if !parts.status.is_success() {
1378                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1379                        let error = serde_json::from_str(&common::to_string(&bytes));
1380                        let response = common::to_response(parts, bytes.into());
1381
1382                        if let common::Retry::After(d) =
1383                            dlg.http_failure(&response, error.as_ref().ok())
1384                        {
1385                            sleep(d).await;
1386                            continue;
1387                        }
1388
1389                        dlg.finished(false);
1390
1391                        return Err(match error {
1392                            Ok(value) => common::Error::BadRequest(value),
1393                            _ => common::Error::Failure(response),
1394                        });
1395                    }
1396                    let response = {
1397                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1398                        let encoded = common::to_string(&bytes);
1399                        match serde_json::from_str(&encoded) {
1400                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1401                            Err(error) => {
1402                                dlg.response_json_decode_error(&encoded, &error);
1403                                return Err(common::Error::JsonDecodeError(
1404                                    encoded.to_string(),
1405                                    error,
1406                                ));
1407                            }
1408                        }
1409                    };
1410
1411                    dlg.finished(true);
1412                    return Ok(response);
1413                }
1414            }
1415        }
1416    }
1417
1418    /// The name of the operation resource to be deleted.
1419    ///
1420    /// Sets the *name* path property to the given value.
1421    ///
1422    /// Even though the property as already been set when instantiating this call,
1423    /// we provide this method for API completeness.
1424    pub fn name(mut self, new_value: &str) -> OperationProjectLocationOperationDeleteCall<'a, C> {
1425        self._name = new_value.to_string();
1426        self
1427    }
1428    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1429    /// while executing the actual API request.
1430    ///
1431    /// ````text
1432    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1433    /// ````
1434    ///
1435    /// Sets the *delegate* property to the given value.
1436    pub fn delegate(
1437        mut self,
1438        new_value: &'a mut dyn common::Delegate,
1439    ) -> OperationProjectLocationOperationDeleteCall<'a, C> {
1440        self._delegate = Some(new_value);
1441        self
1442    }
1443
1444    /// Set any additional parameter of the query string used in the request.
1445    /// It should be used to set parameters which are not yet available through their own
1446    /// setters.
1447    ///
1448    /// Please note that this method must not be used to set any of the known parameters
1449    /// which have their own setter method. If done anyway, the request will fail.
1450    ///
1451    /// # Additional Parameters
1452    ///
1453    /// * *$.xgafv* (query-string) - V1 error format.
1454    /// * *access_token* (query-string) - OAuth access token.
1455    /// * *alt* (query-string) - Data format for response.
1456    /// * *callback* (query-string) - JSONP
1457    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1458    /// * *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.
1459    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1460    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1461    /// * *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.
1462    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1463    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1464    pub fn param<T>(
1465        mut self,
1466        name: T,
1467        value: T,
1468    ) -> OperationProjectLocationOperationDeleteCall<'a, C>
1469    where
1470        T: AsRef<str>,
1471    {
1472        self._additional_params
1473            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1474        self
1475    }
1476
1477    /// Identifies the authorization scope for the method you are building.
1478    ///
1479    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1480    /// [`Scope::CloudPlatform`].
1481    ///
1482    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1483    /// tokens for more than one scope.
1484    ///
1485    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1486    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1487    /// sufficient, a read-write scope will do as well.
1488    pub fn add_scope<St>(mut self, scope: St) -> OperationProjectLocationOperationDeleteCall<'a, C>
1489    where
1490        St: AsRef<str>,
1491    {
1492        self._scopes.insert(String::from(scope.as_ref()));
1493        self
1494    }
1495    /// Identifies the authorization scope(s) for the method you are building.
1496    ///
1497    /// See [`Self::add_scope()`] for details.
1498    pub fn add_scopes<I, St>(
1499        mut self,
1500        scopes: I,
1501    ) -> OperationProjectLocationOperationDeleteCall<'a, C>
1502    where
1503        I: IntoIterator<Item = St>,
1504        St: AsRef<str>,
1505    {
1506        self._scopes
1507            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1508        self
1509    }
1510
1511    /// Removes all scopes, and no default scope will be used either.
1512    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1513    /// for details).
1514    pub fn clear_scopes(mut self) -> OperationProjectLocationOperationDeleteCall<'a, C> {
1515        self._scopes.clear();
1516        self
1517    }
1518}
1519
1520/// 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.
1521///
1522/// A builder for the *projects.locations.operations.get* method supported by a *operation* resource.
1523/// It is not used directly, but through a [`OperationMethods`] instance.
1524///
1525/// # Example
1526///
1527/// Instantiate a resource method builder
1528///
1529/// ```test_harness,no_run
1530/// # extern crate hyper;
1531/// # extern crate hyper_rustls;
1532/// # extern crate google_videointelligence1 as videointelligence1;
1533/// # async fn dox() {
1534/// # use videointelligence1::{CloudVideoIntelligence, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1535///
1536/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1537/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1538/// #     .with_native_roots()
1539/// #     .unwrap()
1540/// #     .https_only()
1541/// #     .enable_http2()
1542/// #     .build();
1543///
1544/// # let executor = hyper_util::rt::TokioExecutor::new();
1545/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1546/// #     secret,
1547/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1548/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1549/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1550/// #     ),
1551/// # ).build().await.unwrap();
1552///
1553/// # let client = hyper_util::client::legacy::Client::builder(
1554/// #     hyper_util::rt::TokioExecutor::new()
1555/// # )
1556/// # .build(
1557/// #     hyper_rustls::HttpsConnectorBuilder::new()
1558/// #         .with_native_roots()
1559/// #         .unwrap()
1560/// #         .https_or_http()
1561/// #         .enable_http2()
1562/// #         .build()
1563/// # );
1564/// # let mut hub = CloudVideoIntelligence::new(client, auth);
1565/// // You can configure optional parameters by calling the respective setters at will, and
1566/// // execute the final call using `doit()`.
1567/// // Values shown here are possibly random and not representative !
1568/// let result = hub.operations().projects_locations_operations_get("name")
1569///              .doit().await;
1570/// # }
1571/// ```
1572pub struct OperationProjectLocationOperationGetCall<'a, C>
1573where
1574    C: 'a,
1575{
1576    hub: &'a CloudVideoIntelligence<C>,
1577    _name: String,
1578    _delegate: Option<&'a mut dyn common::Delegate>,
1579    _additional_params: HashMap<String, String>,
1580    _scopes: BTreeSet<String>,
1581}
1582
1583impl<'a, C> common::CallBuilder for OperationProjectLocationOperationGetCall<'a, C> {}
1584
1585impl<'a, C> OperationProjectLocationOperationGetCall<'a, C>
1586where
1587    C: common::Connector,
1588{
1589    /// Perform the operation you have build so far.
1590    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunning_Operation)> {
1591        use std::borrow::Cow;
1592        use std::io::{Read, Seek};
1593
1594        use common::{url::Params, ToParts};
1595        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1596
1597        let mut dd = common::DefaultDelegate;
1598        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1599        dlg.begin(common::MethodInfo {
1600            id: "videointelligence.operations.projects.locations.operations.get",
1601            http_method: hyper::Method::GET,
1602        });
1603
1604        for &field in ["alt", "name"].iter() {
1605            if self._additional_params.contains_key(field) {
1606                dlg.finished(false);
1607                return Err(common::Error::FieldClash(field));
1608            }
1609        }
1610
1611        let mut params = Params::with_capacity(3 + self._additional_params.len());
1612        params.push("name", self._name);
1613
1614        params.extend(self._additional_params.iter());
1615
1616        params.push("alt", "json");
1617        let mut url = self.hub._base_url.clone() + "v1/operations/{+name}";
1618        if self._scopes.is_empty() {
1619            self._scopes
1620                .insert(Scope::CloudPlatform.as_ref().to_string());
1621        }
1622
1623        #[allow(clippy::single_element_loop)]
1624        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1625            url = params.uri_replacement(url, param_name, find_this, true);
1626        }
1627        {
1628            let to_remove = ["name"];
1629            params.remove_params(&to_remove);
1630        }
1631
1632        let url = params.parse_with_url(&url);
1633
1634        loop {
1635            let token = match self
1636                .hub
1637                .auth
1638                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1639                .await
1640            {
1641                Ok(token) => token,
1642                Err(e) => match dlg.token(e) {
1643                    Ok(token) => token,
1644                    Err(e) => {
1645                        dlg.finished(false);
1646                        return Err(common::Error::MissingToken(e));
1647                    }
1648                },
1649            };
1650            let mut req_result = {
1651                let client = &self.hub.client;
1652                dlg.pre_request();
1653                let mut req_builder = hyper::Request::builder()
1654                    .method(hyper::Method::GET)
1655                    .uri(url.as_str())
1656                    .header(USER_AGENT, self.hub._user_agent.clone());
1657
1658                if let Some(token) = token.as_ref() {
1659                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1660                }
1661
1662                let request = req_builder
1663                    .header(CONTENT_LENGTH, 0_u64)
1664                    .body(common::to_body::<String>(None));
1665
1666                client.request(request.unwrap()).await
1667            };
1668
1669            match req_result {
1670                Err(err) => {
1671                    if let common::Retry::After(d) = dlg.http_error(&err) {
1672                        sleep(d).await;
1673                        continue;
1674                    }
1675                    dlg.finished(false);
1676                    return Err(common::Error::HttpError(err));
1677                }
1678                Ok(res) => {
1679                    let (mut parts, body) = res.into_parts();
1680                    let mut body = common::Body::new(body);
1681                    if !parts.status.is_success() {
1682                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1683                        let error = serde_json::from_str(&common::to_string(&bytes));
1684                        let response = common::to_response(parts, bytes.into());
1685
1686                        if let common::Retry::After(d) =
1687                            dlg.http_failure(&response, error.as_ref().ok())
1688                        {
1689                            sleep(d).await;
1690                            continue;
1691                        }
1692
1693                        dlg.finished(false);
1694
1695                        return Err(match error {
1696                            Ok(value) => common::Error::BadRequest(value),
1697                            _ => common::Error::Failure(response),
1698                        });
1699                    }
1700                    let response = {
1701                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1702                        let encoded = common::to_string(&bytes);
1703                        match serde_json::from_str(&encoded) {
1704                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1705                            Err(error) => {
1706                                dlg.response_json_decode_error(&encoded, &error);
1707                                return Err(common::Error::JsonDecodeError(
1708                                    encoded.to_string(),
1709                                    error,
1710                                ));
1711                            }
1712                        }
1713                    };
1714
1715                    dlg.finished(true);
1716                    return Ok(response);
1717                }
1718            }
1719        }
1720    }
1721
1722    /// The name of the operation resource.
1723    ///
1724    /// Sets the *name* path property to the given value.
1725    ///
1726    /// Even though the property as already been set when instantiating this call,
1727    /// we provide this method for API completeness.
1728    pub fn name(mut self, new_value: &str) -> OperationProjectLocationOperationGetCall<'a, C> {
1729        self._name = new_value.to_string();
1730        self
1731    }
1732    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1733    /// while executing the actual API request.
1734    ///
1735    /// ````text
1736    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1737    /// ````
1738    ///
1739    /// Sets the *delegate* property to the given value.
1740    pub fn delegate(
1741        mut self,
1742        new_value: &'a mut dyn common::Delegate,
1743    ) -> OperationProjectLocationOperationGetCall<'a, C> {
1744        self._delegate = Some(new_value);
1745        self
1746    }
1747
1748    /// Set any additional parameter of the query string used in the request.
1749    /// It should be used to set parameters which are not yet available through their own
1750    /// setters.
1751    ///
1752    /// Please note that this method must not be used to set any of the known parameters
1753    /// which have their own setter method. If done anyway, the request will fail.
1754    ///
1755    /// # Additional Parameters
1756    ///
1757    /// * *$.xgafv* (query-string) - V1 error format.
1758    /// * *access_token* (query-string) - OAuth access token.
1759    /// * *alt* (query-string) - Data format for response.
1760    /// * *callback* (query-string) - JSONP
1761    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1762    /// * *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.
1763    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1764    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1765    /// * *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.
1766    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1767    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1768    pub fn param<T>(mut self, name: T, value: T) -> OperationProjectLocationOperationGetCall<'a, C>
1769    where
1770        T: AsRef<str>,
1771    {
1772        self._additional_params
1773            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1774        self
1775    }
1776
1777    /// Identifies the authorization scope for the method you are building.
1778    ///
1779    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1780    /// [`Scope::CloudPlatform`].
1781    ///
1782    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1783    /// tokens for more than one scope.
1784    ///
1785    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1786    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1787    /// sufficient, a read-write scope will do as well.
1788    pub fn add_scope<St>(mut self, scope: St) -> OperationProjectLocationOperationGetCall<'a, C>
1789    where
1790        St: AsRef<str>,
1791    {
1792        self._scopes.insert(String::from(scope.as_ref()));
1793        self
1794    }
1795    /// Identifies the authorization scope(s) for the method you are building.
1796    ///
1797    /// See [`Self::add_scope()`] for details.
1798    pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationProjectLocationOperationGetCall<'a, C>
1799    where
1800        I: IntoIterator<Item = St>,
1801        St: AsRef<str>,
1802    {
1803        self._scopes
1804            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1805        self
1806    }
1807
1808    /// Removes all scopes, and no default scope will be used either.
1809    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1810    /// for details).
1811    pub fn clear_scopes(mut self) -> OperationProjectLocationOperationGetCall<'a, C> {
1812        self._scopes.clear();
1813        self
1814    }
1815}
1816
1817/// 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`.
1818///
1819/// A builder for the *locations.operations.cancel* method supported by a *project* resource.
1820/// It is not used directly, but through a [`ProjectMethods`] instance.
1821///
1822/// # Example
1823///
1824/// Instantiate a resource method builder
1825///
1826/// ```test_harness,no_run
1827/// # extern crate hyper;
1828/// # extern crate hyper_rustls;
1829/// # extern crate google_videointelligence1 as videointelligence1;
1830/// use videointelligence1::api::GoogleLongrunning_CancelOperationRequest;
1831/// # async fn dox() {
1832/// # use videointelligence1::{CloudVideoIntelligence, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1833///
1834/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1835/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1836/// #     .with_native_roots()
1837/// #     .unwrap()
1838/// #     .https_only()
1839/// #     .enable_http2()
1840/// #     .build();
1841///
1842/// # let executor = hyper_util::rt::TokioExecutor::new();
1843/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1844/// #     secret,
1845/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1846/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1847/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1848/// #     ),
1849/// # ).build().await.unwrap();
1850///
1851/// # let client = hyper_util::client::legacy::Client::builder(
1852/// #     hyper_util::rt::TokioExecutor::new()
1853/// # )
1854/// # .build(
1855/// #     hyper_rustls::HttpsConnectorBuilder::new()
1856/// #         .with_native_roots()
1857/// #         .unwrap()
1858/// #         .https_or_http()
1859/// #         .enable_http2()
1860/// #         .build()
1861/// # );
1862/// # let mut hub = CloudVideoIntelligence::new(client, auth);
1863/// // As the method needs a request, you would usually fill it with the desired information
1864/// // into the respective structure. Some of the parts shown here might not be applicable !
1865/// // Values shown here are possibly random and not representative !
1866/// let mut req = GoogleLongrunning_CancelOperationRequest::default();
1867///
1868/// // You can configure optional parameters by calling the respective setters at will, and
1869/// // execute the final call using `doit()`.
1870/// // Values shown here are possibly random and not representative !
1871/// let result = hub.projects().locations_operations_cancel(req, "name")
1872///              .doit().await;
1873/// # }
1874/// ```
1875pub struct ProjectLocationOperationCancelCall<'a, C>
1876where
1877    C: 'a,
1878{
1879    hub: &'a CloudVideoIntelligence<C>,
1880    _request: GoogleLongrunning_CancelOperationRequest,
1881    _name: String,
1882    _delegate: Option<&'a mut dyn common::Delegate>,
1883    _additional_params: HashMap<String, String>,
1884    _scopes: BTreeSet<String>,
1885}
1886
1887impl<'a, C> common::CallBuilder for ProjectLocationOperationCancelCall<'a, C> {}
1888
1889impl<'a, C> ProjectLocationOperationCancelCall<'a, C>
1890where
1891    C: common::Connector,
1892{
1893    /// Perform the operation you have build so far.
1894    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleProtobuf_Empty)> {
1895        use std::borrow::Cow;
1896        use std::io::{Read, Seek};
1897
1898        use common::{url::Params, ToParts};
1899        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1900
1901        let mut dd = common::DefaultDelegate;
1902        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1903        dlg.begin(common::MethodInfo {
1904            id: "videointelligence.projects.locations.operations.cancel",
1905            http_method: hyper::Method::POST,
1906        });
1907
1908        for &field in ["alt", "name"].iter() {
1909            if self._additional_params.contains_key(field) {
1910                dlg.finished(false);
1911                return Err(common::Error::FieldClash(field));
1912            }
1913        }
1914
1915        let mut params = Params::with_capacity(4 + self._additional_params.len());
1916        params.push("name", self._name);
1917
1918        params.extend(self._additional_params.iter());
1919
1920        params.push("alt", "json");
1921        let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
1922        if self._scopes.is_empty() {
1923            self._scopes
1924                .insert(Scope::CloudPlatform.as_ref().to_string());
1925        }
1926
1927        #[allow(clippy::single_element_loop)]
1928        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1929            url = params.uri_replacement(url, param_name, find_this, true);
1930        }
1931        {
1932            let to_remove = ["name"];
1933            params.remove_params(&to_remove);
1934        }
1935
1936        let url = params.parse_with_url(&url);
1937
1938        let mut json_mime_type = mime::APPLICATION_JSON;
1939        let mut request_value_reader = {
1940            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1941            common::remove_json_null_values(&mut value);
1942            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1943            serde_json::to_writer(&mut dst, &value).unwrap();
1944            dst
1945        };
1946        let request_size = request_value_reader
1947            .seek(std::io::SeekFrom::End(0))
1948            .unwrap();
1949        request_value_reader
1950            .seek(std::io::SeekFrom::Start(0))
1951            .unwrap();
1952
1953        loop {
1954            let token = match self
1955                .hub
1956                .auth
1957                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1958                .await
1959            {
1960                Ok(token) => token,
1961                Err(e) => match dlg.token(e) {
1962                    Ok(token) => token,
1963                    Err(e) => {
1964                        dlg.finished(false);
1965                        return Err(common::Error::MissingToken(e));
1966                    }
1967                },
1968            };
1969            request_value_reader
1970                .seek(std::io::SeekFrom::Start(0))
1971                .unwrap();
1972            let mut req_result = {
1973                let client = &self.hub.client;
1974                dlg.pre_request();
1975                let mut req_builder = hyper::Request::builder()
1976                    .method(hyper::Method::POST)
1977                    .uri(url.as_str())
1978                    .header(USER_AGENT, self.hub._user_agent.clone());
1979
1980                if let Some(token) = token.as_ref() {
1981                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1982                }
1983
1984                let request = req_builder
1985                    .header(CONTENT_TYPE, json_mime_type.to_string())
1986                    .header(CONTENT_LENGTH, request_size as u64)
1987                    .body(common::to_body(
1988                        request_value_reader.get_ref().clone().into(),
1989                    ));
1990
1991                client.request(request.unwrap()).await
1992            };
1993
1994            match req_result {
1995                Err(err) => {
1996                    if let common::Retry::After(d) = dlg.http_error(&err) {
1997                        sleep(d).await;
1998                        continue;
1999                    }
2000                    dlg.finished(false);
2001                    return Err(common::Error::HttpError(err));
2002                }
2003                Ok(res) => {
2004                    let (mut parts, body) = res.into_parts();
2005                    let mut body = common::Body::new(body);
2006                    if !parts.status.is_success() {
2007                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2008                        let error = serde_json::from_str(&common::to_string(&bytes));
2009                        let response = common::to_response(parts, bytes.into());
2010
2011                        if let common::Retry::After(d) =
2012                            dlg.http_failure(&response, error.as_ref().ok())
2013                        {
2014                            sleep(d).await;
2015                            continue;
2016                        }
2017
2018                        dlg.finished(false);
2019
2020                        return Err(match error {
2021                            Ok(value) => common::Error::BadRequest(value),
2022                            _ => common::Error::Failure(response),
2023                        });
2024                    }
2025                    let response = {
2026                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2027                        let encoded = common::to_string(&bytes);
2028                        match serde_json::from_str(&encoded) {
2029                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2030                            Err(error) => {
2031                                dlg.response_json_decode_error(&encoded, &error);
2032                                return Err(common::Error::JsonDecodeError(
2033                                    encoded.to_string(),
2034                                    error,
2035                                ));
2036                            }
2037                        }
2038                    };
2039
2040                    dlg.finished(true);
2041                    return Ok(response);
2042                }
2043            }
2044        }
2045    }
2046
2047    ///
2048    /// Sets the *request* property to the given value.
2049    ///
2050    /// Even though the property as already been set when instantiating this call,
2051    /// we provide this method for API completeness.
2052    pub fn request(
2053        mut self,
2054        new_value: GoogleLongrunning_CancelOperationRequest,
2055    ) -> ProjectLocationOperationCancelCall<'a, C> {
2056        self._request = new_value;
2057        self
2058    }
2059    /// The name of the operation resource to be cancelled.
2060    ///
2061    /// Sets the *name* path property to the given value.
2062    ///
2063    /// Even though the property as already been set when instantiating this call,
2064    /// we provide this method for API completeness.
2065    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationCancelCall<'a, C> {
2066        self._name = new_value.to_string();
2067        self
2068    }
2069    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2070    /// while executing the actual API request.
2071    ///
2072    /// ````text
2073    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2074    /// ````
2075    ///
2076    /// Sets the *delegate* property to the given value.
2077    pub fn delegate(
2078        mut self,
2079        new_value: &'a mut dyn common::Delegate,
2080    ) -> ProjectLocationOperationCancelCall<'a, C> {
2081        self._delegate = Some(new_value);
2082        self
2083    }
2084
2085    /// Set any additional parameter of the query string used in the request.
2086    /// It should be used to set parameters which are not yet available through their own
2087    /// setters.
2088    ///
2089    /// Please note that this method must not be used to set any of the known parameters
2090    /// which have their own setter method. If done anyway, the request will fail.
2091    ///
2092    /// # Additional Parameters
2093    ///
2094    /// * *$.xgafv* (query-string) - V1 error format.
2095    /// * *access_token* (query-string) - OAuth access token.
2096    /// * *alt* (query-string) - Data format for response.
2097    /// * *callback* (query-string) - JSONP
2098    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2099    /// * *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.
2100    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2101    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2102    /// * *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.
2103    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2104    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2105    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationCancelCall<'a, C>
2106    where
2107        T: AsRef<str>,
2108    {
2109        self._additional_params
2110            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2111        self
2112    }
2113
2114    /// Identifies the authorization scope for the method you are building.
2115    ///
2116    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2117    /// [`Scope::CloudPlatform`].
2118    ///
2119    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2120    /// tokens for more than one scope.
2121    ///
2122    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2123    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2124    /// sufficient, a read-write scope will do as well.
2125    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationCancelCall<'a, C>
2126    where
2127        St: AsRef<str>,
2128    {
2129        self._scopes.insert(String::from(scope.as_ref()));
2130        self
2131    }
2132    /// Identifies the authorization scope(s) for the method you are building.
2133    ///
2134    /// See [`Self::add_scope()`] for details.
2135    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationCancelCall<'a, C>
2136    where
2137        I: IntoIterator<Item = St>,
2138        St: AsRef<str>,
2139    {
2140        self._scopes
2141            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2142        self
2143    }
2144
2145    /// Removes all scopes, and no default scope will be used either.
2146    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2147    /// for details).
2148    pub fn clear_scopes(mut self) -> ProjectLocationOperationCancelCall<'a, C> {
2149        self._scopes.clear();
2150        self
2151    }
2152}
2153
2154/// 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`.
2155///
2156/// A builder for the *locations.operations.delete* method supported by a *project* resource.
2157/// It is not used directly, but through a [`ProjectMethods`] instance.
2158///
2159/// # Example
2160///
2161/// Instantiate a resource method builder
2162///
2163/// ```test_harness,no_run
2164/// # extern crate hyper;
2165/// # extern crate hyper_rustls;
2166/// # extern crate google_videointelligence1 as videointelligence1;
2167/// # async fn dox() {
2168/// # use videointelligence1::{CloudVideoIntelligence, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2169///
2170/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2171/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2172/// #     .with_native_roots()
2173/// #     .unwrap()
2174/// #     .https_only()
2175/// #     .enable_http2()
2176/// #     .build();
2177///
2178/// # let executor = hyper_util::rt::TokioExecutor::new();
2179/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2180/// #     secret,
2181/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2182/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2183/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2184/// #     ),
2185/// # ).build().await.unwrap();
2186///
2187/// # let client = hyper_util::client::legacy::Client::builder(
2188/// #     hyper_util::rt::TokioExecutor::new()
2189/// # )
2190/// # .build(
2191/// #     hyper_rustls::HttpsConnectorBuilder::new()
2192/// #         .with_native_roots()
2193/// #         .unwrap()
2194/// #         .https_or_http()
2195/// #         .enable_http2()
2196/// #         .build()
2197/// # );
2198/// # let mut hub = CloudVideoIntelligence::new(client, auth);
2199/// // You can configure optional parameters by calling the respective setters at will, and
2200/// // execute the final call using `doit()`.
2201/// // Values shown here are possibly random and not representative !
2202/// let result = hub.projects().locations_operations_delete("name")
2203///              .doit().await;
2204/// # }
2205/// ```
2206pub struct ProjectLocationOperationDeleteCall<'a, C>
2207where
2208    C: 'a,
2209{
2210    hub: &'a CloudVideoIntelligence<C>,
2211    _name: String,
2212    _delegate: Option<&'a mut dyn common::Delegate>,
2213    _additional_params: HashMap<String, String>,
2214    _scopes: BTreeSet<String>,
2215}
2216
2217impl<'a, C> common::CallBuilder for ProjectLocationOperationDeleteCall<'a, C> {}
2218
2219impl<'a, C> ProjectLocationOperationDeleteCall<'a, C>
2220where
2221    C: common::Connector,
2222{
2223    /// Perform the operation you have build so far.
2224    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleProtobuf_Empty)> {
2225        use std::borrow::Cow;
2226        use std::io::{Read, Seek};
2227
2228        use common::{url::Params, ToParts};
2229        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2230
2231        let mut dd = common::DefaultDelegate;
2232        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2233        dlg.begin(common::MethodInfo {
2234            id: "videointelligence.projects.locations.operations.delete",
2235            http_method: hyper::Method::DELETE,
2236        });
2237
2238        for &field in ["alt", "name"].iter() {
2239            if self._additional_params.contains_key(field) {
2240                dlg.finished(false);
2241                return Err(common::Error::FieldClash(field));
2242            }
2243        }
2244
2245        let mut params = Params::with_capacity(3 + self._additional_params.len());
2246        params.push("name", self._name);
2247
2248        params.extend(self._additional_params.iter());
2249
2250        params.push("alt", "json");
2251        let mut url = self.hub._base_url.clone() + "v1/{+name}";
2252        if self._scopes.is_empty() {
2253            self._scopes
2254                .insert(Scope::CloudPlatform.as_ref().to_string());
2255        }
2256
2257        #[allow(clippy::single_element_loop)]
2258        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2259            url = params.uri_replacement(url, param_name, find_this, true);
2260        }
2261        {
2262            let to_remove = ["name"];
2263            params.remove_params(&to_remove);
2264        }
2265
2266        let url = params.parse_with_url(&url);
2267
2268        loop {
2269            let token = match self
2270                .hub
2271                .auth
2272                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2273                .await
2274            {
2275                Ok(token) => token,
2276                Err(e) => match dlg.token(e) {
2277                    Ok(token) => token,
2278                    Err(e) => {
2279                        dlg.finished(false);
2280                        return Err(common::Error::MissingToken(e));
2281                    }
2282                },
2283            };
2284            let mut req_result = {
2285                let client = &self.hub.client;
2286                dlg.pre_request();
2287                let mut req_builder = hyper::Request::builder()
2288                    .method(hyper::Method::DELETE)
2289                    .uri(url.as_str())
2290                    .header(USER_AGENT, self.hub._user_agent.clone());
2291
2292                if let Some(token) = token.as_ref() {
2293                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2294                }
2295
2296                let request = req_builder
2297                    .header(CONTENT_LENGTH, 0_u64)
2298                    .body(common::to_body::<String>(None));
2299
2300                client.request(request.unwrap()).await
2301            };
2302
2303            match req_result {
2304                Err(err) => {
2305                    if let common::Retry::After(d) = dlg.http_error(&err) {
2306                        sleep(d).await;
2307                        continue;
2308                    }
2309                    dlg.finished(false);
2310                    return Err(common::Error::HttpError(err));
2311                }
2312                Ok(res) => {
2313                    let (mut parts, body) = res.into_parts();
2314                    let mut body = common::Body::new(body);
2315                    if !parts.status.is_success() {
2316                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2317                        let error = serde_json::from_str(&common::to_string(&bytes));
2318                        let response = common::to_response(parts, bytes.into());
2319
2320                        if let common::Retry::After(d) =
2321                            dlg.http_failure(&response, error.as_ref().ok())
2322                        {
2323                            sleep(d).await;
2324                            continue;
2325                        }
2326
2327                        dlg.finished(false);
2328
2329                        return Err(match error {
2330                            Ok(value) => common::Error::BadRequest(value),
2331                            _ => common::Error::Failure(response),
2332                        });
2333                    }
2334                    let response = {
2335                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2336                        let encoded = common::to_string(&bytes);
2337                        match serde_json::from_str(&encoded) {
2338                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2339                            Err(error) => {
2340                                dlg.response_json_decode_error(&encoded, &error);
2341                                return Err(common::Error::JsonDecodeError(
2342                                    encoded.to_string(),
2343                                    error,
2344                                ));
2345                            }
2346                        }
2347                    };
2348
2349                    dlg.finished(true);
2350                    return Ok(response);
2351                }
2352            }
2353        }
2354    }
2355
2356    /// The name of the operation resource to be deleted.
2357    ///
2358    /// Sets the *name* path property to the given value.
2359    ///
2360    /// Even though the property as already been set when instantiating this call,
2361    /// we provide this method for API completeness.
2362    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationDeleteCall<'a, C> {
2363        self._name = new_value.to_string();
2364        self
2365    }
2366    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2367    /// while executing the actual API request.
2368    ///
2369    /// ````text
2370    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2371    /// ````
2372    ///
2373    /// Sets the *delegate* property to the given value.
2374    pub fn delegate(
2375        mut self,
2376        new_value: &'a mut dyn common::Delegate,
2377    ) -> ProjectLocationOperationDeleteCall<'a, C> {
2378        self._delegate = Some(new_value);
2379        self
2380    }
2381
2382    /// Set any additional parameter of the query string used in the request.
2383    /// It should be used to set parameters which are not yet available through their own
2384    /// setters.
2385    ///
2386    /// Please note that this method must not be used to set any of the known parameters
2387    /// which have their own setter method. If done anyway, the request will fail.
2388    ///
2389    /// # Additional Parameters
2390    ///
2391    /// * *$.xgafv* (query-string) - V1 error format.
2392    /// * *access_token* (query-string) - OAuth access token.
2393    /// * *alt* (query-string) - Data format for response.
2394    /// * *callback* (query-string) - JSONP
2395    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2396    /// * *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.
2397    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2398    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2399    /// * *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.
2400    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2401    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2402    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationDeleteCall<'a, C>
2403    where
2404        T: AsRef<str>,
2405    {
2406        self._additional_params
2407            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2408        self
2409    }
2410
2411    /// Identifies the authorization scope for the method you are building.
2412    ///
2413    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2414    /// [`Scope::CloudPlatform`].
2415    ///
2416    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2417    /// tokens for more than one scope.
2418    ///
2419    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2420    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2421    /// sufficient, a read-write scope will do as well.
2422    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationDeleteCall<'a, C>
2423    where
2424        St: AsRef<str>,
2425    {
2426        self._scopes.insert(String::from(scope.as_ref()));
2427        self
2428    }
2429    /// Identifies the authorization scope(s) for the method you are building.
2430    ///
2431    /// See [`Self::add_scope()`] for details.
2432    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationDeleteCall<'a, C>
2433    where
2434        I: IntoIterator<Item = St>,
2435        St: AsRef<str>,
2436    {
2437        self._scopes
2438            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2439        self
2440    }
2441
2442    /// Removes all scopes, and no default scope will be used either.
2443    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2444    /// for details).
2445    pub fn clear_scopes(mut self) -> ProjectLocationOperationDeleteCall<'a, C> {
2446        self._scopes.clear();
2447        self
2448    }
2449}
2450
2451/// 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.
2452///
2453/// A builder for the *locations.operations.get* method supported by a *project* resource.
2454/// It is not used directly, but through a [`ProjectMethods`] instance.
2455///
2456/// # Example
2457///
2458/// Instantiate a resource method builder
2459///
2460/// ```test_harness,no_run
2461/// # extern crate hyper;
2462/// # extern crate hyper_rustls;
2463/// # extern crate google_videointelligence1 as videointelligence1;
2464/// # async fn dox() {
2465/// # use videointelligence1::{CloudVideoIntelligence, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2466///
2467/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2468/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2469/// #     .with_native_roots()
2470/// #     .unwrap()
2471/// #     .https_only()
2472/// #     .enable_http2()
2473/// #     .build();
2474///
2475/// # let executor = hyper_util::rt::TokioExecutor::new();
2476/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2477/// #     secret,
2478/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2479/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2480/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2481/// #     ),
2482/// # ).build().await.unwrap();
2483///
2484/// # let client = hyper_util::client::legacy::Client::builder(
2485/// #     hyper_util::rt::TokioExecutor::new()
2486/// # )
2487/// # .build(
2488/// #     hyper_rustls::HttpsConnectorBuilder::new()
2489/// #         .with_native_roots()
2490/// #         .unwrap()
2491/// #         .https_or_http()
2492/// #         .enable_http2()
2493/// #         .build()
2494/// # );
2495/// # let mut hub = CloudVideoIntelligence::new(client, auth);
2496/// // You can configure optional parameters by calling the respective setters at will, and
2497/// // execute the final call using `doit()`.
2498/// // Values shown here are possibly random and not representative !
2499/// let result = hub.projects().locations_operations_get("name")
2500///              .doit().await;
2501/// # }
2502/// ```
2503pub struct ProjectLocationOperationGetCall<'a, C>
2504where
2505    C: 'a,
2506{
2507    hub: &'a CloudVideoIntelligence<C>,
2508    _name: String,
2509    _delegate: Option<&'a mut dyn common::Delegate>,
2510    _additional_params: HashMap<String, String>,
2511    _scopes: BTreeSet<String>,
2512}
2513
2514impl<'a, C> common::CallBuilder for ProjectLocationOperationGetCall<'a, C> {}
2515
2516impl<'a, C> ProjectLocationOperationGetCall<'a, C>
2517where
2518    C: common::Connector,
2519{
2520    /// Perform the operation you have build so far.
2521    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunning_Operation)> {
2522        use std::borrow::Cow;
2523        use std::io::{Read, Seek};
2524
2525        use common::{url::Params, ToParts};
2526        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2527
2528        let mut dd = common::DefaultDelegate;
2529        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2530        dlg.begin(common::MethodInfo {
2531            id: "videointelligence.projects.locations.operations.get",
2532            http_method: hyper::Method::GET,
2533        });
2534
2535        for &field in ["alt", "name"].iter() {
2536            if self._additional_params.contains_key(field) {
2537                dlg.finished(false);
2538                return Err(common::Error::FieldClash(field));
2539            }
2540        }
2541
2542        let mut params = Params::with_capacity(3 + self._additional_params.len());
2543        params.push("name", self._name);
2544
2545        params.extend(self._additional_params.iter());
2546
2547        params.push("alt", "json");
2548        let mut url = self.hub._base_url.clone() + "v1/{+name}";
2549        if self._scopes.is_empty() {
2550            self._scopes
2551                .insert(Scope::CloudPlatform.as_ref().to_string());
2552        }
2553
2554        #[allow(clippy::single_element_loop)]
2555        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2556            url = params.uri_replacement(url, param_name, find_this, true);
2557        }
2558        {
2559            let to_remove = ["name"];
2560            params.remove_params(&to_remove);
2561        }
2562
2563        let url = params.parse_with_url(&url);
2564
2565        loop {
2566            let token = match self
2567                .hub
2568                .auth
2569                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2570                .await
2571            {
2572                Ok(token) => token,
2573                Err(e) => match dlg.token(e) {
2574                    Ok(token) => token,
2575                    Err(e) => {
2576                        dlg.finished(false);
2577                        return Err(common::Error::MissingToken(e));
2578                    }
2579                },
2580            };
2581            let mut req_result = {
2582                let client = &self.hub.client;
2583                dlg.pre_request();
2584                let mut req_builder = hyper::Request::builder()
2585                    .method(hyper::Method::GET)
2586                    .uri(url.as_str())
2587                    .header(USER_AGENT, self.hub._user_agent.clone());
2588
2589                if let Some(token) = token.as_ref() {
2590                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2591                }
2592
2593                let request = req_builder
2594                    .header(CONTENT_LENGTH, 0_u64)
2595                    .body(common::to_body::<String>(None));
2596
2597                client.request(request.unwrap()).await
2598            };
2599
2600            match req_result {
2601                Err(err) => {
2602                    if let common::Retry::After(d) = dlg.http_error(&err) {
2603                        sleep(d).await;
2604                        continue;
2605                    }
2606                    dlg.finished(false);
2607                    return Err(common::Error::HttpError(err));
2608                }
2609                Ok(res) => {
2610                    let (mut parts, body) = res.into_parts();
2611                    let mut body = common::Body::new(body);
2612                    if !parts.status.is_success() {
2613                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2614                        let error = serde_json::from_str(&common::to_string(&bytes));
2615                        let response = common::to_response(parts, bytes.into());
2616
2617                        if let common::Retry::After(d) =
2618                            dlg.http_failure(&response, error.as_ref().ok())
2619                        {
2620                            sleep(d).await;
2621                            continue;
2622                        }
2623
2624                        dlg.finished(false);
2625
2626                        return Err(match error {
2627                            Ok(value) => common::Error::BadRequest(value),
2628                            _ => common::Error::Failure(response),
2629                        });
2630                    }
2631                    let response = {
2632                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2633                        let encoded = common::to_string(&bytes);
2634                        match serde_json::from_str(&encoded) {
2635                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2636                            Err(error) => {
2637                                dlg.response_json_decode_error(&encoded, &error);
2638                                return Err(common::Error::JsonDecodeError(
2639                                    encoded.to_string(),
2640                                    error,
2641                                ));
2642                            }
2643                        }
2644                    };
2645
2646                    dlg.finished(true);
2647                    return Ok(response);
2648                }
2649            }
2650        }
2651    }
2652
2653    /// The name of the operation resource.
2654    ///
2655    /// Sets the *name* path property to the given value.
2656    ///
2657    /// Even though the property as already been set when instantiating this call,
2658    /// we provide this method for API completeness.
2659    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationGetCall<'a, C> {
2660        self._name = new_value.to_string();
2661        self
2662    }
2663    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2664    /// while executing the actual API request.
2665    ///
2666    /// ````text
2667    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2668    /// ````
2669    ///
2670    /// Sets the *delegate* property to the given value.
2671    pub fn delegate(
2672        mut self,
2673        new_value: &'a mut dyn common::Delegate,
2674    ) -> ProjectLocationOperationGetCall<'a, C> {
2675        self._delegate = Some(new_value);
2676        self
2677    }
2678
2679    /// Set any additional parameter of the query string used in the request.
2680    /// It should be used to set parameters which are not yet available through their own
2681    /// setters.
2682    ///
2683    /// Please note that this method must not be used to set any of the known parameters
2684    /// which have their own setter method. If done anyway, the request will fail.
2685    ///
2686    /// # Additional Parameters
2687    ///
2688    /// * *$.xgafv* (query-string) - V1 error format.
2689    /// * *access_token* (query-string) - OAuth access token.
2690    /// * *alt* (query-string) - Data format for response.
2691    /// * *callback* (query-string) - JSONP
2692    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2693    /// * *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.
2694    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2695    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2696    /// * *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.
2697    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2698    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2699    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationGetCall<'a, C>
2700    where
2701        T: AsRef<str>,
2702    {
2703        self._additional_params
2704            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2705        self
2706    }
2707
2708    /// Identifies the authorization scope for the method you are building.
2709    ///
2710    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2711    /// [`Scope::CloudPlatform`].
2712    ///
2713    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2714    /// tokens for more than one scope.
2715    ///
2716    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2717    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2718    /// sufficient, a read-write scope will do as well.
2719    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationGetCall<'a, C>
2720    where
2721        St: AsRef<str>,
2722    {
2723        self._scopes.insert(String::from(scope.as_ref()));
2724        self
2725    }
2726    /// Identifies the authorization scope(s) for the method you are building.
2727    ///
2728    /// See [`Self::add_scope()`] for details.
2729    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationGetCall<'a, C>
2730    where
2731        I: IntoIterator<Item = St>,
2732        St: AsRef<str>,
2733    {
2734        self._scopes
2735            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2736        self
2737    }
2738
2739    /// Removes all scopes, and no default scope will be used either.
2740    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2741    /// for details).
2742    pub fn clear_scopes(mut self) -> ProjectLocationOperationGetCall<'a, C> {
2743        self._scopes.clear();
2744        self
2745    }
2746}
2747
2748/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
2749///
2750/// A builder for the *locations.operations.list* method supported by a *project* resource.
2751/// It is not used directly, but through a [`ProjectMethods`] instance.
2752///
2753/// # Example
2754///
2755/// Instantiate a resource method builder
2756///
2757/// ```test_harness,no_run
2758/// # extern crate hyper;
2759/// # extern crate hyper_rustls;
2760/// # extern crate google_videointelligence1 as videointelligence1;
2761/// # async fn dox() {
2762/// # use videointelligence1::{CloudVideoIntelligence, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2763///
2764/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2765/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2766/// #     .with_native_roots()
2767/// #     .unwrap()
2768/// #     .https_only()
2769/// #     .enable_http2()
2770/// #     .build();
2771///
2772/// # let executor = hyper_util::rt::TokioExecutor::new();
2773/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2774/// #     secret,
2775/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2776/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2777/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2778/// #     ),
2779/// # ).build().await.unwrap();
2780///
2781/// # let client = hyper_util::client::legacy::Client::builder(
2782/// #     hyper_util::rt::TokioExecutor::new()
2783/// # )
2784/// # .build(
2785/// #     hyper_rustls::HttpsConnectorBuilder::new()
2786/// #         .with_native_roots()
2787/// #         .unwrap()
2788/// #         .https_or_http()
2789/// #         .enable_http2()
2790/// #         .build()
2791/// # );
2792/// # let mut hub = CloudVideoIntelligence::new(client, auth);
2793/// // You can configure optional parameters by calling the respective setters at will, and
2794/// // execute the final call using `doit()`.
2795/// // Values shown here are possibly random and not representative !
2796/// let result = hub.projects().locations_operations_list("name")
2797///              .page_token("amet.")
2798///              .page_size(-20)
2799///              .filter("ipsum")
2800///              .doit().await;
2801/// # }
2802/// ```
2803pub struct ProjectLocationOperationListCall<'a, C>
2804where
2805    C: 'a,
2806{
2807    hub: &'a CloudVideoIntelligence<C>,
2808    _name: String,
2809    _page_token: Option<String>,
2810    _page_size: Option<i32>,
2811    _filter: Option<String>,
2812    _delegate: Option<&'a mut dyn common::Delegate>,
2813    _additional_params: HashMap<String, String>,
2814    _scopes: BTreeSet<String>,
2815}
2816
2817impl<'a, C> common::CallBuilder for ProjectLocationOperationListCall<'a, C> {}
2818
2819impl<'a, C> ProjectLocationOperationListCall<'a, C>
2820where
2821    C: common::Connector,
2822{
2823    /// Perform the operation you have build so far.
2824    pub async fn doit(
2825        mut self,
2826    ) -> common::Result<(common::Response, GoogleLongrunning_ListOperationsResponse)> {
2827        use std::borrow::Cow;
2828        use std::io::{Read, Seek};
2829
2830        use common::{url::Params, ToParts};
2831        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2832
2833        let mut dd = common::DefaultDelegate;
2834        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2835        dlg.begin(common::MethodInfo {
2836            id: "videointelligence.projects.locations.operations.list",
2837            http_method: hyper::Method::GET,
2838        });
2839
2840        for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
2841            if self._additional_params.contains_key(field) {
2842                dlg.finished(false);
2843                return Err(common::Error::FieldClash(field));
2844            }
2845        }
2846
2847        let mut params = Params::with_capacity(6 + self._additional_params.len());
2848        params.push("name", self._name);
2849        if let Some(value) = self._page_token.as_ref() {
2850            params.push("pageToken", value);
2851        }
2852        if let Some(value) = self._page_size.as_ref() {
2853            params.push("pageSize", value.to_string());
2854        }
2855        if let Some(value) = self._filter.as_ref() {
2856            params.push("filter", value);
2857        }
2858
2859        params.extend(self._additional_params.iter());
2860
2861        params.push("alt", "json");
2862        let mut url = self.hub._base_url.clone() + "v1/{+name}/operations";
2863        if self._scopes.is_empty() {
2864            self._scopes
2865                .insert(Scope::CloudPlatform.as_ref().to_string());
2866        }
2867
2868        #[allow(clippy::single_element_loop)]
2869        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2870            url = params.uri_replacement(url, param_name, find_this, true);
2871        }
2872        {
2873            let to_remove = ["name"];
2874            params.remove_params(&to_remove);
2875        }
2876
2877        let url = params.parse_with_url(&url);
2878
2879        loop {
2880            let token = match self
2881                .hub
2882                .auth
2883                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2884                .await
2885            {
2886                Ok(token) => token,
2887                Err(e) => match dlg.token(e) {
2888                    Ok(token) => token,
2889                    Err(e) => {
2890                        dlg.finished(false);
2891                        return Err(common::Error::MissingToken(e));
2892                    }
2893                },
2894            };
2895            let mut req_result = {
2896                let client = &self.hub.client;
2897                dlg.pre_request();
2898                let mut req_builder = hyper::Request::builder()
2899                    .method(hyper::Method::GET)
2900                    .uri(url.as_str())
2901                    .header(USER_AGENT, self.hub._user_agent.clone());
2902
2903                if let Some(token) = token.as_ref() {
2904                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2905                }
2906
2907                let request = req_builder
2908                    .header(CONTENT_LENGTH, 0_u64)
2909                    .body(common::to_body::<String>(None));
2910
2911                client.request(request.unwrap()).await
2912            };
2913
2914            match req_result {
2915                Err(err) => {
2916                    if let common::Retry::After(d) = dlg.http_error(&err) {
2917                        sleep(d).await;
2918                        continue;
2919                    }
2920                    dlg.finished(false);
2921                    return Err(common::Error::HttpError(err));
2922                }
2923                Ok(res) => {
2924                    let (mut parts, body) = res.into_parts();
2925                    let mut body = common::Body::new(body);
2926                    if !parts.status.is_success() {
2927                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2928                        let error = serde_json::from_str(&common::to_string(&bytes));
2929                        let response = common::to_response(parts, bytes.into());
2930
2931                        if let common::Retry::After(d) =
2932                            dlg.http_failure(&response, error.as_ref().ok())
2933                        {
2934                            sleep(d).await;
2935                            continue;
2936                        }
2937
2938                        dlg.finished(false);
2939
2940                        return Err(match error {
2941                            Ok(value) => common::Error::BadRequest(value),
2942                            _ => common::Error::Failure(response),
2943                        });
2944                    }
2945                    let response = {
2946                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2947                        let encoded = common::to_string(&bytes);
2948                        match serde_json::from_str(&encoded) {
2949                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2950                            Err(error) => {
2951                                dlg.response_json_decode_error(&encoded, &error);
2952                                return Err(common::Error::JsonDecodeError(
2953                                    encoded.to_string(),
2954                                    error,
2955                                ));
2956                            }
2957                        }
2958                    };
2959
2960                    dlg.finished(true);
2961                    return Ok(response);
2962                }
2963            }
2964        }
2965    }
2966
2967    /// The name of the operation's parent resource.
2968    ///
2969    /// Sets the *name* path property to the given value.
2970    ///
2971    /// Even though the property as already been set when instantiating this call,
2972    /// we provide this method for API completeness.
2973    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
2974        self._name = new_value.to_string();
2975        self
2976    }
2977    /// The standard list page token.
2978    ///
2979    /// Sets the *page token* query property to the given value.
2980    pub fn page_token(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
2981        self._page_token = Some(new_value.to_string());
2982        self
2983    }
2984    /// The standard list page size.
2985    ///
2986    /// Sets the *page size* query property to the given value.
2987    pub fn page_size(mut self, new_value: i32) -> ProjectLocationOperationListCall<'a, C> {
2988        self._page_size = Some(new_value);
2989        self
2990    }
2991    /// The standard list filter.
2992    ///
2993    /// Sets the *filter* query property to the given value.
2994    pub fn filter(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
2995        self._filter = Some(new_value.to_string());
2996        self
2997    }
2998    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2999    /// while executing the actual API request.
3000    ///
3001    /// ````text
3002    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3003    /// ````
3004    ///
3005    /// Sets the *delegate* property to the given value.
3006    pub fn delegate(
3007        mut self,
3008        new_value: &'a mut dyn common::Delegate,
3009    ) -> ProjectLocationOperationListCall<'a, C> {
3010        self._delegate = Some(new_value);
3011        self
3012    }
3013
3014    /// Set any additional parameter of the query string used in the request.
3015    /// It should be used to set parameters which are not yet available through their own
3016    /// setters.
3017    ///
3018    /// Please note that this method must not be used to set any of the known parameters
3019    /// which have their own setter method. If done anyway, the request will fail.
3020    ///
3021    /// # Additional Parameters
3022    ///
3023    /// * *$.xgafv* (query-string) - V1 error format.
3024    /// * *access_token* (query-string) - OAuth access token.
3025    /// * *alt* (query-string) - Data format for response.
3026    /// * *callback* (query-string) - JSONP
3027    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3028    /// * *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.
3029    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3030    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3031    /// * *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.
3032    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3033    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3034    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationListCall<'a, C>
3035    where
3036        T: AsRef<str>,
3037    {
3038        self._additional_params
3039            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3040        self
3041    }
3042
3043    /// Identifies the authorization scope for the method you are building.
3044    ///
3045    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3046    /// [`Scope::CloudPlatform`].
3047    ///
3048    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3049    /// tokens for more than one scope.
3050    ///
3051    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3052    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3053    /// sufficient, a read-write scope will do as well.
3054    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationListCall<'a, C>
3055    where
3056        St: AsRef<str>,
3057    {
3058        self._scopes.insert(String::from(scope.as_ref()));
3059        self
3060    }
3061    /// Identifies the authorization scope(s) for the method you are building.
3062    ///
3063    /// See [`Self::add_scope()`] for details.
3064    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationListCall<'a, C>
3065    where
3066        I: IntoIterator<Item = St>,
3067        St: AsRef<str>,
3068    {
3069        self._scopes
3070            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3071        self
3072    }
3073
3074    /// Removes all scopes, and no default scope will be used either.
3075    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3076    /// for details).
3077    pub fn clear_scopes(mut self) -> ProjectLocationOperationListCall<'a, C> {
3078        self._scopes.clear();
3079        self
3080    }
3081}
3082
3083/// Performs asynchronous video annotation. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `AnnotateVideoProgress` (progress). `Operation.response` contains `AnnotateVideoResponse` (results).
3084///
3085/// A builder for the *annotate* method supported by a *video* resource.
3086/// It is not used directly, but through a [`VideoMethods`] instance.
3087///
3088/// # Example
3089///
3090/// Instantiate a resource method builder
3091///
3092/// ```test_harness,no_run
3093/// # extern crate hyper;
3094/// # extern crate hyper_rustls;
3095/// # extern crate google_videointelligence1 as videointelligence1;
3096/// use videointelligence1::api::GoogleCloudVideointelligenceV1_AnnotateVideoRequest;
3097/// # async fn dox() {
3098/// # use videointelligence1::{CloudVideoIntelligence, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3099///
3100/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3101/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3102/// #     .with_native_roots()
3103/// #     .unwrap()
3104/// #     .https_only()
3105/// #     .enable_http2()
3106/// #     .build();
3107///
3108/// # let executor = hyper_util::rt::TokioExecutor::new();
3109/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3110/// #     secret,
3111/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3112/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3113/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3114/// #     ),
3115/// # ).build().await.unwrap();
3116///
3117/// # let client = hyper_util::client::legacy::Client::builder(
3118/// #     hyper_util::rt::TokioExecutor::new()
3119/// # )
3120/// # .build(
3121/// #     hyper_rustls::HttpsConnectorBuilder::new()
3122/// #         .with_native_roots()
3123/// #         .unwrap()
3124/// #         .https_or_http()
3125/// #         .enable_http2()
3126/// #         .build()
3127/// # );
3128/// # let mut hub = CloudVideoIntelligence::new(client, auth);
3129/// // As the method needs a request, you would usually fill it with the desired information
3130/// // into the respective structure. Some of the parts shown here might not be applicable !
3131/// // Values shown here are possibly random and not representative !
3132/// let mut req = GoogleCloudVideointelligenceV1_AnnotateVideoRequest::default();
3133///
3134/// // You can configure optional parameters by calling the respective setters at will, and
3135/// // execute the final call using `doit()`.
3136/// // Values shown here are possibly random and not representative !
3137/// let result = hub.videos().annotate(req)
3138///              .doit().await;
3139/// # }
3140/// ```
3141pub struct VideoAnnotateCall<'a, C>
3142where
3143    C: 'a,
3144{
3145    hub: &'a CloudVideoIntelligence<C>,
3146    _request: GoogleCloudVideointelligenceV1_AnnotateVideoRequest,
3147    _delegate: Option<&'a mut dyn common::Delegate>,
3148    _additional_params: HashMap<String, String>,
3149    _scopes: BTreeSet<String>,
3150}
3151
3152impl<'a, C> common::CallBuilder for VideoAnnotateCall<'a, C> {}
3153
3154impl<'a, C> VideoAnnotateCall<'a, C>
3155where
3156    C: common::Connector,
3157{
3158    /// Perform the operation you have build so far.
3159    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunning_Operation)> {
3160        use std::borrow::Cow;
3161        use std::io::{Read, Seek};
3162
3163        use common::{url::Params, ToParts};
3164        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3165
3166        let mut dd = common::DefaultDelegate;
3167        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3168        dlg.begin(common::MethodInfo {
3169            id: "videointelligence.videos.annotate",
3170            http_method: hyper::Method::POST,
3171        });
3172
3173        for &field in ["alt"].iter() {
3174            if self._additional_params.contains_key(field) {
3175                dlg.finished(false);
3176                return Err(common::Error::FieldClash(field));
3177            }
3178        }
3179
3180        let mut params = Params::with_capacity(3 + self._additional_params.len());
3181
3182        params.extend(self._additional_params.iter());
3183
3184        params.push("alt", "json");
3185        let mut url = self.hub._base_url.clone() + "v1/videos:annotate";
3186        if self._scopes.is_empty() {
3187            self._scopes
3188                .insert(Scope::CloudPlatform.as_ref().to_string());
3189        }
3190
3191        let url = params.parse_with_url(&url);
3192
3193        let mut json_mime_type = mime::APPLICATION_JSON;
3194        let mut request_value_reader = {
3195            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3196            common::remove_json_null_values(&mut value);
3197            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3198            serde_json::to_writer(&mut dst, &value).unwrap();
3199            dst
3200        };
3201        let request_size = request_value_reader
3202            .seek(std::io::SeekFrom::End(0))
3203            .unwrap();
3204        request_value_reader
3205            .seek(std::io::SeekFrom::Start(0))
3206            .unwrap();
3207
3208        loop {
3209            let token = match self
3210                .hub
3211                .auth
3212                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3213                .await
3214            {
3215                Ok(token) => token,
3216                Err(e) => match dlg.token(e) {
3217                    Ok(token) => token,
3218                    Err(e) => {
3219                        dlg.finished(false);
3220                        return Err(common::Error::MissingToken(e));
3221                    }
3222                },
3223            };
3224            request_value_reader
3225                .seek(std::io::SeekFrom::Start(0))
3226                .unwrap();
3227            let mut req_result = {
3228                let client = &self.hub.client;
3229                dlg.pre_request();
3230                let mut req_builder = hyper::Request::builder()
3231                    .method(hyper::Method::POST)
3232                    .uri(url.as_str())
3233                    .header(USER_AGENT, self.hub._user_agent.clone());
3234
3235                if let Some(token) = token.as_ref() {
3236                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3237                }
3238
3239                let request = req_builder
3240                    .header(CONTENT_TYPE, json_mime_type.to_string())
3241                    .header(CONTENT_LENGTH, request_size as u64)
3242                    .body(common::to_body(
3243                        request_value_reader.get_ref().clone().into(),
3244                    ));
3245
3246                client.request(request.unwrap()).await
3247            };
3248
3249            match req_result {
3250                Err(err) => {
3251                    if let common::Retry::After(d) = dlg.http_error(&err) {
3252                        sleep(d).await;
3253                        continue;
3254                    }
3255                    dlg.finished(false);
3256                    return Err(common::Error::HttpError(err));
3257                }
3258                Ok(res) => {
3259                    let (mut parts, body) = res.into_parts();
3260                    let mut body = common::Body::new(body);
3261                    if !parts.status.is_success() {
3262                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3263                        let error = serde_json::from_str(&common::to_string(&bytes));
3264                        let response = common::to_response(parts, bytes.into());
3265
3266                        if let common::Retry::After(d) =
3267                            dlg.http_failure(&response, error.as_ref().ok())
3268                        {
3269                            sleep(d).await;
3270                            continue;
3271                        }
3272
3273                        dlg.finished(false);
3274
3275                        return Err(match error {
3276                            Ok(value) => common::Error::BadRequest(value),
3277                            _ => common::Error::Failure(response),
3278                        });
3279                    }
3280                    let response = {
3281                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3282                        let encoded = common::to_string(&bytes);
3283                        match serde_json::from_str(&encoded) {
3284                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3285                            Err(error) => {
3286                                dlg.response_json_decode_error(&encoded, &error);
3287                                return Err(common::Error::JsonDecodeError(
3288                                    encoded.to_string(),
3289                                    error,
3290                                ));
3291                            }
3292                        }
3293                    };
3294
3295                    dlg.finished(true);
3296                    return Ok(response);
3297                }
3298            }
3299        }
3300    }
3301
3302    ///
3303    /// Sets the *request* property to the given value.
3304    ///
3305    /// Even though the property as already been set when instantiating this call,
3306    /// we provide this method for API completeness.
3307    pub fn request(
3308        mut self,
3309        new_value: GoogleCloudVideointelligenceV1_AnnotateVideoRequest,
3310    ) -> VideoAnnotateCall<'a, C> {
3311        self._request = new_value;
3312        self
3313    }
3314    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3315    /// while executing the actual API request.
3316    ///
3317    /// ````text
3318    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3319    /// ````
3320    ///
3321    /// Sets the *delegate* property to the given value.
3322    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> VideoAnnotateCall<'a, C> {
3323        self._delegate = Some(new_value);
3324        self
3325    }
3326
3327    /// Set any additional parameter of the query string used in the request.
3328    /// It should be used to set parameters which are not yet available through their own
3329    /// setters.
3330    ///
3331    /// Please note that this method must not be used to set any of the known parameters
3332    /// which have their own setter method. If done anyway, the request will fail.
3333    ///
3334    /// # Additional Parameters
3335    ///
3336    /// * *$.xgafv* (query-string) - V1 error format.
3337    /// * *access_token* (query-string) - OAuth access token.
3338    /// * *alt* (query-string) - Data format for response.
3339    /// * *callback* (query-string) - JSONP
3340    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3341    /// * *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.
3342    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3343    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3344    /// * *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.
3345    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3346    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3347    pub fn param<T>(mut self, name: T, value: T) -> VideoAnnotateCall<'a, C>
3348    where
3349        T: AsRef<str>,
3350    {
3351        self._additional_params
3352            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3353        self
3354    }
3355
3356    /// Identifies the authorization scope for the method you are building.
3357    ///
3358    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3359    /// [`Scope::CloudPlatform`].
3360    ///
3361    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3362    /// tokens for more than one scope.
3363    ///
3364    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3365    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3366    /// sufficient, a read-write scope will do as well.
3367    pub fn add_scope<St>(mut self, scope: St) -> VideoAnnotateCall<'a, C>
3368    where
3369        St: AsRef<str>,
3370    {
3371        self._scopes.insert(String::from(scope.as_ref()));
3372        self
3373    }
3374    /// Identifies the authorization scope(s) for the method you are building.
3375    ///
3376    /// See [`Self::add_scope()`] for details.
3377    pub fn add_scopes<I, St>(mut self, scopes: I) -> VideoAnnotateCall<'a, C>
3378    where
3379        I: IntoIterator<Item = St>,
3380        St: AsRef<str>,
3381    {
3382        self._scopes
3383            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3384        self
3385    }
3386
3387    /// Removes all scopes, and no default scope will be used either.
3388    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3389    /// for details).
3390    pub fn clear_scopes(mut self) -> VideoAnnotateCall<'a, C> {
3391        self._scopes.clear();
3392        self
3393    }
3394}