google_transcoder1_beta1/
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 Platform data
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 Transcoder 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_transcoder1_beta1 as transcoder1_beta1;
49/// use transcoder1_beta1::api::Job;
50/// use transcoder1_beta1::{Result, Error};
51/// # async fn dox() {
52/// use transcoder1_beta1::{Transcoder, 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 = Transcoder::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 = Job::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_jobs_create(req, "parent")
99///              .doit().await;
100///
101/// match result {
102///     Err(e) => match e {
103///         // The Error enum provides details about what exactly happened.
104///         // You can also just use its `Debug`, `Display` or `Error` traits
105///          Error::HttpError(_)
106///         |Error::Io(_)
107///         |Error::MissingAPIKey
108///         |Error::MissingToken(_)
109///         |Error::Cancelled
110///         |Error::UploadSizeLimitExceeded(_, _)
111///         |Error::Failure(_)
112///         |Error::BadRequest(_)
113///         |Error::FieldClash(_)
114///         |Error::JsonDecodeError(_, _) => println!("{}", e),
115///     },
116///     Ok(res) => println!("Success: {:?}", res),
117/// }
118/// # }
119/// ```
120#[derive(Clone)]
121pub struct Transcoder<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 Transcoder<C> {}
130
131impl<'a, C> Transcoder<C> {
132    pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Transcoder<C> {
133        Transcoder {
134            client,
135            auth: Box::new(auth),
136            _user_agent: "google-api-rust-client/7.0.0".to_string(),
137            _base_url: "https://transcoder.googleapis.com/".to_string(),
138            _root_url: "https://transcoder.googleapis.com/".to_string(),
139        }
140    }
141
142    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
143        ProjectMethods { hub: self }
144    }
145
146    /// Set the user-agent header field to use in all requests to the server.
147    /// It defaults to `google-api-rust-client/7.0.0`.
148    ///
149    /// Returns the previously set user-agent.
150    pub fn user_agent(&mut self, agent_name: String) -> String {
151        std::mem::replace(&mut self._user_agent, agent_name)
152    }
153
154    /// Set the base url to use in all requests to the server.
155    /// It defaults to `https://transcoder.googleapis.com/`.
156    ///
157    /// Returns the previously set base url.
158    pub fn base_url(&mut self, new_base_url: String) -> String {
159        std::mem::replace(&mut self._base_url, new_base_url)
160    }
161
162    /// Set the root url to use in all requests to the server.
163    /// It defaults to `https://transcoder.googleapis.com/`.
164    ///
165    /// Returns the previously set root url.
166    pub fn root_url(&mut self, new_root_url: String) -> String {
167        std::mem::replace(&mut self._root_url, new_root_url)
168    }
169}
170
171// ############
172// SCHEMAS ###
173// ##########
174/// Ad break.
175///
176/// This type is not used in any activity, and only used as *part* of another schema.
177///
178#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
179#[serde_with::serde_as]
180#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
181pub struct AdBreak {
182    /// Start time in seconds for the ad break, relative to the output file timeline. The default is `0s`.
183    #[serde(rename = "startTimeOffset")]
184    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
185    pub start_time_offset: Option<chrono::Duration>,
186}
187
188impl common::Part for AdBreak {}
189
190/// Configuration for AES-128 encryption.
191///
192/// This type is not used in any activity, and only used as *part* of another schema.
193///
194#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
195#[serde_with::serde_as]
196#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
197pub struct Aes128Encryption {
198    /// Required. URI of the key delivery service. This URI is inserted into the M3U8 header.
199    #[serde(rename = "keyUri")]
200    pub key_uri: Option<String>,
201}
202
203impl common::Part for Aes128Encryption {}
204
205/// Animation types.
206///
207/// This type is not used in any activity, and only used as *part* of another schema.
208///
209#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
210#[serde_with::serde_as]
211#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
212pub struct Animation {
213    /// End previous animation.
214    #[serde(rename = "animationEnd")]
215    pub animation_end: Option<AnimationEnd>,
216    /// Display overlay object with fade animation.
217    #[serde(rename = "animationFade")]
218    pub animation_fade: Option<AnimationFade>,
219    /// Display static overlay object.
220    #[serde(rename = "animationStatic")]
221    pub animation_static: Option<AnimationStatic>,
222}
223
224impl common::Part for Animation {}
225
226/// End previous overlay animation from the video. Without AnimationEnd, the overlay object will keep the state of previous animation until the end of the video.
227///
228/// This type is not used in any activity, and only used as *part* of another schema.
229///
230#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
231#[serde_with::serde_as]
232#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
233pub struct AnimationEnd {
234    /// The time to end overlay object, in seconds. Default: 0
235    #[serde(rename = "startTimeOffset")]
236    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
237    pub start_time_offset: Option<chrono::Duration>,
238}
239
240impl common::Part for AnimationEnd {}
241
242/// Display overlay object with fade animation.
243///
244/// This type is not used in any activity, and only used as *part* of another schema.
245///
246#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
247#[serde_with::serde_as]
248#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
249pub struct AnimationFade {
250    /// The time to end the fade animation, in seconds. Default: `start_time_offset` + 1s
251    #[serde(rename = "endTimeOffset")]
252    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
253    pub end_time_offset: Option<chrono::Duration>,
254    /// Required. Type of fade animation: `FADE_IN` or `FADE_OUT`.
255    #[serde(rename = "fadeType")]
256    pub fade_type: Option<String>,
257    /// The time to start the fade animation, in seconds. Default: 0
258    #[serde(rename = "startTimeOffset")]
259    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
260    pub start_time_offset: Option<chrono::Duration>,
261    /// Normalized coordinates based on output video resolution. Valid values: `0.0`–`1.0`. `xy` is the upper-left coordinate of the overlay object. For example, use the x and y coordinates {0,0} to position the top-left corner of the overlay animation in the top-left corner of the output video.
262    pub xy: Option<NormalizedCoordinate>,
263}
264
265impl common::Part for AnimationFade {}
266
267/// Display static overlay object.
268///
269/// This type is not used in any activity, and only used as *part* of another schema.
270///
271#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
272#[serde_with::serde_as]
273#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
274pub struct AnimationStatic {
275    /// The time to start displaying the overlay object, in seconds. Default: 0
276    #[serde(rename = "startTimeOffset")]
277    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
278    pub start_time_offset: Option<chrono::Duration>,
279    /// Normalized coordinates based on output video resolution. Valid values: `0.0`–`1.0`. `xy` is the upper-left coordinate of the overlay object. For example, use the x and y coordinates {0,0} to position the top-left corner of the overlay animation in the top-left corner of the output video.
280    pub xy: Option<NormalizedCoordinate>,
281}
282
283impl common::Part for AnimationStatic {}
284
285/// Audio preprocessing configuration.
286///
287/// This type is not used in any activity, and only used as *part* of another schema.
288///
289#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
290#[serde_with::serde_as]
291#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
292pub struct Audio {
293    /// Enable boosting high frequency components. The default is `false`.
294    #[serde(rename = "highBoost")]
295    pub high_boost: Option<bool>,
296    /// Enable boosting low frequency components. The default is `false`.
297    #[serde(rename = "lowBoost")]
298    pub low_boost: Option<bool>,
299    /// Specify audio loudness normalization in loudness units relative to full scale (LUFS). Enter a value between -24 and 0 (the default), where: * -24 is the Advanced Television Systems Committee (ATSC A/85) standard * -23 is the EU R128 broadcast standard * -19 is the prior standard for online mono audio * -18 is the ReplayGain standard * -16 is the prior standard for stereo audio * -14 is the new online audio standard recommended by Spotify, as well as Amazon Echo * 0 disables normalization
300    pub lufs: Option<f64>,
301}
302
303impl common::Part for Audio {}
304
305/// The mapping for the `Job.edit_list` atoms with audio `EditAtom.inputs`.
306///
307/// This type is not used in any activity, and only used as *part* of another schema.
308///
309#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
310#[serde_with::serde_as]
311#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
312pub struct AudioAtom {
313    /// List of `Channel`s for this audio stream. for in-depth explanation.
314    pub channels: Option<Vec<AudioChannel>>,
315    /// Required. The `EditAtom.key` that references the atom with audio inputs in the `Job.edit_list`.
316    pub key: Option<String>,
317}
318
319impl common::Part for AudioAtom {}
320
321/// The audio channel.
322///
323/// This type is not used in any activity, and only used as *part* of another schema.
324///
325#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
326#[serde_with::serde_as]
327#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
328pub struct AudioChannel {
329    /// List of `Job.inputs` for this audio channel.
330    pub inputs: Option<Vec<AudioChannelInput>>,
331}
332
333impl common::Part for AudioChannel {}
334
335/// Identifies which input file, track, and channel should be used.
336///
337/// This type is not used in any activity, and only used as *part* of another schema.
338///
339#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
340#[serde_with::serde_as]
341#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
342pub struct AudioChannelInput {
343    /// Required. The zero-based index of the channel in the input file.
344    pub channel: Option<i32>,
345    /// Audio volume control in dB. Negative values decrease volume, positive values increase. The default is 0.
346    #[serde(rename = "gainDb")]
347    pub gain_db: Option<f64>,
348    /// Required. The `Input.key` that identifies the input file.
349    pub key: Option<String>,
350    /// Required. The zero-based index of the track in the input file.
351    pub track: Option<i32>,
352}
353
354impl common::Part for AudioChannelInput {}
355
356/// Audio stream resource.
357///
358/// This type is not used in any activity, and only used as *part* of another schema.
359///
360#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
361#[serde_with::serde_as]
362#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
363pub struct AudioStream {
364    /// Required. Audio bitrate in bits per second. Must be between 1 and 10,000,000.
365    #[serde(rename = "bitrateBps")]
366    pub bitrate_bps: Option<i32>,
367    /// Number of audio channels. Must be between 1 and 6. The default is 2.
368    #[serde(rename = "channelCount")]
369    pub channel_count: Option<i32>,
370    /// A list of channel names specifying layout of the audio channels. This only affects the metadata embedded in the container headers, if supported by the specified format. The default is `["fl", "fr"]`. Supported channel names: - 'fl' - Front left channel - 'fr' - Front right channel - 'sl' - Side left channel - 'sr' - Side right channel - 'fc' - Front center channel - 'lfe' - Low frequency
371    #[serde(rename = "channelLayout")]
372    pub channel_layout: Option<Vec<String>>,
373    /// The codec for this audio stream. The default is `"aac"`. Supported audio codecs: - 'aac' - 'aac-he' - 'aac-he-v2' - 'mp3' - 'ac3' - 'eac3'
374    pub codec: Option<String>,
375    /// The mapping for the `Job.edit_list` atoms with audio `EditAtom.inputs`.
376    pub mapping: Option<Vec<AudioAtom>>,
377    /// The audio sample rate in Hertz. The default is 48000 Hertz.
378    #[serde(rename = "sampleRateHertz")]
379    pub sample_rate_hertz: Option<i32>,
380}
381
382impl common::Part for AudioStream {}
383
384/// Color preprocessing configuration.
385///
386/// This type is not used in any activity, and only used as *part* of another schema.
387///
388#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
389#[serde_with::serde_as]
390#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
391pub struct Color {
392    /// Control brightness of the video. Enter a value between -1 and 1, where -1 is minimum brightness and 1 is maximum brightness. 0 is no change. The default is 0.
393    pub brightness: Option<f64>,
394    /// Control black and white contrast of the video. Enter a value between -1 and 1, where -1 is minimum contrast and 1 is maximum contrast. 0 is no change. The default is 0.
395    pub contrast: Option<f64>,
396    /// Control color saturation of the video. Enter a value between -1 and 1, where -1 is fully desaturated and 1 is maximum saturation. 0 is no change. The default is 0.
397    pub saturation: Option<f64>,
398}
399
400impl common::Part for Color {}
401
402/// Video cropping configuration for the input video. The cropped input video is scaled to match the output resolution.
403///
404/// This type is not used in any activity, and only used as *part* of another schema.
405///
406#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
407#[serde_with::serde_as]
408#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
409pub struct Crop {
410    /// The number of pixels to crop from the bottom. The default is 0.
411    #[serde(rename = "bottomPixels")]
412    pub bottom_pixels: Option<i32>,
413    /// The number of pixels to crop from the left. The default is 0.
414    #[serde(rename = "leftPixels")]
415    pub left_pixels: Option<i32>,
416    /// The number of pixels to crop from the right. The default is 0.
417    #[serde(rename = "rightPixels")]
418    pub right_pixels: Option<i32>,
419    /// The number of pixels to crop from the top. The default is 0.
420    #[serde(rename = "topPixels")]
421    pub top_pixels: Option<i32>,
422}
423
424impl common::Part for Crop {}
425
426/// Deblock preprocessing configuration.
427///
428/// This type is not used in any activity, and only used as *part* of another schema.
429///
430#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
431#[serde_with::serde_as]
432#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
433pub struct Deblock {
434    /// Enable deblocker. The default is `false`.
435    pub enabled: Option<bool>,
436    /// Set strength of the deblocker. Enter a value between 0 and 1. The higher the value, the stronger the block removal. 0 is no deblocking. The default is 0.
437    pub strength: Option<f64>,
438}
439
440impl common::Part for Deblock {}
441
442/// Denoise preprocessing configuration.
443///
444/// This type is not used in any activity, and only used as *part* of another schema.
445///
446#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
447#[serde_with::serde_as]
448#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
449pub struct Denoise {
450    /// Set strength of the denoise. Enter a value between 0 and 1. The higher the value, the smoother the image. 0 is no denoising. The default is 0.
451    pub strength: Option<f64>,
452    /// Set the denoiser mode. The default is `"standard"`. Supported denoiser modes: - 'standard' - 'grain'
453    pub tune: Option<String>,
454}
455
456impl common::Part for Denoise {}
457
458/// Edit atom.
459///
460/// This type is not used in any activity, and only used as *part* of another schema.
461///
462#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
463#[serde_with::serde_as]
464#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
465pub struct EditAtom {
466    /// End time in seconds for the atom, relative to the input file timeline. When `end_time_offset` is not specified, the `inputs` are used until the end of the atom.
467    #[serde(rename = "endTimeOffset")]
468    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
469    pub end_time_offset: Option<chrono::Duration>,
470    /// List of `Input.key`s identifying files that should be used in this atom. The listed `inputs` must have the same timeline.
471    pub inputs: Option<Vec<String>>,
472    /// A unique key for this atom. Must be specified when using advanced mapping.
473    pub key: Option<String>,
474    /// Start time in seconds for the atom, relative to the input file timeline. The default is `0s`.
475    #[serde(rename = "startTimeOffset")]
476    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
477    pub start_time_offset: Option<chrono::Duration>,
478}
479
480impl common::Part for EditAtom {}
481
482/// Encoding of an input file such as an audio, video, or text track. Elementary streams must be packaged before mapping and sharing between different output formats.
483///
484/// This type is not used in any activity, and only used as *part* of another schema.
485///
486#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
487#[serde_with::serde_as]
488#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
489pub struct ElementaryStream {
490    /// Encoding of an audio stream.
491    #[serde(rename = "audioStream")]
492    pub audio_stream: Option<AudioStream>,
493    /// A unique key for this elementary stream.
494    pub key: Option<String>,
495    /// Encoding of a text stream. For example, closed captions or subtitles.
496    #[serde(rename = "textStream")]
497    pub text_stream: Option<TextStream>,
498    /// Encoding of a video stream.
499    #[serde(rename = "videoStream")]
500    pub video_stream: Option<VideoStream>,
501}
502
503impl common::Part for ElementaryStream {}
504
505/// 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); } The JSON representation for `Empty` is empty JSON object `{}`.
506///
507/// # Activities
508///
509/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
510/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
511///
512/// * [locations job templates delete projects](ProjectLocationJobTemplateDeleteCall) (response)
513/// * [locations jobs delete projects](ProjectLocationJobDeleteCall) (response)
514#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
515#[serde_with::serde_as]
516#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
517pub struct Empty {
518    _never_set: Option<bool>,
519}
520
521impl common::ResponseResult for Empty {}
522
523/// Encryption settings.
524///
525/// This type is not used in any activity, and only used as *part* of another schema.
526///
527#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
528#[serde_with::serde_as]
529#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
530pub struct Encryption {
531    /// Configuration for AES-128 encryption.
532    pub aes128: Option<Aes128Encryption>,
533    /// Required. 128 bit Initialization Vector (IV) represented as lowercase hexadecimal digits.
534    pub iv: Option<String>,
535    /// Required. 128 bit encryption key represented as lowercase hexadecimal digits.
536    pub key: Option<String>,
537    /// Configuration for MPEG Common Encryption (MPEG-CENC).
538    #[serde(rename = "mpegCenc")]
539    pub mpeg_cenc: Option<MpegCommonEncryption>,
540    /// Configuration for SAMPLE-AES encryption.
541    #[serde(rename = "sampleAes")]
542    pub sample_aes: Option<SampleAesEncryption>,
543}
544
545impl common::Part for Encryption {}
546
547/// Additional information about the reasons for the failure.
548///
549/// This type is not used in any activity, and only used as *part* of another schema.
550///
551#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
552#[serde_with::serde_as]
553#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
554pub struct FailureDetail {
555    /// A description of the failure.
556    pub description: Option<String>,
557}
558
559impl common::Part for FailureDetail {}
560
561/// Overlaid jpeg image.
562///
563/// This type is not used in any activity, and only used as *part* of another schema.
564///
565#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
566#[serde_with::serde_as]
567#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
568pub struct Image {
569    /// Target image opacity. Valid values: `1.0` (solid, default) to `0.0` (transparent).
570    pub alpha: Option<f64>,
571    /// Normalized image resolution, based on output video resolution. Valid values: `0.0`–`1.0`. To respect the original image aspect ratio, set either `x` or `y` to `0.0`. To use the original image resolution, set both `x` and `y` to `0.0`.
572    pub resolution: Option<NormalizedCoordinate>,
573    /// Required. URI of the JPEG image in Cloud Storage. For example, `gs://bucket/inputs/image.jpeg`. JPEG is the only supported image type.
574    pub uri: Option<String>,
575}
576
577impl common::Part for Image {}
578
579/// Input asset.
580///
581/// This type is not used in any activity, and only used as *part* of another schema.
582///
583#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
584#[serde_with::serde_as]
585#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
586pub struct Input {
587    /// A unique key for this input. Must be specified when using advanced mapping and edit lists.
588    pub key: Option<String>,
589    /// Preprocessing configurations.
590    #[serde(rename = "preprocessingConfig")]
591    pub preprocessing_config: Option<PreprocessingConfig>,
592    /// URI of the media. Input files must be at least 5 seconds in duration and stored in Cloud Storage (for example, `gs://bucket/inputs/file.mp4`). If empty, the value will be populated from `Job.input_uri`.
593    pub uri: Option<String>,
594}
595
596impl common::Part for Input {}
597
598/// Transcoding job resource.
599///
600/// # Activities
601///
602/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
603/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
604///
605/// * [locations jobs create projects](ProjectLocationJobCreateCall) (request|response)
606/// * [locations jobs get projects](ProjectLocationJobGetCall) (response)
607#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
608#[serde_with::serde_as]
609#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
610pub struct Job {
611    /// The configuration for this job.
612    pub config: Option<JobConfig>,
613    /// Output only. The time the job was created.
614    #[serde(rename = "createTime")]
615    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
616    /// Output only. The time the transcoding finished.
617    #[serde(rename = "endTime")]
618    pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
619    /// Output only. List of failure details. This property may contain additional information about the failure when `failure_reason` is present. *Note*: This feature is not yet available.
620    #[serde(rename = "failureDetails")]
621    pub failure_details: Option<Vec<FailureDetail>>,
622    /// Output only. A description of the reason for the failure. This property is always present when `state` is `FAILED`.
623    #[serde(rename = "failureReason")]
624    pub failure_reason: Option<String>,
625    /// Input only. Specify the `input_uri` to populate empty `uri` fields in each element of `Job.config.inputs` or `JobTemplate.config.inputs` when using template. URI of the media. Input files must be at least 5 seconds in duration and stored in Cloud Storage (for example, `gs://bucket/inputs/file.mp4`).
626    #[serde(rename = "inputUri")]
627    pub input_uri: Option<String>,
628    /// The resource name of the job. Format: `projects/{project}/locations/{location}/jobs/{job}`
629    pub name: Option<String>,
630    /// Output only. The origin URI. *Note*: This feature is not yet available.
631    #[serde(rename = "originUri")]
632    pub origin_uri: Option<OriginUri>,
633    /// Input only. Specify the `output_uri` to populate an empty `Job.config.output.uri` or `JobTemplate.config.output.uri` when using template. URI for the output file(s). For example, `gs://my-bucket/outputs/`.
634    #[serde(rename = "outputUri")]
635    pub output_uri: Option<String>,
636    /// Specify the priority of the job. Enter a value between 0 and 100, where 0 is the lowest priority and 100 is the highest priority. The default is 0.
637    pub priority: Option<i32>,
638    /// Output only. Estimated fractional progress, from `0` to `1` for each step. *Note*: This feature is not yet available.
639    pub progress: Option<Progress>,
640    /// Output only. The time the transcoding started.
641    #[serde(rename = "startTime")]
642    pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
643    /// Output only. The current state of the job.
644    pub state: Option<String>,
645    /// Input only. Specify the `template_id` to use for populating `Job.config`. The default is `preset/web-hd`. Preset Transcoder templates: - `preset/{preset_id}` - User defined JobTemplate: `{job_template_id}`
646    #[serde(rename = "templateId")]
647    pub template_id: Option<String>,
648    /// Job time to live value in days, which will be effective after job completion. Job should be deleted automatically after the given TTL. Enter a value between 1 and 90. The default is 30.
649    #[serde(rename = "ttlAfterCompletionDays")]
650    pub ttl_after_completion_days: Option<i32>,
651}
652
653impl common::RequestValue for Job {}
654impl common::ResponseResult for Job {}
655
656/// Job configuration
657///
658/// This type is not used in any activity, and only used as *part* of another schema.
659///
660#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
661#[serde_with::serde_as]
662#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
663pub struct JobConfig {
664    /// List of ad breaks. Specifies where to insert ad break tags in the output manifests.
665    #[serde(rename = "adBreaks")]
666    pub ad_breaks: Option<Vec<AdBreak>>,
667    /// List of `Edit atom`s. Defines the ultimate timeline of the resulting file or manifest.
668    #[serde(rename = "editList")]
669    pub edit_list: Option<Vec<EditAtom>>,
670    /// List of elementary streams.
671    #[serde(rename = "elementaryStreams")]
672    pub elementary_streams: Option<Vec<ElementaryStream>>,
673    /// List of input assets stored in Cloud Storage.
674    pub inputs: Option<Vec<Input>>,
675    /// List of output manifests.
676    pub manifests: Option<Vec<Manifest>>,
677    /// List of multiplexing settings for output streams.
678    #[serde(rename = "muxStreams")]
679    pub mux_streams: Option<Vec<MuxStream>>,
680    /// Output configuration.
681    pub output: Option<Output>,
682    /// List of overlays on the output video, in descending Z-order.
683    pub overlays: Option<Vec<Overlay>>,
684    /// Destination on Pub/Sub.
685    #[serde(rename = "pubsubDestination")]
686    pub pubsub_destination: Option<PubsubDestination>,
687    /// List of output sprite sheets.
688    #[serde(rename = "spriteSheets")]
689    pub sprite_sheets: Option<Vec<SpriteSheet>>,
690}
691
692impl common::Part for JobConfig {}
693
694/// Transcoding job template resource.
695///
696/// # Activities
697///
698/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
699/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
700///
701/// * [locations job templates create projects](ProjectLocationJobTemplateCreateCall) (request|response)
702/// * [locations job templates get projects](ProjectLocationJobTemplateGetCall) (response)
703#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
704#[serde_with::serde_as]
705#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
706pub struct JobTemplate {
707    /// The configuration for this template.
708    pub config: Option<JobConfig>,
709    /// The resource name of the job template. Format: `projects/{project}/locations/{location}/jobTemplates/{job_template}`
710    pub name: Option<String>,
711}
712
713impl common::RequestValue for JobTemplate {}
714impl common::ResponseResult for JobTemplate {}
715
716/// Response message for `TranscoderService.ListJobTemplates`.
717///
718/// # Activities
719///
720/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
721/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
722///
723/// * [locations job templates list projects](ProjectLocationJobTemplateListCall) (response)
724#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
725#[serde_with::serde_as]
726#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
727pub struct ListJobTemplatesResponse {
728    /// List of job templates in the specified region.
729    #[serde(rename = "jobTemplates")]
730    pub job_templates: Option<Vec<JobTemplate>>,
731    /// The pagination token.
732    #[serde(rename = "nextPageToken")]
733    pub next_page_token: Option<String>,
734}
735
736impl common::ResponseResult for ListJobTemplatesResponse {}
737
738/// Response message for `TranscoderService.ListJobs`.
739///
740/// # Activities
741///
742/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
743/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
744///
745/// * [locations jobs list projects](ProjectLocationJobListCall) (response)
746#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
747#[serde_with::serde_as]
748#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
749pub struct ListJobsResponse {
750    /// List of jobs in the specified region.
751    pub jobs: Option<Vec<Job>>,
752    /// The pagination token.
753    #[serde(rename = "nextPageToken")]
754    pub next_page_token: Option<String>,
755}
756
757impl common::ResponseResult for ListJobsResponse {}
758
759/// Manifest configuration.
760///
761/// This type is not used in any activity, and only used as *part* of another schema.
762///
763#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
764#[serde_with::serde_as]
765#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
766pub struct Manifest {
767    /// The name of the generated file. The default is `"manifest"` with the extension suffix corresponding to the `Manifest.type`.
768    #[serde(rename = "fileName")]
769    pub file_name: Option<String>,
770    /// Required. List of user given `MuxStream.key`s that should appear in this manifest. When `Manifest.type` is `HLS`, a media manifest with name `MuxStream.key` and `.m3u8` extension is generated for each element of the `Manifest.mux_streams`.
771    #[serde(rename = "muxStreams")]
772    pub mux_streams: Option<Vec<String>>,
773    /// Required. Type of the manifest, can be "HLS" or "DASH".
774    #[serde(rename = "type")]
775    pub type_: Option<String>,
776}
777
778impl common::Part for Manifest {}
779
780/// Configuration for MPEG Common Encryption (MPEG-CENC).
781///
782/// This type is not used in any activity, and only used as *part* of another schema.
783///
784#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
785#[serde_with::serde_as]
786#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
787pub struct MpegCommonEncryption {
788    /// Required. 128 bit Key ID represented as lowercase hexadecimal digits for use with common encryption.
789    #[serde(rename = "keyId")]
790    pub key_id: Option<String>,
791    /// Required. Specify the encryption scheme. Supported encryption schemes: - 'cenc' - 'cbcs'
792    pub scheme: Option<String>,
793}
794
795impl common::Part for MpegCommonEncryption {}
796
797/// Multiplexing settings for output stream.
798///
799/// This type is not used in any activity, and only used as *part* of another schema.
800///
801#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
802#[serde_with::serde_as]
803#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
804pub struct MuxStream {
805    /// The container format. The default is `"mp4"` Supported container formats: - 'ts' - 'fmp4'- the corresponding file extension is `".m4s"` - 'mp4' - 'vtt'
806    pub container: Option<String>,
807    /// List of `ElementaryStream.key`s multiplexed in this stream.
808    #[serde(rename = "elementaryStreams")]
809    pub elementary_streams: Option<Vec<String>>,
810    /// Encryption settings.
811    pub encryption: Option<Encryption>,
812    /// The name of the generated file. The default is `MuxStream.key` with the extension suffix corresponding to the `MuxStream.container`. Individual segments also have an incremental 10-digit zero-padded suffix starting from 0 before the extension, such as `"mux_stream0000000123.ts"`.
813    #[serde(rename = "fileName")]
814    pub file_name: Option<String>,
815    /// A unique key for this multiplexed stream. HLS media manifests will be named `MuxStream.key` with the `".m3u8"` extension suffix.
816    pub key: Option<String>,
817    /// Segment settings for `"ts"`, `"fmp4"` and `"vtt"`.
818    #[serde(rename = "segmentSettings")]
819    pub segment_settings: Option<SegmentSettings>,
820}
821
822impl common::Part for MuxStream {}
823
824/// 2D normalized coordinates. Default: `{0.0, 0.0}`
825///
826/// This type is not used in any activity, and only used as *part* of another schema.
827///
828#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
829#[serde_with::serde_as]
830#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
831pub struct NormalizedCoordinate {
832    /// Normalized x coordinate.
833    pub x: Option<f64>,
834    /// Normalized y coordinate.
835    pub y: Option<f64>,
836}
837
838impl common::Part for NormalizedCoordinate {}
839
840/// The origin URI.
841///
842/// This type is not used in any activity, and only used as *part* of another schema.
843///
844#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
845#[serde_with::serde_as]
846#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
847pub struct OriginUri {
848    /// Dash manifest URI. If multiple Dash manifests are created, only the first one is listed.
849    pub dash: Option<String>,
850    /// HLS manifest URI per https://tools.ietf.org/html/rfc8216#section-4.3.4. If multiple HLS manifests are created, only the first one is listed.
851    pub hls: Option<String>,
852}
853
854impl common::Part for OriginUri {}
855
856/// Location of output file(s) in a Cloud Storage bucket.
857///
858/// This type is not used in any activity, and only used as *part* of another schema.
859///
860#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
861#[serde_with::serde_as]
862#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
863pub struct Output {
864    /// URI for the output file(s). For example, `gs://my-bucket/outputs/`. If empty the value is populated from `Job.output_uri`.
865    pub uri: Option<String>,
866}
867
868impl common::Part for Output {}
869
870/// Overlay configuration.
871///
872/// This type is not used in any activity, and only used as *part* of another schema.
873///
874#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
875#[serde_with::serde_as]
876#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
877pub struct Overlay {
878    /// List of Animations. The list should be chronological, without any time overlap.
879    pub animations: Option<Vec<Animation>>,
880    /// Image overlay.
881    pub image: Option<Image>,
882}
883
884impl common::Part for Overlay {}
885
886/// Pad filter configuration for the input video. The padded input video is scaled after padding with black to match the output resolution.
887///
888/// This type is not used in any activity, and only used as *part* of another schema.
889///
890#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
891#[serde_with::serde_as]
892#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
893pub struct Pad {
894    /// The number of pixels to add to the bottom. The default is 0.
895    #[serde(rename = "bottomPixels")]
896    pub bottom_pixels: Option<i32>,
897    /// The number of pixels to add to the left. The default is 0.
898    #[serde(rename = "leftPixels")]
899    pub left_pixels: Option<i32>,
900    /// The number of pixels to add to the right. The default is 0.
901    #[serde(rename = "rightPixels")]
902    pub right_pixels: Option<i32>,
903    /// The number of pixels to add to the top. The default is 0.
904    #[serde(rename = "topPixels")]
905    pub top_pixels: Option<i32>,
906}
907
908impl common::Part for Pad {}
909
910/// Preprocessing configurations.
911///
912/// This type is not used in any activity, and only used as *part* of another schema.
913///
914#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
915#[serde_with::serde_as]
916#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
917pub struct PreprocessingConfig {
918    /// Audio preprocessing configuration.
919    pub audio: Option<Audio>,
920    /// Color preprocessing configuration.
921    pub color: Option<Color>,
922    /// Specify the video cropping configuration.
923    pub crop: Option<Crop>,
924    /// Deblock preprocessing configuration.
925    pub deblock: Option<Deblock>,
926    /// Denoise preprocessing configuration.
927    pub denoise: Option<Denoise>,
928    /// Specify the video pad filter configuration.
929    pub pad: Option<Pad>,
930}
931
932impl common::Part for PreprocessingConfig {}
933
934/// Estimated fractional progress for each step, from `0` to `1`.
935///
936/// This type is not used in any activity, and only used as *part* of another schema.
937///
938#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
939#[serde_with::serde_as]
940#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
941pub struct Progress {
942    /// Estimated fractional progress for `analyzing` step.
943    pub analyzed: Option<f64>,
944    /// Estimated fractional progress for `encoding` step.
945    pub encoded: Option<f64>,
946    /// Estimated fractional progress for `notifying` step.
947    pub notified: Option<f64>,
948    /// Estimated fractional progress for `uploading` step.
949    pub uploaded: Option<f64>,
950}
951
952impl common::Part for Progress {}
953
954/// A Pub/Sub destination.
955///
956/// This type is not used in any activity, and only used as *part* of another schema.
957///
958#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
959#[serde_with::serde_as]
960#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
961pub struct PubsubDestination {
962    /// The name of the Pub/Sub topic to publish job completion notification to. For example: `projects/{project}/topics/{topic}`.
963    pub topic: Option<String>,
964}
965
966impl common::Part for PubsubDestination {}
967
968/// Configuration for SAMPLE-AES encryption.
969///
970/// This type is not used in any activity, and only used as *part* of another schema.
971///
972#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
973#[serde_with::serde_as]
974#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
975pub struct SampleAesEncryption {
976    /// Required. URI of the key delivery service. This URI is inserted into the M3U8 header.
977    #[serde(rename = "keyUri")]
978    pub key_uri: Option<String>,
979}
980
981impl common::Part for SampleAesEncryption {}
982
983/// Segment settings for `"ts"`, `"fmp4"` and `"vtt"`.
984///
985/// This type is not used in any activity, and only used as *part* of another schema.
986///
987#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
988#[serde_with::serde_as]
989#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
990pub struct SegmentSettings {
991    /// Required. Create an individual segment file. The default is `false`.
992    #[serde(rename = "individualSegments")]
993    pub individual_segments: Option<bool>,
994    /// Duration of the segments in seconds. The default is `"6.0s"`. Note that `segmentDuration` must be greater than or equal to [`gopDuration`](#videostream), and `segmentDuration` must be divisible by [`gopDuration`](#videostream).
995    #[serde(rename = "segmentDuration")]
996    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
997    pub segment_duration: Option<chrono::Duration>,
998}
999
1000impl common::Part for SegmentSettings {}
1001
1002/// Sprite sheet configuration.
1003///
1004/// This type is not used in any activity, and only used as *part* of another schema.
1005///
1006#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1007#[serde_with::serde_as]
1008#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1009pub struct SpriteSheet {
1010    /// The maximum number of sprites per row in a sprite sheet. The default is 0, which indicates no maximum limit.
1011    #[serde(rename = "columnCount")]
1012    pub column_count: Option<i32>,
1013    /// End time in seconds, relative to the output file timeline. When `end_time_offset` is not specified, the sprites are generated until the end of the output file.
1014    #[serde(rename = "endTimeOffset")]
1015    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1016    pub end_time_offset: Option<chrono::Duration>,
1017    /// Required. File name prefix for the generated sprite sheets. Each sprite sheet has an incremental 10-digit zero-padded suffix starting from 0 before the extension, such as `"sprite_sheet0000000123.jpeg"`.
1018    #[serde(rename = "filePrefix")]
1019    pub file_prefix: Option<String>,
1020    /// Format type. The default is `"jpeg"`. Supported formats: - 'jpeg'
1021    pub format: Option<String>,
1022    /// Starting from `0s`, create sprites at regular intervals. Specify the interval value in seconds.
1023    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1024    pub interval: Option<chrono::Duration>,
1025    /// The quality of the generated sprite sheet. Enter a value between 1 and 100, where 1 is the lowest quality and 100 is the highest quality. The default is 100. A high quality value corresponds to a low image data compression ratio.
1026    pub quality: Option<i32>,
1027    /// The maximum number of rows per sprite sheet. When the sprite sheet is full, a new sprite sheet is created. The default is 0, which indicates no maximum limit.
1028    #[serde(rename = "rowCount")]
1029    pub row_count: Option<i32>,
1030    /// Required. The height of sprite in pixels. Must be an even integer. To preserve the source aspect ratio, set the SpriteSheet.sprite_height_pixels field or the SpriteSheet.sprite_width_pixels field, but not both (the API will automatically calculate the missing field).
1031    #[serde(rename = "spriteHeightPixels")]
1032    pub sprite_height_pixels: Option<i32>,
1033    /// Required. The width of sprite in pixels. Must be an even integer. To preserve the source aspect ratio, set the SpriteSheet.sprite_width_pixels field or the SpriteSheet.sprite_height_pixels field, but not both (the API will automatically calculate the missing field).
1034    #[serde(rename = "spriteWidthPixels")]
1035    pub sprite_width_pixels: Option<i32>,
1036    /// Start time in seconds, relative to the output file timeline. Determines the first sprite to pick. The default is `0s`.
1037    #[serde(rename = "startTimeOffset")]
1038    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1039    pub start_time_offset: Option<chrono::Duration>,
1040    /// Total number of sprites. Create the specified number of sprites distributed evenly across the timeline of the output media. The default is 100.
1041    #[serde(rename = "totalCount")]
1042    pub total_count: Option<i32>,
1043}
1044
1045impl common::Part for SpriteSheet {}
1046
1047/// The mapping for the `Job.edit_list` atoms with text `EditAtom.inputs`.
1048///
1049/// This type is not used in any activity, and only used as *part* of another schema.
1050///
1051#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1052#[serde_with::serde_as]
1053#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1054pub struct TextAtom {
1055    /// List of `Job.inputs` that should be embedded in this atom. Only one input is supported.
1056    pub inputs: Option<Vec<TextInput>>,
1057    /// Required. The `EditAtom.key` that references atom with text inputs in the `Job.edit_list`.
1058    pub key: Option<String>,
1059}
1060
1061impl common::Part for TextAtom {}
1062
1063/// Identifies which input file and track should be used.
1064///
1065/// This type is not used in any activity, and only used as *part* of another schema.
1066///
1067#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1068#[serde_with::serde_as]
1069#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1070pub struct TextInput {
1071    /// Required. The `Input.key` that identifies the input file.
1072    pub key: Option<String>,
1073    /// Required. The zero-based index of the track in the input file.
1074    pub track: Option<i32>,
1075}
1076
1077impl common::Part for TextInput {}
1078
1079/// Encoding of a text stream. For example, closed captions or subtitles.
1080///
1081/// This type is not used in any activity, and only used as *part* of another schema.
1082///
1083#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1084#[serde_with::serde_as]
1085#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1086pub struct TextStream {
1087    /// The codec for this text stream. The default is `"webvtt"`. Supported text codecs: - 'srt' - 'ttml' - 'cea608' - 'cea708' - 'webvtt'
1088    pub codec: Option<String>,
1089    /// Required. The BCP-47 language code, such as `"en-US"` or `"sr-Latn"`. For more information, see https://www.unicode.org/reports/tr35/#Unicode_locale_identifier.
1090    #[serde(rename = "languageCode")]
1091    pub language_code: Option<String>,
1092    /// The mapping for the `Job.edit_list` atoms with text `EditAtom.inputs`.
1093    pub mapping: Option<Vec<TextAtom>>,
1094}
1095
1096impl common::Part for TextStream {}
1097
1098/// Video stream resource.
1099///
1100/// This type is not used in any activity, and only used as *part* of another schema.
1101///
1102#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1103#[serde_with::serde_as]
1104#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1105pub struct VideoStream {
1106    /// Specifies whether an open Group of Pictures (GOP) structure should be allowed or not. The default is `false`.
1107    #[serde(rename = "allowOpenGop")]
1108    pub allow_open_gop: Option<bool>,
1109    /// Specify the intensity of the adaptive quantizer (AQ). Must be between 0 and 1, where 0 disables the quantizer and 1 maximizes the quantizer. A higher value equals a lower bitrate but smoother image. The default is 0.
1110    #[serde(rename = "aqStrength")]
1111    pub aq_strength: Option<f64>,
1112    /// The number of consecutive B-frames. Must be greater than or equal to zero. Must be less than `VideoStream.gop_frame_count` if set. The default is 0.
1113    #[serde(rename = "bFrameCount")]
1114    pub b_frame_count: Option<i32>,
1115    /// Allow B-pyramid for reference frame selection. This may not be supported on all decoders. The default is `false`.
1116    #[serde(rename = "bPyramid")]
1117    pub b_pyramid: Option<bool>,
1118    /// Required. The video bitrate in bits per second. Must be between 1 and 1,000,000,000.
1119    #[serde(rename = "bitrateBps")]
1120    pub bitrate_bps: Option<i32>,
1121    /// Codec type. The following codecs are supported: * `h264` (default) * `h265` * `vp9`
1122    pub codec: Option<String>,
1123    /// Target CRF level. Must be between 10 and 36, where 10 is the highest quality and 36 is the most efficient compression. The default is 21.
1124    #[serde(rename = "crfLevel")]
1125    pub crf_level: Option<i32>,
1126    /// Use two-pass encoding strategy to achieve better video quality. `VideoStream.rate_control_mode` must be `"vbr"`. The default is `false`.
1127    #[serde(rename = "enableTwoPass")]
1128    pub enable_two_pass: Option<bool>,
1129    /// The entropy coder to use. The default is `"cabac"`. Supported entropy coders: - 'cavlc' - 'cabac'
1130    #[serde(rename = "entropyCoder")]
1131    pub entropy_coder: Option<String>,
1132    /// Required. The target video frame rate in frames per second (FPS). Must be less than or equal to 120. Will default to the input frame rate if larger than the input frame rate. The API will generate an output FPS that is divisible by the input FPS, and smaller or equal to the target FPS. The following table shows the computed video FPS given the target FPS (in parenthesis) and input FPS (in the first column): ``` | | (30) | (60) | (25) | (50) | |--------|--------|--------|------|------| | 240 | Fail | Fail | Fail | Fail | | 120 | 30 | 60 | 20 | 30 | | 100 | 25 | 50 | 20 | 30 | | 50 | 25 | 50 | 20 | 30 | | 60 | 30 | 60 | 20 | 30 | | 59.94 | 29.97 | 59.94 | 20 | 30 | | 48 | 24 | 48 | 20 | 30 | | 30 | 30 | 30 | 20 | 30 | | 25 | 25 | 25 | 20 | 30 | | 24 | 24 | 24 | 20 | 30 | | 23.976 | 23.976 | 23.976 | 20 | 30 | | 15 | 15 | 15 | 20 | 30 | | 12 | 12 | 12 | 20 | 30 | | 10 | 10 | 10 | 20 | 30 | ```
1133    #[serde(rename = "frameRate")]
1134    pub frame_rate: Option<f64>,
1135    /// Select the GOP size based on the specified duration. The default is `"3s"`. Note that `gopDuration` must be less than or equal to [`segmentDuration`](#SegmentSettings), and [`segmentDuration`](#SegmentSettings) must be divisible by `gopDuration`.
1136    #[serde(rename = "gopDuration")]
1137    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1138    pub gop_duration: Option<chrono::Duration>,
1139    /// Select the GOP size based on the specified frame count. Must be greater than zero.
1140    #[serde(rename = "gopFrameCount")]
1141    pub gop_frame_count: Option<i32>,
1142    /// The height of the video in pixels. Must be an even integer. When not specified, the height is adjusted to match the specified width and input aspect ratio. If both are omitted, the input height is used.
1143    #[serde(rename = "heightPixels")]
1144    pub height_pixels: Option<i32>,
1145    /// Pixel format to use. The default is `"yuv420p"`. Supported pixel formats: - 'yuv420p' pixel format. - 'yuv422p' pixel format. - 'yuv444p' pixel format. - 'yuv420p10' 10-bit HDR pixel format. - 'yuv422p10' 10-bit HDR pixel format. - 'yuv444p10' 10-bit HDR pixel format. - 'yuv420p12' 12-bit HDR pixel format. - 'yuv422p12' 12-bit HDR pixel format. - 'yuv444p12' 12-bit HDR pixel format.
1146    #[serde(rename = "pixelFormat")]
1147    pub pixel_format: Option<String>,
1148    /// Enforces the specified codec preset. The default is `veryfast`. The available options are FFmpeg-compatible. Note that certain values for this field may cause the transcoder to override other fields you set in the `VideoStream` message.
1149    pub preset: Option<String>,
1150    /// Enforces the specified codec profile. The following profiles are supported: * `baseline` * `main` * `high` (default) The available options are FFmpeg-compatible. Note that certain values for this field may cause the transcoder to override other fields you set in the `VideoStream` message.
1151    pub profile: Option<String>,
1152    /// Specify the `rate_control_mode`. The default is `"vbr"`. Supported rate control modes: - 'vbr' - variable bitrate - 'crf' - constant rate factor
1153    #[serde(rename = "rateControlMode")]
1154    pub rate_control_mode: Option<String>,
1155    /// Enforces the specified codec tune. The available options are FFmpeg-compatible. Note that certain values for this field may cause the transcoder to override other fields you set in the `VideoStream` message.
1156    pub tune: Option<String>,
1157    /// Initial fullness of the Video Buffering Verifier (VBV) buffer in bits. Must be greater than zero. The default is equal to 90% of `VideoStream.vbv_size_bits`.
1158    #[serde(rename = "vbvFullnessBits")]
1159    pub vbv_fullness_bits: Option<i32>,
1160    /// Size of the Video Buffering Verifier (VBV) buffer in bits. Must be greater than zero. The default is equal to `VideoStream.bitrate_bps`.
1161    #[serde(rename = "vbvSizeBits")]
1162    pub vbv_size_bits: Option<i32>,
1163    /// The width of the video in pixels. Must be an even integer. When not specified, the width is adjusted to match the specified height and input aspect ratio. If both are omitted, the input width is used.
1164    #[serde(rename = "widthPixels")]
1165    pub width_pixels: Option<i32>,
1166}
1167
1168impl common::Part for VideoStream {}
1169
1170// ###################
1171// MethodBuilders ###
1172// #################
1173
1174/// A builder providing access to all methods supported on *project* resources.
1175/// It is not used directly, but through the [`Transcoder`] hub.
1176///
1177/// # Example
1178///
1179/// Instantiate a resource builder
1180///
1181/// ```test_harness,no_run
1182/// extern crate hyper;
1183/// extern crate hyper_rustls;
1184/// extern crate google_transcoder1_beta1 as transcoder1_beta1;
1185///
1186/// # async fn dox() {
1187/// use transcoder1_beta1::{Transcoder, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1188///
1189/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1190/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1191///     .with_native_roots()
1192///     .unwrap()
1193///     .https_only()
1194///     .enable_http2()
1195///     .build();
1196///
1197/// let executor = hyper_util::rt::TokioExecutor::new();
1198/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1199///     secret,
1200///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1201///     yup_oauth2::client::CustomHyperClientBuilder::from(
1202///         hyper_util::client::legacy::Client::builder(executor).build(connector),
1203///     ),
1204/// ).build().await.unwrap();
1205///
1206/// let client = hyper_util::client::legacy::Client::builder(
1207///     hyper_util::rt::TokioExecutor::new()
1208/// )
1209/// .build(
1210///     hyper_rustls::HttpsConnectorBuilder::new()
1211///         .with_native_roots()
1212///         .unwrap()
1213///         .https_or_http()
1214///         .enable_http2()
1215///         .build()
1216/// );
1217/// let mut hub = Transcoder::new(client, auth);
1218/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1219/// // like `locations_job_templates_create(...)`, `locations_job_templates_delete(...)`, `locations_job_templates_get(...)`, `locations_job_templates_list(...)`, `locations_jobs_create(...)`, `locations_jobs_delete(...)`, `locations_jobs_get(...)` and `locations_jobs_list(...)`
1220/// // to build up your call.
1221/// let rb = hub.projects();
1222/// # }
1223/// ```
1224pub struct ProjectMethods<'a, C>
1225where
1226    C: 'a,
1227{
1228    hub: &'a Transcoder<C>,
1229}
1230
1231impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
1232
1233impl<'a, C> ProjectMethods<'a, C> {
1234    /// Create a builder to help you perform the following task:
1235    ///
1236    /// Creates a job template in the specified region.
1237    ///
1238    /// # Arguments
1239    ///
1240    /// * `request` - No description provided.
1241    /// * `parent` - Required. The parent location to create this job template. Format: `projects/{project}/locations/{location}`
1242    pub fn locations_job_templates_create(
1243        &self,
1244        request: JobTemplate,
1245        parent: &str,
1246    ) -> ProjectLocationJobTemplateCreateCall<'a, C> {
1247        ProjectLocationJobTemplateCreateCall {
1248            hub: self.hub,
1249            _request: request,
1250            _parent: parent.to_string(),
1251            _job_template_id: Default::default(),
1252            _delegate: Default::default(),
1253            _additional_params: Default::default(),
1254            _scopes: Default::default(),
1255        }
1256    }
1257
1258    /// Create a builder to help you perform the following task:
1259    ///
1260    /// Deletes a job template.
1261    ///
1262    /// # Arguments
1263    ///
1264    /// * `name` - Required. The name of the job template to delete. `projects/{project}/locations/{location}/jobTemplates/{job_template}`
1265    pub fn locations_job_templates_delete(
1266        &self,
1267        name: &str,
1268    ) -> ProjectLocationJobTemplateDeleteCall<'a, C> {
1269        ProjectLocationJobTemplateDeleteCall {
1270            hub: self.hub,
1271            _name: name.to_string(),
1272            _delegate: Default::default(),
1273            _additional_params: Default::default(),
1274            _scopes: Default::default(),
1275        }
1276    }
1277
1278    /// Create a builder to help you perform the following task:
1279    ///
1280    /// Returns the job template data.
1281    ///
1282    /// # Arguments
1283    ///
1284    /// * `name` - Required. The name of the job template to retrieve. Format: `projects/{project}/locations/{location}/jobTemplates/{job_template}`
1285    pub fn locations_job_templates_get(
1286        &self,
1287        name: &str,
1288    ) -> ProjectLocationJobTemplateGetCall<'a, C> {
1289        ProjectLocationJobTemplateGetCall {
1290            hub: self.hub,
1291            _name: name.to_string(),
1292            _delegate: Default::default(),
1293            _additional_params: Default::default(),
1294            _scopes: Default::default(),
1295        }
1296    }
1297
1298    /// Create a builder to help you perform the following task:
1299    ///
1300    /// Lists job templates in the specified region.
1301    ///
1302    /// # Arguments
1303    ///
1304    /// * `parent` - Required. The parent location from which to retrieve the collection of job templates. Format: `projects/{project}/locations/{location}`
1305    pub fn locations_job_templates_list(
1306        &self,
1307        parent: &str,
1308    ) -> ProjectLocationJobTemplateListCall<'a, C> {
1309        ProjectLocationJobTemplateListCall {
1310            hub: self.hub,
1311            _parent: parent.to_string(),
1312            _page_token: Default::default(),
1313            _page_size: Default::default(),
1314            _delegate: Default::default(),
1315            _additional_params: Default::default(),
1316            _scopes: Default::default(),
1317        }
1318    }
1319
1320    /// Create a builder to help you perform the following task:
1321    ///
1322    /// Creates a job in the specified region.
1323    ///
1324    /// # Arguments
1325    ///
1326    /// * `request` - No description provided.
1327    /// * `parent` - Required. The parent location to create and process this job. Format: `projects/{project}/locations/{location}`
1328    pub fn locations_jobs_create(
1329        &self,
1330        request: Job,
1331        parent: &str,
1332    ) -> ProjectLocationJobCreateCall<'a, C> {
1333        ProjectLocationJobCreateCall {
1334            hub: self.hub,
1335            _request: request,
1336            _parent: parent.to_string(),
1337            _delegate: Default::default(),
1338            _additional_params: Default::default(),
1339            _scopes: Default::default(),
1340        }
1341    }
1342
1343    /// Create a builder to help you perform the following task:
1344    ///
1345    /// Deletes a job.
1346    ///
1347    /// # Arguments
1348    ///
1349    /// * `name` - Required. The name of the job to delete. Format: `projects/{project}/locations/{location}/jobs/{job}`
1350    pub fn locations_jobs_delete(&self, name: &str) -> ProjectLocationJobDeleteCall<'a, C> {
1351        ProjectLocationJobDeleteCall {
1352            hub: self.hub,
1353            _name: name.to_string(),
1354            _delegate: Default::default(),
1355            _additional_params: Default::default(),
1356            _scopes: Default::default(),
1357        }
1358    }
1359
1360    /// Create a builder to help you perform the following task:
1361    ///
1362    /// Returns the job data.
1363    ///
1364    /// # Arguments
1365    ///
1366    /// * `name` - Required. The name of the job to retrieve. Format: `projects/{project}/locations/{location}/jobs/{job}`
1367    pub fn locations_jobs_get(&self, name: &str) -> ProjectLocationJobGetCall<'a, C> {
1368        ProjectLocationJobGetCall {
1369            hub: self.hub,
1370            _name: name.to_string(),
1371            _delegate: Default::default(),
1372            _additional_params: Default::default(),
1373            _scopes: Default::default(),
1374        }
1375    }
1376
1377    /// Create a builder to help you perform the following task:
1378    ///
1379    /// Lists jobs in the specified region.
1380    ///
1381    /// # Arguments
1382    ///
1383    /// * `parent` - Required. Format: `projects/{project}/locations/{location}`
1384    pub fn locations_jobs_list(&self, parent: &str) -> ProjectLocationJobListCall<'a, C> {
1385        ProjectLocationJobListCall {
1386            hub: self.hub,
1387            _parent: parent.to_string(),
1388            _page_token: Default::default(),
1389            _page_size: Default::default(),
1390            _delegate: Default::default(),
1391            _additional_params: Default::default(),
1392            _scopes: Default::default(),
1393        }
1394    }
1395}
1396
1397// ###################
1398// CallBuilders   ###
1399// #################
1400
1401/// Creates a job template in the specified region.
1402///
1403/// A builder for the *locations.jobTemplates.create* method supported by a *project* resource.
1404/// It is not used directly, but through a [`ProjectMethods`] instance.
1405///
1406/// # Example
1407///
1408/// Instantiate a resource method builder
1409///
1410/// ```test_harness,no_run
1411/// # extern crate hyper;
1412/// # extern crate hyper_rustls;
1413/// # extern crate google_transcoder1_beta1 as transcoder1_beta1;
1414/// use transcoder1_beta1::api::JobTemplate;
1415/// # async fn dox() {
1416/// # use transcoder1_beta1::{Transcoder, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1417///
1418/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1419/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1420/// #     .with_native_roots()
1421/// #     .unwrap()
1422/// #     .https_only()
1423/// #     .enable_http2()
1424/// #     .build();
1425///
1426/// # let executor = hyper_util::rt::TokioExecutor::new();
1427/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1428/// #     secret,
1429/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1430/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1431/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1432/// #     ),
1433/// # ).build().await.unwrap();
1434///
1435/// # let client = hyper_util::client::legacy::Client::builder(
1436/// #     hyper_util::rt::TokioExecutor::new()
1437/// # )
1438/// # .build(
1439/// #     hyper_rustls::HttpsConnectorBuilder::new()
1440/// #         .with_native_roots()
1441/// #         .unwrap()
1442/// #         .https_or_http()
1443/// #         .enable_http2()
1444/// #         .build()
1445/// # );
1446/// # let mut hub = Transcoder::new(client, auth);
1447/// // As the method needs a request, you would usually fill it with the desired information
1448/// // into the respective structure. Some of the parts shown here might not be applicable !
1449/// // Values shown here are possibly random and not representative !
1450/// let mut req = JobTemplate::default();
1451///
1452/// // You can configure optional parameters by calling the respective setters at will, and
1453/// // execute the final call using `doit()`.
1454/// // Values shown here are possibly random and not representative !
1455/// let result = hub.projects().locations_job_templates_create(req, "parent")
1456///              .job_template_id("voluptua.")
1457///              .doit().await;
1458/// # }
1459/// ```
1460pub struct ProjectLocationJobTemplateCreateCall<'a, C>
1461where
1462    C: 'a,
1463{
1464    hub: &'a Transcoder<C>,
1465    _request: JobTemplate,
1466    _parent: String,
1467    _job_template_id: Option<String>,
1468    _delegate: Option<&'a mut dyn common::Delegate>,
1469    _additional_params: HashMap<String, String>,
1470    _scopes: BTreeSet<String>,
1471}
1472
1473impl<'a, C> common::CallBuilder for ProjectLocationJobTemplateCreateCall<'a, C> {}
1474
1475impl<'a, C> ProjectLocationJobTemplateCreateCall<'a, C>
1476where
1477    C: common::Connector,
1478{
1479    /// Perform the operation you have build so far.
1480    pub async fn doit(mut self) -> common::Result<(common::Response, JobTemplate)> {
1481        use std::borrow::Cow;
1482        use std::io::{Read, Seek};
1483
1484        use common::{url::Params, ToParts};
1485        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1486
1487        let mut dd = common::DefaultDelegate;
1488        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1489        dlg.begin(common::MethodInfo {
1490            id: "transcoder.projects.locations.jobTemplates.create",
1491            http_method: hyper::Method::POST,
1492        });
1493
1494        for &field in ["alt", "parent", "jobTemplateId"].iter() {
1495            if self._additional_params.contains_key(field) {
1496                dlg.finished(false);
1497                return Err(common::Error::FieldClash(field));
1498            }
1499        }
1500
1501        let mut params = Params::with_capacity(5 + self._additional_params.len());
1502        params.push("parent", self._parent);
1503        if let Some(value) = self._job_template_id.as_ref() {
1504            params.push("jobTemplateId", value);
1505        }
1506
1507        params.extend(self._additional_params.iter());
1508
1509        params.push("alt", "json");
1510        let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/jobTemplates";
1511        if self._scopes.is_empty() {
1512            self._scopes
1513                .insert(Scope::CloudPlatform.as_ref().to_string());
1514        }
1515
1516        #[allow(clippy::single_element_loop)]
1517        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
1518            url = params.uri_replacement(url, param_name, find_this, true);
1519        }
1520        {
1521            let to_remove = ["parent"];
1522            params.remove_params(&to_remove);
1523        }
1524
1525        let url = params.parse_with_url(&url);
1526
1527        let mut json_mime_type = mime::APPLICATION_JSON;
1528        let mut request_value_reader = {
1529            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1530            common::remove_json_null_values(&mut value);
1531            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1532            serde_json::to_writer(&mut dst, &value).unwrap();
1533            dst
1534        };
1535        let request_size = request_value_reader
1536            .seek(std::io::SeekFrom::End(0))
1537            .unwrap();
1538        request_value_reader
1539            .seek(std::io::SeekFrom::Start(0))
1540            .unwrap();
1541
1542        loop {
1543            let token = match self
1544                .hub
1545                .auth
1546                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1547                .await
1548            {
1549                Ok(token) => token,
1550                Err(e) => match dlg.token(e) {
1551                    Ok(token) => token,
1552                    Err(e) => {
1553                        dlg.finished(false);
1554                        return Err(common::Error::MissingToken(e));
1555                    }
1556                },
1557            };
1558            request_value_reader
1559                .seek(std::io::SeekFrom::Start(0))
1560                .unwrap();
1561            let mut req_result = {
1562                let client = &self.hub.client;
1563                dlg.pre_request();
1564                let mut req_builder = hyper::Request::builder()
1565                    .method(hyper::Method::POST)
1566                    .uri(url.as_str())
1567                    .header(USER_AGENT, self.hub._user_agent.clone());
1568
1569                if let Some(token) = token.as_ref() {
1570                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1571                }
1572
1573                let request = req_builder
1574                    .header(CONTENT_TYPE, json_mime_type.to_string())
1575                    .header(CONTENT_LENGTH, request_size as u64)
1576                    .body(common::to_body(
1577                        request_value_reader.get_ref().clone().into(),
1578                    ));
1579
1580                client.request(request.unwrap()).await
1581            };
1582
1583            match req_result {
1584                Err(err) => {
1585                    if let common::Retry::After(d) = dlg.http_error(&err) {
1586                        sleep(d).await;
1587                        continue;
1588                    }
1589                    dlg.finished(false);
1590                    return Err(common::Error::HttpError(err));
1591                }
1592                Ok(res) => {
1593                    let (mut parts, body) = res.into_parts();
1594                    let mut body = common::Body::new(body);
1595                    if !parts.status.is_success() {
1596                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1597                        let error = serde_json::from_str(&common::to_string(&bytes));
1598                        let response = common::to_response(parts, bytes.into());
1599
1600                        if let common::Retry::After(d) =
1601                            dlg.http_failure(&response, error.as_ref().ok())
1602                        {
1603                            sleep(d).await;
1604                            continue;
1605                        }
1606
1607                        dlg.finished(false);
1608
1609                        return Err(match error {
1610                            Ok(value) => common::Error::BadRequest(value),
1611                            _ => common::Error::Failure(response),
1612                        });
1613                    }
1614                    let response = {
1615                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1616                        let encoded = common::to_string(&bytes);
1617                        match serde_json::from_str(&encoded) {
1618                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1619                            Err(error) => {
1620                                dlg.response_json_decode_error(&encoded, &error);
1621                                return Err(common::Error::JsonDecodeError(
1622                                    encoded.to_string(),
1623                                    error,
1624                                ));
1625                            }
1626                        }
1627                    };
1628
1629                    dlg.finished(true);
1630                    return Ok(response);
1631                }
1632            }
1633        }
1634    }
1635
1636    ///
1637    /// Sets the *request* property to the given value.
1638    ///
1639    /// Even though the property as already been set when instantiating this call,
1640    /// we provide this method for API completeness.
1641    pub fn request(
1642        mut self,
1643        new_value: JobTemplate,
1644    ) -> ProjectLocationJobTemplateCreateCall<'a, C> {
1645        self._request = new_value;
1646        self
1647    }
1648    /// Required. The parent location to create this job template. Format: `projects/{project}/locations/{location}`
1649    ///
1650    /// Sets the *parent* path property to the given value.
1651    ///
1652    /// Even though the property as already been set when instantiating this call,
1653    /// we provide this method for API completeness.
1654    pub fn parent(mut self, new_value: &str) -> ProjectLocationJobTemplateCreateCall<'a, C> {
1655        self._parent = new_value.to_string();
1656        self
1657    }
1658    /// Required. The ID to use for the job template, which will become the final component of the job template's resource name. This value should be 4-63 characters, and valid characters must match the regular expression `a-zA-Z*`.
1659    ///
1660    /// Sets the *job template id* query property to the given value.
1661    pub fn job_template_id(
1662        mut self,
1663        new_value: &str,
1664    ) -> ProjectLocationJobTemplateCreateCall<'a, C> {
1665        self._job_template_id = Some(new_value.to_string());
1666        self
1667    }
1668    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1669    /// while executing the actual API request.
1670    ///
1671    /// ````text
1672    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1673    /// ````
1674    ///
1675    /// Sets the *delegate* property to the given value.
1676    pub fn delegate(
1677        mut self,
1678        new_value: &'a mut dyn common::Delegate,
1679    ) -> ProjectLocationJobTemplateCreateCall<'a, C> {
1680        self._delegate = Some(new_value);
1681        self
1682    }
1683
1684    /// Set any additional parameter of the query string used in the request.
1685    /// It should be used to set parameters which are not yet available through their own
1686    /// setters.
1687    ///
1688    /// Please note that this method must not be used to set any of the known parameters
1689    /// which have their own setter method. If done anyway, the request will fail.
1690    ///
1691    /// # Additional Parameters
1692    ///
1693    /// * *$.xgafv* (query-string) - V1 error format.
1694    /// * *access_token* (query-string) - OAuth access token.
1695    /// * *alt* (query-string) - Data format for response.
1696    /// * *callback* (query-string) - JSONP
1697    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1698    /// * *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.
1699    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1700    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1701    /// * *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.
1702    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1703    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1704    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationJobTemplateCreateCall<'a, C>
1705    where
1706        T: AsRef<str>,
1707    {
1708        self._additional_params
1709            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1710        self
1711    }
1712
1713    /// Identifies the authorization scope for the method you are building.
1714    ///
1715    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1716    /// [`Scope::CloudPlatform`].
1717    ///
1718    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1719    /// tokens for more than one scope.
1720    ///
1721    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1722    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1723    /// sufficient, a read-write scope will do as well.
1724    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationJobTemplateCreateCall<'a, C>
1725    where
1726        St: AsRef<str>,
1727    {
1728        self._scopes.insert(String::from(scope.as_ref()));
1729        self
1730    }
1731    /// Identifies the authorization scope(s) for the method you are building.
1732    ///
1733    /// See [`Self::add_scope()`] for details.
1734    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationJobTemplateCreateCall<'a, C>
1735    where
1736        I: IntoIterator<Item = St>,
1737        St: AsRef<str>,
1738    {
1739        self._scopes
1740            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1741        self
1742    }
1743
1744    /// Removes all scopes, and no default scope will be used either.
1745    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1746    /// for details).
1747    pub fn clear_scopes(mut self) -> ProjectLocationJobTemplateCreateCall<'a, C> {
1748        self._scopes.clear();
1749        self
1750    }
1751}
1752
1753/// Deletes a job template.
1754///
1755/// A builder for the *locations.jobTemplates.delete* method supported by a *project* resource.
1756/// It is not used directly, but through a [`ProjectMethods`] instance.
1757///
1758/// # Example
1759///
1760/// Instantiate a resource method builder
1761///
1762/// ```test_harness,no_run
1763/// # extern crate hyper;
1764/// # extern crate hyper_rustls;
1765/// # extern crate google_transcoder1_beta1 as transcoder1_beta1;
1766/// # async fn dox() {
1767/// # use transcoder1_beta1::{Transcoder, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1768///
1769/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1770/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1771/// #     .with_native_roots()
1772/// #     .unwrap()
1773/// #     .https_only()
1774/// #     .enable_http2()
1775/// #     .build();
1776///
1777/// # let executor = hyper_util::rt::TokioExecutor::new();
1778/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1779/// #     secret,
1780/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1781/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1782/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1783/// #     ),
1784/// # ).build().await.unwrap();
1785///
1786/// # let client = hyper_util::client::legacy::Client::builder(
1787/// #     hyper_util::rt::TokioExecutor::new()
1788/// # )
1789/// # .build(
1790/// #     hyper_rustls::HttpsConnectorBuilder::new()
1791/// #         .with_native_roots()
1792/// #         .unwrap()
1793/// #         .https_or_http()
1794/// #         .enable_http2()
1795/// #         .build()
1796/// # );
1797/// # let mut hub = Transcoder::new(client, auth);
1798/// // You can configure optional parameters by calling the respective setters at will, and
1799/// // execute the final call using `doit()`.
1800/// // Values shown here are possibly random and not representative !
1801/// let result = hub.projects().locations_job_templates_delete("name")
1802///              .doit().await;
1803/// # }
1804/// ```
1805pub struct ProjectLocationJobTemplateDeleteCall<'a, C>
1806where
1807    C: 'a,
1808{
1809    hub: &'a Transcoder<C>,
1810    _name: String,
1811    _delegate: Option<&'a mut dyn common::Delegate>,
1812    _additional_params: HashMap<String, String>,
1813    _scopes: BTreeSet<String>,
1814}
1815
1816impl<'a, C> common::CallBuilder for ProjectLocationJobTemplateDeleteCall<'a, C> {}
1817
1818impl<'a, C> ProjectLocationJobTemplateDeleteCall<'a, C>
1819where
1820    C: common::Connector,
1821{
1822    /// Perform the operation you have build so far.
1823    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
1824        use std::borrow::Cow;
1825        use std::io::{Read, Seek};
1826
1827        use common::{url::Params, ToParts};
1828        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1829
1830        let mut dd = common::DefaultDelegate;
1831        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1832        dlg.begin(common::MethodInfo {
1833            id: "transcoder.projects.locations.jobTemplates.delete",
1834            http_method: hyper::Method::DELETE,
1835        });
1836
1837        for &field in ["alt", "name"].iter() {
1838            if self._additional_params.contains_key(field) {
1839                dlg.finished(false);
1840                return Err(common::Error::FieldClash(field));
1841            }
1842        }
1843
1844        let mut params = Params::with_capacity(3 + self._additional_params.len());
1845        params.push("name", self._name);
1846
1847        params.extend(self._additional_params.iter());
1848
1849        params.push("alt", "json");
1850        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
1851        if self._scopes.is_empty() {
1852            self._scopes
1853                .insert(Scope::CloudPlatform.as_ref().to_string());
1854        }
1855
1856        #[allow(clippy::single_element_loop)]
1857        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1858            url = params.uri_replacement(url, param_name, find_this, true);
1859        }
1860        {
1861            let to_remove = ["name"];
1862            params.remove_params(&to_remove);
1863        }
1864
1865        let url = params.parse_with_url(&url);
1866
1867        loop {
1868            let token = match self
1869                .hub
1870                .auth
1871                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1872                .await
1873            {
1874                Ok(token) => token,
1875                Err(e) => match dlg.token(e) {
1876                    Ok(token) => token,
1877                    Err(e) => {
1878                        dlg.finished(false);
1879                        return Err(common::Error::MissingToken(e));
1880                    }
1881                },
1882            };
1883            let mut req_result = {
1884                let client = &self.hub.client;
1885                dlg.pre_request();
1886                let mut req_builder = hyper::Request::builder()
1887                    .method(hyper::Method::DELETE)
1888                    .uri(url.as_str())
1889                    .header(USER_AGENT, self.hub._user_agent.clone());
1890
1891                if let Some(token) = token.as_ref() {
1892                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1893                }
1894
1895                let request = req_builder
1896                    .header(CONTENT_LENGTH, 0_u64)
1897                    .body(common::to_body::<String>(None));
1898
1899                client.request(request.unwrap()).await
1900            };
1901
1902            match req_result {
1903                Err(err) => {
1904                    if let common::Retry::After(d) = dlg.http_error(&err) {
1905                        sleep(d).await;
1906                        continue;
1907                    }
1908                    dlg.finished(false);
1909                    return Err(common::Error::HttpError(err));
1910                }
1911                Ok(res) => {
1912                    let (mut parts, body) = res.into_parts();
1913                    let mut body = common::Body::new(body);
1914                    if !parts.status.is_success() {
1915                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1916                        let error = serde_json::from_str(&common::to_string(&bytes));
1917                        let response = common::to_response(parts, bytes.into());
1918
1919                        if let common::Retry::After(d) =
1920                            dlg.http_failure(&response, error.as_ref().ok())
1921                        {
1922                            sleep(d).await;
1923                            continue;
1924                        }
1925
1926                        dlg.finished(false);
1927
1928                        return Err(match error {
1929                            Ok(value) => common::Error::BadRequest(value),
1930                            _ => common::Error::Failure(response),
1931                        });
1932                    }
1933                    let response = {
1934                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1935                        let encoded = common::to_string(&bytes);
1936                        match serde_json::from_str(&encoded) {
1937                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1938                            Err(error) => {
1939                                dlg.response_json_decode_error(&encoded, &error);
1940                                return Err(common::Error::JsonDecodeError(
1941                                    encoded.to_string(),
1942                                    error,
1943                                ));
1944                            }
1945                        }
1946                    };
1947
1948                    dlg.finished(true);
1949                    return Ok(response);
1950                }
1951            }
1952        }
1953    }
1954
1955    /// Required. The name of the job template to delete. `projects/{project}/locations/{location}/jobTemplates/{job_template}`
1956    ///
1957    /// Sets the *name* path property to the given value.
1958    ///
1959    /// Even though the property as already been set when instantiating this call,
1960    /// we provide this method for API completeness.
1961    pub fn name(mut self, new_value: &str) -> ProjectLocationJobTemplateDeleteCall<'a, C> {
1962        self._name = new_value.to_string();
1963        self
1964    }
1965    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1966    /// while executing the actual API request.
1967    ///
1968    /// ````text
1969    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1970    /// ````
1971    ///
1972    /// Sets the *delegate* property to the given value.
1973    pub fn delegate(
1974        mut self,
1975        new_value: &'a mut dyn common::Delegate,
1976    ) -> ProjectLocationJobTemplateDeleteCall<'a, C> {
1977        self._delegate = Some(new_value);
1978        self
1979    }
1980
1981    /// Set any additional parameter of the query string used in the request.
1982    /// It should be used to set parameters which are not yet available through their own
1983    /// setters.
1984    ///
1985    /// Please note that this method must not be used to set any of the known parameters
1986    /// which have their own setter method. If done anyway, the request will fail.
1987    ///
1988    /// # Additional Parameters
1989    ///
1990    /// * *$.xgafv* (query-string) - V1 error format.
1991    /// * *access_token* (query-string) - OAuth access token.
1992    /// * *alt* (query-string) - Data format for response.
1993    /// * *callback* (query-string) - JSONP
1994    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1995    /// * *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.
1996    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1997    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1998    /// * *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.
1999    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2000    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2001    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationJobTemplateDeleteCall<'a, C>
2002    where
2003        T: AsRef<str>,
2004    {
2005        self._additional_params
2006            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2007        self
2008    }
2009
2010    /// Identifies the authorization scope for the method you are building.
2011    ///
2012    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2013    /// [`Scope::CloudPlatform`].
2014    ///
2015    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2016    /// tokens for more than one scope.
2017    ///
2018    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2019    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2020    /// sufficient, a read-write scope will do as well.
2021    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationJobTemplateDeleteCall<'a, C>
2022    where
2023        St: AsRef<str>,
2024    {
2025        self._scopes.insert(String::from(scope.as_ref()));
2026        self
2027    }
2028    /// Identifies the authorization scope(s) for the method you are building.
2029    ///
2030    /// See [`Self::add_scope()`] for details.
2031    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationJobTemplateDeleteCall<'a, C>
2032    where
2033        I: IntoIterator<Item = St>,
2034        St: AsRef<str>,
2035    {
2036        self._scopes
2037            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2038        self
2039    }
2040
2041    /// Removes all scopes, and no default scope will be used either.
2042    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2043    /// for details).
2044    pub fn clear_scopes(mut self) -> ProjectLocationJobTemplateDeleteCall<'a, C> {
2045        self._scopes.clear();
2046        self
2047    }
2048}
2049
2050/// Returns the job template data.
2051///
2052/// A builder for the *locations.jobTemplates.get* method supported by a *project* resource.
2053/// It is not used directly, but through a [`ProjectMethods`] instance.
2054///
2055/// # Example
2056///
2057/// Instantiate a resource method builder
2058///
2059/// ```test_harness,no_run
2060/// # extern crate hyper;
2061/// # extern crate hyper_rustls;
2062/// # extern crate google_transcoder1_beta1 as transcoder1_beta1;
2063/// # async fn dox() {
2064/// # use transcoder1_beta1::{Transcoder, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2065///
2066/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2067/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2068/// #     .with_native_roots()
2069/// #     .unwrap()
2070/// #     .https_only()
2071/// #     .enable_http2()
2072/// #     .build();
2073///
2074/// # let executor = hyper_util::rt::TokioExecutor::new();
2075/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2076/// #     secret,
2077/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2078/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2079/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2080/// #     ),
2081/// # ).build().await.unwrap();
2082///
2083/// # let client = hyper_util::client::legacy::Client::builder(
2084/// #     hyper_util::rt::TokioExecutor::new()
2085/// # )
2086/// # .build(
2087/// #     hyper_rustls::HttpsConnectorBuilder::new()
2088/// #         .with_native_roots()
2089/// #         .unwrap()
2090/// #         .https_or_http()
2091/// #         .enable_http2()
2092/// #         .build()
2093/// # );
2094/// # let mut hub = Transcoder::new(client, auth);
2095/// // You can configure optional parameters by calling the respective setters at will, and
2096/// // execute the final call using `doit()`.
2097/// // Values shown here are possibly random and not representative !
2098/// let result = hub.projects().locations_job_templates_get("name")
2099///              .doit().await;
2100/// # }
2101/// ```
2102pub struct ProjectLocationJobTemplateGetCall<'a, C>
2103where
2104    C: 'a,
2105{
2106    hub: &'a Transcoder<C>,
2107    _name: String,
2108    _delegate: Option<&'a mut dyn common::Delegate>,
2109    _additional_params: HashMap<String, String>,
2110    _scopes: BTreeSet<String>,
2111}
2112
2113impl<'a, C> common::CallBuilder for ProjectLocationJobTemplateGetCall<'a, C> {}
2114
2115impl<'a, C> ProjectLocationJobTemplateGetCall<'a, C>
2116where
2117    C: common::Connector,
2118{
2119    /// Perform the operation you have build so far.
2120    pub async fn doit(mut self) -> common::Result<(common::Response, JobTemplate)> {
2121        use std::borrow::Cow;
2122        use std::io::{Read, Seek};
2123
2124        use common::{url::Params, ToParts};
2125        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2126
2127        let mut dd = common::DefaultDelegate;
2128        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2129        dlg.begin(common::MethodInfo {
2130            id: "transcoder.projects.locations.jobTemplates.get",
2131            http_method: hyper::Method::GET,
2132        });
2133
2134        for &field in ["alt", "name"].iter() {
2135            if self._additional_params.contains_key(field) {
2136                dlg.finished(false);
2137                return Err(common::Error::FieldClash(field));
2138            }
2139        }
2140
2141        let mut params = Params::with_capacity(3 + self._additional_params.len());
2142        params.push("name", self._name);
2143
2144        params.extend(self._additional_params.iter());
2145
2146        params.push("alt", "json");
2147        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
2148        if self._scopes.is_empty() {
2149            self._scopes
2150                .insert(Scope::CloudPlatform.as_ref().to_string());
2151        }
2152
2153        #[allow(clippy::single_element_loop)]
2154        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2155            url = params.uri_replacement(url, param_name, find_this, true);
2156        }
2157        {
2158            let to_remove = ["name"];
2159            params.remove_params(&to_remove);
2160        }
2161
2162        let url = params.parse_with_url(&url);
2163
2164        loop {
2165            let token = match self
2166                .hub
2167                .auth
2168                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2169                .await
2170            {
2171                Ok(token) => token,
2172                Err(e) => match dlg.token(e) {
2173                    Ok(token) => token,
2174                    Err(e) => {
2175                        dlg.finished(false);
2176                        return Err(common::Error::MissingToken(e));
2177                    }
2178                },
2179            };
2180            let mut req_result = {
2181                let client = &self.hub.client;
2182                dlg.pre_request();
2183                let mut req_builder = hyper::Request::builder()
2184                    .method(hyper::Method::GET)
2185                    .uri(url.as_str())
2186                    .header(USER_AGENT, self.hub._user_agent.clone());
2187
2188                if let Some(token) = token.as_ref() {
2189                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2190                }
2191
2192                let request = req_builder
2193                    .header(CONTENT_LENGTH, 0_u64)
2194                    .body(common::to_body::<String>(None));
2195
2196                client.request(request.unwrap()).await
2197            };
2198
2199            match req_result {
2200                Err(err) => {
2201                    if let common::Retry::After(d) = dlg.http_error(&err) {
2202                        sleep(d).await;
2203                        continue;
2204                    }
2205                    dlg.finished(false);
2206                    return Err(common::Error::HttpError(err));
2207                }
2208                Ok(res) => {
2209                    let (mut parts, body) = res.into_parts();
2210                    let mut body = common::Body::new(body);
2211                    if !parts.status.is_success() {
2212                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2213                        let error = serde_json::from_str(&common::to_string(&bytes));
2214                        let response = common::to_response(parts, bytes.into());
2215
2216                        if let common::Retry::After(d) =
2217                            dlg.http_failure(&response, error.as_ref().ok())
2218                        {
2219                            sleep(d).await;
2220                            continue;
2221                        }
2222
2223                        dlg.finished(false);
2224
2225                        return Err(match error {
2226                            Ok(value) => common::Error::BadRequest(value),
2227                            _ => common::Error::Failure(response),
2228                        });
2229                    }
2230                    let response = {
2231                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2232                        let encoded = common::to_string(&bytes);
2233                        match serde_json::from_str(&encoded) {
2234                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2235                            Err(error) => {
2236                                dlg.response_json_decode_error(&encoded, &error);
2237                                return Err(common::Error::JsonDecodeError(
2238                                    encoded.to_string(),
2239                                    error,
2240                                ));
2241                            }
2242                        }
2243                    };
2244
2245                    dlg.finished(true);
2246                    return Ok(response);
2247                }
2248            }
2249        }
2250    }
2251
2252    /// Required. The name of the job template to retrieve. Format: `projects/{project}/locations/{location}/jobTemplates/{job_template}`
2253    ///
2254    /// Sets the *name* path property to the given value.
2255    ///
2256    /// Even though the property as already been set when instantiating this call,
2257    /// we provide this method for API completeness.
2258    pub fn name(mut self, new_value: &str) -> ProjectLocationJobTemplateGetCall<'a, C> {
2259        self._name = new_value.to_string();
2260        self
2261    }
2262    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2263    /// while executing the actual API request.
2264    ///
2265    /// ````text
2266    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2267    /// ````
2268    ///
2269    /// Sets the *delegate* property to the given value.
2270    pub fn delegate(
2271        mut self,
2272        new_value: &'a mut dyn common::Delegate,
2273    ) -> ProjectLocationJobTemplateGetCall<'a, C> {
2274        self._delegate = Some(new_value);
2275        self
2276    }
2277
2278    /// Set any additional parameter of the query string used in the request.
2279    /// It should be used to set parameters which are not yet available through their own
2280    /// setters.
2281    ///
2282    /// Please note that this method must not be used to set any of the known parameters
2283    /// which have their own setter method. If done anyway, the request will fail.
2284    ///
2285    /// # Additional Parameters
2286    ///
2287    /// * *$.xgafv* (query-string) - V1 error format.
2288    /// * *access_token* (query-string) - OAuth access token.
2289    /// * *alt* (query-string) - Data format for response.
2290    /// * *callback* (query-string) - JSONP
2291    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2292    /// * *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.
2293    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2294    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2295    /// * *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.
2296    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2297    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2298    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationJobTemplateGetCall<'a, C>
2299    where
2300        T: AsRef<str>,
2301    {
2302        self._additional_params
2303            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2304        self
2305    }
2306
2307    /// Identifies the authorization scope for the method you are building.
2308    ///
2309    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2310    /// [`Scope::CloudPlatform`].
2311    ///
2312    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2313    /// tokens for more than one scope.
2314    ///
2315    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2316    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2317    /// sufficient, a read-write scope will do as well.
2318    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationJobTemplateGetCall<'a, C>
2319    where
2320        St: AsRef<str>,
2321    {
2322        self._scopes.insert(String::from(scope.as_ref()));
2323        self
2324    }
2325    /// Identifies the authorization scope(s) for the method you are building.
2326    ///
2327    /// See [`Self::add_scope()`] for details.
2328    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationJobTemplateGetCall<'a, C>
2329    where
2330        I: IntoIterator<Item = St>,
2331        St: AsRef<str>,
2332    {
2333        self._scopes
2334            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2335        self
2336    }
2337
2338    /// Removes all scopes, and no default scope will be used either.
2339    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2340    /// for details).
2341    pub fn clear_scopes(mut self) -> ProjectLocationJobTemplateGetCall<'a, C> {
2342        self._scopes.clear();
2343        self
2344    }
2345}
2346
2347/// Lists job templates in the specified region.
2348///
2349/// A builder for the *locations.jobTemplates.list* method supported by a *project* resource.
2350/// It is not used directly, but through a [`ProjectMethods`] instance.
2351///
2352/// # Example
2353///
2354/// Instantiate a resource method builder
2355///
2356/// ```test_harness,no_run
2357/// # extern crate hyper;
2358/// # extern crate hyper_rustls;
2359/// # extern crate google_transcoder1_beta1 as transcoder1_beta1;
2360/// # async fn dox() {
2361/// # use transcoder1_beta1::{Transcoder, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2362///
2363/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2364/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2365/// #     .with_native_roots()
2366/// #     .unwrap()
2367/// #     .https_only()
2368/// #     .enable_http2()
2369/// #     .build();
2370///
2371/// # let executor = hyper_util::rt::TokioExecutor::new();
2372/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2373/// #     secret,
2374/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2375/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2376/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2377/// #     ),
2378/// # ).build().await.unwrap();
2379///
2380/// # let client = hyper_util::client::legacy::Client::builder(
2381/// #     hyper_util::rt::TokioExecutor::new()
2382/// # )
2383/// # .build(
2384/// #     hyper_rustls::HttpsConnectorBuilder::new()
2385/// #         .with_native_roots()
2386/// #         .unwrap()
2387/// #         .https_or_http()
2388/// #         .enable_http2()
2389/// #         .build()
2390/// # );
2391/// # let mut hub = Transcoder::new(client, auth);
2392/// // You can configure optional parameters by calling the respective setters at will, and
2393/// // execute the final call using `doit()`.
2394/// // Values shown here are possibly random and not representative !
2395/// let result = hub.projects().locations_job_templates_list("parent")
2396///              .page_token("amet.")
2397///              .page_size(-59)
2398///              .doit().await;
2399/// # }
2400/// ```
2401pub struct ProjectLocationJobTemplateListCall<'a, C>
2402where
2403    C: 'a,
2404{
2405    hub: &'a Transcoder<C>,
2406    _parent: String,
2407    _page_token: Option<String>,
2408    _page_size: Option<i32>,
2409    _delegate: Option<&'a mut dyn common::Delegate>,
2410    _additional_params: HashMap<String, String>,
2411    _scopes: BTreeSet<String>,
2412}
2413
2414impl<'a, C> common::CallBuilder for ProjectLocationJobTemplateListCall<'a, C> {}
2415
2416impl<'a, C> ProjectLocationJobTemplateListCall<'a, C>
2417where
2418    C: common::Connector,
2419{
2420    /// Perform the operation you have build so far.
2421    pub async fn doit(mut self) -> common::Result<(common::Response, ListJobTemplatesResponse)> {
2422        use std::borrow::Cow;
2423        use std::io::{Read, Seek};
2424
2425        use common::{url::Params, ToParts};
2426        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2427
2428        let mut dd = common::DefaultDelegate;
2429        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2430        dlg.begin(common::MethodInfo {
2431            id: "transcoder.projects.locations.jobTemplates.list",
2432            http_method: hyper::Method::GET,
2433        });
2434
2435        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
2436            if self._additional_params.contains_key(field) {
2437                dlg.finished(false);
2438                return Err(common::Error::FieldClash(field));
2439            }
2440        }
2441
2442        let mut params = Params::with_capacity(5 + self._additional_params.len());
2443        params.push("parent", self._parent);
2444        if let Some(value) = self._page_token.as_ref() {
2445            params.push("pageToken", value);
2446        }
2447        if let Some(value) = self._page_size.as_ref() {
2448            params.push("pageSize", value.to_string());
2449        }
2450
2451        params.extend(self._additional_params.iter());
2452
2453        params.push("alt", "json");
2454        let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/jobTemplates";
2455        if self._scopes.is_empty() {
2456            self._scopes
2457                .insert(Scope::CloudPlatform.as_ref().to_string());
2458        }
2459
2460        #[allow(clippy::single_element_loop)]
2461        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2462            url = params.uri_replacement(url, param_name, find_this, true);
2463        }
2464        {
2465            let to_remove = ["parent"];
2466            params.remove_params(&to_remove);
2467        }
2468
2469        let url = params.parse_with_url(&url);
2470
2471        loop {
2472            let token = match self
2473                .hub
2474                .auth
2475                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2476                .await
2477            {
2478                Ok(token) => token,
2479                Err(e) => match dlg.token(e) {
2480                    Ok(token) => token,
2481                    Err(e) => {
2482                        dlg.finished(false);
2483                        return Err(common::Error::MissingToken(e));
2484                    }
2485                },
2486            };
2487            let mut req_result = {
2488                let client = &self.hub.client;
2489                dlg.pre_request();
2490                let mut req_builder = hyper::Request::builder()
2491                    .method(hyper::Method::GET)
2492                    .uri(url.as_str())
2493                    .header(USER_AGENT, self.hub._user_agent.clone());
2494
2495                if let Some(token) = token.as_ref() {
2496                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2497                }
2498
2499                let request = req_builder
2500                    .header(CONTENT_LENGTH, 0_u64)
2501                    .body(common::to_body::<String>(None));
2502
2503                client.request(request.unwrap()).await
2504            };
2505
2506            match req_result {
2507                Err(err) => {
2508                    if let common::Retry::After(d) = dlg.http_error(&err) {
2509                        sleep(d).await;
2510                        continue;
2511                    }
2512                    dlg.finished(false);
2513                    return Err(common::Error::HttpError(err));
2514                }
2515                Ok(res) => {
2516                    let (mut parts, body) = res.into_parts();
2517                    let mut body = common::Body::new(body);
2518                    if !parts.status.is_success() {
2519                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2520                        let error = serde_json::from_str(&common::to_string(&bytes));
2521                        let response = common::to_response(parts, bytes.into());
2522
2523                        if let common::Retry::After(d) =
2524                            dlg.http_failure(&response, error.as_ref().ok())
2525                        {
2526                            sleep(d).await;
2527                            continue;
2528                        }
2529
2530                        dlg.finished(false);
2531
2532                        return Err(match error {
2533                            Ok(value) => common::Error::BadRequest(value),
2534                            _ => common::Error::Failure(response),
2535                        });
2536                    }
2537                    let response = {
2538                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2539                        let encoded = common::to_string(&bytes);
2540                        match serde_json::from_str(&encoded) {
2541                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2542                            Err(error) => {
2543                                dlg.response_json_decode_error(&encoded, &error);
2544                                return Err(common::Error::JsonDecodeError(
2545                                    encoded.to_string(),
2546                                    error,
2547                                ));
2548                            }
2549                        }
2550                    };
2551
2552                    dlg.finished(true);
2553                    return Ok(response);
2554                }
2555            }
2556        }
2557    }
2558
2559    /// Required. The parent location from which to retrieve the collection of job templates. Format: `projects/{project}/locations/{location}`
2560    ///
2561    /// Sets the *parent* path property to the given value.
2562    ///
2563    /// Even though the property as already been set when instantiating this call,
2564    /// we provide this method for API completeness.
2565    pub fn parent(mut self, new_value: &str) -> ProjectLocationJobTemplateListCall<'a, C> {
2566        self._parent = new_value.to_string();
2567        self
2568    }
2569    /// The `next_page_token` value returned from a previous List request, if any.
2570    ///
2571    /// Sets the *page token* query property to the given value.
2572    pub fn page_token(mut self, new_value: &str) -> ProjectLocationJobTemplateListCall<'a, C> {
2573        self._page_token = Some(new_value.to_string());
2574        self
2575    }
2576    /// The maximum number of items to return.
2577    ///
2578    /// Sets the *page size* query property to the given value.
2579    pub fn page_size(mut self, new_value: i32) -> ProjectLocationJobTemplateListCall<'a, C> {
2580        self._page_size = Some(new_value);
2581        self
2582    }
2583    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2584    /// while executing the actual API request.
2585    ///
2586    /// ````text
2587    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2588    /// ````
2589    ///
2590    /// Sets the *delegate* property to the given value.
2591    pub fn delegate(
2592        mut self,
2593        new_value: &'a mut dyn common::Delegate,
2594    ) -> ProjectLocationJobTemplateListCall<'a, C> {
2595        self._delegate = Some(new_value);
2596        self
2597    }
2598
2599    /// Set any additional parameter of the query string used in the request.
2600    /// It should be used to set parameters which are not yet available through their own
2601    /// setters.
2602    ///
2603    /// Please note that this method must not be used to set any of the known parameters
2604    /// which have their own setter method. If done anyway, the request will fail.
2605    ///
2606    /// # Additional Parameters
2607    ///
2608    /// * *$.xgafv* (query-string) - V1 error format.
2609    /// * *access_token* (query-string) - OAuth access token.
2610    /// * *alt* (query-string) - Data format for response.
2611    /// * *callback* (query-string) - JSONP
2612    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2613    /// * *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.
2614    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2615    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2616    /// * *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.
2617    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2618    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2619    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationJobTemplateListCall<'a, C>
2620    where
2621        T: AsRef<str>,
2622    {
2623        self._additional_params
2624            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2625        self
2626    }
2627
2628    /// Identifies the authorization scope for the method you are building.
2629    ///
2630    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2631    /// [`Scope::CloudPlatform`].
2632    ///
2633    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2634    /// tokens for more than one scope.
2635    ///
2636    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2637    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2638    /// sufficient, a read-write scope will do as well.
2639    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationJobTemplateListCall<'a, C>
2640    where
2641        St: AsRef<str>,
2642    {
2643        self._scopes.insert(String::from(scope.as_ref()));
2644        self
2645    }
2646    /// Identifies the authorization scope(s) for the method you are building.
2647    ///
2648    /// See [`Self::add_scope()`] for details.
2649    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationJobTemplateListCall<'a, C>
2650    where
2651        I: IntoIterator<Item = St>,
2652        St: AsRef<str>,
2653    {
2654        self._scopes
2655            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2656        self
2657    }
2658
2659    /// Removes all scopes, and no default scope will be used either.
2660    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2661    /// for details).
2662    pub fn clear_scopes(mut self) -> ProjectLocationJobTemplateListCall<'a, C> {
2663        self._scopes.clear();
2664        self
2665    }
2666}
2667
2668/// Creates a job in the specified region.
2669///
2670/// A builder for the *locations.jobs.create* method supported by a *project* resource.
2671/// It is not used directly, but through a [`ProjectMethods`] instance.
2672///
2673/// # Example
2674///
2675/// Instantiate a resource method builder
2676///
2677/// ```test_harness,no_run
2678/// # extern crate hyper;
2679/// # extern crate hyper_rustls;
2680/// # extern crate google_transcoder1_beta1 as transcoder1_beta1;
2681/// use transcoder1_beta1::api::Job;
2682/// # async fn dox() {
2683/// # use transcoder1_beta1::{Transcoder, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2684///
2685/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2686/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2687/// #     .with_native_roots()
2688/// #     .unwrap()
2689/// #     .https_only()
2690/// #     .enable_http2()
2691/// #     .build();
2692///
2693/// # let executor = hyper_util::rt::TokioExecutor::new();
2694/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2695/// #     secret,
2696/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2697/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2698/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2699/// #     ),
2700/// # ).build().await.unwrap();
2701///
2702/// # let client = hyper_util::client::legacy::Client::builder(
2703/// #     hyper_util::rt::TokioExecutor::new()
2704/// # )
2705/// # .build(
2706/// #     hyper_rustls::HttpsConnectorBuilder::new()
2707/// #         .with_native_roots()
2708/// #         .unwrap()
2709/// #         .https_or_http()
2710/// #         .enable_http2()
2711/// #         .build()
2712/// # );
2713/// # let mut hub = Transcoder::new(client, auth);
2714/// // As the method needs a request, you would usually fill it with the desired information
2715/// // into the respective structure. Some of the parts shown here might not be applicable !
2716/// // Values shown here are possibly random and not representative !
2717/// let mut req = Job::default();
2718///
2719/// // You can configure optional parameters by calling the respective setters at will, and
2720/// // execute the final call using `doit()`.
2721/// // Values shown here are possibly random and not representative !
2722/// let result = hub.projects().locations_jobs_create(req, "parent")
2723///              .doit().await;
2724/// # }
2725/// ```
2726pub struct ProjectLocationJobCreateCall<'a, C>
2727where
2728    C: 'a,
2729{
2730    hub: &'a Transcoder<C>,
2731    _request: Job,
2732    _parent: String,
2733    _delegate: Option<&'a mut dyn common::Delegate>,
2734    _additional_params: HashMap<String, String>,
2735    _scopes: BTreeSet<String>,
2736}
2737
2738impl<'a, C> common::CallBuilder for ProjectLocationJobCreateCall<'a, C> {}
2739
2740impl<'a, C> ProjectLocationJobCreateCall<'a, C>
2741where
2742    C: common::Connector,
2743{
2744    /// Perform the operation you have build so far.
2745    pub async fn doit(mut self) -> common::Result<(common::Response, Job)> {
2746        use std::borrow::Cow;
2747        use std::io::{Read, Seek};
2748
2749        use common::{url::Params, ToParts};
2750        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2751
2752        let mut dd = common::DefaultDelegate;
2753        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2754        dlg.begin(common::MethodInfo {
2755            id: "transcoder.projects.locations.jobs.create",
2756            http_method: hyper::Method::POST,
2757        });
2758
2759        for &field in ["alt", "parent"].iter() {
2760            if self._additional_params.contains_key(field) {
2761                dlg.finished(false);
2762                return Err(common::Error::FieldClash(field));
2763            }
2764        }
2765
2766        let mut params = Params::with_capacity(4 + self._additional_params.len());
2767        params.push("parent", self._parent);
2768
2769        params.extend(self._additional_params.iter());
2770
2771        params.push("alt", "json");
2772        let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/jobs";
2773        if self._scopes.is_empty() {
2774            self._scopes
2775                .insert(Scope::CloudPlatform.as_ref().to_string());
2776        }
2777
2778        #[allow(clippy::single_element_loop)]
2779        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2780            url = params.uri_replacement(url, param_name, find_this, true);
2781        }
2782        {
2783            let to_remove = ["parent"];
2784            params.remove_params(&to_remove);
2785        }
2786
2787        let url = params.parse_with_url(&url);
2788
2789        let mut json_mime_type = mime::APPLICATION_JSON;
2790        let mut request_value_reader = {
2791            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2792            common::remove_json_null_values(&mut value);
2793            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2794            serde_json::to_writer(&mut dst, &value).unwrap();
2795            dst
2796        };
2797        let request_size = request_value_reader
2798            .seek(std::io::SeekFrom::End(0))
2799            .unwrap();
2800        request_value_reader
2801            .seek(std::io::SeekFrom::Start(0))
2802            .unwrap();
2803
2804        loop {
2805            let token = match self
2806                .hub
2807                .auth
2808                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2809                .await
2810            {
2811                Ok(token) => token,
2812                Err(e) => match dlg.token(e) {
2813                    Ok(token) => token,
2814                    Err(e) => {
2815                        dlg.finished(false);
2816                        return Err(common::Error::MissingToken(e));
2817                    }
2818                },
2819            };
2820            request_value_reader
2821                .seek(std::io::SeekFrom::Start(0))
2822                .unwrap();
2823            let mut req_result = {
2824                let client = &self.hub.client;
2825                dlg.pre_request();
2826                let mut req_builder = hyper::Request::builder()
2827                    .method(hyper::Method::POST)
2828                    .uri(url.as_str())
2829                    .header(USER_AGENT, self.hub._user_agent.clone());
2830
2831                if let Some(token) = token.as_ref() {
2832                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2833                }
2834
2835                let request = req_builder
2836                    .header(CONTENT_TYPE, json_mime_type.to_string())
2837                    .header(CONTENT_LENGTH, request_size as u64)
2838                    .body(common::to_body(
2839                        request_value_reader.get_ref().clone().into(),
2840                    ));
2841
2842                client.request(request.unwrap()).await
2843            };
2844
2845            match req_result {
2846                Err(err) => {
2847                    if let common::Retry::After(d) = dlg.http_error(&err) {
2848                        sleep(d).await;
2849                        continue;
2850                    }
2851                    dlg.finished(false);
2852                    return Err(common::Error::HttpError(err));
2853                }
2854                Ok(res) => {
2855                    let (mut parts, body) = res.into_parts();
2856                    let mut body = common::Body::new(body);
2857                    if !parts.status.is_success() {
2858                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2859                        let error = serde_json::from_str(&common::to_string(&bytes));
2860                        let response = common::to_response(parts, bytes.into());
2861
2862                        if let common::Retry::After(d) =
2863                            dlg.http_failure(&response, error.as_ref().ok())
2864                        {
2865                            sleep(d).await;
2866                            continue;
2867                        }
2868
2869                        dlg.finished(false);
2870
2871                        return Err(match error {
2872                            Ok(value) => common::Error::BadRequest(value),
2873                            _ => common::Error::Failure(response),
2874                        });
2875                    }
2876                    let response = {
2877                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2878                        let encoded = common::to_string(&bytes);
2879                        match serde_json::from_str(&encoded) {
2880                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2881                            Err(error) => {
2882                                dlg.response_json_decode_error(&encoded, &error);
2883                                return Err(common::Error::JsonDecodeError(
2884                                    encoded.to_string(),
2885                                    error,
2886                                ));
2887                            }
2888                        }
2889                    };
2890
2891                    dlg.finished(true);
2892                    return Ok(response);
2893                }
2894            }
2895        }
2896    }
2897
2898    ///
2899    /// Sets the *request* property to the given value.
2900    ///
2901    /// Even though the property as already been set when instantiating this call,
2902    /// we provide this method for API completeness.
2903    pub fn request(mut self, new_value: Job) -> ProjectLocationJobCreateCall<'a, C> {
2904        self._request = new_value;
2905        self
2906    }
2907    /// Required. The parent location to create and process this job. Format: `projects/{project}/locations/{location}`
2908    ///
2909    /// Sets the *parent* path property to the given value.
2910    ///
2911    /// Even though the property as already been set when instantiating this call,
2912    /// we provide this method for API completeness.
2913    pub fn parent(mut self, new_value: &str) -> ProjectLocationJobCreateCall<'a, C> {
2914        self._parent = new_value.to_string();
2915        self
2916    }
2917    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2918    /// while executing the actual API request.
2919    ///
2920    /// ````text
2921    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2922    /// ````
2923    ///
2924    /// Sets the *delegate* property to the given value.
2925    pub fn delegate(
2926        mut self,
2927        new_value: &'a mut dyn common::Delegate,
2928    ) -> ProjectLocationJobCreateCall<'a, C> {
2929        self._delegate = Some(new_value);
2930        self
2931    }
2932
2933    /// Set any additional parameter of the query string used in the request.
2934    /// It should be used to set parameters which are not yet available through their own
2935    /// setters.
2936    ///
2937    /// Please note that this method must not be used to set any of the known parameters
2938    /// which have their own setter method. If done anyway, the request will fail.
2939    ///
2940    /// # Additional Parameters
2941    ///
2942    /// * *$.xgafv* (query-string) - V1 error format.
2943    /// * *access_token* (query-string) - OAuth access token.
2944    /// * *alt* (query-string) - Data format for response.
2945    /// * *callback* (query-string) - JSONP
2946    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2947    /// * *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.
2948    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2949    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2950    /// * *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.
2951    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2952    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2953    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationJobCreateCall<'a, C>
2954    where
2955        T: AsRef<str>,
2956    {
2957        self._additional_params
2958            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2959        self
2960    }
2961
2962    /// Identifies the authorization scope for the method you are building.
2963    ///
2964    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2965    /// [`Scope::CloudPlatform`].
2966    ///
2967    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2968    /// tokens for more than one scope.
2969    ///
2970    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2971    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2972    /// sufficient, a read-write scope will do as well.
2973    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationJobCreateCall<'a, C>
2974    where
2975        St: AsRef<str>,
2976    {
2977        self._scopes.insert(String::from(scope.as_ref()));
2978        self
2979    }
2980    /// Identifies the authorization scope(s) for the method you are building.
2981    ///
2982    /// See [`Self::add_scope()`] for details.
2983    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationJobCreateCall<'a, C>
2984    where
2985        I: IntoIterator<Item = St>,
2986        St: AsRef<str>,
2987    {
2988        self._scopes
2989            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2990        self
2991    }
2992
2993    /// Removes all scopes, and no default scope will be used either.
2994    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2995    /// for details).
2996    pub fn clear_scopes(mut self) -> ProjectLocationJobCreateCall<'a, C> {
2997        self._scopes.clear();
2998        self
2999    }
3000}
3001
3002/// Deletes a job.
3003///
3004/// A builder for the *locations.jobs.delete* method supported by a *project* resource.
3005/// It is not used directly, but through a [`ProjectMethods`] instance.
3006///
3007/// # Example
3008///
3009/// Instantiate a resource method builder
3010///
3011/// ```test_harness,no_run
3012/// # extern crate hyper;
3013/// # extern crate hyper_rustls;
3014/// # extern crate google_transcoder1_beta1 as transcoder1_beta1;
3015/// # async fn dox() {
3016/// # use transcoder1_beta1::{Transcoder, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3017///
3018/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3019/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3020/// #     .with_native_roots()
3021/// #     .unwrap()
3022/// #     .https_only()
3023/// #     .enable_http2()
3024/// #     .build();
3025///
3026/// # let executor = hyper_util::rt::TokioExecutor::new();
3027/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3028/// #     secret,
3029/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3030/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3031/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3032/// #     ),
3033/// # ).build().await.unwrap();
3034///
3035/// # let client = hyper_util::client::legacy::Client::builder(
3036/// #     hyper_util::rt::TokioExecutor::new()
3037/// # )
3038/// # .build(
3039/// #     hyper_rustls::HttpsConnectorBuilder::new()
3040/// #         .with_native_roots()
3041/// #         .unwrap()
3042/// #         .https_or_http()
3043/// #         .enable_http2()
3044/// #         .build()
3045/// # );
3046/// # let mut hub = Transcoder::new(client, auth);
3047/// // You can configure optional parameters by calling the respective setters at will, and
3048/// // execute the final call using `doit()`.
3049/// // Values shown here are possibly random and not representative !
3050/// let result = hub.projects().locations_jobs_delete("name")
3051///              .doit().await;
3052/// # }
3053/// ```
3054pub struct ProjectLocationJobDeleteCall<'a, C>
3055where
3056    C: 'a,
3057{
3058    hub: &'a Transcoder<C>,
3059    _name: String,
3060    _delegate: Option<&'a mut dyn common::Delegate>,
3061    _additional_params: HashMap<String, String>,
3062    _scopes: BTreeSet<String>,
3063}
3064
3065impl<'a, C> common::CallBuilder for ProjectLocationJobDeleteCall<'a, C> {}
3066
3067impl<'a, C> ProjectLocationJobDeleteCall<'a, C>
3068where
3069    C: common::Connector,
3070{
3071    /// Perform the operation you have build so far.
3072    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
3073        use std::borrow::Cow;
3074        use std::io::{Read, Seek};
3075
3076        use common::{url::Params, ToParts};
3077        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3078
3079        let mut dd = common::DefaultDelegate;
3080        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3081        dlg.begin(common::MethodInfo {
3082            id: "transcoder.projects.locations.jobs.delete",
3083            http_method: hyper::Method::DELETE,
3084        });
3085
3086        for &field in ["alt", "name"].iter() {
3087            if self._additional_params.contains_key(field) {
3088                dlg.finished(false);
3089                return Err(common::Error::FieldClash(field));
3090            }
3091        }
3092
3093        let mut params = Params::with_capacity(3 + self._additional_params.len());
3094        params.push("name", self._name);
3095
3096        params.extend(self._additional_params.iter());
3097
3098        params.push("alt", "json");
3099        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
3100        if self._scopes.is_empty() {
3101            self._scopes
3102                .insert(Scope::CloudPlatform.as_ref().to_string());
3103        }
3104
3105        #[allow(clippy::single_element_loop)]
3106        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3107            url = params.uri_replacement(url, param_name, find_this, true);
3108        }
3109        {
3110            let to_remove = ["name"];
3111            params.remove_params(&to_remove);
3112        }
3113
3114        let url = params.parse_with_url(&url);
3115
3116        loop {
3117            let token = match self
3118                .hub
3119                .auth
3120                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3121                .await
3122            {
3123                Ok(token) => token,
3124                Err(e) => match dlg.token(e) {
3125                    Ok(token) => token,
3126                    Err(e) => {
3127                        dlg.finished(false);
3128                        return Err(common::Error::MissingToken(e));
3129                    }
3130                },
3131            };
3132            let mut req_result = {
3133                let client = &self.hub.client;
3134                dlg.pre_request();
3135                let mut req_builder = hyper::Request::builder()
3136                    .method(hyper::Method::DELETE)
3137                    .uri(url.as_str())
3138                    .header(USER_AGENT, self.hub._user_agent.clone());
3139
3140                if let Some(token) = token.as_ref() {
3141                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3142                }
3143
3144                let request = req_builder
3145                    .header(CONTENT_LENGTH, 0_u64)
3146                    .body(common::to_body::<String>(None));
3147
3148                client.request(request.unwrap()).await
3149            };
3150
3151            match req_result {
3152                Err(err) => {
3153                    if let common::Retry::After(d) = dlg.http_error(&err) {
3154                        sleep(d).await;
3155                        continue;
3156                    }
3157                    dlg.finished(false);
3158                    return Err(common::Error::HttpError(err));
3159                }
3160                Ok(res) => {
3161                    let (mut parts, body) = res.into_parts();
3162                    let mut body = common::Body::new(body);
3163                    if !parts.status.is_success() {
3164                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3165                        let error = serde_json::from_str(&common::to_string(&bytes));
3166                        let response = common::to_response(parts, bytes.into());
3167
3168                        if let common::Retry::After(d) =
3169                            dlg.http_failure(&response, error.as_ref().ok())
3170                        {
3171                            sleep(d).await;
3172                            continue;
3173                        }
3174
3175                        dlg.finished(false);
3176
3177                        return Err(match error {
3178                            Ok(value) => common::Error::BadRequest(value),
3179                            _ => common::Error::Failure(response),
3180                        });
3181                    }
3182                    let response = {
3183                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3184                        let encoded = common::to_string(&bytes);
3185                        match serde_json::from_str(&encoded) {
3186                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3187                            Err(error) => {
3188                                dlg.response_json_decode_error(&encoded, &error);
3189                                return Err(common::Error::JsonDecodeError(
3190                                    encoded.to_string(),
3191                                    error,
3192                                ));
3193                            }
3194                        }
3195                    };
3196
3197                    dlg.finished(true);
3198                    return Ok(response);
3199                }
3200            }
3201        }
3202    }
3203
3204    /// Required. The name of the job to delete. Format: `projects/{project}/locations/{location}/jobs/{job}`
3205    ///
3206    /// Sets the *name* path property to the given value.
3207    ///
3208    /// Even though the property as already been set when instantiating this call,
3209    /// we provide this method for API completeness.
3210    pub fn name(mut self, new_value: &str) -> ProjectLocationJobDeleteCall<'a, C> {
3211        self._name = new_value.to_string();
3212        self
3213    }
3214    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3215    /// while executing the actual API request.
3216    ///
3217    /// ````text
3218    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3219    /// ````
3220    ///
3221    /// Sets the *delegate* property to the given value.
3222    pub fn delegate(
3223        mut self,
3224        new_value: &'a mut dyn common::Delegate,
3225    ) -> ProjectLocationJobDeleteCall<'a, C> {
3226        self._delegate = Some(new_value);
3227        self
3228    }
3229
3230    /// Set any additional parameter of the query string used in the request.
3231    /// It should be used to set parameters which are not yet available through their own
3232    /// setters.
3233    ///
3234    /// Please note that this method must not be used to set any of the known parameters
3235    /// which have their own setter method. If done anyway, the request will fail.
3236    ///
3237    /// # Additional Parameters
3238    ///
3239    /// * *$.xgafv* (query-string) - V1 error format.
3240    /// * *access_token* (query-string) - OAuth access token.
3241    /// * *alt* (query-string) - Data format for response.
3242    /// * *callback* (query-string) - JSONP
3243    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3244    /// * *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.
3245    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3246    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3247    /// * *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.
3248    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3249    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3250    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationJobDeleteCall<'a, C>
3251    where
3252        T: AsRef<str>,
3253    {
3254        self._additional_params
3255            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3256        self
3257    }
3258
3259    /// Identifies the authorization scope for the method you are building.
3260    ///
3261    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3262    /// [`Scope::CloudPlatform`].
3263    ///
3264    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3265    /// tokens for more than one scope.
3266    ///
3267    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3268    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3269    /// sufficient, a read-write scope will do as well.
3270    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationJobDeleteCall<'a, C>
3271    where
3272        St: AsRef<str>,
3273    {
3274        self._scopes.insert(String::from(scope.as_ref()));
3275        self
3276    }
3277    /// Identifies the authorization scope(s) for the method you are building.
3278    ///
3279    /// See [`Self::add_scope()`] for details.
3280    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationJobDeleteCall<'a, C>
3281    where
3282        I: IntoIterator<Item = St>,
3283        St: AsRef<str>,
3284    {
3285        self._scopes
3286            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3287        self
3288    }
3289
3290    /// Removes all scopes, and no default scope will be used either.
3291    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3292    /// for details).
3293    pub fn clear_scopes(mut self) -> ProjectLocationJobDeleteCall<'a, C> {
3294        self._scopes.clear();
3295        self
3296    }
3297}
3298
3299/// Returns the job data.
3300///
3301/// A builder for the *locations.jobs.get* method supported by a *project* resource.
3302/// It is not used directly, but through a [`ProjectMethods`] instance.
3303///
3304/// # Example
3305///
3306/// Instantiate a resource method builder
3307///
3308/// ```test_harness,no_run
3309/// # extern crate hyper;
3310/// # extern crate hyper_rustls;
3311/// # extern crate google_transcoder1_beta1 as transcoder1_beta1;
3312/// # async fn dox() {
3313/// # use transcoder1_beta1::{Transcoder, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3314///
3315/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3316/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3317/// #     .with_native_roots()
3318/// #     .unwrap()
3319/// #     .https_only()
3320/// #     .enable_http2()
3321/// #     .build();
3322///
3323/// # let executor = hyper_util::rt::TokioExecutor::new();
3324/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3325/// #     secret,
3326/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3327/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3328/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3329/// #     ),
3330/// # ).build().await.unwrap();
3331///
3332/// # let client = hyper_util::client::legacy::Client::builder(
3333/// #     hyper_util::rt::TokioExecutor::new()
3334/// # )
3335/// # .build(
3336/// #     hyper_rustls::HttpsConnectorBuilder::new()
3337/// #         .with_native_roots()
3338/// #         .unwrap()
3339/// #         .https_or_http()
3340/// #         .enable_http2()
3341/// #         .build()
3342/// # );
3343/// # let mut hub = Transcoder::new(client, auth);
3344/// // You can configure optional parameters by calling the respective setters at will, and
3345/// // execute the final call using `doit()`.
3346/// // Values shown here are possibly random and not representative !
3347/// let result = hub.projects().locations_jobs_get("name")
3348///              .doit().await;
3349/// # }
3350/// ```
3351pub struct ProjectLocationJobGetCall<'a, C>
3352where
3353    C: 'a,
3354{
3355    hub: &'a Transcoder<C>,
3356    _name: String,
3357    _delegate: Option<&'a mut dyn common::Delegate>,
3358    _additional_params: HashMap<String, String>,
3359    _scopes: BTreeSet<String>,
3360}
3361
3362impl<'a, C> common::CallBuilder for ProjectLocationJobGetCall<'a, C> {}
3363
3364impl<'a, C> ProjectLocationJobGetCall<'a, C>
3365where
3366    C: common::Connector,
3367{
3368    /// Perform the operation you have build so far.
3369    pub async fn doit(mut self) -> common::Result<(common::Response, Job)> {
3370        use std::borrow::Cow;
3371        use std::io::{Read, Seek};
3372
3373        use common::{url::Params, ToParts};
3374        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3375
3376        let mut dd = common::DefaultDelegate;
3377        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3378        dlg.begin(common::MethodInfo {
3379            id: "transcoder.projects.locations.jobs.get",
3380            http_method: hyper::Method::GET,
3381        });
3382
3383        for &field in ["alt", "name"].iter() {
3384            if self._additional_params.contains_key(field) {
3385                dlg.finished(false);
3386                return Err(common::Error::FieldClash(field));
3387            }
3388        }
3389
3390        let mut params = Params::with_capacity(3 + self._additional_params.len());
3391        params.push("name", self._name);
3392
3393        params.extend(self._additional_params.iter());
3394
3395        params.push("alt", "json");
3396        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
3397        if self._scopes.is_empty() {
3398            self._scopes
3399                .insert(Scope::CloudPlatform.as_ref().to_string());
3400        }
3401
3402        #[allow(clippy::single_element_loop)]
3403        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3404            url = params.uri_replacement(url, param_name, find_this, true);
3405        }
3406        {
3407            let to_remove = ["name"];
3408            params.remove_params(&to_remove);
3409        }
3410
3411        let url = params.parse_with_url(&url);
3412
3413        loop {
3414            let token = match self
3415                .hub
3416                .auth
3417                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3418                .await
3419            {
3420                Ok(token) => token,
3421                Err(e) => match dlg.token(e) {
3422                    Ok(token) => token,
3423                    Err(e) => {
3424                        dlg.finished(false);
3425                        return Err(common::Error::MissingToken(e));
3426                    }
3427                },
3428            };
3429            let mut req_result = {
3430                let client = &self.hub.client;
3431                dlg.pre_request();
3432                let mut req_builder = hyper::Request::builder()
3433                    .method(hyper::Method::GET)
3434                    .uri(url.as_str())
3435                    .header(USER_AGENT, self.hub._user_agent.clone());
3436
3437                if let Some(token) = token.as_ref() {
3438                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3439                }
3440
3441                let request = req_builder
3442                    .header(CONTENT_LENGTH, 0_u64)
3443                    .body(common::to_body::<String>(None));
3444
3445                client.request(request.unwrap()).await
3446            };
3447
3448            match req_result {
3449                Err(err) => {
3450                    if let common::Retry::After(d) = dlg.http_error(&err) {
3451                        sleep(d).await;
3452                        continue;
3453                    }
3454                    dlg.finished(false);
3455                    return Err(common::Error::HttpError(err));
3456                }
3457                Ok(res) => {
3458                    let (mut parts, body) = res.into_parts();
3459                    let mut body = common::Body::new(body);
3460                    if !parts.status.is_success() {
3461                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3462                        let error = serde_json::from_str(&common::to_string(&bytes));
3463                        let response = common::to_response(parts, bytes.into());
3464
3465                        if let common::Retry::After(d) =
3466                            dlg.http_failure(&response, error.as_ref().ok())
3467                        {
3468                            sleep(d).await;
3469                            continue;
3470                        }
3471
3472                        dlg.finished(false);
3473
3474                        return Err(match error {
3475                            Ok(value) => common::Error::BadRequest(value),
3476                            _ => common::Error::Failure(response),
3477                        });
3478                    }
3479                    let response = {
3480                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3481                        let encoded = common::to_string(&bytes);
3482                        match serde_json::from_str(&encoded) {
3483                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3484                            Err(error) => {
3485                                dlg.response_json_decode_error(&encoded, &error);
3486                                return Err(common::Error::JsonDecodeError(
3487                                    encoded.to_string(),
3488                                    error,
3489                                ));
3490                            }
3491                        }
3492                    };
3493
3494                    dlg.finished(true);
3495                    return Ok(response);
3496                }
3497            }
3498        }
3499    }
3500
3501    /// Required. The name of the job to retrieve. Format: `projects/{project}/locations/{location}/jobs/{job}`
3502    ///
3503    /// Sets the *name* path property to the given value.
3504    ///
3505    /// Even though the property as already been set when instantiating this call,
3506    /// we provide this method for API completeness.
3507    pub fn name(mut self, new_value: &str) -> ProjectLocationJobGetCall<'a, C> {
3508        self._name = new_value.to_string();
3509        self
3510    }
3511    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3512    /// while executing the actual API request.
3513    ///
3514    /// ````text
3515    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3516    /// ````
3517    ///
3518    /// Sets the *delegate* property to the given value.
3519    pub fn delegate(
3520        mut self,
3521        new_value: &'a mut dyn common::Delegate,
3522    ) -> ProjectLocationJobGetCall<'a, C> {
3523        self._delegate = Some(new_value);
3524        self
3525    }
3526
3527    /// Set any additional parameter of the query string used in the request.
3528    /// It should be used to set parameters which are not yet available through their own
3529    /// setters.
3530    ///
3531    /// Please note that this method must not be used to set any of the known parameters
3532    /// which have their own setter method. If done anyway, the request will fail.
3533    ///
3534    /// # Additional Parameters
3535    ///
3536    /// * *$.xgafv* (query-string) - V1 error format.
3537    /// * *access_token* (query-string) - OAuth access token.
3538    /// * *alt* (query-string) - Data format for response.
3539    /// * *callback* (query-string) - JSONP
3540    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3541    /// * *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.
3542    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3543    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3544    /// * *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.
3545    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3546    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3547    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationJobGetCall<'a, C>
3548    where
3549        T: AsRef<str>,
3550    {
3551        self._additional_params
3552            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3553        self
3554    }
3555
3556    /// Identifies the authorization scope for the method you are building.
3557    ///
3558    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3559    /// [`Scope::CloudPlatform`].
3560    ///
3561    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3562    /// tokens for more than one scope.
3563    ///
3564    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3565    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3566    /// sufficient, a read-write scope will do as well.
3567    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationJobGetCall<'a, C>
3568    where
3569        St: AsRef<str>,
3570    {
3571        self._scopes.insert(String::from(scope.as_ref()));
3572        self
3573    }
3574    /// Identifies the authorization scope(s) for the method you are building.
3575    ///
3576    /// See [`Self::add_scope()`] for details.
3577    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationJobGetCall<'a, C>
3578    where
3579        I: IntoIterator<Item = St>,
3580        St: AsRef<str>,
3581    {
3582        self._scopes
3583            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3584        self
3585    }
3586
3587    /// Removes all scopes, and no default scope will be used either.
3588    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3589    /// for details).
3590    pub fn clear_scopes(mut self) -> ProjectLocationJobGetCall<'a, C> {
3591        self._scopes.clear();
3592        self
3593    }
3594}
3595
3596/// Lists jobs in the specified region.
3597///
3598/// A builder for the *locations.jobs.list* method supported by a *project* resource.
3599/// It is not used directly, but through a [`ProjectMethods`] instance.
3600///
3601/// # Example
3602///
3603/// Instantiate a resource method builder
3604///
3605/// ```test_harness,no_run
3606/// # extern crate hyper;
3607/// # extern crate hyper_rustls;
3608/// # extern crate google_transcoder1_beta1 as transcoder1_beta1;
3609/// # async fn dox() {
3610/// # use transcoder1_beta1::{Transcoder, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3611///
3612/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3613/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3614/// #     .with_native_roots()
3615/// #     .unwrap()
3616/// #     .https_only()
3617/// #     .enable_http2()
3618/// #     .build();
3619///
3620/// # let executor = hyper_util::rt::TokioExecutor::new();
3621/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3622/// #     secret,
3623/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3624/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3625/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3626/// #     ),
3627/// # ).build().await.unwrap();
3628///
3629/// # let client = hyper_util::client::legacy::Client::builder(
3630/// #     hyper_util::rt::TokioExecutor::new()
3631/// # )
3632/// # .build(
3633/// #     hyper_rustls::HttpsConnectorBuilder::new()
3634/// #         .with_native_roots()
3635/// #         .unwrap()
3636/// #         .https_or_http()
3637/// #         .enable_http2()
3638/// #         .build()
3639/// # );
3640/// # let mut hub = Transcoder::new(client, auth);
3641/// // You can configure optional parameters by calling the respective setters at will, and
3642/// // execute the final call using `doit()`.
3643/// // Values shown here are possibly random and not representative !
3644/// let result = hub.projects().locations_jobs_list("parent")
3645///              .page_token("Lorem")
3646///              .page_size(-12)
3647///              .doit().await;
3648/// # }
3649/// ```
3650pub struct ProjectLocationJobListCall<'a, C>
3651where
3652    C: 'a,
3653{
3654    hub: &'a Transcoder<C>,
3655    _parent: String,
3656    _page_token: Option<String>,
3657    _page_size: Option<i32>,
3658    _delegate: Option<&'a mut dyn common::Delegate>,
3659    _additional_params: HashMap<String, String>,
3660    _scopes: BTreeSet<String>,
3661}
3662
3663impl<'a, C> common::CallBuilder for ProjectLocationJobListCall<'a, C> {}
3664
3665impl<'a, C> ProjectLocationJobListCall<'a, C>
3666where
3667    C: common::Connector,
3668{
3669    /// Perform the operation you have build so far.
3670    pub async fn doit(mut self) -> common::Result<(common::Response, ListJobsResponse)> {
3671        use std::borrow::Cow;
3672        use std::io::{Read, Seek};
3673
3674        use common::{url::Params, ToParts};
3675        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3676
3677        let mut dd = common::DefaultDelegate;
3678        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3679        dlg.begin(common::MethodInfo {
3680            id: "transcoder.projects.locations.jobs.list",
3681            http_method: hyper::Method::GET,
3682        });
3683
3684        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
3685            if self._additional_params.contains_key(field) {
3686                dlg.finished(false);
3687                return Err(common::Error::FieldClash(field));
3688            }
3689        }
3690
3691        let mut params = Params::with_capacity(5 + self._additional_params.len());
3692        params.push("parent", self._parent);
3693        if let Some(value) = self._page_token.as_ref() {
3694            params.push("pageToken", value);
3695        }
3696        if let Some(value) = self._page_size.as_ref() {
3697            params.push("pageSize", value.to_string());
3698        }
3699
3700        params.extend(self._additional_params.iter());
3701
3702        params.push("alt", "json");
3703        let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/jobs";
3704        if self._scopes.is_empty() {
3705            self._scopes
3706                .insert(Scope::CloudPlatform.as_ref().to_string());
3707        }
3708
3709        #[allow(clippy::single_element_loop)]
3710        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3711            url = params.uri_replacement(url, param_name, find_this, true);
3712        }
3713        {
3714            let to_remove = ["parent"];
3715            params.remove_params(&to_remove);
3716        }
3717
3718        let url = params.parse_with_url(&url);
3719
3720        loop {
3721            let token = match self
3722                .hub
3723                .auth
3724                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3725                .await
3726            {
3727                Ok(token) => token,
3728                Err(e) => match dlg.token(e) {
3729                    Ok(token) => token,
3730                    Err(e) => {
3731                        dlg.finished(false);
3732                        return Err(common::Error::MissingToken(e));
3733                    }
3734                },
3735            };
3736            let mut req_result = {
3737                let client = &self.hub.client;
3738                dlg.pre_request();
3739                let mut req_builder = hyper::Request::builder()
3740                    .method(hyper::Method::GET)
3741                    .uri(url.as_str())
3742                    .header(USER_AGENT, self.hub._user_agent.clone());
3743
3744                if let Some(token) = token.as_ref() {
3745                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3746                }
3747
3748                let request = req_builder
3749                    .header(CONTENT_LENGTH, 0_u64)
3750                    .body(common::to_body::<String>(None));
3751
3752                client.request(request.unwrap()).await
3753            };
3754
3755            match req_result {
3756                Err(err) => {
3757                    if let common::Retry::After(d) = dlg.http_error(&err) {
3758                        sleep(d).await;
3759                        continue;
3760                    }
3761                    dlg.finished(false);
3762                    return Err(common::Error::HttpError(err));
3763                }
3764                Ok(res) => {
3765                    let (mut parts, body) = res.into_parts();
3766                    let mut body = common::Body::new(body);
3767                    if !parts.status.is_success() {
3768                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3769                        let error = serde_json::from_str(&common::to_string(&bytes));
3770                        let response = common::to_response(parts, bytes.into());
3771
3772                        if let common::Retry::After(d) =
3773                            dlg.http_failure(&response, error.as_ref().ok())
3774                        {
3775                            sleep(d).await;
3776                            continue;
3777                        }
3778
3779                        dlg.finished(false);
3780
3781                        return Err(match error {
3782                            Ok(value) => common::Error::BadRequest(value),
3783                            _ => common::Error::Failure(response),
3784                        });
3785                    }
3786                    let response = {
3787                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3788                        let encoded = common::to_string(&bytes);
3789                        match serde_json::from_str(&encoded) {
3790                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3791                            Err(error) => {
3792                                dlg.response_json_decode_error(&encoded, &error);
3793                                return Err(common::Error::JsonDecodeError(
3794                                    encoded.to_string(),
3795                                    error,
3796                                ));
3797                            }
3798                        }
3799                    };
3800
3801                    dlg.finished(true);
3802                    return Ok(response);
3803                }
3804            }
3805        }
3806    }
3807
3808    /// Required. Format: `projects/{project}/locations/{location}`
3809    ///
3810    /// Sets the *parent* path property to the given value.
3811    ///
3812    /// Even though the property as already been set when instantiating this call,
3813    /// we provide this method for API completeness.
3814    pub fn parent(mut self, new_value: &str) -> ProjectLocationJobListCall<'a, C> {
3815        self._parent = new_value.to_string();
3816        self
3817    }
3818    /// The `next_page_token` value returned from a previous List request, if any.
3819    ///
3820    /// Sets the *page token* query property to the given value.
3821    pub fn page_token(mut self, new_value: &str) -> ProjectLocationJobListCall<'a, C> {
3822        self._page_token = Some(new_value.to_string());
3823        self
3824    }
3825    /// The maximum number of items to return.
3826    ///
3827    /// Sets the *page size* query property to the given value.
3828    pub fn page_size(mut self, new_value: i32) -> ProjectLocationJobListCall<'a, C> {
3829        self._page_size = Some(new_value);
3830        self
3831    }
3832    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3833    /// while executing the actual API request.
3834    ///
3835    /// ````text
3836    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3837    /// ````
3838    ///
3839    /// Sets the *delegate* property to the given value.
3840    pub fn delegate(
3841        mut self,
3842        new_value: &'a mut dyn common::Delegate,
3843    ) -> ProjectLocationJobListCall<'a, C> {
3844        self._delegate = Some(new_value);
3845        self
3846    }
3847
3848    /// Set any additional parameter of the query string used in the request.
3849    /// It should be used to set parameters which are not yet available through their own
3850    /// setters.
3851    ///
3852    /// Please note that this method must not be used to set any of the known parameters
3853    /// which have their own setter method. If done anyway, the request will fail.
3854    ///
3855    /// # Additional Parameters
3856    ///
3857    /// * *$.xgafv* (query-string) - V1 error format.
3858    /// * *access_token* (query-string) - OAuth access token.
3859    /// * *alt* (query-string) - Data format for response.
3860    /// * *callback* (query-string) - JSONP
3861    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3862    /// * *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.
3863    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3864    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3865    /// * *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.
3866    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3867    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3868    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationJobListCall<'a, C>
3869    where
3870        T: AsRef<str>,
3871    {
3872        self._additional_params
3873            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3874        self
3875    }
3876
3877    /// Identifies the authorization scope for the method you are building.
3878    ///
3879    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3880    /// [`Scope::CloudPlatform`].
3881    ///
3882    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3883    /// tokens for more than one scope.
3884    ///
3885    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3886    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3887    /// sufficient, a read-write scope will do as well.
3888    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationJobListCall<'a, C>
3889    where
3890        St: AsRef<str>,
3891    {
3892        self._scopes.insert(String::from(scope.as_ref()));
3893        self
3894    }
3895    /// Identifies the authorization scope(s) for the method you are building.
3896    ///
3897    /// See [`Self::add_scope()`] for details.
3898    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationJobListCall<'a, C>
3899    where
3900        I: IntoIterator<Item = St>,
3901        St: AsRef<str>,
3902    {
3903        self._scopes
3904            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3905        self
3906    }
3907
3908    /// Removes all scopes, and no default scope will be used either.
3909    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3910    /// for details).
3911    pub fn clear_scopes(mut self) -> ProjectLocationJobListCall<'a, C> {
3912        self._scopes.clear();
3913        self
3914    }
3915}