google_speech1/
api.rs

1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16    /// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
17    CloudPlatform,
18}
19
20impl AsRef<str> for Scope {
21    fn as_ref(&self) -> &str {
22        match *self {
23            Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
24        }
25    }
26}
27
28#[allow(clippy::derivable_impls)]
29impl Default for Scope {
30    fn default() -> Scope {
31        Scope::CloudPlatform
32    }
33}
34
35// ########
36// HUB ###
37// ######
38
39/// Central instance to access all Speech 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_speech1 as speech1;
49/// use speech1::api::CustomClass;
50/// use speech1::{Result, Error};
51/// # async fn dox() {
52/// use speech1::{Speech, 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 = Speech::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 = CustomClass::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_custom_classes_patch(req, "name")
99///              .update_mask(FieldMask::new::<&str>(&[]))
100///              .doit().await;
101///
102/// match result {
103///     Err(e) => match e {
104///         // The Error enum provides details about what exactly happened.
105///         // You can also just use its `Debug`, `Display` or `Error` traits
106///          Error::HttpError(_)
107///         |Error::Io(_)
108///         |Error::MissingAPIKey
109///         |Error::MissingToken(_)
110///         |Error::Cancelled
111///         |Error::UploadSizeLimitExceeded(_, _)
112///         |Error::Failure(_)
113///         |Error::BadRequest(_)
114///         |Error::FieldClash(_)
115///         |Error::JsonDecodeError(_, _) => println!("{}", e),
116///     },
117///     Ok(res) => println!("Success: {:?}", res),
118/// }
119/// # }
120/// ```
121#[derive(Clone)]
122pub struct Speech<C> {
123    pub client: common::Client<C>,
124    pub auth: Box<dyn common::GetToken>,
125    _user_agent: String,
126    _base_url: String,
127    _root_url: String,
128}
129
130impl<C> common::Hub for Speech<C> {}
131
132impl<'a, C> Speech<C> {
133    pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Speech<C> {
134        Speech {
135            client,
136            auth: Box::new(auth),
137            _user_agent: "google-api-rust-client/7.0.0".to_string(),
138            _base_url: "https://speech.googleapis.com/".to_string(),
139            _root_url: "https://speech.googleapis.com/".to_string(),
140        }
141    }
142
143    pub fn operations(&'a self) -> OperationMethods<'a, C> {
144        OperationMethods { hub: self }
145    }
146    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
147        ProjectMethods { hub: self }
148    }
149    pub fn speech(&'a self) -> SpeechMethods<'a, C> {
150        SpeechMethods { hub: self }
151    }
152
153    /// Set the user-agent header field to use in all requests to the server.
154    /// It defaults to `google-api-rust-client/7.0.0`.
155    ///
156    /// Returns the previously set user-agent.
157    pub fn user_agent(&mut self, agent_name: String) -> String {
158        std::mem::replace(&mut self._user_agent, agent_name)
159    }
160
161    /// Set the base url to use in all requests to the server.
162    /// It defaults to `https://speech.googleapis.com/`.
163    ///
164    /// Returns the previously set base url.
165    pub fn base_url(&mut self, new_base_url: String) -> String {
166        std::mem::replace(&mut self._base_url, new_base_url)
167    }
168
169    /// Set the root url to use in all requests to the server.
170    /// It defaults to `https://speech.googleapis.com/`.
171    ///
172    /// Returns the previously set root url.
173    pub fn root_url(&mut self, new_root_url: String) -> String {
174        std::mem::replace(&mut self._root_url, new_root_url)
175    }
176}
177
178// ############
179// SCHEMAS ###
180// ##########
181/// There is no detailed description.
182///
183/// This type is not used in any activity, and only used as *part* of another schema.
184///
185#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
186#[serde_with::serde_as]
187#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
188pub struct ABNFGrammar {
189    /// All declarations and rules of an ABNF grammar broken up into multiple strings that will end up concatenated.
190    #[serde(rename = "abnfStrings")]
191    pub abnf_strings: Option<Vec<String>>,
192}
193
194impl common::Part for ABNFGrammar {}
195
196/// An item of the class.
197///
198/// This type is not used in any activity, and only used as *part* of another schema.
199///
200#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
201#[serde_with::serde_as]
202#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
203pub struct ClassItem {
204    /// The class item's value.
205    pub value: Option<String>,
206}
207
208impl common::Part for ClassItem {}
209
210/// Message sent by the client for the `CreateCustomClass` method.
211///
212/// # Activities
213///
214/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
215/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
216///
217/// * [locations custom classes create projects](ProjectLocationCustomClassCreateCall) (request)
218#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
219#[serde_with::serde_as]
220#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
221pub struct CreateCustomClassRequest {
222    /// Required. The custom class to create.
223    #[serde(rename = "customClass")]
224    pub custom_class: Option<CustomClass>,
225    /// Required. The ID to use for the custom class, which will become the final component of the custom class' resource name. This value should restrict to letters, numbers, and hyphens, with the first character a letter, the last a letter or a number, and be 4-63 characters.
226    #[serde(rename = "customClassId")]
227    pub custom_class_id: Option<String>,
228}
229
230impl common::RequestValue for CreateCustomClassRequest {}
231
232/// Message sent by the client for the `CreatePhraseSet` method.
233///
234/// # Activities
235///
236/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
237/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
238///
239/// * [locations phrase sets create projects](ProjectLocationPhraseSetCreateCall) (request)
240#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
241#[serde_with::serde_as]
242#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
243pub struct CreatePhraseSetRequest {
244    /// Required. The phrase set to create.
245    #[serde(rename = "phraseSet")]
246    pub phrase_set: Option<PhraseSet>,
247    /// Required. The ID to use for the phrase set, which will become the final component of the phrase set's resource name. This value should restrict to letters, numbers, and hyphens, with the first character a letter, the last a letter or a number, and be 4-63 characters.
248    #[serde(rename = "phraseSetId")]
249    pub phrase_set_id: Option<String>,
250}
251
252impl common::RequestValue for CreatePhraseSetRequest {}
253
254/// A set of words or phrases that represents a common concept likely to appear in your audio, for example a list of passenger ship names. CustomClass items can be substituted into placeholders that you set in PhraseSet phrases.
255///
256/// # Activities
257///
258/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
259/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
260///
261/// * [locations custom classes create projects](ProjectLocationCustomClassCreateCall) (response)
262/// * [locations custom classes get projects](ProjectLocationCustomClassGetCall) (response)
263/// * [locations custom classes patch projects](ProjectLocationCustomClassPatchCall) (request|response)
264#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
265#[serde_with::serde_as]
266#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
267pub struct CustomClass {
268    /// Output only. Allows users to store small amounts of arbitrary data. Both the key and the value must be 63 characters or less each. At most 100 annotations. This field is not used.
269    pub annotations: Option<HashMap<String, String>>,
270    /// If this custom class is a resource, the custom_class_id is the resource id of the CustomClass. Case sensitive.
271    #[serde(rename = "customClassId")]
272    pub custom_class_id: Option<String>,
273    /// Output only. The time at which this resource was requested for deletion. This field is not used.
274    #[serde(rename = "deleteTime")]
275    pub delete_time: Option<chrono::DateTime<chrono::offset::Utc>>,
276    /// Output only. User-settable, human-readable name for the CustomClass. Must be 63 characters or less. This field is not used.
277    #[serde(rename = "displayName")]
278    pub display_name: Option<String>,
279    /// Output only. This checksum is computed by the server based on the value of other fields. This may be sent on update, undelete, and delete requests to ensure the client has an up-to-date value before proceeding. This field is not used.
280    pub etag: Option<String>,
281    /// Output only. The time at which this resource will be purged. This field is not used.
282    #[serde(rename = "expireTime")]
283    pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
284    /// A collection of class items.
285    pub items: Option<Vec<ClassItem>>,
286    /// Output only. The [KMS key name](https://cloud.google.com/kms/docs/resource-hierarchy#keys) with which the content of the ClassItem is encrypted. The expected format is `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
287    #[serde(rename = "kmsKeyName")]
288    pub kms_key_name: Option<String>,
289    /// Output only. The [KMS key version name](https://cloud.google.com/kms/docs/resource-hierarchy#key_versions) with which content of the ClassItem is encrypted. The expected format is `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}`.
290    #[serde(rename = "kmsKeyVersionName")]
291    pub kms_key_version_name: Option<String>,
292    /// The resource name of the custom class.
293    pub name: Option<String>,
294    /// Output only. Whether or not this CustomClass is in the process of being updated. This field is not used.
295    pub reconciling: Option<bool>,
296    /// Output only. The CustomClass lifecycle state. This field is not used.
297    pub state: Option<String>,
298    /// Output only. System-assigned unique identifier for the CustomClass. This field is not used.
299    pub uid: Option<String>,
300}
301
302impl common::RequestValue for CustomClass {}
303impl common::ResponseResult for CustomClass {}
304
305/// 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); }
306///
307/// # Activities
308///
309/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
310/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
311///
312/// * [locations custom classes delete projects](ProjectLocationCustomClassDeleteCall) (response)
313/// * [locations phrase sets delete projects](ProjectLocationPhraseSetDeleteCall) (response)
314#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
315#[serde_with::serde_as]
316#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
317pub struct Empty {
318    _never_set: Option<bool>,
319}
320
321impl common::ResponseResult for Empty {}
322
323/// A single replacement configuration.
324///
325/// This type is not used in any activity, and only used as *part* of another schema.
326///
327#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
328#[serde_with::serde_as]
329#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
330pub struct Entry {
331    /// Whether the search is case sensitive.
332    #[serde(rename = "caseSensitive")]
333    pub case_sensitive: Option<bool>,
334    /// What to replace with. Max length is 100 characters.
335    pub replace: Option<String>,
336    /// What to replace. Max length is 100 characters.
337    pub search: Option<String>,
338}
339
340impl common::Part for Entry {}
341
342/// Message returned to the client by the `ListCustomClasses` method.
343///
344/// # Activities
345///
346/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
347/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
348///
349/// * [locations custom classes list projects](ProjectLocationCustomClassListCall) (response)
350#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
351#[serde_with::serde_as]
352#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
353pub struct ListCustomClassesResponse {
354    /// The custom classes.
355    #[serde(rename = "customClasses")]
356    pub custom_classes: Option<Vec<CustomClass>>,
357    /// A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
358    #[serde(rename = "nextPageToken")]
359    pub next_page_token: Option<String>,
360}
361
362impl common::ResponseResult for ListCustomClassesResponse {}
363
364/// The response message for Operations.ListOperations.
365///
366/// # Activities
367///
368/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
369/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
370///
371/// * [list operations](OperationListCall) (response)
372#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
373#[serde_with::serde_as]
374#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
375pub struct ListOperationsResponse {
376    /// The standard List next-page token.
377    #[serde(rename = "nextPageToken")]
378    pub next_page_token: Option<String>,
379    /// A list of operations that matches the specified filter in the request.
380    pub operations: Option<Vec<Operation>>,
381    /// Unordered list. Unreachable resources. Populated when the request sets `ListOperationsRequest.return_partial_success` and reads across collections. For example, when attempting to list all resources across all supported locations.
382    pub unreachable: Option<Vec<String>>,
383}
384
385impl common::ResponseResult for ListOperationsResponse {}
386
387/// Message returned to the client by the `ListPhraseSet` method.
388///
389/// # Activities
390///
391/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
392/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
393///
394/// * [locations phrase sets list projects](ProjectLocationPhraseSetListCall) (response)
395#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
396#[serde_with::serde_as]
397#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
398pub struct ListPhraseSetResponse {
399    /// A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
400    #[serde(rename = "nextPageToken")]
401    pub next_page_token: Option<String>,
402    /// The phrase set.
403    #[serde(rename = "phraseSets")]
404    pub phrase_sets: Option<Vec<PhraseSet>>,
405}
406
407impl common::ResponseResult for ListPhraseSetResponse {}
408
409/// The top-level message sent by the client for the `LongRunningRecognize` method.
410///
411/// # Activities
412///
413/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
414/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
415///
416/// * [longrunningrecognize speech](SpeechLongrunningrecognizeCall) (request)
417#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
418#[serde_with::serde_as]
419#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
420pub struct LongRunningRecognizeRequest {
421    /// Required. The audio data to be recognized.
422    pub audio: Option<RecognitionAudio>,
423    /// Required. Provides information to the recognizer that specifies how to process the request.
424    pub config: Option<RecognitionConfig>,
425    /// Optional. Specifies an optional destination for the recognition results.
426    #[serde(rename = "outputConfig")]
427    pub output_config: Option<TranscriptOutputConfig>,
428}
429
430impl common::RequestValue for LongRunningRecognizeRequest {}
431
432/// This resource represents a long-running operation that is the result of a network API call.
433///
434/// # Activities
435///
436/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
437/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
438///
439/// * [get operations](OperationGetCall) (response)
440/// * [list operations](OperationListCall) (none)
441/// * [longrunningrecognize speech](SpeechLongrunningrecognizeCall) (response)
442#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
443#[serde_with::serde_as]
444#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
445pub struct Operation {
446    /// If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available.
447    pub done: Option<bool>,
448    /// The error result of the operation in case of failure or cancellation.
449    pub error: Option<Status>,
450    /// Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any.
451    pub metadata: Option<HashMap<String, serde_json::Value>>,
452    /// The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`.
453    pub name: Option<String>,
454    /// The normal, successful response of the operation. If the original method returns no data on success, such as `Delete`, the response is `google.protobuf.Empty`. If the original method is standard `Get`/`Create`/`Update`, the response should be the resource. For other methods, the response should have the type `XxxResponse`, where `Xxx` is the original method name. For example, if the original method name is `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`.
455    pub response: Option<HashMap<String, serde_json::Value>>,
456}
457
458impl common::Resource for Operation {}
459impl common::ResponseResult for Operation {}
460
461/// A phrases containing words and phrase "hints" so that the speech recognition is more likely to recognize them. This can be used to improve the accuracy for specific words and phrases, for example, if specific commands are typically spoken by the user. This can also be used to add additional words to the vocabulary of the recognizer. See [usage limits](https://cloud.google.com/speech-to-text/quotas#content). List items can also include pre-built or custom classes containing groups of words that represent common concepts that occur in natural language. For example, rather than providing a phrase hint for every month of the year (e.g. "i was born in january", "i was born in febuary", ...), use the pre-built `$MONTH` class improves the likelihood of correctly transcribing audio that includes months (e.g. "i was born in $month"). To refer to pre-built classes, use the class' symbol prepended with `$` e.g. `$MONTH`. To refer to custom classes that were defined inline in the request, set the class's `custom_class_id` to a string unique to all class resources and inline classes. Then use the class' id wrapped in $`{...}` e.g. "${my-months}". To refer to custom classes resources, use the class' id wrapped in `${}` (e.g. `${my-months}`). Speech-to-Text supports three locations: `global`, `us` (US North America), and `eu` (Europe). If you are calling the `speech.googleapis.com` endpoint, use the `global` location. To specify a region, use a [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) with matching `us` or `eu` location value.
462///
463/// This type is not used in any activity, and only used as *part* of another schema.
464///
465#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
466#[serde_with::serde_as]
467#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
468pub struct Phrase {
469    /// Hint Boost. Overrides the boost set at the phrase set level. Positive value will increase the probability that a specific phrase will be recognized over other similar sounding phrases. The higher the boost, the higher the chance of false positive recognition as well. Negative boost will simply be ignored. Though `boost` can accept a wide range of positive values, most use cases are best served with values between 0 and 20. We recommend using a binary search approach to finding the optimal value for your use case as well as adding phrases both with and without boost to your requests.
470    pub boost: Option<f32>,
471    /// The phrase itself.
472    pub value: Option<String>,
473}
474
475impl common::Part for Phrase {}
476
477/// Provides “hints” to the speech recognizer to favor specific words and phrases in the results.
478///
479/// # Activities
480///
481/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
482/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
483///
484/// * [locations phrase sets create projects](ProjectLocationPhraseSetCreateCall) (response)
485/// * [locations phrase sets get projects](ProjectLocationPhraseSetGetCall) (response)
486/// * [locations phrase sets patch projects](ProjectLocationPhraseSetPatchCall) (request|response)
487#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
488#[serde_with::serde_as]
489#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
490pub struct PhraseSet {
491    /// Output only. Allows users to store small amounts of arbitrary data. Both the key and the value must be 63 characters or less each. At most 100 annotations. This field is not used.
492    pub annotations: Option<HashMap<String, String>>,
493    /// Hint Boost. Positive value will increase the probability that a specific phrase will be recognized over other similar sounding phrases. The higher the boost, the higher the chance of false positive recognition as well. Negative boost values would correspond to anti-biasing. Anti-biasing is not enabled, so negative boost will simply be ignored. Though `boost` can accept a wide range of positive values, most use cases are best served with values between 0 (exclusive) and 20. We recommend using a binary search approach to finding the optimal value for your use case as well as adding phrases both with and without boost to your requests.
494    pub boost: Option<f32>,
495    /// Output only. The time at which this resource was requested for deletion. This field is not used.
496    #[serde(rename = "deleteTime")]
497    pub delete_time: Option<chrono::DateTime<chrono::offset::Utc>>,
498    /// Output only. User-settable, human-readable name for the PhraseSet. Must be 63 characters or less. This field is not used.
499    #[serde(rename = "displayName")]
500    pub display_name: Option<String>,
501    /// Output only. This checksum is computed by the server based on the value of other fields. This may be sent on update, undelete, and delete requests to ensure the client has an up-to-date value before proceeding. This field is not used.
502    pub etag: Option<String>,
503    /// Output only. The time at which this resource will be purged. This field is not used.
504    #[serde(rename = "expireTime")]
505    pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
506    /// Output only. The [KMS key name](https://cloud.google.com/kms/docs/resource-hierarchy#keys) with which the content of the PhraseSet is encrypted. The expected format is `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
507    #[serde(rename = "kmsKeyName")]
508    pub kms_key_name: Option<String>,
509    /// Output only. The [KMS key version name](https://cloud.google.com/kms/docs/resource-hierarchy#key_versions) with which content of the PhraseSet is encrypted. The expected format is `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}`.
510    #[serde(rename = "kmsKeyVersionName")]
511    pub kms_key_version_name: Option<String>,
512    /// The resource name of the phrase set.
513    pub name: Option<String>,
514    /// A list of word and phrases.
515    pub phrases: Option<Vec<Phrase>>,
516    /// Output only. Whether or not this PhraseSet is in the process of being updated. This field is not used.
517    pub reconciling: Option<bool>,
518    /// Output only. The CustomClass lifecycle state. This field is not used.
519    pub state: Option<String>,
520    /// Output only. System-assigned unique identifier for the PhraseSet. This field is not used.
521    pub uid: Option<String>,
522}
523
524impl common::RequestValue for PhraseSet {}
525impl common::ResponseResult for PhraseSet {}
526
527/// Contains audio data in the encoding specified in the `RecognitionConfig`. Either `content` or `uri` must be supplied. Supplying both or neither returns google.rpc.Code.INVALID_ARGUMENT. See [content limits](https://cloud.google.com/speech-to-text/quotas#content).
528///
529/// This type is not used in any activity, and only used as *part* of another schema.
530///
531#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
532#[serde_with::serde_as]
533#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
534pub struct RecognitionAudio {
535    /// The audio data bytes encoded as specified in `RecognitionConfig`. Note: as with all bytes fields, proto buffers use a pure binary representation, whereas JSON representations use base64.
536    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
537    pub content: Option<Vec<u8>>,
538    /// URI that points to a file that contains audio data bytes as specified in `RecognitionConfig`. The file must not be compressed (for example, gzip). Currently, only Google Cloud Storage URIs are supported, which must be specified in the following format: `gs://bucket_name/object_name` (other URI formats return google.rpc.Code.INVALID_ARGUMENT). For more information, see [Request URIs](https://cloud.google.com/storage/docs/reference-uris).
539    pub uri: Option<String>,
540}
541
542impl common::Part for RecognitionAudio {}
543
544/// Provides information to the recognizer that specifies how to process the request.
545///
546/// This type is not used in any activity, and only used as *part* of another schema.
547///
548#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
549#[serde_with::serde_as]
550#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
551pub struct RecognitionConfig {
552    /// Speech adaptation configuration improves the accuracy of speech recognition. For more information, see the [speech adaptation](https://cloud.google.com/speech-to-text/docs/adaptation) documentation. When speech adaptation is set it supersedes the `speech_contexts` field.
553    pub adaptation: Option<SpeechAdaptation>,
554    /// A list of up to 3 additional [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tags, listing possible alternative languages of the supplied audio. See [Language Support](https://cloud.google.com/speech-to-text/docs/languages) for a list of the currently supported language codes. If alternative languages are listed, recognition result will contain recognition in the most likely language detected including the main language_code. The recognition result will include the language tag of the language detected in the audio. Note: This feature is only supported for Voice Command and Voice Search use cases and performance may vary for other use cases (e.g., phone call transcription).
555    #[serde(rename = "alternativeLanguageCodes")]
556    pub alternative_language_codes: Option<Vec<String>>,
557    /// The number of channels in the input audio data. ONLY set this for MULTI-CHANNEL recognition. Valid values for LINEAR16, OGG_OPUS and FLAC are `1`-`8`. Valid value for MULAW, AMR, AMR_WB and SPEEX_WITH_HEADER_BYTE is only `1`. If `0` or omitted, defaults to one channel (mono). Note: We only recognize the first channel by default. To perform independent recognition on each channel set `enable_separate_recognition_per_channel` to 'true'.
558    #[serde(rename = "audioChannelCount")]
559    pub audio_channel_count: Option<i32>,
560    /// Config to enable speaker diarization and set additional parameters to make diarization better suited for your application. Note: When this is enabled, we send all the words from the beginning of the audio for the top alternative in every consecutive STREAMING responses. This is done in order to improve our speaker tags as our models learn to identify the speakers in the conversation over time. For non-streaming requests, the diarization results will be provided only in the top alternative of the FINAL SpeechRecognitionResult.
561    #[serde(rename = "diarizationConfig")]
562    pub diarization_config: Option<SpeakerDiarizationConfig>,
563    /// If 'true', adds punctuation to recognition result hypotheses. This feature is only available in select languages. Setting this for requests in other languages has no effect at all. The default 'false' value does not add punctuation to result hypotheses.
564    #[serde(rename = "enableAutomaticPunctuation")]
565    pub enable_automatic_punctuation: Option<bool>,
566    /// This needs to be set to `true` explicitly and `audio_channel_count` > 1 to get each channel recognized separately. The recognition result will contain a `channel_tag` field to state which channel that result belongs to. If this is not true, we will only recognize the first channel. The request is billed cumulatively for all channels recognized: `audio_channel_count` multiplied by the length of the audio.
567    #[serde(rename = "enableSeparateRecognitionPerChannel")]
568    pub enable_separate_recognition_per_channel: Option<bool>,
569    /// The spoken emoji behavior for the call If not set, uses default behavior based on model of choice If 'true', adds spoken emoji formatting for the request. This will replace spoken emojis with the corresponding Unicode symbols in the final transcript. If 'false', spoken emojis are not replaced.
570    #[serde(rename = "enableSpokenEmojis")]
571    pub enable_spoken_emojis: Option<bool>,
572    /// The spoken punctuation behavior for the call If not set, uses default behavior based on model of choice e.g. command_and_search will enable spoken punctuation by default If 'true', replaces spoken punctuation with the corresponding symbols in the request. For example, "how are you question mark" becomes "how are you?". See https://cloud.google.com/speech-to-text/docs/spoken-punctuation for support. If 'false', spoken punctuation is not replaced.
573    #[serde(rename = "enableSpokenPunctuation")]
574    pub enable_spoken_punctuation: Option<bool>,
575    /// If `true`, the top result includes a list of words and the confidence for those words. If `false`, no word-level confidence information is returned. The default is `false`.
576    #[serde(rename = "enableWordConfidence")]
577    pub enable_word_confidence: Option<bool>,
578    /// If `true`, the top result includes a list of words and the start and end time offsets (timestamps) for those words. If `false`, no word-level time offset information is returned. The default is `false`.
579    #[serde(rename = "enableWordTimeOffsets")]
580    pub enable_word_time_offsets: Option<bool>,
581    /// Encoding of audio data sent in all `RecognitionAudio` messages. This field is optional for `FLAC` and `WAV` audio files and required for all other audio formats. For details, see AudioEncoding.
582    pub encoding: Option<String>,
583    /// Required. The language of the supplied audio as a [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag. Example: "en-US". See [Language Support](https://cloud.google.com/speech-to-text/docs/languages) for a list of the currently supported language codes.
584    #[serde(rename = "languageCode")]
585    pub language_code: Option<String>,
586    /// Maximum number of recognition hypotheses to be returned. Specifically, the maximum number of `SpeechRecognitionAlternative` messages within each `SpeechRecognitionResult`. The server may return fewer than `max_alternatives`. Valid values are `0`-`30`. A value of `0` or `1` will return a maximum of one. If omitted, will return a maximum of one.
587    #[serde(rename = "maxAlternatives")]
588    pub max_alternatives: Option<i32>,
589    /// Metadata regarding this request.
590    pub metadata: Option<RecognitionMetadata>,
591    /// Which model to select for the given request. Select the model best suited to your domain to get best results. If a model is not explicitly specified, then we auto-select a model based on the parameters in the RecognitionConfig. *Model* *Description* latest_long Best for long form content like media or conversation. latest_short Best for short form content like commands or single shot directed speech. command_and_search Best for short queries such as voice commands or voice search. phone_call Best for audio that originated from a phone call (typically recorded at an 8khz sampling rate). video Best for audio that originated from video or includes multiple speakers. Ideally the audio is recorded at a 16khz or greater sampling rate. This is a premium model that costs more than the standard rate. default Best for audio that is not one of the specific audio models. For example, long-form audio. Ideally the audio is high-fidelity, recorded at a 16khz or greater sampling rate. medical_conversation Best for audio that originated from a conversation between a medical provider and patient. medical_dictation Best for audio that originated from dictation notes by a medical provider.
592    pub model: Option<String>,
593    /// If set to `true`, the server will attempt to filter out profanities, replacing all but the initial character in each filtered word with asterisks, e.g. "f***". If set to `false` or omitted, profanities won't be filtered out.
594    #[serde(rename = "profanityFilter")]
595    pub profanity_filter: Option<bool>,
596    /// Sample rate in Hertz of the audio data sent in all `RecognitionAudio` messages. Valid values are: 8000-48000. 16000 is optimal. For best results, set the sampling rate of the audio source to 16000 Hz. If that's not possible, use the native sample rate of the audio source (instead of re-sampling). This field is optional for FLAC and WAV audio files, but is required for all other audio formats. For details, see AudioEncoding.
597    #[serde(rename = "sampleRateHertz")]
598    pub sample_rate_hertz: Option<i32>,
599    /// Array of SpeechContext. A means to provide context to assist the speech recognition. For more information, see [speech adaptation](https://cloud.google.com/speech-to-text/docs/adaptation).
600    #[serde(rename = "speechContexts")]
601    pub speech_contexts: Option<Vec<SpeechContext>>,
602    /// Optional. Use transcription normalization to automatically replace parts of the transcript with phrases of your choosing. For StreamingRecognize, this normalization only applies to stable partial transcripts (stability > 0.8) and final transcripts.
603    #[serde(rename = "transcriptNormalization")]
604    pub transcript_normalization: Option<TranscriptNormalization>,
605    /// Set to true to use an enhanced model for speech recognition. If `use_enhanced` is set to true and the `model` field is not set, then an appropriate enhanced model is chosen if an enhanced model exists for the audio. If `use_enhanced` is true and an enhanced version of the specified model does not exist, then the speech is recognized using the standard version of the specified model.
606    #[serde(rename = "useEnhanced")]
607    pub use_enhanced: Option<bool>,
608}
609
610impl common::Part for RecognitionConfig {}
611
612/// Description of audio data to be recognized.
613///
614/// This type is not used in any activity, and only used as *part* of another schema.
615///
616#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
617#[serde_with::serde_as]
618#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
619pub struct RecognitionMetadata {
620    /// Description of the content. Eg. "Recordings of federal supreme court hearings from 2012".
621    #[serde(rename = "audioTopic")]
622    pub audio_topic: Option<String>,
623    /// The industry vertical to which this speech recognition request most closely applies. This is most indicative of the topics contained in the audio. Use the 6-digit NAICS code to identify the industry vertical - see https://www.naics.com/search/.
624    #[serde(rename = "industryNaicsCodeOfAudio")]
625    pub industry_naics_code_of_audio: Option<u32>,
626    /// The use case most closely describing the audio content to be recognized.
627    #[serde(rename = "interactionType")]
628    pub interaction_type: Option<String>,
629    /// The audio type that most closely describes the audio being recognized.
630    #[serde(rename = "microphoneDistance")]
631    pub microphone_distance: Option<String>,
632    /// The original media the speech was recorded on.
633    #[serde(rename = "originalMediaType")]
634    pub original_media_type: Option<String>,
635    /// Mime type of the original audio file. For example `audio/m4a`, `audio/x-alaw-basic`, `audio/mp3`, `audio/3gpp`. A list of possible audio mime types is maintained at http://www.iana.org/assignments/media-types/media-types.xhtml#audio
636    #[serde(rename = "originalMimeType")]
637    pub original_mime_type: Option<String>,
638    /// The device used to make the recording. Examples 'Nexus 5X' or 'Polycom SoundStation IP 6000' or 'POTS' or 'VoIP' or 'Cardioid Microphone'.
639    #[serde(rename = "recordingDeviceName")]
640    pub recording_device_name: Option<String>,
641    /// The type of device the speech was recorded with.
642    #[serde(rename = "recordingDeviceType")]
643    pub recording_device_type: Option<String>,
644}
645
646impl common::Part for RecognitionMetadata {}
647
648/// The top-level message sent by the client for the `Recognize` method.
649///
650/// # Activities
651///
652/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
653/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
654///
655/// * [recognize speech](SpeechRecognizeCall) (request)
656#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
657#[serde_with::serde_as]
658#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
659pub struct RecognizeRequest {
660    /// Required. The audio data to be recognized.
661    pub audio: Option<RecognitionAudio>,
662    /// Required. Provides information to the recognizer that specifies how to process the request.
663    pub config: Option<RecognitionConfig>,
664}
665
666impl common::RequestValue for RecognizeRequest {}
667
668/// The only message returned to the client by the `Recognize` method. It contains the result as zero or more sequential `SpeechRecognitionResult` messages.
669///
670/// # Activities
671///
672/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
673/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
674///
675/// * [recognize speech](SpeechRecognizeCall) (response)
676#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
677#[serde_with::serde_as]
678#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
679pub struct RecognizeResponse {
680    /// The ID associated with the request. This is a unique ID specific only to the given request.
681    #[serde(rename = "requestId")]
682    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
683    pub request_id: Option<i64>,
684    /// Sequential list of transcription results corresponding to sequential portions of audio.
685    pub results: Option<Vec<SpeechRecognitionResult>>,
686    /// Provides information on adaptation behavior in response
687    #[serde(rename = "speechAdaptationInfo")]
688    pub speech_adaptation_info: Option<SpeechAdaptationInfo>,
689    /// When available, billed audio seconds for the corresponding request.
690    #[serde(rename = "totalBilledTime")]
691    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
692    pub total_billed_time: Option<chrono::Duration>,
693    /// Whether request used legacy asr models (was not automatically migrated to use conformer models).
694    #[serde(rename = "usingLegacyModels")]
695    pub using_legacy_models: Option<bool>,
696}
697
698impl common::ResponseResult for RecognizeResponse {}
699
700/// Config to enable speaker diarization.
701///
702/// This type is not used in any activity, and only used as *part* of another schema.
703///
704#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
705#[serde_with::serde_as]
706#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
707pub struct SpeakerDiarizationConfig {
708    /// If 'true', enables speaker detection for each recognized word in the top alternative of the recognition result using a speaker_label provided in the WordInfo.
709    #[serde(rename = "enableSpeakerDiarization")]
710    pub enable_speaker_diarization: Option<bool>,
711    /// Maximum number of speakers in the conversation. This range gives you more flexibility by allowing the system to automatically determine the correct number of speakers. If not set, the default value is 6.
712    #[serde(rename = "maxSpeakerCount")]
713    pub max_speaker_count: Option<i32>,
714    /// Minimum number of speakers in the conversation. This range gives you more flexibility by allowing the system to automatically determine the correct number of speakers. If not set, the default value is 2.
715    #[serde(rename = "minSpeakerCount")]
716    pub min_speaker_count: Option<i32>,
717    /// Output only. Unused.
718    #[serde(rename = "speakerTag")]
719    pub speaker_tag: Option<i32>,
720}
721
722impl common::Part for SpeakerDiarizationConfig {}
723
724/// Speech adaptation configuration.
725///
726/// This type is not used in any activity, and only used as *part* of another schema.
727///
728#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
729#[serde_with::serde_as]
730#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
731pub struct SpeechAdaptation {
732    /// Augmented Backus-Naur form (ABNF) is a standardized grammar notation comprised by a set of derivation rules. See specifications: https://www.w3.org/TR/speech-grammar
733    #[serde(rename = "abnfGrammar")]
734    pub abnf_grammar: Option<ABNFGrammar>,
735    /// A collection of custom classes. To specify the classes inline, leave the class' `name` blank and fill in the rest of its fields, giving it a unique `custom_class_id`. Refer to the inline defined class in phrase hints by its `custom_class_id`.
736    #[serde(rename = "customClasses")]
737    pub custom_classes: Option<Vec<CustomClass>>,
738    /// A collection of phrase set resource names to use.
739    #[serde(rename = "phraseSetReferences")]
740    pub phrase_set_references: Option<Vec<String>>,
741    /// A collection of phrase sets. To specify the hints inline, leave the phrase set's `name` blank and fill in the rest of its fields. Any phrase set can use any custom class.
742    #[serde(rename = "phraseSets")]
743    pub phrase_sets: Option<Vec<PhraseSet>>,
744}
745
746impl common::Part for SpeechAdaptation {}
747
748/// Information on speech adaptation use in results
749///
750/// This type is not used in any activity, and only used as *part* of another schema.
751///
752#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
753#[serde_with::serde_as]
754#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
755pub struct SpeechAdaptationInfo {
756    /// Whether there was a timeout when applying speech adaptation. If true, adaptation had no effect in the response transcript.
757    #[serde(rename = "adaptationTimeout")]
758    pub adaptation_timeout: Option<bool>,
759    /// If set, returns a message specifying which part of the speech adaptation request timed out.
760    #[serde(rename = "timeoutMessage")]
761    pub timeout_message: Option<String>,
762}
763
764impl common::Part for SpeechAdaptationInfo {}
765
766/// Provides "hints" to the speech recognizer to favor specific words and phrases in the results.
767///
768/// This type is not used in any activity, and only used as *part* of another schema.
769///
770#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
771#[serde_with::serde_as]
772#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
773pub struct SpeechContext {
774    /// Hint Boost. Positive value will increase the probability that a specific phrase will be recognized over other similar sounding phrases. The higher the boost, the higher the chance of false positive recognition as well. Negative boost values would correspond to anti-biasing. Anti-biasing is not enabled, so negative boost will simply be ignored. Though `boost` can accept a wide range of positive values, most use cases are best served with values between 0 and 20. We recommend using a binary search approach to finding the optimal value for your use case.
775    pub boost: Option<f32>,
776    /// A list of strings containing words and phrases "hints" so that the speech recognition is more likely to recognize them. This can be used to improve the accuracy for specific words and phrases, for example, if specific commands are typically spoken by the user. This can also be used to add additional words to the vocabulary of the recognizer. See [usage limits](https://cloud.google.com/speech-to-text/quotas#content). List items can also be set to classes for groups of words that represent common concepts that occur in natural language. For example, rather than providing phrase hints for every month of the year, using the $MONTH class improves the likelihood of correctly transcribing audio that includes months.
777    pub phrases: Option<Vec<String>>,
778}
779
780impl common::Part for SpeechContext {}
781
782/// Alternative hypotheses (a.k.a. n-best list).
783///
784/// This type is not used in any activity, and only used as *part* of another schema.
785///
786#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
787#[serde_with::serde_as]
788#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
789pub struct SpeechRecognitionAlternative {
790    /// The confidence estimate between 0.0 and 1.0. A higher number indicates an estimated greater likelihood that the recognized words are correct. This field is set only for the top alternative of a non-streaming result or, of a streaming result where `is_final=true`. This field is not guaranteed to be accurate and users should not rely on it to be always provided. The default of 0.0 is a sentinel value indicating `confidence` was not set.
791    pub confidence: Option<f32>,
792    /// Transcript text representing the words that the user spoke. In languages that use spaces to separate words, the transcript might have a leading space if it isn't the first result. You can concatenate each result to obtain the full transcript without using a separator.
793    pub transcript: Option<String>,
794    /// A list of word-specific information for each recognized word. Note: When `enable_speaker_diarization` is true, you will see all the words from the beginning of the audio.
795    pub words: Option<Vec<WordInfo>>,
796}
797
798impl common::Part for SpeechRecognitionAlternative {}
799
800/// A speech recognition result corresponding to a portion of the audio.
801///
802/// This type is not used in any activity, and only used as *part* of another schema.
803///
804#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
805#[serde_with::serde_as]
806#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
807pub struct SpeechRecognitionResult {
808    /// May contain one or more recognition hypotheses (up to the maximum specified in `max_alternatives`). These alternatives are ordered in terms of accuracy, with the top (first) alternative being the most probable, as ranked by the recognizer.
809    pub alternatives: Option<Vec<SpeechRecognitionAlternative>>,
810    /// For multi-channel audio, this is the channel number corresponding to the recognized result for the audio from that channel. For audio_channel_count = N, its output values can range from '1' to 'N'.
811    #[serde(rename = "channelTag")]
812    pub channel_tag: Option<i32>,
813    /// Output only. The [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag of the language in this result. This language code was detected to have the most likelihood of being spoken in the audio.
814    #[serde(rename = "languageCode")]
815    pub language_code: Option<String>,
816    /// Time offset of the end of this result relative to the beginning of the audio.
817    #[serde(rename = "resultEndTime")]
818    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
819    pub result_end_time: Option<chrono::Duration>,
820}
821
822impl common::Part for SpeechRecognitionResult {}
823
824/// The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).
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 Status {
832    /// The status code, which should be an enum value of google.rpc.Code.
833    pub code: Option<i32>,
834    /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
835    pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
836    /// A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
837    pub message: Option<String>,
838}
839
840impl common::Part for Status {}
841
842/// Transcription normalization configuration. Use transcription normalization to automatically replace parts of the transcript with phrases of your choosing. For StreamingRecognize, this normalization only applies to stable partial transcripts (stability > 0.8) and final transcripts.
843///
844/// This type is not used in any activity, and only used as *part* of another schema.
845///
846#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
847#[serde_with::serde_as]
848#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
849pub struct TranscriptNormalization {
850    /// A list of replacement entries. We will perform replacement with one entry at a time. For example, the second entry in ["cat" => "dog", "mountain cat" => "mountain dog"] will never be applied because we will always process the first entry before it. At most 100 entries.
851    pub entries: Option<Vec<Entry>>,
852}
853
854impl common::Part for TranscriptNormalization {}
855
856/// Specifies an optional destination for the recognition results.
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 TranscriptOutputConfig {
864    /// Specifies a Cloud Storage URI for the recognition results. Must be specified in the format: `gs://bucket_name/object_name`, and the bucket must already exist.
865    #[serde(rename = "gcsUri")]
866    pub gcs_uri: Option<String>,
867}
868
869impl common::Part for TranscriptOutputConfig {}
870
871/// Word-specific information for recognized words.
872///
873/// This type is not used in any activity, and only used as *part* of another schema.
874///
875#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
876#[serde_with::serde_as]
877#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
878pub struct WordInfo {
879    /// The confidence estimate between 0.0 and 1.0. A higher number indicates an estimated greater likelihood that the recognized words are correct. This field is set only for the top alternative of a non-streaming result or, of a streaming result where `is_final=true`. This field is not guaranteed to be accurate and users should not rely on it to be always provided. The default of 0.0 is a sentinel value indicating `confidence` was not set.
880    pub confidence: Option<f32>,
881    /// Time offset relative to the beginning of the audio, and corresponding to the end of the spoken word. This field is only set if `enable_word_time_offsets=true` and only in the top hypothesis. This is an experimental feature and the accuracy of the time offset can vary.
882    #[serde(rename = "endTime")]
883    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
884    pub end_time: Option<chrono::Duration>,
885    /// Output only. A label value assigned for every unique speaker within the audio. This field specifies which speaker was detected to have spoken this word. For some models, like medical_conversation this can be actual speaker role, for example "patient" or "provider", but generally this would be a number identifying a speaker. This field is only set if enable_speaker_diarization = 'true' and only for the top alternative.
886    #[serde(rename = "speakerLabel")]
887    pub speaker_label: Option<String>,
888    /// Output only. A distinct integer value is assigned for every speaker within the audio. This field specifies which one of those speakers was detected to have spoken this word. Value ranges from '1' to diarization_speaker_count. speaker_tag is set if enable_speaker_diarization = 'true' and only for the top alternative. Note: Use speaker_label instead.
889    #[serde(rename = "speakerTag")]
890    pub speaker_tag: Option<i32>,
891    /// Time offset relative to the beginning of the audio, and corresponding to the start of the spoken word. This field is only set if `enable_word_time_offsets=true` and only in the top hypothesis. This is an experimental feature and the accuracy of the time offset can vary.
892    #[serde(rename = "startTime")]
893    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
894    pub start_time: Option<chrono::Duration>,
895    /// The word corresponding to this set of information.
896    pub word: Option<String>,
897}
898
899impl common::Part for WordInfo {}
900
901// ###################
902// MethodBuilders ###
903// #################
904
905/// A builder providing access to all methods supported on *operation* resources.
906/// It is not used directly, but through the [`Speech`] hub.
907///
908/// # Example
909///
910/// Instantiate a resource builder
911///
912/// ```test_harness,no_run
913/// extern crate hyper;
914/// extern crate hyper_rustls;
915/// extern crate google_speech1 as speech1;
916///
917/// # async fn dox() {
918/// use speech1::{Speech, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
919///
920/// let secret: yup_oauth2::ApplicationSecret = Default::default();
921/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
922///     .with_native_roots()
923///     .unwrap()
924///     .https_only()
925///     .enable_http2()
926///     .build();
927///
928/// let executor = hyper_util::rt::TokioExecutor::new();
929/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
930///     secret,
931///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
932///     yup_oauth2::client::CustomHyperClientBuilder::from(
933///         hyper_util::client::legacy::Client::builder(executor).build(connector),
934///     ),
935/// ).build().await.unwrap();
936///
937/// let client = hyper_util::client::legacy::Client::builder(
938///     hyper_util::rt::TokioExecutor::new()
939/// )
940/// .build(
941///     hyper_rustls::HttpsConnectorBuilder::new()
942///         .with_native_roots()
943///         .unwrap()
944///         .https_or_http()
945///         .enable_http2()
946///         .build()
947/// );
948/// let mut hub = Speech::new(client, auth);
949/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
950/// // like `get(...)` and `list(...)`
951/// // to build up your call.
952/// let rb = hub.operations();
953/// # }
954/// ```
955pub struct OperationMethods<'a, C>
956where
957    C: 'a,
958{
959    hub: &'a Speech<C>,
960}
961
962impl<'a, C> common::MethodsBuilder for OperationMethods<'a, C> {}
963
964impl<'a, C> OperationMethods<'a, C> {
965    /// Create a builder to help you perform the following task:
966    ///
967    /// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
968    ///
969    /// # Arguments
970    ///
971    /// * `name` - The name of the operation resource.
972    pub fn get(&self, name: &str) -> OperationGetCall<'a, C> {
973        OperationGetCall {
974            hub: self.hub,
975            _name: name.to_string(),
976            _delegate: Default::default(),
977            _additional_params: Default::default(),
978            _scopes: Default::default(),
979        }
980    }
981
982    /// Create a builder to help you perform the following task:
983    ///
984    /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
985    pub fn list(&self) -> OperationListCall<'a, C> {
986        OperationListCall {
987            hub: self.hub,
988            _return_partial_success: Default::default(),
989            _page_token: Default::default(),
990            _page_size: Default::default(),
991            _name: Default::default(),
992            _filter: Default::default(),
993            _delegate: Default::default(),
994            _additional_params: Default::default(),
995            _scopes: Default::default(),
996        }
997    }
998}
999
1000/// A builder providing access to all methods supported on *project* resources.
1001/// It is not used directly, but through the [`Speech`] hub.
1002///
1003/// # Example
1004///
1005/// Instantiate a resource builder
1006///
1007/// ```test_harness,no_run
1008/// extern crate hyper;
1009/// extern crate hyper_rustls;
1010/// extern crate google_speech1 as speech1;
1011///
1012/// # async fn dox() {
1013/// use speech1::{Speech, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1014///
1015/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1016/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1017///     .with_native_roots()
1018///     .unwrap()
1019///     .https_only()
1020///     .enable_http2()
1021///     .build();
1022///
1023/// let executor = hyper_util::rt::TokioExecutor::new();
1024/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1025///     secret,
1026///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1027///     yup_oauth2::client::CustomHyperClientBuilder::from(
1028///         hyper_util::client::legacy::Client::builder(executor).build(connector),
1029///     ),
1030/// ).build().await.unwrap();
1031///
1032/// let client = hyper_util::client::legacy::Client::builder(
1033///     hyper_util::rt::TokioExecutor::new()
1034/// )
1035/// .build(
1036///     hyper_rustls::HttpsConnectorBuilder::new()
1037///         .with_native_roots()
1038///         .unwrap()
1039///         .https_or_http()
1040///         .enable_http2()
1041///         .build()
1042/// );
1043/// let mut hub = Speech::new(client, auth);
1044/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1045/// // like `locations_custom_classes_create(...)`, `locations_custom_classes_delete(...)`, `locations_custom_classes_get(...)`, `locations_custom_classes_list(...)`, `locations_custom_classes_patch(...)`, `locations_phrase_sets_create(...)`, `locations_phrase_sets_delete(...)`, `locations_phrase_sets_get(...)`, `locations_phrase_sets_list(...)` and `locations_phrase_sets_patch(...)`
1046/// // to build up your call.
1047/// let rb = hub.projects();
1048/// # }
1049/// ```
1050pub struct ProjectMethods<'a, C>
1051where
1052    C: 'a,
1053{
1054    hub: &'a Speech<C>,
1055}
1056
1057impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
1058
1059impl<'a, C> ProjectMethods<'a, C> {
1060    /// Create a builder to help you perform the following task:
1061    ///
1062    /// Create a custom class.
1063    ///
1064    /// # Arguments
1065    ///
1066    /// * `request` - No description provided.
1067    /// * `parent` - Required. The parent resource where this custom class will be created. Format: `projects/{project}/locations/{location}/customClasses` Speech-to-Text supports three locations: `global`, `us` (US North America), and `eu` (Europe). If you are calling the `speech.googleapis.com` endpoint, use the `global` location. To specify a region, use a [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) with matching `us` or `eu` location value.
1068    pub fn locations_custom_classes_create(
1069        &self,
1070        request: CreateCustomClassRequest,
1071        parent: &str,
1072    ) -> ProjectLocationCustomClassCreateCall<'a, C> {
1073        ProjectLocationCustomClassCreateCall {
1074            hub: self.hub,
1075            _request: request,
1076            _parent: parent.to_string(),
1077            _delegate: Default::default(),
1078            _additional_params: Default::default(),
1079            _scopes: Default::default(),
1080        }
1081    }
1082
1083    /// Create a builder to help you perform the following task:
1084    ///
1085    /// Delete a custom class.
1086    ///
1087    /// # Arguments
1088    ///
1089    /// * `name` - Required. The name of the custom class to delete. Format: `projects/{project}/locations/{location}/customClasses/{custom_class}` Speech-to-Text supports three locations: `global`, `us` (US North America), and `eu` (Europe). If you are calling the `speech.googleapis.com` endpoint, use the `global` location. To specify a region, use a [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) with matching `us` or `eu` location value.
1090    pub fn locations_custom_classes_delete(
1091        &self,
1092        name: &str,
1093    ) -> ProjectLocationCustomClassDeleteCall<'a, C> {
1094        ProjectLocationCustomClassDeleteCall {
1095            hub: self.hub,
1096            _name: name.to_string(),
1097            _delegate: Default::default(),
1098            _additional_params: Default::default(),
1099            _scopes: Default::default(),
1100        }
1101    }
1102
1103    /// Create a builder to help you perform the following task:
1104    ///
1105    /// Get a custom class.
1106    ///
1107    /// # Arguments
1108    ///
1109    /// * `name` - Required. The name of the custom class to retrieve. Format: `projects/{project}/locations/{location}/customClasses/{custom_class}`
1110    pub fn locations_custom_classes_get(
1111        &self,
1112        name: &str,
1113    ) -> ProjectLocationCustomClassGetCall<'a, C> {
1114        ProjectLocationCustomClassGetCall {
1115            hub: self.hub,
1116            _name: name.to_string(),
1117            _delegate: Default::default(),
1118            _additional_params: Default::default(),
1119            _scopes: Default::default(),
1120        }
1121    }
1122
1123    /// Create a builder to help you perform the following task:
1124    ///
1125    /// List custom classes.
1126    ///
1127    /// # Arguments
1128    ///
1129    /// * `parent` - Required. The parent, which owns this collection of custom classes. Format: `projects/{project}/locations/{location}/customClasses` Speech-to-Text supports three locations: `global`, `us` (US North America), and `eu` (Europe). If you are calling the `speech.googleapis.com` endpoint, use the `global` location. To specify a region, use a [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) with matching `us` or `eu` location value.
1130    pub fn locations_custom_classes_list(
1131        &self,
1132        parent: &str,
1133    ) -> ProjectLocationCustomClassListCall<'a, C> {
1134        ProjectLocationCustomClassListCall {
1135            hub: self.hub,
1136            _parent: parent.to_string(),
1137            _page_token: Default::default(),
1138            _page_size: Default::default(),
1139            _delegate: Default::default(),
1140            _additional_params: Default::default(),
1141            _scopes: Default::default(),
1142        }
1143    }
1144
1145    /// Create a builder to help you perform the following task:
1146    ///
1147    /// Update a custom class.
1148    ///
1149    /// # Arguments
1150    ///
1151    /// * `request` - No description provided.
1152    /// * `name` - The resource name of the custom class.
1153    pub fn locations_custom_classes_patch(
1154        &self,
1155        request: CustomClass,
1156        name: &str,
1157    ) -> ProjectLocationCustomClassPatchCall<'a, C> {
1158        ProjectLocationCustomClassPatchCall {
1159            hub: self.hub,
1160            _request: request,
1161            _name: name.to_string(),
1162            _update_mask: Default::default(),
1163            _delegate: Default::default(),
1164            _additional_params: Default::default(),
1165            _scopes: Default::default(),
1166        }
1167    }
1168
1169    /// Create a builder to help you perform the following task:
1170    ///
1171    /// Create a set of phrase hints. Each item in the set can be a single word or a multi-word phrase. The items in the PhraseSet are favored by the recognition model when you send a call that includes the PhraseSet.
1172    ///
1173    /// # Arguments
1174    ///
1175    /// * `request` - No description provided.
1176    /// * `parent` - Required. The parent resource where this phrase set will be created. Format: `projects/{project}/locations/{location}` Speech-to-Text supports three locations: `global`, `us` (US North America), and `eu` (Europe). If you are calling the `speech.googleapis.com` endpoint, use the `global` location. To specify a region, use a [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) with matching `us` or `eu` location value.
1177    pub fn locations_phrase_sets_create(
1178        &self,
1179        request: CreatePhraseSetRequest,
1180        parent: &str,
1181    ) -> ProjectLocationPhraseSetCreateCall<'a, C> {
1182        ProjectLocationPhraseSetCreateCall {
1183            hub: self.hub,
1184            _request: request,
1185            _parent: parent.to_string(),
1186            _delegate: Default::default(),
1187            _additional_params: Default::default(),
1188            _scopes: Default::default(),
1189        }
1190    }
1191
1192    /// Create a builder to help you perform the following task:
1193    ///
1194    /// Delete a phrase set.
1195    ///
1196    /// # Arguments
1197    ///
1198    /// * `name` - Required. The name of the phrase set to delete. Format: `projects/{project}/locations/{location}/phraseSets/{phrase_set}`
1199    pub fn locations_phrase_sets_delete(
1200        &self,
1201        name: &str,
1202    ) -> ProjectLocationPhraseSetDeleteCall<'a, C> {
1203        ProjectLocationPhraseSetDeleteCall {
1204            hub: self.hub,
1205            _name: name.to_string(),
1206            _delegate: Default::default(),
1207            _additional_params: Default::default(),
1208            _scopes: Default::default(),
1209        }
1210    }
1211
1212    /// Create a builder to help you perform the following task:
1213    ///
1214    /// Get a phrase set.
1215    ///
1216    /// # Arguments
1217    ///
1218    /// * `name` - Required. The name of the phrase set to retrieve. Format: `projects/{project}/locations/{location}/phraseSets/{phrase_set}` Speech-to-Text supports three locations: `global`, `us` (US North America), and `eu` (Europe). If you are calling the `speech.googleapis.com` endpoint, use the `global` location. To specify a region, use a [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) with matching `us` or `eu` location value.
1219    pub fn locations_phrase_sets_get(&self, name: &str) -> ProjectLocationPhraseSetGetCall<'a, C> {
1220        ProjectLocationPhraseSetGetCall {
1221            hub: self.hub,
1222            _name: name.to_string(),
1223            _delegate: Default::default(),
1224            _additional_params: Default::default(),
1225            _scopes: Default::default(),
1226        }
1227    }
1228
1229    /// Create a builder to help you perform the following task:
1230    ///
1231    /// List phrase sets.
1232    ///
1233    /// # Arguments
1234    ///
1235    /// * `parent` - Required. The parent, which owns this collection of phrase set. Format: `projects/{project}/locations/{location}` Speech-to-Text supports three locations: `global`, `us` (US North America), and `eu` (Europe). If you are calling the `speech.googleapis.com` endpoint, use the `global` location. To specify a region, use a [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) with matching `us` or `eu` location value.
1236    pub fn locations_phrase_sets_list(
1237        &self,
1238        parent: &str,
1239    ) -> ProjectLocationPhraseSetListCall<'a, C> {
1240        ProjectLocationPhraseSetListCall {
1241            hub: self.hub,
1242            _parent: parent.to_string(),
1243            _page_token: Default::default(),
1244            _page_size: Default::default(),
1245            _delegate: Default::default(),
1246            _additional_params: Default::default(),
1247            _scopes: Default::default(),
1248        }
1249    }
1250
1251    /// Create a builder to help you perform the following task:
1252    ///
1253    /// Update a phrase set.
1254    ///
1255    /// # Arguments
1256    ///
1257    /// * `request` - No description provided.
1258    /// * `name` - The resource name of the phrase set.
1259    pub fn locations_phrase_sets_patch(
1260        &self,
1261        request: PhraseSet,
1262        name: &str,
1263    ) -> ProjectLocationPhraseSetPatchCall<'a, C> {
1264        ProjectLocationPhraseSetPatchCall {
1265            hub: self.hub,
1266            _request: request,
1267            _name: name.to_string(),
1268            _update_mask: Default::default(),
1269            _delegate: Default::default(),
1270            _additional_params: Default::default(),
1271            _scopes: Default::default(),
1272        }
1273    }
1274}
1275
1276/// A builder providing access to all methods supported on *speech* resources.
1277/// It is not used directly, but through the [`Speech`] hub.
1278///
1279/// # Example
1280///
1281/// Instantiate a resource builder
1282///
1283/// ```test_harness,no_run
1284/// extern crate hyper;
1285/// extern crate hyper_rustls;
1286/// extern crate google_speech1 as speech1;
1287///
1288/// # async fn dox() {
1289/// use speech1::{Speech, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1290///
1291/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1292/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1293///     .with_native_roots()
1294///     .unwrap()
1295///     .https_only()
1296///     .enable_http2()
1297///     .build();
1298///
1299/// let executor = hyper_util::rt::TokioExecutor::new();
1300/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1301///     secret,
1302///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1303///     yup_oauth2::client::CustomHyperClientBuilder::from(
1304///         hyper_util::client::legacy::Client::builder(executor).build(connector),
1305///     ),
1306/// ).build().await.unwrap();
1307///
1308/// let client = hyper_util::client::legacy::Client::builder(
1309///     hyper_util::rt::TokioExecutor::new()
1310/// )
1311/// .build(
1312///     hyper_rustls::HttpsConnectorBuilder::new()
1313///         .with_native_roots()
1314///         .unwrap()
1315///         .https_or_http()
1316///         .enable_http2()
1317///         .build()
1318/// );
1319/// let mut hub = Speech::new(client, auth);
1320/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1321/// // like `longrunningrecognize(...)` and `recognize(...)`
1322/// // to build up your call.
1323/// let rb = hub.speech();
1324/// # }
1325/// ```
1326pub struct SpeechMethods<'a, C>
1327where
1328    C: 'a,
1329{
1330    hub: &'a Speech<C>,
1331}
1332
1333impl<'a, C> common::MethodsBuilder for SpeechMethods<'a, C> {}
1334
1335impl<'a, C> SpeechMethods<'a, C> {
1336    /// Create a builder to help you perform the following task:
1337    ///
1338    /// Performs asynchronous speech recognition: receive results via the google.longrunning.Operations interface. Returns either an `Operation.error` or an `Operation.response` which contains a `LongRunningRecognizeResponse` message. For more information on asynchronous speech recognition, see the [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize).
1339    ///
1340    /// # Arguments
1341    ///
1342    /// * `request` - No description provided.
1343    pub fn longrunningrecognize(
1344        &self,
1345        request: LongRunningRecognizeRequest,
1346    ) -> SpeechLongrunningrecognizeCall<'a, C> {
1347        SpeechLongrunningrecognizeCall {
1348            hub: self.hub,
1349            _request: request,
1350            _delegate: Default::default(),
1351            _additional_params: Default::default(),
1352            _scopes: Default::default(),
1353        }
1354    }
1355
1356    /// Create a builder to help you perform the following task:
1357    ///
1358    /// Performs synchronous speech recognition: receive results after all audio has been sent and processed.
1359    ///
1360    /// # Arguments
1361    ///
1362    /// * `request` - No description provided.
1363    pub fn recognize(&self, request: RecognizeRequest) -> SpeechRecognizeCall<'a, C> {
1364        SpeechRecognizeCall {
1365            hub: self.hub,
1366            _request: request,
1367            _delegate: Default::default(),
1368            _additional_params: Default::default(),
1369            _scopes: Default::default(),
1370        }
1371    }
1372}
1373
1374// ###################
1375// CallBuilders   ###
1376// #################
1377
1378/// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
1379///
1380/// A builder for the *get* method supported by a *operation* resource.
1381/// It is not used directly, but through a [`OperationMethods`] instance.
1382///
1383/// # Example
1384///
1385/// Instantiate a resource method builder
1386///
1387/// ```test_harness,no_run
1388/// # extern crate hyper;
1389/// # extern crate hyper_rustls;
1390/// # extern crate google_speech1 as speech1;
1391/// # async fn dox() {
1392/// # use speech1::{Speech, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1393///
1394/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1395/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1396/// #     .with_native_roots()
1397/// #     .unwrap()
1398/// #     .https_only()
1399/// #     .enable_http2()
1400/// #     .build();
1401///
1402/// # let executor = hyper_util::rt::TokioExecutor::new();
1403/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1404/// #     secret,
1405/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1406/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1407/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1408/// #     ),
1409/// # ).build().await.unwrap();
1410///
1411/// # let client = hyper_util::client::legacy::Client::builder(
1412/// #     hyper_util::rt::TokioExecutor::new()
1413/// # )
1414/// # .build(
1415/// #     hyper_rustls::HttpsConnectorBuilder::new()
1416/// #         .with_native_roots()
1417/// #         .unwrap()
1418/// #         .https_or_http()
1419/// #         .enable_http2()
1420/// #         .build()
1421/// # );
1422/// # let mut hub = Speech::new(client, auth);
1423/// // You can configure optional parameters by calling the respective setters at will, and
1424/// // execute the final call using `doit()`.
1425/// // Values shown here are possibly random and not representative !
1426/// let result = hub.operations().get("name")
1427///              .doit().await;
1428/// # }
1429/// ```
1430pub struct OperationGetCall<'a, C>
1431where
1432    C: 'a,
1433{
1434    hub: &'a Speech<C>,
1435    _name: String,
1436    _delegate: Option<&'a mut dyn common::Delegate>,
1437    _additional_params: HashMap<String, String>,
1438    _scopes: BTreeSet<String>,
1439}
1440
1441impl<'a, C> common::CallBuilder for OperationGetCall<'a, C> {}
1442
1443impl<'a, C> OperationGetCall<'a, C>
1444where
1445    C: common::Connector,
1446{
1447    /// Perform the operation you have build so far.
1448    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
1449        use std::borrow::Cow;
1450        use std::io::{Read, Seek};
1451
1452        use common::{url::Params, ToParts};
1453        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1454
1455        let mut dd = common::DefaultDelegate;
1456        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1457        dlg.begin(common::MethodInfo {
1458            id: "speech.operations.get",
1459            http_method: hyper::Method::GET,
1460        });
1461
1462        for &field in ["alt", "name"].iter() {
1463            if self._additional_params.contains_key(field) {
1464                dlg.finished(false);
1465                return Err(common::Error::FieldClash(field));
1466            }
1467        }
1468
1469        let mut params = Params::with_capacity(3 + self._additional_params.len());
1470        params.push("name", self._name);
1471
1472        params.extend(self._additional_params.iter());
1473
1474        params.push("alt", "json");
1475        let mut url = self.hub._base_url.clone() + "v1/operations/{+name}";
1476        if self._scopes.is_empty() {
1477            self._scopes
1478                .insert(Scope::CloudPlatform.as_ref().to_string());
1479        }
1480
1481        #[allow(clippy::single_element_loop)]
1482        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1483            url = params.uri_replacement(url, param_name, find_this, true);
1484        }
1485        {
1486            let to_remove = ["name"];
1487            params.remove_params(&to_remove);
1488        }
1489
1490        let url = params.parse_with_url(&url);
1491
1492        loop {
1493            let token = match self
1494                .hub
1495                .auth
1496                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1497                .await
1498            {
1499                Ok(token) => token,
1500                Err(e) => match dlg.token(e) {
1501                    Ok(token) => token,
1502                    Err(e) => {
1503                        dlg.finished(false);
1504                        return Err(common::Error::MissingToken(e));
1505                    }
1506                },
1507            };
1508            let mut req_result = {
1509                let client = &self.hub.client;
1510                dlg.pre_request();
1511                let mut req_builder = hyper::Request::builder()
1512                    .method(hyper::Method::GET)
1513                    .uri(url.as_str())
1514                    .header(USER_AGENT, self.hub._user_agent.clone());
1515
1516                if let Some(token) = token.as_ref() {
1517                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1518                }
1519
1520                let request = req_builder
1521                    .header(CONTENT_LENGTH, 0_u64)
1522                    .body(common::to_body::<String>(None));
1523
1524                client.request(request.unwrap()).await
1525            };
1526
1527            match req_result {
1528                Err(err) => {
1529                    if let common::Retry::After(d) = dlg.http_error(&err) {
1530                        sleep(d).await;
1531                        continue;
1532                    }
1533                    dlg.finished(false);
1534                    return Err(common::Error::HttpError(err));
1535                }
1536                Ok(res) => {
1537                    let (mut parts, body) = res.into_parts();
1538                    let mut body = common::Body::new(body);
1539                    if !parts.status.is_success() {
1540                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1541                        let error = serde_json::from_str(&common::to_string(&bytes));
1542                        let response = common::to_response(parts, bytes.into());
1543
1544                        if let common::Retry::After(d) =
1545                            dlg.http_failure(&response, error.as_ref().ok())
1546                        {
1547                            sleep(d).await;
1548                            continue;
1549                        }
1550
1551                        dlg.finished(false);
1552
1553                        return Err(match error {
1554                            Ok(value) => common::Error::BadRequest(value),
1555                            _ => common::Error::Failure(response),
1556                        });
1557                    }
1558                    let response = {
1559                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1560                        let encoded = common::to_string(&bytes);
1561                        match serde_json::from_str(&encoded) {
1562                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1563                            Err(error) => {
1564                                dlg.response_json_decode_error(&encoded, &error);
1565                                return Err(common::Error::JsonDecodeError(
1566                                    encoded.to_string(),
1567                                    error,
1568                                ));
1569                            }
1570                        }
1571                    };
1572
1573                    dlg.finished(true);
1574                    return Ok(response);
1575                }
1576            }
1577        }
1578    }
1579
1580    /// The name of the operation resource.
1581    ///
1582    /// Sets the *name* path property to the given value.
1583    ///
1584    /// Even though the property as already been set when instantiating this call,
1585    /// we provide this method for API completeness.
1586    pub fn name(mut self, new_value: &str) -> OperationGetCall<'a, C> {
1587        self._name = new_value.to_string();
1588        self
1589    }
1590    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1591    /// while executing the actual API request.
1592    ///
1593    /// ````text
1594    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1595    /// ````
1596    ///
1597    /// Sets the *delegate* property to the given value.
1598    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OperationGetCall<'a, C> {
1599        self._delegate = Some(new_value);
1600        self
1601    }
1602
1603    /// Set any additional parameter of the query string used in the request.
1604    /// It should be used to set parameters which are not yet available through their own
1605    /// setters.
1606    ///
1607    /// Please note that this method must not be used to set any of the known parameters
1608    /// which have their own setter method. If done anyway, the request will fail.
1609    ///
1610    /// # Additional Parameters
1611    ///
1612    /// * *$.xgafv* (query-string) - V1 error format.
1613    /// * *access_token* (query-string) - OAuth access token.
1614    /// * *alt* (query-string) - Data format for response.
1615    /// * *callback* (query-string) - JSONP
1616    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1617    /// * *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.
1618    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1619    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1620    /// * *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.
1621    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1622    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1623    pub fn param<T>(mut self, name: T, value: T) -> OperationGetCall<'a, C>
1624    where
1625        T: AsRef<str>,
1626    {
1627        self._additional_params
1628            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1629        self
1630    }
1631
1632    /// Identifies the authorization scope for the method you are building.
1633    ///
1634    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1635    /// [`Scope::CloudPlatform`].
1636    ///
1637    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1638    /// tokens for more than one scope.
1639    ///
1640    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1641    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1642    /// sufficient, a read-write scope will do as well.
1643    pub fn add_scope<St>(mut self, scope: St) -> OperationGetCall<'a, C>
1644    where
1645        St: AsRef<str>,
1646    {
1647        self._scopes.insert(String::from(scope.as_ref()));
1648        self
1649    }
1650    /// Identifies the authorization scope(s) for the method you are building.
1651    ///
1652    /// See [`Self::add_scope()`] for details.
1653    pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationGetCall<'a, C>
1654    where
1655        I: IntoIterator<Item = St>,
1656        St: AsRef<str>,
1657    {
1658        self._scopes
1659            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1660        self
1661    }
1662
1663    /// Removes all scopes, and no default scope will be used either.
1664    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1665    /// for details).
1666    pub fn clear_scopes(mut self) -> OperationGetCall<'a, C> {
1667        self._scopes.clear();
1668        self
1669    }
1670}
1671
1672/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
1673///
1674/// A builder for the *list* method supported by a *operation* resource.
1675/// It is not used directly, but through a [`OperationMethods`] instance.
1676///
1677/// # Example
1678///
1679/// Instantiate a resource method builder
1680///
1681/// ```test_harness,no_run
1682/// # extern crate hyper;
1683/// # extern crate hyper_rustls;
1684/// # extern crate google_speech1 as speech1;
1685/// # async fn dox() {
1686/// # use speech1::{Speech, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1687///
1688/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1689/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1690/// #     .with_native_roots()
1691/// #     .unwrap()
1692/// #     .https_only()
1693/// #     .enable_http2()
1694/// #     .build();
1695///
1696/// # let executor = hyper_util::rt::TokioExecutor::new();
1697/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1698/// #     secret,
1699/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1700/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1701/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1702/// #     ),
1703/// # ).build().await.unwrap();
1704///
1705/// # let client = hyper_util::client::legacy::Client::builder(
1706/// #     hyper_util::rt::TokioExecutor::new()
1707/// # )
1708/// # .build(
1709/// #     hyper_rustls::HttpsConnectorBuilder::new()
1710/// #         .with_native_roots()
1711/// #         .unwrap()
1712/// #         .https_or_http()
1713/// #         .enable_http2()
1714/// #         .build()
1715/// # );
1716/// # let mut hub = Speech::new(client, auth);
1717/// // You can configure optional parameters by calling the respective setters at will, and
1718/// // execute the final call using `doit()`.
1719/// // Values shown here are possibly random and not representative !
1720/// let result = hub.operations().list()
1721///              .return_partial_success(false)
1722///              .page_token("amet.")
1723///              .page_size(-59)
1724///              .name("amet.")
1725///              .filter("duo")
1726///              .doit().await;
1727/// # }
1728/// ```
1729pub struct OperationListCall<'a, C>
1730where
1731    C: 'a,
1732{
1733    hub: &'a Speech<C>,
1734    _return_partial_success: Option<bool>,
1735    _page_token: Option<String>,
1736    _page_size: Option<i32>,
1737    _name: Option<String>,
1738    _filter: Option<String>,
1739    _delegate: Option<&'a mut dyn common::Delegate>,
1740    _additional_params: HashMap<String, String>,
1741    _scopes: BTreeSet<String>,
1742}
1743
1744impl<'a, C> common::CallBuilder for OperationListCall<'a, C> {}
1745
1746impl<'a, C> OperationListCall<'a, C>
1747where
1748    C: common::Connector,
1749{
1750    /// Perform the operation you have build so far.
1751    pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
1752        use std::borrow::Cow;
1753        use std::io::{Read, Seek};
1754
1755        use common::{url::Params, ToParts};
1756        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1757
1758        let mut dd = common::DefaultDelegate;
1759        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1760        dlg.begin(common::MethodInfo {
1761            id: "speech.operations.list",
1762            http_method: hyper::Method::GET,
1763        });
1764
1765        for &field in [
1766            "alt",
1767            "returnPartialSuccess",
1768            "pageToken",
1769            "pageSize",
1770            "name",
1771            "filter",
1772        ]
1773        .iter()
1774        {
1775            if self._additional_params.contains_key(field) {
1776                dlg.finished(false);
1777                return Err(common::Error::FieldClash(field));
1778            }
1779        }
1780
1781        let mut params = Params::with_capacity(7 + self._additional_params.len());
1782        if let Some(value) = self._return_partial_success.as_ref() {
1783            params.push("returnPartialSuccess", value.to_string());
1784        }
1785        if let Some(value) = self._page_token.as_ref() {
1786            params.push("pageToken", value);
1787        }
1788        if let Some(value) = self._page_size.as_ref() {
1789            params.push("pageSize", value.to_string());
1790        }
1791        if let Some(value) = self._name.as_ref() {
1792            params.push("name", value);
1793        }
1794        if let Some(value) = self._filter.as_ref() {
1795            params.push("filter", value);
1796        }
1797
1798        params.extend(self._additional_params.iter());
1799
1800        params.push("alt", "json");
1801        let mut url = self.hub._base_url.clone() + "v1/operations";
1802        if self._scopes.is_empty() {
1803            self._scopes
1804                .insert(Scope::CloudPlatform.as_ref().to_string());
1805        }
1806
1807        let url = params.parse_with_url(&url);
1808
1809        loop {
1810            let token = match self
1811                .hub
1812                .auth
1813                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1814                .await
1815            {
1816                Ok(token) => token,
1817                Err(e) => match dlg.token(e) {
1818                    Ok(token) => token,
1819                    Err(e) => {
1820                        dlg.finished(false);
1821                        return Err(common::Error::MissingToken(e));
1822                    }
1823                },
1824            };
1825            let mut req_result = {
1826                let client = &self.hub.client;
1827                dlg.pre_request();
1828                let mut req_builder = hyper::Request::builder()
1829                    .method(hyper::Method::GET)
1830                    .uri(url.as_str())
1831                    .header(USER_AGENT, self.hub._user_agent.clone());
1832
1833                if let Some(token) = token.as_ref() {
1834                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1835                }
1836
1837                let request = req_builder
1838                    .header(CONTENT_LENGTH, 0_u64)
1839                    .body(common::to_body::<String>(None));
1840
1841                client.request(request.unwrap()).await
1842            };
1843
1844            match req_result {
1845                Err(err) => {
1846                    if let common::Retry::After(d) = dlg.http_error(&err) {
1847                        sleep(d).await;
1848                        continue;
1849                    }
1850                    dlg.finished(false);
1851                    return Err(common::Error::HttpError(err));
1852                }
1853                Ok(res) => {
1854                    let (mut parts, body) = res.into_parts();
1855                    let mut body = common::Body::new(body);
1856                    if !parts.status.is_success() {
1857                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1858                        let error = serde_json::from_str(&common::to_string(&bytes));
1859                        let response = common::to_response(parts, bytes.into());
1860
1861                        if let common::Retry::After(d) =
1862                            dlg.http_failure(&response, error.as_ref().ok())
1863                        {
1864                            sleep(d).await;
1865                            continue;
1866                        }
1867
1868                        dlg.finished(false);
1869
1870                        return Err(match error {
1871                            Ok(value) => common::Error::BadRequest(value),
1872                            _ => common::Error::Failure(response),
1873                        });
1874                    }
1875                    let response = {
1876                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1877                        let encoded = common::to_string(&bytes);
1878                        match serde_json::from_str(&encoded) {
1879                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1880                            Err(error) => {
1881                                dlg.response_json_decode_error(&encoded, &error);
1882                                return Err(common::Error::JsonDecodeError(
1883                                    encoded.to_string(),
1884                                    error,
1885                                ));
1886                            }
1887                        }
1888                    };
1889
1890                    dlg.finished(true);
1891                    return Ok(response);
1892                }
1893            }
1894        }
1895    }
1896
1897    /// When set to `true`, operations that are reachable are returned as normal, and those that are unreachable are returned in the ListOperationsResponse.unreachable field. This can only be `true` when reading across collections. For example, when `parent` is set to `"projects/example/locations/-"`. This field is not supported by default and will result in an `UNIMPLEMENTED` error if set unless explicitly documented otherwise in service or product specific documentation.
1898    ///
1899    /// Sets the *return partial success* query property to the given value.
1900    pub fn return_partial_success(mut self, new_value: bool) -> OperationListCall<'a, C> {
1901        self._return_partial_success = Some(new_value);
1902        self
1903    }
1904    /// The standard list page token.
1905    ///
1906    /// Sets the *page token* query property to the given value.
1907    pub fn page_token(mut self, new_value: &str) -> OperationListCall<'a, C> {
1908        self._page_token = Some(new_value.to_string());
1909        self
1910    }
1911    /// The standard list page size.
1912    ///
1913    /// Sets the *page size* query property to the given value.
1914    pub fn page_size(mut self, new_value: i32) -> OperationListCall<'a, C> {
1915        self._page_size = Some(new_value);
1916        self
1917    }
1918    /// The name of the operation's parent resource.
1919    ///
1920    /// Sets the *name* query property to the given value.
1921    pub fn name(mut self, new_value: &str) -> OperationListCall<'a, C> {
1922        self._name = Some(new_value.to_string());
1923        self
1924    }
1925    /// The standard list filter.
1926    ///
1927    /// Sets the *filter* query property to the given value.
1928    pub fn filter(mut self, new_value: &str) -> OperationListCall<'a, C> {
1929        self._filter = Some(new_value.to_string());
1930        self
1931    }
1932    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1933    /// while executing the actual API request.
1934    ///
1935    /// ````text
1936    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1937    /// ````
1938    ///
1939    /// Sets the *delegate* property to the given value.
1940    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OperationListCall<'a, C> {
1941        self._delegate = Some(new_value);
1942        self
1943    }
1944
1945    /// Set any additional parameter of the query string used in the request.
1946    /// It should be used to set parameters which are not yet available through their own
1947    /// setters.
1948    ///
1949    /// Please note that this method must not be used to set any of the known parameters
1950    /// which have their own setter method. If done anyway, the request will fail.
1951    ///
1952    /// # Additional Parameters
1953    ///
1954    /// * *$.xgafv* (query-string) - V1 error format.
1955    /// * *access_token* (query-string) - OAuth access token.
1956    /// * *alt* (query-string) - Data format for response.
1957    /// * *callback* (query-string) - JSONP
1958    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1959    /// * *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.
1960    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1961    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1962    /// * *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.
1963    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1964    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1965    pub fn param<T>(mut self, name: T, value: T) -> OperationListCall<'a, C>
1966    where
1967        T: AsRef<str>,
1968    {
1969        self._additional_params
1970            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1971        self
1972    }
1973
1974    /// Identifies the authorization scope for the method you are building.
1975    ///
1976    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1977    /// [`Scope::CloudPlatform`].
1978    ///
1979    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1980    /// tokens for more than one scope.
1981    ///
1982    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1983    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1984    /// sufficient, a read-write scope will do as well.
1985    pub fn add_scope<St>(mut self, scope: St) -> OperationListCall<'a, C>
1986    where
1987        St: AsRef<str>,
1988    {
1989        self._scopes.insert(String::from(scope.as_ref()));
1990        self
1991    }
1992    /// Identifies the authorization scope(s) for the method you are building.
1993    ///
1994    /// See [`Self::add_scope()`] for details.
1995    pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationListCall<'a, C>
1996    where
1997        I: IntoIterator<Item = St>,
1998        St: AsRef<str>,
1999    {
2000        self._scopes
2001            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2002        self
2003    }
2004
2005    /// Removes all scopes, and no default scope will be used either.
2006    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2007    /// for details).
2008    pub fn clear_scopes(mut self) -> OperationListCall<'a, C> {
2009        self._scopes.clear();
2010        self
2011    }
2012}
2013
2014/// Create a custom class.
2015///
2016/// A builder for the *locations.customClasses.create* method supported by a *project* resource.
2017/// It is not used directly, but through a [`ProjectMethods`] instance.
2018///
2019/// # Example
2020///
2021/// Instantiate a resource method builder
2022///
2023/// ```test_harness,no_run
2024/// # extern crate hyper;
2025/// # extern crate hyper_rustls;
2026/// # extern crate google_speech1 as speech1;
2027/// use speech1::api::CreateCustomClassRequest;
2028/// # async fn dox() {
2029/// # use speech1::{Speech, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2030///
2031/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2032/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2033/// #     .with_native_roots()
2034/// #     .unwrap()
2035/// #     .https_only()
2036/// #     .enable_http2()
2037/// #     .build();
2038///
2039/// # let executor = hyper_util::rt::TokioExecutor::new();
2040/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2041/// #     secret,
2042/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2043/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2044/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2045/// #     ),
2046/// # ).build().await.unwrap();
2047///
2048/// # let client = hyper_util::client::legacy::Client::builder(
2049/// #     hyper_util::rt::TokioExecutor::new()
2050/// # )
2051/// # .build(
2052/// #     hyper_rustls::HttpsConnectorBuilder::new()
2053/// #         .with_native_roots()
2054/// #         .unwrap()
2055/// #         .https_or_http()
2056/// #         .enable_http2()
2057/// #         .build()
2058/// # );
2059/// # let mut hub = Speech::new(client, auth);
2060/// // As the method needs a request, you would usually fill it with the desired information
2061/// // into the respective structure. Some of the parts shown here might not be applicable !
2062/// // Values shown here are possibly random and not representative !
2063/// let mut req = CreateCustomClassRequest::default();
2064///
2065/// // You can configure optional parameters by calling the respective setters at will, and
2066/// // execute the final call using `doit()`.
2067/// // Values shown here are possibly random and not representative !
2068/// let result = hub.projects().locations_custom_classes_create(req, "parent")
2069///              .doit().await;
2070/// # }
2071/// ```
2072pub struct ProjectLocationCustomClassCreateCall<'a, C>
2073where
2074    C: 'a,
2075{
2076    hub: &'a Speech<C>,
2077    _request: CreateCustomClassRequest,
2078    _parent: String,
2079    _delegate: Option<&'a mut dyn common::Delegate>,
2080    _additional_params: HashMap<String, String>,
2081    _scopes: BTreeSet<String>,
2082}
2083
2084impl<'a, C> common::CallBuilder for ProjectLocationCustomClassCreateCall<'a, C> {}
2085
2086impl<'a, C> ProjectLocationCustomClassCreateCall<'a, C>
2087where
2088    C: common::Connector,
2089{
2090    /// Perform the operation you have build so far.
2091    pub async fn doit(mut self) -> common::Result<(common::Response, CustomClass)> {
2092        use std::borrow::Cow;
2093        use std::io::{Read, Seek};
2094
2095        use common::{url::Params, ToParts};
2096        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2097
2098        let mut dd = common::DefaultDelegate;
2099        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2100        dlg.begin(common::MethodInfo {
2101            id: "speech.projects.locations.customClasses.create",
2102            http_method: hyper::Method::POST,
2103        });
2104
2105        for &field in ["alt", "parent"].iter() {
2106            if self._additional_params.contains_key(field) {
2107                dlg.finished(false);
2108                return Err(common::Error::FieldClash(field));
2109            }
2110        }
2111
2112        let mut params = Params::with_capacity(4 + self._additional_params.len());
2113        params.push("parent", self._parent);
2114
2115        params.extend(self._additional_params.iter());
2116
2117        params.push("alt", "json");
2118        let mut url = self.hub._base_url.clone() + "v1/{+parent}/customClasses";
2119        if self._scopes.is_empty() {
2120            self._scopes
2121                .insert(Scope::CloudPlatform.as_ref().to_string());
2122        }
2123
2124        #[allow(clippy::single_element_loop)]
2125        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2126            url = params.uri_replacement(url, param_name, find_this, true);
2127        }
2128        {
2129            let to_remove = ["parent"];
2130            params.remove_params(&to_remove);
2131        }
2132
2133        let url = params.parse_with_url(&url);
2134
2135        let mut json_mime_type = mime::APPLICATION_JSON;
2136        let mut request_value_reader = {
2137            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2138            common::remove_json_null_values(&mut value);
2139            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2140            serde_json::to_writer(&mut dst, &value).unwrap();
2141            dst
2142        };
2143        let request_size = request_value_reader
2144            .seek(std::io::SeekFrom::End(0))
2145            .unwrap();
2146        request_value_reader
2147            .seek(std::io::SeekFrom::Start(0))
2148            .unwrap();
2149
2150        loop {
2151            let token = match self
2152                .hub
2153                .auth
2154                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2155                .await
2156            {
2157                Ok(token) => token,
2158                Err(e) => match dlg.token(e) {
2159                    Ok(token) => token,
2160                    Err(e) => {
2161                        dlg.finished(false);
2162                        return Err(common::Error::MissingToken(e));
2163                    }
2164                },
2165            };
2166            request_value_reader
2167                .seek(std::io::SeekFrom::Start(0))
2168                .unwrap();
2169            let mut req_result = {
2170                let client = &self.hub.client;
2171                dlg.pre_request();
2172                let mut req_builder = hyper::Request::builder()
2173                    .method(hyper::Method::POST)
2174                    .uri(url.as_str())
2175                    .header(USER_AGENT, self.hub._user_agent.clone());
2176
2177                if let Some(token) = token.as_ref() {
2178                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2179                }
2180
2181                let request = req_builder
2182                    .header(CONTENT_TYPE, json_mime_type.to_string())
2183                    .header(CONTENT_LENGTH, request_size as u64)
2184                    .body(common::to_body(
2185                        request_value_reader.get_ref().clone().into(),
2186                    ));
2187
2188                client.request(request.unwrap()).await
2189            };
2190
2191            match req_result {
2192                Err(err) => {
2193                    if let common::Retry::After(d) = dlg.http_error(&err) {
2194                        sleep(d).await;
2195                        continue;
2196                    }
2197                    dlg.finished(false);
2198                    return Err(common::Error::HttpError(err));
2199                }
2200                Ok(res) => {
2201                    let (mut parts, body) = res.into_parts();
2202                    let mut body = common::Body::new(body);
2203                    if !parts.status.is_success() {
2204                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2205                        let error = serde_json::from_str(&common::to_string(&bytes));
2206                        let response = common::to_response(parts, bytes.into());
2207
2208                        if let common::Retry::After(d) =
2209                            dlg.http_failure(&response, error.as_ref().ok())
2210                        {
2211                            sleep(d).await;
2212                            continue;
2213                        }
2214
2215                        dlg.finished(false);
2216
2217                        return Err(match error {
2218                            Ok(value) => common::Error::BadRequest(value),
2219                            _ => common::Error::Failure(response),
2220                        });
2221                    }
2222                    let response = {
2223                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2224                        let encoded = common::to_string(&bytes);
2225                        match serde_json::from_str(&encoded) {
2226                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2227                            Err(error) => {
2228                                dlg.response_json_decode_error(&encoded, &error);
2229                                return Err(common::Error::JsonDecodeError(
2230                                    encoded.to_string(),
2231                                    error,
2232                                ));
2233                            }
2234                        }
2235                    };
2236
2237                    dlg.finished(true);
2238                    return Ok(response);
2239                }
2240            }
2241        }
2242    }
2243
2244    ///
2245    /// Sets the *request* property to the given value.
2246    ///
2247    /// Even though the property as already been set when instantiating this call,
2248    /// we provide this method for API completeness.
2249    pub fn request(
2250        mut self,
2251        new_value: CreateCustomClassRequest,
2252    ) -> ProjectLocationCustomClassCreateCall<'a, C> {
2253        self._request = new_value;
2254        self
2255    }
2256    /// Required. The parent resource where this custom class will be created. Format: `projects/{project}/locations/{location}/customClasses` Speech-to-Text supports three locations: `global`, `us` (US North America), and `eu` (Europe). If you are calling the `speech.googleapis.com` endpoint, use the `global` location. To specify a region, use a [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) with matching `us` or `eu` location value.
2257    ///
2258    /// Sets the *parent* path property to the given value.
2259    ///
2260    /// Even though the property as already been set when instantiating this call,
2261    /// we provide this method for API completeness.
2262    pub fn parent(mut self, new_value: &str) -> ProjectLocationCustomClassCreateCall<'a, C> {
2263        self._parent = new_value.to_string();
2264        self
2265    }
2266    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2267    /// while executing the actual API request.
2268    ///
2269    /// ````text
2270    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2271    /// ````
2272    ///
2273    /// Sets the *delegate* property to the given value.
2274    pub fn delegate(
2275        mut self,
2276        new_value: &'a mut dyn common::Delegate,
2277    ) -> ProjectLocationCustomClassCreateCall<'a, C> {
2278        self._delegate = Some(new_value);
2279        self
2280    }
2281
2282    /// Set any additional parameter of the query string used in the request.
2283    /// It should be used to set parameters which are not yet available through their own
2284    /// setters.
2285    ///
2286    /// Please note that this method must not be used to set any of the known parameters
2287    /// which have their own setter method. If done anyway, the request will fail.
2288    ///
2289    /// # Additional Parameters
2290    ///
2291    /// * *$.xgafv* (query-string) - V1 error format.
2292    /// * *access_token* (query-string) - OAuth access token.
2293    /// * *alt* (query-string) - Data format for response.
2294    /// * *callback* (query-string) - JSONP
2295    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2296    /// * *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.
2297    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2298    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2299    /// * *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.
2300    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2301    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2302    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCustomClassCreateCall<'a, C>
2303    where
2304        T: AsRef<str>,
2305    {
2306        self._additional_params
2307            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2308        self
2309    }
2310
2311    /// Identifies the authorization scope for the method you are building.
2312    ///
2313    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2314    /// [`Scope::CloudPlatform`].
2315    ///
2316    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2317    /// tokens for more than one scope.
2318    ///
2319    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2320    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2321    /// sufficient, a read-write scope will do as well.
2322    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCustomClassCreateCall<'a, C>
2323    where
2324        St: AsRef<str>,
2325    {
2326        self._scopes.insert(String::from(scope.as_ref()));
2327        self
2328    }
2329    /// Identifies the authorization scope(s) for the method you are building.
2330    ///
2331    /// See [`Self::add_scope()`] for details.
2332    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationCustomClassCreateCall<'a, C>
2333    where
2334        I: IntoIterator<Item = St>,
2335        St: AsRef<str>,
2336    {
2337        self._scopes
2338            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2339        self
2340    }
2341
2342    /// Removes all scopes, and no default scope will be used either.
2343    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2344    /// for details).
2345    pub fn clear_scopes(mut self) -> ProjectLocationCustomClassCreateCall<'a, C> {
2346        self._scopes.clear();
2347        self
2348    }
2349}
2350
2351/// Delete a custom class.
2352///
2353/// A builder for the *locations.customClasses.delete* method supported by a *project* resource.
2354/// It is not used directly, but through a [`ProjectMethods`] instance.
2355///
2356/// # Example
2357///
2358/// Instantiate a resource method builder
2359///
2360/// ```test_harness,no_run
2361/// # extern crate hyper;
2362/// # extern crate hyper_rustls;
2363/// # extern crate google_speech1 as speech1;
2364/// # async fn dox() {
2365/// # use speech1::{Speech, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2366///
2367/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2368/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2369/// #     .with_native_roots()
2370/// #     .unwrap()
2371/// #     .https_only()
2372/// #     .enable_http2()
2373/// #     .build();
2374///
2375/// # let executor = hyper_util::rt::TokioExecutor::new();
2376/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2377/// #     secret,
2378/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2379/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2380/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2381/// #     ),
2382/// # ).build().await.unwrap();
2383///
2384/// # let client = hyper_util::client::legacy::Client::builder(
2385/// #     hyper_util::rt::TokioExecutor::new()
2386/// # )
2387/// # .build(
2388/// #     hyper_rustls::HttpsConnectorBuilder::new()
2389/// #         .with_native_roots()
2390/// #         .unwrap()
2391/// #         .https_or_http()
2392/// #         .enable_http2()
2393/// #         .build()
2394/// # );
2395/// # let mut hub = Speech::new(client, auth);
2396/// // You can configure optional parameters by calling the respective setters at will, and
2397/// // execute the final call using `doit()`.
2398/// // Values shown here are possibly random and not representative !
2399/// let result = hub.projects().locations_custom_classes_delete("name")
2400///              .doit().await;
2401/// # }
2402/// ```
2403pub struct ProjectLocationCustomClassDeleteCall<'a, C>
2404where
2405    C: 'a,
2406{
2407    hub: &'a Speech<C>,
2408    _name: String,
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 ProjectLocationCustomClassDeleteCall<'a, C> {}
2415
2416impl<'a, C> ProjectLocationCustomClassDeleteCall<'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, Empty)> {
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: "speech.projects.locations.customClasses.delete",
2432            http_method: hyper::Method::DELETE,
2433        });
2434
2435        for &field in ["alt", "name"].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(3 + self._additional_params.len());
2443        params.push("name", self._name);
2444
2445        params.extend(self._additional_params.iter());
2446
2447        params.push("alt", "json");
2448        let mut url = self.hub._base_url.clone() + "v1/{+name}";
2449        if self._scopes.is_empty() {
2450            self._scopes
2451                .insert(Scope::CloudPlatform.as_ref().to_string());
2452        }
2453
2454        #[allow(clippy::single_element_loop)]
2455        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2456            url = params.uri_replacement(url, param_name, find_this, true);
2457        }
2458        {
2459            let to_remove = ["name"];
2460            params.remove_params(&to_remove);
2461        }
2462
2463        let url = params.parse_with_url(&url);
2464
2465        loop {
2466            let token = match self
2467                .hub
2468                .auth
2469                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2470                .await
2471            {
2472                Ok(token) => token,
2473                Err(e) => match dlg.token(e) {
2474                    Ok(token) => token,
2475                    Err(e) => {
2476                        dlg.finished(false);
2477                        return Err(common::Error::MissingToken(e));
2478                    }
2479                },
2480            };
2481            let mut req_result = {
2482                let client = &self.hub.client;
2483                dlg.pre_request();
2484                let mut req_builder = hyper::Request::builder()
2485                    .method(hyper::Method::DELETE)
2486                    .uri(url.as_str())
2487                    .header(USER_AGENT, self.hub._user_agent.clone());
2488
2489                if let Some(token) = token.as_ref() {
2490                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2491                }
2492
2493                let request = req_builder
2494                    .header(CONTENT_LENGTH, 0_u64)
2495                    .body(common::to_body::<String>(None));
2496
2497                client.request(request.unwrap()).await
2498            };
2499
2500            match req_result {
2501                Err(err) => {
2502                    if let common::Retry::After(d) = dlg.http_error(&err) {
2503                        sleep(d).await;
2504                        continue;
2505                    }
2506                    dlg.finished(false);
2507                    return Err(common::Error::HttpError(err));
2508                }
2509                Ok(res) => {
2510                    let (mut parts, body) = res.into_parts();
2511                    let mut body = common::Body::new(body);
2512                    if !parts.status.is_success() {
2513                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2514                        let error = serde_json::from_str(&common::to_string(&bytes));
2515                        let response = common::to_response(parts, bytes.into());
2516
2517                        if let common::Retry::After(d) =
2518                            dlg.http_failure(&response, error.as_ref().ok())
2519                        {
2520                            sleep(d).await;
2521                            continue;
2522                        }
2523
2524                        dlg.finished(false);
2525
2526                        return Err(match error {
2527                            Ok(value) => common::Error::BadRequest(value),
2528                            _ => common::Error::Failure(response),
2529                        });
2530                    }
2531                    let response = {
2532                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2533                        let encoded = common::to_string(&bytes);
2534                        match serde_json::from_str(&encoded) {
2535                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2536                            Err(error) => {
2537                                dlg.response_json_decode_error(&encoded, &error);
2538                                return Err(common::Error::JsonDecodeError(
2539                                    encoded.to_string(),
2540                                    error,
2541                                ));
2542                            }
2543                        }
2544                    };
2545
2546                    dlg.finished(true);
2547                    return Ok(response);
2548                }
2549            }
2550        }
2551    }
2552
2553    /// Required. The name of the custom class to delete. Format: `projects/{project}/locations/{location}/customClasses/{custom_class}` Speech-to-Text supports three locations: `global`, `us` (US North America), and `eu` (Europe). If you are calling the `speech.googleapis.com` endpoint, use the `global` location. To specify a region, use a [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) with matching `us` or `eu` location value.
2554    ///
2555    /// Sets the *name* path property to the given value.
2556    ///
2557    /// Even though the property as already been set when instantiating this call,
2558    /// we provide this method for API completeness.
2559    pub fn name(mut self, new_value: &str) -> ProjectLocationCustomClassDeleteCall<'a, C> {
2560        self._name = new_value.to_string();
2561        self
2562    }
2563    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2564    /// while executing the actual API request.
2565    ///
2566    /// ````text
2567    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2568    /// ````
2569    ///
2570    /// Sets the *delegate* property to the given value.
2571    pub fn delegate(
2572        mut self,
2573        new_value: &'a mut dyn common::Delegate,
2574    ) -> ProjectLocationCustomClassDeleteCall<'a, C> {
2575        self._delegate = Some(new_value);
2576        self
2577    }
2578
2579    /// Set any additional parameter of the query string used in the request.
2580    /// It should be used to set parameters which are not yet available through their own
2581    /// setters.
2582    ///
2583    /// Please note that this method must not be used to set any of the known parameters
2584    /// which have their own setter method. If done anyway, the request will fail.
2585    ///
2586    /// # Additional Parameters
2587    ///
2588    /// * *$.xgafv* (query-string) - V1 error format.
2589    /// * *access_token* (query-string) - OAuth access token.
2590    /// * *alt* (query-string) - Data format for response.
2591    /// * *callback* (query-string) - JSONP
2592    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2593    /// * *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.
2594    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2595    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2596    /// * *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.
2597    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2598    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2599    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCustomClassDeleteCall<'a, C>
2600    where
2601        T: AsRef<str>,
2602    {
2603        self._additional_params
2604            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2605        self
2606    }
2607
2608    /// Identifies the authorization scope for the method you are building.
2609    ///
2610    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2611    /// [`Scope::CloudPlatform`].
2612    ///
2613    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2614    /// tokens for more than one scope.
2615    ///
2616    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2617    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2618    /// sufficient, a read-write scope will do as well.
2619    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCustomClassDeleteCall<'a, C>
2620    where
2621        St: AsRef<str>,
2622    {
2623        self._scopes.insert(String::from(scope.as_ref()));
2624        self
2625    }
2626    /// Identifies the authorization scope(s) for the method you are building.
2627    ///
2628    /// See [`Self::add_scope()`] for details.
2629    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationCustomClassDeleteCall<'a, C>
2630    where
2631        I: IntoIterator<Item = St>,
2632        St: AsRef<str>,
2633    {
2634        self._scopes
2635            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2636        self
2637    }
2638
2639    /// Removes all scopes, and no default scope will be used either.
2640    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2641    /// for details).
2642    pub fn clear_scopes(mut self) -> ProjectLocationCustomClassDeleteCall<'a, C> {
2643        self._scopes.clear();
2644        self
2645    }
2646}
2647
2648/// Get a custom class.
2649///
2650/// A builder for the *locations.customClasses.get* method supported by a *project* resource.
2651/// It is not used directly, but through a [`ProjectMethods`] instance.
2652///
2653/// # Example
2654///
2655/// Instantiate a resource method builder
2656///
2657/// ```test_harness,no_run
2658/// # extern crate hyper;
2659/// # extern crate hyper_rustls;
2660/// # extern crate google_speech1 as speech1;
2661/// # async fn dox() {
2662/// # use speech1::{Speech, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2663///
2664/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2665/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2666/// #     .with_native_roots()
2667/// #     .unwrap()
2668/// #     .https_only()
2669/// #     .enable_http2()
2670/// #     .build();
2671///
2672/// # let executor = hyper_util::rt::TokioExecutor::new();
2673/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2674/// #     secret,
2675/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2676/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2677/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2678/// #     ),
2679/// # ).build().await.unwrap();
2680///
2681/// # let client = hyper_util::client::legacy::Client::builder(
2682/// #     hyper_util::rt::TokioExecutor::new()
2683/// # )
2684/// # .build(
2685/// #     hyper_rustls::HttpsConnectorBuilder::new()
2686/// #         .with_native_roots()
2687/// #         .unwrap()
2688/// #         .https_or_http()
2689/// #         .enable_http2()
2690/// #         .build()
2691/// # );
2692/// # let mut hub = Speech::new(client, auth);
2693/// // You can configure optional parameters by calling the respective setters at will, and
2694/// // execute the final call using `doit()`.
2695/// // Values shown here are possibly random and not representative !
2696/// let result = hub.projects().locations_custom_classes_get("name")
2697///              .doit().await;
2698/// # }
2699/// ```
2700pub struct ProjectLocationCustomClassGetCall<'a, C>
2701where
2702    C: 'a,
2703{
2704    hub: &'a Speech<C>,
2705    _name: String,
2706    _delegate: Option<&'a mut dyn common::Delegate>,
2707    _additional_params: HashMap<String, String>,
2708    _scopes: BTreeSet<String>,
2709}
2710
2711impl<'a, C> common::CallBuilder for ProjectLocationCustomClassGetCall<'a, C> {}
2712
2713impl<'a, C> ProjectLocationCustomClassGetCall<'a, C>
2714where
2715    C: common::Connector,
2716{
2717    /// Perform the operation you have build so far.
2718    pub async fn doit(mut self) -> common::Result<(common::Response, CustomClass)> {
2719        use std::borrow::Cow;
2720        use std::io::{Read, Seek};
2721
2722        use common::{url::Params, ToParts};
2723        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2724
2725        let mut dd = common::DefaultDelegate;
2726        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2727        dlg.begin(common::MethodInfo {
2728            id: "speech.projects.locations.customClasses.get",
2729            http_method: hyper::Method::GET,
2730        });
2731
2732        for &field in ["alt", "name"].iter() {
2733            if self._additional_params.contains_key(field) {
2734                dlg.finished(false);
2735                return Err(common::Error::FieldClash(field));
2736            }
2737        }
2738
2739        let mut params = Params::with_capacity(3 + self._additional_params.len());
2740        params.push("name", self._name);
2741
2742        params.extend(self._additional_params.iter());
2743
2744        params.push("alt", "json");
2745        let mut url = self.hub._base_url.clone() + "v1/{+name}";
2746        if self._scopes.is_empty() {
2747            self._scopes
2748                .insert(Scope::CloudPlatform.as_ref().to_string());
2749        }
2750
2751        #[allow(clippy::single_element_loop)]
2752        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2753            url = params.uri_replacement(url, param_name, find_this, true);
2754        }
2755        {
2756            let to_remove = ["name"];
2757            params.remove_params(&to_remove);
2758        }
2759
2760        let url = params.parse_with_url(&url);
2761
2762        loop {
2763            let token = match self
2764                .hub
2765                .auth
2766                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2767                .await
2768            {
2769                Ok(token) => token,
2770                Err(e) => match dlg.token(e) {
2771                    Ok(token) => token,
2772                    Err(e) => {
2773                        dlg.finished(false);
2774                        return Err(common::Error::MissingToken(e));
2775                    }
2776                },
2777            };
2778            let mut req_result = {
2779                let client = &self.hub.client;
2780                dlg.pre_request();
2781                let mut req_builder = hyper::Request::builder()
2782                    .method(hyper::Method::GET)
2783                    .uri(url.as_str())
2784                    .header(USER_AGENT, self.hub._user_agent.clone());
2785
2786                if let Some(token) = token.as_ref() {
2787                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2788                }
2789
2790                let request = req_builder
2791                    .header(CONTENT_LENGTH, 0_u64)
2792                    .body(common::to_body::<String>(None));
2793
2794                client.request(request.unwrap()).await
2795            };
2796
2797            match req_result {
2798                Err(err) => {
2799                    if let common::Retry::After(d) = dlg.http_error(&err) {
2800                        sleep(d).await;
2801                        continue;
2802                    }
2803                    dlg.finished(false);
2804                    return Err(common::Error::HttpError(err));
2805                }
2806                Ok(res) => {
2807                    let (mut parts, body) = res.into_parts();
2808                    let mut body = common::Body::new(body);
2809                    if !parts.status.is_success() {
2810                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2811                        let error = serde_json::from_str(&common::to_string(&bytes));
2812                        let response = common::to_response(parts, bytes.into());
2813
2814                        if let common::Retry::After(d) =
2815                            dlg.http_failure(&response, error.as_ref().ok())
2816                        {
2817                            sleep(d).await;
2818                            continue;
2819                        }
2820
2821                        dlg.finished(false);
2822
2823                        return Err(match error {
2824                            Ok(value) => common::Error::BadRequest(value),
2825                            _ => common::Error::Failure(response),
2826                        });
2827                    }
2828                    let response = {
2829                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2830                        let encoded = common::to_string(&bytes);
2831                        match serde_json::from_str(&encoded) {
2832                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2833                            Err(error) => {
2834                                dlg.response_json_decode_error(&encoded, &error);
2835                                return Err(common::Error::JsonDecodeError(
2836                                    encoded.to_string(),
2837                                    error,
2838                                ));
2839                            }
2840                        }
2841                    };
2842
2843                    dlg.finished(true);
2844                    return Ok(response);
2845                }
2846            }
2847        }
2848    }
2849
2850    /// Required. The name of the custom class to retrieve. Format: `projects/{project}/locations/{location}/customClasses/{custom_class}`
2851    ///
2852    /// Sets the *name* path property to the given value.
2853    ///
2854    /// Even though the property as already been set when instantiating this call,
2855    /// we provide this method for API completeness.
2856    pub fn name(mut self, new_value: &str) -> ProjectLocationCustomClassGetCall<'a, C> {
2857        self._name = new_value.to_string();
2858        self
2859    }
2860    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2861    /// while executing the actual API request.
2862    ///
2863    /// ````text
2864    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2865    /// ````
2866    ///
2867    /// Sets the *delegate* property to the given value.
2868    pub fn delegate(
2869        mut self,
2870        new_value: &'a mut dyn common::Delegate,
2871    ) -> ProjectLocationCustomClassGetCall<'a, C> {
2872        self._delegate = Some(new_value);
2873        self
2874    }
2875
2876    /// Set any additional parameter of the query string used in the request.
2877    /// It should be used to set parameters which are not yet available through their own
2878    /// setters.
2879    ///
2880    /// Please note that this method must not be used to set any of the known parameters
2881    /// which have their own setter method. If done anyway, the request will fail.
2882    ///
2883    /// # Additional Parameters
2884    ///
2885    /// * *$.xgafv* (query-string) - V1 error format.
2886    /// * *access_token* (query-string) - OAuth access token.
2887    /// * *alt* (query-string) - Data format for response.
2888    /// * *callback* (query-string) - JSONP
2889    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2890    /// * *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.
2891    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2892    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2893    /// * *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.
2894    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2895    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2896    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCustomClassGetCall<'a, C>
2897    where
2898        T: AsRef<str>,
2899    {
2900        self._additional_params
2901            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2902        self
2903    }
2904
2905    /// Identifies the authorization scope for the method you are building.
2906    ///
2907    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2908    /// [`Scope::CloudPlatform`].
2909    ///
2910    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2911    /// tokens for more than one scope.
2912    ///
2913    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2914    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2915    /// sufficient, a read-write scope will do as well.
2916    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCustomClassGetCall<'a, C>
2917    where
2918        St: AsRef<str>,
2919    {
2920        self._scopes.insert(String::from(scope.as_ref()));
2921        self
2922    }
2923    /// Identifies the authorization scope(s) for the method you are building.
2924    ///
2925    /// See [`Self::add_scope()`] for details.
2926    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationCustomClassGetCall<'a, C>
2927    where
2928        I: IntoIterator<Item = St>,
2929        St: AsRef<str>,
2930    {
2931        self._scopes
2932            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2933        self
2934    }
2935
2936    /// Removes all scopes, and no default scope will be used either.
2937    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2938    /// for details).
2939    pub fn clear_scopes(mut self) -> ProjectLocationCustomClassGetCall<'a, C> {
2940        self._scopes.clear();
2941        self
2942    }
2943}
2944
2945/// List custom classes.
2946///
2947/// A builder for the *locations.customClasses.list* method supported by a *project* resource.
2948/// It is not used directly, but through a [`ProjectMethods`] instance.
2949///
2950/// # Example
2951///
2952/// Instantiate a resource method builder
2953///
2954/// ```test_harness,no_run
2955/// # extern crate hyper;
2956/// # extern crate hyper_rustls;
2957/// # extern crate google_speech1 as speech1;
2958/// # async fn dox() {
2959/// # use speech1::{Speech, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2960///
2961/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2962/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2963/// #     .with_native_roots()
2964/// #     .unwrap()
2965/// #     .https_only()
2966/// #     .enable_http2()
2967/// #     .build();
2968///
2969/// # let executor = hyper_util::rt::TokioExecutor::new();
2970/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2971/// #     secret,
2972/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2973/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2974/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2975/// #     ),
2976/// # ).build().await.unwrap();
2977///
2978/// # let client = hyper_util::client::legacy::Client::builder(
2979/// #     hyper_util::rt::TokioExecutor::new()
2980/// # )
2981/// # .build(
2982/// #     hyper_rustls::HttpsConnectorBuilder::new()
2983/// #         .with_native_roots()
2984/// #         .unwrap()
2985/// #         .https_or_http()
2986/// #         .enable_http2()
2987/// #         .build()
2988/// # );
2989/// # let mut hub = Speech::new(client, auth);
2990/// // You can configure optional parameters by calling the respective setters at will, and
2991/// // execute the final call using `doit()`.
2992/// // Values shown here are possibly random and not representative !
2993/// let result = hub.projects().locations_custom_classes_list("parent")
2994///              .page_token("eos")
2995///              .page_size(-4)
2996///              .doit().await;
2997/// # }
2998/// ```
2999pub struct ProjectLocationCustomClassListCall<'a, C>
3000where
3001    C: 'a,
3002{
3003    hub: &'a Speech<C>,
3004    _parent: String,
3005    _page_token: Option<String>,
3006    _page_size: Option<i32>,
3007    _delegate: Option<&'a mut dyn common::Delegate>,
3008    _additional_params: HashMap<String, String>,
3009    _scopes: BTreeSet<String>,
3010}
3011
3012impl<'a, C> common::CallBuilder for ProjectLocationCustomClassListCall<'a, C> {}
3013
3014impl<'a, C> ProjectLocationCustomClassListCall<'a, C>
3015where
3016    C: common::Connector,
3017{
3018    /// Perform the operation you have build so far.
3019    pub async fn doit(mut self) -> common::Result<(common::Response, ListCustomClassesResponse)> {
3020        use std::borrow::Cow;
3021        use std::io::{Read, Seek};
3022
3023        use common::{url::Params, ToParts};
3024        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3025
3026        let mut dd = common::DefaultDelegate;
3027        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3028        dlg.begin(common::MethodInfo {
3029            id: "speech.projects.locations.customClasses.list",
3030            http_method: hyper::Method::GET,
3031        });
3032
3033        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
3034            if self._additional_params.contains_key(field) {
3035                dlg.finished(false);
3036                return Err(common::Error::FieldClash(field));
3037            }
3038        }
3039
3040        let mut params = Params::with_capacity(5 + self._additional_params.len());
3041        params.push("parent", self._parent);
3042        if let Some(value) = self._page_token.as_ref() {
3043            params.push("pageToken", value);
3044        }
3045        if let Some(value) = self._page_size.as_ref() {
3046            params.push("pageSize", value.to_string());
3047        }
3048
3049        params.extend(self._additional_params.iter());
3050
3051        params.push("alt", "json");
3052        let mut url = self.hub._base_url.clone() + "v1/{+parent}/customClasses";
3053        if self._scopes.is_empty() {
3054            self._scopes
3055                .insert(Scope::CloudPlatform.as_ref().to_string());
3056        }
3057
3058        #[allow(clippy::single_element_loop)]
3059        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3060            url = params.uri_replacement(url, param_name, find_this, true);
3061        }
3062        {
3063            let to_remove = ["parent"];
3064            params.remove_params(&to_remove);
3065        }
3066
3067        let url = params.parse_with_url(&url);
3068
3069        loop {
3070            let token = match self
3071                .hub
3072                .auth
3073                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3074                .await
3075            {
3076                Ok(token) => token,
3077                Err(e) => match dlg.token(e) {
3078                    Ok(token) => token,
3079                    Err(e) => {
3080                        dlg.finished(false);
3081                        return Err(common::Error::MissingToken(e));
3082                    }
3083                },
3084            };
3085            let mut req_result = {
3086                let client = &self.hub.client;
3087                dlg.pre_request();
3088                let mut req_builder = hyper::Request::builder()
3089                    .method(hyper::Method::GET)
3090                    .uri(url.as_str())
3091                    .header(USER_AGENT, self.hub._user_agent.clone());
3092
3093                if let Some(token) = token.as_ref() {
3094                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3095                }
3096
3097                let request = req_builder
3098                    .header(CONTENT_LENGTH, 0_u64)
3099                    .body(common::to_body::<String>(None));
3100
3101                client.request(request.unwrap()).await
3102            };
3103
3104            match req_result {
3105                Err(err) => {
3106                    if let common::Retry::After(d) = dlg.http_error(&err) {
3107                        sleep(d).await;
3108                        continue;
3109                    }
3110                    dlg.finished(false);
3111                    return Err(common::Error::HttpError(err));
3112                }
3113                Ok(res) => {
3114                    let (mut parts, body) = res.into_parts();
3115                    let mut body = common::Body::new(body);
3116                    if !parts.status.is_success() {
3117                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3118                        let error = serde_json::from_str(&common::to_string(&bytes));
3119                        let response = common::to_response(parts, bytes.into());
3120
3121                        if let common::Retry::After(d) =
3122                            dlg.http_failure(&response, error.as_ref().ok())
3123                        {
3124                            sleep(d).await;
3125                            continue;
3126                        }
3127
3128                        dlg.finished(false);
3129
3130                        return Err(match error {
3131                            Ok(value) => common::Error::BadRequest(value),
3132                            _ => common::Error::Failure(response),
3133                        });
3134                    }
3135                    let response = {
3136                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3137                        let encoded = common::to_string(&bytes);
3138                        match serde_json::from_str(&encoded) {
3139                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3140                            Err(error) => {
3141                                dlg.response_json_decode_error(&encoded, &error);
3142                                return Err(common::Error::JsonDecodeError(
3143                                    encoded.to_string(),
3144                                    error,
3145                                ));
3146                            }
3147                        }
3148                    };
3149
3150                    dlg.finished(true);
3151                    return Ok(response);
3152                }
3153            }
3154        }
3155    }
3156
3157    /// Required. The parent, which owns this collection of custom classes. Format: `projects/{project}/locations/{location}/customClasses` Speech-to-Text supports three locations: `global`, `us` (US North America), and `eu` (Europe). If you are calling the `speech.googleapis.com` endpoint, use the `global` location. To specify a region, use a [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) with matching `us` or `eu` location value.
3158    ///
3159    /// Sets the *parent* path property to the given value.
3160    ///
3161    /// Even though the property as already been set when instantiating this call,
3162    /// we provide this method for API completeness.
3163    pub fn parent(mut self, new_value: &str) -> ProjectLocationCustomClassListCall<'a, C> {
3164        self._parent = new_value.to_string();
3165        self
3166    }
3167    /// A page token, received from a previous `ListCustomClass` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListCustomClass` must match the call that provided the page token.
3168    ///
3169    /// Sets the *page token* query property to the given value.
3170    pub fn page_token(mut self, new_value: &str) -> ProjectLocationCustomClassListCall<'a, C> {
3171        self._page_token = Some(new_value.to_string());
3172        self
3173    }
3174    /// The maximum number of custom classes to return. The service may return fewer than this value. If unspecified, at most 50 custom classes will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000.
3175    ///
3176    /// Sets the *page size* query property to the given value.
3177    pub fn page_size(mut self, new_value: i32) -> ProjectLocationCustomClassListCall<'a, C> {
3178        self._page_size = Some(new_value);
3179        self
3180    }
3181    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3182    /// while executing the actual API request.
3183    ///
3184    /// ````text
3185    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3186    /// ````
3187    ///
3188    /// Sets the *delegate* property to the given value.
3189    pub fn delegate(
3190        mut self,
3191        new_value: &'a mut dyn common::Delegate,
3192    ) -> ProjectLocationCustomClassListCall<'a, C> {
3193        self._delegate = Some(new_value);
3194        self
3195    }
3196
3197    /// Set any additional parameter of the query string used in the request.
3198    /// It should be used to set parameters which are not yet available through their own
3199    /// setters.
3200    ///
3201    /// Please note that this method must not be used to set any of the known parameters
3202    /// which have their own setter method. If done anyway, the request will fail.
3203    ///
3204    /// # Additional Parameters
3205    ///
3206    /// * *$.xgafv* (query-string) - V1 error format.
3207    /// * *access_token* (query-string) - OAuth access token.
3208    /// * *alt* (query-string) - Data format for response.
3209    /// * *callback* (query-string) - JSONP
3210    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3211    /// * *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.
3212    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3213    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3214    /// * *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.
3215    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3216    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3217    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCustomClassListCall<'a, C>
3218    where
3219        T: AsRef<str>,
3220    {
3221        self._additional_params
3222            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3223        self
3224    }
3225
3226    /// Identifies the authorization scope for the method you are building.
3227    ///
3228    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3229    /// [`Scope::CloudPlatform`].
3230    ///
3231    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3232    /// tokens for more than one scope.
3233    ///
3234    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3235    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3236    /// sufficient, a read-write scope will do as well.
3237    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCustomClassListCall<'a, C>
3238    where
3239        St: AsRef<str>,
3240    {
3241        self._scopes.insert(String::from(scope.as_ref()));
3242        self
3243    }
3244    /// Identifies the authorization scope(s) for the method you are building.
3245    ///
3246    /// See [`Self::add_scope()`] for details.
3247    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationCustomClassListCall<'a, C>
3248    where
3249        I: IntoIterator<Item = St>,
3250        St: AsRef<str>,
3251    {
3252        self._scopes
3253            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3254        self
3255    }
3256
3257    /// Removes all scopes, and no default scope will be used either.
3258    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3259    /// for details).
3260    pub fn clear_scopes(mut self) -> ProjectLocationCustomClassListCall<'a, C> {
3261        self._scopes.clear();
3262        self
3263    }
3264}
3265
3266/// Update a custom class.
3267///
3268/// A builder for the *locations.customClasses.patch* method supported by a *project* resource.
3269/// It is not used directly, but through a [`ProjectMethods`] instance.
3270///
3271/// # Example
3272///
3273/// Instantiate a resource method builder
3274///
3275/// ```test_harness,no_run
3276/// # extern crate hyper;
3277/// # extern crate hyper_rustls;
3278/// # extern crate google_speech1 as speech1;
3279/// use speech1::api::CustomClass;
3280/// # async fn dox() {
3281/// # use speech1::{Speech, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3282///
3283/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3284/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3285/// #     .with_native_roots()
3286/// #     .unwrap()
3287/// #     .https_only()
3288/// #     .enable_http2()
3289/// #     .build();
3290///
3291/// # let executor = hyper_util::rt::TokioExecutor::new();
3292/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3293/// #     secret,
3294/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3295/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3296/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3297/// #     ),
3298/// # ).build().await.unwrap();
3299///
3300/// # let client = hyper_util::client::legacy::Client::builder(
3301/// #     hyper_util::rt::TokioExecutor::new()
3302/// # )
3303/// # .build(
3304/// #     hyper_rustls::HttpsConnectorBuilder::new()
3305/// #         .with_native_roots()
3306/// #         .unwrap()
3307/// #         .https_or_http()
3308/// #         .enable_http2()
3309/// #         .build()
3310/// # );
3311/// # let mut hub = Speech::new(client, auth);
3312/// // As the method needs a request, you would usually fill it with the desired information
3313/// // into the respective structure. Some of the parts shown here might not be applicable !
3314/// // Values shown here are possibly random and not representative !
3315/// let mut req = CustomClass::default();
3316///
3317/// // You can configure optional parameters by calling the respective setters at will, and
3318/// // execute the final call using `doit()`.
3319/// // Values shown here are possibly random and not representative !
3320/// let result = hub.projects().locations_custom_classes_patch(req, "name")
3321///              .update_mask(FieldMask::new::<&str>(&[]))
3322///              .doit().await;
3323/// # }
3324/// ```
3325pub struct ProjectLocationCustomClassPatchCall<'a, C>
3326where
3327    C: 'a,
3328{
3329    hub: &'a Speech<C>,
3330    _request: CustomClass,
3331    _name: String,
3332    _update_mask: Option<common::FieldMask>,
3333    _delegate: Option<&'a mut dyn common::Delegate>,
3334    _additional_params: HashMap<String, String>,
3335    _scopes: BTreeSet<String>,
3336}
3337
3338impl<'a, C> common::CallBuilder for ProjectLocationCustomClassPatchCall<'a, C> {}
3339
3340impl<'a, C> ProjectLocationCustomClassPatchCall<'a, C>
3341where
3342    C: common::Connector,
3343{
3344    /// Perform the operation you have build so far.
3345    pub async fn doit(mut self) -> common::Result<(common::Response, CustomClass)> {
3346        use std::borrow::Cow;
3347        use std::io::{Read, Seek};
3348
3349        use common::{url::Params, ToParts};
3350        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3351
3352        let mut dd = common::DefaultDelegate;
3353        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3354        dlg.begin(common::MethodInfo {
3355            id: "speech.projects.locations.customClasses.patch",
3356            http_method: hyper::Method::PATCH,
3357        });
3358
3359        for &field in ["alt", "name", "updateMask"].iter() {
3360            if self._additional_params.contains_key(field) {
3361                dlg.finished(false);
3362                return Err(common::Error::FieldClash(field));
3363            }
3364        }
3365
3366        let mut params = Params::with_capacity(5 + self._additional_params.len());
3367        params.push("name", self._name);
3368        if let Some(value) = self._update_mask.as_ref() {
3369            params.push("updateMask", value.to_string());
3370        }
3371
3372        params.extend(self._additional_params.iter());
3373
3374        params.push("alt", "json");
3375        let mut url = self.hub._base_url.clone() + "v1/{+name}";
3376        if self._scopes.is_empty() {
3377            self._scopes
3378                .insert(Scope::CloudPlatform.as_ref().to_string());
3379        }
3380
3381        #[allow(clippy::single_element_loop)]
3382        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3383            url = params.uri_replacement(url, param_name, find_this, true);
3384        }
3385        {
3386            let to_remove = ["name"];
3387            params.remove_params(&to_remove);
3388        }
3389
3390        let url = params.parse_with_url(&url);
3391
3392        let mut json_mime_type = mime::APPLICATION_JSON;
3393        let mut request_value_reader = {
3394            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3395            common::remove_json_null_values(&mut value);
3396            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3397            serde_json::to_writer(&mut dst, &value).unwrap();
3398            dst
3399        };
3400        let request_size = request_value_reader
3401            .seek(std::io::SeekFrom::End(0))
3402            .unwrap();
3403        request_value_reader
3404            .seek(std::io::SeekFrom::Start(0))
3405            .unwrap();
3406
3407        loop {
3408            let token = match self
3409                .hub
3410                .auth
3411                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3412                .await
3413            {
3414                Ok(token) => token,
3415                Err(e) => match dlg.token(e) {
3416                    Ok(token) => token,
3417                    Err(e) => {
3418                        dlg.finished(false);
3419                        return Err(common::Error::MissingToken(e));
3420                    }
3421                },
3422            };
3423            request_value_reader
3424                .seek(std::io::SeekFrom::Start(0))
3425                .unwrap();
3426            let mut req_result = {
3427                let client = &self.hub.client;
3428                dlg.pre_request();
3429                let mut req_builder = hyper::Request::builder()
3430                    .method(hyper::Method::PATCH)
3431                    .uri(url.as_str())
3432                    .header(USER_AGENT, self.hub._user_agent.clone());
3433
3434                if let Some(token) = token.as_ref() {
3435                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3436                }
3437
3438                let request = req_builder
3439                    .header(CONTENT_TYPE, json_mime_type.to_string())
3440                    .header(CONTENT_LENGTH, request_size as u64)
3441                    .body(common::to_body(
3442                        request_value_reader.get_ref().clone().into(),
3443                    ));
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    ///
3502    /// Sets the *request* property to the given value.
3503    ///
3504    /// Even though the property as already been set when instantiating this call,
3505    /// we provide this method for API completeness.
3506    pub fn request(mut self, new_value: CustomClass) -> ProjectLocationCustomClassPatchCall<'a, C> {
3507        self._request = new_value;
3508        self
3509    }
3510    /// The resource name of the custom class.
3511    ///
3512    /// Sets the *name* path property to the given value.
3513    ///
3514    /// Even though the property as already been set when instantiating this call,
3515    /// we provide this method for API completeness.
3516    pub fn name(mut self, new_value: &str) -> ProjectLocationCustomClassPatchCall<'a, C> {
3517        self._name = new_value.to_string();
3518        self
3519    }
3520    /// The list of fields to be updated.
3521    ///
3522    /// Sets the *update mask* query property to the given value.
3523    pub fn update_mask(
3524        mut self,
3525        new_value: common::FieldMask,
3526    ) -> ProjectLocationCustomClassPatchCall<'a, C> {
3527        self._update_mask = Some(new_value);
3528        self
3529    }
3530    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3531    /// while executing the actual API request.
3532    ///
3533    /// ````text
3534    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3535    /// ````
3536    ///
3537    /// Sets the *delegate* property to the given value.
3538    pub fn delegate(
3539        mut self,
3540        new_value: &'a mut dyn common::Delegate,
3541    ) -> ProjectLocationCustomClassPatchCall<'a, C> {
3542        self._delegate = Some(new_value);
3543        self
3544    }
3545
3546    /// Set any additional parameter of the query string used in the request.
3547    /// It should be used to set parameters which are not yet available through their own
3548    /// setters.
3549    ///
3550    /// Please note that this method must not be used to set any of the known parameters
3551    /// which have their own setter method. If done anyway, the request will fail.
3552    ///
3553    /// # Additional Parameters
3554    ///
3555    /// * *$.xgafv* (query-string) - V1 error format.
3556    /// * *access_token* (query-string) - OAuth access token.
3557    /// * *alt* (query-string) - Data format for response.
3558    /// * *callback* (query-string) - JSONP
3559    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3560    /// * *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.
3561    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3562    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3563    /// * *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.
3564    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3565    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3566    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCustomClassPatchCall<'a, C>
3567    where
3568        T: AsRef<str>,
3569    {
3570        self._additional_params
3571            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3572        self
3573    }
3574
3575    /// Identifies the authorization scope for the method you are building.
3576    ///
3577    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3578    /// [`Scope::CloudPlatform`].
3579    ///
3580    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3581    /// tokens for more than one scope.
3582    ///
3583    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3584    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3585    /// sufficient, a read-write scope will do as well.
3586    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCustomClassPatchCall<'a, C>
3587    where
3588        St: AsRef<str>,
3589    {
3590        self._scopes.insert(String::from(scope.as_ref()));
3591        self
3592    }
3593    /// Identifies the authorization scope(s) for the method you are building.
3594    ///
3595    /// See [`Self::add_scope()`] for details.
3596    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationCustomClassPatchCall<'a, C>
3597    where
3598        I: IntoIterator<Item = St>,
3599        St: AsRef<str>,
3600    {
3601        self._scopes
3602            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3603        self
3604    }
3605
3606    /// Removes all scopes, and no default scope will be used either.
3607    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3608    /// for details).
3609    pub fn clear_scopes(mut self) -> ProjectLocationCustomClassPatchCall<'a, C> {
3610        self._scopes.clear();
3611        self
3612    }
3613}
3614
3615/// Create a set of phrase hints. Each item in the set can be a single word or a multi-word phrase. The items in the PhraseSet are favored by the recognition model when you send a call that includes the PhraseSet.
3616///
3617/// A builder for the *locations.phraseSets.create* method supported by a *project* resource.
3618/// It is not used directly, but through a [`ProjectMethods`] instance.
3619///
3620/// # Example
3621///
3622/// Instantiate a resource method builder
3623///
3624/// ```test_harness,no_run
3625/// # extern crate hyper;
3626/// # extern crate hyper_rustls;
3627/// # extern crate google_speech1 as speech1;
3628/// use speech1::api::CreatePhraseSetRequest;
3629/// # async fn dox() {
3630/// # use speech1::{Speech, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3631///
3632/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3633/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3634/// #     .with_native_roots()
3635/// #     .unwrap()
3636/// #     .https_only()
3637/// #     .enable_http2()
3638/// #     .build();
3639///
3640/// # let executor = hyper_util::rt::TokioExecutor::new();
3641/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3642/// #     secret,
3643/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3644/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3645/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3646/// #     ),
3647/// # ).build().await.unwrap();
3648///
3649/// # let client = hyper_util::client::legacy::Client::builder(
3650/// #     hyper_util::rt::TokioExecutor::new()
3651/// # )
3652/// # .build(
3653/// #     hyper_rustls::HttpsConnectorBuilder::new()
3654/// #         .with_native_roots()
3655/// #         .unwrap()
3656/// #         .https_or_http()
3657/// #         .enable_http2()
3658/// #         .build()
3659/// # );
3660/// # let mut hub = Speech::new(client, auth);
3661/// // As the method needs a request, you would usually fill it with the desired information
3662/// // into the respective structure. Some of the parts shown here might not be applicable !
3663/// // Values shown here are possibly random and not representative !
3664/// let mut req = CreatePhraseSetRequest::default();
3665///
3666/// // You can configure optional parameters by calling the respective setters at will, and
3667/// // execute the final call using `doit()`.
3668/// // Values shown here are possibly random and not representative !
3669/// let result = hub.projects().locations_phrase_sets_create(req, "parent")
3670///              .doit().await;
3671/// # }
3672/// ```
3673pub struct ProjectLocationPhraseSetCreateCall<'a, C>
3674where
3675    C: 'a,
3676{
3677    hub: &'a Speech<C>,
3678    _request: CreatePhraseSetRequest,
3679    _parent: String,
3680    _delegate: Option<&'a mut dyn common::Delegate>,
3681    _additional_params: HashMap<String, String>,
3682    _scopes: BTreeSet<String>,
3683}
3684
3685impl<'a, C> common::CallBuilder for ProjectLocationPhraseSetCreateCall<'a, C> {}
3686
3687impl<'a, C> ProjectLocationPhraseSetCreateCall<'a, C>
3688where
3689    C: common::Connector,
3690{
3691    /// Perform the operation you have build so far.
3692    pub async fn doit(mut self) -> common::Result<(common::Response, PhraseSet)> {
3693        use std::borrow::Cow;
3694        use std::io::{Read, Seek};
3695
3696        use common::{url::Params, ToParts};
3697        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3698
3699        let mut dd = common::DefaultDelegate;
3700        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3701        dlg.begin(common::MethodInfo {
3702            id: "speech.projects.locations.phraseSets.create",
3703            http_method: hyper::Method::POST,
3704        });
3705
3706        for &field in ["alt", "parent"].iter() {
3707            if self._additional_params.contains_key(field) {
3708                dlg.finished(false);
3709                return Err(common::Error::FieldClash(field));
3710            }
3711        }
3712
3713        let mut params = Params::with_capacity(4 + self._additional_params.len());
3714        params.push("parent", self._parent);
3715
3716        params.extend(self._additional_params.iter());
3717
3718        params.push("alt", "json");
3719        let mut url = self.hub._base_url.clone() + "v1/{+parent}/phraseSets";
3720        if self._scopes.is_empty() {
3721            self._scopes
3722                .insert(Scope::CloudPlatform.as_ref().to_string());
3723        }
3724
3725        #[allow(clippy::single_element_loop)]
3726        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3727            url = params.uri_replacement(url, param_name, find_this, true);
3728        }
3729        {
3730            let to_remove = ["parent"];
3731            params.remove_params(&to_remove);
3732        }
3733
3734        let url = params.parse_with_url(&url);
3735
3736        let mut json_mime_type = mime::APPLICATION_JSON;
3737        let mut request_value_reader = {
3738            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3739            common::remove_json_null_values(&mut value);
3740            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3741            serde_json::to_writer(&mut dst, &value).unwrap();
3742            dst
3743        };
3744        let request_size = request_value_reader
3745            .seek(std::io::SeekFrom::End(0))
3746            .unwrap();
3747        request_value_reader
3748            .seek(std::io::SeekFrom::Start(0))
3749            .unwrap();
3750
3751        loop {
3752            let token = match self
3753                .hub
3754                .auth
3755                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3756                .await
3757            {
3758                Ok(token) => token,
3759                Err(e) => match dlg.token(e) {
3760                    Ok(token) => token,
3761                    Err(e) => {
3762                        dlg.finished(false);
3763                        return Err(common::Error::MissingToken(e));
3764                    }
3765                },
3766            };
3767            request_value_reader
3768                .seek(std::io::SeekFrom::Start(0))
3769                .unwrap();
3770            let mut req_result = {
3771                let client = &self.hub.client;
3772                dlg.pre_request();
3773                let mut req_builder = hyper::Request::builder()
3774                    .method(hyper::Method::POST)
3775                    .uri(url.as_str())
3776                    .header(USER_AGENT, self.hub._user_agent.clone());
3777
3778                if let Some(token) = token.as_ref() {
3779                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3780                }
3781
3782                let request = req_builder
3783                    .header(CONTENT_TYPE, json_mime_type.to_string())
3784                    .header(CONTENT_LENGTH, request_size as u64)
3785                    .body(common::to_body(
3786                        request_value_reader.get_ref().clone().into(),
3787                    ));
3788
3789                client.request(request.unwrap()).await
3790            };
3791
3792            match req_result {
3793                Err(err) => {
3794                    if let common::Retry::After(d) = dlg.http_error(&err) {
3795                        sleep(d).await;
3796                        continue;
3797                    }
3798                    dlg.finished(false);
3799                    return Err(common::Error::HttpError(err));
3800                }
3801                Ok(res) => {
3802                    let (mut parts, body) = res.into_parts();
3803                    let mut body = common::Body::new(body);
3804                    if !parts.status.is_success() {
3805                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3806                        let error = serde_json::from_str(&common::to_string(&bytes));
3807                        let response = common::to_response(parts, bytes.into());
3808
3809                        if let common::Retry::After(d) =
3810                            dlg.http_failure(&response, error.as_ref().ok())
3811                        {
3812                            sleep(d).await;
3813                            continue;
3814                        }
3815
3816                        dlg.finished(false);
3817
3818                        return Err(match error {
3819                            Ok(value) => common::Error::BadRequest(value),
3820                            _ => common::Error::Failure(response),
3821                        });
3822                    }
3823                    let response = {
3824                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3825                        let encoded = common::to_string(&bytes);
3826                        match serde_json::from_str(&encoded) {
3827                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3828                            Err(error) => {
3829                                dlg.response_json_decode_error(&encoded, &error);
3830                                return Err(common::Error::JsonDecodeError(
3831                                    encoded.to_string(),
3832                                    error,
3833                                ));
3834                            }
3835                        }
3836                    };
3837
3838                    dlg.finished(true);
3839                    return Ok(response);
3840                }
3841            }
3842        }
3843    }
3844
3845    ///
3846    /// Sets the *request* property to the given value.
3847    ///
3848    /// Even though the property as already been set when instantiating this call,
3849    /// we provide this method for API completeness.
3850    pub fn request(
3851        mut self,
3852        new_value: CreatePhraseSetRequest,
3853    ) -> ProjectLocationPhraseSetCreateCall<'a, C> {
3854        self._request = new_value;
3855        self
3856    }
3857    /// Required. The parent resource where this phrase set will be created. Format: `projects/{project}/locations/{location}` Speech-to-Text supports three locations: `global`, `us` (US North America), and `eu` (Europe). If you are calling the `speech.googleapis.com` endpoint, use the `global` location. To specify a region, use a [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) with matching `us` or `eu` location value.
3858    ///
3859    /// Sets the *parent* path property to the given value.
3860    ///
3861    /// Even though the property as already been set when instantiating this call,
3862    /// we provide this method for API completeness.
3863    pub fn parent(mut self, new_value: &str) -> ProjectLocationPhraseSetCreateCall<'a, C> {
3864        self._parent = new_value.to_string();
3865        self
3866    }
3867    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3868    /// while executing the actual API request.
3869    ///
3870    /// ````text
3871    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3872    /// ````
3873    ///
3874    /// Sets the *delegate* property to the given value.
3875    pub fn delegate(
3876        mut self,
3877        new_value: &'a mut dyn common::Delegate,
3878    ) -> ProjectLocationPhraseSetCreateCall<'a, C> {
3879        self._delegate = Some(new_value);
3880        self
3881    }
3882
3883    /// Set any additional parameter of the query string used in the request.
3884    /// It should be used to set parameters which are not yet available through their own
3885    /// setters.
3886    ///
3887    /// Please note that this method must not be used to set any of the known parameters
3888    /// which have their own setter method. If done anyway, the request will fail.
3889    ///
3890    /// # Additional Parameters
3891    ///
3892    /// * *$.xgafv* (query-string) - V1 error format.
3893    /// * *access_token* (query-string) - OAuth access token.
3894    /// * *alt* (query-string) - Data format for response.
3895    /// * *callback* (query-string) - JSONP
3896    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3897    /// * *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.
3898    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3899    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3900    /// * *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.
3901    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3902    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3903    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationPhraseSetCreateCall<'a, C>
3904    where
3905        T: AsRef<str>,
3906    {
3907        self._additional_params
3908            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3909        self
3910    }
3911
3912    /// Identifies the authorization scope for the method you are building.
3913    ///
3914    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3915    /// [`Scope::CloudPlatform`].
3916    ///
3917    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3918    /// tokens for more than one scope.
3919    ///
3920    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3921    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3922    /// sufficient, a read-write scope will do as well.
3923    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationPhraseSetCreateCall<'a, C>
3924    where
3925        St: AsRef<str>,
3926    {
3927        self._scopes.insert(String::from(scope.as_ref()));
3928        self
3929    }
3930    /// Identifies the authorization scope(s) for the method you are building.
3931    ///
3932    /// See [`Self::add_scope()`] for details.
3933    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationPhraseSetCreateCall<'a, C>
3934    where
3935        I: IntoIterator<Item = St>,
3936        St: AsRef<str>,
3937    {
3938        self._scopes
3939            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3940        self
3941    }
3942
3943    /// Removes all scopes, and no default scope will be used either.
3944    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3945    /// for details).
3946    pub fn clear_scopes(mut self) -> ProjectLocationPhraseSetCreateCall<'a, C> {
3947        self._scopes.clear();
3948        self
3949    }
3950}
3951
3952/// Delete a phrase set.
3953///
3954/// A builder for the *locations.phraseSets.delete* method supported by a *project* resource.
3955/// It is not used directly, but through a [`ProjectMethods`] instance.
3956///
3957/// # Example
3958///
3959/// Instantiate a resource method builder
3960///
3961/// ```test_harness,no_run
3962/// # extern crate hyper;
3963/// # extern crate hyper_rustls;
3964/// # extern crate google_speech1 as speech1;
3965/// # async fn dox() {
3966/// # use speech1::{Speech, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3967///
3968/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3969/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3970/// #     .with_native_roots()
3971/// #     .unwrap()
3972/// #     .https_only()
3973/// #     .enable_http2()
3974/// #     .build();
3975///
3976/// # let executor = hyper_util::rt::TokioExecutor::new();
3977/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3978/// #     secret,
3979/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3980/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3981/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3982/// #     ),
3983/// # ).build().await.unwrap();
3984///
3985/// # let client = hyper_util::client::legacy::Client::builder(
3986/// #     hyper_util::rt::TokioExecutor::new()
3987/// # )
3988/// # .build(
3989/// #     hyper_rustls::HttpsConnectorBuilder::new()
3990/// #         .with_native_roots()
3991/// #         .unwrap()
3992/// #         .https_or_http()
3993/// #         .enable_http2()
3994/// #         .build()
3995/// # );
3996/// # let mut hub = Speech::new(client, auth);
3997/// // You can configure optional parameters by calling the respective setters at will, and
3998/// // execute the final call using `doit()`.
3999/// // Values shown here are possibly random and not representative !
4000/// let result = hub.projects().locations_phrase_sets_delete("name")
4001///              .doit().await;
4002/// # }
4003/// ```
4004pub struct ProjectLocationPhraseSetDeleteCall<'a, C>
4005where
4006    C: 'a,
4007{
4008    hub: &'a Speech<C>,
4009    _name: String,
4010    _delegate: Option<&'a mut dyn common::Delegate>,
4011    _additional_params: HashMap<String, String>,
4012    _scopes: BTreeSet<String>,
4013}
4014
4015impl<'a, C> common::CallBuilder for ProjectLocationPhraseSetDeleteCall<'a, C> {}
4016
4017impl<'a, C> ProjectLocationPhraseSetDeleteCall<'a, C>
4018where
4019    C: common::Connector,
4020{
4021    /// Perform the operation you have build so far.
4022    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
4023        use std::borrow::Cow;
4024        use std::io::{Read, Seek};
4025
4026        use common::{url::Params, ToParts};
4027        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4028
4029        let mut dd = common::DefaultDelegate;
4030        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4031        dlg.begin(common::MethodInfo {
4032            id: "speech.projects.locations.phraseSets.delete",
4033            http_method: hyper::Method::DELETE,
4034        });
4035
4036        for &field in ["alt", "name"].iter() {
4037            if self._additional_params.contains_key(field) {
4038                dlg.finished(false);
4039                return Err(common::Error::FieldClash(field));
4040            }
4041        }
4042
4043        let mut params = Params::with_capacity(3 + self._additional_params.len());
4044        params.push("name", self._name);
4045
4046        params.extend(self._additional_params.iter());
4047
4048        params.push("alt", "json");
4049        let mut url = self.hub._base_url.clone() + "v1/{+name}";
4050        if self._scopes.is_empty() {
4051            self._scopes
4052                .insert(Scope::CloudPlatform.as_ref().to_string());
4053        }
4054
4055        #[allow(clippy::single_element_loop)]
4056        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4057            url = params.uri_replacement(url, param_name, find_this, true);
4058        }
4059        {
4060            let to_remove = ["name"];
4061            params.remove_params(&to_remove);
4062        }
4063
4064        let url = params.parse_with_url(&url);
4065
4066        loop {
4067            let token = match self
4068                .hub
4069                .auth
4070                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4071                .await
4072            {
4073                Ok(token) => token,
4074                Err(e) => match dlg.token(e) {
4075                    Ok(token) => token,
4076                    Err(e) => {
4077                        dlg.finished(false);
4078                        return Err(common::Error::MissingToken(e));
4079                    }
4080                },
4081            };
4082            let mut req_result = {
4083                let client = &self.hub.client;
4084                dlg.pre_request();
4085                let mut req_builder = hyper::Request::builder()
4086                    .method(hyper::Method::DELETE)
4087                    .uri(url.as_str())
4088                    .header(USER_AGENT, self.hub._user_agent.clone());
4089
4090                if let Some(token) = token.as_ref() {
4091                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4092                }
4093
4094                let request = req_builder
4095                    .header(CONTENT_LENGTH, 0_u64)
4096                    .body(common::to_body::<String>(None));
4097
4098                client.request(request.unwrap()).await
4099            };
4100
4101            match req_result {
4102                Err(err) => {
4103                    if let common::Retry::After(d) = dlg.http_error(&err) {
4104                        sleep(d).await;
4105                        continue;
4106                    }
4107                    dlg.finished(false);
4108                    return Err(common::Error::HttpError(err));
4109                }
4110                Ok(res) => {
4111                    let (mut parts, body) = res.into_parts();
4112                    let mut body = common::Body::new(body);
4113                    if !parts.status.is_success() {
4114                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4115                        let error = serde_json::from_str(&common::to_string(&bytes));
4116                        let response = common::to_response(parts, bytes.into());
4117
4118                        if let common::Retry::After(d) =
4119                            dlg.http_failure(&response, error.as_ref().ok())
4120                        {
4121                            sleep(d).await;
4122                            continue;
4123                        }
4124
4125                        dlg.finished(false);
4126
4127                        return Err(match error {
4128                            Ok(value) => common::Error::BadRequest(value),
4129                            _ => common::Error::Failure(response),
4130                        });
4131                    }
4132                    let response = {
4133                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4134                        let encoded = common::to_string(&bytes);
4135                        match serde_json::from_str(&encoded) {
4136                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4137                            Err(error) => {
4138                                dlg.response_json_decode_error(&encoded, &error);
4139                                return Err(common::Error::JsonDecodeError(
4140                                    encoded.to_string(),
4141                                    error,
4142                                ));
4143                            }
4144                        }
4145                    };
4146
4147                    dlg.finished(true);
4148                    return Ok(response);
4149                }
4150            }
4151        }
4152    }
4153
4154    /// Required. The name of the phrase set to delete. Format: `projects/{project}/locations/{location}/phraseSets/{phrase_set}`
4155    ///
4156    /// Sets the *name* path property to the given value.
4157    ///
4158    /// Even though the property as already been set when instantiating this call,
4159    /// we provide this method for API completeness.
4160    pub fn name(mut self, new_value: &str) -> ProjectLocationPhraseSetDeleteCall<'a, C> {
4161        self._name = new_value.to_string();
4162        self
4163    }
4164    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4165    /// while executing the actual API request.
4166    ///
4167    /// ````text
4168    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4169    /// ````
4170    ///
4171    /// Sets the *delegate* property to the given value.
4172    pub fn delegate(
4173        mut self,
4174        new_value: &'a mut dyn common::Delegate,
4175    ) -> ProjectLocationPhraseSetDeleteCall<'a, C> {
4176        self._delegate = Some(new_value);
4177        self
4178    }
4179
4180    /// Set any additional parameter of the query string used in the request.
4181    /// It should be used to set parameters which are not yet available through their own
4182    /// setters.
4183    ///
4184    /// Please note that this method must not be used to set any of the known parameters
4185    /// which have their own setter method. If done anyway, the request will fail.
4186    ///
4187    /// # Additional Parameters
4188    ///
4189    /// * *$.xgafv* (query-string) - V1 error format.
4190    /// * *access_token* (query-string) - OAuth access token.
4191    /// * *alt* (query-string) - Data format for response.
4192    /// * *callback* (query-string) - JSONP
4193    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4194    /// * *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.
4195    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4196    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4197    /// * *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.
4198    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4199    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4200    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationPhraseSetDeleteCall<'a, C>
4201    where
4202        T: AsRef<str>,
4203    {
4204        self._additional_params
4205            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4206        self
4207    }
4208
4209    /// Identifies the authorization scope for the method you are building.
4210    ///
4211    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4212    /// [`Scope::CloudPlatform`].
4213    ///
4214    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4215    /// tokens for more than one scope.
4216    ///
4217    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4218    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4219    /// sufficient, a read-write scope will do as well.
4220    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationPhraseSetDeleteCall<'a, C>
4221    where
4222        St: AsRef<str>,
4223    {
4224        self._scopes.insert(String::from(scope.as_ref()));
4225        self
4226    }
4227    /// Identifies the authorization scope(s) for the method you are building.
4228    ///
4229    /// See [`Self::add_scope()`] for details.
4230    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationPhraseSetDeleteCall<'a, C>
4231    where
4232        I: IntoIterator<Item = St>,
4233        St: AsRef<str>,
4234    {
4235        self._scopes
4236            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4237        self
4238    }
4239
4240    /// Removes all scopes, and no default scope will be used either.
4241    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4242    /// for details).
4243    pub fn clear_scopes(mut self) -> ProjectLocationPhraseSetDeleteCall<'a, C> {
4244        self._scopes.clear();
4245        self
4246    }
4247}
4248
4249/// Get a phrase set.
4250///
4251/// A builder for the *locations.phraseSets.get* method supported by a *project* resource.
4252/// It is not used directly, but through a [`ProjectMethods`] instance.
4253///
4254/// # Example
4255///
4256/// Instantiate a resource method builder
4257///
4258/// ```test_harness,no_run
4259/// # extern crate hyper;
4260/// # extern crate hyper_rustls;
4261/// # extern crate google_speech1 as speech1;
4262/// # async fn dox() {
4263/// # use speech1::{Speech, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4264///
4265/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4266/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4267/// #     .with_native_roots()
4268/// #     .unwrap()
4269/// #     .https_only()
4270/// #     .enable_http2()
4271/// #     .build();
4272///
4273/// # let executor = hyper_util::rt::TokioExecutor::new();
4274/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4275/// #     secret,
4276/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4277/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4278/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4279/// #     ),
4280/// # ).build().await.unwrap();
4281///
4282/// # let client = hyper_util::client::legacy::Client::builder(
4283/// #     hyper_util::rt::TokioExecutor::new()
4284/// # )
4285/// # .build(
4286/// #     hyper_rustls::HttpsConnectorBuilder::new()
4287/// #         .with_native_roots()
4288/// #         .unwrap()
4289/// #         .https_or_http()
4290/// #         .enable_http2()
4291/// #         .build()
4292/// # );
4293/// # let mut hub = Speech::new(client, auth);
4294/// // You can configure optional parameters by calling the respective setters at will, and
4295/// // execute the final call using `doit()`.
4296/// // Values shown here are possibly random and not representative !
4297/// let result = hub.projects().locations_phrase_sets_get("name")
4298///              .doit().await;
4299/// # }
4300/// ```
4301pub struct ProjectLocationPhraseSetGetCall<'a, C>
4302where
4303    C: 'a,
4304{
4305    hub: &'a Speech<C>,
4306    _name: String,
4307    _delegate: Option<&'a mut dyn common::Delegate>,
4308    _additional_params: HashMap<String, String>,
4309    _scopes: BTreeSet<String>,
4310}
4311
4312impl<'a, C> common::CallBuilder for ProjectLocationPhraseSetGetCall<'a, C> {}
4313
4314impl<'a, C> ProjectLocationPhraseSetGetCall<'a, C>
4315where
4316    C: common::Connector,
4317{
4318    /// Perform the operation you have build so far.
4319    pub async fn doit(mut self) -> common::Result<(common::Response, PhraseSet)> {
4320        use std::borrow::Cow;
4321        use std::io::{Read, Seek};
4322
4323        use common::{url::Params, ToParts};
4324        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4325
4326        let mut dd = common::DefaultDelegate;
4327        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4328        dlg.begin(common::MethodInfo {
4329            id: "speech.projects.locations.phraseSets.get",
4330            http_method: hyper::Method::GET,
4331        });
4332
4333        for &field in ["alt", "name"].iter() {
4334            if self._additional_params.contains_key(field) {
4335                dlg.finished(false);
4336                return Err(common::Error::FieldClash(field));
4337            }
4338        }
4339
4340        let mut params = Params::with_capacity(3 + self._additional_params.len());
4341        params.push("name", self._name);
4342
4343        params.extend(self._additional_params.iter());
4344
4345        params.push("alt", "json");
4346        let mut url = self.hub._base_url.clone() + "v1/{+name}";
4347        if self._scopes.is_empty() {
4348            self._scopes
4349                .insert(Scope::CloudPlatform.as_ref().to_string());
4350        }
4351
4352        #[allow(clippy::single_element_loop)]
4353        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4354            url = params.uri_replacement(url, param_name, find_this, true);
4355        }
4356        {
4357            let to_remove = ["name"];
4358            params.remove_params(&to_remove);
4359        }
4360
4361        let url = params.parse_with_url(&url);
4362
4363        loop {
4364            let token = match self
4365                .hub
4366                .auth
4367                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4368                .await
4369            {
4370                Ok(token) => token,
4371                Err(e) => match dlg.token(e) {
4372                    Ok(token) => token,
4373                    Err(e) => {
4374                        dlg.finished(false);
4375                        return Err(common::Error::MissingToken(e));
4376                    }
4377                },
4378            };
4379            let mut req_result = {
4380                let client = &self.hub.client;
4381                dlg.pre_request();
4382                let mut req_builder = hyper::Request::builder()
4383                    .method(hyper::Method::GET)
4384                    .uri(url.as_str())
4385                    .header(USER_AGENT, self.hub._user_agent.clone());
4386
4387                if let Some(token) = token.as_ref() {
4388                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4389                }
4390
4391                let request = req_builder
4392                    .header(CONTENT_LENGTH, 0_u64)
4393                    .body(common::to_body::<String>(None));
4394
4395                client.request(request.unwrap()).await
4396            };
4397
4398            match req_result {
4399                Err(err) => {
4400                    if let common::Retry::After(d) = dlg.http_error(&err) {
4401                        sleep(d).await;
4402                        continue;
4403                    }
4404                    dlg.finished(false);
4405                    return Err(common::Error::HttpError(err));
4406                }
4407                Ok(res) => {
4408                    let (mut parts, body) = res.into_parts();
4409                    let mut body = common::Body::new(body);
4410                    if !parts.status.is_success() {
4411                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4412                        let error = serde_json::from_str(&common::to_string(&bytes));
4413                        let response = common::to_response(parts, bytes.into());
4414
4415                        if let common::Retry::After(d) =
4416                            dlg.http_failure(&response, error.as_ref().ok())
4417                        {
4418                            sleep(d).await;
4419                            continue;
4420                        }
4421
4422                        dlg.finished(false);
4423
4424                        return Err(match error {
4425                            Ok(value) => common::Error::BadRequest(value),
4426                            _ => common::Error::Failure(response),
4427                        });
4428                    }
4429                    let response = {
4430                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4431                        let encoded = common::to_string(&bytes);
4432                        match serde_json::from_str(&encoded) {
4433                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4434                            Err(error) => {
4435                                dlg.response_json_decode_error(&encoded, &error);
4436                                return Err(common::Error::JsonDecodeError(
4437                                    encoded.to_string(),
4438                                    error,
4439                                ));
4440                            }
4441                        }
4442                    };
4443
4444                    dlg.finished(true);
4445                    return Ok(response);
4446                }
4447            }
4448        }
4449    }
4450
4451    /// Required. The name of the phrase set to retrieve. Format: `projects/{project}/locations/{location}/phraseSets/{phrase_set}` Speech-to-Text supports three locations: `global`, `us` (US North America), and `eu` (Europe). If you are calling the `speech.googleapis.com` endpoint, use the `global` location. To specify a region, use a [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) with matching `us` or `eu` location value.
4452    ///
4453    /// Sets the *name* path property to the given value.
4454    ///
4455    /// Even though the property as already been set when instantiating this call,
4456    /// we provide this method for API completeness.
4457    pub fn name(mut self, new_value: &str) -> ProjectLocationPhraseSetGetCall<'a, C> {
4458        self._name = new_value.to_string();
4459        self
4460    }
4461    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4462    /// while executing the actual API request.
4463    ///
4464    /// ````text
4465    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4466    /// ````
4467    ///
4468    /// Sets the *delegate* property to the given value.
4469    pub fn delegate(
4470        mut self,
4471        new_value: &'a mut dyn common::Delegate,
4472    ) -> ProjectLocationPhraseSetGetCall<'a, C> {
4473        self._delegate = Some(new_value);
4474        self
4475    }
4476
4477    /// Set any additional parameter of the query string used in the request.
4478    /// It should be used to set parameters which are not yet available through their own
4479    /// setters.
4480    ///
4481    /// Please note that this method must not be used to set any of the known parameters
4482    /// which have their own setter method. If done anyway, the request will fail.
4483    ///
4484    /// # Additional Parameters
4485    ///
4486    /// * *$.xgafv* (query-string) - V1 error format.
4487    /// * *access_token* (query-string) - OAuth access token.
4488    /// * *alt* (query-string) - Data format for response.
4489    /// * *callback* (query-string) - JSONP
4490    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4491    /// * *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.
4492    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4493    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4494    /// * *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.
4495    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4496    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4497    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationPhraseSetGetCall<'a, C>
4498    where
4499        T: AsRef<str>,
4500    {
4501        self._additional_params
4502            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4503        self
4504    }
4505
4506    /// Identifies the authorization scope for the method you are building.
4507    ///
4508    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4509    /// [`Scope::CloudPlatform`].
4510    ///
4511    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4512    /// tokens for more than one scope.
4513    ///
4514    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4515    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4516    /// sufficient, a read-write scope will do as well.
4517    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationPhraseSetGetCall<'a, C>
4518    where
4519        St: AsRef<str>,
4520    {
4521        self._scopes.insert(String::from(scope.as_ref()));
4522        self
4523    }
4524    /// Identifies the authorization scope(s) for the method you are building.
4525    ///
4526    /// See [`Self::add_scope()`] for details.
4527    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationPhraseSetGetCall<'a, C>
4528    where
4529        I: IntoIterator<Item = St>,
4530        St: AsRef<str>,
4531    {
4532        self._scopes
4533            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4534        self
4535    }
4536
4537    /// Removes all scopes, and no default scope will be used either.
4538    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4539    /// for details).
4540    pub fn clear_scopes(mut self) -> ProjectLocationPhraseSetGetCall<'a, C> {
4541        self._scopes.clear();
4542        self
4543    }
4544}
4545
4546/// List phrase sets.
4547///
4548/// A builder for the *locations.phraseSets.list* method supported by a *project* resource.
4549/// It is not used directly, but through a [`ProjectMethods`] instance.
4550///
4551/// # Example
4552///
4553/// Instantiate a resource method builder
4554///
4555/// ```test_harness,no_run
4556/// # extern crate hyper;
4557/// # extern crate hyper_rustls;
4558/// # extern crate google_speech1 as speech1;
4559/// # async fn dox() {
4560/// # use speech1::{Speech, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4561///
4562/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4563/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4564/// #     .with_native_roots()
4565/// #     .unwrap()
4566/// #     .https_only()
4567/// #     .enable_http2()
4568/// #     .build();
4569///
4570/// # let executor = hyper_util::rt::TokioExecutor::new();
4571/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4572/// #     secret,
4573/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4574/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4575/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4576/// #     ),
4577/// # ).build().await.unwrap();
4578///
4579/// # let client = hyper_util::client::legacy::Client::builder(
4580/// #     hyper_util::rt::TokioExecutor::new()
4581/// # )
4582/// # .build(
4583/// #     hyper_rustls::HttpsConnectorBuilder::new()
4584/// #         .with_native_roots()
4585/// #         .unwrap()
4586/// #         .https_or_http()
4587/// #         .enable_http2()
4588/// #         .build()
4589/// # );
4590/// # let mut hub = Speech::new(client, auth);
4591/// // You can configure optional parameters by calling the respective setters at will, and
4592/// // execute the final call using `doit()`.
4593/// // Values shown here are possibly random and not representative !
4594/// let result = hub.projects().locations_phrase_sets_list("parent")
4595///              .page_token("ipsum")
4596///              .page_size(-93)
4597///              .doit().await;
4598/// # }
4599/// ```
4600pub struct ProjectLocationPhraseSetListCall<'a, C>
4601where
4602    C: 'a,
4603{
4604    hub: &'a Speech<C>,
4605    _parent: String,
4606    _page_token: Option<String>,
4607    _page_size: Option<i32>,
4608    _delegate: Option<&'a mut dyn common::Delegate>,
4609    _additional_params: HashMap<String, String>,
4610    _scopes: BTreeSet<String>,
4611}
4612
4613impl<'a, C> common::CallBuilder for ProjectLocationPhraseSetListCall<'a, C> {}
4614
4615impl<'a, C> ProjectLocationPhraseSetListCall<'a, C>
4616where
4617    C: common::Connector,
4618{
4619    /// Perform the operation you have build so far.
4620    pub async fn doit(mut self) -> common::Result<(common::Response, ListPhraseSetResponse)> {
4621        use std::borrow::Cow;
4622        use std::io::{Read, Seek};
4623
4624        use common::{url::Params, ToParts};
4625        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4626
4627        let mut dd = common::DefaultDelegate;
4628        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4629        dlg.begin(common::MethodInfo {
4630            id: "speech.projects.locations.phraseSets.list",
4631            http_method: hyper::Method::GET,
4632        });
4633
4634        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
4635            if self._additional_params.contains_key(field) {
4636                dlg.finished(false);
4637                return Err(common::Error::FieldClash(field));
4638            }
4639        }
4640
4641        let mut params = Params::with_capacity(5 + self._additional_params.len());
4642        params.push("parent", self._parent);
4643        if let Some(value) = self._page_token.as_ref() {
4644            params.push("pageToken", value);
4645        }
4646        if let Some(value) = self._page_size.as_ref() {
4647            params.push("pageSize", value.to_string());
4648        }
4649
4650        params.extend(self._additional_params.iter());
4651
4652        params.push("alt", "json");
4653        let mut url = self.hub._base_url.clone() + "v1/{+parent}/phraseSets";
4654        if self._scopes.is_empty() {
4655            self._scopes
4656                .insert(Scope::CloudPlatform.as_ref().to_string());
4657        }
4658
4659        #[allow(clippy::single_element_loop)]
4660        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4661            url = params.uri_replacement(url, param_name, find_this, true);
4662        }
4663        {
4664            let to_remove = ["parent"];
4665            params.remove_params(&to_remove);
4666        }
4667
4668        let url = params.parse_with_url(&url);
4669
4670        loop {
4671            let token = match self
4672                .hub
4673                .auth
4674                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4675                .await
4676            {
4677                Ok(token) => token,
4678                Err(e) => match dlg.token(e) {
4679                    Ok(token) => token,
4680                    Err(e) => {
4681                        dlg.finished(false);
4682                        return Err(common::Error::MissingToken(e));
4683                    }
4684                },
4685            };
4686            let mut req_result = {
4687                let client = &self.hub.client;
4688                dlg.pre_request();
4689                let mut req_builder = hyper::Request::builder()
4690                    .method(hyper::Method::GET)
4691                    .uri(url.as_str())
4692                    .header(USER_AGENT, self.hub._user_agent.clone());
4693
4694                if let Some(token) = token.as_ref() {
4695                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4696                }
4697
4698                let request = req_builder
4699                    .header(CONTENT_LENGTH, 0_u64)
4700                    .body(common::to_body::<String>(None));
4701
4702                client.request(request.unwrap()).await
4703            };
4704
4705            match req_result {
4706                Err(err) => {
4707                    if let common::Retry::After(d) = dlg.http_error(&err) {
4708                        sleep(d).await;
4709                        continue;
4710                    }
4711                    dlg.finished(false);
4712                    return Err(common::Error::HttpError(err));
4713                }
4714                Ok(res) => {
4715                    let (mut parts, body) = res.into_parts();
4716                    let mut body = common::Body::new(body);
4717                    if !parts.status.is_success() {
4718                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4719                        let error = serde_json::from_str(&common::to_string(&bytes));
4720                        let response = common::to_response(parts, bytes.into());
4721
4722                        if let common::Retry::After(d) =
4723                            dlg.http_failure(&response, error.as_ref().ok())
4724                        {
4725                            sleep(d).await;
4726                            continue;
4727                        }
4728
4729                        dlg.finished(false);
4730
4731                        return Err(match error {
4732                            Ok(value) => common::Error::BadRequest(value),
4733                            _ => common::Error::Failure(response),
4734                        });
4735                    }
4736                    let response = {
4737                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4738                        let encoded = common::to_string(&bytes);
4739                        match serde_json::from_str(&encoded) {
4740                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4741                            Err(error) => {
4742                                dlg.response_json_decode_error(&encoded, &error);
4743                                return Err(common::Error::JsonDecodeError(
4744                                    encoded.to_string(),
4745                                    error,
4746                                ));
4747                            }
4748                        }
4749                    };
4750
4751                    dlg.finished(true);
4752                    return Ok(response);
4753                }
4754            }
4755        }
4756    }
4757
4758    /// Required. The parent, which owns this collection of phrase set. Format: `projects/{project}/locations/{location}` Speech-to-Text supports three locations: `global`, `us` (US North America), and `eu` (Europe). If you are calling the `speech.googleapis.com` endpoint, use the `global` location. To specify a region, use a [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) with matching `us` or `eu` location value.
4759    ///
4760    /// Sets the *parent* path property to the given value.
4761    ///
4762    /// Even though the property as already been set when instantiating this call,
4763    /// we provide this method for API completeness.
4764    pub fn parent(mut self, new_value: &str) -> ProjectLocationPhraseSetListCall<'a, C> {
4765        self._parent = new_value.to_string();
4766        self
4767    }
4768    /// A page token, received from a previous `ListPhraseSet` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListPhraseSet` must match the call that provided the page token.
4769    ///
4770    /// Sets the *page token* query property to the given value.
4771    pub fn page_token(mut self, new_value: &str) -> ProjectLocationPhraseSetListCall<'a, C> {
4772        self._page_token = Some(new_value.to_string());
4773        self
4774    }
4775    /// The maximum number of phrase sets to return. The service may return fewer than this value. If unspecified, at most 50 phrase sets will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000.
4776    ///
4777    /// Sets the *page size* query property to the given value.
4778    pub fn page_size(mut self, new_value: i32) -> ProjectLocationPhraseSetListCall<'a, C> {
4779        self._page_size = Some(new_value);
4780        self
4781    }
4782    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4783    /// while executing the actual API request.
4784    ///
4785    /// ````text
4786    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4787    /// ````
4788    ///
4789    /// Sets the *delegate* property to the given value.
4790    pub fn delegate(
4791        mut self,
4792        new_value: &'a mut dyn common::Delegate,
4793    ) -> ProjectLocationPhraseSetListCall<'a, C> {
4794        self._delegate = Some(new_value);
4795        self
4796    }
4797
4798    /// Set any additional parameter of the query string used in the request.
4799    /// It should be used to set parameters which are not yet available through their own
4800    /// setters.
4801    ///
4802    /// Please note that this method must not be used to set any of the known parameters
4803    /// which have their own setter method. If done anyway, the request will fail.
4804    ///
4805    /// # Additional Parameters
4806    ///
4807    /// * *$.xgafv* (query-string) - V1 error format.
4808    /// * *access_token* (query-string) - OAuth access token.
4809    /// * *alt* (query-string) - Data format for response.
4810    /// * *callback* (query-string) - JSONP
4811    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4812    /// * *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.
4813    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4814    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4815    /// * *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.
4816    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4817    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4818    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationPhraseSetListCall<'a, C>
4819    where
4820        T: AsRef<str>,
4821    {
4822        self._additional_params
4823            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4824        self
4825    }
4826
4827    /// Identifies the authorization scope for the method you are building.
4828    ///
4829    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4830    /// [`Scope::CloudPlatform`].
4831    ///
4832    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4833    /// tokens for more than one scope.
4834    ///
4835    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4836    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4837    /// sufficient, a read-write scope will do as well.
4838    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationPhraseSetListCall<'a, C>
4839    where
4840        St: AsRef<str>,
4841    {
4842        self._scopes.insert(String::from(scope.as_ref()));
4843        self
4844    }
4845    /// Identifies the authorization scope(s) for the method you are building.
4846    ///
4847    /// See [`Self::add_scope()`] for details.
4848    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationPhraseSetListCall<'a, C>
4849    where
4850        I: IntoIterator<Item = St>,
4851        St: AsRef<str>,
4852    {
4853        self._scopes
4854            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4855        self
4856    }
4857
4858    /// Removes all scopes, and no default scope will be used either.
4859    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4860    /// for details).
4861    pub fn clear_scopes(mut self) -> ProjectLocationPhraseSetListCall<'a, C> {
4862        self._scopes.clear();
4863        self
4864    }
4865}
4866
4867/// Update a phrase set.
4868///
4869/// A builder for the *locations.phraseSets.patch* method supported by a *project* resource.
4870/// It is not used directly, but through a [`ProjectMethods`] instance.
4871///
4872/// # Example
4873///
4874/// Instantiate a resource method builder
4875///
4876/// ```test_harness,no_run
4877/// # extern crate hyper;
4878/// # extern crate hyper_rustls;
4879/// # extern crate google_speech1 as speech1;
4880/// use speech1::api::PhraseSet;
4881/// # async fn dox() {
4882/// # use speech1::{Speech, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4883///
4884/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4885/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4886/// #     .with_native_roots()
4887/// #     .unwrap()
4888/// #     .https_only()
4889/// #     .enable_http2()
4890/// #     .build();
4891///
4892/// # let executor = hyper_util::rt::TokioExecutor::new();
4893/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4894/// #     secret,
4895/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4896/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4897/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4898/// #     ),
4899/// # ).build().await.unwrap();
4900///
4901/// # let client = hyper_util::client::legacy::Client::builder(
4902/// #     hyper_util::rt::TokioExecutor::new()
4903/// # )
4904/// # .build(
4905/// #     hyper_rustls::HttpsConnectorBuilder::new()
4906/// #         .with_native_roots()
4907/// #         .unwrap()
4908/// #         .https_or_http()
4909/// #         .enable_http2()
4910/// #         .build()
4911/// # );
4912/// # let mut hub = Speech::new(client, auth);
4913/// // As the method needs a request, you would usually fill it with the desired information
4914/// // into the respective structure. Some of the parts shown here might not be applicable !
4915/// // Values shown here are possibly random and not representative !
4916/// let mut req = PhraseSet::default();
4917///
4918/// // You can configure optional parameters by calling the respective setters at will, and
4919/// // execute the final call using `doit()`.
4920/// // Values shown here are possibly random and not representative !
4921/// let result = hub.projects().locations_phrase_sets_patch(req, "name")
4922///              .update_mask(FieldMask::new::<&str>(&[]))
4923///              .doit().await;
4924/// # }
4925/// ```
4926pub struct ProjectLocationPhraseSetPatchCall<'a, C>
4927where
4928    C: 'a,
4929{
4930    hub: &'a Speech<C>,
4931    _request: PhraseSet,
4932    _name: String,
4933    _update_mask: Option<common::FieldMask>,
4934    _delegate: Option<&'a mut dyn common::Delegate>,
4935    _additional_params: HashMap<String, String>,
4936    _scopes: BTreeSet<String>,
4937}
4938
4939impl<'a, C> common::CallBuilder for ProjectLocationPhraseSetPatchCall<'a, C> {}
4940
4941impl<'a, C> ProjectLocationPhraseSetPatchCall<'a, C>
4942where
4943    C: common::Connector,
4944{
4945    /// Perform the operation you have build so far.
4946    pub async fn doit(mut self) -> common::Result<(common::Response, PhraseSet)> {
4947        use std::borrow::Cow;
4948        use std::io::{Read, Seek};
4949
4950        use common::{url::Params, ToParts};
4951        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4952
4953        let mut dd = common::DefaultDelegate;
4954        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4955        dlg.begin(common::MethodInfo {
4956            id: "speech.projects.locations.phraseSets.patch",
4957            http_method: hyper::Method::PATCH,
4958        });
4959
4960        for &field in ["alt", "name", "updateMask"].iter() {
4961            if self._additional_params.contains_key(field) {
4962                dlg.finished(false);
4963                return Err(common::Error::FieldClash(field));
4964            }
4965        }
4966
4967        let mut params = Params::with_capacity(5 + self._additional_params.len());
4968        params.push("name", self._name);
4969        if let Some(value) = self._update_mask.as_ref() {
4970            params.push("updateMask", value.to_string());
4971        }
4972
4973        params.extend(self._additional_params.iter());
4974
4975        params.push("alt", "json");
4976        let mut url = self.hub._base_url.clone() + "v1/{+name}";
4977        if self._scopes.is_empty() {
4978            self._scopes
4979                .insert(Scope::CloudPlatform.as_ref().to_string());
4980        }
4981
4982        #[allow(clippy::single_element_loop)]
4983        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4984            url = params.uri_replacement(url, param_name, find_this, true);
4985        }
4986        {
4987            let to_remove = ["name"];
4988            params.remove_params(&to_remove);
4989        }
4990
4991        let url = params.parse_with_url(&url);
4992
4993        let mut json_mime_type = mime::APPLICATION_JSON;
4994        let mut request_value_reader = {
4995            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4996            common::remove_json_null_values(&mut value);
4997            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4998            serde_json::to_writer(&mut dst, &value).unwrap();
4999            dst
5000        };
5001        let request_size = request_value_reader
5002            .seek(std::io::SeekFrom::End(0))
5003            .unwrap();
5004        request_value_reader
5005            .seek(std::io::SeekFrom::Start(0))
5006            .unwrap();
5007
5008        loop {
5009            let token = match self
5010                .hub
5011                .auth
5012                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5013                .await
5014            {
5015                Ok(token) => token,
5016                Err(e) => match dlg.token(e) {
5017                    Ok(token) => token,
5018                    Err(e) => {
5019                        dlg.finished(false);
5020                        return Err(common::Error::MissingToken(e));
5021                    }
5022                },
5023            };
5024            request_value_reader
5025                .seek(std::io::SeekFrom::Start(0))
5026                .unwrap();
5027            let mut req_result = {
5028                let client = &self.hub.client;
5029                dlg.pre_request();
5030                let mut req_builder = hyper::Request::builder()
5031                    .method(hyper::Method::PATCH)
5032                    .uri(url.as_str())
5033                    .header(USER_AGENT, self.hub._user_agent.clone());
5034
5035                if let Some(token) = token.as_ref() {
5036                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5037                }
5038
5039                let request = req_builder
5040                    .header(CONTENT_TYPE, json_mime_type.to_string())
5041                    .header(CONTENT_LENGTH, request_size as u64)
5042                    .body(common::to_body(
5043                        request_value_reader.get_ref().clone().into(),
5044                    ));
5045
5046                client.request(request.unwrap()).await
5047            };
5048
5049            match req_result {
5050                Err(err) => {
5051                    if let common::Retry::After(d) = dlg.http_error(&err) {
5052                        sleep(d).await;
5053                        continue;
5054                    }
5055                    dlg.finished(false);
5056                    return Err(common::Error::HttpError(err));
5057                }
5058                Ok(res) => {
5059                    let (mut parts, body) = res.into_parts();
5060                    let mut body = common::Body::new(body);
5061                    if !parts.status.is_success() {
5062                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5063                        let error = serde_json::from_str(&common::to_string(&bytes));
5064                        let response = common::to_response(parts, bytes.into());
5065
5066                        if let common::Retry::After(d) =
5067                            dlg.http_failure(&response, error.as_ref().ok())
5068                        {
5069                            sleep(d).await;
5070                            continue;
5071                        }
5072
5073                        dlg.finished(false);
5074
5075                        return Err(match error {
5076                            Ok(value) => common::Error::BadRequest(value),
5077                            _ => common::Error::Failure(response),
5078                        });
5079                    }
5080                    let response = {
5081                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5082                        let encoded = common::to_string(&bytes);
5083                        match serde_json::from_str(&encoded) {
5084                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5085                            Err(error) => {
5086                                dlg.response_json_decode_error(&encoded, &error);
5087                                return Err(common::Error::JsonDecodeError(
5088                                    encoded.to_string(),
5089                                    error,
5090                                ));
5091                            }
5092                        }
5093                    };
5094
5095                    dlg.finished(true);
5096                    return Ok(response);
5097                }
5098            }
5099        }
5100    }
5101
5102    ///
5103    /// Sets the *request* property to the given value.
5104    ///
5105    /// Even though the property as already been set when instantiating this call,
5106    /// we provide this method for API completeness.
5107    pub fn request(mut self, new_value: PhraseSet) -> ProjectLocationPhraseSetPatchCall<'a, C> {
5108        self._request = new_value;
5109        self
5110    }
5111    /// The resource name of the phrase set.
5112    ///
5113    /// Sets the *name* path property to the given value.
5114    ///
5115    /// Even though the property as already been set when instantiating this call,
5116    /// we provide this method for API completeness.
5117    pub fn name(mut self, new_value: &str) -> ProjectLocationPhraseSetPatchCall<'a, C> {
5118        self._name = new_value.to_string();
5119        self
5120    }
5121    /// The list of fields to be updated.
5122    ///
5123    /// Sets the *update mask* query property to the given value.
5124    pub fn update_mask(
5125        mut self,
5126        new_value: common::FieldMask,
5127    ) -> ProjectLocationPhraseSetPatchCall<'a, C> {
5128        self._update_mask = Some(new_value);
5129        self
5130    }
5131    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5132    /// while executing the actual API request.
5133    ///
5134    /// ````text
5135    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5136    /// ````
5137    ///
5138    /// Sets the *delegate* property to the given value.
5139    pub fn delegate(
5140        mut self,
5141        new_value: &'a mut dyn common::Delegate,
5142    ) -> ProjectLocationPhraseSetPatchCall<'a, C> {
5143        self._delegate = Some(new_value);
5144        self
5145    }
5146
5147    /// Set any additional parameter of the query string used in the request.
5148    /// It should be used to set parameters which are not yet available through their own
5149    /// setters.
5150    ///
5151    /// Please note that this method must not be used to set any of the known parameters
5152    /// which have their own setter method. If done anyway, the request will fail.
5153    ///
5154    /// # Additional Parameters
5155    ///
5156    /// * *$.xgafv* (query-string) - V1 error format.
5157    /// * *access_token* (query-string) - OAuth access token.
5158    /// * *alt* (query-string) - Data format for response.
5159    /// * *callback* (query-string) - JSONP
5160    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5161    /// * *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.
5162    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5163    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5164    /// * *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.
5165    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5166    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5167    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationPhraseSetPatchCall<'a, C>
5168    where
5169        T: AsRef<str>,
5170    {
5171        self._additional_params
5172            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5173        self
5174    }
5175
5176    /// Identifies the authorization scope for the method you are building.
5177    ///
5178    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5179    /// [`Scope::CloudPlatform`].
5180    ///
5181    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5182    /// tokens for more than one scope.
5183    ///
5184    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5185    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5186    /// sufficient, a read-write scope will do as well.
5187    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationPhraseSetPatchCall<'a, C>
5188    where
5189        St: AsRef<str>,
5190    {
5191        self._scopes.insert(String::from(scope.as_ref()));
5192        self
5193    }
5194    /// Identifies the authorization scope(s) for the method you are building.
5195    ///
5196    /// See [`Self::add_scope()`] for details.
5197    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationPhraseSetPatchCall<'a, C>
5198    where
5199        I: IntoIterator<Item = St>,
5200        St: AsRef<str>,
5201    {
5202        self._scopes
5203            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5204        self
5205    }
5206
5207    /// Removes all scopes, and no default scope will be used either.
5208    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5209    /// for details).
5210    pub fn clear_scopes(mut self) -> ProjectLocationPhraseSetPatchCall<'a, C> {
5211        self._scopes.clear();
5212        self
5213    }
5214}
5215
5216/// Performs asynchronous speech recognition: receive results via the google.longrunning.Operations interface. Returns either an `Operation.error` or an `Operation.response` which contains a `LongRunningRecognizeResponse` message. For more information on asynchronous speech recognition, see the [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize).
5217///
5218/// A builder for the *longrunningrecognize* method supported by a *speech* resource.
5219/// It is not used directly, but through a [`SpeechMethods`] instance.
5220///
5221/// # Example
5222///
5223/// Instantiate a resource method builder
5224///
5225/// ```test_harness,no_run
5226/// # extern crate hyper;
5227/// # extern crate hyper_rustls;
5228/// # extern crate google_speech1 as speech1;
5229/// use speech1::api::LongRunningRecognizeRequest;
5230/// # async fn dox() {
5231/// # use speech1::{Speech, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5232///
5233/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5234/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5235/// #     .with_native_roots()
5236/// #     .unwrap()
5237/// #     .https_only()
5238/// #     .enable_http2()
5239/// #     .build();
5240///
5241/// # let executor = hyper_util::rt::TokioExecutor::new();
5242/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5243/// #     secret,
5244/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5245/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5246/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5247/// #     ),
5248/// # ).build().await.unwrap();
5249///
5250/// # let client = hyper_util::client::legacy::Client::builder(
5251/// #     hyper_util::rt::TokioExecutor::new()
5252/// # )
5253/// # .build(
5254/// #     hyper_rustls::HttpsConnectorBuilder::new()
5255/// #         .with_native_roots()
5256/// #         .unwrap()
5257/// #         .https_or_http()
5258/// #         .enable_http2()
5259/// #         .build()
5260/// # );
5261/// # let mut hub = Speech::new(client, auth);
5262/// // As the method needs a request, you would usually fill it with the desired information
5263/// // into the respective structure. Some of the parts shown here might not be applicable !
5264/// // Values shown here are possibly random and not representative !
5265/// let mut req = LongRunningRecognizeRequest::default();
5266///
5267/// // You can configure optional parameters by calling the respective setters at will, and
5268/// // execute the final call using `doit()`.
5269/// // Values shown here are possibly random and not representative !
5270/// let result = hub.speech().longrunningrecognize(req)
5271///              .doit().await;
5272/// # }
5273/// ```
5274pub struct SpeechLongrunningrecognizeCall<'a, C>
5275where
5276    C: 'a,
5277{
5278    hub: &'a Speech<C>,
5279    _request: LongRunningRecognizeRequest,
5280    _delegate: Option<&'a mut dyn common::Delegate>,
5281    _additional_params: HashMap<String, String>,
5282    _scopes: BTreeSet<String>,
5283}
5284
5285impl<'a, C> common::CallBuilder for SpeechLongrunningrecognizeCall<'a, C> {}
5286
5287impl<'a, C> SpeechLongrunningrecognizeCall<'a, C>
5288where
5289    C: common::Connector,
5290{
5291    /// Perform the operation you have build so far.
5292    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5293        use std::borrow::Cow;
5294        use std::io::{Read, Seek};
5295
5296        use common::{url::Params, ToParts};
5297        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5298
5299        let mut dd = common::DefaultDelegate;
5300        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5301        dlg.begin(common::MethodInfo {
5302            id: "speech.speech.longrunningrecognize",
5303            http_method: hyper::Method::POST,
5304        });
5305
5306        for &field in ["alt"].iter() {
5307            if self._additional_params.contains_key(field) {
5308                dlg.finished(false);
5309                return Err(common::Error::FieldClash(field));
5310            }
5311        }
5312
5313        let mut params = Params::with_capacity(3 + self._additional_params.len());
5314
5315        params.extend(self._additional_params.iter());
5316
5317        params.push("alt", "json");
5318        let mut url = self.hub._base_url.clone() + "v1/speech:longrunningrecognize";
5319        if self._scopes.is_empty() {
5320            self._scopes
5321                .insert(Scope::CloudPlatform.as_ref().to_string());
5322        }
5323
5324        let url = params.parse_with_url(&url);
5325
5326        let mut json_mime_type = mime::APPLICATION_JSON;
5327        let mut request_value_reader = {
5328            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5329            common::remove_json_null_values(&mut value);
5330            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5331            serde_json::to_writer(&mut dst, &value).unwrap();
5332            dst
5333        };
5334        let request_size = request_value_reader
5335            .seek(std::io::SeekFrom::End(0))
5336            .unwrap();
5337        request_value_reader
5338            .seek(std::io::SeekFrom::Start(0))
5339            .unwrap();
5340
5341        loop {
5342            let token = match self
5343                .hub
5344                .auth
5345                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5346                .await
5347            {
5348                Ok(token) => token,
5349                Err(e) => match dlg.token(e) {
5350                    Ok(token) => token,
5351                    Err(e) => {
5352                        dlg.finished(false);
5353                        return Err(common::Error::MissingToken(e));
5354                    }
5355                },
5356            };
5357            request_value_reader
5358                .seek(std::io::SeekFrom::Start(0))
5359                .unwrap();
5360            let mut req_result = {
5361                let client = &self.hub.client;
5362                dlg.pre_request();
5363                let mut req_builder = hyper::Request::builder()
5364                    .method(hyper::Method::POST)
5365                    .uri(url.as_str())
5366                    .header(USER_AGENT, self.hub._user_agent.clone());
5367
5368                if let Some(token) = token.as_ref() {
5369                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5370                }
5371
5372                let request = req_builder
5373                    .header(CONTENT_TYPE, json_mime_type.to_string())
5374                    .header(CONTENT_LENGTH, request_size as u64)
5375                    .body(common::to_body(
5376                        request_value_reader.get_ref().clone().into(),
5377                    ));
5378
5379                client.request(request.unwrap()).await
5380            };
5381
5382            match req_result {
5383                Err(err) => {
5384                    if let common::Retry::After(d) = dlg.http_error(&err) {
5385                        sleep(d).await;
5386                        continue;
5387                    }
5388                    dlg.finished(false);
5389                    return Err(common::Error::HttpError(err));
5390                }
5391                Ok(res) => {
5392                    let (mut parts, body) = res.into_parts();
5393                    let mut body = common::Body::new(body);
5394                    if !parts.status.is_success() {
5395                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5396                        let error = serde_json::from_str(&common::to_string(&bytes));
5397                        let response = common::to_response(parts, bytes.into());
5398
5399                        if let common::Retry::After(d) =
5400                            dlg.http_failure(&response, error.as_ref().ok())
5401                        {
5402                            sleep(d).await;
5403                            continue;
5404                        }
5405
5406                        dlg.finished(false);
5407
5408                        return Err(match error {
5409                            Ok(value) => common::Error::BadRequest(value),
5410                            _ => common::Error::Failure(response),
5411                        });
5412                    }
5413                    let response = {
5414                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5415                        let encoded = common::to_string(&bytes);
5416                        match serde_json::from_str(&encoded) {
5417                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5418                            Err(error) => {
5419                                dlg.response_json_decode_error(&encoded, &error);
5420                                return Err(common::Error::JsonDecodeError(
5421                                    encoded.to_string(),
5422                                    error,
5423                                ));
5424                            }
5425                        }
5426                    };
5427
5428                    dlg.finished(true);
5429                    return Ok(response);
5430                }
5431            }
5432        }
5433    }
5434
5435    ///
5436    /// Sets the *request* property to the given value.
5437    ///
5438    /// Even though the property as already been set when instantiating this call,
5439    /// we provide this method for API completeness.
5440    pub fn request(
5441        mut self,
5442        new_value: LongRunningRecognizeRequest,
5443    ) -> SpeechLongrunningrecognizeCall<'a, C> {
5444        self._request = new_value;
5445        self
5446    }
5447    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5448    /// while executing the actual API request.
5449    ///
5450    /// ````text
5451    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5452    /// ````
5453    ///
5454    /// Sets the *delegate* property to the given value.
5455    pub fn delegate(
5456        mut self,
5457        new_value: &'a mut dyn common::Delegate,
5458    ) -> SpeechLongrunningrecognizeCall<'a, C> {
5459        self._delegate = Some(new_value);
5460        self
5461    }
5462
5463    /// Set any additional parameter of the query string used in the request.
5464    /// It should be used to set parameters which are not yet available through their own
5465    /// setters.
5466    ///
5467    /// Please note that this method must not be used to set any of the known parameters
5468    /// which have their own setter method. If done anyway, the request will fail.
5469    ///
5470    /// # Additional Parameters
5471    ///
5472    /// * *$.xgafv* (query-string) - V1 error format.
5473    /// * *access_token* (query-string) - OAuth access token.
5474    /// * *alt* (query-string) - Data format for response.
5475    /// * *callback* (query-string) - JSONP
5476    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5477    /// * *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.
5478    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5479    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5480    /// * *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.
5481    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5482    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5483    pub fn param<T>(mut self, name: T, value: T) -> SpeechLongrunningrecognizeCall<'a, C>
5484    where
5485        T: AsRef<str>,
5486    {
5487        self._additional_params
5488            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5489        self
5490    }
5491
5492    /// Identifies the authorization scope for the method you are building.
5493    ///
5494    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5495    /// [`Scope::CloudPlatform`].
5496    ///
5497    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5498    /// tokens for more than one scope.
5499    ///
5500    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5501    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5502    /// sufficient, a read-write scope will do as well.
5503    pub fn add_scope<St>(mut self, scope: St) -> SpeechLongrunningrecognizeCall<'a, C>
5504    where
5505        St: AsRef<str>,
5506    {
5507        self._scopes.insert(String::from(scope.as_ref()));
5508        self
5509    }
5510    /// Identifies the authorization scope(s) for the method you are building.
5511    ///
5512    /// See [`Self::add_scope()`] for details.
5513    pub fn add_scopes<I, St>(mut self, scopes: I) -> SpeechLongrunningrecognizeCall<'a, C>
5514    where
5515        I: IntoIterator<Item = St>,
5516        St: AsRef<str>,
5517    {
5518        self._scopes
5519            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5520        self
5521    }
5522
5523    /// Removes all scopes, and no default scope will be used either.
5524    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5525    /// for details).
5526    pub fn clear_scopes(mut self) -> SpeechLongrunningrecognizeCall<'a, C> {
5527        self._scopes.clear();
5528        self
5529    }
5530}
5531
5532/// Performs synchronous speech recognition: receive results after all audio has been sent and processed.
5533///
5534/// A builder for the *recognize* method supported by a *speech* resource.
5535/// It is not used directly, but through a [`SpeechMethods`] instance.
5536///
5537/// # Example
5538///
5539/// Instantiate a resource method builder
5540///
5541/// ```test_harness,no_run
5542/// # extern crate hyper;
5543/// # extern crate hyper_rustls;
5544/// # extern crate google_speech1 as speech1;
5545/// use speech1::api::RecognizeRequest;
5546/// # async fn dox() {
5547/// # use speech1::{Speech, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5548///
5549/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5550/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5551/// #     .with_native_roots()
5552/// #     .unwrap()
5553/// #     .https_only()
5554/// #     .enable_http2()
5555/// #     .build();
5556///
5557/// # let executor = hyper_util::rt::TokioExecutor::new();
5558/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5559/// #     secret,
5560/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5561/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5562/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5563/// #     ),
5564/// # ).build().await.unwrap();
5565///
5566/// # let client = hyper_util::client::legacy::Client::builder(
5567/// #     hyper_util::rt::TokioExecutor::new()
5568/// # )
5569/// # .build(
5570/// #     hyper_rustls::HttpsConnectorBuilder::new()
5571/// #         .with_native_roots()
5572/// #         .unwrap()
5573/// #         .https_or_http()
5574/// #         .enable_http2()
5575/// #         .build()
5576/// # );
5577/// # let mut hub = Speech::new(client, auth);
5578/// // As the method needs a request, you would usually fill it with the desired information
5579/// // into the respective structure. Some of the parts shown here might not be applicable !
5580/// // Values shown here are possibly random and not representative !
5581/// let mut req = RecognizeRequest::default();
5582///
5583/// // You can configure optional parameters by calling the respective setters at will, and
5584/// // execute the final call using `doit()`.
5585/// // Values shown here are possibly random and not representative !
5586/// let result = hub.speech().recognize(req)
5587///              .doit().await;
5588/// # }
5589/// ```
5590pub struct SpeechRecognizeCall<'a, C>
5591where
5592    C: 'a,
5593{
5594    hub: &'a Speech<C>,
5595    _request: RecognizeRequest,
5596    _delegate: Option<&'a mut dyn common::Delegate>,
5597    _additional_params: HashMap<String, String>,
5598    _scopes: BTreeSet<String>,
5599}
5600
5601impl<'a, C> common::CallBuilder for SpeechRecognizeCall<'a, C> {}
5602
5603impl<'a, C> SpeechRecognizeCall<'a, C>
5604where
5605    C: common::Connector,
5606{
5607    /// Perform the operation you have build so far.
5608    pub async fn doit(mut self) -> common::Result<(common::Response, RecognizeResponse)> {
5609        use std::borrow::Cow;
5610        use std::io::{Read, Seek};
5611
5612        use common::{url::Params, ToParts};
5613        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5614
5615        let mut dd = common::DefaultDelegate;
5616        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5617        dlg.begin(common::MethodInfo {
5618            id: "speech.speech.recognize",
5619            http_method: hyper::Method::POST,
5620        });
5621
5622        for &field in ["alt"].iter() {
5623            if self._additional_params.contains_key(field) {
5624                dlg.finished(false);
5625                return Err(common::Error::FieldClash(field));
5626            }
5627        }
5628
5629        let mut params = Params::with_capacity(3 + self._additional_params.len());
5630
5631        params.extend(self._additional_params.iter());
5632
5633        params.push("alt", "json");
5634        let mut url = self.hub._base_url.clone() + "v1/speech:recognize";
5635        if self._scopes.is_empty() {
5636            self._scopes
5637                .insert(Scope::CloudPlatform.as_ref().to_string());
5638        }
5639
5640        let url = params.parse_with_url(&url);
5641
5642        let mut json_mime_type = mime::APPLICATION_JSON;
5643        let mut request_value_reader = {
5644            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5645            common::remove_json_null_values(&mut value);
5646            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5647            serde_json::to_writer(&mut dst, &value).unwrap();
5648            dst
5649        };
5650        let request_size = request_value_reader
5651            .seek(std::io::SeekFrom::End(0))
5652            .unwrap();
5653        request_value_reader
5654            .seek(std::io::SeekFrom::Start(0))
5655            .unwrap();
5656
5657        loop {
5658            let token = match self
5659                .hub
5660                .auth
5661                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5662                .await
5663            {
5664                Ok(token) => token,
5665                Err(e) => match dlg.token(e) {
5666                    Ok(token) => token,
5667                    Err(e) => {
5668                        dlg.finished(false);
5669                        return Err(common::Error::MissingToken(e));
5670                    }
5671                },
5672            };
5673            request_value_reader
5674                .seek(std::io::SeekFrom::Start(0))
5675                .unwrap();
5676            let mut req_result = {
5677                let client = &self.hub.client;
5678                dlg.pre_request();
5679                let mut req_builder = hyper::Request::builder()
5680                    .method(hyper::Method::POST)
5681                    .uri(url.as_str())
5682                    .header(USER_AGENT, self.hub._user_agent.clone());
5683
5684                if let Some(token) = token.as_ref() {
5685                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5686                }
5687
5688                let request = req_builder
5689                    .header(CONTENT_TYPE, json_mime_type.to_string())
5690                    .header(CONTENT_LENGTH, request_size as u64)
5691                    .body(common::to_body(
5692                        request_value_reader.get_ref().clone().into(),
5693                    ));
5694
5695                client.request(request.unwrap()).await
5696            };
5697
5698            match req_result {
5699                Err(err) => {
5700                    if let common::Retry::After(d) = dlg.http_error(&err) {
5701                        sleep(d).await;
5702                        continue;
5703                    }
5704                    dlg.finished(false);
5705                    return Err(common::Error::HttpError(err));
5706                }
5707                Ok(res) => {
5708                    let (mut parts, body) = res.into_parts();
5709                    let mut body = common::Body::new(body);
5710                    if !parts.status.is_success() {
5711                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5712                        let error = serde_json::from_str(&common::to_string(&bytes));
5713                        let response = common::to_response(parts, bytes.into());
5714
5715                        if let common::Retry::After(d) =
5716                            dlg.http_failure(&response, error.as_ref().ok())
5717                        {
5718                            sleep(d).await;
5719                            continue;
5720                        }
5721
5722                        dlg.finished(false);
5723
5724                        return Err(match error {
5725                            Ok(value) => common::Error::BadRequest(value),
5726                            _ => common::Error::Failure(response),
5727                        });
5728                    }
5729                    let response = {
5730                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5731                        let encoded = common::to_string(&bytes);
5732                        match serde_json::from_str(&encoded) {
5733                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5734                            Err(error) => {
5735                                dlg.response_json_decode_error(&encoded, &error);
5736                                return Err(common::Error::JsonDecodeError(
5737                                    encoded.to_string(),
5738                                    error,
5739                                ));
5740                            }
5741                        }
5742                    };
5743
5744                    dlg.finished(true);
5745                    return Ok(response);
5746                }
5747            }
5748        }
5749    }
5750
5751    ///
5752    /// Sets the *request* property to the given value.
5753    ///
5754    /// Even though the property as already been set when instantiating this call,
5755    /// we provide this method for API completeness.
5756    pub fn request(mut self, new_value: RecognizeRequest) -> SpeechRecognizeCall<'a, C> {
5757        self._request = new_value;
5758        self
5759    }
5760    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5761    /// while executing the actual API request.
5762    ///
5763    /// ````text
5764    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5765    /// ````
5766    ///
5767    /// Sets the *delegate* property to the given value.
5768    pub fn delegate(
5769        mut self,
5770        new_value: &'a mut dyn common::Delegate,
5771    ) -> SpeechRecognizeCall<'a, C> {
5772        self._delegate = Some(new_value);
5773        self
5774    }
5775
5776    /// Set any additional parameter of the query string used in the request.
5777    /// It should be used to set parameters which are not yet available through their own
5778    /// setters.
5779    ///
5780    /// Please note that this method must not be used to set any of the known parameters
5781    /// which have their own setter method. If done anyway, the request will fail.
5782    ///
5783    /// # Additional Parameters
5784    ///
5785    /// * *$.xgafv* (query-string) - V1 error format.
5786    /// * *access_token* (query-string) - OAuth access token.
5787    /// * *alt* (query-string) - Data format for response.
5788    /// * *callback* (query-string) - JSONP
5789    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5790    /// * *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.
5791    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5792    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5793    /// * *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.
5794    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5795    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5796    pub fn param<T>(mut self, name: T, value: T) -> SpeechRecognizeCall<'a, C>
5797    where
5798        T: AsRef<str>,
5799    {
5800        self._additional_params
5801            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5802        self
5803    }
5804
5805    /// Identifies the authorization scope for the method you are building.
5806    ///
5807    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5808    /// [`Scope::CloudPlatform`].
5809    ///
5810    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5811    /// tokens for more than one scope.
5812    ///
5813    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5814    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5815    /// sufficient, a read-write scope will do as well.
5816    pub fn add_scope<St>(mut self, scope: St) -> SpeechRecognizeCall<'a, C>
5817    where
5818        St: AsRef<str>,
5819    {
5820        self._scopes.insert(String::from(scope.as_ref()));
5821        self
5822    }
5823    /// Identifies the authorization scope(s) for the method you are building.
5824    ///
5825    /// See [`Self::add_scope()`] for details.
5826    pub fn add_scopes<I, St>(mut self, scopes: I) -> SpeechRecognizeCall<'a, C>
5827    where
5828        I: IntoIterator<Item = St>,
5829        St: AsRef<str>,
5830    {
5831        self._scopes
5832            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5833        self
5834    }
5835
5836    /// Removes all scopes, and no default scope will be used either.
5837    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5838    /// for details).
5839    pub fn clear_scopes(mut self) -> SpeechRecognizeCall<'a, C> {
5840        self._scopes.clear();
5841        self
5842    }
5843}