google_translate3/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 /// Translate text from one language to another using Google Translate
20 CloudTranslation,
21}
22
23impl AsRef<str> for Scope {
24 fn as_ref(&self) -> &str {
25 match *self {
26 Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
27 Scope::CloudTranslation => "https://www.googleapis.com/auth/cloud-translation",
28 }
29 }
30}
31
32#[allow(clippy::derivable_impls)]
33impl Default for Scope {
34 fn default() -> Scope {
35 Scope::CloudPlatform
36 }
37}
38
39// ########
40// HUB ###
41// ######
42
43/// Central instance to access all Translate related resource activities
44///
45/// # Examples
46///
47/// Instantiate a new hub
48///
49/// ```test_harness,no_run
50/// extern crate hyper;
51/// extern crate hyper_rustls;
52/// extern crate google_translate3 as translate3;
53/// use translate3::api::Glossary;
54/// use translate3::{Result, Error};
55/// # async fn dox() {
56/// use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
57///
58/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
59/// // `client_secret`, among other things.
60/// let secret: yup_oauth2::ApplicationSecret = Default::default();
61/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
62/// // unless you replace `None` with the desired Flow.
63/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
64/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
65/// // retrieve them from storage.
66/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
67/// .with_native_roots()
68/// .unwrap()
69/// .https_only()
70/// .enable_http2()
71/// .build();
72///
73/// let executor = hyper_util::rt::TokioExecutor::new();
74/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
75/// secret,
76/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
77/// yup_oauth2::client::CustomHyperClientBuilder::from(
78/// hyper_util::client::legacy::Client::builder(executor).build(connector),
79/// ),
80/// ).build().await.unwrap();
81///
82/// let client = hyper_util::client::legacy::Client::builder(
83/// hyper_util::rt::TokioExecutor::new()
84/// )
85/// .build(
86/// hyper_rustls::HttpsConnectorBuilder::new()
87/// .with_native_roots()
88/// .unwrap()
89/// .https_or_http()
90/// .enable_http2()
91/// .build()
92/// );
93/// let mut hub = Translate::new(client, auth);
94/// // As the method needs a request, you would usually fill it with the desired information
95/// // into the respective structure. Some of the parts shown here might not be applicable !
96/// // Values shown here are possibly random and not representative !
97/// let mut req = Glossary::default();
98///
99/// // You can configure optional parameters by calling the respective setters at will, and
100/// // execute the final call using `doit()`.
101/// // Values shown here are possibly random and not representative !
102/// let result = hub.projects().locations_glossaries_patch(req, "name")
103/// .update_mask(FieldMask::new::<&str>(&[]))
104/// .doit().await;
105///
106/// match result {
107/// Err(e) => match e {
108/// // The Error enum provides details about what exactly happened.
109/// // You can also just use its `Debug`, `Display` or `Error` traits
110/// Error::HttpError(_)
111/// |Error::Io(_)
112/// |Error::MissingAPIKey
113/// |Error::MissingToken(_)
114/// |Error::Cancelled
115/// |Error::UploadSizeLimitExceeded(_, _)
116/// |Error::Failure(_)
117/// |Error::BadRequest(_)
118/// |Error::FieldClash(_)
119/// |Error::JsonDecodeError(_, _) => println!("{}", e),
120/// },
121/// Ok(res) => println!("Success: {:?}", res),
122/// }
123/// # }
124/// ```
125#[derive(Clone)]
126pub struct Translate<C> {
127 pub client: common::Client<C>,
128 pub auth: Box<dyn common::GetToken>,
129 _user_agent: String,
130 _base_url: String,
131 _root_url: String,
132}
133
134impl<C> common::Hub for Translate<C> {}
135
136impl<'a, C> Translate<C> {
137 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Translate<C> {
138 Translate {
139 client,
140 auth: Box::new(auth),
141 _user_agent: "google-api-rust-client/7.0.0".to_string(),
142 _base_url: "https://translation.googleapis.com/".to_string(),
143 _root_url: "https://translation.googleapis.com/".to_string(),
144 }
145 }
146
147 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
148 ProjectMethods { hub: self }
149 }
150
151 /// Set the user-agent header field to use in all requests to the server.
152 /// It defaults to `google-api-rust-client/7.0.0`.
153 ///
154 /// Returns the previously set user-agent.
155 pub fn user_agent(&mut self, agent_name: String) -> String {
156 std::mem::replace(&mut self._user_agent, agent_name)
157 }
158
159 /// Set the base url to use in all requests to the server.
160 /// It defaults to `https://translation.googleapis.com/`.
161 ///
162 /// Returns the previously set base url.
163 pub fn base_url(&mut self, new_base_url: String) -> String {
164 std::mem::replace(&mut self._base_url, new_base_url)
165 }
166
167 /// Set the root url to use in all requests to the server.
168 /// It defaults to `https://translation.googleapis.com/`.
169 ///
170 /// Returns the previously set root url.
171 pub fn root_url(&mut self, new_root_url: String) -> String {
172 std::mem::replace(&mut self._root_url, new_root_url)
173 }
174}
175
176// ############
177// SCHEMAS ###
178// ##########
179/// An Adaptive MT Dataset.
180///
181/// # Activities
182///
183/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
184/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
185///
186/// * [locations adaptive mt datasets create projects](ProjectLocationAdaptiveMtDatasetCreateCall) (request|response)
187/// * [locations adaptive mt datasets get projects](ProjectLocationAdaptiveMtDatasetGetCall) (response)
188#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
189#[serde_with::serde_as]
190#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
191pub struct AdaptiveMtDataset {
192 /// Output only. Timestamp when this dataset was created.
193 #[serde(rename = "createTime")]
194 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
195 /// The name of the dataset to show in the interface. The name can be up to 32 characters long and can consist only of ASCII Latin letters A-Z and a-z, underscores (_), and ASCII digits 0-9.
196 #[serde(rename = "displayName")]
197 pub display_name: Option<String>,
198 /// The number of examples in the dataset.
199 #[serde(rename = "exampleCount")]
200 pub example_count: Option<i32>,
201 /// Required. The resource name of the dataset, in form of `projects/{project-number-or-id}/locations/{location_id}/adaptiveMtDatasets/{dataset_id}`
202 pub name: Option<String>,
203 /// The BCP-47 language code of the source language.
204 #[serde(rename = "sourceLanguageCode")]
205 pub source_language_code: Option<String>,
206 /// The BCP-47 language code of the target language.
207 #[serde(rename = "targetLanguageCode")]
208 pub target_language_code: Option<String>,
209 /// Output only. Timestamp when this dataset was last updated.
210 #[serde(rename = "updateTime")]
211 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
212}
213
214impl common::RequestValue for AdaptiveMtDataset {}
215impl common::ResponseResult for AdaptiveMtDataset {}
216
217/// An AdaptiveMtFile.
218///
219/// # Activities
220///
221/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
222/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
223///
224/// * [locations adaptive mt datasets adaptive mt files get projects](ProjectLocationAdaptiveMtDatasetAdaptiveMtFileGetCall) (response)
225#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
226#[serde_with::serde_as]
227#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
228pub struct AdaptiveMtFile {
229 /// Output only. Timestamp when this file was created.
230 #[serde(rename = "createTime")]
231 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
232 /// The file's display name.
233 #[serde(rename = "displayName")]
234 pub display_name: Option<String>,
235 /// The number of entries that the file contains.
236 #[serde(rename = "entryCount")]
237 pub entry_count: Option<i32>,
238 /// Required. The resource name of the file, in form of `projects/{project-number-or-id}/locations/{location_id}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file}`
239 pub name: Option<String>,
240 /// Output only. Timestamp when this file was last updated.
241 #[serde(rename = "updateTime")]
242 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
243}
244
245impl common::ResponseResult for AdaptiveMtFile {}
246
247/// An AdaptiveMt sentence entry.
248///
249/// This type is not used in any activity, and only used as *part* of another schema.
250///
251#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
252#[serde_with::serde_as]
253#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
254pub struct AdaptiveMtSentence {
255 /// Output only. Timestamp when this sentence was created.
256 #[serde(rename = "createTime")]
257 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
258 /// Required. The resource name of the file, in form of `projects/{project-number-or-id}/locations/{location_id}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file}/adaptiveMtSentences/{sentence}`
259 pub name: Option<String>,
260 /// Required. The source sentence.
261 #[serde(rename = "sourceSentence")]
262 pub source_sentence: Option<String>,
263 /// Required. The target sentence.
264 #[serde(rename = "targetSentence")]
265 pub target_sentence: Option<String>,
266 /// Output only. Timestamp when this sentence was last updated.
267 #[serde(rename = "updateTime")]
268 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
269}
270
271impl common::Part for AdaptiveMtSentence {}
272
273/// The request for sending an AdaptiveMt translation query.
274///
275/// # Activities
276///
277/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
278/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
279///
280/// * [locations adaptive mt translate projects](ProjectLocationAdaptiveMtTranslateCall) (request)
281#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
282#[serde_with::serde_as]
283#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
284pub struct AdaptiveMtTranslateRequest {
285 /// Required. The content of the input in string format.
286 pub content: Option<Vec<String>>,
287 /// Required. The resource name for the dataset to use for adaptive MT. `projects/{project}/locations/{location-id}/adaptiveMtDatasets/{dataset}`
288 pub dataset: Option<String>,
289 /// Optional. Glossary to be applied. The glossary must be within the same region (have the same location-id) as the model, otherwise an INVALID_ARGUMENT (400) error is returned.
290 #[serde(rename = "glossaryConfig")]
291 pub glossary_config: Option<GlossaryConfig>,
292 /// Configuration for caller provided reference sentences.
293 #[serde(rename = "referenceSentenceConfig")]
294 pub reference_sentence_config: Option<ReferenceSentenceConfig>,
295}
296
297impl common::RequestValue for AdaptiveMtTranslateRequest {}
298
299/// An AdaptiveMtTranslate response.
300///
301/// # Activities
302///
303/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
304/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
305///
306/// * [locations adaptive mt translate projects](ProjectLocationAdaptiveMtTranslateCall) (response)
307#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
308#[serde_with::serde_as]
309#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
310pub struct AdaptiveMtTranslateResponse {
311 /// Text translation response if a glossary is provided in the request. This could be the same as 'translation' above if no terms apply.
312 #[serde(rename = "glossaryTranslations")]
313 pub glossary_translations: Option<Vec<AdaptiveMtTranslation>>,
314 /// Output only. The translation's language code.
315 #[serde(rename = "languageCode")]
316 pub language_code: Option<String>,
317 /// Output only. The translation.
318 pub translations: Option<Vec<AdaptiveMtTranslation>>,
319}
320
321impl common::ResponseResult for AdaptiveMtTranslateResponse {}
322
323/// An AdaptiveMt translation.
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 AdaptiveMtTranslation {
331 /// Output only. The translated text.
332 #[serde(rename = "translatedText")]
333 pub translated_text: Option<String>,
334}
335
336impl common::Part for AdaptiveMtTranslation {}
337
338/// Input configuration for BatchTranslateDocument request.
339///
340/// This type is not used in any activity, and only used as *part* of another schema.
341///
342#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
343#[serde_with::serde_as]
344#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
345pub struct BatchDocumentInputConfig {
346 /// Google Cloud Storage location for the source input. This can be a single file (for example, `gs://translation-test/input.docx`) or a wildcard (for example, `gs://translation-test/*`). File mime type is determined based on extension. Supported mime type includes: - `pdf`, application/pdf - `docx`, application/vnd.openxmlformats-officedocument.wordprocessingml.document - `pptx`, application/vnd.openxmlformats-officedocument.presentationml.presentation - `xlsx`, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet The max file size to support for `.docx`, `.pptx` and `.xlsx` is 100MB. The max file size to support for `.pdf` is 1GB and the max page limit is 1000 pages. The max file size to support for all input documents is 1GB.
347 #[serde(rename = "gcsSource")]
348 pub gcs_source: Option<GcsSource>,
349}
350
351impl common::Part for BatchDocumentInputConfig {}
352
353/// Output configuration for BatchTranslateDocument request.
354///
355/// This type is not used in any activity, and only used as *part* of another schema.
356///
357#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
358#[serde_with::serde_as]
359#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
360pub struct BatchDocumentOutputConfig {
361 /// Google Cloud Storage destination for output content. For every single input document (for example, gs://a/b/c.[extension]), we generate at most 2 * n output files. (n is the # of target_language_codes in the BatchTranslateDocumentRequest). While the input documents are being processed, we write/update an index file `index.csv` under `gcs_destination.output_uri_prefix` (for example, gs://translation_output/index.csv) The index file is generated/updated as new files are being translated. The format is: input_document,target_language_code,translation_output,error_output, glossary_translation_output,glossary_error_output `input_document` is one file we matched using gcs_source.input_uri. `target_language_code` is provided in the request. `translation_output` contains the translations. (details provided below) `error_output` contains the error message during processing of the file. Both translations_file and errors_file could be empty strings if we have no content to output. `glossary_translation_output` and `glossary_error_output` are the translated output/error when we apply glossaries. They could also be empty if we have no content to output. Once a row is present in index.csv, the input/output matching never changes. Callers should also expect all the content in input_file are processed and ready to be consumed (that is, no partial output file is written). Since index.csv will be keeping updated during the process, please make sure there is no custom retention policy applied on the output bucket that may avoid file updating. (https://cloud.google.com/storage/docs/bucket-lock#retention-policy) The naming format of translation output files follows (for target language code [trg]): `translation_output`: `gs://translation_output/a_b_c_[trg]_translation.[extension]` `glossary_translation_output`: `gs://translation_test/a_b_c_[trg]_glossary_translation.[extension]`. The output document will maintain the same file format as the input document. The naming format of error output files follows (for target language code [trg]): `error_output`: `gs://translation_test/a_b_c_[trg]_errors.txt` `glossary_error_output`: `gs://translation_test/a_b_c_[trg]_glossary_translation.txt`. The error output is a txt file containing error details.
362 #[serde(rename = "gcsDestination")]
363 pub gcs_destination: Option<GcsDestination>,
364}
365
366impl common::Part for BatchDocumentOutputConfig {}
367
368/// The BatchTranslateDocument request.
369///
370/// # Activities
371///
372/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
373/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
374///
375/// * [locations batch translate document projects](ProjectLocationBatchTranslateDocumentCall) (request)
376#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
377#[serde_with::serde_as]
378#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
379pub struct BatchTranslateDocumentRequest {
380 /// Optional. This flag is to support user customized attribution. If not provided, the default is `Machine Translated by Google`. Customized attribution should follow rules in https://cloud.google.com/translate/attribution#attribution_and_logos
381 #[serde(rename = "customizedAttribution")]
382 pub customized_attribution: Option<String>,
383 /// Optional. If true, enable auto rotation correction in DVS.
384 #[serde(rename = "enableRotationCorrection")]
385 pub enable_rotation_correction: Option<bool>,
386 /// Optional. If true, use the text removal server to remove the shadow text on background image for native pdf translation. Shadow removal feature can only be enabled when is_translate_native_pdf_only: false && pdf_native_only: false
387 #[serde(rename = "enableShadowRemovalNativePdf")]
388 pub enable_shadow_removal_native_pdf: Option<bool>,
389 /// Optional. The file format conversion map that is applied to all input files. The map key is the original mime_type. The map value is the target mime_type of translated documents. Supported file format conversion includes: - `application/pdf` to `application/vnd.openxmlformats-officedocument.wordprocessingml.document` If nothing specified, output files will be in the same format as the original file.
390 #[serde(rename = "formatConversions")]
391 pub format_conversions: Option<HashMap<String, String>>,
392 /// Optional. Glossaries to be applied. It's keyed by target language code.
393 pub glossaries: Option<HashMap<String, TranslateTextGlossaryConfig>>,
394 /// Required. Input configurations. The total number of files matched should be <= 100. The total content size to translate should be <= 100M Unicode codepoints. The files must use UTF-8 encoding.
395 #[serde(rename = "inputConfigs")]
396 pub input_configs: Option<Vec<BatchDocumentInputConfig>>,
397 /// Optional. The models to use for translation. Map's key is target language code. Map's value is the model name. Value can be a built-in general model, or an AutoML Translation model. The value format depends on model type: - AutoML Translation models: `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}` - General (built-in) models: `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`, If the map is empty or a specific model is not requested for a language pair, then default google model (nmt) is used.
398 pub models: Option<HashMap<String, String>>,
399 /// Required. Output configuration. If 2 input configs match to the same file (that is, same input path), we don't generate output for duplicate inputs.
400 #[serde(rename = "outputConfig")]
401 pub output_config: Option<BatchDocumentOutputConfig>,
402 /// Required. The ISO-639 language code of the input document if known, for example, "en-US" or "sr-Latn". Supported language codes are listed in [Language Support](https://cloud.google.com/translate/docs/languages).
403 #[serde(rename = "sourceLanguageCode")]
404 pub source_language_code: Option<String>,
405 /// Required. The ISO-639 language code to use for translation of the input document. Specify up to 10 language codes here.
406 #[serde(rename = "targetLanguageCodes")]
407 pub target_language_codes: Option<Vec<String>>,
408}
409
410impl common::RequestValue for BatchTranslateDocumentRequest {}
411
412/// The batch translation request.
413///
414/// # Activities
415///
416/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
417/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
418///
419/// * [locations batch translate text projects](ProjectLocationBatchTranslateTextCall) (request)
420#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
421#[serde_with::serde_as]
422#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
423pub struct BatchTranslateTextRequest {
424 /// Optional. Glossaries to be applied for translation. It's keyed by target language code.
425 pub glossaries: Option<HashMap<String, TranslateTextGlossaryConfig>>,
426 /// Required. Input configurations. The total number of files matched should be <= 100. The total content size should be <= 100M Unicode codepoints. The files must use UTF-8 encoding.
427 #[serde(rename = "inputConfigs")]
428 pub input_configs: Option<Vec<InputConfig>>,
429 /// Optional. The labels with user-defined metadata for the request. Label keys and values can be no longer than 63 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. Label values are optional. Label keys must start with a letter. See https://cloud.google.com/translate/docs/advanced/labels for more information.
430 pub labels: Option<HashMap<String, String>>,
431 /// Optional. The models to use for translation. Map's key is target language code. Map's value is model name. Value can be a built-in general model, or an AutoML Translation model. The value format depends on model type: - AutoML Translation models: `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}` - General (built-in) models: `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`, If the map is empty or a specific model is not requested for a language pair, then default google model (nmt) is used.
432 pub models: Option<HashMap<String, String>>,
433 /// Required. Output configuration. If 2 input configs match to the same file (that is, same input path), we don't generate output for duplicate inputs.
434 #[serde(rename = "outputConfig")]
435 pub output_config: Option<OutputConfig>,
436 /// Required. Source language code.
437 #[serde(rename = "sourceLanguageCode")]
438 pub source_language_code: Option<String>,
439 /// Required. Specify up to 10 language codes here.
440 #[serde(rename = "targetLanguageCodes")]
441 pub target_language_codes: Option<Vec<String>>,
442}
443
444impl common::RequestValue for BatchTranslateTextRequest {}
445
446/// The request message for Operations.CancelOperation.
447///
448/// # Activities
449///
450/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
451/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
452///
453/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (request)
454#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
455#[serde_with::serde_as]
456#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
457pub struct CancelOperationRequest {
458 _never_set: Option<bool>,
459}
460
461impl common::RequestValue for CancelOperationRequest {}
462
463/// A dataset that hosts the examples (sentence pairs) used for translation models.
464///
465/// # Activities
466///
467/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
468/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
469///
470/// * [locations datasets create projects](ProjectLocationDatasetCreateCall) (request)
471/// * [locations datasets get projects](ProjectLocationDatasetGetCall) (response)
472#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
473#[serde_with::serde_as]
474#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
475pub struct Dataset {
476 /// Output only. Timestamp when this dataset was created.
477 #[serde(rename = "createTime")]
478 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
479 /// The name of the dataset to show in the interface. The name can be up to 32 characters long and can consist only of ASCII Latin letters A-Z and a-z, underscores (_), and ASCII digits 0-9.
480 #[serde(rename = "displayName")]
481 pub display_name: Option<String>,
482 /// Output only. The number of examples in the dataset.
483 #[serde(rename = "exampleCount")]
484 pub example_count: Option<i32>,
485 /// The resource name of the dataset, in form of `projects/{project-number-or-id}/locations/{location_id}/datasets/{dataset_id}`
486 pub name: Option<String>,
487 /// The BCP-47 language code of the source language.
488 #[serde(rename = "sourceLanguageCode")]
489 pub source_language_code: Option<String>,
490 /// The BCP-47 language code of the target language.
491 #[serde(rename = "targetLanguageCode")]
492 pub target_language_code: Option<String>,
493 /// Output only. Number of test examples (sentence pairs).
494 #[serde(rename = "testExampleCount")]
495 pub test_example_count: Option<i32>,
496 /// Output only. Number of training examples (sentence pairs).
497 #[serde(rename = "trainExampleCount")]
498 pub train_example_count: Option<i32>,
499 /// Output only. Timestamp when this dataset was last updated.
500 #[serde(rename = "updateTime")]
501 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
502 /// Output only. Number of validation examples (sentence pairs).
503 #[serde(rename = "validateExampleCount")]
504 pub validate_example_count: Option<i32>,
505}
506
507impl common::RequestValue for Dataset {}
508impl common::ResponseResult for Dataset {}
509
510/// Input configuration for datasets.
511///
512/// This type is not used in any activity, and only used as *part* of another schema.
513///
514#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
515#[serde_with::serde_as]
516#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
517pub struct DatasetInputConfig {
518 /// Files containing the sentence pairs to be imported to the dataset.
519 #[serde(rename = "inputFiles")]
520 pub input_files: Option<Vec<InputFile>>,
521}
522
523impl common::Part for DatasetInputConfig {}
524
525/// Output configuration for datasets.
526///
527/// This type is not used in any activity, and only used as *part* of another schema.
528///
529#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
530#[serde_with::serde_as]
531#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
532pub struct DatasetOutputConfig {
533 /// Google Cloud Storage destination to write the output.
534 #[serde(rename = "gcsDestination")]
535 pub gcs_destination: Option<GcsOutputDestination>,
536}
537
538impl common::Part for DatasetOutputConfig {}
539
540/// The request message for language detection.
541///
542/// # Activities
543///
544/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
545/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
546///
547/// * [locations detect language projects](ProjectLocationDetectLanguageCall) (request)
548/// * [detect language projects](ProjectDetectLanguageCall) (request)
549#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
550#[serde_with::serde_as]
551#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
552pub struct DetectLanguageRequest {
553 /// The content of the input stored as a string.
554 pub content: Option<String>,
555 /// Optional. The labels with user-defined metadata for the request. Label keys and values can be no longer than 63 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. Label values are optional. Label keys must start with a letter. See https://cloud.google.com/translate/docs/advanced/labels for more information.
556 pub labels: Option<HashMap<String, String>>,
557 /// Optional. The format of the source text, for example, "text/html", "text/plain". If left blank, the MIME type defaults to "text/html".
558 #[serde(rename = "mimeType")]
559 pub mime_type: Option<String>,
560 /// Optional. The language detection model to be used. Format: `projects/{project-number-or-id}/locations/{location-id}/models/language-detection/{model-id}` Only one language detection model is currently supported: `projects/{project-number-or-id}/locations/{location-id}/models/language-detection/default`. If not specified, the default model is used.
561 pub model: Option<String>,
562}
563
564impl common::RequestValue for DetectLanguageRequest {}
565
566/// The response message for language detection.
567///
568/// # Activities
569///
570/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
571/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
572///
573/// * [locations detect language projects](ProjectLocationDetectLanguageCall) (response)
574/// * [detect language projects](ProjectDetectLanguageCall) (response)
575#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
576#[serde_with::serde_as]
577#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
578pub struct DetectLanguageResponse {
579 /// The most probable language detected by the Translation API. For each request, the Translation API will always return only one result.
580 pub languages: Option<Vec<DetectedLanguage>>,
581}
582
583impl common::ResponseResult for DetectLanguageResponse {}
584
585/// The response message for language detection.
586///
587/// This type is not used in any activity, and only used as *part* of another schema.
588///
589#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
590#[serde_with::serde_as]
591#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
592pub struct DetectedLanguage {
593 /// The confidence of the detection result for this language.
594 pub confidence: Option<f32>,
595 /// The ISO-639 language code of the source content in the request, detected automatically.
596 #[serde(rename = "languageCode")]
597 pub language_code: Option<String>,
598}
599
600impl common::Part for DetectedLanguage {}
601
602/// A document translation request input config.
603///
604/// This type is not used in any activity, and only used as *part* of another schema.
605///
606#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
607#[serde_with::serde_as]
608#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
609pub struct DocumentInputConfig {
610 /// Document's content represented as a stream of bytes.
611 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
612 pub content: Option<Vec<u8>>,
613 /// Google Cloud Storage location. This must be a single file. For example: gs://example_bucket/example_file.pdf
614 #[serde(rename = "gcsSource")]
615 pub gcs_source: Option<GcsSource>,
616 /// Specifies the input document's mime_type. If not specified it will be determined using the file extension for gcs_source provided files. For a file provided through bytes content the mime_type must be provided. Currently supported mime types are: - application/pdf - application/vnd.openxmlformats-officedocument.wordprocessingml.document - application/vnd.openxmlformats-officedocument.presentationml.presentation - application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
617 #[serde(rename = "mimeType")]
618 pub mime_type: Option<String>,
619}
620
621impl common::Part for DocumentInputConfig {}
622
623/// A document translation request output config.
624///
625/// This type is not used in any activity, and only used as *part* of another schema.
626///
627#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
628#[serde_with::serde_as]
629#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
630pub struct DocumentOutputConfig {
631 /// Optional. Google Cloud Storage destination for the translation output, e.g., `gs://my_bucket/my_directory/`. The destination directory provided does not have to be empty, but the bucket must exist. If a file with the same name as the output file already exists in the destination an error will be returned. For a DocumentInputConfig.contents provided document, the output file will have the name "output_[trg]_translations.[ext]", where - [trg] corresponds to the translated file's language code, - [ext] corresponds to the translated file's extension according to its mime type. For a DocumentInputConfig.gcs_uri provided document, the output file will have a name according to its URI. For example: an input file with URI: `gs://a/b/c.[extension]` stored in a gcs_destination bucket with name "my_bucket" will have an output URI: `gs://my_bucket/a_b_c_[trg]_translations.[ext]`, where - [trg] corresponds to the translated file's language code, - [ext] corresponds to the translated file's extension according to its mime type. If the document was directly provided through the request, then the output document will have the format: `gs://my_bucket/translated_document_[trg]_translations.[ext]`, where - [trg] corresponds to the translated file's language code, - [ext] corresponds to the translated file's extension according to its mime type. If a glossary was provided, then the output URI for the glossary translation will be equal to the default output URI but have `glossary_translations` instead of `translations`. For the previous example, its glossary URI would be: `gs://my_bucket/a_b_c_[trg]_glossary_translations.[ext]`. Thus the max number of output files will be 2 (Translated document, Glossary translated document). Callers should expect no partial outputs. If there is any error during document translation, no output will be stored in the Cloud Storage bucket.
632 #[serde(rename = "gcsDestination")]
633 pub gcs_destination: Option<GcsDestination>,
634 /// Optional. Specifies the translated document's mime_type. If not specified, the translated file's mime type will be the same as the input file's mime type. Currently only support the output mime type to be the same as input mime type. - application/pdf - application/vnd.openxmlformats-officedocument.wordprocessingml.document - application/vnd.openxmlformats-officedocument.presentationml.presentation - application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
635 #[serde(rename = "mimeType")]
636 pub mime_type: Option<String>,
637}
638
639impl common::Part for DocumentOutputConfig {}
640
641/// A translated document message.
642///
643/// This type is not used in any activity, and only used as *part* of another schema.
644///
645#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
646#[serde_with::serde_as]
647#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
648pub struct DocumentTranslation {
649 /// The array of translated documents. It is expected to be size 1 for now. We may produce multiple translated documents in the future for other type of file formats.
650 #[serde(rename = "byteStreamOutputs")]
651 #[serde_as(as = "Option<Vec<common::serde::standard_base64::Wrapper>>")]
652 pub byte_stream_outputs: Option<Vec<Vec<u8>>>,
653 /// The detected language for the input document. If the user did not provide the source language for the input document, this field will have the language code automatically detected. If the source language was passed, auto-detection of the language does not occur and this field is empty.
654 #[serde(rename = "detectedLanguageCode")]
655 pub detected_language_code: Option<String>,
656 /// The translated document's mime type.
657 #[serde(rename = "mimeType")]
658 pub mime_type: Option<String>,
659}
660
661impl common::Part for DocumentTranslation {}
662
663/// 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); }
664///
665/// # Activities
666///
667/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
668/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
669///
670/// * [locations adaptive mt datasets adaptive mt files delete projects](ProjectLocationAdaptiveMtDatasetAdaptiveMtFileDeleteCall) (response)
671/// * [locations adaptive mt datasets delete projects](ProjectLocationAdaptiveMtDatasetDeleteCall) (response)
672/// * [locations glossaries glossary entries delete projects](ProjectLocationGlossaryGlossaryEntryDeleteCall) (response)
673/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (response)
674/// * [locations operations delete projects](ProjectLocationOperationDeleteCall) (response)
675#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
676#[serde_with::serde_as]
677#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
678pub struct Empty {
679 _never_set: Option<bool>,
680}
681
682impl common::ResponseResult for Empty {}
683
684/// A sentence pair.
685///
686/// This type is not used in any activity, and only used as *part* of another schema.
687///
688#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
689#[serde_with::serde_as]
690#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
691pub struct Example {
692 /// Output only. The resource name of the example, in form of `projects/{project-number-or-id}/locations/{location_id}/datasets/{dataset_id}/examples/{example_id}`
693 pub name: Option<String>,
694 /// Sentence in source language.
695 #[serde(rename = "sourceText")]
696 pub source_text: Option<String>,
697 /// Sentence in target language.
698 #[serde(rename = "targetText")]
699 pub target_text: Option<String>,
700 /// Output only. Usage of the sentence pair. Options are TRAIN|VALIDATION|TEST.
701 pub usage: Option<String>,
702}
703
704impl common::Part for Example {}
705
706/// Request message for ExportData.
707///
708/// # Activities
709///
710/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
711/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
712///
713/// * [locations datasets export data projects](ProjectLocationDatasetExportDataCall) (request)
714#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
715#[serde_with::serde_as]
716#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
717pub struct ExportDataRequest {
718 /// Required. The config for the output content.
719 #[serde(rename = "outputConfig")]
720 pub output_config: Option<DatasetOutputConfig>,
721}
722
723impl common::RequestValue for ExportDataRequest {}
724
725/// An inlined file.
726///
727/// This type is not used in any activity, and only used as *part* of another schema.
728///
729#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
730#[serde_with::serde_as]
731#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
732pub struct FileInputSource {
733 /// Required. The file's byte contents.
734 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
735 pub content: Option<Vec<u8>>,
736 /// Required. The file's display name.
737 #[serde(rename = "displayName")]
738 pub display_name: Option<String>,
739 /// Required. The file's mime type.
740 #[serde(rename = "mimeType")]
741 pub mime_type: Option<String>,
742}
743
744impl common::Part for FileInputSource {}
745
746/// The Google Cloud Storage location for the output content.
747///
748/// This type is not used in any activity, and only used as *part* of another schema.
749///
750#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
751#[serde_with::serde_as]
752#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
753pub struct GcsDestination {
754 /// Required. The bucket used in 'output_uri_prefix' must exist and there must be no files under 'output_uri_prefix'. 'output_uri_prefix' must end with "/" and start with "gs://". One 'output_uri_prefix' can only be used by one batch translation job at a time. Otherwise an INVALID_ARGUMENT (400) error is returned.
755 #[serde(rename = "outputUriPrefix")]
756 pub output_uri_prefix: Option<String>,
757}
758
759impl common::Part for GcsDestination {}
760
761/// The Google Cloud Storage location for the input content.
762///
763/// This type is not used in any activity, and only used as *part* of another schema.
764///
765#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
766#[serde_with::serde_as]
767#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
768pub struct GcsInputSource {
769 /// Required. Source data URI. For example, `gs://my_bucket/my_object`.
770 #[serde(rename = "inputUri")]
771 pub input_uri: Option<String>,
772}
773
774impl common::Part for GcsInputSource {}
775
776/// The Google Cloud Storage location for the output content.
777///
778/// This type is not used in any activity, and only used as *part* of another schema.
779///
780#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
781#[serde_with::serde_as]
782#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
783pub struct GcsOutputDestination {
784 /// Required. Google Cloud Storage URI to output directory. For example, `gs://bucket/directory`. The requesting user must have write permission to the bucket. The directory will be created if it doesn't exist.
785 #[serde(rename = "outputUriPrefix")]
786 pub output_uri_prefix: Option<String>,
787}
788
789impl common::Part for GcsOutputDestination {}
790
791/// The Google Cloud Storage location for the input content.
792///
793/// This type is not used in any activity, and only used as *part* of another schema.
794///
795#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
796#[serde_with::serde_as]
797#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
798pub struct GcsSource {
799 /// Required. Source data URI. For example, `gs://my_bucket/my_object`.
800 #[serde(rename = "inputUri")]
801 pub input_uri: Option<String>,
802}
803
804impl common::Part for GcsSource {}
805
806/// Represents a glossary built from user-provided data.
807///
808/// # Activities
809///
810/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
811/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
812///
813/// * [locations glossaries create projects](ProjectLocationGlossaryCreateCall) (request)
814/// * [locations glossaries get projects](ProjectLocationGlossaryGetCall) (response)
815/// * [locations glossaries patch projects](ProjectLocationGlossaryPatchCall) (request)
816#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
817#[serde_with::serde_as]
818#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
819pub struct Glossary {
820 /// Optional. The display name of the glossary.
821 #[serde(rename = "displayName")]
822 pub display_name: Option<String>,
823 /// Output only. When the glossary creation was finished.
824 #[serde(rename = "endTime")]
825 pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
826 /// Output only. The number of entries defined in the glossary.
827 #[serde(rename = "entryCount")]
828 pub entry_count: Option<i32>,
829 /// Required. Provides examples to build the glossary from. Total glossary must not exceed 10M Unicode codepoints.
830 #[serde(rename = "inputConfig")]
831 pub input_config: Option<GlossaryInputConfig>,
832 /// Used with equivalent term set glossaries.
833 #[serde(rename = "languageCodesSet")]
834 pub language_codes_set: Option<LanguageCodesSet>,
835 /// Used with unidirectional glossaries.
836 #[serde(rename = "languagePair")]
837 pub language_pair: Option<LanguageCodePair>,
838 /// Required. The resource name of the glossary. Glossary names have the form `projects/{project-number-or-id}/locations/{location-id}/glossaries/{glossary-id}`.
839 pub name: Option<String>,
840 /// Output only. When CreateGlossary was called.
841 #[serde(rename = "submitTime")]
842 pub submit_time: Option<chrono::DateTime<chrono::offset::Utc>>,
843}
844
845impl common::RequestValue for Glossary {}
846impl common::ResponseResult for Glossary {}
847
848/// Configures which glossary is used for a specific target language and defines options for applying that glossary.
849///
850/// This type is not used in any activity, and only used as *part* of another schema.
851///
852#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
853#[serde_with::serde_as]
854#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
855pub struct GlossaryConfig {
856 /// Optional. If set to true, the glossary will be used for contextual translation.
857 #[serde(rename = "contextualTranslationEnabled")]
858 pub contextual_translation_enabled: Option<bool>,
859 /// Required. The `glossary` to be applied for this translation. The format depends on the glossary: - User-provided custom glossary: `projects/{project-number-or-id}/locations/{location-id}/glossaries/{glossary-id}`
860 pub glossary: Option<String>,
861 /// Optional. Indicates match is case insensitive. The default value is `false` if missing.
862 #[serde(rename = "ignoreCase")]
863 pub ignore_case: Option<bool>,
864}
865
866impl common::Part for GlossaryConfig {}
867
868/// Represents a single entry in a glossary.
869///
870/// # Activities
871///
872/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
873/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
874///
875/// * [locations glossaries glossary entries create projects](ProjectLocationGlossaryGlossaryEntryCreateCall) (request|response)
876/// * [locations glossaries glossary entries get projects](ProjectLocationGlossaryGlossaryEntryGetCall) (response)
877/// * [locations glossaries glossary entries patch projects](ProjectLocationGlossaryGlossaryEntryPatchCall) (request|response)
878#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
879#[serde_with::serde_as]
880#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
881pub struct GlossaryEntry {
882 /// Describes the glossary entry.
883 pub description: Option<String>,
884 /// Identifier. The resource name of the entry. Format: `projects/*/locations/*/glossaries/*/glossaryEntries/*`
885 pub name: Option<String>,
886 /// Used for an unidirectional glossary.
887 #[serde(rename = "termsPair")]
888 pub terms_pair: Option<GlossaryTermsPair>,
889 /// Used for an equivalent term sets glossary.
890 #[serde(rename = "termsSet")]
891 pub terms_set: Option<GlossaryTermsSet>,
892}
893
894impl common::RequestValue for GlossaryEntry {}
895impl common::ResponseResult for GlossaryEntry {}
896
897/// Input configuration for glossaries.
898///
899/// This type is not used in any activity, and only used as *part* of another schema.
900///
901#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
902#[serde_with::serde_as]
903#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
904pub struct GlossaryInputConfig {
905 /// Required. Google Cloud Storage location of glossary data. File format is determined based on the filename extension. API returns [google.rpc.Code.INVALID_ARGUMENT] for unsupported URI-s and file formats. Wildcards are not allowed. This must be a single file in one of the following formats: For unidirectional glossaries: - TSV/CSV (`.tsv`/`.csv`): Two column file, tab- or comma-separated. The first column is source text. The second column is target text. No headers in this file. The first row contains data and not column names. - TMX (`.tmx`): TMX file with parallel data defining source/target term pairs. For equivalent term sets glossaries: - CSV (`.csv`): Multi-column CSV file defining equivalent glossary terms in multiple languages. See documentation for more information - [glossaries](https://cloud.google.com/translate/docs/advanced/glossary).
906 #[serde(rename = "gcsSource")]
907 pub gcs_source: Option<GcsSource>,
908}
909
910impl common::Part for GlossaryInputConfig {}
911
912/// Represents a single glossary term
913///
914/// This type is not used in any activity, and only used as *part* of another schema.
915///
916#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
917#[serde_with::serde_as]
918#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
919pub struct GlossaryTerm {
920 /// The language for this glossary term.
921 #[serde(rename = "languageCode")]
922 pub language_code: Option<String>,
923 /// The text for the glossary term.
924 pub text: Option<String>,
925}
926
927impl common::Part for GlossaryTerm {}
928
929/// Represents a single entry for an unidirectional glossary.
930///
931/// This type is not used in any activity, and only used as *part* of another schema.
932///
933#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
934#[serde_with::serde_as]
935#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
936pub struct GlossaryTermsPair {
937 /// The source term is the term that will get match in the text,
938 #[serde(rename = "sourceTerm")]
939 pub source_term: Option<GlossaryTerm>,
940 /// The term that will replace the match source term.
941 #[serde(rename = "targetTerm")]
942 pub target_term: Option<GlossaryTerm>,
943}
944
945impl common::Part for GlossaryTermsPair {}
946
947/// Represents a single entry for an equivalent term set glossary. This is used for equivalent term sets where each term can be replaced by the other terms in the set.
948///
949/// This type is not used in any activity, and only used as *part* of another schema.
950///
951#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
952#[serde_with::serde_as]
953#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
954pub struct GlossaryTermsSet {
955 /// Each term in the set represents a term that can be replaced by the other terms.
956 pub terms: Option<Vec<GlossaryTerm>>,
957}
958
959impl common::Part for GlossaryTermsSet {}
960
961/// The request for importing an AdaptiveMt file along with its sentences.
962///
963/// # Activities
964///
965/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
966/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
967///
968/// * [locations adaptive mt datasets import adaptive mt file projects](ProjectLocationAdaptiveMtDatasetImportAdaptiveMtFileCall) (request)
969#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
970#[serde_with::serde_as]
971#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
972pub struct ImportAdaptiveMtFileRequest {
973 /// Inline file source.
974 #[serde(rename = "fileInputSource")]
975 pub file_input_source: Option<FileInputSource>,
976 /// Google Cloud Storage file source.
977 #[serde(rename = "gcsInputSource")]
978 pub gcs_input_source: Option<GcsInputSource>,
979}
980
981impl common::RequestValue for ImportAdaptiveMtFileRequest {}
982
983/// The response for importing an AdaptiveMtFile
984///
985/// # Activities
986///
987/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
988/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
989///
990/// * [locations adaptive mt datasets import adaptive mt file projects](ProjectLocationAdaptiveMtDatasetImportAdaptiveMtFileCall) (response)
991#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
992#[serde_with::serde_as]
993#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
994pub struct ImportAdaptiveMtFileResponse {
995 /// Output only. The Adaptive MT file that was imported.
996 #[serde(rename = "adaptiveMtFile")]
997 pub adaptive_mt_file: Option<AdaptiveMtFile>,
998}
999
1000impl common::ResponseResult for ImportAdaptiveMtFileResponse {}
1001
1002/// Request message for ImportData.
1003///
1004/// # Activities
1005///
1006/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1007/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1008///
1009/// * [locations datasets import data projects](ProjectLocationDatasetImportDataCall) (request)
1010#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1011#[serde_with::serde_as]
1012#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1013pub struct ImportDataRequest {
1014 /// Required. The config for the input content.
1015 #[serde(rename = "inputConfig")]
1016 pub input_config: Option<DatasetInputConfig>,
1017}
1018
1019impl common::RequestValue for ImportDataRequest {}
1020
1021/// Input configuration for BatchTranslateText request.
1022///
1023/// This type is not used in any activity, and only used as *part* of another schema.
1024///
1025#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1026#[serde_with::serde_as]
1027#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1028pub struct InputConfig {
1029 /// Required. Google Cloud Storage location for the source input. This can be a single file (for example, `gs://translation-test/input.tsv`) or a wildcard (for example, `gs://translation-test/*`). If a file extension is `.tsv`, it can contain either one or two columns. The first column (optional) is the id of the text request. If the first column is missing, we use the row number (0-based) from the input file as the ID in the output file. The second column is the actual text to be translated. We recommend each row be <= 10K Unicode codepoints, otherwise an error might be returned. Note that the input tsv must be RFC 4180 compliant. You could use https://github.com/Clever/csvlint to check potential formatting errors in your tsv file. csvlint --delimiter='\t' your_input_file.tsv The other supported file extensions are `.txt` or `.html`, which is treated as a single large chunk of text.
1030 #[serde(rename = "gcsSource")]
1031 pub gcs_source: Option<GcsSource>,
1032 /// Optional. Can be "text/plain" or "text/html". For `.tsv`, "text/html" is used if mime_type is missing. For `.html`, this field must be "text/html" or empty. For `.txt`, this field must be "text/plain" or empty.
1033 #[serde(rename = "mimeType")]
1034 pub mime_type: Option<String>,
1035}
1036
1037impl common::Part for InputConfig {}
1038
1039/// An input file.
1040///
1041/// This type is not used in any activity, and only used as *part* of another schema.
1042///
1043#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1044#[serde_with::serde_as]
1045#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1046pub struct InputFile {
1047 /// Google Cloud Storage file source.
1048 #[serde(rename = "gcsSource")]
1049 pub gcs_source: Option<GcsInputSource>,
1050 /// Optional. Usage of the file contents. Options are TRAIN|VALIDATION|TEST, or UNASSIGNED (by default) for auto split.
1051 pub usage: Option<String>,
1052}
1053
1054impl common::Part for InputFile {}
1055
1056/// Used with unidirectional glossaries.
1057///
1058/// This type is not used in any activity, and only used as *part* of another schema.
1059///
1060#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1061#[serde_with::serde_as]
1062#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1063pub struct LanguageCodePair {
1064 /// Required. The ISO-639 language code of the input text, for example, "en-US". Expected to be an exact match for GlossaryTerm.language_code.
1065 #[serde(rename = "sourceLanguageCode")]
1066 pub source_language_code: Option<String>,
1067 /// Required. The ISO-639 language code for translation output, for example, "zh-CN". Expected to be an exact match for GlossaryTerm.language_code.
1068 #[serde(rename = "targetLanguageCode")]
1069 pub target_language_code: Option<String>,
1070}
1071
1072impl common::Part for LanguageCodePair {}
1073
1074/// Used with equivalent term set glossaries.
1075///
1076/// This type is not used in any activity, and only used as *part* of another schema.
1077///
1078#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1079#[serde_with::serde_as]
1080#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1081pub struct LanguageCodesSet {
1082 /// The ISO-639 language code(s) for terms defined in the glossary. All entries are unique. The list contains at least two entries. Expected to be an exact match for GlossaryTerm.language_code.
1083 #[serde(rename = "languageCodes")]
1084 pub language_codes: Option<Vec<String>>,
1085}
1086
1087impl common::Part for LanguageCodesSet {}
1088
1089/// A list of AdaptiveMtDatasets.
1090///
1091/// # Activities
1092///
1093/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1094/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1095///
1096/// * [locations adaptive mt datasets list projects](ProjectLocationAdaptiveMtDatasetListCall) (response)
1097#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1098#[serde_with::serde_as]
1099#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1100pub struct ListAdaptiveMtDatasetsResponse {
1101 /// Output only. A list of Adaptive MT datasets.
1102 #[serde(rename = "adaptiveMtDatasets")]
1103 pub adaptive_mt_datasets: Option<Vec<AdaptiveMtDataset>>,
1104 /// Optional. A token to retrieve a page of results. Pass this value in the [ListAdaptiveMtDatasetsRequest.page_token] field in the subsequent call to `ListAdaptiveMtDatasets` method to retrieve the next page of results.
1105 #[serde(rename = "nextPageToken")]
1106 pub next_page_token: Option<String>,
1107}
1108
1109impl common::ResponseResult for ListAdaptiveMtDatasetsResponse {}
1110
1111/// The response for listing all AdaptiveMt files under a given dataset.
1112///
1113/// # Activities
1114///
1115/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1116/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1117///
1118/// * [locations adaptive mt datasets adaptive mt files list projects](ProjectLocationAdaptiveMtDatasetAdaptiveMtFileListCall) (response)
1119#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1120#[serde_with::serde_as]
1121#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1122pub struct ListAdaptiveMtFilesResponse {
1123 /// Output only. The Adaptive MT files.
1124 #[serde(rename = "adaptiveMtFiles")]
1125 pub adaptive_mt_files: Option<Vec<AdaptiveMtFile>>,
1126 /// Optional. A token to retrieve a page of results. Pass this value in the ListAdaptiveMtFilesRequest.page_token field in the subsequent call to `ListAdaptiveMtFiles` method to retrieve the next page of results.
1127 #[serde(rename = "nextPageToken")]
1128 pub next_page_token: Option<String>,
1129}
1130
1131impl common::ResponseResult for ListAdaptiveMtFilesResponse {}
1132
1133/// List AdaptiveMt sentences response.
1134///
1135/// # Activities
1136///
1137/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1138/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1139///
1140/// * [locations adaptive mt datasets adaptive mt files adaptive mt sentences list projects](ProjectLocationAdaptiveMtDatasetAdaptiveMtFileAdaptiveMtSentenceListCall) (response)
1141/// * [locations adaptive mt datasets adaptive mt sentences list projects](ProjectLocationAdaptiveMtDatasetAdaptiveMtSentenceListCall) (response)
1142#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1143#[serde_with::serde_as]
1144#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1145pub struct ListAdaptiveMtSentencesResponse {
1146 /// Output only. The list of AdaptiveMtSentences.
1147 #[serde(rename = "adaptiveMtSentences")]
1148 pub adaptive_mt_sentences: Option<Vec<AdaptiveMtSentence>>,
1149 /// Optional.
1150 #[serde(rename = "nextPageToken")]
1151 pub next_page_token: Option<String>,
1152}
1153
1154impl common::ResponseResult for ListAdaptiveMtSentencesResponse {}
1155
1156/// Response message for ListDatasets.
1157///
1158/// # Activities
1159///
1160/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1161/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1162///
1163/// * [locations datasets list projects](ProjectLocationDatasetListCall) (response)
1164#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1165#[serde_with::serde_as]
1166#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1167pub struct ListDatasetsResponse {
1168 /// The datasets read.
1169 pub datasets: Option<Vec<Dataset>>,
1170 /// A token to retrieve next page of results. Pass this token to the page_token field in the ListDatasetsRequest to obtain the corresponding page.
1171 #[serde(rename = "nextPageToken")]
1172 pub next_page_token: Option<String>,
1173}
1174
1175impl common::ResponseResult for ListDatasetsResponse {}
1176
1177/// Response message for ListExamples.
1178///
1179/// # Activities
1180///
1181/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1182/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1183///
1184/// * [locations datasets examples list projects](ProjectLocationDatasetExampleListCall) (response)
1185#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1186#[serde_with::serde_as]
1187#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1188pub struct ListExamplesResponse {
1189 /// The sentence pairs.
1190 pub examples: Option<Vec<Example>>,
1191 /// A token to retrieve next page of results. Pass this token to the page_token field in the ListExamplesRequest to obtain the corresponding page.
1192 #[serde(rename = "nextPageToken")]
1193 pub next_page_token: Option<String>,
1194}
1195
1196impl common::ResponseResult for ListExamplesResponse {}
1197
1198/// Response message for ListGlossaries.
1199///
1200/// # Activities
1201///
1202/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1203/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1204///
1205/// * [locations glossaries list projects](ProjectLocationGlossaryListCall) (response)
1206#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1207#[serde_with::serde_as]
1208#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1209pub struct ListGlossariesResponse {
1210 /// The list of glossaries for a project.
1211 pub glossaries: Option<Vec<Glossary>>,
1212 /// A token to retrieve a page of results. Pass this value in the [ListGlossariesRequest.page_token] field in the subsequent call to `ListGlossaries` method to retrieve the next page of results.
1213 #[serde(rename = "nextPageToken")]
1214 pub next_page_token: Option<String>,
1215}
1216
1217impl common::ResponseResult for ListGlossariesResponse {}
1218
1219/// Response message for ListGlossaryEntries
1220///
1221/// # Activities
1222///
1223/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1224/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1225///
1226/// * [locations glossaries glossary entries list projects](ProjectLocationGlossaryGlossaryEntryListCall) (response)
1227#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1228#[serde_with::serde_as]
1229#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1230pub struct ListGlossaryEntriesResponse {
1231 /// Optional. The Glossary Entries
1232 #[serde(rename = "glossaryEntries")]
1233 pub glossary_entries: Option<Vec<GlossaryEntry>>,
1234 /// Optional. A token to retrieve a page of results. Pass this value in the [ListGLossaryEntriesRequest.page_token] field in the subsequent calls.
1235 #[serde(rename = "nextPageToken")]
1236 pub next_page_token: Option<String>,
1237}
1238
1239impl common::ResponseResult for ListGlossaryEntriesResponse {}
1240
1241/// The response message for Locations.ListLocations.
1242///
1243/// # Activities
1244///
1245/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1246/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1247///
1248/// * [locations list projects](ProjectLocationListCall) (response)
1249#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1250#[serde_with::serde_as]
1251#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1252pub struct ListLocationsResponse {
1253 /// A list of locations that matches the specified filter in the request.
1254 pub locations: Option<Vec<Location>>,
1255 /// The standard List next-page token.
1256 #[serde(rename = "nextPageToken")]
1257 pub next_page_token: Option<String>,
1258}
1259
1260impl common::ResponseResult for ListLocationsResponse {}
1261
1262/// Response message for ListModels.
1263///
1264/// # Activities
1265///
1266/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1267/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1268///
1269/// * [locations models list projects](ProjectLocationModelListCall) (response)
1270#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1271#[serde_with::serde_as]
1272#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1273pub struct ListModelsResponse {
1274 /// The models read.
1275 pub models: Option<Vec<Model>>,
1276 /// A token to retrieve next page of results. Pass this token to the page_token field in the ListModelsRequest to obtain the corresponding page.
1277 #[serde(rename = "nextPageToken")]
1278 pub next_page_token: Option<String>,
1279}
1280
1281impl common::ResponseResult for ListModelsResponse {}
1282
1283/// The response message for Operations.ListOperations.
1284///
1285/// # Activities
1286///
1287/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1288/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1289///
1290/// * [locations operations list projects](ProjectLocationOperationListCall) (response)
1291#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1292#[serde_with::serde_as]
1293#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1294pub struct ListOperationsResponse {
1295 /// The standard List next-page token.
1296 #[serde(rename = "nextPageToken")]
1297 pub next_page_token: Option<String>,
1298 /// A list of operations that matches the specified filter in the request.
1299 pub operations: Option<Vec<Operation>>,
1300}
1301
1302impl common::ResponseResult for ListOperationsResponse {}
1303
1304/// A resource that represents a Google Cloud location.
1305///
1306/// # Activities
1307///
1308/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1309/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1310///
1311/// * [locations get projects](ProjectLocationGetCall) (response)
1312#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1313#[serde_with::serde_as]
1314#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1315pub struct Location {
1316 /// The friendly name for this location, typically a nearby city name. For example, "Tokyo".
1317 #[serde(rename = "displayName")]
1318 pub display_name: Option<String>,
1319 /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"}
1320 pub labels: Option<HashMap<String, String>>,
1321 /// The canonical id for this location. For example: `"us-east1"`.
1322 #[serde(rename = "locationId")]
1323 pub location_id: Option<String>,
1324 /// Service-specific metadata. For example the available capacity at the given location.
1325 pub metadata: Option<HashMap<String, serde_json::Value>>,
1326 /// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"`
1327 pub name: Option<String>,
1328}
1329
1330impl common::ResponseResult for Location {}
1331
1332/// A trained translation model.
1333///
1334/// # Activities
1335///
1336/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1337/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1338///
1339/// * [locations models create projects](ProjectLocationModelCreateCall) (request)
1340/// * [locations models get projects](ProjectLocationModelGetCall) (response)
1341#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1342#[serde_with::serde_as]
1343#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1344pub struct Model {
1345 /// Output only. Timestamp when the model resource was created, which is also when the training started.
1346 #[serde(rename = "createTime")]
1347 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1348 /// The dataset from which the model is trained, in form of `projects/{project-number-or-id}/locations/{location_id}/datasets/{dataset_id}`
1349 pub dataset: Option<String>,
1350 /// The name of the model to show in the interface. The name can be up to 32 characters long and can consist only of ASCII Latin letters A-Z and a-z, underscores (_), and ASCII digits 0-9.
1351 #[serde(rename = "displayName")]
1352 pub display_name: Option<String>,
1353 /// The resource name of the model, in form of `projects/{project-number-or-id}/locations/{location_id}/models/{model_id}`
1354 pub name: Option<String>,
1355 /// Output only. The BCP-47 language code of the source language.
1356 #[serde(rename = "sourceLanguageCode")]
1357 pub source_language_code: Option<String>,
1358 /// Output only. The BCP-47 language code of the target language.
1359 #[serde(rename = "targetLanguageCode")]
1360 pub target_language_code: Option<String>,
1361 /// Output only. Number of examples (sentence pairs) used to test the model.
1362 #[serde(rename = "testExampleCount")]
1363 pub test_example_count: Option<i32>,
1364 /// Output only. Number of examples (sentence pairs) used to train the model.
1365 #[serde(rename = "trainExampleCount")]
1366 pub train_example_count: Option<i32>,
1367 /// Output only. Timestamp when this model was last updated.
1368 #[serde(rename = "updateTime")]
1369 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1370 /// Output only. Number of examples (sentence pairs) used to validate the model.
1371 #[serde(rename = "validateExampleCount")]
1372 pub validate_example_count: Option<i32>,
1373}
1374
1375impl common::RequestValue for Model {}
1376impl common::ResponseResult for Model {}
1377
1378/// This resource represents a long-running operation that is the result of a network API call.
1379///
1380/// # Activities
1381///
1382/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1383/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1384///
1385/// * [locations datasets create projects](ProjectLocationDatasetCreateCall) (response)
1386/// * [locations datasets delete projects](ProjectLocationDatasetDeleteCall) (response)
1387/// * [locations datasets export data projects](ProjectLocationDatasetExportDataCall) (response)
1388/// * [locations datasets import data projects](ProjectLocationDatasetImportDataCall) (response)
1389/// * [locations glossaries create projects](ProjectLocationGlossaryCreateCall) (response)
1390/// * [locations glossaries delete projects](ProjectLocationGlossaryDeleteCall) (response)
1391/// * [locations glossaries patch projects](ProjectLocationGlossaryPatchCall) (response)
1392/// * [locations models create projects](ProjectLocationModelCreateCall) (response)
1393/// * [locations models delete projects](ProjectLocationModelDeleteCall) (response)
1394/// * [locations operations get projects](ProjectLocationOperationGetCall) (response)
1395/// * [locations operations wait projects](ProjectLocationOperationWaitCall) (response)
1396/// * [locations batch translate document projects](ProjectLocationBatchTranslateDocumentCall) (response)
1397/// * [locations batch translate text projects](ProjectLocationBatchTranslateTextCall) (response)
1398#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1399#[serde_with::serde_as]
1400#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1401pub struct Operation {
1402 /// 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.
1403 pub done: Option<bool>,
1404 /// The error result of the operation in case of failure or cancellation.
1405 pub error: Option<Status>,
1406 /// 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.
1407 pub metadata: Option<HashMap<String, serde_json::Value>>,
1408 /// 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}`.
1409 pub name: Option<String>,
1410 /// 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`.
1411 pub response: Option<HashMap<String, serde_json::Value>>,
1412}
1413
1414impl common::ResponseResult for Operation {}
1415
1416/// Output configuration for BatchTranslateText request.
1417///
1418/// This type is not used in any activity, and only used as *part* of another schema.
1419///
1420#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1421#[serde_with::serde_as]
1422#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1423pub struct OutputConfig {
1424 /// Google Cloud Storage destination for output content. For every single input file (for example, gs://a/b/c.[extension]), we generate at most 2 * n output files. (n is the # of target_language_codes in the BatchTranslateTextRequest). Output files (tsv) generated are compliant with RFC 4180 except that record delimiters are '\n' instead of '\r\n'. We don't provide any way to change record delimiters. While the input files are being processed, we write/update an index file 'index.csv' under 'output_uri_prefix' (for example, gs://translation-test/index.csv) The index file is generated/updated as new files are being translated. The format is: input_file,target_language_code,translations_file,errors_file, glossary_translations_file,glossary_errors_file input_file is one file we matched using gcs_source.input_uri. target_language_code is provided in the request. translations_file contains the translations. (details provided below) errors_file contains the errors during processing of the file. (details below). Both translations_file and errors_file could be empty strings if we have no content to output. glossary_translations_file and glossary_errors_file are always empty strings if the input_file is tsv. They could also be empty if we have no content to output. Once a row is present in index.csv, the input/output matching never changes. Callers should also expect all the content in input_file are processed and ready to be consumed (that is, no partial output file is written). Since index.csv will be keeping updated during the process, please make sure there is no custom retention policy applied on the output bucket that may avoid file updating. (https://cloud.google.com/storage/docs/bucket-lock#retention-policy) The format of translations_file (for target language code 'trg') is: `gs://translation_test/a_b_c_'trg'_translations.[extension]` If the input file extension is tsv, the output has the following columns: Column 1: ID of the request provided in the input, if it's not provided in the input, then the input row number is used (0-based). Column 2: source sentence. Column 3: translation without applying a glossary. Empty string if there is an error. Column 4 (only present if a glossary is provided in the request): translation after applying the glossary. Empty string if there is an error applying the glossary. Could be same string as column 3 if there is no glossary applied. If input file extension is a txt or html, the translation is directly written to the output file. If glossary is requested, a separate glossary_translations_file has format of `gs://translation_test/a_b_c_'trg'_glossary_translations.[extension]` The format of errors file (for target language code 'trg') is: `gs://translation_test/a_b_c_'trg'_errors.[extension]` If the input file extension is tsv, errors_file contains the following: Column 1: ID of the request provided in the input, if it's not provided in the input, then the input row number is used (0-based). Column 2: source sentence. Column 3: Error detail for the translation. Could be empty. Column 4 (only present if a glossary is provided in the request): Error when applying the glossary. If the input file extension is txt or html, glossary_error_file will be generated that contains error details. glossary_error_file has format of `gs://translation_test/a_b_c_'trg'_glossary_errors.[extension]`
1425 #[serde(rename = "gcsDestination")]
1426 pub gcs_destination: Option<GcsDestination>,
1427}
1428
1429impl common::Part for OutputConfig {}
1430
1431/// Message of caller-provided reference configuration.
1432///
1433/// This type is not used in any activity, and only used as *part* of another schema.
1434///
1435#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1436#[serde_with::serde_as]
1437#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1438pub struct ReferenceSentenceConfig {
1439 /// Reference sentences pair lists. Each list will be used as the references to translate the sentence under "content" field at the corresponding index. Length of the list is required to be equal to the length of "content" field.
1440 #[serde(rename = "referenceSentencePairLists")]
1441 pub reference_sentence_pair_lists: Option<Vec<ReferenceSentencePairList>>,
1442 /// Source language code.
1443 #[serde(rename = "sourceLanguageCode")]
1444 pub source_language_code: Option<String>,
1445 /// Target language code.
1446 #[serde(rename = "targetLanguageCode")]
1447 pub target_language_code: Option<String>,
1448}
1449
1450impl common::Part for ReferenceSentenceConfig {}
1451
1452/// A pair of sentences used as reference in source and target languages.
1453///
1454/// This type is not used in any activity, and only used as *part* of another schema.
1455///
1456#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1457#[serde_with::serde_as]
1458#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1459pub struct ReferenceSentencePair {
1460 /// Source sentence in the sentence pair.
1461 #[serde(rename = "sourceSentence")]
1462 pub source_sentence: Option<String>,
1463 /// Target sentence in the sentence pair.
1464 #[serde(rename = "targetSentence")]
1465 pub target_sentence: Option<String>,
1466}
1467
1468impl common::Part for ReferenceSentencePair {}
1469
1470/// A list of reference sentence pairs.
1471///
1472/// This type is not used in any activity, and only used as *part* of another schema.
1473///
1474#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1475#[serde_with::serde_as]
1476#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1477pub struct ReferenceSentencePairList {
1478 /// Reference sentence pairs.
1479 #[serde(rename = "referenceSentencePairs")]
1480 pub reference_sentence_pairs: Option<Vec<ReferenceSentencePair>>,
1481}
1482
1483impl common::Part for ReferenceSentencePairList {}
1484
1485/// A single romanization response.
1486///
1487/// This type is not used in any activity, and only used as *part* of another schema.
1488///
1489#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1490#[serde_with::serde_as]
1491#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1492pub struct Romanization {
1493 /// The ISO-639 language code of source text in the initial request, detected automatically, if no source language was passed within the initial request. If the source language was passed, auto-detection of the language does not occur and this field is empty.
1494 #[serde(rename = "detectedLanguageCode")]
1495 pub detected_language_code: Option<String>,
1496 /// Romanized text. If an error occurs during romanization, this field might be excluded from the response.
1497 #[serde(rename = "romanizedText")]
1498 pub romanized_text: Option<String>,
1499}
1500
1501impl common::Part for Romanization {}
1502
1503/// The request message for synchronous romanization.
1504///
1505/// # Activities
1506///
1507/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1508/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1509///
1510/// * [locations romanize text projects](ProjectLocationRomanizeTextCall) (request)
1511/// * [romanize text projects](ProjectRomanizeTextCall) (request)
1512#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1513#[serde_with::serde_as]
1514#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1515pub struct RomanizeTextRequest {
1516 /// Required. The content of the input in string format.
1517 pub contents: Option<Vec<String>>,
1518 /// Optional. The ISO-639 language code of the input text if known, for example, "hi" or "zh". If the source language isn't specified, the API attempts to identify the source language automatically and returns the source language for each content in the response.
1519 #[serde(rename = "sourceLanguageCode")]
1520 pub source_language_code: Option<String>,
1521}
1522
1523impl common::RequestValue for RomanizeTextRequest {}
1524
1525/// The response message for synchronous romanization.
1526///
1527/// # Activities
1528///
1529/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1530/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1531///
1532/// * [locations romanize text projects](ProjectLocationRomanizeTextCall) (response)
1533/// * [romanize text projects](ProjectRomanizeTextCall) (response)
1534#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1535#[serde_with::serde_as]
1536#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1537pub struct RomanizeTextResponse {
1538 /// Text romanization responses. This field has the same length as `contents`.
1539 pub romanizations: Option<Vec<Romanization>>,
1540}
1541
1542impl common::ResponseResult for RomanizeTextResponse {}
1543
1544/// 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).
1545///
1546/// This type is not used in any activity, and only used as *part* of another schema.
1547///
1548#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1549#[serde_with::serde_as]
1550#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1551pub struct Status {
1552 /// The status code, which should be an enum value of google.rpc.Code.
1553 pub code: Option<i32>,
1554 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
1555 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
1556 /// 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.
1557 pub message: Option<String>,
1558}
1559
1560impl common::Part for Status {}
1561
1562/// A single supported language response corresponds to information related to one supported language.
1563///
1564/// This type is not used in any activity, and only used as *part* of another schema.
1565///
1566#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1567#[serde_with::serde_as]
1568#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1569pub struct SupportedLanguage {
1570 /// Human-readable name of the language localized in the display language specified in the request.
1571 #[serde(rename = "displayName")]
1572 pub display_name: Option<String>,
1573 /// Supported language code, generally consisting of its ISO 639-1 identifier, for example, 'en', 'ja'. In certain cases, ISO-639 codes including language and region identifiers are returned (for example, 'zh-TW' and 'zh-CN').
1574 #[serde(rename = "languageCode")]
1575 pub language_code: Option<String>,
1576 /// Can be used as a source language.
1577 #[serde(rename = "supportSource")]
1578 pub support_source: Option<bool>,
1579 /// Can be used as a target language.
1580 #[serde(rename = "supportTarget")]
1581 pub support_target: Option<bool>,
1582}
1583
1584impl common::Part for SupportedLanguage {}
1585
1586/// The response message for discovering supported languages.
1587///
1588/// # Activities
1589///
1590/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1591/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1592///
1593/// * [locations get supported languages projects](ProjectLocationGetSupportedLanguageCall) (response)
1594/// * [get supported languages projects](ProjectGetSupportedLanguageCall) (response)
1595#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1596#[serde_with::serde_as]
1597#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1598pub struct SupportedLanguages {
1599 /// A list of supported language responses. This list contains an entry for each language the Translation API supports.
1600 pub languages: Option<Vec<SupportedLanguage>>,
1601}
1602
1603impl common::ResponseResult for SupportedLanguages {}
1604
1605/// A document translation request.
1606///
1607/// # Activities
1608///
1609/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1610/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1611///
1612/// * [locations translate document projects](ProjectLocationTranslateDocumentCall) (request)
1613#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1614#[serde_with::serde_as]
1615#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1616pub struct TranslateDocumentRequest {
1617 /// Optional. This flag is to support user customized attribution. If not provided, the default is `Machine Translated by Google`. Customized attribution should follow rules in https://cloud.google.com/translate/attribution#attribution_and_logos
1618 #[serde(rename = "customizedAttribution")]
1619 pub customized_attribution: Option<String>,
1620 /// Required. Input configurations.
1621 #[serde(rename = "documentInputConfig")]
1622 pub document_input_config: Option<DocumentInputConfig>,
1623 /// Optional. Output configurations. Defines if the output file should be stored within Cloud Storage as well as the desired output format. If not provided the translated file will only be returned through a byte-stream and its output mime type will be the same as the input file's mime type.
1624 #[serde(rename = "documentOutputConfig")]
1625 pub document_output_config: Option<DocumentOutputConfig>,
1626 /// Optional. If true, enable auto rotation correction in DVS.
1627 #[serde(rename = "enableRotationCorrection")]
1628 pub enable_rotation_correction: Option<bool>,
1629 /// Optional. If true, use the text removal server to remove the shadow text on background image for native pdf translation. Shadow removal feature can only be enabled when is_translate_native_pdf_only: false && pdf_native_only: false
1630 #[serde(rename = "enableShadowRemovalNativePdf")]
1631 pub enable_shadow_removal_native_pdf: Option<bool>,
1632 /// Optional. Glossary to be applied. The glossary must be within the same region (have the same location-id) as the model, otherwise an INVALID_ARGUMENT (400) error is returned.
1633 #[serde(rename = "glossaryConfig")]
1634 pub glossary_config: Option<TranslateTextGlossaryConfig>,
1635 /// Optional. is_translate_native_pdf_only field for external customers. If true, the page limit of online native pdf translation is 300 and only native pdf pages will be translated.
1636 #[serde(rename = "isTranslateNativePdfOnly")]
1637 pub is_translate_native_pdf_only: Option<bool>,
1638 /// Optional. The labels with user-defined metadata for the request. Label keys and values can be no longer than 63 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. Label values are optional. Label keys must start with a letter. See https://cloud.google.com/translate/docs/advanced/labels for more information.
1639 pub labels: Option<HashMap<String, String>>,
1640 /// Optional. The `model` type requested for this translation. The format depends on model type: - AutoML Translation models: `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}` - General (built-in) models: `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`, If not provided, the default Google model (NMT) will be used for translation.
1641 pub model: Option<String>,
1642 /// Optional. The ISO-639 language code of the input document if known, for example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support. If the source language isn't specified, the API attempts to identify the source language automatically and returns the source language within the response. Source language must be specified if the request contains a glossary or a custom model.
1643 #[serde(rename = "sourceLanguageCode")]
1644 pub source_language_code: Option<String>,
1645 /// Required. The ISO-639 language code to use for translation of the input document, set to one of the language codes listed in Language Support.
1646 #[serde(rename = "targetLanguageCode")]
1647 pub target_language_code: Option<String>,
1648}
1649
1650impl common::RequestValue for TranslateDocumentRequest {}
1651
1652/// A translated document response message.
1653///
1654/// # Activities
1655///
1656/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1657/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1658///
1659/// * [locations translate document projects](ProjectLocationTranslateDocumentCall) (response)
1660#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1661#[serde_with::serde_as]
1662#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1663pub struct TranslateDocumentResponse {
1664 /// Translated document.
1665 #[serde(rename = "documentTranslation")]
1666 pub document_translation: Option<DocumentTranslation>,
1667 /// The `glossary_config` used for this translation.
1668 #[serde(rename = "glossaryConfig")]
1669 pub glossary_config: Option<TranslateTextGlossaryConfig>,
1670 /// The document's translation output if a glossary is provided in the request. This can be the same as [TranslateDocumentResponse.document_translation] if no glossary terms apply.
1671 #[serde(rename = "glossaryDocumentTranslation")]
1672 pub glossary_document_translation: Option<DocumentTranslation>,
1673 /// Only present when 'model' is present in the request. 'model' is normalized to have a project number. For example: If the 'model' field in TranslateDocumentRequest is: `projects/{project-id}/locations/{location-id}/models/general/nmt` then `model` here would be normalized to `projects/{project-number}/locations/{location-id}/models/general/nmt`.
1674 pub model: Option<String>,
1675}
1676
1677impl common::ResponseResult for TranslateDocumentResponse {}
1678
1679/// Configures which glossary is used for a specific target language and defines options for applying that glossary.
1680///
1681/// This type is not used in any activity, and only used as *part* of another schema.
1682///
1683#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1684#[serde_with::serde_as]
1685#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1686pub struct TranslateTextGlossaryConfig {
1687 /// Optional. If set to true, the glossary will be used for contextual translation.
1688 #[serde(rename = "contextualTranslationEnabled")]
1689 pub contextual_translation_enabled: Option<bool>,
1690 /// Required. The `glossary` to be applied for this translation. The format depends on the glossary: - User-provided custom glossary: `projects/{project-number-or-id}/locations/{location-id}/glossaries/{glossary-id}`
1691 pub glossary: Option<String>,
1692 /// Optional. Indicates match is case insensitive. The default value is `false` if missing.
1693 #[serde(rename = "ignoreCase")]
1694 pub ignore_case: Option<bool>,
1695}
1696
1697impl common::Part for TranslateTextGlossaryConfig {}
1698
1699/// The request message for synchronous translation.
1700///
1701/// # Activities
1702///
1703/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1704/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1705///
1706/// * [locations translate text projects](ProjectLocationTranslateTextCall) (request)
1707/// * [translate text projects](ProjectTranslateTextCall) (request)
1708#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1709#[serde_with::serde_as]
1710#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1711pub struct TranslateTextRequest {
1712 /// Required. The content of the input in string format. We recommend the total content be less than 30,000 codepoints. The max length of this field is 1024. Use BatchTranslateText for larger text.
1713 pub contents: Option<Vec<String>>,
1714 /// Optional. Glossary to be applied. The glossary must be within the same region (have the same location-id) as the model, otherwise an INVALID_ARGUMENT (400) error is returned.
1715 #[serde(rename = "glossaryConfig")]
1716 pub glossary_config: Option<TranslateTextGlossaryConfig>,
1717 /// Optional. The labels with user-defined metadata for the request. Label keys and values can be no longer than 63 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. Label values are optional. Label keys must start with a letter. See https://cloud.google.com/translate/docs/advanced/labels for more information.
1718 pub labels: Option<HashMap<String, String>>,
1719 /// Optional. The format of the source text, for example, "text/html", "text/plain". If left blank, the MIME type defaults to "text/html".
1720 #[serde(rename = "mimeType")]
1721 pub mime_type: Option<String>,
1722 /// Optional. The `model` type requested for this translation. The format depends on model type: - AutoML Translation models: `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}` - General (built-in) models: `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`, - Translation LLM models: `projects/{project-number-or-id}/locations/{location-id}/models/general/translation-llm`, For global (non-regionalized) requests, use `location-id` `global`. For example, `projects/{project-number-or-id}/locations/global/models/general/nmt`. If not provided, the default Google model (NMT) will be used
1723 pub model: Option<String>,
1724 /// Optional. The ISO-639 language code of the input text if known, for example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support. If the source language isn't specified, the API attempts to identify the source language automatically and returns the source language within the response.
1725 #[serde(rename = "sourceLanguageCode")]
1726 pub source_language_code: Option<String>,
1727 /// Required. The ISO-639 language code to use for translation of the input text, set to one of the language codes listed in Language Support.
1728 #[serde(rename = "targetLanguageCode")]
1729 pub target_language_code: Option<String>,
1730 /// Optional. Transliteration to be applied.
1731 #[serde(rename = "transliterationConfig")]
1732 pub transliteration_config: Option<TransliterationConfig>,
1733}
1734
1735impl common::RequestValue for TranslateTextRequest {}
1736
1737/// There is no detailed description.
1738///
1739/// # Activities
1740///
1741/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1742/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1743///
1744/// * [locations translate text projects](ProjectLocationTranslateTextCall) (response)
1745/// * [translate text projects](ProjectTranslateTextCall) (response)
1746#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1747#[serde_with::serde_as]
1748#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1749pub struct TranslateTextResponse {
1750 /// Text translation responses if a glossary is provided in the request. This can be the same as `translations` if no terms apply. This field has the same length as `contents`.
1751 #[serde(rename = "glossaryTranslations")]
1752 pub glossary_translations: Option<Vec<Translation>>,
1753 /// Text translation responses with no glossary applied. This field has the same length as `contents`.
1754 pub translations: Option<Vec<Translation>>,
1755}
1756
1757impl common::ResponseResult for TranslateTextResponse {}
1758
1759/// A single translation response.
1760///
1761/// This type is not used in any activity, and only used as *part* of another schema.
1762///
1763#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1764#[serde_with::serde_as]
1765#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1766pub struct Translation {
1767 /// The ISO-639 language code of source text in the initial request, detected automatically, if no source language was passed within the initial request. If the source language was passed, auto-detection of the language does not occur and this field is empty.
1768 #[serde(rename = "detectedLanguageCode")]
1769 pub detected_language_code: Option<String>,
1770 /// The `glossary_config` used for this translation.
1771 #[serde(rename = "glossaryConfig")]
1772 pub glossary_config: Option<TranslateTextGlossaryConfig>,
1773 /// Only present when `model` is present in the request. `model` here is normalized to have project number. For example: If the `model` requested in TranslationTextRequest is `projects/{project-id}/locations/{location-id}/models/general/nmt` then `model` here would be normalized to `projects/{project-number}/locations/{location-id}/models/general/nmt`.
1774 pub model: Option<String>,
1775 /// Text translated into the target language. If an error occurs during translation, this field might be excluded from the response.
1776 #[serde(rename = "translatedText")]
1777 pub translated_text: Option<String>,
1778}
1779
1780impl common::Part for Translation {}
1781
1782/// Configures transliteration feature on top of translation.
1783///
1784/// This type is not used in any activity, and only used as *part* of another schema.
1785///
1786#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1787#[serde_with::serde_as]
1788#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1789pub struct TransliterationConfig {
1790 /// If true, source text in romanized form can be translated to the target language.
1791 #[serde(rename = "enableTransliteration")]
1792 pub enable_transliteration: Option<bool>,
1793}
1794
1795impl common::Part for TransliterationConfig {}
1796
1797/// The request message for Operations.WaitOperation.
1798///
1799/// # Activities
1800///
1801/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1802/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1803///
1804/// * [locations operations wait projects](ProjectLocationOperationWaitCall) (request)
1805#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1806#[serde_with::serde_as]
1807#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1808pub struct WaitOperationRequest {
1809 /// The maximum duration to wait before timing out. If left blank, the wait will be at most the time permitted by the underlying HTTP/RPC protocol. If RPC context deadline is also specified, the shorter one will be used.
1810 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1811 pub timeout: Option<chrono::Duration>,
1812}
1813
1814impl common::RequestValue for WaitOperationRequest {}
1815
1816// ###################
1817// MethodBuilders ###
1818// #################
1819
1820/// A builder providing access to all methods supported on *project* resources.
1821/// It is not used directly, but through the [`Translate`] hub.
1822///
1823/// # Example
1824///
1825/// Instantiate a resource builder
1826///
1827/// ```test_harness,no_run
1828/// extern crate hyper;
1829/// extern crate hyper_rustls;
1830/// extern crate google_translate3 as translate3;
1831///
1832/// # async fn dox() {
1833/// use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1834///
1835/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1836/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1837/// .with_native_roots()
1838/// .unwrap()
1839/// .https_only()
1840/// .enable_http2()
1841/// .build();
1842///
1843/// let executor = hyper_util::rt::TokioExecutor::new();
1844/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1845/// secret,
1846/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1847/// yup_oauth2::client::CustomHyperClientBuilder::from(
1848/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1849/// ),
1850/// ).build().await.unwrap();
1851///
1852/// let client = hyper_util::client::legacy::Client::builder(
1853/// hyper_util::rt::TokioExecutor::new()
1854/// )
1855/// .build(
1856/// hyper_rustls::HttpsConnectorBuilder::new()
1857/// .with_native_roots()
1858/// .unwrap()
1859/// .https_or_http()
1860/// .enable_http2()
1861/// .build()
1862/// );
1863/// let mut hub = Translate::new(client, auth);
1864/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1865/// // like `detect_language(...)`, `get_supported_languages(...)`, `locations_adaptive_mt_datasets_adaptive_mt_files_adaptive_mt_sentences_list(...)`, `locations_adaptive_mt_datasets_adaptive_mt_files_delete(...)`, `locations_adaptive_mt_datasets_adaptive_mt_files_get(...)`, `locations_adaptive_mt_datasets_adaptive_mt_files_list(...)`, `locations_adaptive_mt_datasets_adaptive_mt_sentences_list(...)`, `locations_adaptive_mt_datasets_create(...)`, `locations_adaptive_mt_datasets_delete(...)`, `locations_adaptive_mt_datasets_get(...)`, `locations_adaptive_mt_datasets_import_adaptive_mt_file(...)`, `locations_adaptive_mt_datasets_list(...)`, `locations_adaptive_mt_translate(...)`, `locations_batch_translate_document(...)`, `locations_batch_translate_text(...)`, `locations_datasets_create(...)`, `locations_datasets_delete(...)`, `locations_datasets_examples_list(...)`, `locations_datasets_export_data(...)`, `locations_datasets_get(...)`, `locations_datasets_import_data(...)`, `locations_datasets_list(...)`, `locations_detect_language(...)`, `locations_get(...)`, `locations_get_supported_languages(...)`, `locations_glossaries_create(...)`, `locations_glossaries_delete(...)`, `locations_glossaries_get(...)`, `locations_glossaries_glossary_entries_create(...)`, `locations_glossaries_glossary_entries_delete(...)`, `locations_glossaries_glossary_entries_get(...)`, `locations_glossaries_glossary_entries_list(...)`, `locations_glossaries_glossary_entries_patch(...)`, `locations_glossaries_list(...)`, `locations_glossaries_patch(...)`, `locations_list(...)`, `locations_models_create(...)`, `locations_models_delete(...)`, `locations_models_get(...)`, `locations_models_list(...)`, `locations_operations_cancel(...)`, `locations_operations_delete(...)`, `locations_operations_get(...)`, `locations_operations_list(...)`, `locations_operations_wait(...)`, `locations_romanize_text(...)`, `locations_translate_document(...)`, `locations_translate_text(...)`, `romanize_text(...)` and `translate_text(...)`
1866/// // to build up your call.
1867/// let rb = hub.projects();
1868/// # }
1869/// ```
1870pub struct ProjectMethods<'a, C>
1871where
1872 C: 'a,
1873{
1874 hub: &'a Translate<C>,
1875}
1876
1877impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
1878
1879impl<'a, C> ProjectMethods<'a, C> {
1880 /// Create a builder to help you perform the following task:
1881 ///
1882 /// Lists all AdaptiveMtSentences under a given file/dataset.
1883 ///
1884 /// # Arguments
1885 ///
1886 /// * `parent` - Required. The resource name of the project from which to list the Adaptive MT files. The following format lists all sentences under a file. `projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file}` The following format lists all sentences within a dataset. `projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}`
1887 pub fn locations_adaptive_mt_datasets_adaptive_mt_files_adaptive_mt_sentences_list(
1888 &self,
1889 parent: &str,
1890 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileAdaptiveMtSentenceListCall<'a, C> {
1891 ProjectLocationAdaptiveMtDatasetAdaptiveMtFileAdaptiveMtSentenceListCall {
1892 hub: self.hub,
1893 _parent: parent.to_string(),
1894 _page_token: Default::default(),
1895 _page_size: Default::default(),
1896 _delegate: Default::default(),
1897 _additional_params: Default::default(),
1898 _scopes: Default::default(),
1899 }
1900 }
1901
1902 /// Create a builder to help you perform the following task:
1903 ///
1904 /// Deletes an AdaptiveMtFile along with its sentences.
1905 ///
1906 /// # Arguments
1907 ///
1908 /// * `name` - Required. The resource name of the file to delete, in form of `projects/{project-number-or-id}/locations/{location_id}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file}`
1909 pub fn locations_adaptive_mt_datasets_adaptive_mt_files_delete(
1910 &self,
1911 name: &str,
1912 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileDeleteCall<'a, C> {
1913 ProjectLocationAdaptiveMtDatasetAdaptiveMtFileDeleteCall {
1914 hub: self.hub,
1915 _name: name.to_string(),
1916 _delegate: Default::default(),
1917 _additional_params: Default::default(),
1918 _scopes: Default::default(),
1919 }
1920 }
1921
1922 /// Create a builder to help you perform the following task:
1923 ///
1924 /// Gets and AdaptiveMtFile
1925 ///
1926 /// # Arguments
1927 ///
1928 /// * `name` - Required. The resource name of the file, in form of `projects/{project-number-or-id}/locations/{location_id}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file}`
1929 pub fn locations_adaptive_mt_datasets_adaptive_mt_files_get(
1930 &self,
1931 name: &str,
1932 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileGetCall<'a, C> {
1933 ProjectLocationAdaptiveMtDatasetAdaptiveMtFileGetCall {
1934 hub: self.hub,
1935 _name: name.to_string(),
1936 _delegate: Default::default(),
1937 _additional_params: Default::default(),
1938 _scopes: Default::default(),
1939 }
1940 }
1941
1942 /// Create a builder to help you perform the following task:
1943 ///
1944 /// Lists all AdaptiveMtFiles associated to an AdaptiveMtDataset.
1945 ///
1946 /// # Arguments
1947 ///
1948 /// * `parent` - Required. The resource name of the project from which to list the Adaptive MT files. `projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}`
1949 pub fn locations_adaptive_mt_datasets_adaptive_mt_files_list(
1950 &self,
1951 parent: &str,
1952 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileListCall<'a, C> {
1953 ProjectLocationAdaptiveMtDatasetAdaptiveMtFileListCall {
1954 hub: self.hub,
1955 _parent: parent.to_string(),
1956 _page_token: Default::default(),
1957 _page_size: Default::default(),
1958 _delegate: Default::default(),
1959 _additional_params: Default::default(),
1960 _scopes: Default::default(),
1961 }
1962 }
1963
1964 /// Create a builder to help you perform the following task:
1965 ///
1966 /// Lists all AdaptiveMtSentences under a given file/dataset.
1967 ///
1968 /// # Arguments
1969 ///
1970 /// * `parent` - Required. The resource name of the project from which to list the Adaptive MT files. The following format lists all sentences under a file. `projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file}` The following format lists all sentences within a dataset. `projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}`
1971 pub fn locations_adaptive_mt_datasets_adaptive_mt_sentences_list(
1972 &self,
1973 parent: &str,
1974 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtSentenceListCall<'a, C> {
1975 ProjectLocationAdaptiveMtDatasetAdaptiveMtSentenceListCall {
1976 hub: self.hub,
1977 _parent: parent.to_string(),
1978 _page_token: Default::default(),
1979 _page_size: Default::default(),
1980 _delegate: Default::default(),
1981 _additional_params: Default::default(),
1982 _scopes: Default::default(),
1983 }
1984 }
1985
1986 /// Create a builder to help you perform the following task:
1987 ///
1988 /// Creates an Adaptive MT dataset.
1989 ///
1990 /// # Arguments
1991 ///
1992 /// * `request` - No description provided.
1993 /// * `parent` - Required. Name of the parent project. In form of `projects/{project-number-or-id}/locations/{location-id}`
1994 pub fn locations_adaptive_mt_datasets_create(
1995 &self,
1996 request: AdaptiveMtDataset,
1997 parent: &str,
1998 ) -> ProjectLocationAdaptiveMtDatasetCreateCall<'a, C> {
1999 ProjectLocationAdaptiveMtDatasetCreateCall {
2000 hub: self.hub,
2001 _request: request,
2002 _parent: parent.to_string(),
2003 _delegate: Default::default(),
2004 _additional_params: Default::default(),
2005 _scopes: Default::default(),
2006 }
2007 }
2008
2009 /// Create a builder to help you perform the following task:
2010 ///
2011 /// Deletes an Adaptive MT dataset, including all its entries and associated metadata.
2012 ///
2013 /// # Arguments
2014 ///
2015 /// * `name` - Required. Name of the dataset. In the form of `projects/{project-number-or-id}/locations/{location-id}/adaptiveMtDatasets/{adaptive-mt-dataset-id}`
2016 pub fn locations_adaptive_mt_datasets_delete(
2017 &self,
2018 name: &str,
2019 ) -> ProjectLocationAdaptiveMtDatasetDeleteCall<'a, C> {
2020 ProjectLocationAdaptiveMtDatasetDeleteCall {
2021 hub: self.hub,
2022 _name: name.to_string(),
2023 _delegate: Default::default(),
2024 _additional_params: Default::default(),
2025 _scopes: Default::default(),
2026 }
2027 }
2028
2029 /// Create a builder to help you perform the following task:
2030 ///
2031 /// Gets the Adaptive MT dataset.
2032 ///
2033 /// # Arguments
2034 ///
2035 /// * `name` - Required. Name of the dataset. In the form of `projects/{project-number-or-id}/locations/{location-id}/adaptiveMtDatasets/{adaptive-mt-dataset-id}`
2036 pub fn locations_adaptive_mt_datasets_get(
2037 &self,
2038 name: &str,
2039 ) -> ProjectLocationAdaptiveMtDatasetGetCall<'a, C> {
2040 ProjectLocationAdaptiveMtDatasetGetCall {
2041 hub: self.hub,
2042 _name: name.to_string(),
2043 _delegate: Default::default(),
2044 _additional_params: Default::default(),
2045 _scopes: Default::default(),
2046 }
2047 }
2048
2049 /// Create a builder to help you perform the following task:
2050 ///
2051 /// Imports an AdaptiveMtFile and adds all of its sentences into the AdaptiveMtDataset.
2052 ///
2053 /// # Arguments
2054 ///
2055 /// * `request` - No description provided.
2056 /// * `parent` - Required. The resource name of the file, in form of `projects/{project-number-or-id}/locations/{location_id}/adaptiveMtDatasets/{dataset}`
2057 pub fn locations_adaptive_mt_datasets_import_adaptive_mt_file(
2058 &self,
2059 request: ImportAdaptiveMtFileRequest,
2060 parent: &str,
2061 ) -> ProjectLocationAdaptiveMtDatasetImportAdaptiveMtFileCall<'a, C> {
2062 ProjectLocationAdaptiveMtDatasetImportAdaptiveMtFileCall {
2063 hub: self.hub,
2064 _request: request,
2065 _parent: parent.to_string(),
2066 _delegate: Default::default(),
2067 _additional_params: Default::default(),
2068 _scopes: Default::default(),
2069 }
2070 }
2071
2072 /// Create a builder to help you perform the following task:
2073 ///
2074 /// Lists all Adaptive MT datasets for which the caller has read permission.
2075 ///
2076 /// # Arguments
2077 ///
2078 /// * `parent` - Required. The resource name of the project from which to list the Adaptive MT datasets. `projects/{project-number-or-id}/locations/{location-id}`
2079 pub fn locations_adaptive_mt_datasets_list(
2080 &self,
2081 parent: &str,
2082 ) -> ProjectLocationAdaptiveMtDatasetListCall<'a, C> {
2083 ProjectLocationAdaptiveMtDatasetListCall {
2084 hub: self.hub,
2085 _parent: parent.to_string(),
2086 _page_token: Default::default(),
2087 _page_size: Default::default(),
2088 _filter: Default::default(),
2089 _delegate: Default::default(),
2090 _additional_params: Default::default(),
2091 _scopes: Default::default(),
2092 }
2093 }
2094
2095 /// Create a builder to help you perform the following task:
2096 ///
2097 /// Lists sentence pairs in the dataset.
2098 ///
2099 /// # Arguments
2100 ///
2101 /// * `parent` - Required. Name of the parent dataset. In form of `projects/{project-number-or-id}/locations/{location-id}/datasets/{dataset-id}`
2102 pub fn locations_datasets_examples_list(
2103 &self,
2104 parent: &str,
2105 ) -> ProjectLocationDatasetExampleListCall<'a, C> {
2106 ProjectLocationDatasetExampleListCall {
2107 hub: self.hub,
2108 _parent: parent.to_string(),
2109 _page_token: Default::default(),
2110 _page_size: Default::default(),
2111 _filter: Default::default(),
2112 _delegate: Default::default(),
2113 _additional_params: Default::default(),
2114 _scopes: Default::default(),
2115 }
2116 }
2117
2118 /// Create a builder to help you perform the following task:
2119 ///
2120 /// Creates a Dataset.
2121 ///
2122 /// # Arguments
2123 ///
2124 /// * `request` - No description provided.
2125 /// * `parent` - Required. The project name.
2126 pub fn locations_datasets_create(
2127 &self,
2128 request: Dataset,
2129 parent: &str,
2130 ) -> ProjectLocationDatasetCreateCall<'a, C> {
2131 ProjectLocationDatasetCreateCall {
2132 hub: self.hub,
2133 _request: request,
2134 _parent: parent.to_string(),
2135 _delegate: Default::default(),
2136 _additional_params: Default::default(),
2137 _scopes: Default::default(),
2138 }
2139 }
2140
2141 /// Create a builder to help you perform the following task:
2142 ///
2143 /// Deletes a dataset and all of its contents.
2144 ///
2145 /// # Arguments
2146 ///
2147 /// * `name` - Required. The name of the dataset to delete.
2148 pub fn locations_datasets_delete(&self, name: &str) -> ProjectLocationDatasetDeleteCall<'a, C> {
2149 ProjectLocationDatasetDeleteCall {
2150 hub: self.hub,
2151 _name: name.to_string(),
2152 _delegate: Default::default(),
2153 _additional_params: Default::default(),
2154 _scopes: Default::default(),
2155 }
2156 }
2157
2158 /// Create a builder to help you perform the following task:
2159 ///
2160 /// Exports dataset's data to the provided output location.
2161 ///
2162 /// # Arguments
2163 ///
2164 /// * `request` - No description provided.
2165 /// * `dataset` - Required. Name of the dataset. In form of `projects/{project-number-or-id}/locations/{location-id}/datasets/{dataset-id}`
2166 pub fn locations_datasets_export_data(
2167 &self,
2168 request: ExportDataRequest,
2169 dataset: &str,
2170 ) -> ProjectLocationDatasetExportDataCall<'a, C> {
2171 ProjectLocationDatasetExportDataCall {
2172 hub: self.hub,
2173 _request: request,
2174 _dataset: dataset.to_string(),
2175 _delegate: Default::default(),
2176 _additional_params: Default::default(),
2177 _scopes: Default::default(),
2178 }
2179 }
2180
2181 /// Create a builder to help you perform the following task:
2182 ///
2183 /// Gets a Dataset.
2184 ///
2185 /// # Arguments
2186 ///
2187 /// * `name` - Required. The resource name of the dataset to retrieve.
2188 pub fn locations_datasets_get(&self, name: &str) -> ProjectLocationDatasetGetCall<'a, C> {
2189 ProjectLocationDatasetGetCall {
2190 hub: self.hub,
2191 _name: name.to_string(),
2192 _delegate: Default::default(),
2193 _additional_params: Default::default(),
2194 _scopes: Default::default(),
2195 }
2196 }
2197
2198 /// Create a builder to help you perform the following task:
2199 ///
2200 /// Import sentence pairs into translation Dataset.
2201 ///
2202 /// # Arguments
2203 ///
2204 /// * `request` - No description provided.
2205 /// * `dataset` - Required. Name of the dataset. In form of `projects/{project-number-or-id}/locations/{location-id}/datasets/{dataset-id}`
2206 pub fn locations_datasets_import_data(
2207 &self,
2208 request: ImportDataRequest,
2209 dataset: &str,
2210 ) -> ProjectLocationDatasetImportDataCall<'a, C> {
2211 ProjectLocationDatasetImportDataCall {
2212 hub: self.hub,
2213 _request: request,
2214 _dataset: dataset.to_string(),
2215 _delegate: Default::default(),
2216 _additional_params: Default::default(),
2217 _scopes: Default::default(),
2218 }
2219 }
2220
2221 /// Create a builder to help you perform the following task:
2222 ///
2223 /// Lists datasets.
2224 ///
2225 /// # Arguments
2226 ///
2227 /// * `parent` - Required. Name of the parent project. In form of `projects/{project-number-or-id}/locations/{location-id}`
2228 pub fn locations_datasets_list(&self, parent: &str) -> ProjectLocationDatasetListCall<'a, C> {
2229 ProjectLocationDatasetListCall {
2230 hub: self.hub,
2231 _parent: parent.to_string(),
2232 _page_token: Default::default(),
2233 _page_size: Default::default(),
2234 _delegate: Default::default(),
2235 _additional_params: Default::default(),
2236 _scopes: Default::default(),
2237 }
2238 }
2239
2240 /// Create a builder to help you perform the following task:
2241 ///
2242 /// Creates a glossary entry.
2243 ///
2244 /// # Arguments
2245 ///
2246 /// * `request` - No description provided.
2247 /// * `parent` - Required. The resource name of the glossary to create the entry under.
2248 pub fn locations_glossaries_glossary_entries_create(
2249 &self,
2250 request: GlossaryEntry,
2251 parent: &str,
2252 ) -> ProjectLocationGlossaryGlossaryEntryCreateCall<'a, C> {
2253 ProjectLocationGlossaryGlossaryEntryCreateCall {
2254 hub: self.hub,
2255 _request: request,
2256 _parent: parent.to_string(),
2257 _delegate: Default::default(),
2258 _additional_params: Default::default(),
2259 _scopes: Default::default(),
2260 }
2261 }
2262
2263 /// Create a builder to help you perform the following task:
2264 ///
2265 /// Deletes a single entry from the glossary
2266 ///
2267 /// # Arguments
2268 ///
2269 /// * `name` - Required. The resource name of the glossary entry to delete
2270 pub fn locations_glossaries_glossary_entries_delete(
2271 &self,
2272 name: &str,
2273 ) -> ProjectLocationGlossaryGlossaryEntryDeleteCall<'a, C> {
2274 ProjectLocationGlossaryGlossaryEntryDeleteCall {
2275 hub: self.hub,
2276 _name: name.to_string(),
2277 _delegate: Default::default(),
2278 _additional_params: Default::default(),
2279 _scopes: Default::default(),
2280 }
2281 }
2282
2283 /// Create a builder to help you perform the following task:
2284 ///
2285 /// Gets a single glossary entry by the given id.
2286 ///
2287 /// # Arguments
2288 ///
2289 /// * `name` - Required. The resource name of the glossary entry to get
2290 pub fn locations_glossaries_glossary_entries_get(
2291 &self,
2292 name: &str,
2293 ) -> ProjectLocationGlossaryGlossaryEntryGetCall<'a, C> {
2294 ProjectLocationGlossaryGlossaryEntryGetCall {
2295 hub: self.hub,
2296 _name: name.to_string(),
2297 _delegate: Default::default(),
2298 _additional_params: Default::default(),
2299 _scopes: Default::default(),
2300 }
2301 }
2302
2303 /// Create a builder to help you perform the following task:
2304 ///
2305 /// List the entries for the glossary.
2306 ///
2307 /// # Arguments
2308 ///
2309 /// * `parent` - Required. The parent glossary resource name for listing the glossary's entries.
2310 pub fn locations_glossaries_glossary_entries_list(
2311 &self,
2312 parent: &str,
2313 ) -> ProjectLocationGlossaryGlossaryEntryListCall<'a, C> {
2314 ProjectLocationGlossaryGlossaryEntryListCall {
2315 hub: self.hub,
2316 _parent: parent.to_string(),
2317 _page_token: Default::default(),
2318 _page_size: Default::default(),
2319 _delegate: Default::default(),
2320 _additional_params: Default::default(),
2321 _scopes: Default::default(),
2322 }
2323 }
2324
2325 /// Create a builder to help you perform the following task:
2326 ///
2327 /// Updates a glossary entry.
2328 ///
2329 /// # Arguments
2330 ///
2331 /// * `request` - No description provided.
2332 /// * `name` - Identifier. The resource name of the entry. Format: `projects/*/locations/*/glossaries/*/glossaryEntries/*`
2333 pub fn locations_glossaries_glossary_entries_patch(
2334 &self,
2335 request: GlossaryEntry,
2336 name: &str,
2337 ) -> ProjectLocationGlossaryGlossaryEntryPatchCall<'a, C> {
2338 ProjectLocationGlossaryGlossaryEntryPatchCall {
2339 hub: self.hub,
2340 _request: request,
2341 _name: name.to_string(),
2342 _delegate: Default::default(),
2343 _additional_params: Default::default(),
2344 _scopes: Default::default(),
2345 }
2346 }
2347
2348 /// Create a builder to help you perform the following task:
2349 ///
2350 /// Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project doesn't exist.
2351 ///
2352 /// # Arguments
2353 ///
2354 /// * `request` - No description provided.
2355 /// * `parent` - Required. The project name.
2356 pub fn locations_glossaries_create(
2357 &self,
2358 request: Glossary,
2359 parent: &str,
2360 ) -> ProjectLocationGlossaryCreateCall<'a, C> {
2361 ProjectLocationGlossaryCreateCall {
2362 hub: self.hub,
2363 _request: request,
2364 _parent: parent.to_string(),
2365 _delegate: Default::default(),
2366 _additional_params: Default::default(),
2367 _scopes: Default::default(),
2368 }
2369 }
2370
2371 /// Create a builder to help you perform the following task:
2372 ///
2373 /// Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns NOT_FOUND, if the glossary doesn't exist.
2374 ///
2375 /// # Arguments
2376 ///
2377 /// * `name` - Required. The name of the glossary to delete.
2378 pub fn locations_glossaries_delete(
2379 &self,
2380 name: &str,
2381 ) -> ProjectLocationGlossaryDeleteCall<'a, C> {
2382 ProjectLocationGlossaryDeleteCall {
2383 hub: self.hub,
2384 _name: name.to_string(),
2385 _delegate: Default::default(),
2386 _additional_params: Default::default(),
2387 _scopes: Default::default(),
2388 }
2389 }
2390
2391 /// Create a builder to help you perform the following task:
2392 ///
2393 /// Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist.
2394 ///
2395 /// # Arguments
2396 ///
2397 /// * `name` - Required. The name of the glossary to retrieve.
2398 pub fn locations_glossaries_get(&self, name: &str) -> ProjectLocationGlossaryGetCall<'a, C> {
2399 ProjectLocationGlossaryGetCall {
2400 hub: self.hub,
2401 _name: name.to_string(),
2402 _delegate: Default::default(),
2403 _additional_params: Default::default(),
2404 _scopes: Default::default(),
2405 }
2406 }
2407
2408 /// Create a builder to help you perform the following task:
2409 ///
2410 /// Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist.
2411 ///
2412 /// # Arguments
2413 ///
2414 /// * `parent` - Required. The name of the project from which to list all of the glossaries.
2415 pub fn locations_glossaries_list(
2416 &self,
2417 parent: &str,
2418 ) -> ProjectLocationGlossaryListCall<'a, C> {
2419 ProjectLocationGlossaryListCall {
2420 hub: self.hub,
2421 _parent: parent.to_string(),
2422 _page_token: Default::default(),
2423 _page_size: Default::default(),
2424 _filter: Default::default(),
2425 _delegate: Default::default(),
2426 _additional_params: Default::default(),
2427 _scopes: Default::default(),
2428 }
2429 }
2430
2431 /// Create a builder to help you perform the following task:
2432 ///
2433 /// Updates a glossary. A LRO is used since the update can be async if the glossary's entry file is updated.
2434 ///
2435 /// # Arguments
2436 ///
2437 /// * `request` - No description provided.
2438 /// * `name` - Required. The resource name of the glossary. Glossary names have the form `projects/{project-number-or-id}/locations/{location-id}/glossaries/{glossary-id}`.
2439 pub fn locations_glossaries_patch(
2440 &self,
2441 request: Glossary,
2442 name: &str,
2443 ) -> ProjectLocationGlossaryPatchCall<'a, C> {
2444 ProjectLocationGlossaryPatchCall {
2445 hub: self.hub,
2446 _request: request,
2447 _name: name.to_string(),
2448 _update_mask: Default::default(),
2449 _delegate: Default::default(),
2450 _additional_params: Default::default(),
2451 _scopes: Default::default(),
2452 }
2453 }
2454
2455 /// Create a builder to help you perform the following task:
2456 ///
2457 /// Creates a Model.
2458 ///
2459 /// # Arguments
2460 ///
2461 /// * `request` - No description provided.
2462 /// * `parent` - Required. The project name, in form of `projects/{project}/locations/{location}`
2463 pub fn locations_models_create(
2464 &self,
2465 request: Model,
2466 parent: &str,
2467 ) -> ProjectLocationModelCreateCall<'a, C> {
2468 ProjectLocationModelCreateCall {
2469 hub: self.hub,
2470 _request: request,
2471 _parent: parent.to_string(),
2472 _delegate: Default::default(),
2473 _additional_params: Default::default(),
2474 _scopes: Default::default(),
2475 }
2476 }
2477
2478 /// Create a builder to help you perform the following task:
2479 ///
2480 /// Deletes a model.
2481 ///
2482 /// # Arguments
2483 ///
2484 /// * `name` - Required. The name of the model to delete.
2485 pub fn locations_models_delete(&self, name: &str) -> ProjectLocationModelDeleteCall<'a, C> {
2486 ProjectLocationModelDeleteCall {
2487 hub: self.hub,
2488 _name: name.to_string(),
2489 _delegate: Default::default(),
2490 _additional_params: Default::default(),
2491 _scopes: Default::default(),
2492 }
2493 }
2494
2495 /// Create a builder to help you perform the following task:
2496 ///
2497 /// Gets a model.
2498 ///
2499 /// # Arguments
2500 ///
2501 /// * `name` - Required. The resource name of the model to retrieve.
2502 pub fn locations_models_get(&self, name: &str) -> ProjectLocationModelGetCall<'a, C> {
2503 ProjectLocationModelGetCall {
2504 hub: self.hub,
2505 _name: name.to_string(),
2506 _delegate: Default::default(),
2507 _additional_params: Default::default(),
2508 _scopes: Default::default(),
2509 }
2510 }
2511
2512 /// Create a builder to help you perform the following task:
2513 ///
2514 /// Lists models.
2515 ///
2516 /// # Arguments
2517 ///
2518 /// * `parent` - Required. Name of the parent project. In form of `projects/{project-number-or-id}/locations/{location-id}`
2519 pub fn locations_models_list(&self, parent: &str) -> ProjectLocationModelListCall<'a, C> {
2520 ProjectLocationModelListCall {
2521 hub: self.hub,
2522 _parent: parent.to_string(),
2523 _page_token: Default::default(),
2524 _page_size: Default::default(),
2525 _filter: Default::default(),
2526 _delegate: Default::default(),
2527 _additional_params: Default::default(),
2528 _scopes: Default::default(),
2529 }
2530 }
2531
2532 /// Create a builder to help you perform the following task:
2533 ///
2534 /// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of `1`, corresponding to `Code.CANCELLED`.
2535 ///
2536 /// # Arguments
2537 ///
2538 /// * `request` - No description provided.
2539 /// * `name` - The name of the operation resource to be cancelled.
2540 pub fn locations_operations_cancel(
2541 &self,
2542 request: CancelOperationRequest,
2543 name: &str,
2544 ) -> ProjectLocationOperationCancelCall<'a, C> {
2545 ProjectLocationOperationCancelCall {
2546 hub: self.hub,
2547 _request: request,
2548 _name: name.to_string(),
2549 _delegate: Default::default(),
2550 _additional_params: Default::default(),
2551 _scopes: Default::default(),
2552 }
2553 }
2554
2555 /// Create a builder to help you perform the following task:
2556 ///
2557 /// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`.
2558 ///
2559 /// # Arguments
2560 ///
2561 /// * `name` - The name of the operation resource to be deleted.
2562 pub fn locations_operations_delete(
2563 &self,
2564 name: &str,
2565 ) -> ProjectLocationOperationDeleteCall<'a, C> {
2566 ProjectLocationOperationDeleteCall {
2567 hub: self.hub,
2568 _name: name.to_string(),
2569 _delegate: Default::default(),
2570 _additional_params: Default::default(),
2571 _scopes: Default::default(),
2572 }
2573 }
2574
2575 /// Create a builder to help you perform the following task:
2576 ///
2577 /// 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.
2578 ///
2579 /// # Arguments
2580 ///
2581 /// * `name` - The name of the operation resource.
2582 pub fn locations_operations_get(&self, name: &str) -> ProjectLocationOperationGetCall<'a, C> {
2583 ProjectLocationOperationGetCall {
2584 hub: self.hub,
2585 _name: name.to_string(),
2586 _delegate: Default::default(),
2587 _additional_params: Default::default(),
2588 _scopes: Default::default(),
2589 }
2590 }
2591
2592 /// Create a builder to help you perform the following task:
2593 ///
2594 /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
2595 ///
2596 /// # Arguments
2597 ///
2598 /// * `name` - The name of the operation's parent resource.
2599 pub fn locations_operations_list(&self, name: &str) -> ProjectLocationOperationListCall<'a, C> {
2600 ProjectLocationOperationListCall {
2601 hub: self.hub,
2602 _name: name.to_string(),
2603 _page_token: Default::default(),
2604 _page_size: Default::default(),
2605 _filter: Default::default(),
2606 _delegate: Default::default(),
2607 _additional_params: Default::default(),
2608 _scopes: Default::default(),
2609 }
2610 }
2611
2612 /// Create a builder to help you perform the following task:
2613 ///
2614 /// Waits until the specified long-running operation is done or reaches at most a specified timeout, returning the latest state. If the operation is already done, the latest state is immediately returned. If the timeout specified is greater than the default HTTP/RPC timeout, the HTTP/RPC timeout is used. If the server does not support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Note that this method is on a best-effort basis. It may return the latest state before the specified timeout (including immediately), meaning even an immediate response is no guarantee that the operation is done.
2615 ///
2616 /// # Arguments
2617 ///
2618 /// * `request` - No description provided.
2619 /// * `name` - The name of the operation resource to wait on.
2620 pub fn locations_operations_wait(
2621 &self,
2622 request: WaitOperationRequest,
2623 name: &str,
2624 ) -> ProjectLocationOperationWaitCall<'a, C> {
2625 ProjectLocationOperationWaitCall {
2626 hub: self.hub,
2627 _request: request,
2628 _name: name.to_string(),
2629 _delegate: Default::default(),
2630 _additional_params: Default::default(),
2631 _scopes: Default::default(),
2632 }
2633 }
2634
2635 /// Create a builder to help you perform the following task:
2636 ///
2637 /// Translate text using Adaptive MT.
2638 ///
2639 /// # Arguments
2640 ///
2641 /// * `request` - No description provided.
2642 /// * `parent` - Required. Location to make a regional call. Format: `projects/{project-number-or-id}/locations/{location-id}`.
2643 pub fn locations_adaptive_mt_translate(
2644 &self,
2645 request: AdaptiveMtTranslateRequest,
2646 parent: &str,
2647 ) -> ProjectLocationAdaptiveMtTranslateCall<'a, C> {
2648 ProjectLocationAdaptiveMtTranslateCall {
2649 hub: self.hub,
2650 _request: request,
2651 _parent: parent.to_string(),
2652 _delegate: Default::default(),
2653 _additional_params: Default::default(),
2654 _scopes: Default::default(),
2655 }
2656 }
2657
2658 /// Create a builder to help you perform the following task:
2659 ///
2660 /// Translates a large volume of document in asynchronous batch mode. This function provides real-time output as the inputs are being processed. If caller cancels a request, the partial results (for an input file, it's all or nothing) may still be available on the specified output location. This call returns immediately and you can use google.longrunning.Operation.name to poll the status of the call.
2661 ///
2662 /// # Arguments
2663 ///
2664 /// * `request` - No description provided.
2665 /// * `parent` - Required. Location to make a regional call. Format: `projects/{project-number-or-id}/locations/{location-id}`. The `global` location is not supported for batch translation. Only AutoML Translation models or glossaries within the same region (have the same location-id) can be used, otherwise an INVALID_ARGUMENT (400) error is returned.
2666 pub fn locations_batch_translate_document(
2667 &self,
2668 request: BatchTranslateDocumentRequest,
2669 parent: &str,
2670 ) -> ProjectLocationBatchTranslateDocumentCall<'a, C> {
2671 ProjectLocationBatchTranslateDocumentCall {
2672 hub: self.hub,
2673 _request: request,
2674 _parent: parent.to_string(),
2675 _delegate: Default::default(),
2676 _additional_params: Default::default(),
2677 _scopes: Default::default(),
2678 }
2679 }
2680
2681 /// Create a builder to help you perform the following task:
2682 ///
2683 /// Translates a large volume of text in asynchronous batch mode. This function provides real-time output as the inputs are being processed. If caller cancels a request, the partial results (for an input file, it's all or nothing) may still be available on the specified output location. This call returns immediately and you can use google.longrunning.Operation.name to poll the status of the call.
2684 ///
2685 /// # Arguments
2686 ///
2687 /// * `request` - No description provided.
2688 /// * `parent` - Required. Location to make a call. Must refer to a caller's project. Format: `projects/{project-number-or-id}/locations/{location-id}`. The `global` location is not supported for batch translation. Only AutoML Translation models or glossaries within the same region (have the same location-id) can be used, otherwise an INVALID_ARGUMENT (400) error is returned.
2689 pub fn locations_batch_translate_text(
2690 &self,
2691 request: BatchTranslateTextRequest,
2692 parent: &str,
2693 ) -> ProjectLocationBatchTranslateTextCall<'a, C> {
2694 ProjectLocationBatchTranslateTextCall {
2695 hub: self.hub,
2696 _request: request,
2697 _parent: parent.to_string(),
2698 _delegate: Default::default(),
2699 _additional_params: Default::default(),
2700 _scopes: Default::default(),
2701 }
2702 }
2703
2704 /// Create a builder to help you perform the following task:
2705 ///
2706 /// Detects the language of text within a request.
2707 ///
2708 /// # Arguments
2709 ///
2710 /// * `request` - No description provided.
2711 /// * `parent` - Required. Project or location to make a call. Must refer to a caller's project. Format: `projects/{project-number-or-id}/locations/{location-id}` or `projects/{project-number-or-id}`. For global calls, use `projects/{project-number-or-id}/locations/global` or `projects/{project-number-or-id}`. Only models within the same region (has same location-id) can be used. Otherwise an INVALID_ARGUMENT (400) error is returned.
2712 pub fn locations_detect_language(
2713 &self,
2714 request: DetectLanguageRequest,
2715 parent: &str,
2716 ) -> ProjectLocationDetectLanguageCall<'a, C> {
2717 ProjectLocationDetectLanguageCall {
2718 hub: self.hub,
2719 _request: request,
2720 _parent: parent.to_string(),
2721 _delegate: Default::default(),
2722 _additional_params: Default::default(),
2723 _scopes: Default::default(),
2724 }
2725 }
2726
2727 /// Create a builder to help you perform the following task:
2728 ///
2729 /// Gets information about a location.
2730 ///
2731 /// # Arguments
2732 ///
2733 /// * `name` - Resource name for the location.
2734 pub fn locations_get(&self, name: &str) -> ProjectLocationGetCall<'a, C> {
2735 ProjectLocationGetCall {
2736 hub: self.hub,
2737 _name: name.to_string(),
2738 _delegate: Default::default(),
2739 _additional_params: Default::default(),
2740 _scopes: Default::default(),
2741 }
2742 }
2743
2744 /// Create a builder to help you perform the following task:
2745 ///
2746 /// Returns a list of supported languages for translation.
2747 ///
2748 /// # Arguments
2749 ///
2750 /// * `parent` - Required. Project or location to make a call. Must refer to a caller's project. Format: `projects/{project-number-or-id}` or `projects/{project-number-or-id}/locations/{location-id}`. For global calls, use `projects/{project-number-or-id}/locations/global` or `projects/{project-number-or-id}`. Non-global location is required for AutoML models. Only models within the same region (have same location-id) can be used, otherwise an INVALID_ARGUMENT (400) error is returned.
2751 pub fn locations_get_supported_languages(
2752 &self,
2753 parent: &str,
2754 ) -> ProjectLocationGetSupportedLanguageCall<'a, C> {
2755 ProjectLocationGetSupportedLanguageCall {
2756 hub: self.hub,
2757 _parent: parent.to_string(),
2758 _model: Default::default(),
2759 _display_language_code: Default::default(),
2760 _delegate: Default::default(),
2761 _additional_params: Default::default(),
2762 _scopes: Default::default(),
2763 }
2764 }
2765
2766 /// Create a builder to help you perform the following task:
2767 ///
2768 /// Lists information about the supported locations for this service.
2769 ///
2770 /// # Arguments
2771 ///
2772 /// * `name` - The resource that owns the locations collection, if applicable.
2773 pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C> {
2774 ProjectLocationListCall {
2775 hub: self.hub,
2776 _name: name.to_string(),
2777 _page_token: Default::default(),
2778 _page_size: Default::default(),
2779 _filter: Default::default(),
2780 _extra_location_types: Default::default(),
2781 _delegate: Default::default(),
2782 _additional_params: Default::default(),
2783 _scopes: Default::default(),
2784 }
2785 }
2786
2787 /// Create a builder to help you perform the following task:
2788 ///
2789 /// Romanize input text written in non-Latin scripts to Latin text.
2790 ///
2791 /// # Arguments
2792 ///
2793 /// * `request` - No description provided.
2794 /// * `parent` - Required. Project or location to make a call. Must refer to a caller's project. Format: `projects/{project-number-or-id}/locations/{location-id}` or `projects/{project-number-or-id}`. For global calls, use `projects/{project-number-or-id}/locations/global` or `projects/{project-number-or-id}`.
2795 pub fn locations_romanize_text(
2796 &self,
2797 request: RomanizeTextRequest,
2798 parent: &str,
2799 ) -> ProjectLocationRomanizeTextCall<'a, C> {
2800 ProjectLocationRomanizeTextCall {
2801 hub: self.hub,
2802 _request: request,
2803 _parent: parent.to_string(),
2804 _delegate: Default::default(),
2805 _additional_params: Default::default(),
2806 _scopes: Default::default(),
2807 }
2808 }
2809
2810 /// Create a builder to help you perform the following task:
2811 ///
2812 /// Translates documents in synchronous mode.
2813 ///
2814 /// # Arguments
2815 ///
2816 /// * `request` - No description provided.
2817 /// * `parent` - Required. Location to make a regional call. Format: `projects/{project-number-or-id}/locations/{location-id}`. For global calls, use `projects/{project-number-or-id}/locations/global` or `projects/{project-number-or-id}`. Non-global location is required for requests using AutoML models or custom glossaries. Models and glossaries must be within the same region (have the same location-id), otherwise an INVALID_ARGUMENT (400) error is returned.
2818 pub fn locations_translate_document(
2819 &self,
2820 request: TranslateDocumentRequest,
2821 parent: &str,
2822 ) -> ProjectLocationTranslateDocumentCall<'a, C> {
2823 ProjectLocationTranslateDocumentCall {
2824 hub: self.hub,
2825 _request: request,
2826 _parent: parent.to_string(),
2827 _delegate: Default::default(),
2828 _additional_params: Default::default(),
2829 _scopes: Default::default(),
2830 }
2831 }
2832
2833 /// Create a builder to help you perform the following task:
2834 ///
2835 /// Translates input text and returns translated text.
2836 ///
2837 /// # Arguments
2838 ///
2839 /// * `request` - No description provided.
2840 /// * `parent` - Required. Project or location to make a call. Must refer to a caller's project. Format: `projects/{project-number-or-id}` or `projects/{project-number-or-id}/locations/{location-id}`. For global calls, use `projects/{project-number-or-id}/locations/global` or `projects/{project-number-or-id}`. Non-global location is required for requests using AutoML models or custom glossaries. Models and glossaries must be within the same region (have same location-id), otherwise an INVALID_ARGUMENT (400) error is returned.
2841 pub fn locations_translate_text(
2842 &self,
2843 request: TranslateTextRequest,
2844 parent: &str,
2845 ) -> ProjectLocationTranslateTextCall<'a, C> {
2846 ProjectLocationTranslateTextCall {
2847 hub: self.hub,
2848 _request: request,
2849 _parent: parent.to_string(),
2850 _delegate: Default::default(),
2851 _additional_params: Default::default(),
2852 _scopes: Default::default(),
2853 }
2854 }
2855
2856 /// Create a builder to help you perform the following task:
2857 ///
2858 /// Detects the language of text within a request.
2859 ///
2860 /// # Arguments
2861 ///
2862 /// * `request` - No description provided.
2863 /// * `parent` - Required. Project or location to make a call. Must refer to a caller's project. Format: `projects/{project-number-or-id}/locations/{location-id}` or `projects/{project-number-or-id}`. For global calls, use `projects/{project-number-or-id}/locations/global` or `projects/{project-number-or-id}`. Only models within the same region (has same location-id) can be used. Otherwise an INVALID_ARGUMENT (400) error is returned.
2864 pub fn detect_language(
2865 &self,
2866 request: DetectLanguageRequest,
2867 parent: &str,
2868 ) -> ProjectDetectLanguageCall<'a, C> {
2869 ProjectDetectLanguageCall {
2870 hub: self.hub,
2871 _request: request,
2872 _parent: parent.to_string(),
2873 _delegate: Default::default(),
2874 _additional_params: Default::default(),
2875 _scopes: Default::default(),
2876 }
2877 }
2878
2879 /// Create a builder to help you perform the following task:
2880 ///
2881 /// Returns a list of supported languages for translation.
2882 ///
2883 /// # Arguments
2884 ///
2885 /// * `parent` - Required. Project or location to make a call. Must refer to a caller's project. Format: `projects/{project-number-or-id}` or `projects/{project-number-or-id}/locations/{location-id}`. For global calls, use `projects/{project-number-or-id}/locations/global` or `projects/{project-number-or-id}`. Non-global location is required for AutoML models. Only models within the same region (have same location-id) can be used, otherwise an INVALID_ARGUMENT (400) error is returned.
2886 pub fn get_supported_languages(&self, parent: &str) -> ProjectGetSupportedLanguageCall<'a, C> {
2887 ProjectGetSupportedLanguageCall {
2888 hub: self.hub,
2889 _parent: parent.to_string(),
2890 _model: Default::default(),
2891 _display_language_code: Default::default(),
2892 _delegate: Default::default(),
2893 _additional_params: Default::default(),
2894 _scopes: Default::default(),
2895 }
2896 }
2897
2898 /// Create a builder to help you perform the following task:
2899 ///
2900 /// Romanize input text written in non-Latin scripts to Latin text.
2901 ///
2902 /// # Arguments
2903 ///
2904 /// * `request` - No description provided.
2905 /// * `parent` - Required. Project or location to make a call. Must refer to a caller's project. Format: `projects/{project-number-or-id}/locations/{location-id}` or `projects/{project-number-or-id}`. For global calls, use `projects/{project-number-or-id}/locations/global` or `projects/{project-number-or-id}`.
2906 pub fn romanize_text(
2907 &self,
2908 request: RomanizeTextRequest,
2909 parent: &str,
2910 ) -> ProjectRomanizeTextCall<'a, C> {
2911 ProjectRomanizeTextCall {
2912 hub: self.hub,
2913 _request: request,
2914 _parent: parent.to_string(),
2915 _delegate: Default::default(),
2916 _additional_params: Default::default(),
2917 _scopes: Default::default(),
2918 }
2919 }
2920
2921 /// Create a builder to help you perform the following task:
2922 ///
2923 /// Translates input text and returns translated text.
2924 ///
2925 /// # Arguments
2926 ///
2927 /// * `request` - No description provided.
2928 /// * `parent` - Required. Project or location to make a call. Must refer to a caller's project. Format: `projects/{project-number-or-id}` or `projects/{project-number-or-id}/locations/{location-id}`. For global calls, use `projects/{project-number-or-id}/locations/global` or `projects/{project-number-or-id}`. Non-global location is required for requests using AutoML models or custom glossaries. Models and glossaries must be within the same region (have same location-id), otherwise an INVALID_ARGUMENT (400) error is returned.
2929 pub fn translate_text(
2930 &self,
2931 request: TranslateTextRequest,
2932 parent: &str,
2933 ) -> ProjectTranslateTextCall<'a, C> {
2934 ProjectTranslateTextCall {
2935 hub: self.hub,
2936 _request: request,
2937 _parent: parent.to_string(),
2938 _delegate: Default::default(),
2939 _additional_params: Default::default(),
2940 _scopes: Default::default(),
2941 }
2942 }
2943}
2944
2945// ###################
2946// CallBuilders ###
2947// #################
2948
2949/// Lists all AdaptiveMtSentences under a given file/dataset.
2950///
2951/// A builder for the *locations.adaptiveMtDatasets.adaptiveMtFiles.adaptiveMtSentences.list* method supported by a *project* resource.
2952/// It is not used directly, but through a [`ProjectMethods`] instance.
2953///
2954/// # Example
2955///
2956/// Instantiate a resource method builder
2957///
2958/// ```test_harness,no_run
2959/// # extern crate hyper;
2960/// # extern crate hyper_rustls;
2961/// # extern crate google_translate3 as translate3;
2962/// # async fn dox() {
2963/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2964///
2965/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2966/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2967/// # .with_native_roots()
2968/// # .unwrap()
2969/// # .https_only()
2970/// # .enable_http2()
2971/// # .build();
2972///
2973/// # let executor = hyper_util::rt::TokioExecutor::new();
2974/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2975/// # secret,
2976/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2977/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2978/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2979/// # ),
2980/// # ).build().await.unwrap();
2981///
2982/// # let client = hyper_util::client::legacy::Client::builder(
2983/// # hyper_util::rt::TokioExecutor::new()
2984/// # )
2985/// # .build(
2986/// # hyper_rustls::HttpsConnectorBuilder::new()
2987/// # .with_native_roots()
2988/// # .unwrap()
2989/// # .https_or_http()
2990/// # .enable_http2()
2991/// # .build()
2992/// # );
2993/// # let mut hub = Translate::new(client, auth);
2994/// // You can configure optional parameters by calling the respective setters at will, and
2995/// // execute the final call using `doit()`.
2996/// // Values shown here are possibly random and not representative !
2997/// let result = hub.projects().locations_adaptive_mt_datasets_adaptive_mt_files_adaptive_mt_sentences_list("parent")
2998/// .page_token("voluptua.")
2999/// .page_size(-27)
3000/// .doit().await;
3001/// # }
3002/// ```
3003pub struct ProjectLocationAdaptiveMtDatasetAdaptiveMtFileAdaptiveMtSentenceListCall<'a, C>
3004where
3005 C: 'a,
3006{
3007 hub: &'a Translate<C>,
3008 _parent: String,
3009 _page_token: Option<String>,
3010 _page_size: Option<i32>,
3011 _delegate: Option<&'a mut dyn common::Delegate>,
3012 _additional_params: HashMap<String, String>,
3013 _scopes: BTreeSet<String>,
3014}
3015
3016impl<'a, C> common::CallBuilder
3017 for ProjectLocationAdaptiveMtDatasetAdaptiveMtFileAdaptiveMtSentenceListCall<'a, C>
3018{
3019}
3020
3021impl<'a, C> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileAdaptiveMtSentenceListCall<'a, C>
3022where
3023 C: common::Connector,
3024{
3025 /// Perform the operation you have build so far.
3026 pub async fn doit(
3027 mut self,
3028 ) -> common::Result<(common::Response, ListAdaptiveMtSentencesResponse)> {
3029 use std::borrow::Cow;
3030 use std::io::{Read, Seek};
3031
3032 use common::{url::Params, ToParts};
3033 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3034
3035 let mut dd = common::DefaultDelegate;
3036 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3037 dlg.begin(common::MethodInfo { id: "translate.projects.locations.adaptiveMtDatasets.adaptiveMtFiles.adaptiveMtSentences.list",
3038 http_method: hyper::Method::GET });
3039
3040 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
3041 if self._additional_params.contains_key(field) {
3042 dlg.finished(false);
3043 return Err(common::Error::FieldClash(field));
3044 }
3045 }
3046
3047 let mut params = Params::with_capacity(5 + self._additional_params.len());
3048 params.push("parent", self._parent);
3049 if let Some(value) = self._page_token.as_ref() {
3050 params.push("pageToken", value);
3051 }
3052 if let Some(value) = self._page_size.as_ref() {
3053 params.push("pageSize", value.to_string());
3054 }
3055
3056 params.extend(self._additional_params.iter());
3057
3058 params.push("alt", "json");
3059 let mut url = self.hub._base_url.clone() + "v3/{+parent}/adaptiveMtSentences";
3060 if self._scopes.is_empty() {
3061 self._scopes
3062 .insert(Scope::CloudPlatform.as_ref().to_string());
3063 }
3064
3065 #[allow(clippy::single_element_loop)]
3066 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3067 url = params.uri_replacement(url, param_name, find_this, true);
3068 }
3069 {
3070 let to_remove = ["parent"];
3071 params.remove_params(&to_remove);
3072 }
3073
3074 let url = params.parse_with_url(&url);
3075
3076 loop {
3077 let token = match self
3078 .hub
3079 .auth
3080 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3081 .await
3082 {
3083 Ok(token) => token,
3084 Err(e) => match dlg.token(e) {
3085 Ok(token) => token,
3086 Err(e) => {
3087 dlg.finished(false);
3088 return Err(common::Error::MissingToken(e));
3089 }
3090 },
3091 };
3092 let mut req_result = {
3093 let client = &self.hub.client;
3094 dlg.pre_request();
3095 let mut req_builder = hyper::Request::builder()
3096 .method(hyper::Method::GET)
3097 .uri(url.as_str())
3098 .header(USER_AGENT, self.hub._user_agent.clone());
3099
3100 if let Some(token) = token.as_ref() {
3101 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3102 }
3103
3104 let request = req_builder
3105 .header(CONTENT_LENGTH, 0_u64)
3106 .body(common::to_body::<String>(None));
3107
3108 client.request(request.unwrap()).await
3109 };
3110
3111 match req_result {
3112 Err(err) => {
3113 if let common::Retry::After(d) = dlg.http_error(&err) {
3114 sleep(d).await;
3115 continue;
3116 }
3117 dlg.finished(false);
3118 return Err(common::Error::HttpError(err));
3119 }
3120 Ok(res) => {
3121 let (mut parts, body) = res.into_parts();
3122 let mut body = common::Body::new(body);
3123 if !parts.status.is_success() {
3124 let bytes = common::to_bytes(body).await.unwrap_or_default();
3125 let error = serde_json::from_str(&common::to_string(&bytes));
3126 let response = common::to_response(parts, bytes.into());
3127
3128 if let common::Retry::After(d) =
3129 dlg.http_failure(&response, error.as_ref().ok())
3130 {
3131 sleep(d).await;
3132 continue;
3133 }
3134
3135 dlg.finished(false);
3136
3137 return Err(match error {
3138 Ok(value) => common::Error::BadRequest(value),
3139 _ => common::Error::Failure(response),
3140 });
3141 }
3142 let response = {
3143 let bytes = common::to_bytes(body).await.unwrap_or_default();
3144 let encoded = common::to_string(&bytes);
3145 match serde_json::from_str(&encoded) {
3146 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3147 Err(error) => {
3148 dlg.response_json_decode_error(&encoded, &error);
3149 return Err(common::Error::JsonDecodeError(
3150 encoded.to_string(),
3151 error,
3152 ));
3153 }
3154 }
3155 };
3156
3157 dlg.finished(true);
3158 return Ok(response);
3159 }
3160 }
3161 }
3162 }
3163
3164 /// Required. The resource name of the project from which to list the Adaptive MT files. The following format lists all sentences under a file. `projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file}` The following format lists all sentences within a dataset. `projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}`
3165 ///
3166 /// Sets the *parent* path property to the given value.
3167 ///
3168 /// Even though the property as already been set when instantiating this call,
3169 /// we provide this method for API completeness.
3170 pub fn parent(
3171 mut self,
3172 new_value: &str,
3173 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileAdaptiveMtSentenceListCall<'a, C> {
3174 self._parent = new_value.to_string();
3175 self
3176 }
3177 /// A token identifying a page of results the server should return. Typically, this is the value of ListAdaptiveMtSentencesRequest.next_page_token returned from the previous call to `ListTranslationMemories` method. The first page is returned if `page_token` is empty or missing.
3178 ///
3179 /// Sets the *page token* query property to the given value.
3180 pub fn page_token(
3181 mut self,
3182 new_value: &str,
3183 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileAdaptiveMtSentenceListCall<'a, C> {
3184 self._page_token = Some(new_value.to_string());
3185 self
3186 }
3187 ///
3188 /// Sets the *page size* query property to the given value.
3189 pub fn page_size(
3190 mut self,
3191 new_value: i32,
3192 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileAdaptiveMtSentenceListCall<'a, C> {
3193 self._page_size = Some(new_value);
3194 self
3195 }
3196 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3197 /// while executing the actual API request.
3198 ///
3199 /// ````text
3200 /// It should be used to handle progress information, and to implement a certain level of resilience.
3201 /// ````
3202 ///
3203 /// Sets the *delegate* property to the given value.
3204 pub fn delegate(
3205 mut self,
3206 new_value: &'a mut dyn common::Delegate,
3207 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileAdaptiveMtSentenceListCall<'a, C> {
3208 self._delegate = Some(new_value);
3209 self
3210 }
3211
3212 /// Set any additional parameter of the query string used in the request.
3213 /// It should be used to set parameters which are not yet available through their own
3214 /// setters.
3215 ///
3216 /// Please note that this method must not be used to set any of the known parameters
3217 /// which have their own setter method. If done anyway, the request will fail.
3218 ///
3219 /// # Additional Parameters
3220 ///
3221 /// * *$.xgafv* (query-string) - V1 error format.
3222 /// * *access_token* (query-string) - OAuth access token.
3223 /// * *alt* (query-string) - Data format for response.
3224 /// * *callback* (query-string) - JSONP
3225 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3226 /// * *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.
3227 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3228 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3229 /// * *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.
3230 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3231 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3232 pub fn param<T>(
3233 mut self,
3234 name: T,
3235 value: T,
3236 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileAdaptiveMtSentenceListCall<'a, C>
3237 where
3238 T: AsRef<str>,
3239 {
3240 self._additional_params
3241 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3242 self
3243 }
3244
3245 /// Identifies the authorization scope for the method you are building.
3246 ///
3247 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3248 /// [`Scope::CloudPlatform`].
3249 ///
3250 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3251 /// tokens for more than one scope.
3252 ///
3253 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3254 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3255 /// sufficient, a read-write scope will do as well.
3256 pub fn add_scope<St>(
3257 mut self,
3258 scope: St,
3259 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileAdaptiveMtSentenceListCall<'a, C>
3260 where
3261 St: AsRef<str>,
3262 {
3263 self._scopes.insert(String::from(scope.as_ref()));
3264 self
3265 }
3266 /// Identifies the authorization scope(s) for the method you are building.
3267 ///
3268 /// See [`Self::add_scope()`] for details.
3269 pub fn add_scopes<I, St>(
3270 mut self,
3271 scopes: I,
3272 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileAdaptiveMtSentenceListCall<'a, C>
3273 where
3274 I: IntoIterator<Item = St>,
3275 St: AsRef<str>,
3276 {
3277 self._scopes
3278 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3279 self
3280 }
3281
3282 /// Removes all scopes, and no default scope will be used either.
3283 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3284 /// for details).
3285 pub fn clear_scopes(
3286 mut self,
3287 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileAdaptiveMtSentenceListCall<'a, C> {
3288 self._scopes.clear();
3289 self
3290 }
3291}
3292
3293/// Deletes an AdaptiveMtFile along with its sentences.
3294///
3295/// A builder for the *locations.adaptiveMtDatasets.adaptiveMtFiles.delete* method supported by a *project* resource.
3296/// It is not used directly, but through a [`ProjectMethods`] instance.
3297///
3298/// # Example
3299///
3300/// Instantiate a resource method builder
3301///
3302/// ```test_harness,no_run
3303/// # extern crate hyper;
3304/// # extern crate hyper_rustls;
3305/// # extern crate google_translate3 as translate3;
3306/// # async fn dox() {
3307/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3308///
3309/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3310/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3311/// # .with_native_roots()
3312/// # .unwrap()
3313/// # .https_only()
3314/// # .enable_http2()
3315/// # .build();
3316///
3317/// # let executor = hyper_util::rt::TokioExecutor::new();
3318/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3319/// # secret,
3320/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3321/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3322/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3323/// # ),
3324/// # ).build().await.unwrap();
3325///
3326/// # let client = hyper_util::client::legacy::Client::builder(
3327/// # hyper_util::rt::TokioExecutor::new()
3328/// # )
3329/// # .build(
3330/// # hyper_rustls::HttpsConnectorBuilder::new()
3331/// # .with_native_roots()
3332/// # .unwrap()
3333/// # .https_or_http()
3334/// # .enable_http2()
3335/// # .build()
3336/// # );
3337/// # let mut hub = Translate::new(client, auth);
3338/// // You can configure optional parameters by calling the respective setters at will, and
3339/// // execute the final call using `doit()`.
3340/// // Values shown here are possibly random and not representative !
3341/// let result = hub.projects().locations_adaptive_mt_datasets_adaptive_mt_files_delete("name")
3342/// .doit().await;
3343/// # }
3344/// ```
3345pub struct ProjectLocationAdaptiveMtDatasetAdaptiveMtFileDeleteCall<'a, C>
3346where
3347 C: 'a,
3348{
3349 hub: &'a Translate<C>,
3350 _name: String,
3351 _delegate: Option<&'a mut dyn common::Delegate>,
3352 _additional_params: HashMap<String, String>,
3353 _scopes: BTreeSet<String>,
3354}
3355
3356impl<'a, C> common::CallBuilder
3357 for ProjectLocationAdaptiveMtDatasetAdaptiveMtFileDeleteCall<'a, C>
3358{
3359}
3360
3361impl<'a, C> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileDeleteCall<'a, C>
3362where
3363 C: common::Connector,
3364{
3365 /// Perform the operation you have build so far.
3366 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
3367 use std::borrow::Cow;
3368 use std::io::{Read, Seek};
3369
3370 use common::{url::Params, ToParts};
3371 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3372
3373 let mut dd = common::DefaultDelegate;
3374 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3375 dlg.begin(common::MethodInfo {
3376 id: "translate.projects.locations.adaptiveMtDatasets.adaptiveMtFiles.delete",
3377 http_method: hyper::Method::DELETE,
3378 });
3379
3380 for &field in ["alt", "name"].iter() {
3381 if self._additional_params.contains_key(field) {
3382 dlg.finished(false);
3383 return Err(common::Error::FieldClash(field));
3384 }
3385 }
3386
3387 let mut params = Params::with_capacity(3 + self._additional_params.len());
3388 params.push("name", self._name);
3389
3390 params.extend(self._additional_params.iter());
3391
3392 params.push("alt", "json");
3393 let mut url = self.hub._base_url.clone() + "v3/{+name}";
3394 if self._scopes.is_empty() {
3395 self._scopes
3396 .insert(Scope::CloudPlatform.as_ref().to_string());
3397 }
3398
3399 #[allow(clippy::single_element_loop)]
3400 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3401 url = params.uri_replacement(url, param_name, find_this, true);
3402 }
3403 {
3404 let to_remove = ["name"];
3405 params.remove_params(&to_remove);
3406 }
3407
3408 let url = params.parse_with_url(&url);
3409
3410 loop {
3411 let token = match self
3412 .hub
3413 .auth
3414 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3415 .await
3416 {
3417 Ok(token) => token,
3418 Err(e) => match dlg.token(e) {
3419 Ok(token) => token,
3420 Err(e) => {
3421 dlg.finished(false);
3422 return Err(common::Error::MissingToken(e));
3423 }
3424 },
3425 };
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::DELETE)
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_LENGTH, 0_u64)
3440 .body(common::to_body::<String>(None));
3441
3442 client.request(request.unwrap()).await
3443 };
3444
3445 match req_result {
3446 Err(err) => {
3447 if let common::Retry::After(d) = dlg.http_error(&err) {
3448 sleep(d).await;
3449 continue;
3450 }
3451 dlg.finished(false);
3452 return Err(common::Error::HttpError(err));
3453 }
3454 Ok(res) => {
3455 let (mut parts, body) = res.into_parts();
3456 let mut body = common::Body::new(body);
3457 if !parts.status.is_success() {
3458 let bytes = common::to_bytes(body).await.unwrap_or_default();
3459 let error = serde_json::from_str(&common::to_string(&bytes));
3460 let response = common::to_response(parts, bytes.into());
3461
3462 if let common::Retry::After(d) =
3463 dlg.http_failure(&response, error.as_ref().ok())
3464 {
3465 sleep(d).await;
3466 continue;
3467 }
3468
3469 dlg.finished(false);
3470
3471 return Err(match error {
3472 Ok(value) => common::Error::BadRequest(value),
3473 _ => common::Error::Failure(response),
3474 });
3475 }
3476 let response = {
3477 let bytes = common::to_bytes(body).await.unwrap_or_default();
3478 let encoded = common::to_string(&bytes);
3479 match serde_json::from_str(&encoded) {
3480 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3481 Err(error) => {
3482 dlg.response_json_decode_error(&encoded, &error);
3483 return Err(common::Error::JsonDecodeError(
3484 encoded.to_string(),
3485 error,
3486 ));
3487 }
3488 }
3489 };
3490
3491 dlg.finished(true);
3492 return Ok(response);
3493 }
3494 }
3495 }
3496 }
3497
3498 /// Required. The resource name of the file to delete, in form of `projects/{project-number-or-id}/locations/{location_id}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file}`
3499 ///
3500 /// Sets the *name* path property to the given value.
3501 ///
3502 /// Even though the property as already been set when instantiating this call,
3503 /// we provide this method for API completeness.
3504 pub fn name(
3505 mut self,
3506 new_value: &str,
3507 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileDeleteCall<'a, C> {
3508 self._name = new_value.to_string();
3509 self
3510 }
3511 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3512 /// while executing the actual API request.
3513 ///
3514 /// ````text
3515 /// It should be used to handle progress information, and to implement a certain level of resilience.
3516 /// ````
3517 ///
3518 /// Sets the *delegate* property to the given value.
3519 pub fn delegate(
3520 mut self,
3521 new_value: &'a mut dyn common::Delegate,
3522 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileDeleteCall<'a, C> {
3523 self._delegate = Some(new_value);
3524 self
3525 }
3526
3527 /// Set any additional parameter of the query string used in the request.
3528 /// It should be used to set parameters which are not yet available through their own
3529 /// setters.
3530 ///
3531 /// Please note that this method must not be used to set any of the known parameters
3532 /// which have their own setter method. If done anyway, the request will fail.
3533 ///
3534 /// # Additional Parameters
3535 ///
3536 /// * *$.xgafv* (query-string) - V1 error format.
3537 /// * *access_token* (query-string) - OAuth access token.
3538 /// * *alt* (query-string) - Data format for response.
3539 /// * *callback* (query-string) - JSONP
3540 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3541 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3542 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3543 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3544 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3545 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3546 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3547 pub fn param<T>(
3548 mut self,
3549 name: T,
3550 value: T,
3551 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileDeleteCall<'a, C>
3552 where
3553 T: AsRef<str>,
3554 {
3555 self._additional_params
3556 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3557 self
3558 }
3559
3560 /// Identifies the authorization scope for the method you are building.
3561 ///
3562 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3563 /// [`Scope::CloudPlatform`].
3564 ///
3565 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3566 /// tokens for more than one scope.
3567 ///
3568 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3569 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3570 /// sufficient, a read-write scope will do as well.
3571 pub fn add_scope<St>(
3572 mut self,
3573 scope: St,
3574 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileDeleteCall<'a, C>
3575 where
3576 St: AsRef<str>,
3577 {
3578 self._scopes.insert(String::from(scope.as_ref()));
3579 self
3580 }
3581 /// Identifies the authorization scope(s) for the method you are building.
3582 ///
3583 /// See [`Self::add_scope()`] for details.
3584 pub fn add_scopes<I, St>(
3585 mut self,
3586 scopes: I,
3587 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileDeleteCall<'a, C>
3588 where
3589 I: IntoIterator<Item = St>,
3590 St: AsRef<str>,
3591 {
3592 self._scopes
3593 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3594 self
3595 }
3596
3597 /// Removes all scopes, and no default scope will be used either.
3598 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3599 /// for details).
3600 pub fn clear_scopes(
3601 mut self,
3602 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileDeleteCall<'a, C> {
3603 self._scopes.clear();
3604 self
3605 }
3606}
3607
3608/// Gets and AdaptiveMtFile
3609///
3610/// A builder for the *locations.adaptiveMtDatasets.adaptiveMtFiles.get* method supported by a *project* resource.
3611/// It is not used directly, but through a [`ProjectMethods`] instance.
3612///
3613/// # Example
3614///
3615/// Instantiate a resource method builder
3616///
3617/// ```test_harness,no_run
3618/// # extern crate hyper;
3619/// # extern crate hyper_rustls;
3620/// # extern crate google_translate3 as translate3;
3621/// # async fn dox() {
3622/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3623///
3624/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3625/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3626/// # .with_native_roots()
3627/// # .unwrap()
3628/// # .https_only()
3629/// # .enable_http2()
3630/// # .build();
3631///
3632/// # let executor = hyper_util::rt::TokioExecutor::new();
3633/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3634/// # secret,
3635/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3636/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3637/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3638/// # ),
3639/// # ).build().await.unwrap();
3640///
3641/// # let client = hyper_util::client::legacy::Client::builder(
3642/// # hyper_util::rt::TokioExecutor::new()
3643/// # )
3644/// # .build(
3645/// # hyper_rustls::HttpsConnectorBuilder::new()
3646/// # .with_native_roots()
3647/// # .unwrap()
3648/// # .https_or_http()
3649/// # .enable_http2()
3650/// # .build()
3651/// # );
3652/// # let mut hub = Translate::new(client, auth);
3653/// // You can configure optional parameters by calling the respective setters at will, and
3654/// // execute the final call using `doit()`.
3655/// // Values shown here are possibly random and not representative !
3656/// let result = hub.projects().locations_adaptive_mt_datasets_adaptive_mt_files_get("name")
3657/// .doit().await;
3658/// # }
3659/// ```
3660pub struct ProjectLocationAdaptiveMtDatasetAdaptiveMtFileGetCall<'a, C>
3661where
3662 C: 'a,
3663{
3664 hub: &'a Translate<C>,
3665 _name: String,
3666 _delegate: Option<&'a mut dyn common::Delegate>,
3667 _additional_params: HashMap<String, String>,
3668 _scopes: BTreeSet<String>,
3669}
3670
3671impl<'a, C> common::CallBuilder for ProjectLocationAdaptiveMtDatasetAdaptiveMtFileGetCall<'a, C> {}
3672
3673impl<'a, C> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileGetCall<'a, C>
3674where
3675 C: common::Connector,
3676{
3677 /// Perform the operation you have build so far.
3678 pub async fn doit(mut self) -> common::Result<(common::Response, AdaptiveMtFile)> {
3679 use std::borrow::Cow;
3680 use std::io::{Read, Seek};
3681
3682 use common::{url::Params, ToParts};
3683 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3684
3685 let mut dd = common::DefaultDelegate;
3686 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3687 dlg.begin(common::MethodInfo {
3688 id: "translate.projects.locations.adaptiveMtDatasets.adaptiveMtFiles.get",
3689 http_method: hyper::Method::GET,
3690 });
3691
3692 for &field in ["alt", "name"].iter() {
3693 if self._additional_params.contains_key(field) {
3694 dlg.finished(false);
3695 return Err(common::Error::FieldClash(field));
3696 }
3697 }
3698
3699 let mut params = Params::with_capacity(3 + self._additional_params.len());
3700 params.push("name", self._name);
3701
3702 params.extend(self._additional_params.iter());
3703
3704 params.push("alt", "json");
3705 let mut url = self.hub._base_url.clone() + "v3/{+name}";
3706 if self._scopes.is_empty() {
3707 self._scopes
3708 .insert(Scope::CloudPlatform.as_ref().to_string());
3709 }
3710
3711 #[allow(clippy::single_element_loop)]
3712 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3713 url = params.uri_replacement(url, param_name, find_this, true);
3714 }
3715 {
3716 let to_remove = ["name"];
3717 params.remove_params(&to_remove);
3718 }
3719
3720 let url = params.parse_with_url(&url);
3721
3722 loop {
3723 let token = match self
3724 .hub
3725 .auth
3726 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3727 .await
3728 {
3729 Ok(token) => token,
3730 Err(e) => match dlg.token(e) {
3731 Ok(token) => token,
3732 Err(e) => {
3733 dlg.finished(false);
3734 return Err(common::Error::MissingToken(e));
3735 }
3736 },
3737 };
3738 let mut req_result = {
3739 let client = &self.hub.client;
3740 dlg.pre_request();
3741 let mut req_builder = hyper::Request::builder()
3742 .method(hyper::Method::GET)
3743 .uri(url.as_str())
3744 .header(USER_AGENT, self.hub._user_agent.clone());
3745
3746 if let Some(token) = token.as_ref() {
3747 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3748 }
3749
3750 let request = req_builder
3751 .header(CONTENT_LENGTH, 0_u64)
3752 .body(common::to_body::<String>(None));
3753
3754 client.request(request.unwrap()).await
3755 };
3756
3757 match req_result {
3758 Err(err) => {
3759 if let common::Retry::After(d) = dlg.http_error(&err) {
3760 sleep(d).await;
3761 continue;
3762 }
3763 dlg.finished(false);
3764 return Err(common::Error::HttpError(err));
3765 }
3766 Ok(res) => {
3767 let (mut parts, body) = res.into_parts();
3768 let mut body = common::Body::new(body);
3769 if !parts.status.is_success() {
3770 let bytes = common::to_bytes(body).await.unwrap_or_default();
3771 let error = serde_json::from_str(&common::to_string(&bytes));
3772 let response = common::to_response(parts, bytes.into());
3773
3774 if let common::Retry::After(d) =
3775 dlg.http_failure(&response, error.as_ref().ok())
3776 {
3777 sleep(d).await;
3778 continue;
3779 }
3780
3781 dlg.finished(false);
3782
3783 return Err(match error {
3784 Ok(value) => common::Error::BadRequest(value),
3785 _ => common::Error::Failure(response),
3786 });
3787 }
3788 let response = {
3789 let bytes = common::to_bytes(body).await.unwrap_or_default();
3790 let encoded = common::to_string(&bytes);
3791 match serde_json::from_str(&encoded) {
3792 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3793 Err(error) => {
3794 dlg.response_json_decode_error(&encoded, &error);
3795 return Err(common::Error::JsonDecodeError(
3796 encoded.to_string(),
3797 error,
3798 ));
3799 }
3800 }
3801 };
3802
3803 dlg.finished(true);
3804 return Ok(response);
3805 }
3806 }
3807 }
3808 }
3809
3810 /// Required. The resource name of the file, in form of `projects/{project-number-or-id}/locations/{location_id}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file}`
3811 ///
3812 /// Sets the *name* path property to the given value.
3813 ///
3814 /// Even though the property as already been set when instantiating this call,
3815 /// we provide this method for API completeness.
3816 pub fn name(
3817 mut self,
3818 new_value: &str,
3819 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileGetCall<'a, C> {
3820 self._name = new_value.to_string();
3821 self
3822 }
3823 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3824 /// while executing the actual API request.
3825 ///
3826 /// ````text
3827 /// It should be used to handle progress information, and to implement a certain level of resilience.
3828 /// ````
3829 ///
3830 /// Sets the *delegate* property to the given value.
3831 pub fn delegate(
3832 mut self,
3833 new_value: &'a mut dyn common::Delegate,
3834 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileGetCall<'a, C> {
3835 self._delegate = Some(new_value);
3836 self
3837 }
3838
3839 /// Set any additional parameter of the query string used in the request.
3840 /// It should be used to set parameters which are not yet available through their own
3841 /// setters.
3842 ///
3843 /// Please note that this method must not be used to set any of the known parameters
3844 /// which have their own setter method. If done anyway, the request will fail.
3845 ///
3846 /// # Additional Parameters
3847 ///
3848 /// * *$.xgafv* (query-string) - V1 error format.
3849 /// * *access_token* (query-string) - OAuth access token.
3850 /// * *alt* (query-string) - Data format for response.
3851 /// * *callback* (query-string) - JSONP
3852 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3853 /// * *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.
3854 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3855 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3856 /// * *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.
3857 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3858 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3859 pub fn param<T>(
3860 mut self,
3861 name: T,
3862 value: T,
3863 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileGetCall<'a, C>
3864 where
3865 T: AsRef<str>,
3866 {
3867 self._additional_params
3868 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3869 self
3870 }
3871
3872 /// Identifies the authorization scope for the method you are building.
3873 ///
3874 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3875 /// [`Scope::CloudPlatform`].
3876 ///
3877 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3878 /// tokens for more than one scope.
3879 ///
3880 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3881 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3882 /// sufficient, a read-write scope will do as well.
3883 pub fn add_scope<St>(
3884 mut self,
3885 scope: St,
3886 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileGetCall<'a, C>
3887 where
3888 St: AsRef<str>,
3889 {
3890 self._scopes.insert(String::from(scope.as_ref()));
3891 self
3892 }
3893 /// Identifies the authorization scope(s) for the method you are building.
3894 ///
3895 /// See [`Self::add_scope()`] for details.
3896 pub fn add_scopes<I, St>(
3897 mut self,
3898 scopes: I,
3899 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileGetCall<'a, C>
3900 where
3901 I: IntoIterator<Item = St>,
3902 St: AsRef<str>,
3903 {
3904 self._scopes
3905 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3906 self
3907 }
3908
3909 /// Removes all scopes, and no default scope will be used either.
3910 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3911 /// for details).
3912 pub fn clear_scopes(mut self) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileGetCall<'a, C> {
3913 self._scopes.clear();
3914 self
3915 }
3916}
3917
3918/// Lists all AdaptiveMtFiles associated to an AdaptiveMtDataset.
3919///
3920/// A builder for the *locations.adaptiveMtDatasets.adaptiveMtFiles.list* method supported by a *project* resource.
3921/// It is not used directly, but through a [`ProjectMethods`] instance.
3922///
3923/// # Example
3924///
3925/// Instantiate a resource method builder
3926///
3927/// ```test_harness,no_run
3928/// # extern crate hyper;
3929/// # extern crate hyper_rustls;
3930/// # extern crate google_translate3 as translate3;
3931/// # async fn dox() {
3932/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3933///
3934/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3935/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3936/// # .with_native_roots()
3937/// # .unwrap()
3938/// # .https_only()
3939/// # .enable_http2()
3940/// # .build();
3941///
3942/// # let executor = hyper_util::rt::TokioExecutor::new();
3943/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3944/// # secret,
3945/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3946/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3947/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3948/// # ),
3949/// # ).build().await.unwrap();
3950///
3951/// # let client = hyper_util::client::legacy::Client::builder(
3952/// # hyper_util::rt::TokioExecutor::new()
3953/// # )
3954/// # .build(
3955/// # hyper_rustls::HttpsConnectorBuilder::new()
3956/// # .with_native_roots()
3957/// # .unwrap()
3958/// # .https_or_http()
3959/// # .enable_http2()
3960/// # .build()
3961/// # );
3962/// # let mut hub = Translate::new(client, auth);
3963/// // You can configure optional parameters by calling the respective setters at will, and
3964/// // execute the final call using `doit()`.
3965/// // Values shown here are possibly random and not representative !
3966/// let result = hub.projects().locations_adaptive_mt_datasets_adaptive_mt_files_list("parent")
3967/// .page_token("takimata")
3968/// .page_size(-52)
3969/// .doit().await;
3970/// # }
3971/// ```
3972pub struct ProjectLocationAdaptiveMtDatasetAdaptiveMtFileListCall<'a, C>
3973where
3974 C: 'a,
3975{
3976 hub: &'a Translate<C>,
3977 _parent: String,
3978 _page_token: Option<String>,
3979 _page_size: Option<i32>,
3980 _delegate: Option<&'a mut dyn common::Delegate>,
3981 _additional_params: HashMap<String, String>,
3982 _scopes: BTreeSet<String>,
3983}
3984
3985impl<'a, C> common::CallBuilder for ProjectLocationAdaptiveMtDatasetAdaptiveMtFileListCall<'a, C> {}
3986
3987impl<'a, C> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileListCall<'a, C>
3988where
3989 C: common::Connector,
3990{
3991 /// Perform the operation you have build so far.
3992 pub async fn doit(mut self) -> common::Result<(common::Response, ListAdaptiveMtFilesResponse)> {
3993 use std::borrow::Cow;
3994 use std::io::{Read, Seek};
3995
3996 use common::{url::Params, ToParts};
3997 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3998
3999 let mut dd = common::DefaultDelegate;
4000 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4001 dlg.begin(common::MethodInfo {
4002 id: "translate.projects.locations.adaptiveMtDatasets.adaptiveMtFiles.list",
4003 http_method: hyper::Method::GET,
4004 });
4005
4006 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
4007 if self._additional_params.contains_key(field) {
4008 dlg.finished(false);
4009 return Err(common::Error::FieldClash(field));
4010 }
4011 }
4012
4013 let mut params = Params::with_capacity(5 + self._additional_params.len());
4014 params.push("parent", self._parent);
4015 if let Some(value) = self._page_token.as_ref() {
4016 params.push("pageToken", value);
4017 }
4018 if let Some(value) = self._page_size.as_ref() {
4019 params.push("pageSize", value.to_string());
4020 }
4021
4022 params.extend(self._additional_params.iter());
4023
4024 params.push("alt", "json");
4025 let mut url = self.hub._base_url.clone() + "v3/{+parent}/adaptiveMtFiles";
4026 if self._scopes.is_empty() {
4027 self._scopes
4028 .insert(Scope::CloudPlatform.as_ref().to_string());
4029 }
4030
4031 #[allow(clippy::single_element_loop)]
4032 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4033 url = params.uri_replacement(url, param_name, find_this, true);
4034 }
4035 {
4036 let to_remove = ["parent"];
4037 params.remove_params(&to_remove);
4038 }
4039
4040 let url = params.parse_with_url(&url);
4041
4042 loop {
4043 let token = match self
4044 .hub
4045 .auth
4046 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4047 .await
4048 {
4049 Ok(token) => token,
4050 Err(e) => match dlg.token(e) {
4051 Ok(token) => token,
4052 Err(e) => {
4053 dlg.finished(false);
4054 return Err(common::Error::MissingToken(e));
4055 }
4056 },
4057 };
4058 let mut req_result = {
4059 let client = &self.hub.client;
4060 dlg.pre_request();
4061 let mut req_builder = hyper::Request::builder()
4062 .method(hyper::Method::GET)
4063 .uri(url.as_str())
4064 .header(USER_AGENT, self.hub._user_agent.clone());
4065
4066 if let Some(token) = token.as_ref() {
4067 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4068 }
4069
4070 let request = req_builder
4071 .header(CONTENT_LENGTH, 0_u64)
4072 .body(common::to_body::<String>(None));
4073
4074 client.request(request.unwrap()).await
4075 };
4076
4077 match req_result {
4078 Err(err) => {
4079 if let common::Retry::After(d) = dlg.http_error(&err) {
4080 sleep(d).await;
4081 continue;
4082 }
4083 dlg.finished(false);
4084 return Err(common::Error::HttpError(err));
4085 }
4086 Ok(res) => {
4087 let (mut parts, body) = res.into_parts();
4088 let mut body = common::Body::new(body);
4089 if !parts.status.is_success() {
4090 let bytes = common::to_bytes(body).await.unwrap_or_default();
4091 let error = serde_json::from_str(&common::to_string(&bytes));
4092 let response = common::to_response(parts, bytes.into());
4093
4094 if let common::Retry::After(d) =
4095 dlg.http_failure(&response, error.as_ref().ok())
4096 {
4097 sleep(d).await;
4098 continue;
4099 }
4100
4101 dlg.finished(false);
4102
4103 return Err(match error {
4104 Ok(value) => common::Error::BadRequest(value),
4105 _ => common::Error::Failure(response),
4106 });
4107 }
4108 let response = {
4109 let bytes = common::to_bytes(body).await.unwrap_or_default();
4110 let encoded = common::to_string(&bytes);
4111 match serde_json::from_str(&encoded) {
4112 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4113 Err(error) => {
4114 dlg.response_json_decode_error(&encoded, &error);
4115 return Err(common::Error::JsonDecodeError(
4116 encoded.to_string(),
4117 error,
4118 ));
4119 }
4120 }
4121 };
4122
4123 dlg.finished(true);
4124 return Ok(response);
4125 }
4126 }
4127 }
4128 }
4129
4130 /// Required. The resource name of the project from which to list the Adaptive MT files. `projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}`
4131 ///
4132 /// Sets the *parent* path property to the given value.
4133 ///
4134 /// Even though the property as already been set when instantiating this call,
4135 /// we provide this method for API completeness.
4136 pub fn parent(
4137 mut self,
4138 new_value: &str,
4139 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileListCall<'a, C> {
4140 self._parent = new_value.to_string();
4141 self
4142 }
4143 /// Optional. A token identifying a page of results the server should return. Typically, this is the value of ListAdaptiveMtFilesResponse.next_page_token returned from the previous call to `ListAdaptiveMtFiles` method. The first page is returned if `page_token`is empty or missing.
4144 ///
4145 /// Sets the *page token* query property to the given value.
4146 pub fn page_token(
4147 mut self,
4148 new_value: &str,
4149 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileListCall<'a, C> {
4150 self._page_token = Some(new_value.to_string());
4151 self
4152 }
4153 /// Optional.
4154 ///
4155 /// Sets the *page size* query property to the given value.
4156 pub fn page_size(
4157 mut self,
4158 new_value: i32,
4159 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileListCall<'a, C> {
4160 self._page_size = Some(new_value);
4161 self
4162 }
4163 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4164 /// while executing the actual API request.
4165 ///
4166 /// ````text
4167 /// It should be used to handle progress information, and to implement a certain level of resilience.
4168 /// ````
4169 ///
4170 /// Sets the *delegate* property to the given value.
4171 pub fn delegate(
4172 mut self,
4173 new_value: &'a mut dyn common::Delegate,
4174 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileListCall<'a, C> {
4175 self._delegate = Some(new_value);
4176 self
4177 }
4178
4179 /// Set any additional parameter of the query string used in the request.
4180 /// It should be used to set parameters which are not yet available through their own
4181 /// setters.
4182 ///
4183 /// Please note that this method must not be used to set any of the known parameters
4184 /// which have their own setter method. If done anyway, the request will fail.
4185 ///
4186 /// # Additional Parameters
4187 ///
4188 /// * *$.xgafv* (query-string) - V1 error format.
4189 /// * *access_token* (query-string) - OAuth access token.
4190 /// * *alt* (query-string) - Data format for response.
4191 /// * *callback* (query-string) - JSONP
4192 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4193 /// * *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.
4194 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4195 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4196 /// * *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.
4197 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4198 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4199 pub fn param<T>(
4200 mut self,
4201 name: T,
4202 value: T,
4203 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileListCall<'a, C>
4204 where
4205 T: AsRef<str>,
4206 {
4207 self._additional_params
4208 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4209 self
4210 }
4211
4212 /// Identifies the authorization scope for the method you are building.
4213 ///
4214 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4215 /// [`Scope::CloudPlatform`].
4216 ///
4217 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4218 /// tokens for more than one scope.
4219 ///
4220 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4221 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4222 /// sufficient, a read-write scope will do as well.
4223 pub fn add_scope<St>(
4224 mut self,
4225 scope: St,
4226 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileListCall<'a, C>
4227 where
4228 St: AsRef<str>,
4229 {
4230 self._scopes.insert(String::from(scope.as_ref()));
4231 self
4232 }
4233 /// Identifies the authorization scope(s) for the method you are building.
4234 ///
4235 /// See [`Self::add_scope()`] for details.
4236 pub fn add_scopes<I, St>(
4237 mut self,
4238 scopes: I,
4239 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileListCall<'a, C>
4240 where
4241 I: IntoIterator<Item = St>,
4242 St: AsRef<str>,
4243 {
4244 self._scopes
4245 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4246 self
4247 }
4248
4249 /// Removes all scopes, and no default scope will be used either.
4250 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4251 /// for details).
4252 pub fn clear_scopes(mut self) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtFileListCall<'a, C> {
4253 self._scopes.clear();
4254 self
4255 }
4256}
4257
4258/// Lists all AdaptiveMtSentences under a given file/dataset.
4259///
4260/// A builder for the *locations.adaptiveMtDatasets.adaptiveMtSentences.list* method supported by a *project* resource.
4261/// It is not used directly, but through a [`ProjectMethods`] instance.
4262///
4263/// # Example
4264///
4265/// Instantiate a resource method builder
4266///
4267/// ```test_harness,no_run
4268/// # extern crate hyper;
4269/// # extern crate hyper_rustls;
4270/// # extern crate google_translate3 as translate3;
4271/// # async fn dox() {
4272/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4273///
4274/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4275/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4276/// # .with_native_roots()
4277/// # .unwrap()
4278/// # .https_only()
4279/// # .enable_http2()
4280/// # .build();
4281///
4282/// # let executor = hyper_util::rt::TokioExecutor::new();
4283/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4284/// # secret,
4285/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4286/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4287/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4288/// # ),
4289/// # ).build().await.unwrap();
4290///
4291/// # let client = hyper_util::client::legacy::Client::builder(
4292/// # hyper_util::rt::TokioExecutor::new()
4293/// # )
4294/// # .build(
4295/// # hyper_rustls::HttpsConnectorBuilder::new()
4296/// # .with_native_roots()
4297/// # .unwrap()
4298/// # .https_or_http()
4299/// # .enable_http2()
4300/// # .build()
4301/// # );
4302/// # let mut hub = Translate::new(client, auth);
4303/// // You can configure optional parameters by calling the respective setters at will, and
4304/// // execute the final call using `doit()`.
4305/// // Values shown here are possibly random and not representative !
4306/// let result = hub.projects().locations_adaptive_mt_datasets_adaptive_mt_sentences_list("parent")
4307/// .page_token("ipsum")
4308/// .page_size(-62)
4309/// .doit().await;
4310/// # }
4311/// ```
4312pub struct ProjectLocationAdaptiveMtDatasetAdaptiveMtSentenceListCall<'a, C>
4313where
4314 C: 'a,
4315{
4316 hub: &'a Translate<C>,
4317 _parent: String,
4318 _page_token: Option<String>,
4319 _page_size: Option<i32>,
4320 _delegate: Option<&'a mut dyn common::Delegate>,
4321 _additional_params: HashMap<String, String>,
4322 _scopes: BTreeSet<String>,
4323}
4324
4325impl<'a, C> common::CallBuilder
4326 for ProjectLocationAdaptiveMtDatasetAdaptiveMtSentenceListCall<'a, C>
4327{
4328}
4329
4330impl<'a, C> ProjectLocationAdaptiveMtDatasetAdaptiveMtSentenceListCall<'a, C>
4331where
4332 C: common::Connector,
4333{
4334 /// Perform the operation you have build so far.
4335 pub async fn doit(
4336 mut self,
4337 ) -> common::Result<(common::Response, ListAdaptiveMtSentencesResponse)> {
4338 use std::borrow::Cow;
4339 use std::io::{Read, Seek};
4340
4341 use common::{url::Params, ToParts};
4342 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4343
4344 let mut dd = common::DefaultDelegate;
4345 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4346 dlg.begin(common::MethodInfo {
4347 id: "translate.projects.locations.adaptiveMtDatasets.adaptiveMtSentences.list",
4348 http_method: hyper::Method::GET,
4349 });
4350
4351 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
4352 if self._additional_params.contains_key(field) {
4353 dlg.finished(false);
4354 return Err(common::Error::FieldClash(field));
4355 }
4356 }
4357
4358 let mut params = Params::with_capacity(5 + self._additional_params.len());
4359 params.push("parent", self._parent);
4360 if let Some(value) = self._page_token.as_ref() {
4361 params.push("pageToken", value);
4362 }
4363 if let Some(value) = self._page_size.as_ref() {
4364 params.push("pageSize", value.to_string());
4365 }
4366
4367 params.extend(self._additional_params.iter());
4368
4369 params.push("alt", "json");
4370 let mut url = self.hub._base_url.clone() + "v3/{+parent}/adaptiveMtSentences";
4371 if self._scopes.is_empty() {
4372 self._scopes
4373 .insert(Scope::CloudPlatform.as_ref().to_string());
4374 }
4375
4376 #[allow(clippy::single_element_loop)]
4377 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4378 url = params.uri_replacement(url, param_name, find_this, true);
4379 }
4380 {
4381 let to_remove = ["parent"];
4382 params.remove_params(&to_remove);
4383 }
4384
4385 let url = params.parse_with_url(&url);
4386
4387 loop {
4388 let token = match self
4389 .hub
4390 .auth
4391 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4392 .await
4393 {
4394 Ok(token) => token,
4395 Err(e) => match dlg.token(e) {
4396 Ok(token) => token,
4397 Err(e) => {
4398 dlg.finished(false);
4399 return Err(common::Error::MissingToken(e));
4400 }
4401 },
4402 };
4403 let mut req_result = {
4404 let client = &self.hub.client;
4405 dlg.pre_request();
4406 let mut req_builder = hyper::Request::builder()
4407 .method(hyper::Method::GET)
4408 .uri(url.as_str())
4409 .header(USER_AGENT, self.hub._user_agent.clone());
4410
4411 if let Some(token) = token.as_ref() {
4412 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4413 }
4414
4415 let request = req_builder
4416 .header(CONTENT_LENGTH, 0_u64)
4417 .body(common::to_body::<String>(None));
4418
4419 client.request(request.unwrap()).await
4420 };
4421
4422 match req_result {
4423 Err(err) => {
4424 if let common::Retry::After(d) = dlg.http_error(&err) {
4425 sleep(d).await;
4426 continue;
4427 }
4428 dlg.finished(false);
4429 return Err(common::Error::HttpError(err));
4430 }
4431 Ok(res) => {
4432 let (mut parts, body) = res.into_parts();
4433 let mut body = common::Body::new(body);
4434 if !parts.status.is_success() {
4435 let bytes = common::to_bytes(body).await.unwrap_or_default();
4436 let error = serde_json::from_str(&common::to_string(&bytes));
4437 let response = common::to_response(parts, bytes.into());
4438
4439 if let common::Retry::After(d) =
4440 dlg.http_failure(&response, error.as_ref().ok())
4441 {
4442 sleep(d).await;
4443 continue;
4444 }
4445
4446 dlg.finished(false);
4447
4448 return Err(match error {
4449 Ok(value) => common::Error::BadRequest(value),
4450 _ => common::Error::Failure(response),
4451 });
4452 }
4453 let response = {
4454 let bytes = common::to_bytes(body).await.unwrap_or_default();
4455 let encoded = common::to_string(&bytes);
4456 match serde_json::from_str(&encoded) {
4457 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4458 Err(error) => {
4459 dlg.response_json_decode_error(&encoded, &error);
4460 return Err(common::Error::JsonDecodeError(
4461 encoded.to_string(),
4462 error,
4463 ));
4464 }
4465 }
4466 };
4467
4468 dlg.finished(true);
4469 return Ok(response);
4470 }
4471 }
4472 }
4473 }
4474
4475 /// Required. The resource name of the project from which to list the Adaptive MT files. The following format lists all sentences under a file. `projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file}` The following format lists all sentences within a dataset. `projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}`
4476 ///
4477 /// Sets the *parent* path property to the given value.
4478 ///
4479 /// Even though the property as already been set when instantiating this call,
4480 /// we provide this method for API completeness.
4481 pub fn parent(
4482 mut self,
4483 new_value: &str,
4484 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtSentenceListCall<'a, C> {
4485 self._parent = new_value.to_string();
4486 self
4487 }
4488 /// A token identifying a page of results the server should return. Typically, this is the value of ListAdaptiveMtSentencesRequest.next_page_token returned from the previous call to `ListTranslationMemories` method. The first page is returned if `page_token` is empty or missing.
4489 ///
4490 /// Sets the *page token* query property to the given value.
4491 pub fn page_token(
4492 mut self,
4493 new_value: &str,
4494 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtSentenceListCall<'a, C> {
4495 self._page_token = Some(new_value.to_string());
4496 self
4497 }
4498 ///
4499 /// Sets the *page size* query property to the given value.
4500 pub fn page_size(
4501 mut self,
4502 new_value: i32,
4503 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtSentenceListCall<'a, C> {
4504 self._page_size = Some(new_value);
4505 self
4506 }
4507 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4508 /// while executing the actual API request.
4509 ///
4510 /// ````text
4511 /// It should be used to handle progress information, and to implement a certain level of resilience.
4512 /// ````
4513 ///
4514 /// Sets the *delegate* property to the given value.
4515 pub fn delegate(
4516 mut self,
4517 new_value: &'a mut dyn common::Delegate,
4518 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtSentenceListCall<'a, C> {
4519 self._delegate = Some(new_value);
4520 self
4521 }
4522
4523 /// Set any additional parameter of the query string used in the request.
4524 /// It should be used to set parameters which are not yet available through their own
4525 /// setters.
4526 ///
4527 /// Please note that this method must not be used to set any of the known parameters
4528 /// which have their own setter method. If done anyway, the request will fail.
4529 ///
4530 /// # Additional Parameters
4531 ///
4532 /// * *$.xgafv* (query-string) - V1 error format.
4533 /// * *access_token* (query-string) - OAuth access token.
4534 /// * *alt* (query-string) - Data format for response.
4535 /// * *callback* (query-string) - JSONP
4536 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4537 /// * *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.
4538 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4539 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4540 /// * *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.
4541 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4542 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4543 pub fn param<T>(
4544 mut self,
4545 name: T,
4546 value: T,
4547 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtSentenceListCall<'a, C>
4548 where
4549 T: AsRef<str>,
4550 {
4551 self._additional_params
4552 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4553 self
4554 }
4555
4556 /// Identifies the authorization scope for the method you are building.
4557 ///
4558 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4559 /// [`Scope::CloudPlatform`].
4560 ///
4561 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4562 /// tokens for more than one scope.
4563 ///
4564 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4565 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4566 /// sufficient, a read-write scope will do as well.
4567 pub fn add_scope<St>(
4568 mut self,
4569 scope: St,
4570 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtSentenceListCall<'a, C>
4571 where
4572 St: AsRef<str>,
4573 {
4574 self._scopes.insert(String::from(scope.as_ref()));
4575 self
4576 }
4577 /// Identifies the authorization scope(s) for the method you are building.
4578 ///
4579 /// See [`Self::add_scope()`] for details.
4580 pub fn add_scopes<I, St>(
4581 mut self,
4582 scopes: I,
4583 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtSentenceListCall<'a, C>
4584 where
4585 I: IntoIterator<Item = St>,
4586 St: AsRef<str>,
4587 {
4588 self._scopes
4589 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4590 self
4591 }
4592
4593 /// Removes all scopes, and no default scope will be used either.
4594 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4595 /// for details).
4596 pub fn clear_scopes(
4597 mut self,
4598 ) -> ProjectLocationAdaptiveMtDatasetAdaptiveMtSentenceListCall<'a, C> {
4599 self._scopes.clear();
4600 self
4601 }
4602}
4603
4604/// Creates an Adaptive MT dataset.
4605///
4606/// A builder for the *locations.adaptiveMtDatasets.create* method supported by a *project* resource.
4607/// It is not used directly, but through a [`ProjectMethods`] instance.
4608///
4609/// # Example
4610///
4611/// Instantiate a resource method builder
4612///
4613/// ```test_harness,no_run
4614/// # extern crate hyper;
4615/// # extern crate hyper_rustls;
4616/// # extern crate google_translate3 as translate3;
4617/// use translate3::api::AdaptiveMtDataset;
4618/// # async fn dox() {
4619/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4620///
4621/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4622/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4623/// # .with_native_roots()
4624/// # .unwrap()
4625/// # .https_only()
4626/// # .enable_http2()
4627/// # .build();
4628///
4629/// # let executor = hyper_util::rt::TokioExecutor::new();
4630/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4631/// # secret,
4632/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4633/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4634/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4635/// # ),
4636/// # ).build().await.unwrap();
4637///
4638/// # let client = hyper_util::client::legacy::Client::builder(
4639/// # hyper_util::rt::TokioExecutor::new()
4640/// # )
4641/// # .build(
4642/// # hyper_rustls::HttpsConnectorBuilder::new()
4643/// # .with_native_roots()
4644/// # .unwrap()
4645/// # .https_or_http()
4646/// # .enable_http2()
4647/// # .build()
4648/// # );
4649/// # let mut hub = Translate::new(client, auth);
4650/// // As the method needs a request, you would usually fill it with the desired information
4651/// // into the respective structure. Some of the parts shown here might not be applicable !
4652/// // Values shown here are possibly random and not representative !
4653/// let mut req = AdaptiveMtDataset::default();
4654///
4655/// // You can configure optional parameters by calling the respective setters at will, and
4656/// // execute the final call using `doit()`.
4657/// // Values shown here are possibly random and not representative !
4658/// let result = hub.projects().locations_adaptive_mt_datasets_create(req, "parent")
4659/// .doit().await;
4660/// # }
4661/// ```
4662pub struct ProjectLocationAdaptiveMtDatasetCreateCall<'a, C>
4663where
4664 C: 'a,
4665{
4666 hub: &'a Translate<C>,
4667 _request: AdaptiveMtDataset,
4668 _parent: String,
4669 _delegate: Option<&'a mut dyn common::Delegate>,
4670 _additional_params: HashMap<String, String>,
4671 _scopes: BTreeSet<String>,
4672}
4673
4674impl<'a, C> common::CallBuilder for ProjectLocationAdaptiveMtDatasetCreateCall<'a, C> {}
4675
4676impl<'a, C> ProjectLocationAdaptiveMtDatasetCreateCall<'a, C>
4677where
4678 C: common::Connector,
4679{
4680 /// Perform the operation you have build so far.
4681 pub async fn doit(mut self) -> common::Result<(common::Response, AdaptiveMtDataset)> {
4682 use std::borrow::Cow;
4683 use std::io::{Read, Seek};
4684
4685 use common::{url::Params, ToParts};
4686 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4687
4688 let mut dd = common::DefaultDelegate;
4689 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4690 dlg.begin(common::MethodInfo {
4691 id: "translate.projects.locations.adaptiveMtDatasets.create",
4692 http_method: hyper::Method::POST,
4693 });
4694
4695 for &field in ["alt", "parent"].iter() {
4696 if self._additional_params.contains_key(field) {
4697 dlg.finished(false);
4698 return Err(common::Error::FieldClash(field));
4699 }
4700 }
4701
4702 let mut params = Params::with_capacity(4 + self._additional_params.len());
4703 params.push("parent", self._parent);
4704
4705 params.extend(self._additional_params.iter());
4706
4707 params.push("alt", "json");
4708 let mut url = self.hub._base_url.clone() + "v3/{+parent}/adaptiveMtDatasets";
4709 if self._scopes.is_empty() {
4710 self._scopes
4711 .insert(Scope::CloudPlatform.as_ref().to_string());
4712 }
4713
4714 #[allow(clippy::single_element_loop)]
4715 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4716 url = params.uri_replacement(url, param_name, find_this, true);
4717 }
4718 {
4719 let to_remove = ["parent"];
4720 params.remove_params(&to_remove);
4721 }
4722
4723 let url = params.parse_with_url(&url);
4724
4725 let mut json_mime_type = mime::APPLICATION_JSON;
4726 let mut request_value_reader = {
4727 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4728 common::remove_json_null_values(&mut value);
4729 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4730 serde_json::to_writer(&mut dst, &value).unwrap();
4731 dst
4732 };
4733 let request_size = request_value_reader
4734 .seek(std::io::SeekFrom::End(0))
4735 .unwrap();
4736 request_value_reader
4737 .seek(std::io::SeekFrom::Start(0))
4738 .unwrap();
4739
4740 loop {
4741 let token = match self
4742 .hub
4743 .auth
4744 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4745 .await
4746 {
4747 Ok(token) => token,
4748 Err(e) => match dlg.token(e) {
4749 Ok(token) => token,
4750 Err(e) => {
4751 dlg.finished(false);
4752 return Err(common::Error::MissingToken(e));
4753 }
4754 },
4755 };
4756 request_value_reader
4757 .seek(std::io::SeekFrom::Start(0))
4758 .unwrap();
4759 let mut req_result = {
4760 let client = &self.hub.client;
4761 dlg.pre_request();
4762 let mut req_builder = hyper::Request::builder()
4763 .method(hyper::Method::POST)
4764 .uri(url.as_str())
4765 .header(USER_AGENT, self.hub._user_agent.clone());
4766
4767 if let Some(token) = token.as_ref() {
4768 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4769 }
4770
4771 let request = req_builder
4772 .header(CONTENT_TYPE, json_mime_type.to_string())
4773 .header(CONTENT_LENGTH, request_size as u64)
4774 .body(common::to_body(
4775 request_value_reader.get_ref().clone().into(),
4776 ));
4777
4778 client.request(request.unwrap()).await
4779 };
4780
4781 match req_result {
4782 Err(err) => {
4783 if let common::Retry::After(d) = dlg.http_error(&err) {
4784 sleep(d).await;
4785 continue;
4786 }
4787 dlg.finished(false);
4788 return Err(common::Error::HttpError(err));
4789 }
4790 Ok(res) => {
4791 let (mut parts, body) = res.into_parts();
4792 let mut body = common::Body::new(body);
4793 if !parts.status.is_success() {
4794 let bytes = common::to_bytes(body).await.unwrap_or_default();
4795 let error = serde_json::from_str(&common::to_string(&bytes));
4796 let response = common::to_response(parts, bytes.into());
4797
4798 if let common::Retry::After(d) =
4799 dlg.http_failure(&response, error.as_ref().ok())
4800 {
4801 sleep(d).await;
4802 continue;
4803 }
4804
4805 dlg.finished(false);
4806
4807 return Err(match error {
4808 Ok(value) => common::Error::BadRequest(value),
4809 _ => common::Error::Failure(response),
4810 });
4811 }
4812 let response = {
4813 let bytes = common::to_bytes(body).await.unwrap_or_default();
4814 let encoded = common::to_string(&bytes);
4815 match serde_json::from_str(&encoded) {
4816 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4817 Err(error) => {
4818 dlg.response_json_decode_error(&encoded, &error);
4819 return Err(common::Error::JsonDecodeError(
4820 encoded.to_string(),
4821 error,
4822 ));
4823 }
4824 }
4825 };
4826
4827 dlg.finished(true);
4828 return Ok(response);
4829 }
4830 }
4831 }
4832 }
4833
4834 ///
4835 /// Sets the *request* property to the given value.
4836 ///
4837 /// Even though the property as already been set when instantiating this call,
4838 /// we provide this method for API completeness.
4839 pub fn request(
4840 mut self,
4841 new_value: AdaptiveMtDataset,
4842 ) -> ProjectLocationAdaptiveMtDatasetCreateCall<'a, C> {
4843 self._request = new_value;
4844 self
4845 }
4846 /// Required. Name of the parent project. In form of `projects/{project-number-or-id}/locations/{location-id}`
4847 ///
4848 /// Sets the *parent* path property to the given value.
4849 ///
4850 /// Even though the property as already been set when instantiating this call,
4851 /// we provide this method for API completeness.
4852 pub fn parent(mut self, new_value: &str) -> ProjectLocationAdaptiveMtDatasetCreateCall<'a, C> {
4853 self._parent = new_value.to_string();
4854 self
4855 }
4856 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4857 /// while executing the actual API request.
4858 ///
4859 /// ````text
4860 /// It should be used to handle progress information, and to implement a certain level of resilience.
4861 /// ````
4862 ///
4863 /// Sets the *delegate* property to the given value.
4864 pub fn delegate(
4865 mut self,
4866 new_value: &'a mut dyn common::Delegate,
4867 ) -> ProjectLocationAdaptiveMtDatasetCreateCall<'a, C> {
4868 self._delegate = Some(new_value);
4869 self
4870 }
4871
4872 /// Set any additional parameter of the query string used in the request.
4873 /// It should be used to set parameters which are not yet available through their own
4874 /// setters.
4875 ///
4876 /// Please note that this method must not be used to set any of the known parameters
4877 /// which have their own setter method. If done anyway, the request will fail.
4878 ///
4879 /// # Additional Parameters
4880 ///
4881 /// * *$.xgafv* (query-string) - V1 error format.
4882 /// * *access_token* (query-string) - OAuth access token.
4883 /// * *alt* (query-string) - Data format for response.
4884 /// * *callback* (query-string) - JSONP
4885 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4886 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4887 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4888 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4889 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4890 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4891 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4892 pub fn param<T>(
4893 mut self,
4894 name: T,
4895 value: T,
4896 ) -> ProjectLocationAdaptiveMtDatasetCreateCall<'a, C>
4897 where
4898 T: AsRef<str>,
4899 {
4900 self._additional_params
4901 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4902 self
4903 }
4904
4905 /// Identifies the authorization scope for the method you are building.
4906 ///
4907 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4908 /// [`Scope::CloudPlatform`].
4909 ///
4910 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4911 /// tokens for more than one scope.
4912 ///
4913 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4914 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4915 /// sufficient, a read-write scope will do as well.
4916 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationAdaptiveMtDatasetCreateCall<'a, C>
4917 where
4918 St: AsRef<str>,
4919 {
4920 self._scopes.insert(String::from(scope.as_ref()));
4921 self
4922 }
4923 /// Identifies the authorization scope(s) for the method you are building.
4924 ///
4925 /// See [`Self::add_scope()`] for details.
4926 pub fn add_scopes<I, St>(
4927 mut self,
4928 scopes: I,
4929 ) -> ProjectLocationAdaptiveMtDatasetCreateCall<'a, C>
4930 where
4931 I: IntoIterator<Item = St>,
4932 St: AsRef<str>,
4933 {
4934 self._scopes
4935 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4936 self
4937 }
4938
4939 /// Removes all scopes, and no default scope will be used either.
4940 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4941 /// for details).
4942 pub fn clear_scopes(mut self) -> ProjectLocationAdaptiveMtDatasetCreateCall<'a, C> {
4943 self._scopes.clear();
4944 self
4945 }
4946}
4947
4948/// Deletes an Adaptive MT dataset, including all its entries and associated metadata.
4949///
4950/// A builder for the *locations.adaptiveMtDatasets.delete* method supported by a *project* resource.
4951/// It is not used directly, but through a [`ProjectMethods`] instance.
4952///
4953/// # Example
4954///
4955/// Instantiate a resource method builder
4956///
4957/// ```test_harness,no_run
4958/// # extern crate hyper;
4959/// # extern crate hyper_rustls;
4960/// # extern crate google_translate3 as translate3;
4961/// # async fn dox() {
4962/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4963///
4964/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4965/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4966/// # .with_native_roots()
4967/// # .unwrap()
4968/// # .https_only()
4969/// # .enable_http2()
4970/// # .build();
4971///
4972/// # let executor = hyper_util::rt::TokioExecutor::new();
4973/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4974/// # secret,
4975/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4976/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4977/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4978/// # ),
4979/// # ).build().await.unwrap();
4980///
4981/// # let client = hyper_util::client::legacy::Client::builder(
4982/// # hyper_util::rt::TokioExecutor::new()
4983/// # )
4984/// # .build(
4985/// # hyper_rustls::HttpsConnectorBuilder::new()
4986/// # .with_native_roots()
4987/// # .unwrap()
4988/// # .https_or_http()
4989/// # .enable_http2()
4990/// # .build()
4991/// # );
4992/// # let mut hub = Translate::new(client, auth);
4993/// // You can configure optional parameters by calling the respective setters at will, and
4994/// // execute the final call using `doit()`.
4995/// // Values shown here are possibly random and not representative !
4996/// let result = hub.projects().locations_adaptive_mt_datasets_delete("name")
4997/// .doit().await;
4998/// # }
4999/// ```
5000pub struct ProjectLocationAdaptiveMtDatasetDeleteCall<'a, C>
5001where
5002 C: 'a,
5003{
5004 hub: &'a Translate<C>,
5005 _name: String,
5006 _delegate: Option<&'a mut dyn common::Delegate>,
5007 _additional_params: HashMap<String, String>,
5008 _scopes: BTreeSet<String>,
5009}
5010
5011impl<'a, C> common::CallBuilder for ProjectLocationAdaptiveMtDatasetDeleteCall<'a, C> {}
5012
5013impl<'a, C> ProjectLocationAdaptiveMtDatasetDeleteCall<'a, C>
5014where
5015 C: common::Connector,
5016{
5017 /// Perform the operation you have build so far.
5018 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
5019 use std::borrow::Cow;
5020 use std::io::{Read, Seek};
5021
5022 use common::{url::Params, ToParts};
5023 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5024
5025 let mut dd = common::DefaultDelegate;
5026 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5027 dlg.begin(common::MethodInfo {
5028 id: "translate.projects.locations.adaptiveMtDatasets.delete",
5029 http_method: hyper::Method::DELETE,
5030 });
5031
5032 for &field in ["alt", "name"].iter() {
5033 if self._additional_params.contains_key(field) {
5034 dlg.finished(false);
5035 return Err(common::Error::FieldClash(field));
5036 }
5037 }
5038
5039 let mut params = Params::with_capacity(3 + self._additional_params.len());
5040 params.push("name", self._name);
5041
5042 params.extend(self._additional_params.iter());
5043
5044 params.push("alt", "json");
5045 let mut url = self.hub._base_url.clone() + "v3/{+name}";
5046 if self._scopes.is_empty() {
5047 self._scopes
5048 .insert(Scope::CloudPlatform.as_ref().to_string());
5049 }
5050
5051 #[allow(clippy::single_element_loop)]
5052 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5053 url = params.uri_replacement(url, param_name, find_this, true);
5054 }
5055 {
5056 let to_remove = ["name"];
5057 params.remove_params(&to_remove);
5058 }
5059
5060 let url = params.parse_with_url(&url);
5061
5062 loop {
5063 let token = match self
5064 .hub
5065 .auth
5066 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5067 .await
5068 {
5069 Ok(token) => token,
5070 Err(e) => match dlg.token(e) {
5071 Ok(token) => token,
5072 Err(e) => {
5073 dlg.finished(false);
5074 return Err(common::Error::MissingToken(e));
5075 }
5076 },
5077 };
5078 let mut req_result = {
5079 let client = &self.hub.client;
5080 dlg.pre_request();
5081 let mut req_builder = hyper::Request::builder()
5082 .method(hyper::Method::DELETE)
5083 .uri(url.as_str())
5084 .header(USER_AGENT, self.hub._user_agent.clone());
5085
5086 if let Some(token) = token.as_ref() {
5087 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5088 }
5089
5090 let request = req_builder
5091 .header(CONTENT_LENGTH, 0_u64)
5092 .body(common::to_body::<String>(None));
5093
5094 client.request(request.unwrap()).await
5095 };
5096
5097 match req_result {
5098 Err(err) => {
5099 if let common::Retry::After(d) = dlg.http_error(&err) {
5100 sleep(d).await;
5101 continue;
5102 }
5103 dlg.finished(false);
5104 return Err(common::Error::HttpError(err));
5105 }
5106 Ok(res) => {
5107 let (mut parts, body) = res.into_parts();
5108 let mut body = common::Body::new(body);
5109 if !parts.status.is_success() {
5110 let bytes = common::to_bytes(body).await.unwrap_or_default();
5111 let error = serde_json::from_str(&common::to_string(&bytes));
5112 let response = common::to_response(parts, bytes.into());
5113
5114 if let common::Retry::After(d) =
5115 dlg.http_failure(&response, error.as_ref().ok())
5116 {
5117 sleep(d).await;
5118 continue;
5119 }
5120
5121 dlg.finished(false);
5122
5123 return Err(match error {
5124 Ok(value) => common::Error::BadRequest(value),
5125 _ => common::Error::Failure(response),
5126 });
5127 }
5128 let response = {
5129 let bytes = common::to_bytes(body).await.unwrap_or_default();
5130 let encoded = common::to_string(&bytes);
5131 match serde_json::from_str(&encoded) {
5132 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5133 Err(error) => {
5134 dlg.response_json_decode_error(&encoded, &error);
5135 return Err(common::Error::JsonDecodeError(
5136 encoded.to_string(),
5137 error,
5138 ));
5139 }
5140 }
5141 };
5142
5143 dlg.finished(true);
5144 return Ok(response);
5145 }
5146 }
5147 }
5148 }
5149
5150 /// Required. Name of the dataset. In the form of `projects/{project-number-or-id}/locations/{location-id}/adaptiveMtDatasets/{adaptive-mt-dataset-id}`
5151 ///
5152 /// Sets the *name* path property to the given value.
5153 ///
5154 /// Even though the property as already been set when instantiating this call,
5155 /// we provide this method for API completeness.
5156 pub fn name(mut self, new_value: &str) -> ProjectLocationAdaptiveMtDatasetDeleteCall<'a, C> {
5157 self._name = new_value.to_string();
5158 self
5159 }
5160 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5161 /// while executing the actual API request.
5162 ///
5163 /// ````text
5164 /// It should be used to handle progress information, and to implement a certain level of resilience.
5165 /// ````
5166 ///
5167 /// Sets the *delegate* property to the given value.
5168 pub fn delegate(
5169 mut self,
5170 new_value: &'a mut dyn common::Delegate,
5171 ) -> ProjectLocationAdaptiveMtDatasetDeleteCall<'a, C> {
5172 self._delegate = Some(new_value);
5173 self
5174 }
5175
5176 /// Set any additional parameter of the query string used in the request.
5177 /// It should be used to set parameters which are not yet available through their own
5178 /// setters.
5179 ///
5180 /// Please note that this method must not be used to set any of the known parameters
5181 /// which have their own setter method. If done anyway, the request will fail.
5182 ///
5183 /// # Additional Parameters
5184 ///
5185 /// * *$.xgafv* (query-string) - V1 error format.
5186 /// * *access_token* (query-string) - OAuth access token.
5187 /// * *alt* (query-string) - Data format for response.
5188 /// * *callback* (query-string) - JSONP
5189 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5190 /// * *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.
5191 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5192 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5193 /// * *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.
5194 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5195 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5196 pub fn param<T>(
5197 mut self,
5198 name: T,
5199 value: T,
5200 ) -> ProjectLocationAdaptiveMtDatasetDeleteCall<'a, C>
5201 where
5202 T: AsRef<str>,
5203 {
5204 self._additional_params
5205 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5206 self
5207 }
5208
5209 /// Identifies the authorization scope for the method you are building.
5210 ///
5211 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5212 /// [`Scope::CloudPlatform`].
5213 ///
5214 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5215 /// tokens for more than one scope.
5216 ///
5217 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5218 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5219 /// sufficient, a read-write scope will do as well.
5220 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationAdaptiveMtDatasetDeleteCall<'a, C>
5221 where
5222 St: AsRef<str>,
5223 {
5224 self._scopes.insert(String::from(scope.as_ref()));
5225 self
5226 }
5227 /// Identifies the authorization scope(s) for the method you are building.
5228 ///
5229 /// See [`Self::add_scope()`] for details.
5230 pub fn add_scopes<I, St>(
5231 mut self,
5232 scopes: I,
5233 ) -> ProjectLocationAdaptiveMtDatasetDeleteCall<'a, C>
5234 where
5235 I: IntoIterator<Item = St>,
5236 St: AsRef<str>,
5237 {
5238 self._scopes
5239 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5240 self
5241 }
5242
5243 /// Removes all scopes, and no default scope will be used either.
5244 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5245 /// for details).
5246 pub fn clear_scopes(mut self) -> ProjectLocationAdaptiveMtDatasetDeleteCall<'a, C> {
5247 self._scopes.clear();
5248 self
5249 }
5250}
5251
5252/// Gets the Adaptive MT dataset.
5253///
5254/// A builder for the *locations.adaptiveMtDatasets.get* method supported by a *project* resource.
5255/// It is not used directly, but through a [`ProjectMethods`] instance.
5256///
5257/// # Example
5258///
5259/// Instantiate a resource method builder
5260///
5261/// ```test_harness,no_run
5262/// # extern crate hyper;
5263/// # extern crate hyper_rustls;
5264/// # extern crate google_translate3 as translate3;
5265/// # async fn dox() {
5266/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5267///
5268/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5269/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5270/// # .with_native_roots()
5271/// # .unwrap()
5272/// # .https_only()
5273/// # .enable_http2()
5274/// # .build();
5275///
5276/// # let executor = hyper_util::rt::TokioExecutor::new();
5277/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5278/// # secret,
5279/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5280/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5281/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5282/// # ),
5283/// # ).build().await.unwrap();
5284///
5285/// # let client = hyper_util::client::legacy::Client::builder(
5286/// # hyper_util::rt::TokioExecutor::new()
5287/// # )
5288/// # .build(
5289/// # hyper_rustls::HttpsConnectorBuilder::new()
5290/// # .with_native_roots()
5291/// # .unwrap()
5292/// # .https_or_http()
5293/// # .enable_http2()
5294/// # .build()
5295/// # );
5296/// # let mut hub = Translate::new(client, auth);
5297/// // You can configure optional parameters by calling the respective setters at will, and
5298/// // execute the final call using `doit()`.
5299/// // Values shown here are possibly random and not representative !
5300/// let result = hub.projects().locations_adaptive_mt_datasets_get("name")
5301/// .doit().await;
5302/// # }
5303/// ```
5304pub struct ProjectLocationAdaptiveMtDatasetGetCall<'a, C>
5305where
5306 C: 'a,
5307{
5308 hub: &'a Translate<C>,
5309 _name: String,
5310 _delegate: Option<&'a mut dyn common::Delegate>,
5311 _additional_params: HashMap<String, String>,
5312 _scopes: BTreeSet<String>,
5313}
5314
5315impl<'a, C> common::CallBuilder for ProjectLocationAdaptiveMtDatasetGetCall<'a, C> {}
5316
5317impl<'a, C> ProjectLocationAdaptiveMtDatasetGetCall<'a, C>
5318where
5319 C: common::Connector,
5320{
5321 /// Perform the operation you have build so far.
5322 pub async fn doit(mut self) -> common::Result<(common::Response, AdaptiveMtDataset)> {
5323 use std::borrow::Cow;
5324 use std::io::{Read, Seek};
5325
5326 use common::{url::Params, ToParts};
5327 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5328
5329 let mut dd = common::DefaultDelegate;
5330 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5331 dlg.begin(common::MethodInfo {
5332 id: "translate.projects.locations.adaptiveMtDatasets.get",
5333 http_method: hyper::Method::GET,
5334 });
5335
5336 for &field in ["alt", "name"].iter() {
5337 if self._additional_params.contains_key(field) {
5338 dlg.finished(false);
5339 return Err(common::Error::FieldClash(field));
5340 }
5341 }
5342
5343 let mut params = Params::with_capacity(3 + self._additional_params.len());
5344 params.push("name", self._name);
5345
5346 params.extend(self._additional_params.iter());
5347
5348 params.push("alt", "json");
5349 let mut url = self.hub._base_url.clone() + "v3/{+name}";
5350 if self._scopes.is_empty() {
5351 self._scopes
5352 .insert(Scope::CloudPlatform.as_ref().to_string());
5353 }
5354
5355 #[allow(clippy::single_element_loop)]
5356 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5357 url = params.uri_replacement(url, param_name, find_this, true);
5358 }
5359 {
5360 let to_remove = ["name"];
5361 params.remove_params(&to_remove);
5362 }
5363
5364 let url = params.parse_with_url(&url);
5365
5366 loop {
5367 let token = match self
5368 .hub
5369 .auth
5370 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5371 .await
5372 {
5373 Ok(token) => token,
5374 Err(e) => match dlg.token(e) {
5375 Ok(token) => token,
5376 Err(e) => {
5377 dlg.finished(false);
5378 return Err(common::Error::MissingToken(e));
5379 }
5380 },
5381 };
5382 let mut req_result = {
5383 let client = &self.hub.client;
5384 dlg.pre_request();
5385 let mut req_builder = hyper::Request::builder()
5386 .method(hyper::Method::GET)
5387 .uri(url.as_str())
5388 .header(USER_AGENT, self.hub._user_agent.clone());
5389
5390 if let Some(token) = token.as_ref() {
5391 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5392 }
5393
5394 let request = req_builder
5395 .header(CONTENT_LENGTH, 0_u64)
5396 .body(common::to_body::<String>(None));
5397
5398 client.request(request.unwrap()).await
5399 };
5400
5401 match req_result {
5402 Err(err) => {
5403 if let common::Retry::After(d) = dlg.http_error(&err) {
5404 sleep(d).await;
5405 continue;
5406 }
5407 dlg.finished(false);
5408 return Err(common::Error::HttpError(err));
5409 }
5410 Ok(res) => {
5411 let (mut parts, body) = res.into_parts();
5412 let mut body = common::Body::new(body);
5413 if !parts.status.is_success() {
5414 let bytes = common::to_bytes(body).await.unwrap_or_default();
5415 let error = serde_json::from_str(&common::to_string(&bytes));
5416 let response = common::to_response(parts, bytes.into());
5417
5418 if let common::Retry::After(d) =
5419 dlg.http_failure(&response, error.as_ref().ok())
5420 {
5421 sleep(d).await;
5422 continue;
5423 }
5424
5425 dlg.finished(false);
5426
5427 return Err(match error {
5428 Ok(value) => common::Error::BadRequest(value),
5429 _ => common::Error::Failure(response),
5430 });
5431 }
5432 let response = {
5433 let bytes = common::to_bytes(body).await.unwrap_or_default();
5434 let encoded = common::to_string(&bytes);
5435 match serde_json::from_str(&encoded) {
5436 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5437 Err(error) => {
5438 dlg.response_json_decode_error(&encoded, &error);
5439 return Err(common::Error::JsonDecodeError(
5440 encoded.to_string(),
5441 error,
5442 ));
5443 }
5444 }
5445 };
5446
5447 dlg.finished(true);
5448 return Ok(response);
5449 }
5450 }
5451 }
5452 }
5453
5454 /// Required. Name of the dataset. In the form of `projects/{project-number-or-id}/locations/{location-id}/adaptiveMtDatasets/{adaptive-mt-dataset-id}`
5455 ///
5456 /// Sets the *name* path property to the given value.
5457 ///
5458 /// Even though the property as already been set when instantiating this call,
5459 /// we provide this method for API completeness.
5460 pub fn name(mut self, new_value: &str) -> ProjectLocationAdaptiveMtDatasetGetCall<'a, C> {
5461 self._name = new_value.to_string();
5462 self
5463 }
5464 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5465 /// while executing the actual API request.
5466 ///
5467 /// ````text
5468 /// It should be used to handle progress information, and to implement a certain level of resilience.
5469 /// ````
5470 ///
5471 /// Sets the *delegate* property to the given value.
5472 pub fn delegate(
5473 mut self,
5474 new_value: &'a mut dyn common::Delegate,
5475 ) -> ProjectLocationAdaptiveMtDatasetGetCall<'a, C> {
5476 self._delegate = Some(new_value);
5477 self
5478 }
5479
5480 /// Set any additional parameter of the query string used in the request.
5481 /// It should be used to set parameters which are not yet available through their own
5482 /// setters.
5483 ///
5484 /// Please note that this method must not be used to set any of the known parameters
5485 /// which have their own setter method. If done anyway, the request will fail.
5486 ///
5487 /// # Additional Parameters
5488 ///
5489 /// * *$.xgafv* (query-string) - V1 error format.
5490 /// * *access_token* (query-string) - OAuth access token.
5491 /// * *alt* (query-string) - Data format for response.
5492 /// * *callback* (query-string) - JSONP
5493 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5494 /// * *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.
5495 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5496 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5497 /// * *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.
5498 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5499 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5500 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationAdaptiveMtDatasetGetCall<'a, C>
5501 where
5502 T: AsRef<str>,
5503 {
5504 self._additional_params
5505 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5506 self
5507 }
5508
5509 /// Identifies the authorization scope for the method you are building.
5510 ///
5511 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5512 /// [`Scope::CloudPlatform`].
5513 ///
5514 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5515 /// tokens for more than one scope.
5516 ///
5517 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5518 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5519 /// sufficient, a read-write scope will do as well.
5520 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationAdaptiveMtDatasetGetCall<'a, C>
5521 where
5522 St: AsRef<str>,
5523 {
5524 self._scopes.insert(String::from(scope.as_ref()));
5525 self
5526 }
5527 /// Identifies the authorization scope(s) for the method you are building.
5528 ///
5529 /// See [`Self::add_scope()`] for details.
5530 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationAdaptiveMtDatasetGetCall<'a, C>
5531 where
5532 I: IntoIterator<Item = St>,
5533 St: AsRef<str>,
5534 {
5535 self._scopes
5536 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5537 self
5538 }
5539
5540 /// Removes all scopes, and no default scope will be used either.
5541 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5542 /// for details).
5543 pub fn clear_scopes(mut self) -> ProjectLocationAdaptiveMtDatasetGetCall<'a, C> {
5544 self._scopes.clear();
5545 self
5546 }
5547}
5548
5549/// Imports an AdaptiveMtFile and adds all of its sentences into the AdaptiveMtDataset.
5550///
5551/// A builder for the *locations.adaptiveMtDatasets.importAdaptiveMtFile* method supported by a *project* resource.
5552/// It is not used directly, but through a [`ProjectMethods`] instance.
5553///
5554/// # Example
5555///
5556/// Instantiate a resource method builder
5557///
5558/// ```test_harness,no_run
5559/// # extern crate hyper;
5560/// # extern crate hyper_rustls;
5561/// # extern crate google_translate3 as translate3;
5562/// use translate3::api::ImportAdaptiveMtFileRequest;
5563/// # async fn dox() {
5564/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5565///
5566/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5567/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5568/// # .with_native_roots()
5569/// # .unwrap()
5570/// # .https_only()
5571/// # .enable_http2()
5572/// # .build();
5573///
5574/// # let executor = hyper_util::rt::TokioExecutor::new();
5575/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5576/// # secret,
5577/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5578/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5579/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5580/// # ),
5581/// # ).build().await.unwrap();
5582///
5583/// # let client = hyper_util::client::legacy::Client::builder(
5584/// # hyper_util::rt::TokioExecutor::new()
5585/// # )
5586/// # .build(
5587/// # hyper_rustls::HttpsConnectorBuilder::new()
5588/// # .with_native_roots()
5589/// # .unwrap()
5590/// # .https_or_http()
5591/// # .enable_http2()
5592/// # .build()
5593/// # );
5594/// # let mut hub = Translate::new(client, auth);
5595/// // As the method needs a request, you would usually fill it with the desired information
5596/// // into the respective structure. Some of the parts shown here might not be applicable !
5597/// // Values shown here are possibly random and not representative !
5598/// let mut req = ImportAdaptiveMtFileRequest::default();
5599///
5600/// // You can configure optional parameters by calling the respective setters at will, and
5601/// // execute the final call using `doit()`.
5602/// // Values shown here are possibly random and not representative !
5603/// let result = hub.projects().locations_adaptive_mt_datasets_import_adaptive_mt_file(req, "parent")
5604/// .doit().await;
5605/// # }
5606/// ```
5607pub struct ProjectLocationAdaptiveMtDatasetImportAdaptiveMtFileCall<'a, C>
5608where
5609 C: 'a,
5610{
5611 hub: &'a Translate<C>,
5612 _request: ImportAdaptiveMtFileRequest,
5613 _parent: String,
5614 _delegate: Option<&'a mut dyn common::Delegate>,
5615 _additional_params: HashMap<String, String>,
5616 _scopes: BTreeSet<String>,
5617}
5618
5619impl<'a, C> common::CallBuilder
5620 for ProjectLocationAdaptiveMtDatasetImportAdaptiveMtFileCall<'a, C>
5621{
5622}
5623
5624impl<'a, C> ProjectLocationAdaptiveMtDatasetImportAdaptiveMtFileCall<'a, C>
5625where
5626 C: common::Connector,
5627{
5628 /// Perform the operation you have build so far.
5629 pub async fn doit(
5630 mut self,
5631 ) -> common::Result<(common::Response, ImportAdaptiveMtFileResponse)> {
5632 use std::borrow::Cow;
5633 use std::io::{Read, Seek};
5634
5635 use common::{url::Params, ToParts};
5636 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5637
5638 let mut dd = common::DefaultDelegate;
5639 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5640 dlg.begin(common::MethodInfo {
5641 id: "translate.projects.locations.adaptiveMtDatasets.importAdaptiveMtFile",
5642 http_method: hyper::Method::POST,
5643 });
5644
5645 for &field in ["alt", "parent"].iter() {
5646 if self._additional_params.contains_key(field) {
5647 dlg.finished(false);
5648 return Err(common::Error::FieldClash(field));
5649 }
5650 }
5651
5652 let mut params = Params::with_capacity(4 + self._additional_params.len());
5653 params.push("parent", self._parent);
5654
5655 params.extend(self._additional_params.iter());
5656
5657 params.push("alt", "json");
5658 let mut url = self.hub._base_url.clone() + "v3/{+parent}:importAdaptiveMtFile";
5659 if self._scopes.is_empty() {
5660 self._scopes
5661 .insert(Scope::CloudPlatform.as_ref().to_string());
5662 }
5663
5664 #[allow(clippy::single_element_loop)]
5665 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5666 url = params.uri_replacement(url, param_name, find_this, true);
5667 }
5668 {
5669 let to_remove = ["parent"];
5670 params.remove_params(&to_remove);
5671 }
5672
5673 let url = params.parse_with_url(&url);
5674
5675 let mut json_mime_type = mime::APPLICATION_JSON;
5676 let mut request_value_reader = {
5677 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5678 common::remove_json_null_values(&mut value);
5679 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5680 serde_json::to_writer(&mut dst, &value).unwrap();
5681 dst
5682 };
5683 let request_size = request_value_reader
5684 .seek(std::io::SeekFrom::End(0))
5685 .unwrap();
5686 request_value_reader
5687 .seek(std::io::SeekFrom::Start(0))
5688 .unwrap();
5689
5690 loop {
5691 let token = match self
5692 .hub
5693 .auth
5694 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5695 .await
5696 {
5697 Ok(token) => token,
5698 Err(e) => match dlg.token(e) {
5699 Ok(token) => token,
5700 Err(e) => {
5701 dlg.finished(false);
5702 return Err(common::Error::MissingToken(e));
5703 }
5704 },
5705 };
5706 request_value_reader
5707 .seek(std::io::SeekFrom::Start(0))
5708 .unwrap();
5709 let mut req_result = {
5710 let client = &self.hub.client;
5711 dlg.pre_request();
5712 let mut req_builder = hyper::Request::builder()
5713 .method(hyper::Method::POST)
5714 .uri(url.as_str())
5715 .header(USER_AGENT, self.hub._user_agent.clone());
5716
5717 if let Some(token) = token.as_ref() {
5718 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5719 }
5720
5721 let request = req_builder
5722 .header(CONTENT_TYPE, json_mime_type.to_string())
5723 .header(CONTENT_LENGTH, request_size as u64)
5724 .body(common::to_body(
5725 request_value_reader.get_ref().clone().into(),
5726 ));
5727
5728 client.request(request.unwrap()).await
5729 };
5730
5731 match req_result {
5732 Err(err) => {
5733 if let common::Retry::After(d) = dlg.http_error(&err) {
5734 sleep(d).await;
5735 continue;
5736 }
5737 dlg.finished(false);
5738 return Err(common::Error::HttpError(err));
5739 }
5740 Ok(res) => {
5741 let (mut parts, body) = res.into_parts();
5742 let mut body = common::Body::new(body);
5743 if !parts.status.is_success() {
5744 let bytes = common::to_bytes(body).await.unwrap_or_default();
5745 let error = serde_json::from_str(&common::to_string(&bytes));
5746 let response = common::to_response(parts, bytes.into());
5747
5748 if let common::Retry::After(d) =
5749 dlg.http_failure(&response, error.as_ref().ok())
5750 {
5751 sleep(d).await;
5752 continue;
5753 }
5754
5755 dlg.finished(false);
5756
5757 return Err(match error {
5758 Ok(value) => common::Error::BadRequest(value),
5759 _ => common::Error::Failure(response),
5760 });
5761 }
5762 let response = {
5763 let bytes = common::to_bytes(body).await.unwrap_or_default();
5764 let encoded = common::to_string(&bytes);
5765 match serde_json::from_str(&encoded) {
5766 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5767 Err(error) => {
5768 dlg.response_json_decode_error(&encoded, &error);
5769 return Err(common::Error::JsonDecodeError(
5770 encoded.to_string(),
5771 error,
5772 ));
5773 }
5774 }
5775 };
5776
5777 dlg.finished(true);
5778 return Ok(response);
5779 }
5780 }
5781 }
5782 }
5783
5784 ///
5785 /// Sets the *request* property to the given value.
5786 ///
5787 /// Even though the property as already been set when instantiating this call,
5788 /// we provide this method for API completeness.
5789 pub fn request(
5790 mut self,
5791 new_value: ImportAdaptiveMtFileRequest,
5792 ) -> ProjectLocationAdaptiveMtDatasetImportAdaptiveMtFileCall<'a, C> {
5793 self._request = new_value;
5794 self
5795 }
5796 /// Required. The resource name of the file, in form of `projects/{project-number-or-id}/locations/{location_id}/adaptiveMtDatasets/{dataset}`
5797 ///
5798 /// Sets the *parent* path property to the given value.
5799 ///
5800 /// Even though the property as already been set when instantiating this call,
5801 /// we provide this method for API completeness.
5802 pub fn parent(
5803 mut self,
5804 new_value: &str,
5805 ) -> ProjectLocationAdaptiveMtDatasetImportAdaptiveMtFileCall<'a, C> {
5806 self._parent = new_value.to_string();
5807 self
5808 }
5809 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5810 /// while executing the actual API request.
5811 ///
5812 /// ````text
5813 /// It should be used to handle progress information, and to implement a certain level of resilience.
5814 /// ````
5815 ///
5816 /// Sets the *delegate* property to the given value.
5817 pub fn delegate(
5818 mut self,
5819 new_value: &'a mut dyn common::Delegate,
5820 ) -> ProjectLocationAdaptiveMtDatasetImportAdaptiveMtFileCall<'a, C> {
5821 self._delegate = Some(new_value);
5822 self
5823 }
5824
5825 /// Set any additional parameter of the query string used in the request.
5826 /// It should be used to set parameters which are not yet available through their own
5827 /// setters.
5828 ///
5829 /// Please note that this method must not be used to set any of the known parameters
5830 /// which have their own setter method. If done anyway, the request will fail.
5831 ///
5832 /// # Additional Parameters
5833 ///
5834 /// * *$.xgafv* (query-string) - V1 error format.
5835 /// * *access_token* (query-string) - OAuth access token.
5836 /// * *alt* (query-string) - Data format for response.
5837 /// * *callback* (query-string) - JSONP
5838 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5839 /// * *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.
5840 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5841 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5842 /// * *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.
5843 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5844 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5845 pub fn param<T>(
5846 mut self,
5847 name: T,
5848 value: T,
5849 ) -> ProjectLocationAdaptiveMtDatasetImportAdaptiveMtFileCall<'a, C>
5850 where
5851 T: AsRef<str>,
5852 {
5853 self._additional_params
5854 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5855 self
5856 }
5857
5858 /// Identifies the authorization scope for the method you are building.
5859 ///
5860 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5861 /// [`Scope::CloudPlatform`].
5862 ///
5863 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5864 /// tokens for more than one scope.
5865 ///
5866 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5867 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5868 /// sufficient, a read-write scope will do as well.
5869 pub fn add_scope<St>(
5870 mut self,
5871 scope: St,
5872 ) -> ProjectLocationAdaptiveMtDatasetImportAdaptiveMtFileCall<'a, C>
5873 where
5874 St: AsRef<str>,
5875 {
5876 self._scopes.insert(String::from(scope.as_ref()));
5877 self
5878 }
5879 /// Identifies the authorization scope(s) for the method you are building.
5880 ///
5881 /// See [`Self::add_scope()`] for details.
5882 pub fn add_scopes<I, St>(
5883 mut self,
5884 scopes: I,
5885 ) -> ProjectLocationAdaptiveMtDatasetImportAdaptiveMtFileCall<'a, C>
5886 where
5887 I: IntoIterator<Item = St>,
5888 St: AsRef<str>,
5889 {
5890 self._scopes
5891 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5892 self
5893 }
5894
5895 /// Removes all scopes, and no default scope will be used either.
5896 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5897 /// for details).
5898 pub fn clear_scopes(
5899 mut self,
5900 ) -> ProjectLocationAdaptiveMtDatasetImportAdaptiveMtFileCall<'a, C> {
5901 self._scopes.clear();
5902 self
5903 }
5904}
5905
5906/// Lists all Adaptive MT datasets for which the caller has read permission.
5907///
5908/// A builder for the *locations.adaptiveMtDatasets.list* method supported by a *project* resource.
5909/// It is not used directly, but through a [`ProjectMethods`] instance.
5910///
5911/// # Example
5912///
5913/// Instantiate a resource method builder
5914///
5915/// ```test_harness,no_run
5916/// # extern crate hyper;
5917/// # extern crate hyper_rustls;
5918/// # extern crate google_translate3 as translate3;
5919/// # async fn dox() {
5920/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5921///
5922/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5923/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5924/// # .with_native_roots()
5925/// # .unwrap()
5926/// # .https_only()
5927/// # .enable_http2()
5928/// # .build();
5929///
5930/// # let executor = hyper_util::rt::TokioExecutor::new();
5931/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5932/// # secret,
5933/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5934/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5935/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5936/// # ),
5937/// # ).build().await.unwrap();
5938///
5939/// # let client = hyper_util::client::legacy::Client::builder(
5940/// # hyper_util::rt::TokioExecutor::new()
5941/// # )
5942/// # .build(
5943/// # hyper_rustls::HttpsConnectorBuilder::new()
5944/// # .with_native_roots()
5945/// # .unwrap()
5946/// # .https_or_http()
5947/// # .enable_http2()
5948/// # .build()
5949/// # );
5950/// # let mut hub = Translate::new(client, auth);
5951/// // You can configure optional parameters by calling the respective setters at will, and
5952/// // execute the final call using `doit()`.
5953/// // Values shown here are possibly random and not representative !
5954/// let result = hub.projects().locations_adaptive_mt_datasets_list("parent")
5955/// .page_token("ipsum")
5956/// .page_size(-88)
5957/// .filter("amet")
5958/// .doit().await;
5959/// # }
5960/// ```
5961pub struct ProjectLocationAdaptiveMtDatasetListCall<'a, C>
5962where
5963 C: 'a,
5964{
5965 hub: &'a Translate<C>,
5966 _parent: String,
5967 _page_token: Option<String>,
5968 _page_size: Option<i32>,
5969 _filter: Option<String>,
5970 _delegate: Option<&'a mut dyn common::Delegate>,
5971 _additional_params: HashMap<String, String>,
5972 _scopes: BTreeSet<String>,
5973}
5974
5975impl<'a, C> common::CallBuilder for ProjectLocationAdaptiveMtDatasetListCall<'a, C> {}
5976
5977impl<'a, C> ProjectLocationAdaptiveMtDatasetListCall<'a, C>
5978where
5979 C: common::Connector,
5980{
5981 /// Perform the operation you have build so far.
5982 pub async fn doit(
5983 mut self,
5984 ) -> common::Result<(common::Response, ListAdaptiveMtDatasetsResponse)> {
5985 use std::borrow::Cow;
5986 use std::io::{Read, Seek};
5987
5988 use common::{url::Params, ToParts};
5989 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5990
5991 let mut dd = common::DefaultDelegate;
5992 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5993 dlg.begin(common::MethodInfo {
5994 id: "translate.projects.locations.adaptiveMtDatasets.list",
5995 http_method: hyper::Method::GET,
5996 });
5997
5998 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
5999 if self._additional_params.contains_key(field) {
6000 dlg.finished(false);
6001 return Err(common::Error::FieldClash(field));
6002 }
6003 }
6004
6005 let mut params = Params::with_capacity(6 + self._additional_params.len());
6006 params.push("parent", self._parent);
6007 if let Some(value) = self._page_token.as_ref() {
6008 params.push("pageToken", value);
6009 }
6010 if let Some(value) = self._page_size.as_ref() {
6011 params.push("pageSize", value.to_string());
6012 }
6013 if let Some(value) = self._filter.as_ref() {
6014 params.push("filter", value);
6015 }
6016
6017 params.extend(self._additional_params.iter());
6018
6019 params.push("alt", "json");
6020 let mut url = self.hub._base_url.clone() + "v3/{+parent}/adaptiveMtDatasets";
6021 if self._scopes.is_empty() {
6022 self._scopes
6023 .insert(Scope::CloudPlatform.as_ref().to_string());
6024 }
6025
6026 #[allow(clippy::single_element_loop)]
6027 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6028 url = params.uri_replacement(url, param_name, find_this, true);
6029 }
6030 {
6031 let to_remove = ["parent"];
6032 params.remove_params(&to_remove);
6033 }
6034
6035 let url = params.parse_with_url(&url);
6036
6037 loop {
6038 let token = match self
6039 .hub
6040 .auth
6041 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6042 .await
6043 {
6044 Ok(token) => token,
6045 Err(e) => match dlg.token(e) {
6046 Ok(token) => token,
6047 Err(e) => {
6048 dlg.finished(false);
6049 return Err(common::Error::MissingToken(e));
6050 }
6051 },
6052 };
6053 let mut req_result = {
6054 let client = &self.hub.client;
6055 dlg.pre_request();
6056 let mut req_builder = hyper::Request::builder()
6057 .method(hyper::Method::GET)
6058 .uri(url.as_str())
6059 .header(USER_AGENT, self.hub._user_agent.clone());
6060
6061 if let Some(token) = token.as_ref() {
6062 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6063 }
6064
6065 let request = req_builder
6066 .header(CONTENT_LENGTH, 0_u64)
6067 .body(common::to_body::<String>(None));
6068
6069 client.request(request.unwrap()).await
6070 };
6071
6072 match req_result {
6073 Err(err) => {
6074 if let common::Retry::After(d) = dlg.http_error(&err) {
6075 sleep(d).await;
6076 continue;
6077 }
6078 dlg.finished(false);
6079 return Err(common::Error::HttpError(err));
6080 }
6081 Ok(res) => {
6082 let (mut parts, body) = res.into_parts();
6083 let mut body = common::Body::new(body);
6084 if !parts.status.is_success() {
6085 let bytes = common::to_bytes(body).await.unwrap_or_default();
6086 let error = serde_json::from_str(&common::to_string(&bytes));
6087 let response = common::to_response(parts, bytes.into());
6088
6089 if let common::Retry::After(d) =
6090 dlg.http_failure(&response, error.as_ref().ok())
6091 {
6092 sleep(d).await;
6093 continue;
6094 }
6095
6096 dlg.finished(false);
6097
6098 return Err(match error {
6099 Ok(value) => common::Error::BadRequest(value),
6100 _ => common::Error::Failure(response),
6101 });
6102 }
6103 let response = {
6104 let bytes = common::to_bytes(body).await.unwrap_or_default();
6105 let encoded = common::to_string(&bytes);
6106 match serde_json::from_str(&encoded) {
6107 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6108 Err(error) => {
6109 dlg.response_json_decode_error(&encoded, &error);
6110 return Err(common::Error::JsonDecodeError(
6111 encoded.to_string(),
6112 error,
6113 ));
6114 }
6115 }
6116 };
6117
6118 dlg.finished(true);
6119 return Ok(response);
6120 }
6121 }
6122 }
6123 }
6124
6125 /// Required. The resource name of the project from which to list the Adaptive MT datasets. `projects/{project-number-or-id}/locations/{location-id}`
6126 ///
6127 /// Sets the *parent* path property to the given value.
6128 ///
6129 /// Even though the property as already been set when instantiating this call,
6130 /// we provide this method for API completeness.
6131 pub fn parent(mut self, new_value: &str) -> ProjectLocationAdaptiveMtDatasetListCall<'a, C> {
6132 self._parent = new_value.to_string();
6133 self
6134 }
6135 /// Optional. A token identifying a page of results the server should return. Typically, this is the value of ListAdaptiveMtDatasetsResponse.next_page_token returned from the previous call to `ListAdaptiveMtDatasets` method. The first page is returned if `page_token`is empty or missing.
6136 ///
6137 /// Sets the *page token* query property to the given value.
6138 pub fn page_token(
6139 mut self,
6140 new_value: &str,
6141 ) -> ProjectLocationAdaptiveMtDatasetListCall<'a, C> {
6142 self._page_token = Some(new_value.to_string());
6143 self
6144 }
6145 /// Optional. Requested page size. The server may return fewer results than requested. If unspecified, the server picks an appropriate default.
6146 ///
6147 /// Sets the *page size* query property to the given value.
6148 pub fn page_size(mut self, new_value: i32) -> ProjectLocationAdaptiveMtDatasetListCall<'a, C> {
6149 self._page_size = Some(new_value);
6150 self
6151 }
6152 /// Optional. An expression for filtering the results of the request. Filter is not supported yet.
6153 ///
6154 /// Sets the *filter* query property to the given value.
6155 pub fn filter(mut self, new_value: &str) -> ProjectLocationAdaptiveMtDatasetListCall<'a, C> {
6156 self._filter = Some(new_value.to_string());
6157 self
6158 }
6159 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6160 /// while executing the actual API request.
6161 ///
6162 /// ````text
6163 /// It should be used to handle progress information, and to implement a certain level of resilience.
6164 /// ````
6165 ///
6166 /// Sets the *delegate* property to the given value.
6167 pub fn delegate(
6168 mut self,
6169 new_value: &'a mut dyn common::Delegate,
6170 ) -> ProjectLocationAdaptiveMtDatasetListCall<'a, C> {
6171 self._delegate = Some(new_value);
6172 self
6173 }
6174
6175 /// Set any additional parameter of the query string used in the request.
6176 /// It should be used to set parameters which are not yet available through their own
6177 /// setters.
6178 ///
6179 /// Please note that this method must not be used to set any of the known parameters
6180 /// which have their own setter method. If done anyway, the request will fail.
6181 ///
6182 /// # Additional Parameters
6183 ///
6184 /// * *$.xgafv* (query-string) - V1 error format.
6185 /// * *access_token* (query-string) - OAuth access token.
6186 /// * *alt* (query-string) - Data format for response.
6187 /// * *callback* (query-string) - JSONP
6188 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6189 /// * *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.
6190 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6191 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6192 /// * *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.
6193 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6194 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6195 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationAdaptiveMtDatasetListCall<'a, C>
6196 where
6197 T: AsRef<str>,
6198 {
6199 self._additional_params
6200 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6201 self
6202 }
6203
6204 /// Identifies the authorization scope for the method you are building.
6205 ///
6206 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6207 /// [`Scope::CloudPlatform`].
6208 ///
6209 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6210 /// tokens for more than one scope.
6211 ///
6212 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6213 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6214 /// sufficient, a read-write scope will do as well.
6215 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationAdaptiveMtDatasetListCall<'a, C>
6216 where
6217 St: AsRef<str>,
6218 {
6219 self._scopes.insert(String::from(scope.as_ref()));
6220 self
6221 }
6222 /// Identifies the authorization scope(s) for the method you are building.
6223 ///
6224 /// See [`Self::add_scope()`] for details.
6225 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationAdaptiveMtDatasetListCall<'a, C>
6226 where
6227 I: IntoIterator<Item = St>,
6228 St: AsRef<str>,
6229 {
6230 self._scopes
6231 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6232 self
6233 }
6234
6235 /// Removes all scopes, and no default scope will be used either.
6236 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6237 /// for details).
6238 pub fn clear_scopes(mut self) -> ProjectLocationAdaptiveMtDatasetListCall<'a, C> {
6239 self._scopes.clear();
6240 self
6241 }
6242}
6243
6244/// Lists sentence pairs in the dataset.
6245///
6246/// A builder for the *locations.datasets.examples.list* method supported by a *project* resource.
6247/// It is not used directly, but through a [`ProjectMethods`] instance.
6248///
6249/// # Example
6250///
6251/// Instantiate a resource method builder
6252///
6253/// ```test_harness,no_run
6254/// # extern crate hyper;
6255/// # extern crate hyper_rustls;
6256/// # extern crate google_translate3 as translate3;
6257/// # async fn dox() {
6258/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6259///
6260/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6261/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6262/// # .with_native_roots()
6263/// # .unwrap()
6264/// # .https_only()
6265/// # .enable_http2()
6266/// # .build();
6267///
6268/// # let executor = hyper_util::rt::TokioExecutor::new();
6269/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6270/// # secret,
6271/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6272/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6273/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6274/// # ),
6275/// # ).build().await.unwrap();
6276///
6277/// # let client = hyper_util::client::legacy::Client::builder(
6278/// # hyper_util::rt::TokioExecutor::new()
6279/// # )
6280/// # .build(
6281/// # hyper_rustls::HttpsConnectorBuilder::new()
6282/// # .with_native_roots()
6283/// # .unwrap()
6284/// # .https_or_http()
6285/// # .enable_http2()
6286/// # .build()
6287/// # );
6288/// # let mut hub = Translate::new(client, auth);
6289/// // You can configure optional parameters by calling the respective setters at will, and
6290/// // execute the final call using `doit()`.
6291/// // Values shown here are possibly random and not representative !
6292/// let result = hub.projects().locations_datasets_examples_list("parent")
6293/// .page_token("ipsum")
6294/// .page_size(-93)
6295/// .filter("ut")
6296/// .doit().await;
6297/// # }
6298/// ```
6299pub struct ProjectLocationDatasetExampleListCall<'a, C>
6300where
6301 C: 'a,
6302{
6303 hub: &'a Translate<C>,
6304 _parent: String,
6305 _page_token: Option<String>,
6306 _page_size: Option<i32>,
6307 _filter: Option<String>,
6308 _delegate: Option<&'a mut dyn common::Delegate>,
6309 _additional_params: HashMap<String, String>,
6310 _scopes: BTreeSet<String>,
6311}
6312
6313impl<'a, C> common::CallBuilder for ProjectLocationDatasetExampleListCall<'a, C> {}
6314
6315impl<'a, C> ProjectLocationDatasetExampleListCall<'a, C>
6316where
6317 C: common::Connector,
6318{
6319 /// Perform the operation you have build so far.
6320 pub async fn doit(mut self) -> common::Result<(common::Response, ListExamplesResponse)> {
6321 use std::borrow::Cow;
6322 use std::io::{Read, Seek};
6323
6324 use common::{url::Params, ToParts};
6325 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6326
6327 let mut dd = common::DefaultDelegate;
6328 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6329 dlg.begin(common::MethodInfo {
6330 id: "translate.projects.locations.datasets.examples.list",
6331 http_method: hyper::Method::GET,
6332 });
6333
6334 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
6335 if self._additional_params.contains_key(field) {
6336 dlg.finished(false);
6337 return Err(common::Error::FieldClash(field));
6338 }
6339 }
6340
6341 let mut params = Params::with_capacity(6 + self._additional_params.len());
6342 params.push("parent", self._parent);
6343 if let Some(value) = self._page_token.as_ref() {
6344 params.push("pageToken", value);
6345 }
6346 if let Some(value) = self._page_size.as_ref() {
6347 params.push("pageSize", value.to_string());
6348 }
6349 if let Some(value) = self._filter.as_ref() {
6350 params.push("filter", value);
6351 }
6352
6353 params.extend(self._additional_params.iter());
6354
6355 params.push("alt", "json");
6356 let mut url = self.hub._base_url.clone() + "v3/{+parent}/examples";
6357 if self._scopes.is_empty() {
6358 self._scopes
6359 .insert(Scope::CloudPlatform.as_ref().to_string());
6360 }
6361
6362 #[allow(clippy::single_element_loop)]
6363 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6364 url = params.uri_replacement(url, param_name, find_this, true);
6365 }
6366 {
6367 let to_remove = ["parent"];
6368 params.remove_params(&to_remove);
6369 }
6370
6371 let url = params.parse_with_url(&url);
6372
6373 loop {
6374 let token = match self
6375 .hub
6376 .auth
6377 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6378 .await
6379 {
6380 Ok(token) => token,
6381 Err(e) => match dlg.token(e) {
6382 Ok(token) => token,
6383 Err(e) => {
6384 dlg.finished(false);
6385 return Err(common::Error::MissingToken(e));
6386 }
6387 },
6388 };
6389 let mut req_result = {
6390 let client = &self.hub.client;
6391 dlg.pre_request();
6392 let mut req_builder = hyper::Request::builder()
6393 .method(hyper::Method::GET)
6394 .uri(url.as_str())
6395 .header(USER_AGENT, self.hub._user_agent.clone());
6396
6397 if let Some(token) = token.as_ref() {
6398 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6399 }
6400
6401 let request = req_builder
6402 .header(CONTENT_LENGTH, 0_u64)
6403 .body(common::to_body::<String>(None));
6404
6405 client.request(request.unwrap()).await
6406 };
6407
6408 match req_result {
6409 Err(err) => {
6410 if let common::Retry::After(d) = dlg.http_error(&err) {
6411 sleep(d).await;
6412 continue;
6413 }
6414 dlg.finished(false);
6415 return Err(common::Error::HttpError(err));
6416 }
6417 Ok(res) => {
6418 let (mut parts, body) = res.into_parts();
6419 let mut body = common::Body::new(body);
6420 if !parts.status.is_success() {
6421 let bytes = common::to_bytes(body).await.unwrap_or_default();
6422 let error = serde_json::from_str(&common::to_string(&bytes));
6423 let response = common::to_response(parts, bytes.into());
6424
6425 if let common::Retry::After(d) =
6426 dlg.http_failure(&response, error.as_ref().ok())
6427 {
6428 sleep(d).await;
6429 continue;
6430 }
6431
6432 dlg.finished(false);
6433
6434 return Err(match error {
6435 Ok(value) => common::Error::BadRequest(value),
6436 _ => common::Error::Failure(response),
6437 });
6438 }
6439 let response = {
6440 let bytes = common::to_bytes(body).await.unwrap_or_default();
6441 let encoded = common::to_string(&bytes);
6442 match serde_json::from_str(&encoded) {
6443 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6444 Err(error) => {
6445 dlg.response_json_decode_error(&encoded, &error);
6446 return Err(common::Error::JsonDecodeError(
6447 encoded.to_string(),
6448 error,
6449 ));
6450 }
6451 }
6452 };
6453
6454 dlg.finished(true);
6455 return Ok(response);
6456 }
6457 }
6458 }
6459 }
6460
6461 /// Required. Name of the parent dataset. In form of `projects/{project-number-or-id}/locations/{location-id}/datasets/{dataset-id}`
6462 ///
6463 /// Sets the *parent* path property to the given value.
6464 ///
6465 /// Even though the property as already been set when instantiating this call,
6466 /// we provide this method for API completeness.
6467 pub fn parent(mut self, new_value: &str) -> ProjectLocationDatasetExampleListCall<'a, C> {
6468 self._parent = new_value.to_string();
6469 self
6470 }
6471 /// Optional. A token identifying a page of results for the server to return. Typically obtained from next_page_token field in the response of a ListExamples call.
6472 ///
6473 /// Sets the *page token* query property to the given value.
6474 pub fn page_token(mut self, new_value: &str) -> ProjectLocationDatasetExampleListCall<'a, C> {
6475 self._page_token = Some(new_value.to_string());
6476 self
6477 }
6478 /// Optional. Requested page size. The server can return fewer results than requested.
6479 ///
6480 /// Sets the *page size* query property to the given value.
6481 pub fn page_size(mut self, new_value: i32) -> ProjectLocationDatasetExampleListCall<'a, C> {
6482 self._page_size = Some(new_value);
6483 self
6484 }
6485 /// Optional. An expression for filtering the examples that will be returned. Example filter: * `usage=TRAIN`
6486 ///
6487 /// Sets the *filter* query property to the given value.
6488 pub fn filter(mut self, new_value: &str) -> ProjectLocationDatasetExampleListCall<'a, C> {
6489 self._filter = Some(new_value.to_string());
6490 self
6491 }
6492 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6493 /// while executing the actual API request.
6494 ///
6495 /// ````text
6496 /// It should be used to handle progress information, and to implement a certain level of resilience.
6497 /// ````
6498 ///
6499 /// Sets the *delegate* property to the given value.
6500 pub fn delegate(
6501 mut self,
6502 new_value: &'a mut dyn common::Delegate,
6503 ) -> ProjectLocationDatasetExampleListCall<'a, C> {
6504 self._delegate = Some(new_value);
6505 self
6506 }
6507
6508 /// Set any additional parameter of the query string used in the request.
6509 /// It should be used to set parameters which are not yet available through their own
6510 /// setters.
6511 ///
6512 /// Please note that this method must not be used to set any of the known parameters
6513 /// which have their own setter method. If done anyway, the request will fail.
6514 ///
6515 /// # Additional Parameters
6516 ///
6517 /// * *$.xgafv* (query-string) - V1 error format.
6518 /// * *access_token* (query-string) - OAuth access token.
6519 /// * *alt* (query-string) - Data format for response.
6520 /// * *callback* (query-string) - JSONP
6521 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6522 /// * *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.
6523 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6524 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6525 /// * *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.
6526 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6527 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6528 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationDatasetExampleListCall<'a, C>
6529 where
6530 T: AsRef<str>,
6531 {
6532 self._additional_params
6533 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6534 self
6535 }
6536
6537 /// Identifies the authorization scope for the method you are building.
6538 ///
6539 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6540 /// [`Scope::CloudPlatform`].
6541 ///
6542 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6543 /// tokens for more than one scope.
6544 ///
6545 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6546 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6547 /// sufficient, a read-write scope will do as well.
6548 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationDatasetExampleListCall<'a, C>
6549 where
6550 St: AsRef<str>,
6551 {
6552 self._scopes.insert(String::from(scope.as_ref()));
6553 self
6554 }
6555 /// Identifies the authorization scope(s) for the method you are building.
6556 ///
6557 /// See [`Self::add_scope()`] for details.
6558 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationDatasetExampleListCall<'a, C>
6559 where
6560 I: IntoIterator<Item = St>,
6561 St: AsRef<str>,
6562 {
6563 self._scopes
6564 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6565 self
6566 }
6567
6568 /// Removes all scopes, and no default scope will be used either.
6569 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6570 /// for details).
6571 pub fn clear_scopes(mut self) -> ProjectLocationDatasetExampleListCall<'a, C> {
6572 self._scopes.clear();
6573 self
6574 }
6575}
6576
6577/// Creates a Dataset.
6578///
6579/// A builder for the *locations.datasets.create* method supported by a *project* resource.
6580/// It is not used directly, but through a [`ProjectMethods`] instance.
6581///
6582/// # Example
6583///
6584/// Instantiate a resource method builder
6585///
6586/// ```test_harness,no_run
6587/// # extern crate hyper;
6588/// # extern crate hyper_rustls;
6589/// # extern crate google_translate3 as translate3;
6590/// use translate3::api::Dataset;
6591/// # async fn dox() {
6592/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6593///
6594/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6595/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6596/// # .with_native_roots()
6597/// # .unwrap()
6598/// # .https_only()
6599/// # .enable_http2()
6600/// # .build();
6601///
6602/// # let executor = hyper_util::rt::TokioExecutor::new();
6603/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6604/// # secret,
6605/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6606/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6607/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6608/// # ),
6609/// # ).build().await.unwrap();
6610///
6611/// # let client = hyper_util::client::legacy::Client::builder(
6612/// # hyper_util::rt::TokioExecutor::new()
6613/// # )
6614/// # .build(
6615/// # hyper_rustls::HttpsConnectorBuilder::new()
6616/// # .with_native_roots()
6617/// # .unwrap()
6618/// # .https_or_http()
6619/// # .enable_http2()
6620/// # .build()
6621/// # );
6622/// # let mut hub = Translate::new(client, auth);
6623/// // As the method needs a request, you would usually fill it with the desired information
6624/// // into the respective structure. Some of the parts shown here might not be applicable !
6625/// // Values shown here are possibly random and not representative !
6626/// let mut req = Dataset::default();
6627///
6628/// // You can configure optional parameters by calling the respective setters at will, and
6629/// // execute the final call using `doit()`.
6630/// // Values shown here are possibly random and not representative !
6631/// let result = hub.projects().locations_datasets_create(req, "parent")
6632/// .doit().await;
6633/// # }
6634/// ```
6635pub struct ProjectLocationDatasetCreateCall<'a, C>
6636where
6637 C: 'a,
6638{
6639 hub: &'a Translate<C>,
6640 _request: Dataset,
6641 _parent: String,
6642 _delegate: Option<&'a mut dyn common::Delegate>,
6643 _additional_params: HashMap<String, String>,
6644 _scopes: BTreeSet<String>,
6645}
6646
6647impl<'a, C> common::CallBuilder for ProjectLocationDatasetCreateCall<'a, C> {}
6648
6649impl<'a, C> ProjectLocationDatasetCreateCall<'a, C>
6650where
6651 C: common::Connector,
6652{
6653 /// Perform the operation you have build so far.
6654 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6655 use std::borrow::Cow;
6656 use std::io::{Read, Seek};
6657
6658 use common::{url::Params, ToParts};
6659 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6660
6661 let mut dd = common::DefaultDelegate;
6662 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6663 dlg.begin(common::MethodInfo {
6664 id: "translate.projects.locations.datasets.create",
6665 http_method: hyper::Method::POST,
6666 });
6667
6668 for &field in ["alt", "parent"].iter() {
6669 if self._additional_params.contains_key(field) {
6670 dlg.finished(false);
6671 return Err(common::Error::FieldClash(field));
6672 }
6673 }
6674
6675 let mut params = Params::with_capacity(4 + self._additional_params.len());
6676 params.push("parent", self._parent);
6677
6678 params.extend(self._additional_params.iter());
6679
6680 params.push("alt", "json");
6681 let mut url = self.hub._base_url.clone() + "v3/{+parent}/datasets";
6682 if self._scopes.is_empty() {
6683 self._scopes
6684 .insert(Scope::CloudPlatform.as_ref().to_string());
6685 }
6686
6687 #[allow(clippy::single_element_loop)]
6688 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6689 url = params.uri_replacement(url, param_name, find_this, true);
6690 }
6691 {
6692 let to_remove = ["parent"];
6693 params.remove_params(&to_remove);
6694 }
6695
6696 let url = params.parse_with_url(&url);
6697
6698 let mut json_mime_type = mime::APPLICATION_JSON;
6699 let mut request_value_reader = {
6700 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6701 common::remove_json_null_values(&mut value);
6702 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6703 serde_json::to_writer(&mut dst, &value).unwrap();
6704 dst
6705 };
6706 let request_size = request_value_reader
6707 .seek(std::io::SeekFrom::End(0))
6708 .unwrap();
6709 request_value_reader
6710 .seek(std::io::SeekFrom::Start(0))
6711 .unwrap();
6712
6713 loop {
6714 let token = match self
6715 .hub
6716 .auth
6717 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6718 .await
6719 {
6720 Ok(token) => token,
6721 Err(e) => match dlg.token(e) {
6722 Ok(token) => token,
6723 Err(e) => {
6724 dlg.finished(false);
6725 return Err(common::Error::MissingToken(e));
6726 }
6727 },
6728 };
6729 request_value_reader
6730 .seek(std::io::SeekFrom::Start(0))
6731 .unwrap();
6732 let mut req_result = {
6733 let client = &self.hub.client;
6734 dlg.pre_request();
6735 let mut req_builder = hyper::Request::builder()
6736 .method(hyper::Method::POST)
6737 .uri(url.as_str())
6738 .header(USER_AGENT, self.hub._user_agent.clone());
6739
6740 if let Some(token) = token.as_ref() {
6741 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6742 }
6743
6744 let request = req_builder
6745 .header(CONTENT_TYPE, json_mime_type.to_string())
6746 .header(CONTENT_LENGTH, request_size as u64)
6747 .body(common::to_body(
6748 request_value_reader.get_ref().clone().into(),
6749 ));
6750
6751 client.request(request.unwrap()).await
6752 };
6753
6754 match req_result {
6755 Err(err) => {
6756 if let common::Retry::After(d) = dlg.http_error(&err) {
6757 sleep(d).await;
6758 continue;
6759 }
6760 dlg.finished(false);
6761 return Err(common::Error::HttpError(err));
6762 }
6763 Ok(res) => {
6764 let (mut parts, body) = res.into_parts();
6765 let mut body = common::Body::new(body);
6766 if !parts.status.is_success() {
6767 let bytes = common::to_bytes(body).await.unwrap_or_default();
6768 let error = serde_json::from_str(&common::to_string(&bytes));
6769 let response = common::to_response(parts, bytes.into());
6770
6771 if let common::Retry::After(d) =
6772 dlg.http_failure(&response, error.as_ref().ok())
6773 {
6774 sleep(d).await;
6775 continue;
6776 }
6777
6778 dlg.finished(false);
6779
6780 return Err(match error {
6781 Ok(value) => common::Error::BadRequest(value),
6782 _ => common::Error::Failure(response),
6783 });
6784 }
6785 let response = {
6786 let bytes = common::to_bytes(body).await.unwrap_or_default();
6787 let encoded = common::to_string(&bytes);
6788 match serde_json::from_str(&encoded) {
6789 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6790 Err(error) => {
6791 dlg.response_json_decode_error(&encoded, &error);
6792 return Err(common::Error::JsonDecodeError(
6793 encoded.to_string(),
6794 error,
6795 ));
6796 }
6797 }
6798 };
6799
6800 dlg.finished(true);
6801 return Ok(response);
6802 }
6803 }
6804 }
6805 }
6806
6807 ///
6808 /// Sets the *request* property to the given value.
6809 ///
6810 /// Even though the property as already been set when instantiating this call,
6811 /// we provide this method for API completeness.
6812 pub fn request(mut self, new_value: Dataset) -> ProjectLocationDatasetCreateCall<'a, C> {
6813 self._request = new_value;
6814 self
6815 }
6816 /// Required. The project name.
6817 ///
6818 /// Sets the *parent* path property to the given value.
6819 ///
6820 /// Even though the property as already been set when instantiating this call,
6821 /// we provide this method for API completeness.
6822 pub fn parent(mut self, new_value: &str) -> ProjectLocationDatasetCreateCall<'a, C> {
6823 self._parent = new_value.to_string();
6824 self
6825 }
6826 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6827 /// while executing the actual API request.
6828 ///
6829 /// ````text
6830 /// It should be used to handle progress information, and to implement a certain level of resilience.
6831 /// ````
6832 ///
6833 /// Sets the *delegate* property to the given value.
6834 pub fn delegate(
6835 mut self,
6836 new_value: &'a mut dyn common::Delegate,
6837 ) -> ProjectLocationDatasetCreateCall<'a, C> {
6838 self._delegate = Some(new_value);
6839 self
6840 }
6841
6842 /// Set any additional parameter of the query string used in the request.
6843 /// It should be used to set parameters which are not yet available through their own
6844 /// setters.
6845 ///
6846 /// Please note that this method must not be used to set any of the known parameters
6847 /// which have their own setter method. If done anyway, the request will fail.
6848 ///
6849 /// # Additional Parameters
6850 ///
6851 /// * *$.xgafv* (query-string) - V1 error format.
6852 /// * *access_token* (query-string) - OAuth access token.
6853 /// * *alt* (query-string) - Data format for response.
6854 /// * *callback* (query-string) - JSONP
6855 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6856 /// * *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.
6857 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6858 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6859 /// * *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.
6860 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6861 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6862 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationDatasetCreateCall<'a, C>
6863 where
6864 T: AsRef<str>,
6865 {
6866 self._additional_params
6867 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6868 self
6869 }
6870
6871 /// Identifies the authorization scope for the method you are building.
6872 ///
6873 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6874 /// [`Scope::CloudPlatform`].
6875 ///
6876 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6877 /// tokens for more than one scope.
6878 ///
6879 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6880 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6881 /// sufficient, a read-write scope will do as well.
6882 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationDatasetCreateCall<'a, C>
6883 where
6884 St: AsRef<str>,
6885 {
6886 self._scopes.insert(String::from(scope.as_ref()));
6887 self
6888 }
6889 /// Identifies the authorization scope(s) for the method you are building.
6890 ///
6891 /// See [`Self::add_scope()`] for details.
6892 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationDatasetCreateCall<'a, C>
6893 where
6894 I: IntoIterator<Item = St>,
6895 St: AsRef<str>,
6896 {
6897 self._scopes
6898 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6899 self
6900 }
6901
6902 /// Removes all scopes, and no default scope will be used either.
6903 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6904 /// for details).
6905 pub fn clear_scopes(mut self) -> ProjectLocationDatasetCreateCall<'a, C> {
6906 self._scopes.clear();
6907 self
6908 }
6909}
6910
6911/// Deletes a dataset and all of its contents.
6912///
6913/// A builder for the *locations.datasets.delete* method supported by a *project* resource.
6914/// It is not used directly, but through a [`ProjectMethods`] instance.
6915///
6916/// # Example
6917///
6918/// Instantiate a resource method builder
6919///
6920/// ```test_harness,no_run
6921/// # extern crate hyper;
6922/// # extern crate hyper_rustls;
6923/// # extern crate google_translate3 as translate3;
6924/// # async fn dox() {
6925/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6926///
6927/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6928/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6929/// # .with_native_roots()
6930/// # .unwrap()
6931/// # .https_only()
6932/// # .enable_http2()
6933/// # .build();
6934///
6935/// # let executor = hyper_util::rt::TokioExecutor::new();
6936/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6937/// # secret,
6938/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6939/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6940/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6941/// # ),
6942/// # ).build().await.unwrap();
6943///
6944/// # let client = hyper_util::client::legacy::Client::builder(
6945/// # hyper_util::rt::TokioExecutor::new()
6946/// # )
6947/// # .build(
6948/// # hyper_rustls::HttpsConnectorBuilder::new()
6949/// # .with_native_roots()
6950/// # .unwrap()
6951/// # .https_or_http()
6952/// # .enable_http2()
6953/// # .build()
6954/// # );
6955/// # let mut hub = Translate::new(client, auth);
6956/// // You can configure optional parameters by calling the respective setters at will, and
6957/// // execute the final call using `doit()`.
6958/// // Values shown here are possibly random and not representative !
6959/// let result = hub.projects().locations_datasets_delete("name")
6960/// .doit().await;
6961/// # }
6962/// ```
6963pub struct ProjectLocationDatasetDeleteCall<'a, C>
6964where
6965 C: 'a,
6966{
6967 hub: &'a Translate<C>,
6968 _name: String,
6969 _delegate: Option<&'a mut dyn common::Delegate>,
6970 _additional_params: HashMap<String, String>,
6971 _scopes: BTreeSet<String>,
6972}
6973
6974impl<'a, C> common::CallBuilder for ProjectLocationDatasetDeleteCall<'a, C> {}
6975
6976impl<'a, C> ProjectLocationDatasetDeleteCall<'a, C>
6977where
6978 C: common::Connector,
6979{
6980 /// Perform the operation you have build so far.
6981 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6982 use std::borrow::Cow;
6983 use std::io::{Read, Seek};
6984
6985 use common::{url::Params, ToParts};
6986 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6987
6988 let mut dd = common::DefaultDelegate;
6989 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6990 dlg.begin(common::MethodInfo {
6991 id: "translate.projects.locations.datasets.delete",
6992 http_method: hyper::Method::DELETE,
6993 });
6994
6995 for &field in ["alt", "name"].iter() {
6996 if self._additional_params.contains_key(field) {
6997 dlg.finished(false);
6998 return Err(common::Error::FieldClash(field));
6999 }
7000 }
7001
7002 let mut params = Params::with_capacity(3 + self._additional_params.len());
7003 params.push("name", self._name);
7004
7005 params.extend(self._additional_params.iter());
7006
7007 params.push("alt", "json");
7008 let mut url = self.hub._base_url.clone() + "v3/{+name}";
7009 if self._scopes.is_empty() {
7010 self._scopes
7011 .insert(Scope::CloudPlatform.as_ref().to_string());
7012 }
7013
7014 #[allow(clippy::single_element_loop)]
7015 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7016 url = params.uri_replacement(url, param_name, find_this, true);
7017 }
7018 {
7019 let to_remove = ["name"];
7020 params.remove_params(&to_remove);
7021 }
7022
7023 let url = params.parse_with_url(&url);
7024
7025 loop {
7026 let token = match self
7027 .hub
7028 .auth
7029 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7030 .await
7031 {
7032 Ok(token) => token,
7033 Err(e) => match dlg.token(e) {
7034 Ok(token) => token,
7035 Err(e) => {
7036 dlg.finished(false);
7037 return Err(common::Error::MissingToken(e));
7038 }
7039 },
7040 };
7041 let mut req_result = {
7042 let client = &self.hub.client;
7043 dlg.pre_request();
7044 let mut req_builder = hyper::Request::builder()
7045 .method(hyper::Method::DELETE)
7046 .uri(url.as_str())
7047 .header(USER_AGENT, self.hub._user_agent.clone());
7048
7049 if let Some(token) = token.as_ref() {
7050 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7051 }
7052
7053 let request = req_builder
7054 .header(CONTENT_LENGTH, 0_u64)
7055 .body(common::to_body::<String>(None));
7056
7057 client.request(request.unwrap()).await
7058 };
7059
7060 match req_result {
7061 Err(err) => {
7062 if let common::Retry::After(d) = dlg.http_error(&err) {
7063 sleep(d).await;
7064 continue;
7065 }
7066 dlg.finished(false);
7067 return Err(common::Error::HttpError(err));
7068 }
7069 Ok(res) => {
7070 let (mut parts, body) = res.into_parts();
7071 let mut body = common::Body::new(body);
7072 if !parts.status.is_success() {
7073 let bytes = common::to_bytes(body).await.unwrap_or_default();
7074 let error = serde_json::from_str(&common::to_string(&bytes));
7075 let response = common::to_response(parts, bytes.into());
7076
7077 if let common::Retry::After(d) =
7078 dlg.http_failure(&response, error.as_ref().ok())
7079 {
7080 sleep(d).await;
7081 continue;
7082 }
7083
7084 dlg.finished(false);
7085
7086 return Err(match error {
7087 Ok(value) => common::Error::BadRequest(value),
7088 _ => common::Error::Failure(response),
7089 });
7090 }
7091 let response = {
7092 let bytes = common::to_bytes(body).await.unwrap_or_default();
7093 let encoded = common::to_string(&bytes);
7094 match serde_json::from_str(&encoded) {
7095 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7096 Err(error) => {
7097 dlg.response_json_decode_error(&encoded, &error);
7098 return Err(common::Error::JsonDecodeError(
7099 encoded.to_string(),
7100 error,
7101 ));
7102 }
7103 }
7104 };
7105
7106 dlg.finished(true);
7107 return Ok(response);
7108 }
7109 }
7110 }
7111 }
7112
7113 /// Required. The name of the dataset to delete.
7114 ///
7115 /// Sets the *name* path property to the given value.
7116 ///
7117 /// Even though the property as already been set when instantiating this call,
7118 /// we provide this method for API completeness.
7119 pub fn name(mut self, new_value: &str) -> ProjectLocationDatasetDeleteCall<'a, C> {
7120 self._name = new_value.to_string();
7121 self
7122 }
7123 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7124 /// while executing the actual API request.
7125 ///
7126 /// ````text
7127 /// It should be used to handle progress information, and to implement a certain level of resilience.
7128 /// ````
7129 ///
7130 /// Sets the *delegate* property to the given value.
7131 pub fn delegate(
7132 mut self,
7133 new_value: &'a mut dyn common::Delegate,
7134 ) -> ProjectLocationDatasetDeleteCall<'a, C> {
7135 self._delegate = Some(new_value);
7136 self
7137 }
7138
7139 /// Set any additional parameter of the query string used in the request.
7140 /// It should be used to set parameters which are not yet available through their own
7141 /// setters.
7142 ///
7143 /// Please note that this method must not be used to set any of the known parameters
7144 /// which have their own setter method. If done anyway, the request will fail.
7145 ///
7146 /// # Additional Parameters
7147 ///
7148 /// * *$.xgafv* (query-string) - V1 error format.
7149 /// * *access_token* (query-string) - OAuth access token.
7150 /// * *alt* (query-string) - Data format for response.
7151 /// * *callback* (query-string) - JSONP
7152 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7153 /// * *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.
7154 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7155 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7156 /// * *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.
7157 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7158 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7159 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationDatasetDeleteCall<'a, C>
7160 where
7161 T: AsRef<str>,
7162 {
7163 self._additional_params
7164 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7165 self
7166 }
7167
7168 /// Identifies the authorization scope for the method you are building.
7169 ///
7170 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7171 /// [`Scope::CloudPlatform`].
7172 ///
7173 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7174 /// tokens for more than one scope.
7175 ///
7176 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7177 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7178 /// sufficient, a read-write scope will do as well.
7179 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationDatasetDeleteCall<'a, C>
7180 where
7181 St: AsRef<str>,
7182 {
7183 self._scopes.insert(String::from(scope.as_ref()));
7184 self
7185 }
7186 /// Identifies the authorization scope(s) for the method you are building.
7187 ///
7188 /// See [`Self::add_scope()`] for details.
7189 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationDatasetDeleteCall<'a, C>
7190 where
7191 I: IntoIterator<Item = St>,
7192 St: AsRef<str>,
7193 {
7194 self._scopes
7195 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7196 self
7197 }
7198
7199 /// Removes all scopes, and no default scope will be used either.
7200 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7201 /// for details).
7202 pub fn clear_scopes(mut self) -> ProjectLocationDatasetDeleteCall<'a, C> {
7203 self._scopes.clear();
7204 self
7205 }
7206}
7207
7208/// Exports dataset's data to the provided output location.
7209///
7210/// A builder for the *locations.datasets.exportData* method supported by a *project* resource.
7211/// It is not used directly, but through a [`ProjectMethods`] instance.
7212///
7213/// # Example
7214///
7215/// Instantiate a resource method builder
7216///
7217/// ```test_harness,no_run
7218/// # extern crate hyper;
7219/// # extern crate hyper_rustls;
7220/// # extern crate google_translate3 as translate3;
7221/// use translate3::api::ExportDataRequest;
7222/// # async fn dox() {
7223/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7224///
7225/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7226/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7227/// # .with_native_roots()
7228/// # .unwrap()
7229/// # .https_only()
7230/// # .enable_http2()
7231/// # .build();
7232///
7233/// # let executor = hyper_util::rt::TokioExecutor::new();
7234/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7235/// # secret,
7236/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7237/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7238/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7239/// # ),
7240/// # ).build().await.unwrap();
7241///
7242/// # let client = hyper_util::client::legacy::Client::builder(
7243/// # hyper_util::rt::TokioExecutor::new()
7244/// # )
7245/// # .build(
7246/// # hyper_rustls::HttpsConnectorBuilder::new()
7247/// # .with_native_roots()
7248/// # .unwrap()
7249/// # .https_or_http()
7250/// # .enable_http2()
7251/// # .build()
7252/// # );
7253/// # let mut hub = Translate::new(client, auth);
7254/// // As the method needs a request, you would usually fill it with the desired information
7255/// // into the respective structure. Some of the parts shown here might not be applicable !
7256/// // Values shown here are possibly random and not representative !
7257/// let mut req = ExportDataRequest::default();
7258///
7259/// // You can configure optional parameters by calling the respective setters at will, and
7260/// // execute the final call using `doit()`.
7261/// // Values shown here are possibly random and not representative !
7262/// let result = hub.projects().locations_datasets_export_data(req, "dataset")
7263/// .doit().await;
7264/// # }
7265/// ```
7266pub struct ProjectLocationDatasetExportDataCall<'a, C>
7267where
7268 C: 'a,
7269{
7270 hub: &'a Translate<C>,
7271 _request: ExportDataRequest,
7272 _dataset: String,
7273 _delegate: Option<&'a mut dyn common::Delegate>,
7274 _additional_params: HashMap<String, String>,
7275 _scopes: BTreeSet<String>,
7276}
7277
7278impl<'a, C> common::CallBuilder for ProjectLocationDatasetExportDataCall<'a, C> {}
7279
7280impl<'a, C> ProjectLocationDatasetExportDataCall<'a, C>
7281where
7282 C: common::Connector,
7283{
7284 /// Perform the operation you have build so far.
7285 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
7286 use std::borrow::Cow;
7287 use std::io::{Read, Seek};
7288
7289 use common::{url::Params, ToParts};
7290 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7291
7292 let mut dd = common::DefaultDelegate;
7293 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7294 dlg.begin(common::MethodInfo {
7295 id: "translate.projects.locations.datasets.exportData",
7296 http_method: hyper::Method::POST,
7297 });
7298
7299 for &field in ["alt", "dataset"].iter() {
7300 if self._additional_params.contains_key(field) {
7301 dlg.finished(false);
7302 return Err(common::Error::FieldClash(field));
7303 }
7304 }
7305
7306 let mut params = Params::with_capacity(4 + self._additional_params.len());
7307 params.push("dataset", self._dataset);
7308
7309 params.extend(self._additional_params.iter());
7310
7311 params.push("alt", "json");
7312 let mut url = self.hub._base_url.clone() + "v3/{+dataset}:exportData";
7313 if self._scopes.is_empty() {
7314 self._scopes
7315 .insert(Scope::CloudPlatform.as_ref().to_string());
7316 }
7317
7318 #[allow(clippy::single_element_loop)]
7319 for &(find_this, param_name) in [("{+dataset}", "dataset")].iter() {
7320 url = params.uri_replacement(url, param_name, find_this, true);
7321 }
7322 {
7323 let to_remove = ["dataset"];
7324 params.remove_params(&to_remove);
7325 }
7326
7327 let url = params.parse_with_url(&url);
7328
7329 let mut json_mime_type = mime::APPLICATION_JSON;
7330 let mut request_value_reader = {
7331 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7332 common::remove_json_null_values(&mut value);
7333 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7334 serde_json::to_writer(&mut dst, &value).unwrap();
7335 dst
7336 };
7337 let request_size = request_value_reader
7338 .seek(std::io::SeekFrom::End(0))
7339 .unwrap();
7340 request_value_reader
7341 .seek(std::io::SeekFrom::Start(0))
7342 .unwrap();
7343
7344 loop {
7345 let token = match self
7346 .hub
7347 .auth
7348 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7349 .await
7350 {
7351 Ok(token) => token,
7352 Err(e) => match dlg.token(e) {
7353 Ok(token) => token,
7354 Err(e) => {
7355 dlg.finished(false);
7356 return Err(common::Error::MissingToken(e));
7357 }
7358 },
7359 };
7360 request_value_reader
7361 .seek(std::io::SeekFrom::Start(0))
7362 .unwrap();
7363 let mut req_result = {
7364 let client = &self.hub.client;
7365 dlg.pre_request();
7366 let mut req_builder = hyper::Request::builder()
7367 .method(hyper::Method::POST)
7368 .uri(url.as_str())
7369 .header(USER_AGENT, self.hub._user_agent.clone());
7370
7371 if let Some(token) = token.as_ref() {
7372 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7373 }
7374
7375 let request = req_builder
7376 .header(CONTENT_TYPE, json_mime_type.to_string())
7377 .header(CONTENT_LENGTH, request_size as u64)
7378 .body(common::to_body(
7379 request_value_reader.get_ref().clone().into(),
7380 ));
7381
7382 client.request(request.unwrap()).await
7383 };
7384
7385 match req_result {
7386 Err(err) => {
7387 if let common::Retry::After(d) = dlg.http_error(&err) {
7388 sleep(d).await;
7389 continue;
7390 }
7391 dlg.finished(false);
7392 return Err(common::Error::HttpError(err));
7393 }
7394 Ok(res) => {
7395 let (mut parts, body) = res.into_parts();
7396 let mut body = common::Body::new(body);
7397 if !parts.status.is_success() {
7398 let bytes = common::to_bytes(body).await.unwrap_or_default();
7399 let error = serde_json::from_str(&common::to_string(&bytes));
7400 let response = common::to_response(parts, bytes.into());
7401
7402 if let common::Retry::After(d) =
7403 dlg.http_failure(&response, error.as_ref().ok())
7404 {
7405 sleep(d).await;
7406 continue;
7407 }
7408
7409 dlg.finished(false);
7410
7411 return Err(match error {
7412 Ok(value) => common::Error::BadRequest(value),
7413 _ => common::Error::Failure(response),
7414 });
7415 }
7416 let response = {
7417 let bytes = common::to_bytes(body).await.unwrap_or_default();
7418 let encoded = common::to_string(&bytes);
7419 match serde_json::from_str(&encoded) {
7420 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7421 Err(error) => {
7422 dlg.response_json_decode_error(&encoded, &error);
7423 return Err(common::Error::JsonDecodeError(
7424 encoded.to_string(),
7425 error,
7426 ));
7427 }
7428 }
7429 };
7430
7431 dlg.finished(true);
7432 return Ok(response);
7433 }
7434 }
7435 }
7436 }
7437
7438 ///
7439 /// Sets the *request* property to the given value.
7440 ///
7441 /// Even though the property as already been set when instantiating this call,
7442 /// we provide this method for API completeness.
7443 pub fn request(
7444 mut self,
7445 new_value: ExportDataRequest,
7446 ) -> ProjectLocationDatasetExportDataCall<'a, C> {
7447 self._request = new_value;
7448 self
7449 }
7450 /// Required. Name of the dataset. In form of `projects/{project-number-or-id}/locations/{location-id}/datasets/{dataset-id}`
7451 ///
7452 /// Sets the *dataset* path property to the given value.
7453 ///
7454 /// Even though the property as already been set when instantiating this call,
7455 /// we provide this method for API completeness.
7456 pub fn dataset(mut self, new_value: &str) -> ProjectLocationDatasetExportDataCall<'a, C> {
7457 self._dataset = new_value.to_string();
7458 self
7459 }
7460 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7461 /// while executing the actual API request.
7462 ///
7463 /// ````text
7464 /// It should be used to handle progress information, and to implement a certain level of resilience.
7465 /// ````
7466 ///
7467 /// Sets the *delegate* property to the given value.
7468 pub fn delegate(
7469 mut self,
7470 new_value: &'a mut dyn common::Delegate,
7471 ) -> ProjectLocationDatasetExportDataCall<'a, C> {
7472 self._delegate = Some(new_value);
7473 self
7474 }
7475
7476 /// Set any additional parameter of the query string used in the request.
7477 /// It should be used to set parameters which are not yet available through their own
7478 /// setters.
7479 ///
7480 /// Please note that this method must not be used to set any of the known parameters
7481 /// which have their own setter method. If done anyway, the request will fail.
7482 ///
7483 /// # Additional Parameters
7484 ///
7485 /// * *$.xgafv* (query-string) - V1 error format.
7486 /// * *access_token* (query-string) - OAuth access token.
7487 /// * *alt* (query-string) - Data format for response.
7488 /// * *callback* (query-string) - JSONP
7489 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7490 /// * *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.
7491 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7492 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7493 /// * *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.
7494 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7495 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7496 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationDatasetExportDataCall<'a, C>
7497 where
7498 T: AsRef<str>,
7499 {
7500 self._additional_params
7501 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7502 self
7503 }
7504
7505 /// Identifies the authorization scope for the method you are building.
7506 ///
7507 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7508 /// [`Scope::CloudPlatform`].
7509 ///
7510 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7511 /// tokens for more than one scope.
7512 ///
7513 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7514 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7515 /// sufficient, a read-write scope will do as well.
7516 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationDatasetExportDataCall<'a, C>
7517 where
7518 St: AsRef<str>,
7519 {
7520 self._scopes.insert(String::from(scope.as_ref()));
7521 self
7522 }
7523 /// Identifies the authorization scope(s) for the method you are building.
7524 ///
7525 /// See [`Self::add_scope()`] for details.
7526 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationDatasetExportDataCall<'a, C>
7527 where
7528 I: IntoIterator<Item = St>,
7529 St: AsRef<str>,
7530 {
7531 self._scopes
7532 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7533 self
7534 }
7535
7536 /// Removes all scopes, and no default scope will be used either.
7537 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7538 /// for details).
7539 pub fn clear_scopes(mut self) -> ProjectLocationDatasetExportDataCall<'a, C> {
7540 self._scopes.clear();
7541 self
7542 }
7543}
7544
7545/// Gets a Dataset.
7546///
7547/// A builder for the *locations.datasets.get* method supported by a *project* resource.
7548/// It is not used directly, but through a [`ProjectMethods`] instance.
7549///
7550/// # Example
7551///
7552/// Instantiate a resource method builder
7553///
7554/// ```test_harness,no_run
7555/// # extern crate hyper;
7556/// # extern crate hyper_rustls;
7557/// # extern crate google_translate3 as translate3;
7558/// # async fn dox() {
7559/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7560///
7561/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7562/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7563/// # .with_native_roots()
7564/// # .unwrap()
7565/// # .https_only()
7566/// # .enable_http2()
7567/// # .build();
7568///
7569/// # let executor = hyper_util::rt::TokioExecutor::new();
7570/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7571/// # secret,
7572/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7573/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7574/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7575/// # ),
7576/// # ).build().await.unwrap();
7577///
7578/// # let client = hyper_util::client::legacy::Client::builder(
7579/// # hyper_util::rt::TokioExecutor::new()
7580/// # )
7581/// # .build(
7582/// # hyper_rustls::HttpsConnectorBuilder::new()
7583/// # .with_native_roots()
7584/// # .unwrap()
7585/// # .https_or_http()
7586/// # .enable_http2()
7587/// # .build()
7588/// # );
7589/// # let mut hub = Translate::new(client, auth);
7590/// // You can configure optional parameters by calling the respective setters at will, and
7591/// // execute the final call using `doit()`.
7592/// // Values shown here are possibly random and not representative !
7593/// let result = hub.projects().locations_datasets_get("name")
7594/// .doit().await;
7595/// # }
7596/// ```
7597pub struct ProjectLocationDatasetGetCall<'a, C>
7598where
7599 C: 'a,
7600{
7601 hub: &'a Translate<C>,
7602 _name: String,
7603 _delegate: Option<&'a mut dyn common::Delegate>,
7604 _additional_params: HashMap<String, String>,
7605 _scopes: BTreeSet<String>,
7606}
7607
7608impl<'a, C> common::CallBuilder for ProjectLocationDatasetGetCall<'a, C> {}
7609
7610impl<'a, C> ProjectLocationDatasetGetCall<'a, C>
7611where
7612 C: common::Connector,
7613{
7614 /// Perform the operation you have build so far.
7615 pub async fn doit(mut self) -> common::Result<(common::Response, Dataset)> {
7616 use std::borrow::Cow;
7617 use std::io::{Read, Seek};
7618
7619 use common::{url::Params, ToParts};
7620 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7621
7622 let mut dd = common::DefaultDelegate;
7623 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7624 dlg.begin(common::MethodInfo {
7625 id: "translate.projects.locations.datasets.get",
7626 http_method: hyper::Method::GET,
7627 });
7628
7629 for &field in ["alt", "name"].iter() {
7630 if self._additional_params.contains_key(field) {
7631 dlg.finished(false);
7632 return Err(common::Error::FieldClash(field));
7633 }
7634 }
7635
7636 let mut params = Params::with_capacity(3 + self._additional_params.len());
7637 params.push("name", self._name);
7638
7639 params.extend(self._additional_params.iter());
7640
7641 params.push("alt", "json");
7642 let mut url = self.hub._base_url.clone() + "v3/{+name}";
7643 if self._scopes.is_empty() {
7644 self._scopes
7645 .insert(Scope::CloudPlatform.as_ref().to_string());
7646 }
7647
7648 #[allow(clippy::single_element_loop)]
7649 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7650 url = params.uri_replacement(url, param_name, find_this, true);
7651 }
7652 {
7653 let to_remove = ["name"];
7654 params.remove_params(&to_remove);
7655 }
7656
7657 let url = params.parse_with_url(&url);
7658
7659 loop {
7660 let token = match self
7661 .hub
7662 .auth
7663 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7664 .await
7665 {
7666 Ok(token) => token,
7667 Err(e) => match dlg.token(e) {
7668 Ok(token) => token,
7669 Err(e) => {
7670 dlg.finished(false);
7671 return Err(common::Error::MissingToken(e));
7672 }
7673 },
7674 };
7675 let mut req_result = {
7676 let client = &self.hub.client;
7677 dlg.pre_request();
7678 let mut req_builder = hyper::Request::builder()
7679 .method(hyper::Method::GET)
7680 .uri(url.as_str())
7681 .header(USER_AGENT, self.hub._user_agent.clone());
7682
7683 if let Some(token) = token.as_ref() {
7684 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7685 }
7686
7687 let request = req_builder
7688 .header(CONTENT_LENGTH, 0_u64)
7689 .body(common::to_body::<String>(None));
7690
7691 client.request(request.unwrap()).await
7692 };
7693
7694 match req_result {
7695 Err(err) => {
7696 if let common::Retry::After(d) = dlg.http_error(&err) {
7697 sleep(d).await;
7698 continue;
7699 }
7700 dlg.finished(false);
7701 return Err(common::Error::HttpError(err));
7702 }
7703 Ok(res) => {
7704 let (mut parts, body) = res.into_parts();
7705 let mut body = common::Body::new(body);
7706 if !parts.status.is_success() {
7707 let bytes = common::to_bytes(body).await.unwrap_or_default();
7708 let error = serde_json::from_str(&common::to_string(&bytes));
7709 let response = common::to_response(parts, bytes.into());
7710
7711 if let common::Retry::After(d) =
7712 dlg.http_failure(&response, error.as_ref().ok())
7713 {
7714 sleep(d).await;
7715 continue;
7716 }
7717
7718 dlg.finished(false);
7719
7720 return Err(match error {
7721 Ok(value) => common::Error::BadRequest(value),
7722 _ => common::Error::Failure(response),
7723 });
7724 }
7725 let response = {
7726 let bytes = common::to_bytes(body).await.unwrap_or_default();
7727 let encoded = common::to_string(&bytes);
7728 match serde_json::from_str(&encoded) {
7729 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7730 Err(error) => {
7731 dlg.response_json_decode_error(&encoded, &error);
7732 return Err(common::Error::JsonDecodeError(
7733 encoded.to_string(),
7734 error,
7735 ));
7736 }
7737 }
7738 };
7739
7740 dlg.finished(true);
7741 return Ok(response);
7742 }
7743 }
7744 }
7745 }
7746
7747 /// Required. The resource name of the dataset to retrieve.
7748 ///
7749 /// Sets the *name* path property to the given value.
7750 ///
7751 /// Even though the property as already been set when instantiating this call,
7752 /// we provide this method for API completeness.
7753 pub fn name(mut self, new_value: &str) -> ProjectLocationDatasetGetCall<'a, C> {
7754 self._name = new_value.to_string();
7755 self
7756 }
7757 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7758 /// while executing the actual API request.
7759 ///
7760 /// ````text
7761 /// It should be used to handle progress information, and to implement a certain level of resilience.
7762 /// ````
7763 ///
7764 /// Sets the *delegate* property to the given value.
7765 pub fn delegate(
7766 mut self,
7767 new_value: &'a mut dyn common::Delegate,
7768 ) -> ProjectLocationDatasetGetCall<'a, C> {
7769 self._delegate = Some(new_value);
7770 self
7771 }
7772
7773 /// Set any additional parameter of the query string used in the request.
7774 /// It should be used to set parameters which are not yet available through their own
7775 /// setters.
7776 ///
7777 /// Please note that this method must not be used to set any of the known parameters
7778 /// which have their own setter method. If done anyway, the request will fail.
7779 ///
7780 /// # Additional Parameters
7781 ///
7782 /// * *$.xgafv* (query-string) - V1 error format.
7783 /// * *access_token* (query-string) - OAuth access token.
7784 /// * *alt* (query-string) - Data format for response.
7785 /// * *callback* (query-string) - JSONP
7786 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7787 /// * *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.
7788 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7789 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7790 /// * *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.
7791 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7792 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7793 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationDatasetGetCall<'a, C>
7794 where
7795 T: AsRef<str>,
7796 {
7797 self._additional_params
7798 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7799 self
7800 }
7801
7802 /// Identifies the authorization scope for the method you are building.
7803 ///
7804 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7805 /// [`Scope::CloudPlatform`].
7806 ///
7807 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7808 /// tokens for more than one scope.
7809 ///
7810 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7811 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7812 /// sufficient, a read-write scope will do as well.
7813 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationDatasetGetCall<'a, C>
7814 where
7815 St: AsRef<str>,
7816 {
7817 self._scopes.insert(String::from(scope.as_ref()));
7818 self
7819 }
7820 /// Identifies the authorization scope(s) for the method you are building.
7821 ///
7822 /// See [`Self::add_scope()`] for details.
7823 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationDatasetGetCall<'a, C>
7824 where
7825 I: IntoIterator<Item = St>,
7826 St: AsRef<str>,
7827 {
7828 self._scopes
7829 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7830 self
7831 }
7832
7833 /// Removes all scopes, and no default scope will be used either.
7834 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7835 /// for details).
7836 pub fn clear_scopes(mut self) -> ProjectLocationDatasetGetCall<'a, C> {
7837 self._scopes.clear();
7838 self
7839 }
7840}
7841
7842/// Import sentence pairs into translation Dataset.
7843///
7844/// A builder for the *locations.datasets.importData* method supported by a *project* resource.
7845/// It is not used directly, but through a [`ProjectMethods`] instance.
7846///
7847/// # Example
7848///
7849/// Instantiate a resource method builder
7850///
7851/// ```test_harness,no_run
7852/// # extern crate hyper;
7853/// # extern crate hyper_rustls;
7854/// # extern crate google_translate3 as translate3;
7855/// use translate3::api::ImportDataRequest;
7856/// # async fn dox() {
7857/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7858///
7859/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7860/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7861/// # .with_native_roots()
7862/// # .unwrap()
7863/// # .https_only()
7864/// # .enable_http2()
7865/// # .build();
7866///
7867/// # let executor = hyper_util::rt::TokioExecutor::new();
7868/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7869/// # secret,
7870/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7871/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7872/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7873/// # ),
7874/// # ).build().await.unwrap();
7875///
7876/// # let client = hyper_util::client::legacy::Client::builder(
7877/// # hyper_util::rt::TokioExecutor::new()
7878/// # )
7879/// # .build(
7880/// # hyper_rustls::HttpsConnectorBuilder::new()
7881/// # .with_native_roots()
7882/// # .unwrap()
7883/// # .https_or_http()
7884/// # .enable_http2()
7885/// # .build()
7886/// # );
7887/// # let mut hub = Translate::new(client, auth);
7888/// // As the method needs a request, you would usually fill it with the desired information
7889/// // into the respective structure. Some of the parts shown here might not be applicable !
7890/// // Values shown here are possibly random and not representative !
7891/// let mut req = ImportDataRequest::default();
7892///
7893/// // You can configure optional parameters by calling the respective setters at will, and
7894/// // execute the final call using `doit()`.
7895/// // Values shown here are possibly random and not representative !
7896/// let result = hub.projects().locations_datasets_import_data(req, "dataset")
7897/// .doit().await;
7898/// # }
7899/// ```
7900pub struct ProjectLocationDatasetImportDataCall<'a, C>
7901where
7902 C: 'a,
7903{
7904 hub: &'a Translate<C>,
7905 _request: ImportDataRequest,
7906 _dataset: String,
7907 _delegate: Option<&'a mut dyn common::Delegate>,
7908 _additional_params: HashMap<String, String>,
7909 _scopes: BTreeSet<String>,
7910}
7911
7912impl<'a, C> common::CallBuilder for ProjectLocationDatasetImportDataCall<'a, C> {}
7913
7914impl<'a, C> ProjectLocationDatasetImportDataCall<'a, C>
7915where
7916 C: common::Connector,
7917{
7918 /// Perform the operation you have build so far.
7919 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
7920 use std::borrow::Cow;
7921 use std::io::{Read, Seek};
7922
7923 use common::{url::Params, ToParts};
7924 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7925
7926 let mut dd = common::DefaultDelegate;
7927 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7928 dlg.begin(common::MethodInfo {
7929 id: "translate.projects.locations.datasets.importData",
7930 http_method: hyper::Method::POST,
7931 });
7932
7933 for &field in ["alt", "dataset"].iter() {
7934 if self._additional_params.contains_key(field) {
7935 dlg.finished(false);
7936 return Err(common::Error::FieldClash(field));
7937 }
7938 }
7939
7940 let mut params = Params::with_capacity(4 + self._additional_params.len());
7941 params.push("dataset", self._dataset);
7942
7943 params.extend(self._additional_params.iter());
7944
7945 params.push("alt", "json");
7946 let mut url = self.hub._base_url.clone() + "v3/{+dataset}:importData";
7947 if self._scopes.is_empty() {
7948 self._scopes
7949 .insert(Scope::CloudPlatform.as_ref().to_string());
7950 }
7951
7952 #[allow(clippy::single_element_loop)]
7953 for &(find_this, param_name) in [("{+dataset}", "dataset")].iter() {
7954 url = params.uri_replacement(url, param_name, find_this, true);
7955 }
7956 {
7957 let to_remove = ["dataset"];
7958 params.remove_params(&to_remove);
7959 }
7960
7961 let url = params.parse_with_url(&url);
7962
7963 let mut json_mime_type = mime::APPLICATION_JSON;
7964 let mut request_value_reader = {
7965 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7966 common::remove_json_null_values(&mut value);
7967 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7968 serde_json::to_writer(&mut dst, &value).unwrap();
7969 dst
7970 };
7971 let request_size = request_value_reader
7972 .seek(std::io::SeekFrom::End(0))
7973 .unwrap();
7974 request_value_reader
7975 .seek(std::io::SeekFrom::Start(0))
7976 .unwrap();
7977
7978 loop {
7979 let token = match self
7980 .hub
7981 .auth
7982 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7983 .await
7984 {
7985 Ok(token) => token,
7986 Err(e) => match dlg.token(e) {
7987 Ok(token) => token,
7988 Err(e) => {
7989 dlg.finished(false);
7990 return Err(common::Error::MissingToken(e));
7991 }
7992 },
7993 };
7994 request_value_reader
7995 .seek(std::io::SeekFrom::Start(0))
7996 .unwrap();
7997 let mut req_result = {
7998 let client = &self.hub.client;
7999 dlg.pre_request();
8000 let mut req_builder = hyper::Request::builder()
8001 .method(hyper::Method::POST)
8002 .uri(url.as_str())
8003 .header(USER_AGENT, self.hub._user_agent.clone());
8004
8005 if let Some(token) = token.as_ref() {
8006 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8007 }
8008
8009 let request = req_builder
8010 .header(CONTENT_TYPE, json_mime_type.to_string())
8011 .header(CONTENT_LENGTH, request_size as u64)
8012 .body(common::to_body(
8013 request_value_reader.get_ref().clone().into(),
8014 ));
8015
8016 client.request(request.unwrap()).await
8017 };
8018
8019 match req_result {
8020 Err(err) => {
8021 if let common::Retry::After(d) = dlg.http_error(&err) {
8022 sleep(d).await;
8023 continue;
8024 }
8025 dlg.finished(false);
8026 return Err(common::Error::HttpError(err));
8027 }
8028 Ok(res) => {
8029 let (mut parts, body) = res.into_parts();
8030 let mut body = common::Body::new(body);
8031 if !parts.status.is_success() {
8032 let bytes = common::to_bytes(body).await.unwrap_or_default();
8033 let error = serde_json::from_str(&common::to_string(&bytes));
8034 let response = common::to_response(parts, bytes.into());
8035
8036 if let common::Retry::After(d) =
8037 dlg.http_failure(&response, error.as_ref().ok())
8038 {
8039 sleep(d).await;
8040 continue;
8041 }
8042
8043 dlg.finished(false);
8044
8045 return Err(match error {
8046 Ok(value) => common::Error::BadRequest(value),
8047 _ => common::Error::Failure(response),
8048 });
8049 }
8050 let response = {
8051 let bytes = common::to_bytes(body).await.unwrap_or_default();
8052 let encoded = common::to_string(&bytes);
8053 match serde_json::from_str(&encoded) {
8054 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8055 Err(error) => {
8056 dlg.response_json_decode_error(&encoded, &error);
8057 return Err(common::Error::JsonDecodeError(
8058 encoded.to_string(),
8059 error,
8060 ));
8061 }
8062 }
8063 };
8064
8065 dlg.finished(true);
8066 return Ok(response);
8067 }
8068 }
8069 }
8070 }
8071
8072 ///
8073 /// Sets the *request* property to the given value.
8074 ///
8075 /// Even though the property as already been set when instantiating this call,
8076 /// we provide this method for API completeness.
8077 pub fn request(
8078 mut self,
8079 new_value: ImportDataRequest,
8080 ) -> ProjectLocationDatasetImportDataCall<'a, C> {
8081 self._request = new_value;
8082 self
8083 }
8084 /// Required. Name of the dataset. In form of `projects/{project-number-or-id}/locations/{location-id}/datasets/{dataset-id}`
8085 ///
8086 /// Sets the *dataset* path property to the given value.
8087 ///
8088 /// Even though the property as already been set when instantiating this call,
8089 /// we provide this method for API completeness.
8090 pub fn dataset(mut self, new_value: &str) -> ProjectLocationDatasetImportDataCall<'a, C> {
8091 self._dataset = new_value.to_string();
8092 self
8093 }
8094 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8095 /// while executing the actual API request.
8096 ///
8097 /// ````text
8098 /// It should be used to handle progress information, and to implement a certain level of resilience.
8099 /// ````
8100 ///
8101 /// Sets the *delegate* property to the given value.
8102 pub fn delegate(
8103 mut self,
8104 new_value: &'a mut dyn common::Delegate,
8105 ) -> ProjectLocationDatasetImportDataCall<'a, C> {
8106 self._delegate = Some(new_value);
8107 self
8108 }
8109
8110 /// Set any additional parameter of the query string used in the request.
8111 /// It should be used to set parameters which are not yet available through their own
8112 /// setters.
8113 ///
8114 /// Please note that this method must not be used to set any of the known parameters
8115 /// which have their own setter method. If done anyway, the request will fail.
8116 ///
8117 /// # Additional Parameters
8118 ///
8119 /// * *$.xgafv* (query-string) - V1 error format.
8120 /// * *access_token* (query-string) - OAuth access token.
8121 /// * *alt* (query-string) - Data format for response.
8122 /// * *callback* (query-string) - JSONP
8123 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8124 /// * *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.
8125 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8126 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8127 /// * *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.
8128 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8129 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8130 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationDatasetImportDataCall<'a, C>
8131 where
8132 T: AsRef<str>,
8133 {
8134 self._additional_params
8135 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8136 self
8137 }
8138
8139 /// Identifies the authorization scope for the method you are building.
8140 ///
8141 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8142 /// [`Scope::CloudPlatform`].
8143 ///
8144 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8145 /// tokens for more than one scope.
8146 ///
8147 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8148 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8149 /// sufficient, a read-write scope will do as well.
8150 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationDatasetImportDataCall<'a, C>
8151 where
8152 St: AsRef<str>,
8153 {
8154 self._scopes.insert(String::from(scope.as_ref()));
8155 self
8156 }
8157 /// Identifies the authorization scope(s) for the method you are building.
8158 ///
8159 /// See [`Self::add_scope()`] for details.
8160 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationDatasetImportDataCall<'a, C>
8161 where
8162 I: IntoIterator<Item = St>,
8163 St: AsRef<str>,
8164 {
8165 self._scopes
8166 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8167 self
8168 }
8169
8170 /// Removes all scopes, and no default scope will be used either.
8171 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8172 /// for details).
8173 pub fn clear_scopes(mut self) -> ProjectLocationDatasetImportDataCall<'a, C> {
8174 self._scopes.clear();
8175 self
8176 }
8177}
8178
8179/// Lists datasets.
8180///
8181/// A builder for the *locations.datasets.list* method supported by a *project* resource.
8182/// It is not used directly, but through a [`ProjectMethods`] instance.
8183///
8184/// # Example
8185///
8186/// Instantiate a resource method builder
8187///
8188/// ```test_harness,no_run
8189/// # extern crate hyper;
8190/// # extern crate hyper_rustls;
8191/// # extern crate google_translate3 as translate3;
8192/// # async fn dox() {
8193/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8194///
8195/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8196/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8197/// # .with_native_roots()
8198/// # .unwrap()
8199/// # .https_only()
8200/// # .enable_http2()
8201/// # .build();
8202///
8203/// # let executor = hyper_util::rt::TokioExecutor::new();
8204/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8205/// # secret,
8206/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8207/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8208/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8209/// # ),
8210/// # ).build().await.unwrap();
8211///
8212/// # let client = hyper_util::client::legacy::Client::builder(
8213/// # hyper_util::rt::TokioExecutor::new()
8214/// # )
8215/// # .build(
8216/// # hyper_rustls::HttpsConnectorBuilder::new()
8217/// # .with_native_roots()
8218/// # .unwrap()
8219/// # .https_or_http()
8220/// # .enable_http2()
8221/// # .build()
8222/// # );
8223/// # let mut hub = Translate::new(client, auth);
8224/// // You can configure optional parameters by calling the respective setters at will, and
8225/// // execute the final call using `doit()`.
8226/// // Values shown here are possibly random and not representative !
8227/// let result = hub.projects().locations_datasets_list("parent")
8228/// .page_token("gubergren")
8229/// .page_size(-17)
8230/// .doit().await;
8231/// # }
8232/// ```
8233pub struct ProjectLocationDatasetListCall<'a, C>
8234where
8235 C: 'a,
8236{
8237 hub: &'a Translate<C>,
8238 _parent: String,
8239 _page_token: Option<String>,
8240 _page_size: Option<i32>,
8241 _delegate: Option<&'a mut dyn common::Delegate>,
8242 _additional_params: HashMap<String, String>,
8243 _scopes: BTreeSet<String>,
8244}
8245
8246impl<'a, C> common::CallBuilder for ProjectLocationDatasetListCall<'a, C> {}
8247
8248impl<'a, C> ProjectLocationDatasetListCall<'a, C>
8249where
8250 C: common::Connector,
8251{
8252 /// Perform the operation you have build so far.
8253 pub async fn doit(mut self) -> common::Result<(common::Response, ListDatasetsResponse)> {
8254 use std::borrow::Cow;
8255 use std::io::{Read, Seek};
8256
8257 use common::{url::Params, ToParts};
8258 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8259
8260 let mut dd = common::DefaultDelegate;
8261 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8262 dlg.begin(common::MethodInfo {
8263 id: "translate.projects.locations.datasets.list",
8264 http_method: hyper::Method::GET,
8265 });
8266
8267 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
8268 if self._additional_params.contains_key(field) {
8269 dlg.finished(false);
8270 return Err(common::Error::FieldClash(field));
8271 }
8272 }
8273
8274 let mut params = Params::with_capacity(5 + self._additional_params.len());
8275 params.push("parent", self._parent);
8276 if let Some(value) = self._page_token.as_ref() {
8277 params.push("pageToken", value);
8278 }
8279 if let Some(value) = self._page_size.as_ref() {
8280 params.push("pageSize", value.to_string());
8281 }
8282
8283 params.extend(self._additional_params.iter());
8284
8285 params.push("alt", "json");
8286 let mut url = self.hub._base_url.clone() + "v3/{+parent}/datasets";
8287 if self._scopes.is_empty() {
8288 self._scopes
8289 .insert(Scope::CloudPlatform.as_ref().to_string());
8290 }
8291
8292 #[allow(clippy::single_element_loop)]
8293 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8294 url = params.uri_replacement(url, param_name, find_this, true);
8295 }
8296 {
8297 let to_remove = ["parent"];
8298 params.remove_params(&to_remove);
8299 }
8300
8301 let url = params.parse_with_url(&url);
8302
8303 loop {
8304 let token = match self
8305 .hub
8306 .auth
8307 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8308 .await
8309 {
8310 Ok(token) => token,
8311 Err(e) => match dlg.token(e) {
8312 Ok(token) => token,
8313 Err(e) => {
8314 dlg.finished(false);
8315 return Err(common::Error::MissingToken(e));
8316 }
8317 },
8318 };
8319 let mut req_result = {
8320 let client = &self.hub.client;
8321 dlg.pre_request();
8322 let mut req_builder = hyper::Request::builder()
8323 .method(hyper::Method::GET)
8324 .uri(url.as_str())
8325 .header(USER_AGENT, self.hub._user_agent.clone());
8326
8327 if let Some(token) = token.as_ref() {
8328 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8329 }
8330
8331 let request = req_builder
8332 .header(CONTENT_LENGTH, 0_u64)
8333 .body(common::to_body::<String>(None));
8334
8335 client.request(request.unwrap()).await
8336 };
8337
8338 match req_result {
8339 Err(err) => {
8340 if let common::Retry::After(d) = dlg.http_error(&err) {
8341 sleep(d).await;
8342 continue;
8343 }
8344 dlg.finished(false);
8345 return Err(common::Error::HttpError(err));
8346 }
8347 Ok(res) => {
8348 let (mut parts, body) = res.into_parts();
8349 let mut body = common::Body::new(body);
8350 if !parts.status.is_success() {
8351 let bytes = common::to_bytes(body).await.unwrap_or_default();
8352 let error = serde_json::from_str(&common::to_string(&bytes));
8353 let response = common::to_response(parts, bytes.into());
8354
8355 if let common::Retry::After(d) =
8356 dlg.http_failure(&response, error.as_ref().ok())
8357 {
8358 sleep(d).await;
8359 continue;
8360 }
8361
8362 dlg.finished(false);
8363
8364 return Err(match error {
8365 Ok(value) => common::Error::BadRequest(value),
8366 _ => common::Error::Failure(response),
8367 });
8368 }
8369 let response = {
8370 let bytes = common::to_bytes(body).await.unwrap_or_default();
8371 let encoded = common::to_string(&bytes);
8372 match serde_json::from_str(&encoded) {
8373 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8374 Err(error) => {
8375 dlg.response_json_decode_error(&encoded, &error);
8376 return Err(common::Error::JsonDecodeError(
8377 encoded.to_string(),
8378 error,
8379 ));
8380 }
8381 }
8382 };
8383
8384 dlg.finished(true);
8385 return Ok(response);
8386 }
8387 }
8388 }
8389 }
8390
8391 /// Required. Name of the parent project. In form of `projects/{project-number-or-id}/locations/{location-id}`
8392 ///
8393 /// Sets the *parent* path property to the given value.
8394 ///
8395 /// Even though the property as already been set when instantiating this call,
8396 /// we provide this method for API completeness.
8397 pub fn parent(mut self, new_value: &str) -> ProjectLocationDatasetListCall<'a, C> {
8398 self._parent = new_value.to_string();
8399 self
8400 }
8401 /// Optional. A token identifying a page of results for the server to return. Typically obtained from next_page_token field in the response of a ListDatasets call.
8402 ///
8403 /// Sets the *page token* query property to the given value.
8404 pub fn page_token(mut self, new_value: &str) -> ProjectLocationDatasetListCall<'a, C> {
8405 self._page_token = Some(new_value.to_string());
8406 self
8407 }
8408 /// Optional. Requested page size. The server can return fewer results than requested.
8409 ///
8410 /// Sets the *page size* query property to the given value.
8411 pub fn page_size(mut self, new_value: i32) -> ProjectLocationDatasetListCall<'a, C> {
8412 self._page_size = Some(new_value);
8413 self
8414 }
8415 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8416 /// while executing the actual API request.
8417 ///
8418 /// ````text
8419 /// It should be used to handle progress information, and to implement a certain level of resilience.
8420 /// ````
8421 ///
8422 /// Sets the *delegate* property to the given value.
8423 pub fn delegate(
8424 mut self,
8425 new_value: &'a mut dyn common::Delegate,
8426 ) -> ProjectLocationDatasetListCall<'a, C> {
8427 self._delegate = Some(new_value);
8428 self
8429 }
8430
8431 /// Set any additional parameter of the query string used in the request.
8432 /// It should be used to set parameters which are not yet available through their own
8433 /// setters.
8434 ///
8435 /// Please note that this method must not be used to set any of the known parameters
8436 /// which have their own setter method. If done anyway, the request will fail.
8437 ///
8438 /// # Additional Parameters
8439 ///
8440 /// * *$.xgafv* (query-string) - V1 error format.
8441 /// * *access_token* (query-string) - OAuth access token.
8442 /// * *alt* (query-string) - Data format for response.
8443 /// * *callback* (query-string) - JSONP
8444 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8445 /// * *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.
8446 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8447 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8448 /// * *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.
8449 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8450 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8451 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationDatasetListCall<'a, C>
8452 where
8453 T: AsRef<str>,
8454 {
8455 self._additional_params
8456 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8457 self
8458 }
8459
8460 /// Identifies the authorization scope for the method you are building.
8461 ///
8462 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8463 /// [`Scope::CloudPlatform`].
8464 ///
8465 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8466 /// tokens for more than one scope.
8467 ///
8468 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8469 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8470 /// sufficient, a read-write scope will do as well.
8471 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationDatasetListCall<'a, C>
8472 where
8473 St: AsRef<str>,
8474 {
8475 self._scopes.insert(String::from(scope.as_ref()));
8476 self
8477 }
8478 /// Identifies the authorization scope(s) for the method you are building.
8479 ///
8480 /// See [`Self::add_scope()`] for details.
8481 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationDatasetListCall<'a, C>
8482 where
8483 I: IntoIterator<Item = St>,
8484 St: AsRef<str>,
8485 {
8486 self._scopes
8487 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8488 self
8489 }
8490
8491 /// Removes all scopes, and no default scope will be used either.
8492 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8493 /// for details).
8494 pub fn clear_scopes(mut self) -> ProjectLocationDatasetListCall<'a, C> {
8495 self._scopes.clear();
8496 self
8497 }
8498}
8499
8500/// Creates a glossary entry.
8501///
8502/// A builder for the *locations.glossaries.glossaryEntries.create* method supported by a *project* resource.
8503/// It is not used directly, but through a [`ProjectMethods`] instance.
8504///
8505/// # Example
8506///
8507/// Instantiate a resource method builder
8508///
8509/// ```test_harness,no_run
8510/// # extern crate hyper;
8511/// # extern crate hyper_rustls;
8512/// # extern crate google_translate3 as translate3;
8513/// use translate3::api::GlossaryEntry;
8514/// # async fn dox() {
8515/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8516///
8517/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8518/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8519/// # .with_native_roots()
8520/// # .unwrap()
8521/// # .https_only()
8522/// # .enable_http2()
8523/// # .build();
8524///
8525/// # let executor = hyper_util::rt::TokioExecutor::new();
8526/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8527/// # secret,
8528/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8529/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8530/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8531/// # ),
8532/// # ).build().await.unwrap();
8533///
8534/// # let client = hyper_util::client::legacy::Client::builder(
8535/// # hyper_util::rt::TokioExecutor::new()
8536/// # )
8537/// # .build(
8538/// # hyper_rustls::HttpsConnectorBuilder::new()
8539/// # .with_native_roots()
8540/// # .unwrap()
8541/// # .https_or_http()
8542/// # .enable_http2()
8543/// # .build()
8544/// # );
8545/// # let mut hub = Translate::new(client, auth);
8546/// // As the method needs a request, you would usually fill it with the desired information
8547/// // into the respective structure. Some of the parts shown here might not be applicable !
8548/// // Values shown here are possibly random and not representative !
8549/// let mut req = GlossaryEntry::default();
8550///
8551/// // You can configure optional parameters by calling the respective setters at will, and
8552/// // execute the final call using `doit()`.
8553/// // Values shown here are possibly random and not representative !
8554/// let result = hub.projects().locations_glossaries_glossary_entries_create(req, "parent")
8555/// .doit().await;
8556/// # }
8557/// ```
8558pub struct ProjectLocationGlossaryGlossaryEntryCreateCall<'a, C>
8559where
8560 C: 'a,
8561{
8562 hub: &'a Translate<C>,
8563 _request: GlossaryEntry,
8564 _parent: String,
8565 _delegate: Option<&'a mut dyn common::Delegate>,
8566 _additional_params: HashMap<String, String>,
8567 _scopes: BTreeSet<String>,
8568}
8569
8570impl<'a, C> common::CallBuilder for ProjectLocationGlossaryGlossaryEntryCreateCall<'a, C> {}
8571
8572impl<'a, C> ProjectLocationGlossaryGlossaryEntryCreateCall<'a, C>
8573where
8574 C: common::Connector,
8575{
8576 /// Perform the operation you have build so far.
8577 pub async fn doit(mut self) -> common::Result<(common::Response, GlossaryEntry)> {
8578 use std::borrow::Cow;
8579 use std::io::{Read, Seek};
8580
8581 use common::{url::Params, ToParts};
8582 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8583
8584 let mut dd = common::DefaultDelegate;
8585 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8586 dlg.begin(common::MethodInfo {
8587 id: "translate.projects.locations.glossaries.glossaryEntries.create",
8588 http_method: hyper::Method::POST,
8589 });
8590
8591 for &field in ["alt", "parent"].iter() {
8592 if self._additional_params.contains_key(field) {
8593 dlg.finished(false);
8594 return Err(common::Error::FieldClash(field));
8595 }
8596 }
8597
8598 let mut params = Params::with_capacity(4 + self._additional_params.len());
8599 params.push("parent", self._parent);
8600
8601 params.extend(self._additional_params.iter());
8602
8603 params.push("alt", "json");
8604 let mut url = self.hub._base_url.clone() + "v3/{+parent}/glossaryEntries";
8605 if self._scopes.is_empty() {
8606 self._scopes
8607 .insert(Scope::CloudPlatform.as_ref().to_string());
8608 }
8609
8610 #[allow(clippy::single_element_loop)]
8611 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8612 url = params.uri_replacement(url, param_name, find_this, true);
8613 }
8614 {
8615 let to_remove = ["parent"];
8616 params.remove_params(&to_remove);
8617 }
8618
8619 let url = params.parse_with_url(&url);
8620
8621 let mut json_mime_type = mime::APPLICATION_JSON;
8622 let mut request_value_reader = {
8623 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8624 common::remove_json_null_values(&mut value);
8625 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8626 serde_json::to_writer(&mut dst, &value).unwrap();
8627 dst
8628 };
8629 let request_size = request_value_reader
8630 .seek(std::io::SeekFrom::End(0))
8631 .unwrap();
8632 request_value_reader
8633 .seek(std::io::SeekFrom::Start(0))
8634 .unwrap();
8635
8636 loop {
8637 let token = match self
8638 .hub
8639 .auth
8640 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8641 .await
8642 {
8643 Ok(token) => token,
8644 Err(e) => match dlg.token(e) {
8645 Ok(token) => token,
8646 Err(e) => {
8647 dlg.finished(false);
8648 return Err(common::Error::MissingToken(e));
8649 }
8650 },
8651 };
8652 request_value_reader
8653 .seek(std::io::SeekFrom::Start(0))
8654 .unwrap();
8655 let mut req_result = {
8656 let client = &self.hub.client;
8657 dlg.pre_request();
8658 let mut req_builder = hyper::Request::builder()
8659 .method(hyper::Method::POST)
8660 .uri(url.as_str())
8661 .header(USER_AGENT, self.hub._user_agent.clone());
8662
8663 if let Some(token) = token.as_ref() {
8664 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8665 }
8666
8667 let request = req_builder
8668 .header(CONTENT_TYPE, json_mime_type.to_string())
8669 .header(CONTENT_LENGTH, request_size as u64)
8670 .body(common::to_body(
8671 request_value_reader.get_ref().clone().into(),
8672 ));
8673
8674 client.request(request.unwrap()).await
8675 };
8676
8677 match req_result {
8678 Err(err) => {
8679 if let common::Retry::After(d) = dlg.http_error(&err) {
8680 sleep(d).await;
8681 continue;
8682 }
8683 dlg.finished(false);
8684 return Err(common::Error::HttpError(err));
8685 }
8686 Ok(res) => {
8687 let (mut parts, body) = res.into_parts();
8688 let mut body = common::Body::new(body);
8689 if !parts.status.is_success() {
8690 let bytes = common::to_bytes(body).await.unwrap_or_default();
8691 let error = serde_json::from_str(&common::to_string(&bytes));
8692 let response = common::to_response(parts, bytes.into());
8693
8694 if let common::Retry::After(d) =
8695 dlg.http_failure(&response, error.as_ref().ok())
8696 {
8697 sleep(d).await;
8698 continue;
8699 }
8700
8701 dlg.finished(false);
8702
8703 return Err(match error {
8704 Ok(value) => common::Error::BadRequest(value),
8705 _ => common::Error::Failure(response),
8706 });
8707 }
8708 let response = {
8709 let bytes = common::to_bytes(body).await.unwrap_or_default();
8710 let encoded = common::to_string(&bytes);
8711 match serde_json::from_str(&encoded) {
8712 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8713 Err(error) => {
8714 dlg.response_json_decode_error(&encoded, &error);
8715 return Err(common::Error::JsonDecodeError(
8716 encoded.to_string(),
8717 error,
8718 ));
8719 }
8720 }
8721 };
8722
8723 dlg.finished(true);
8724 return Ok(response);
8725 }
8726 }
8727 }
8728 }
8729
8730 ///
8731 /// Sets the *request* property to the given value.
8732 ///
8733 /// Even though the property as already been set when instantiating this call,
8734 /// we provide this method for API completeness.
8735 pub fn request(
8736 mut self,
8737 new_value: GlossaryEntry,
8738 ) -> ProjectLocationGlossaryGlossaryEntryCreateCall<'a, C> {
8739 self._request = new_value;
8740 self
8741 }
8742 /// Required. The resource name of the glossary to create the entry under.
8743 ///
8744 /// Sets the *parent* path property to the given value.
8745 ///
8746 /// Even though the property as already been set when instantiating this call,
8747 /// we provide this method for API completeness.
8748 pub fn parent(
8749 mut self,
8750 new_value: &str,
8751 ) -> ProjectLocationGlossaryGlossaryEntryCreateCall<'a, C> {
8752 self._parent = new_value.to_string();
8753 self
8754 }
8755 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8756 /// while executing the actual API request.
8757 ///
8758 /// ````text
8759 /// It should be used to handle progress information, and to implement a certain level of resilience.
8760 /// ````
8761 ///
8762 /// Sets the *delegate* property to the given value.
8763 pub fn delegate(
8764 mut self,
8765 new_value: &'a mut dyn common::Delegate,
8766 ) -> ProjectLocationGlossaryGlossaryEntryCreateCall<'a, C> {
8767 self._delegate = Some(new_value);
8768 self
8769 }
8770
8771 /// Set any additional parameter of the query string used in the request.
8772 /// It should be used to set parameters which are not yet available through their own
8773 /// setters.
8774 ///
8775 /// Please note that this method must not be used to set any of the known parameters
8776 /// which have their own setter method. If done anyway, the request will fail.
8777 ///
8778 /// # Additional Parameters
8779 ///
8780 /// * *$.xgafv* (query-string) - V1 error format.
8781 /// * *access_token* (query-string) - OAuth access token.
8782 /// * *alt* (query-string) - Data format for response.
8783 /// * *callback* (query-string) - JSONP
8784 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8785 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8786 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8787 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8788 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
8789 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8790 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8791 pub fn param<T>(
8792 mut self,
8793 name: T,
8794 value: T,
8795 ) -> ProjectLocationGlossaryGlossaryEntryCreateCall<'a, C>
8796 where
8797 T: AsRef<str>,
8798 {
8799 self._additional_params
8800 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8801 self
8802 }
8803
8804 /// Identifies the authorization scope for the method you are building.
8805 ///
8806 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8807 /// [`Scope::CloudPlatform`].
8808 ///
8809 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8810 /// tokens for more than one scope.
8811 ///
8812 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8813 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8814 /// sufficient, a read-write scope will do as well.
8815 pub fn add_scope<St>(
8816 mut self,
8817 scope: St,
8818 ) -> ProjectLocationGlossaryGlossaryEntryCreateCall<'a, C>
8819 where
8820 St: AsRef<str>,
8821 {
8822 self._scopes.insert(String::from(scope.as_ref()));
8823 self
8824 }
8825 /// Identifies the authorization scope(s) for the method you are building.
8826 ///
8827 /// See [`Self::add_scope()`] for details.
8828 pub fn add_scopes<I, St>(
8829 mut self,
8830 scopes: I,
8831 ) -> ProjectLocationGlossaryGlossaryEntryCreateCall<'a, C>
8832 where
8833 I: IntoIterator<Item = St>,
8834 St: AsRef<str>,
8835 {
8836 self._scopes
8837 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8838 self
8839 }
8840
8841 /// Removes all scopes, and no default scope will be used either.
8842 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8843 /// for details).
8844 pub fn clear_scopes(mut self) -> ProjectLocationGlossaryGlossaryEntryCreateCall<'a, C> {
8845 self._scopes.clear();
8846 self
8847 }
8848}
8849
8850/// Deletes a single entry from the glossary
8851///
8852/// A builder for the *locations.glossaries.glossaryEntries.delete* method supported by a *project* resource.
8853/// It is not used directly, but through a [`ProjectMethods`] instance.
8854///
8855/// # Example
8856///
8857/// Instantiate a resource method builder
8858///
8859/// ```test_harness,no_run
8860/// # extern crate hyper;
8861/// # extern crate hyper_rustls;
8862/// # extern crate google_translate3 as translate3;
8863/// # async fn dox() {
8864/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8865///
8866/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8867/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8868/// # .with_native_roots()
8869/// # .unwrap()
8870/// # .https_only()
8871/// # .enable_http2()
8872/// # .build();
8873///
8874/// # let executor = hyper_util::rt::TokioExecutor::new();
8875/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8876/// # secret,
8877/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8878/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8879/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8880/// # ),
8881/// # ).build().await.unwrap();
8882///
8883/// # let client = hyper_util::client::legacy::Client::builder(
8884/// # hyper_util::rt::TokioExecutor::new()
8885/// # )
8886/// # .build(
8887/// # hyper_rustls::HttpsConnectorBuilder::new()
8888/// # .with_native_roots()
8889/// # .unwrap()
8890/// # .https_or_http()
8891/// # .enable_http2()
8892/// # .build()
8893/// # );
8894/// # let mut hub = Translate::new(client, auth);
8895/// // You can configure optional parameters by calling the respective setters at will, and
8896/// // execute the final call using `doit()`.
8897/// // Values shown here are possibly random and not representative !
8898/// let result = hub.projects().locations_glossaries_glossary_entries_delete("name")
8899/// .doit().await;
8900/// # }
8901/// ```
8902pub struct ProjectLocationGlossaryGlossaryEntryDeleteCall<'a, C>
8903where
8904 C: 'a,
8905{
8906 hub: &'a Translate<C>,
8907 _name: String,
8908 _delegate: Option<&'a mut dyn common::Delegate>,
8909 _additional_params: HashMap<String, String>,
8910 _scopes: BTreeSet<String>,
8911}
8912
8913impl<'a, C> common::CallBuilder for ProjectLocationGlossaryGlossaryEntryDeleteCall<'a, C> {}
8914
8915impl<'a, C> ProjectLocationGlossaryGlossaryEntryDeleteCall<'a, C>
8916where
8917 C: common::Connector,
8918{
8919 /// Perform the operation you have build so far.
8920 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
8921 use std::borrow::Cow;
8922 use std::io::{Read, Seek};
8923
8924 use common::{url::Params, ToParts};
8925 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8926
8927 let mut dd = common::DefaultDelegate;
8928 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8929 dlg.begin(common::MethodInfo {
8930 id: "translate.projects.locations.glossaries.glossaryEntries.delete",
8931 http_method: hyper::Method::DELETE,
8932 });
8933
8934 for &field in ["alt", "name"].iter() {
8935 if self._additional_params.contains_key(field) {
8936 dlg.finished(false);
8937 return Err(common::Error::FieldClash(field));
8938 }
8939 }
8940
8941 let mut params = Params::with_capacity(3 + self._additional_params.len());
8942 params.push("name", self._name);
8943
8944 params.extend(self._additional_params.iter());
8945
8946 params.push("alt", "json");
8947 let mut url = self.hub._base_url.clone() + "v3/{+name}";
8948 if self._scopes.is_empty() {
8949 self._scopes
8950 .insert(Scope::CloudPlatform.as_ref().to_string());
8951 }
8952
8953 #[allow(clippy::single_element_loop)]
8954 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8955 url = params.uri_replacement(url, param_name, find_this, true);
8956 }
8957 {
8958 let to_remove = ["name"];
8959 params.remove_params(&to_remove);
8960 }
8961
8962 let url = params.parse_with_url(&url);
8963
8964 loop {
8965 let token = match self
8966 .hub
8967 .auth
8968 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8969 .await
8970 {
8971 Ok(token) => token,
8972 Err(e) => match dlg.token(e) {
8973 Ok(token) => token,
8974 Err(e) => {
8975 dlg.finished(false);
8976 return Err(common::Error::MissingToken(e));
8977 }
8978 },
8979 };
8980 let mut req_result = {
8981 let client = &self.hub.client;
8982 dlg.pre_request();
8983 let mut req_builder = hyper::Request::builder()
8984 .method(hyper::Method::DELETE)
8985 .uri(url.as_str())
8986 .header(USER_AGENT, self.hub._user_agent.clone());
8987
8988 if let Some(token) = token.as_ref() {
8989 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8990 }
8991
8992 let request = req_builder
8993 .header(CONTENT_LENGTH, 0_u64)
8994 .body(common::to_body::<String>(None));
8995
8996 client.request(request.unwrap()).await
8997 };
8998
8999 match req_result {
9000 Err(err) => {
9001 if let common::Retry::After(d) = dlg.http_error(&err) {
9002 sleep(d).await;
9003 continue;
9004 }
9005 dlg.finished(false);
9006 return Err(common::Error::HttpError(err));
9007 }
9008 Ok(res) => {
9009 let (mut parts, body) = res.into_parts();
9010 let mut body = common::Body::new(body);
9011 if !parts.status.is_success() {
9012 let bytes = common::to_bytes(body).await.unwrap_or_default();
9013 let error = serde_json::from_str(&common::to_string(&bytes));
9014 let response = common::to_response(parts, bytes.into());
9015
9016 if let common::Retry::After(d) =
9017 dlg.http_failure(&response, error.as_ref().ok())
9018 {
9019 sleep(d).await;
9020 continue;
9021 }
9022
9023 dlg.finished(false);
9024
9025 return Err(match error {
9026 Ok(value) => common::Error::BadRequest(value),
9027 _ => common::Error::Failure(response),
9028 });
9029 }
9030 let response = {
9031 let bytes = common::to_bytes(body).await.unwrap_or_default();
9032 let encoded = common::to_string(&bytes);
9033 match serde_json::from_str(&encoded) {
9034 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9035 Err(error) => {
9036 dlg.response_json_decode_error(&encoded, &error);
9037 return Err(common::Error::JsonDecodeError(
9038 encoded.to_string(),
9039 error,
9040 ));
9041 }
9042 }
9043 };
9044
9045 dlg.finished(true);
9046 return Ok(response);
9047 }
9048 }
9049 }
9050 }
9051
9052 /// Required. The resource name of the glossary entry to delete
9053 ///
9054 /// Sets the *name* path property to the given value.
9055 ///
9056 /// Even though the property as already been set when instantiating this call,
9057 /// we provide this method for API completeness.
9058 pub fn name(
9059 mut self,
9060 new_value: &str,
9061 ) -> ProjectLocationGlossaryGlossaryEntryDeleteCall<'a, C> {
9062 self._name = new_value.to_string();
9063 self
9064 }
9065 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9066 /// while executing the actual API request.
9067 ///
9068 /// ````text
9069 /// It should be used to handle progress information, and to implement a certain level of resilience.
9070 /// ````
9071 ///
9072 /// Sets the *delegate* property to the given value.
9073 pub fn delegate(
9074 mut self,
9075 new_value: &'a mut dyn common::Delegate,
9076 ) -> ProjectLocationGlossaryGlossaryEntryDeleteCall<'a, C> {
9077 self._delegate = Some(new_value);
9078 self
9079 }
9080
9081 /// Set any additional parameter of the query string used in the request.
9082 /// It should be used to set parameters which are not yet available through their own
9083 /// setters.
9084 ///
9085 /// Please note that this method must not be used to set any of the known parameters
9086 /// which have their own setter method. If done anyway, the request will fail.
9087 ///
9088 /// # Additional Parameters
9089 ///
9090 /// * *$.xgafv* (query-string) - V1 error format.
9091 /// * *access_token* (query-string) - OAuth access token.
9092 /// * *alt* (query-string) - Data format for response.
9093 /// * *callback* (query-string) - JSONP
9094 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9095 /// * *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.
9096 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9097 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9098 /// * *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.
9099 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9100 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9101 pub fn param<T>(
9102 mut self,
9103 name: T,
9104 value: T,
9105 ) -> ProjectLocationGlossaryGlossaryEntryDeleteCall<'a, C>
9106 where
9107 T: AsRef<str>,
9108 {
9109 self._additional_params
9110 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9111 self
9112 }
9113
9114 /// Identifies the authorization scope for the method you are building.
9115 ///
9116 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9117 /// [`Scope::CloudPlatform`].
9118 ///
9119 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9120 /// tokens for more than one scope.
9121 ///
9122 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9123 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9124 /// sufficient, a read-write scope will do as well.
9125 pub fn add_scope<St>(
9126 mut self,
9127 scope: St,
9128 ) -> ProjectLocationGlossaryGlossaryEntryDeleteCall<'a, C>
9129 where
9130 St: AsRef<str>,
9131 {
9132 self._scopes.insert(String::from(scope.as_ref()));
9133 self
9134 }
9135 /// Identifies the authorization scope(s) for the method you are building.
9136 ///
9137 /// See [`Self::add_scope()`] for details.
9138 pub fn add_scopes<I, St>(
9139 mut self,
9140 scopes: I,
9141 ) -> ProjectLocationGlossaryGlossaryEntryDeleteCall<'a, C>
9142 where
9143 I: IntoIterator<Item = St>,
9144 St: AsRef<str>,
9145 {
9146 self._scopes
9147 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9148 self
9149 }
9150
9151 /// Removes all scopes, and no default scope will be used either.
9152 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9153 /// for details).
9154 pub fn clear_scopes(mut self) -> ProjectLocationGlossaryGlossaryEntryDeleteCall<'a, C> {
9155 self._scopes.clear();
9156 self
9157 }
9158}
9159
9160/// Gets a single glossary entry by the given id.
9161///
9162/// A builder for the *locations.glossaries.glossaryEntries.get* method supported by a *project* resource.
9163/// It is not used directly, but through a [`ProjectMethods`] instance.
9164///
9165/// # Example
9166///
9167/// Instantiate a resource method builder
9168///
9169/// ```test_harness,no_run
9170/// # extern crate hyper;
9171/// # extern crate hyper_rustls;
9172/// # extern crate google_translate3 as translate3;
9173/// # async fn dox() {
9174/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9175///
9176/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9177/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9178/// # .with_native_roots()
9179/// # .unwrap()
9180/// # .https_only()
9181/// # .enable_http2()
9182/// # .build();
9183///
9184/// # let executor = hyper_util::rt::TokioExecutor::new();
9185/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9186/// # secret,
9187/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9188/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9189/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9190/// # ),
9191/// # ).build().await.unwrap();
9192///
9193/// # let client = hyper_util::client::legacy::Client::builder(
9194/// # hyper_util::rt::TokioExecutor::new()
9195/// # )
9196/// # .build(
9197/// # hyper_rustls::HttpsConnectorBuilder::new()
9198/// # .with_native_roots()
9199/// # .unwrap()
9200/// # .https_or_http()
9201/// # .enable_http2()
9202/// # .build()
9203/// # );
9204/// # let mut hub = Translate::new(client, auth);
9205/// // You can configure optional parameters by calling the respective setters at will, and
9206/// // execute the final call using `doit()`.
9207/// // Values shown here are possibly random and not representative !
9208/// let result = hub.projects().locations_glossaries_glossary_entries_get("name")
9209/// .doit().await;
9210/// # }
9211/// ```
9212pub struct ProjectLocationGlossaryGlossaryEntryGetCall<'a, C>
9213where
9214 C: 'a,
9215{
9216 hub: &'a Translate<C>,
9217 _name: String,
9218 _delegate: Option<&'a mut dyn common::Delegate>,
9219 _additional_params: HashMap<String, String>,
9220 _scopes: BTreeSet<String>,
9221}
9222
9223impl<'a, C> common::CallBuilder for ProjectLocationGlossaryGlossaryEntryGetCall<'a, C> {}
9224
9225impl<'a, C> ProjectLocationGlossaryGlossaryEntryGetCall<'a, C>
9226where
9227 C: common::Connector,
9228{
9229 /// Perform the operation you have build so far.
9230 pub async fn doit(mut self) -> common::Result<(common::Response, GlossaryEntry)> {
9231 use std::borrow::Cow;
9232 use std::io::{Read, Seek};
9233
9234 use common::{url::Params, ToParts};
9235 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9236
9237 let mut dd = common::DefaultDelegate;
9238 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9239 dlg.begin(common::MethodInfo {
9240 id: "translate.projects.locations.glossaries.glossaryEntries.get",
9241 http_method: hyper::Method::GET,
9242 });
9243
9244 for &field in ["alt", "name"].iter() {
9245 if self._additional_params.contains_key(field) {
9246 dlg.finished(false);
9247 return Err(common::Error::FieldClash(field));
9248 }
9249 }
9250
9251 let mut params = Params::with_capacity(3 + self._additional_params.len());
9252 params.push("name", self._name);
9253
9254 params.extend(self._additional_params.iter());
9255
9256 params.push("alt", "json");
9257 let mut url = self.hub._base_url.clone() + "v3/{+name}";
9258 if self._scopes.is_empty() {
9259 self._scopes
9260 .insert(Scope::CloudPlatform.as_ref().to_string());
9261 }
9262
9263 #[allow(clippy::single_element_loop)]
9264 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9265 url = params.uri_replacement(url, param_name, find_this, true);
9266 }
9267 {
9268 let to_remove = ["name"];
9269 params.remove_params(&to_remove);
9270 }
9271
9272 let url = params.parse_with_url(&url);
9273
9274 loop {
9275 let token = match self
9276 .hub
9277 .auth
9278 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9279 .await
9280 {
9281 Ok(token) => token,
9282 Err(e) => match dlg.token(e) {
9283 Ok(token) => token,
9284 Err(e) => {
9285 dlg.finished(false);
9286 return Err(common::Error::MissingToken(e));
9287 }
9288 },
9289 };
9290 let mut req_result = {
9291 let client = &self.hub.client;
9292 dlg.pre_request();
9293 let mut req_builder = hyper::Request::builder()
9294 .method(hyper::Method::GET)
9295 .uri(url.as_str())
9296 .header(USER_AGENT, self.hub._user_agent.clone());
9297
9298 if let Some(token) = token.as_ref() {
9299 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9300 }
9301
9302 let request = req_builder
9303 .header(CONTENT_LENGTH, 0_u64)
9304 .body(common::to_body::<String>(None));
9305
9306 client.request(request.unwrap()).await
9307 };
9308
9309 match req_result {
9310 Err(err) => {
9311 if let common::Retry::After(d) = dlg.http_error(&err) {
9312 sleep(d).await;
9313 continue;
9314 }
9315 dlg.finished(false);
9316 return Err(common::Error::HttpError(err));
9317 }
9318 Ok(res) => {
9319 let (mut parts, body) = res.into_parts();
9320 let mut body = common::Body::new(body);
9321 if !parts.status.is_success() {
9322 let bytes = common::to_bytes(body).await.unwrap_or_default();
9323 let error = serde_json::from_str(&common::to_string(&bytes));
9324 let response = common::to_response(parts, bytes.into());
9325
9326 if let common::Retry::After(d) =
9327 dlg.http_failure(&response, error.as_ref().ok())
9328 {
9329 sleep(d).await;
9330 continue;
9331 }
9332
9333 dlg.finished(false);
9334
9335 return Err(match error {
9336 Ok(value) => common::Error::BadRequest(value),
9337 _ => common::Error::Failure(response),
9338 });
9339 }
9340 let response = {
9341 let bytes = common::to_bytes(body).await.unwrap_or_default();
9342 let encoded = common::to_string(&bytes);
9343 match serde_json::from_str(&encoded) {
9344 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9345 Err(error) => {
9346 dlg.response_json_decode_error(&encoded, &error);
9347 return Err(common::Error::JsonDecodeError(
9348 encoded.to_string(),
9349 error,
9350 ));
9351 }
9352 }
9353 };
9354
9355 dlg.finished(true);
9356 return Ok(response);
9357 }
9358 }
9359 }
9360 }
9361
9362 /// Required. The resource name of the glossary entry to get
9363 ///
9364 /// Sets the *name* path property to the given value.
9365 ///
9366 /// Even though the property as already been set when instantiating this call,
9367 /// we provide this method for API completeness.
9368 pub fn name(mut self, new_value: &str) -> ProjectLocationGlossaryGlossaryEntryGetCall<'a, C> {
9369 self._name = new_value.to_string();
9370 self
9371 }
9372 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9373 /// while executing the actual API request.
9374 ///
9375 /// ````text
9376 /// It should be used to handle progress information, and to implement a certain level of resilience.
9377 /// ````
9378 ///
9379 /// Sets the *delegate* property to the given value.
9380 pub fn delegate(
9381 mut self,
9382 new_value: &'a mut dyn common::Delegate,
9383 ) -> ProjectLocationGlossaryGlossaryEntryGetCall<'a, C> {
9384 self._delegate = Some(new_value);
9385 self
9386 }
9387
9388 /// Set any additional parameter of the query string used in the request.
9389 /// It should be used to set parameters which are not yet available through their own
9390 /// setters.
9391 ///
9392 /// Please note that this method must not be used to set any of the known parameters
9393 /// which have their own setter method. If done anyway, the request will fail.
9394 ///
9395 /// # Additional Parameters
9396 ///
9397 /// * *$.xgafv* (query-string) - V1 error format.
9398 /// * *access_token* (query-string) - OAuth access token.
9399 /// * *alt* (query-string) - Data format for response.
9400 /// * *callback* (query-string) - JSONP
9401 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9402 /// * *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.
9403 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9404 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9405 /// * *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.
9406 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9407 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9408 pub fn param<T>(
9409 mut self,
9410 name: T,
9411 value: T,
9412 ) -> ProjectLocationGlossaryGlossaryEntryGetCall<'a, C>
9413 where
9414 T: AsRef<str>,
9415 {
9416 self._additional_params
9417 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9418 self
9419 }
9420
9421 /// Identifies the authorization scope for the method you are building.
9422 ///
9423 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9424 /// [`Scope::CloudPlatform`].
9425 ///
9426 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9427 /// tokens for more than one scope.
9428 ///
9429 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9430 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9431 /// sufficient, a read-write scope will do as well.
9432 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGlossaryGlossaryEntryGetCall<'a, C>
9433 where
9434 St: AsRef<str>,
9435 {
9436 self._scopes.insert(String::from(scope.as_ref()));
9437 self
9438 }
9439 /// Identifies the authorization scope(s) for the method you are building.
9440 ///
9441 /// See [`Self::add_scope()`] for details.
9442 pub fn add_scopes<I, St>(
9443 mut self,
9444 scopes: I,
9445 ) -> ProjectLocationGlossaryGlossaryEntryGetCall<'a, C>
9446 where
9447 I: IntoIterator<Item = St>,
9448 St: AsRef<str>,
9449 {
9450 self._scopes
9451 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9452 self
9453 }
9454
9455 /// Removes all scopes, and no default scope will be used either.
9456 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9457 /// for details).
9458 pub fn clear_scopes(mut self) -> ProjectLocationGlossaryGlossaryEntryGetCall<'a, C> {
9459 self._scopes.clear();
9460 self
9461 }
9462}
9463
9464/// List the entries for the glossary.
9465///
9466/// A builder for the *locations.glossaries.glossaryEntries.list* method supported by a *project* resource.
9467/// It is not used directly, but through a [`ProjectMethods`] instance.
9468///
9469/// # Example
9470///
9471/// Instantiate a resource method builder
9472///
9473/// ```test_harness,no_run
9474/// # extern crate hyper;
9475/// # extern crate hyper_rustls;
9476/// # extern crate google_translate3 as translate3;
9477/// # async fn dox() {
9478/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9479///
9480/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9481/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9482/// # .with_native_roots()
9483/// # .unwrap()
9484/// # .https_only()
9485/// # .enable_http2()
9486/// # .build();
9487///
9488/// # let executor = hyper_util::rt::TokioExecutor::new();
9489/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9490/// # secret,
9491/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9492/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9493/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9494/// # ),
9495/// # ).build().await.unwrap();
9496///
9497/// # let client = hyper_util::client::legacy::Client::builder(
9498/// # hyper_util::rt::TokioExecutor::new()
9499/// # )
9500/// # .build(
9501/// # hyper_rustls::HttpsConnectorBuilder::new()
9502/// # .with_native_roots()
9503/// # .unwrap()
9504/// # .https_or_http()
9505/// # .enable_http2()
9506/// # .build()
9507/// # );
9508/// # let mut hub = Translate::new(client, auth);
9509/// // You can configure optional parameters by calling the respective setters at will, and
9510/// // execute the final call using `doit()`.
9511/// // Values shown here are possibly random and not representative !
9512/// let result = hub.projects().locations_glossaries_glossary_entries_list("parent")
9513/// .page_token("sed")
9514/// .page_size(-70)
9515/// .doit().await;
9516/// # }
9517/// ```
9518pub struct ProjectLocationGlossaryGlossaryEntryListCall<'a, C>
9519where
9520 C: 'a,
9521{
9522 hub: &'a Translate<C>,
9523 _parent: String,
9524 _page_token: Option<String>,
9525 _page_size: Option<i32>,
9526 _delegate: Option<&'a mut dyn common::Delegate>,
9527 _additional_params: HashMap<String, String>,
9528 _scopes: BTreeSet<String>,
9529}
9530
9531impl<'a, C> common::CallBuilder for ProjectLocationGlossaryGlossaryEntryListCall<'a, C> {}
9532
9533impl<'a, C> ProjectLocationGlossaryGlossaryEntryListCall<'a, C>
9534where
9535 C: common::Connector,
9536{
9537 /// Perform the operation you have build so far.
9538 pub async fn doit(mut self) -> common::Result<(common::Response, ListGlossaryEntriesResponse)> {
9539 use std::borrow::Cow;
9540 use std::io::{Read, Seek};
9541
9542 use common::{url::Params, ToParts};
9543 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9544
9545 let mut dd = common::DefaultDelegate;
9546 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9547 dlg.begin(common::MethodInfo {
9548 id: "translate.projects.locations.glossaries.glossaryEntries.list",
9549 http_method: hyper::Method::GET,
9550 });
9551
9552 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
9553 if self._additional_params.contains_key(field) {
9554 dlg.finished(false);
9555 return Err(common::Error::FieldClash(field));
9556 }
9557 }
9558
9559 let mut params = Params::with_capacity(5 + self._additional_params.len());
9560 params.push("parent", self._parent);
9561 if let Some(value) = self._page_token.as_ref() {
9562 params.push("pageToken", value);
9563 }
9564 if let Some(value) = self._page_size.as_ref() {
9565 params.push("pageSize", value.to_string());
9566 }
9567
9568 params.extend(self._additional_params.iter());
9569
9570 params.push("alt", "json");
9571 let mut url = self.hub._base_url.clone() + "v3/{+parent}/glossaryEntries";
9572 if self._scopes.is_empty() {
9573 self._scopes
9574 .insert(Scope::CloudPlatform.as_ref().to_string());
9575 }
9576
9577 #[allow(clippy::single_element_loop)]
9578 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9579 url = params.uri_replacement(url, param_name, find_this, true);
9580 }
9581 {
9582 let to_remove = ["parent"];
9583 params.remove_params(&to_remove);
9584 }
9585
9586 let url = params.parse_with_url(&url);
9587
9588 loop {
9589 let token = match self
9590 .hub
9591 .auth
9592 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9593 .await
9594 {
9595 Ok(token) => token,
9596 Err(e) => match dlg.token(e) {
9597 Ok(token) => token,
9598 Err(e) => {
9599 dlg.finished(false);
9600 return Err(common::Error::MissingToken(e));
9601 }
9602 },
9603 };
9604 let mut req_result = {
9605 let client = &self.hub.client;
9606 dlg.pre_request();
9607 let mut req_builder = hyper::Request::builder()
9608 .method(hyper::Method::GET)
9609 .uri(url.as_str())
9610 .header(USER_AGENT, self.hub._user_agent.clone());
9611
9612 if let Some(token) = token.as_ref() {
9613 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9614 }
9615
9616 let request = req_builder
9617 .header(CONTENT_LENGTH, 0_u64)
9618 .body(common::to_body::<String>(None));
9619
9620 client.request(request.unwrap()).await
9621 };
9622
9623 match req_result {
9624 Err(err) => {
9625 if let common::Retry::After(d) = dlg.http_error(&err) {
9626 sleep(d).await;
9627 continue;
9628 }
9629 dlg.finished(false);
9630 return Err(common::Error::HttpError(err));
9631 }
9632 Ok(res) => {
9633 let (mut parts, body) = res.into_parts();
9634 let mut body = common::Body::new(body);
9635 if !parts.status.is_success() {
9636 let bytes = common::to_bytes(body).await.unwrap_or_default();
9637 let error = serde_json::from_str(&common::to_string(&bytes));
9638 let response = common::to_response(parts, bytes.into());
9639
9640 if let common::Retry::After(d) =
9641 dlg.http_failure(&response, error.as_ref().ok())
9642 {
9643 sleep(d).await;
9644 continue;
9645 }
9646
9647 dlg.finished(false);
9648
9649 return Err(match error {
9650 Ok(value) => common::Error::BadRequest(value),
9651 _ => common::Error::Failure(response),
9652 });
9653 }
9654 let response = {
9655 let bytes = common::to_bytes(body).await.unwrap_or_default();
9656 let encoded = common::to_string(&bytes);
9657 match serde_json::from_str(&encoded) {
9658 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9659 Err(error) => {
9660 dlg.response_json_decode_error(&encoded, &error);
9661 return Err(common::Error::JsonDecodeError(
9662 encoded.to_string(),
9663 error,
9664 ));
9665 }
9666 }
9667 };
9668
9669 dlg.finished(true);
9670 return Ok(response);
9671 }
9672 }
9673 }
9674 }
9675
9676 /// Required. The parent glossary resource name for listing the glossary's entries.
9677 ///
9678 /// Sets the *parent* path property to the given value.
9679 ///
9680 /// Even though the property as already been set when instantiating this call,
9681 /// we provide this method for API completeness.
9682 pub fn parent(
9683 mut self,
9684 new_value: &str,
9685 ) -> ProjectLocationGlossaryGlossaryEntryListCall<'a, C> {
9686 self._parent = new_value.to_string();
9687 self
9688 }
9689 /// Optional. A token identifying a page of results the server should return. Typically, this is the value of [ListGlossaryEntriesResponse.next_page_token] returned from the previous call. The first page is returned if `page_token`is empty or missing.
9690 ///
9691 /// Sets the *page token* query property to the given value.
9692 pub fn page_token(
9693 mut self,
9694 new_value: &str,
9695 ) -> ProjectLocationGlossaryGlossaryEntryListCall<'a, C> {
9696 self._page_token = Some(new_value.to_string());
9697 self
9698 }
9699 /// Optional. Requested page size. The server may return fewer glossary entries than requested. If unspecified, the server picks an appropriate default.
9700 ///
9701 /// Sets the *page size* query property to the given value.
9702 pub fn page_size(
9703 mut self,
9704 new_value: i32,
9705 ) -> ProjectLocationGlossaryGlossaryEntryListCall<'a, C> {
9706 self._page_size = Some(new_value);
9707 self
9708 }
9709 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9710 /// while executing the actual API request.
9711 ///
9712 /// ````text
9713 /// It should be used to handle progress information, and to implement a certain level of resilience.
9714 /// ````
9715 ///
9716 /// Sets the *delegate* property to the given value.
9717 pub fn delegate(
9718 mut self,
9719 new_value: &'a mut dyn common::Delegate,
9720 ) -> ProjectLocationGlossaryGlossaryEntryListCall<'a, C> {
9721 self._delegate = Some(new_value);
9722 self
9723 }
9724
9725 /// Set any additional parameter of the query string used in the request.
9726 /// It should be used to set parameters which are not yet available through their own
9727 /// setters.
9728 ///
9729 /// Please note that this method must not be used to set any of the known parameters
9730 /// which have their own setter method. If done anyway, the request will fail.
9731 ///
9732 /// # Additional Parameters
9733 ///
9734 /// * *$.xgafv* (query-string) - V1 error format.
9735 /// * *access_token* (query-string) - OAuth access token.
9736 /// * *alt* (query-string) - Data format for response.
9737 /// * *callback* (query-string) - JSONP
9738 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9739 /// * *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.
9740 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9741 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9742 /// * *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.
9743 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9744 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9745 pub fn param<T>(
9746 mut self,
9747 name: T,
9748 value: T,
9749 ) -> ProjectLocationGlossaryGlossaryEntryListCall<'a, C>
9750 where
9751 T: AsRef<str>,
9752 {
9753 self._additional_params
9754 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9755 self
9756 }
9757
9758 /// Identifies the authorization scope for the method you are building.
9759 ///
9760 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9761 /// [`Scope::CloudPlatform`].
9762 ///
9763 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9764 /// tokens for more than one scope.
9765 ///
9766 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9767 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9768 /// sufficient, a read-write scope will do as well.
9769 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGlossaryGlossaryEntryListCall<'a, C>
9770 where
9771 St: AsRef<str>,
9772 {
9773 self._scopes.insert(String::from(scope.as_ref()));
9774 self
9775 }
9776 /// Identifies the authorization scope(s) for the method you are building.
9777 ///
9778 /// See [`Self::add_scope()`] for details.
9779 pub fn add_scopes<I, St>(
9780 mut self,
9781 scopes: I,
9782 ) -> ProjectLocationGlossaryGlossaryEntryListCall<'a, C>
9783 where
9784 I: IntoIterator<Item = St>,
9785 St: AsRef<str>,
9786 {
9787 self._scopes
9788 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9789 self
9790 }
9791
9792 /// Removes all scopes, and no default scope will be used either.
9793 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9794 /// for details).
9795 pub fn clear_scopes(mut self) -> ProjectLocationGlossaryGlossaryEntryListCall<'a, C> {
9796 self._scopes.clear();
9797 self
9798 }
9799}
9800
9801/// Updates a glossary entry.
9802///
9803/// A builder for the *locations.glossaries.glossaryEntries.patch* method supported by a *project* resource.
9804/// It is not used directly, but through a [`ProjectMethods`] instance.
9805///
9806/// # Example
9807///
9808/// Instantiate a resource method builder
9809///
9810/// ```test_harness,no_run
9811/// # extern crate hyper;
9812/// # extern crate hyper_rustls;
9813/// # extern crate google_translate3 as translate3;
9814/// use translate3::api::GlossaryEntry;
9815/// # async fn dox() {
9816/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9817///
9818/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9819/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9820/// # .with_native_roots()
9821/// # .unwrap()
9822/// # .https_only()
9823/// # .enable_http2()
9824/// # .build();
9825///
9826/// # let executor = hyper_util::rt::TokioExecutor::new();
9827/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9828/// # secret,
9829/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9830/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9831/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9832/// # ),
9833/// # ).build().await.unwrap();
9834///
9835/// # let client = hyper_util::client::legacy::Client::builder(
9836/// # hyper_util::rt::TokioExecutor::new()
9837/// # )
9838/// # .build(
9839/// # hyper_rustls::HttpsConnectorBuilder::new()
9840/// # .with_native_roots()
9841/// # .unwrap()
9842/// # .https_or_http()
9843/// # .enable_http2()
9844/// # .build()
9845/// # );
9846/// # let mut hub = Translate::new(client, auth);
9847/// // As the method needs a request, you would usually fill it with the desired information
9848/// // into the respective structure. Some of the parts shown here might not be applicable !
9849/// // Values shown here are possibly random and not representative !
9850/// let mut req = GlossaryEntry::default();
9851///
9852/// // You can configure optional parameters by calling the respective setters at will, and
9853/// // execute the final call using `doit()`.
9854/// // Values shown here are possibly random and not representative !
9855/// let result = hub.projects().locations_glossaries_glossary_entries_patch(req, "name")
9856/// .doit().await;
9857/// # }
9858/// ```
9859pub struct ProjectLocationGlossaryGlossaryEntryPatchCall<'a, C>
9860where
9861 C: 'a,
9862{
9863 hub: &'a Translate<C>,
9864 _request: GlossaryEntry,
9865 _name: String,
9866 _delegate: Option<&'a mut dyn common::Delegate>,
9867 _additional_params: HashMap<String, String>,
9868 _scopes: BTreeSet<String>,
9869}
9870
9871impl<'a, C> common::CallBuilder for ProjectLocationGlossaryGlossaryEntryPatchCall<'a, C> {}
9872
9873impl<'a, C> ProjectLocationGlossaryGlossaryEntryPatchCall<'a, C>
9874where
9875 C: common::Connector,
9876{
9877 /// Perform the operation you have build so far.
9878 pub async fn doit(mut self) -> common::Result<(common::Response, GlossaryEntry)> {
9879 use std::borrow::Cow;
9880 use std::io::{Read, Seek};
9881
9882 use common::{url::Params, ToParts};
9883 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9884
9885 let mut dd = common::DefaultDelegate;
9886 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9887 dlg.begin(common::MethodInfo {
9888 id: "translate.projects.locations.glossaries.glossaryEntries.patch",
9889 http_method: hyper::Method::PATCH,
9890 });
9891
9892 for &field in ["alt", "name"].iter() {
9893 if self._additional_params.contains_key(field) {
9894 dlg.finished(false);
9895 return Err(common::Error::FieldClash(field));
9896 }
9897 }
9898
9899 let mut params = Params::with_capacity(4 + self._additional_params.len());
9900 params.push("name", self._name);
9901
9902 params.extend(self._additional_params.iter());
9903
9904 params.push("alt", "json");
9905 let mut url = self.hub._base_url.clone() + "v3/{+name}";
9906 if self._scopes.is_empty() {
9907 self._scopes
9908 .insert(Scope::CloudPlatform.as_ref().to_string());
9909 }
9910
9911 #[allow(clippy::single_element_loop)]
9912 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9913 url = params.uri_replacement(url, param_name, find_this, true);
9914 }
9915 {
9916 let to_remove = ["name"];
9917 params.remove_params(&to_remove);
9918 }
9919
9920 let url = params.parse_with_url(&url);
9921
9922 let mut json_mime_type = mime::APPLICATION_JSON;
9923 let mut request_value_reader = {
9924 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9925 common::remove_json_null_values(&mut value);
9926 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9927 serde_json::to_writer(&mut dst, &value).unwrap();
9928 dst
9929 };
9930 let request_size = request_value_reader
9931 .seek(std::io::SeekFrom::End(0))
9932 .unwrap();
9933 request_value_reader
9934 .seek(std::io::SeekFrom::Start(0))
9935 .unwrap();
9936
9937 loop {
9938 let token = match self
9939 .hub
9940 .auth
9941 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9942 .await
9943 {
9944 Ok(token) => token,
9945 Err(e) => match dlg.token(e) {
9946 Ok(token) => token,
9947 Err(e) => {
9948 dlg.finished(false);
9949 return Err(common::Error::MissingToken(e));
9950 }
9951 },
9952 };
9953 request_value_reader
9954 .seek(std::io::SeekFrom::Start(0))
9955 .unwrap();
9956 let mut req_result = {
9957 let client = &self.hub.client;
9958 dlg.pre_request();
9959 let mut req_builder = hyper::Request::builder()
9960 .method(hyper::Method::PATCH)
9961 .uri(url.as_str())
9962 .header(USER_AGENT, self.hub._user_agent.clone());
9963
9964 if let Some(token) = token.as_ref() {
9965 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9966 }
9967
9968 let request = req_builder
9969 .header(CONTENT_TYPE, json_mime_type.to_string())
9970 .header(CONTENT_LENGTH, request_size as u64)
9971 .body(common::to_body(
9972 request_value_reader.get_ref().clone().into(),
9973 ));
9974
9975 client.request(request.unwrap()).await
9976 };
9977
9978 match req_result {
9979 Err(err) => {
9980 if let common::Retry::After(d) = dlg.http_error(&err) {
9981 sleep(d).await;
9982 continue;
9983 }
9984 dlg.finished(false);
9985 return Err(common::Error::HttpError(err));
9986 }
9987 Ok(res) => {
9988 let (mut parts, body) = res.into_parts();
9989 let mut body = common::Body::new(body);
9990 if !parts.status.is_success() {
9991 let bytes = common::to_bytes(body).await.unwrap_or_default();
9992 let error = serde_json::from_str(&common::to_string(&bytes));
9993 let response = common::to_response(parts, bytes.into());
9994
9995 if let common::Retry::After(d) =
9996 dlg.http_failure(&response, error.as_ref().ok())
9997 {
9998 sleep(d).await;
9999 continue;
10000 }
10001
10002 dlg.finished(false);
10003
10004 return Err(match error {
10005 Ok(value) => common::Error::BadRequest(value),
10006 _ => common::Error::Failure(response),
10007 });
10008 }
10009 let response = {
10010 let bytes = common::to_bytes(body).await.unwrap_or_default();
10011 let encoded = common::to_string(&bytes);
10012 match serde_json::from_str(&encoded) {
10013 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10014 Err(error) => {
10015 dlg.response_json_decode_error(&encoded, &error);
10016 return Err(common::Error::JsonDecodeError(
10017 encoded.to_string(),
10018 error,
10019 ));
10020 }
10021 }
10022 };
10023
10024 dlg.finished(true);
10025 return Ok(response);
10026 }
10027 }
10028 }
10029 }
10030
10031 ///
10032 /// Sets the *request* property to the given value.
10033 ///
10034 /// Even though the property as already been set when instantiating this call,
10035 /// we provide this method for API completeness.
10036 pub fn request(
10037 mut self,
10038 new_value: GlossaryEntry,
10039 ) -> ProjectLocationGlossaryGlossaryEntryPatchCall<'a, C> {
10040 self._request = new_value;
10041 self
10042 }
10043 /// Identifier. The resource name of the entry. Format: `projects/*/locations/*/glossaries/*/glossaryEntries/*`
10044 ///
10045 /// Sets the *name* path property to the given value.
10046 ///
10047 /// Even though the property as already been set when instantiating this call,
10048 /// we provide this method for API completeness.
10049 pub fn name(mut self, new_value: &str) -> ProjectLocationGlossaryGlossaryEntryPatchCall<'a, C> {
10050 self._name = new_value.to_string();
10051 self
10052 }
10053 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10054 /// while executing the actual API request.
10055 ///
10056 /// ````text
10057 /// It should be used to handle progress information, and to implement a certain level of resilience.
10058 /// ````
10059 ///
10060 /// Sets the *delegate* property to the given value.
10061 pub fn delegate(
10062 mut self,
10063 new_value: &'a mut dyn common::Delegate,
10064 ) -> ProjectLocationGlossaryGlossaryEntryPatchCall<'a, C> {
10065 self._delegate = Some(new_value);
10066 self
10067 }
10068
10069 /// Set any additional parameter of the query string used in the request.
10070 /// It should be used to set parameters which are not yet available through their own
10071 /// setters.
10072 ///
10073 /// Please note that this method must not be used to set any of the known parameters
10074 /// which have their own setter method. If done anyway, the request will fail.
10075 ///
10076 /// # Additional Parameters
10077 ///
10078 /// * *$.xgafv* (query-string) - V1 error format.
10079 /// * *access_token* (query-string) - OAuth access token.
10080 /// * *alt* (query-string) - Data format for response.
10081 /// * *callback* (query-string) - JSONP
10082 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10083 /// * *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.
10084 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10085 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10086 /// * *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.
10087 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10088 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10089 pub fn param<T>(
10090 mut self,
10091 name: T,
10092 value: T,
10093 ) -> ProjectLocationGlossaryGlossaryEntryPatchCall<'a, C>
10094 where
10095 T: AsRef<str>,
10096 {
10097 self._additional_params
10098 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10099 self
10100 }
10101
10102 /// Identifies the authorization scope for the method you are building.
10103 ///
10104 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10105 /// [`Scope::CloudPlatform`].
10106 ///
10107 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10108 /// tokens for more than one scope.
10109 ///
10110 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10111 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10112 /// sufficient, a read-write scope will do as well.
10113 pub fn add_scope<St>(
10114 mut self,
10115 scope: St,
10116 ) -> ProjectLocationGlossaryGlossaryEntryPatchCall<'a, C>
10117 where
10118 St: AsRef<str>,
10119 {
10120 self._scopes.insert(String::from(scope.as_ref()));
10121 self
10122 }
10123 /// Identifies the authorization scope(s) for the method you are building.
10124 ///
10125 /// See [`Self::add_scope()`] for details.
10126 pub fn add_scopes<I, St>(
10127 mut self,
10128 scopes: I,
10129 ) -> ProjectLocationGlossaryGlossaryEntryPatchCall<'a, C>
10130 where
10131 I: IntoIterator<Item = St>,
10132 St: AsRef<str>,
10133 {
10134 self._scopes
10135 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10136 self
10137 }
10138
10139 /// Removes all scopes, and no default scope will be used either.
10140 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10141 /// for details).
10142 pub fn clear_scopes(mut self) -> ProjectLocationGlossaryGlossaryEntryPatchCall<'a, C> {
10143 self._scopes.clear();
10144 self
10145 }
10146}
10147
10148/// Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project doesn't exist.
10149///
10150/// A builder for the *locations.glossaries.create* method supported by a *project* resource.
10151/// It is not used directly, but through a [`ProjectMethods`] instance.
10152///
10153/// # Example
10154///
10155/// Instantiate a resource method builder
10156///
10157/// ```test_harness,no_run
10158/// # extern crate hyper;
10159/// # extern crate hyper_rustls;
10160/// # extern crate google_translate3 as translate3;
10161/// use translate3::api::Glossary;
10162/// # async fn dox() {
10163/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10164///
10165/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10166/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10167/// # .with_native_roots()
10168/// # .unwrap()
10169/// # .https_only()
10170/// # .enable_http2()
10171/// # .build();
10172///
10173/// # let executor = hyper_util::rt::TokioExecutor::new();
10174/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10175/// # secret,
10176/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10177/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10178/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10179/// # ),
10180/// # ).build().await.unwrap();
10181///
10182/// # let client = hyper_util::client::legacy::Client::builder(
10183/// # hyper_util::rt::TokioExecutor::new()
10184/// # )
10185/// # .build(
10186/// # hyper_rustls::HttpsConnectorBuilder::new()
10187/// # .with_native_roots()
10188/// # .unwrap()
10189/// # .https_or_http()
10190/// # .enable_http2()
10191/// # .build()
10192/// # );
10193/// # let mut hub = Translate::new(client, auth);
10194/// // As the method needs a request, you would usually fill it with the desired information
10195/// // into the respective structure. Some of the parts shown here might not be applicable !
10196/// // Values shown here are possibly random and not representative !
10197/// let mut req = Glossary::default();
10198///
10199/// // You can configure optional parameters by calling the respective setters at will, and
10200/// // execute the final call using `doit()`.
10201/// // Values shown here are possibly random and not representative !
10202/// let result = hub.projects().locations_glossaries_create(req, "parent")
10203/// .doit().await;
10204/// # }
10205/// ```
10206pub struct ProjectLocationGlossaryCreateCall<'a, C>
10207where
10208 C: 'a,
10209{
10210 hub: &'a Translate<C>,
10211 _request: Glossary,
10212 _parent: String,
10213 _delegate: Option<&'a mut dyn common::Delegate>,
10214 _additional_params: HashMap<String, String>,
10215 _scopes: BTreeSet<String>,
10216}
10217
10218impl<'a, C> common::CallBuilder for ProjectLocationGlossaryCreateCall<'a, C> {}
10219
10220impl<'a, C> ProjectLocationGlossaryCreateCall<'a, C>
10221where
10222 C: common::Connector,
10223{
10224 /// Perform the operation you have build so far.
10225 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
10226 use std::borrow::Cow;
10227 use std::io::{Read, Seek};
10228
10229 use common::{url::Params, ToParts};
10230 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10231
10232 let mut dd = common::DefaultDelegate;
10233 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10234 dlg.begin(common::MethodInfo {
10235 id: "translate.projects.locations.glossaries.create",
10236 http_method: hyper::Method::POST,
10237 });
10238
10239 for &field in ["alt", "parent"].iter() {
10240 if self._additional_params.contains_key(field) {
10241 dlg.finished(false);
10242 return Err(common::Error::FieldClash(field));
10243 }
10244 }
10245
10246 let mut params = Params::with_capacity(4 + self._additional_params.len());
10247 params.push("parent", self._parent);
10248
10249 params.extend(self._additional_params.iter());
10250
10251 params.push("alt", "json");
10252 let mut url = self.hub._base_url.clone() + "v3/{+parent}/glossaries";
10253 if self._scopes.is_empty() {
10254 self._scopes
10255 .insert(Scope::CloudPlatform.as_ref().to_string());
10256 }
10257
10258 #[allow(clippy::single_element_loop)]
10259 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
10260 url = params.uri_replacement(url, param_name, find_this, true);
10261 }
10262 {
10263 let to_remove = ["parent"];
10264 params.remove_params(&to_remove);
10265 }
10266
10267 let url = params.parse_with_url(&url);
10268
10269 let mut json_mime_type = mime::APPLICATION_JSON;
10270 let mut request_value_reader = {
10271 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10272 common::remove_json_null_values(&mut value);
10273 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10274 serde_json::to_writer(&mut dst, &value).unwrap();
10275 dst
10276 };
10277 let request_size = request_value_reader
10278 .seek(std::io::SeekFrom::End(0))
10279 .unwrap();
10280 request_value_reader
10281 .seek(std::io::SeekFrom::Start(0))
10282 .unwrap();
10283
10284 loop {
10285 let token = match self
10286 .hub
10287 .auth
10288 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10289 .await
10290 {
10291 Ok(token) => token,
10292 Err(e) => match dlg.token(e) {
10293 Ok(token) => token,
10294 Err(e) => {
10295 dlg.finished(false);
10296 return Err(common::Error::MissingToken(e));
10297 }
10298 },
10299 };
10300 request_value_reader
10301 .seek(std::io::SeekFrom::Start(0))
10302 .unwrap();
10303 let mut req_result = {
10304 let client = &self.hub.client;
10305 dlg.pre_request();
10306 let mut req_builder = hyper::Request::builder()
10307 .method(hyper::Method::POST)
10308 .uri(url.as_str())
10309 .header(USER_AGENT, self.hub._user_agent.clone());
10310
10311 if let Some(token) = token.as_ref() {
10312 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10313 }
10314
10315 let request = req_builder
10316 .header(CONTENT_TYPE, json_mime_type.to_string())
10317 .header(CONTENT_LENGTH, request_size as u64)
10318 .body(common::to_body(
10319 request_value_reader.get_ref().clone().into(),
10320 ));
10321
10322 client.request(request.unwrap()).await
10323 };
10324
10325 match req_result {
10326 Err(err) => {
10327 if let common::Retry::After(d) = dlg.http_error(&err) {
10328 sleep(d).await;
10329 continue;
10330 }
10331 dlg.finished(false);
10332 return Err(common::Error::HttpError(err));
10333 }
10334 Ok(res) => {
10335 let (mut parts, body) = res.into_parts();
10336 let mut body = common::Body::new(body);
10337 if !parts.status.is_success() {
10338 let bytes = common::to_bytes(body).await.unwrap_or_default();
10339 let error = serde_json::from_str(&common::to_string(&bytes));
10340 let response = common::to_response(parts, bytes.into());
10341
10342 if let common::Retry::After(d) =
10343 dlg.http_failure(&response, error.as_ref().ok())
10344 {
10345 sleep(d).await;
10346 continue;
10347 }
10348
10349 dlg.finished(false);
10350
10351 return Err(match error {
10352 Ok(value) => common::Error::BadRequest(value),
10353 _ => common::Error::Failure(response),
10354 });
10355 }
10356 let response = {
10357 let bytes = common::to_bytes(body).await.unwrap_or_default();
10358 let encoded = common::to_string(&bytes);
10359 match serde_json::from_str(&encoded) {
10360 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10361 Err(error) => {
10362 dlg.response_json_decode_error(&encoded, &error);
10363 return Err(common::Error::JsonDecodeError(
10364 encoded.to_string(),
10365 error,
10366 ));
10367 }
10368 }
10369 };
10370
10371 dlg.finished(true);
10372 return Ok(response);
10373 }
10374 }
10375 }
10376 }
10377
10378 ///
10379 /// Sets the *request* property to the given value.
10380 ///
10381 /// Even though the property as already been set when instantiating this call,
10382 /// we provide this method for API completeness.
10383 pub fn request(mut self, new_value: Glossary) -> ProjectLocationGlossaryCreateCall<'a, C> {
10384 self._request = new_value;
10385 self
10386 }
10387 /// Required. The project name.
10388 ///
10389 /// Sets the *parent* path property to the given value.
10390 ///
10391 /// Even though the property as already been set when instantiating this call,
10392 /// we provide this method for API completeness.
10393 pub fn parent(mut self, new_value: &str) -> ProjectLocationGlossaryCreateCall<'a, C> {
10394 self._parent = new_value.to_string();
10395 self
10396 }
10397 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10398 /// while executing the actual API request.
10399 ///
10400 /// ````text
10401 /// It should be used to handle progress information, and to implement a certain level of resilience.
10402 /// ````
10403 ///
10404 /// Sets the *delegate* property to the given value.
10405 pub fn delegate(
10406 mut self,
10407 new_value: &'a mut dyn common::Delegate,
10408 ) -> ProjectLocationGlossaryCreateCall<'a, C> {
10409 self._delegate = Some(new_value);
10410 self
10411 }
10412
10413 /// Set any additional parameter of the query string used in the request.
10414 /// It should be used to set parameters which are not yet available through their own
10415 /// setters.
10416 ///
10417 /// Please note that this method must not be used to set any of the known parameters
10418 /// which have their own setter method. If done anyway, the request will fail.
10419 ///
10420 /// # Additional Parameters
10421 ///
10422 /// * *$.xgafv* (query-string) - V1 error format.
10423 /// * *access_token* (query-string) - OAuth access token.
10424 /// * *alt* (query-string) - Data format for response.
10425 /// * *callback* (query-string) - JSONP
10426 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10427 /// * *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.
10428 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10429 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10430 /// * *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.
10431 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10432 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10433 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGlossaryCreateCall<'a, C>
10434 where
10435 T: AsRef<str>,
10436 {
10437 self._additional_params
10438 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10439 self
10440 }
10441
10442 /// Identifies the authorization scope for the method you are building.
10443 ///
10444 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10445 /// [`Scope::CloudPlatform`].
10446 ///
10447 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10448 /// tokens for more than one scope.
10449 ///
10450 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10451 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10452 /// sufficient, a read-write scope will do as well.
10453 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGlossaryCreateCall<'a, C>
10454 where
10455 St: AsRef<str>,
10456 {
10457 self._scopes.insert(String::from(scope.as_ref()));
10458 self
10459 }
10460 /// Identifies the authorization scope(s) for the method you are building.
10461 ///
10462 /// See [`Self::add_scope()`] for details.
10463 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGlossaryCreateCall<'a, C>
10464 where
10465 I: IntoIterator<Item = St>,
10466 St: AsRef<str>,
10467 {
10468 self._scopes
10469 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10470 self
10471 }
10472
10473 /// Removes all scopes, and no default scope will be used either.
10474 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10475 /// for details).
10476 pub fn clear_scopes(mut self) -> ProjectLocationGlossaryCreateCall<'a, C> {
10477 self._scopes.clear();
10478 self
10479 }
10480}
10481
10482/// Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns NOT_FOUND, if the glossary doesn't exist.
10483///
10484/// A builder for the *locations.glossaries.delete* method supported by a *project* resource.
10485/// It is not used directly, but through a [`ProjectMethods`] instance.
10486///
10487/// # Example
10488///
10489/// Instantiate a resource method builder
10490///
10491/// ```test_harness,no_run
10492/// # extern crate hyper;
10493/// # extern crate hyper_rustls;
10494/// # extern crate google_translate3 as translate3;
10495/// # async fn dox() {
10496/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10497///
10498/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10499/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10500/// # .with_native_roots()
10501/// # .unwrap()
10502/// # .https_only()
10503/// # .enable_http2()
10504/// # .build();
10505///
10506/// # let executor = hyper_util::rt::TokioExecutor::new();
10507/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10508/// # secret,
10509/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10510/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10511/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10512/// # ),
10513/// # ).build().await.unwrap();
10514///
10515/// # let client = hyper_util::client::legacy::Client::builder(
10516/// # hyper_util::rt::TokioExecutor::new()
10517/// # )
10518/// # .build(
10519/// # hyper_rustls::HttpsConnectorBuilder::new()
10520/// # .with_native_roots()
10521/// # .unwrap()
10522/// # .https_or_http()
10523/// # .enable_http2()
10524/// # .build()
10525/// # );
10526/// # let mut hub = Translate::new(client, auth);
10527/// // You can configure optional parameters by calling the respective setters at will, and
10528/// // execute the final call using `doit()`.
10529/// // Values shown here are possibly random and not representative !
10530/// let result = hub.projects().locations_glossaries_delete("name")
10531/// .doit().await;
10532/// # }
10533/// ```
10534pub struct ProjectLocationGlossaryDeleteCall<'a, C>
10535where
10536 C: 'a,
10537{
10538 hub: &'a Translate<C>,
10539 _name: String,
10540 _delegate: Option<&'a mut dyn common::Delegate>,
10541 _additional_params: HashMap<String, String>,
10542 _scopes: BTreeSet<String>,
10543}
10544
10545impl<'a, C> common::CallBuilder for ProjectLocationGlossaryDeleteCall<'a, C> {}
10546
10547impl<'a, C> ProjectLocationGlossaryDeleteCall<'a, C>
10548where
10549 C: common::Connector,
10550{
10551 /// Perform the operation you have build so far.
10552 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
10553 use std::borrow::Cow;
10554 use std::io::{Read, Seek};
10555
10556 use common::{url::Params, ToParts};
10557 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10558
10559 let mut dd = common::DefaultDelegate;
10560 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10561 dlg.begin(common::MethodInfo {
10562 id: "translate.projects.locations.glossaries.delete",
10563 http_method: hyper::Method::DELETE,
10564 });
10565
10566 for &field in ["alt", "name"].iter() {
10567 if self._additional_params.contains_key(field) {
10568 dlg.finished(false);
10569 return Err(common::Error::FieldClash(field));
10570 }
10571 }
10572
10573 let mut params = Params::with_capacity(3 + self._additional_params.len());
10574 params.push("name", self._name);
10575
10576 params.extend(self._additional_params.iter());
10577
10578 params.push("alt", "json");
10579 let mut url = self.hub._base_url.clone() + "v3/{+name}";
10580 if self._scopes.is_empty() {
10581 self._scopes
10582 .insert(Scope::CloudPlatform.as_ref().to_string());
10583 }
10584
10585 #[allow(clippy::single_element_loop)]
10586 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10587 url = params.uri_replacement(url, param_name, find_this, true);
10588 }
10589 {
10590 let to_remove = ["name"];
10591 params.remove_params(&to_remove);
10592 }
10593
10594 let url = params.parse_with_url(&url);
10595
10596 loop {
10597 let token = match self
10598 .hub
10599 .auth
10600 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10601 .await
10602 {
10603 Ok(token) => token,
10604 Err(e) => match dlg.token(e) {
10605 Ok(token) => token,
10606 Err(e) => {
10607 dlg.finished(false);
10608 return Err(common::Error::MissingToken(e));
10609 }
10610 },
10611 };
10612 let mut req_result = {
10613 let client = &self.hub.client;
10614 dlg.pre_request();
10615 let mut req_builder = hyper::Request::builder()
10616 .method(hyper::Method::DELETE)
10617 .uri(url.as_str())
10618 .header(USER_AGENT, self.hub._user_agent.clone());
10619
10620 if let Some(token) = token.as_ref() {
10621 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10622 }
10623
10624 let request = req_builder
10625 .header(CONTENT_LENGTH, 0_u64)
10626 .body(common::to_body::<String>(None));
10627
10628 client.request(request.unwrap()).await
10629 };
10630
10631 match req_result {
10632 Err(err) => {
10633 if let common::Retry::After(d) = dlg.http_error(&err) {
10634 sleep(d).await;
10635 continue;
10636 }
10637 dlg.finished(false);
10638 return Err(common::Error::HttpError(err));
10639 }
10640 Ok(res) => {
10641 let (mut parts, body) = res.into_parts();
10642 let mut body = common::Body::new(body);
10643 if !parts.status.is_success() {
10644 let bytes = common::to_bytes(body).await.unwrap_or_default();
10645 let error = serde_json::from_str(&common::to_string(&bytes));
10646 let response = common::to_response(parts, bytes.into());
10647
10648 if let common::Retry::After(d) =
10649 dlg.http_failure(&response, error.as_ref().ok())
10650 {
10651 sleep(d).await;
10652 continue;
10653 }
10654
10655 dlg.finished(false);
10656
10657 return Err(match error {
10658 Ok(value) => common::Error::BadRequest(value),
10659 _ => common::Error::Failure(response),
10660 });
10661 }
10662 let response = {
10663 let bytes = common::to_bytes(body).await.unwrap_or_default();
10664 let encoded = common::to_string(&bytes);
10665 match serde_json::from_str(&encoded) {
10666 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10667 Err(error) => {
10668 dlg.response_json_decode_error(&encoded, &error);
10669 return Err(common::Error::JsonDecodeError(
10670 encoded.to_string(),
10671 error,
10672 ));
10673 }
10674 }
10675 };
10676
10677 dlg.finished(true);
10678 return Ok(response);
10679 }
10680 }
10681 }
10682 }
10683
10684 /// Required. The name of the glossary to delete.
10685 ///
10686 /// Sets the *name* path property to the given value.
10687 ///
10688 /// Even though the property as already been set when instantiating this call,
10689 /// we provide this method for API completeness.
10690 pub fn name(mut self, new_value: &str) -> ProjectLocationGlossaryDeleteCall<'a, C> {
10691 self._name = new_value.to_string();
10692 self
10693 }
10694 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10695 /// while executing the actual API request.
10696 ///
10697 /// ````text
10698 /// It should be used to handle progress information, and to implement a certain level of resilience.
10699 /// ````
10700 ///
10701 /// Sets the *delegate* property to the given value.
10702 pub fn delegate(
10703 mut self,
10704 new_value: &'a mut dyn common::Delegate,
10705 ) -> ProjectLocationGlossaryDeleteCall<'a, C> {
10706 self._delegate = Some(new_value);
10707 self
10708 }
10709
10710 /// Set any additional parameter of the query string used in the request.
10711 /// It should be used to set parameters which are not yet available through their own
10712 /// setters.
10713 ///
10714 /// Please note that this method must not be used to set any of the known parameters
10715 /// which have their own setter method. If done anyway, the request will fail.
10716 ///
10717 /// # Additional Parameters
10718 ///
10719 /// * *$.xgafv* (query-string) - V1 error format.
10720 /// * *access_token* (query-string) - OAuth access token.
10721 /// * *alt* (query-string) - Data format for response.
10722 /// * *callback* (query-string) - JSONP
10723 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10724 /// * *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.
10725 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10726 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10727 /// * *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.
10728 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10729 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10730 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGlossaryDeleteCall<'a, C>
10731 where
10732 T: AsRef<str>,
10733 {
10734 self._additional_params
10735 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10736 self
10737 }
10738
10739 /// Identifies the authorization scope for the method you are building.
10740 ///
10741 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10742 /// [`Scope::CloudPlatform`].
10743 ///
10744 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10745 /// tokens for more than one scope.
10746 ///
10747 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10748 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10749 /// sufficient, a read-write scope will do as well.
10750 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGlossaryDeleteCall<'a, C>
10751 where
10752 St: AsRef<str>,
10753 {
10754 self._scopes.insert(String::from(scope.as_ref()));
10755 self
10756 }
10757 /// Identifies the authorization scope(s) for the method you are building.
10758 ///
10759 /// See [`Self::add_scope()`] for details.
10760 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGlossaryDeleteCall<'a, C>
10761 where
10762 I: IntoIterator<Item = St>,
10763 St: AsRef<str>,
10764 {
10765 self._scopes
10766 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10767 self
10768 }
10769
10770 /// Removes all scopes, and no default scope will be used either.
10771 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10772 /// for details).
10773 pub fn clear_scopes(mut self) -> ProjectLocationGlossaryDeleteCall<'a, C> {
10774 self._scopes.clear();
10775 self
10776 }
10777}
10778
10779/// Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist.
10780///
10781/// A builder for the *locations.glossaries.get* method supported by a *project* resource.
10782/// It is not used directly, but through a [`ProjectMethods`] instance.
10783///
10784/// # Example
10785///
10786/// Instantiate a resource method builder
10787///
10788/// ```test_harness,no_run
10789/// # extern crate hyper;
10790/// # extern crate hyper_rustls;
10791/// # extern crate google_translate3 as translate3;
10792/// # async fn dox() {
10793/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10794///
10795/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10796/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10797/// # .with_native_roots()
10798/// # .unwrap()
10799/// # .https_only()
10800/// # .enable_http2()
10801/// # .build();
10802///
10803/// # let executor = hyper_util::rt::TokioExecutor::new();
10804/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10805/// # secret,
10806/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10807/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10808/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10809/// # ),
10810/// # ).build().await.unwrap();
10811///
10812/// # let client = hyper_util::client::legacy::Client::builder(
10813/// # hyper_util::rt::TokioExecutor::new()
10814/// # )
10815/// # .build(
10816/// # hyper_rustls::HttpsConnectorBuilder::new()
10817/// # .with_native_roots()
10818/// # .unwrap()
10819/// # .https_or_http()
10820/// # .enable_http2()
10821/// # .build()
10822/// # );
10823/// # let mut hub = Translate::new(client, auth);
10824/// // You can configure optional parameters by calling the respective setters at will, and
10825/// // execute the final call using `doit()`.
10826/// // Values shown here are possibly random and not representative !
10827/// let result = hub.projects().locations_glossaries_get("name")
10828/// .doit().await;
10829/// # }
10830/// ```
10831pub struct ProjectLocationGlossaryGetCall<'a, C>
10832where
10833 C: 'a,
10834{
10835 hub: &'a Translate<C>,
10836 _name: String,
10837 _delegate: Option<&'a mut dyn common::Delegate>,
10838 _additional_params: HashMap<String, String>,
10839 _scopes: BTreeSet<String>,
10840}
10841
10842impl<'a, C> common::CallBuilder for ProjectLocationGlossaryGetCall<'a, C> {}
10843
10844impl<'a, C> ProjectLocationGlossaryGetCall<'a, C>
10845where
10846 C: common::Connector,
10847{
10848 /// Perform the operation you have build so far.
10849 pub async fn doit(mut self) -> common::Result<(common::Response, Glossary)> {
10850 use std::borrow::Cow;
10851 use std::io::{Read, Seek};
10852
10853 use common::{url::Params, ToParts};
10854 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10855
10856 let mut dd = common::DefaultDelegate;
10857 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10858 dlg.begin(common::MethodInfo {
10859 id: "translate.projects.locations.glossaries.get",
10860 http_method: hyper::Method::GET,
10861 });
10862
10863 for &field in ["alt", "name"].iter() {
10864 if self._additional_params.contains_key(field) {
10865 dlg.finished(false);
10866 return Err(common::Error::FieldClash(field));
10867 }
10868 }
10869
10870 let mut params = Params::with_capacity(3 + self._additional_params.len());
10871 params.push("name", self._name);
10872
10873 params.extend(self._additional_params.iter());
10874
10875 params.push("alt", "json");
10876 let mut url = self.hub._base_url.clone() + "v3/{+name}";
10877 if self._scopes.is_empty() {
10878 self._scopes
10879 .insert(Scope::CloudPlatform.as_ref().to_string());
10880 }
10881
10882 #[allow(clippy::single_element_loop)]
10883 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10884 url = params.uri_replacement(url, param_name, find_this, true);
10885 }
10886 {
10887 let to_remove = ["name"];
10888 params.remove_params(&to_remove);
10889 }
10890
10891 let url = params.parse_with_url(&url);
10892
10893 loop {
10894 let token = match self
10895 .hub
10896 .auth
10897 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10898 .await
10899 {
10900 Ok(token) => token,
10901 Err(e) => match dlg.token(e) {
10902 Ok(token) => token,
10903 Err(e) => {
10904 dlg.finished(false);
10905 return Err(common::Error::MissingToken(e));
10906 }
10907 },
10908 };
10909 let mut req_result = {
10910 let client = &self.hub.client;
10911 dlg.pre_request();
10912 let mut req_builder = hyper::Request::builder()
10913 .method(hyper::Method::GET)
10914 .uri(url.as_str())
10915 .header(USER_AGENT, self.hub._user_agent.clone());
10916
10917 if let Some(token) = token.as_ref() {
10918 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10919 }
10920
10921 let request = req_builder
10922 .header(CONTENT_LENGTH, 0_u64)
10923 .body(common::to_body::<String>(None));
10924
10925 client.request(request.unwrap()).await
10926 };
10927
10928 match req_result {
10929 Err(err) => {
10930 if let common::Retry::After(d) = dlg.http_error(&err) {
10931 sleep(d).await;
10932 continue;
10933 }
10934 dlg.finished(false);
10935 return Err(common::Error::HttpError(err));
10936 }
10937 Ok(res) => {
10938 let (mut parts, body) = res.into_parts();
10939 let mut body = common::Body::new(body);
10940 if !parts.status.is_success() {
10941 let bytes = common::to_bytes(body).await.unwrap_or_default();
10942 let error = serde_json::from_str(&common::to_string(&bytes));
10943 let response = common::to_response(parts, bytes.into());
10944
10945 if let common::Retry::After(d) =
10946 dlg.http_failure(&response, error.as_ref().ok())
10947 {
10948 sleep(d).await;
10949 continue;
10950 }
10951
10952 dlg.finished(false);
10953
10954 return Err(match error {
10955 Ok(value) => common::Error::BadRequest(value),
10956 _ => common::Error::Failure(response),
10957 });
10958 }
10959 let response = {
10960 let bytes = common::to_bytes(body).await.unwrap_or_default();
10961 let encoded = common::to_string(&bytes);
10962 match serde_json::from_str(&encoded) {
10963 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10964 Err(error) => {
10965 dlg.response_json_decode_error(&encoded, &error);
10966 return Err(common::Error::JsonDecodeError(
10967 encoded.to_string(),
10968 error,
10969 ));
10970 }
10971 }
10972 };
10973
10974 dlg.finished(true);
10975 return Ok(response);
10976 }
10977 }
10978 }
10979 }
10980
10981 /// Required. The name of the glossary to retrieve.
10982 ///
10983 /// Sets the *name* path property to the given value.
10984 ///
10985 /// Even though the property as already been set when instantiating this call,
10986 /// we provide this method for API completeness.
10987 pub fn name(mut self, new_value: &str) -> ProjectLocationGlossaryGetCall<'a, C> {
10988 self._name = new_value.to_string();
10989 self
10990 }
10991 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10992 /// while executing the actual API request.
10993 ///
10994 /// ````text
10995 /// It should be used to handle progress information, and to implement a certain level of resilience.
10996 /// ````
10997 ///
10998 /// Sets the *delegate* property to the given value.
10999 pub fn delegate(
11000 mut self,
11001 new_value: &'a mut dyn common::Delegate,
11002 ) -> ProjectLocationGlossaryGetCall<'a, C> {
11003 self._delegate = Some(new_value);
11004 self
11005 }
11006
11007 /// Set any additional parameter of the query string used in the request.
11008 /// It should be used to set parameters which are not yet available through their own
11009 /// setters.
11010 ///
11011 /// Please note that this method must not be used to set any of the known parameters
11012 /// which have their own setter method. If done anyway, the request will fail.
11013 ///
11014 /// # Additional Parameters
11015 ///
11016 /// * *$.xgafv* (query-string) - V1 error format.
11017 /// * *access_token* (query-string) - OAuth access token.
11018 /// * *alt* (query-string) - Data format for response.
11019 /// * *callback* (query-string) - JSONP
11020 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11021 /// * *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.
11022 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11023 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11024 /// * *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.
11025 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11026 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11027 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGlossaryGetCall<'a, C>
11028 where
11029 T: AsRef<str>,
11030 {
11031 self._additional_params
11032 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11033 self
11034 }
11035
11036 /// Identifies the authorization scope for the method you are building.
11037 ///
11038 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11039 /// [`Scope::CloudPlatform`].
11040 ///
11041 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11042 /// tokens for more than one scope.
11043 ///
11044 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11045 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11046 /// sufficient, a read-write scope will do as well.
11047 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGlossaryGetCall<'a, C>
11048 where
11049 St: AsRef<str>,
11050 {
11051 self._scopes.insert(String::from(scope.as_ref()));
11052 self
11053 }
11054 /// Identifies the authorization scope(s) for the method you are building.
11055 ///
11056 /// See [`Self::add_scope()`] for details.
11057 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGlossaryGetCall<'a, C>
11058 where
11059 I: IntoIterator<Item = St>,
11060 St: AsRef<str>,
11061 {
11062 self._scopes
11063 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11064 self
11065 }
11066
11067 /// Removes all scopes, and no default scope will be used either.
11068 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11069 /// for details).
11070 pub fn clear_scopes(mut self) -> ProjectLocationGlossaryGetCall<'a, C> {
11071 self._scopes.clear();
11072 self
11073 }
11074}
11075
11076/// Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist.
11077///
11078/// A builder for the *locations.glossaries.list* method supported by a *project* resource.
11079/// It is not used directly, but through a [`ProjectMethods`] instance.
11080///
11081/// # Example
11082///
11083/// Instantiate a resource method builder
11084///
11085/// ```test_harness,no_run
11086/// # extern crate hyper;
11087/// # extern crate hyper_rustls;
11088/// # extern crate google_translate3 as translate3;
11089/// # async fn dox() {
11090/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11091///
11092/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11093/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11094/// # .with_native_roots()
11095/// # .unwrap()
11096/// # .https_only()
11097/// # .enable_http2()
11098/// # .build();
11099///
11100/// # let executor = hyper_util::rt::TokioExecutor::new();
11101/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11102/// # secret,
11103/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11104/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11105/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11106/// # ),
11107/// # ).build().await.unwrap();
11108///
11109/// # let client = hyper_util::client::legacy::Client::builder(
11110/// # hyper_util::rt::TokioExecutor::new()
11111/// # )
11112/// # .build(
11113/// # hyper_rustls::HttpsConnectorBuilder::new()
11114/// # .with_native_roots()
11115/// # .unwrap()
11116/// # .https_or_http()
11117/// # .enable_http2()
11118/// # .build()
11119/// # );
11120/// # let mut hub = Translate::new(client, auth);
11121/// // You can configure optional parameters by calling the respective setters at will, and
11122/// // execute the final call using `doit()`.
11123/// // Values shown here are possibly random and not representative !
11124/// let result = hub.projects().locations_glossaries_list("parent")
11125/// .page_token("sed")
11126/// .page_size(-24)
11127/// .filter("et")
11128/// .doit().await;
11129/// # }
11130/// ```
11131pub struct ProjectLocationGlossaryListCall<'a, C>
11132where
11133 C: 'a,
11134{
11135 hub: &'a Translate<C>,
11136 _parent: String,
11137 _page_token: Option<String>,
11138 _page_size: Option<i32>,
11139 _filter: Option<String>,
11140 _delegate: Option<&'a mut dyn common::Delegate>,
11141 _additional_params: HashMap<String, String>,
11142 _scopes: BTreeSet<String>,
11143}
11144
11145impl<'a, C> common::CallBuilder for ProjectLocationGlossaryListCall<'a, C> {}
11146
11147impl<'a, C> ProjectLocationGlossaryListCall<'a, C>
11148where
11149 C: common::Connector,
11150{
11151 /// Perform the operation you have build so far.
11152 pub async fn doit(mut self) -> common::Result<(common::Response, ListGlossariesResponse)> {
11153 use std::borrow::Cow;
11154 use std::io::{Read, Seek};
11155
11156 use common::{url::Params, ToParts};
11157 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11158
11159 let mut dd = common::DefaultDelegate;
11160 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11161 dlg.begin(common::MethodInfo {
11162 id: "translate.projects.locations.glossaries.list",
11163 http_method: hyper::Method::GET,
11164 });
11165
11166 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
11167 if self._additional_params.contains_key(field) {
11168 dlg.finished(false);
11169 return Err(common::Error::FieldClash(field));
11170 }
11171 }
11172
11173 let mut params = Params::with_capacity(6 + self._additional_params.len());
11174 params.push("parent", self._parent);
11175 if let Some(value) = self._page_token.as_ref() {
11176 params.push("pageToken", value);
11177 }
11178 if let Some(value) = self._page_size.as_ref() {
11179 params.push("pageSize", value.to_string());
11180 }
11181 if let Some(value) = self._filter.as_ref() {
11182 params.push("filter", value);
11183 }
11184
11185 params.extend(self._additional_params.iter());
11186
11187 params.push("alt", "json");
11188 let mut url = self.hub._base_url.clone() + "v3/{+parent}/glossaries";
11189 if self._scopes.is_empty() {
11190 self._scopes
11191 .insert(Scope::CloudPlatform.as_ref().to_string());
11192 }
11193
11194 #[allow(clippy::single_element_loop)]
11195 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
11196 url = params.uri_replacement(url, param_name, find_this, true);
11197 }
11198 {
11199 let to_remove = ["parent"];
11200 params.remove_params(&to_remove);
11201 }
11202
11203 let url = params.parse_with_url(&url);
11204
11205 loop {
11206 let token = match self
11207 .hub
11208 .auth
11209 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11210 .await
11211 {
11212 Ok(token) => token,
11213 Err(e) => match dlg.token(e) {
11214 Ok(token) => token,
11215 Err(e) => {
11216 dlg.finished(false);
11217 return Err(common::Error::MissingToken(e));
11218 }
11219 },
11220 };
11221 let mut req_result = {
11222 let client = &self.hub.client;
11223 dlg.pre_request();
11224 let mut req_builder = hyper::Request::builder()
11225 .method(hyper::Method::GET)
11226 .uri(url.as_str())
11227 .header(USER_AGENT, self.hub._user_agent.clone());
11228
11229 if let Some(token) = token.as_ref() {
11230 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11231 }
11232
11233 let request = req_builder
11234 .header(CONTENT_LENGTH, 0_u64)
11235 .body(common::to_body::<String>(None));
11236
11237 client.request(request.unwrap()).await
11238 };
11239
11240 match req_result {
11241 Err(err) => {
11242 if let common::Retry::After(d) = dlg.http_error(&err) {
11243 sleep(d).await;
11244 continue;
11245 }
11246 dlg.finished(false);
11247 return Err(common::Error::HttpError(err));
11248 }
11249 Ok(res) => {
11250 let (mut parts, body) = res.into_parts();
11251 let mut body = common::Body::new(body);
11252 if !parts.status.is_success() {
11253 let bytes = common::to_bytes(body).await.unwrap_or_default();
11254 let error = serde_json::from_str(&common::to_string(&bytes));
11255 let response = common::to_response(parts, bytes.into());
11256
11257 if let common::Retry::After(d) =
11258 dlg.http_failure(&response, error.as_ref().ok())
11259 {
11260 sleep(d).await;
11261 continue;
11262 }
11263
11264 dlg.finished(false);
11265
11266 return Err(match error {
11267 Ok(value) => common::Error::BadRequest(value),
11268 _ => common::Error::Failure(response),
11269 });
11270 }
11271 let response = {
11272 let bytes = common::to_bytes(body).await.unwrap_or_default();
11273 let encoded = common::to_string(&bytes);
11274 match serde_json::from_str(&encoded) {
11275 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11276 Err(error) => {
11277 dlg.response_json_decode_error(&encoded, &error);
11278 return Err(common::Error::JsonDecodeError(
11279 encoded.to_string(),
11280 error,
11281 ));
11282 }
11283 }
11284 };
11285
11286 dlg.finished(true);
11287 return Ok(response);
11288 }
11289 }
11290 }
11291 }
11292
11293 /// Required. The name of the project from which to list all of the glossaries.
11294 ///
11295 /// Sets the *parent* path property to the given value.
11296 ///
11297 /// Even though the property as already been set when instantiating this call,
11298 /// we provide this method for API completeness.
11299 pub fn parent(mut self, new_value: &str) -> ProjectLocationGlossaryListCall<'a, C> {
11300 self._parent = new_value.to_string();
11301 self
11302 }
11303 /// Optional. A token identifying a page of results the server should return. Typically, this is the value of [ListGlossariesResponse.next_page_token] returned from the previous call to `ListGlossaries` method. The first page is returned if `page_token`is empty or missing.
11304 ///
11305 /// Sets the *page token* query property to the given value.
11306 pub fn page_token(mut self, new_value: &str) -> ProjectLocationGlossaryListCall<'a, C> {
11307 self._page_token = Some(new_value.to_string());
11308 self
11309 }
11310 /// Optional. Requested page size. The server may return fewer glossaries than requested. If unspecified, the server picks an appropriate default.
11311 ///
11312 /// Sets the *page size* query property to the given value.
11313 pub fn page_size(mut self, new_value: i32) -> ProjectLocationGlossaryListCall<'a, C> {
11314 self._page_size = Some(new_value);
11315 self
11316 }
11317 /// Optional. Filter specifying constraints of a list operation. Specify the constraint by the format of "key=value", where key must be "src" or "tgt", and the value must be a valid language code. For multiple restrictions, concatenate them by "AND" (uppercase only), such as: "src=en-US AND tgt=zh-CN". Notice that the exact match is used here, which means using 'en-US' and 'en' can lead to different results, which depends on the language code you used when you create the glossary. For the unidirectional glossaries, the "src" and "tgt" add restrictions on the source and target language code separately. For the equivalent term set glossaries, the "src" and/or "tgt" add restrictions on the term set. For example: "src=en-US AND tgt=zh-CN" will only pick the unidirectional glossaries which exactly match the source language code as "en-US" and the target language code "zh-CN", but all equivalent term set glossaries which contain "en-US" and "zh-CN" in their language set will be picked. If missing, no filtering is performed.
11318 ///
11319 /// Sets the *filter* query property to the given value.
11320 pub fn filter(mut self, new_value: &str) -> ProjectLocationGlossaryListCall<'a, C> {
11321 self._filter = Some(new_value.to_string());
11322 self
11323 }
11324 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11325 /// while executing the actual API request.
11326 ///
11327 /// ````text
11328 /// It should be used to handle progress information, and to implement a certain level of resilience.
11329 /// ````
11330 ///
11331 /// Sets the *delegate* property to the given value.
11332 pub fn delegate(
11333 mut self,
11334 new_value: &'a mut dyn common::Delegate,
11335 ) -> ProjectLocationGlossaryListCall<'a, C> {
11336 self._delegate = Some(new_value);
11337 self
11338 }
11339
11340 /// Set any additional parameter of the query string used in the request.
11341 /// It should be used to set parameters which are not yet available through their own
11342 /// setters.
11343 ///
11344 /// Please note that this method must not be used to set any of the known parameters
11345 /// which have their own setter method. If done anyway, the request will fail.
11346 ///
11347 /// # Additional Parameters
11348 ///
11349 /// * *$.xgafv* (query-string) - V1 error format.
11350 /// * *access_token* (query-string) - OAuth access token.
11351 /// * *alt* (query-string) - Data format for response.
11352 /// * *callback* (query-string) - JSONP
11353 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11354 /// * *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.
11355 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11356 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11357 /// * *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.
11358 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11359 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11360 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGlossaryListCall<'a, C>
11361 where
11362 T: AsRef<str>,
11363 {
11364 self._additional_params
11365 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11366 self
11367 }
11368
11369 /// Identifies the authorization scope for the method you are building.
11370 ///
11371 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11372 /// [`Scope::CloudPlatform`].
11373 ///
11374 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11375 /// tokens for more than one scope.
11376 ///
11377 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11378 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11379 /// sufficient, a read-write scope will do as well.
11380 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGlossaryListCall<'a, C>
11381 where
11382 St: AsRef<str>,
11383 {
11384 self._scopes.insert(String::from(scope.as_ref()));
11385 self
11386 }
11387 /// Identifies the authorization scope(s) for the method you are building.
11388 ///
11389 /// See [`Self::add_scope()`] for details.
11390 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGlossaryListCall<'a, C>
11391 where
11392 I: IntoIterator<Item = St>,
11393 St: AsRef<str>,
11394 {
11395 self._scopes
11396 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11397 self
11398 }
11399
11400 /// Removes all scopes, and no default scope will be used either.
11401 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11402 /// for details).
11403 pub fn clear_scopes(mut self) -> ProjectLocationGlossaryListCall<'a, C> {
11404 self._scopes.clear();
11405 self
11406 }
11407}
11408
11409/// Updates a glossary. A LRO is used since the update can be async if the glossary's entry file is updated.
11410///
11411/// A builder for the *locations.glossaries.patch* method supported by a *project* resource.
11412/// It is not used directly, but through a [`ProjectMethods`] instance.
11413///
11414/// # Example
11415///
11416/// Instantiate a resource method builder
11417///
11418/// ```test_harness,no_run
11419/// # extern crate hyper;
11420/// # extern crate hyper_rustls;
11421/// # extern crate google_translate3 as translate3;
11422/// use translate3::api::Glossary;
11423/// # async fn dox() {
11424/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11425///
11426/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11427/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11428/// # .with_native_roots()
11429/// # .unwrap()
11430/// # .https_only()
11431/// # .enable_http2()
11432/// # .build();
11433///
11434/// # let executor = hyper_util::rt::TokioExecutor::new();
11435/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11436/// # secret,
11437/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11438/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11439/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11440/// # ),
11441/// # ).build().await.unwrap();
11442///
11443/// # let client = hyper_util::client::legacy::Client::builder(
11444/// # hyper_util::rt::TokioExecutor::new()
11445/// # )
11446/// # .build(
11447/// # hyper_rustls::HttpsConnectorBuilder::new()
11448/// # .with_native_roots()
11449/// # .unwrap()
11450/// # .https_or_http()
11451/// # .enable_http2()
11452/// # .build()
11453/// # );
11454/// # let mut hub = Translate::new(client, auth);
11455/// // As the method needs a request, you would usually fill it with the desired information
11456/// // into the respective structure. Some of the parts shown here might not be applicable !
11457/// // Values shown here are possibly random and not representative !
11458/// let mut req = Glossary::default();
11459///
11460/// // You can configure optional parameters by calling the respective setters at will, and
11461/// // execute the final call using `doit()`.
11462/// // Values shown here are possibly random and not representative !
11463/// let result = hub.projects().locations_glossaries_patch(req, "name")
11464/// .update_mask(FieldMask::new::<&str>(&[]))
11465/// .doit().await;
11466/// # }
11467/// ```
11468pub struct ProjectLocationGlossaryPatchCall<'a, C>
11469where
11470 C: 'a,
11471{
11472 hub: &'a Translate<C>,
11473 _request: Glossary,
11474 _name: String,
11475 _update_mask: Option<common::FieldMask>,
11476 _delegate: Option<&'a mut dyn common::Delegate>,
11477 _additional_params: HashMap<String, String>,
11478 _scopes: BTreeSet<String>,
11479}
11480
11481impl<'a, C> common::CallBuilder for ProjectLocationGlossaryPatchCall<'a, C> {}
11482
11483impl<'a, C> ProjectLocationGlossaryPatchCall<'a, C>
11484where
11485 C: common::Connector,
11486{
11487 /// Perform the operation you have build so far.
11488 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
11489 use std::borrow::Cow;
11490 use std::io::{Read, Seek};
11491
11492 use common::{url::Params, ToParts};
11493 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11494
11495 let mut dd = common::DefaultDelegate;
11496 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11497 dlg.begin(common::MethodInfo {
11498 id: "translate.projects.locations.glossaries.patch",
11499 http_method: hyper::Method::PATCH,
11500 });
11501
11502 for &field in ["alt", "name", "updateMask"].iter() {
11503 if self._additional_params.contains_key(field) {
11504 dlg.finished(false);
11505 return Err(common::Error::FieldClash(field));
11506 }
11507 }
11508
11509 let mut params = Params::with_capacity(5 + self._additional_params.len());
11510 params.push("name", self._name);
11511 if let Some(value) = self._update_mask.as_ref() {
11512 params.push("updateMask", value.to_string());
11513 }
11514
11515 params.extend(self._additional_params.iter());
11516
11517 params.push("alt", "json");
11518 let mut url = self.hub._base_url.clone() + "v3/{+name}";
11519 if self._scopes.is_empty() {
11520 self._scopes
11521 .insert(Scope::CloudPlatform.as_ref().to_string());
11522 }
11523
11524 #[allow(clippy::single_element_loop)]
11525 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11526 url = params.uri_replacement(url, param_name, find_this, true);
11527 }
11528 {
11529 let to_remove = ["name"];
11530 params.remove_params(&to_remove);
11531 }
11532
11533 let url = params.parse_with_url(&url);
11534
11535 let mut json_mime_type = mime::APPLICATION_JSON;
11536 let mut request_value_reader = {
11537 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11538 common::remove_json_null_values(&mut value);
11539 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11540 serde_json::to_writer(&mut dst, &value).unwrap();
11541 dst
11542 };
11543 let request_size = request_value_reader
11544 .seek(std::io::SeekFrom::End(0))
11545 .unwrap();
11546 request_value_reader
11547 .seek(std::io::SeekFrom::Start(0))
11548 .unwrap();
11549
11550 loop {
11551 let token = match self
11552 .hub
11553 .auth
11554 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11555 .await
11556 {
11557 Ok(token) => token,
11558 Err(e) => match dlg.token(e) {
11559 Ok(token) => token,
11560 Err(e) => {
11561 dlg.finished(false);
11562 return Err(common::Error::MissingToken(e));
11563 }
11564 },
11565 };
11566 request_value_reader
11567 .seek(std::io::SeekFrom::Start(0))
11568 .unwrap();
11569 let mut req_result = {
11570 let client = &self.hub.client;
11571 dlg.pre_request();
11572 let mut req_builder = hyper::Request::builder()
11573 .method(hyper::Method::PATCH)
11574 .uri(url.as_str())
11575 .header(USER_AGENT, self.hub._user_agent.clone());
11576
11577 if let Some(token) = token.as_ref() {
11578 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11579 }
11580
11581 let request = req_builder
11582 .header(CONTENT_TYPE, json_mime_type.to_string())
11583 .header(CONTENT_LENGTH, request_size as u64)
11584 .body(common::to_body(
11585 request_value_reader.get_ref().clone().into(),
11586 ));
11587
11588 client.request(request.unwrap()).await
11589 };
11590
11591 match req_result {
11592 Err(err) => {
11593 if let common::Retry::After(d) = dlg.http_error(&err) {
11594 sleep(d).await;
11595 continue;
11596 }
11597 dlg.finished(false);
11598 return Err(common::Error::HttpError(err));
11599 }
11600 Ok(res) => {
11601 let (mut parts, body) = res.into_parts();
11602 let mut body = common::Body::new(body);
11603 if !parts.status.is_success() {
11604 let bytes = common::to_bytes(body).await.unwrap_or_default();
11605 let error = serde_json::from_str(&common::to_string(&bytes));
11606 let response = common::to_response(parts, bytes.into());
11607
11608 if let common::Retry::After(d) =
11609 dlg.http_failure(&response, error.as_ref().ok())
11610 {
11611 sleep(d).await;
11612 continue;
11613 }
11614
11615 dlg.finished(false);
11616
11617 return Err(match error {
11618 Ok(value) => common::Error::BadRequest(value),
11619 _ => common::Error::Failure(response),
11620 });
11621 }
11622 let response = {
11623 let bytes = common::to_bytes(body).await.unwrap_or_default();
11624 let encoded = common::to_string(&bytes);
11625 match serde_json::from_str(&encoded) {
11626 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11627 Err(error) => {
11628 dlg.response_json_decode_error(&encoded, &error);
11629 return Err(common::Error::JsonDecodeError(
11630 encoded.to_string(),
11631 error,
11632 ));
11633 }
11634 }
11635 };
11636
11637 dlg.finished(true);
11638 return Ok(response);
11639 }
11640 }
11641 }
11642 }
11643
11644 ///
11645 /// Sets the *request* property to the given value.
11646 ///
11647 /// Even though the property as already been set when instantiating this call,
11648 /// we provide this method for API completeness.
11649 pub fn request(mut self, new_value: Glossary) -> ProjectLocationGlossaryPatchCall<'a, C> {
11650 self._request = new_value;
11651 self
11652 }
11653 /// Required. The resource name of the glossary. Glossary names have the form `projects/{project-number-or-id}/locations/{location-id}/glossaries/{glossary-id}`.
11654 ///
11655 /// Sets the *name* path property to the given value.
11656 ///
11657 /// Even though the property as already been set when instantiating this call,
11658 /// we provide this method for API completeness.
11659 pub fn name(mut self, new_value: &str) -> ProjectLocationGlossaryPatchCall<'a, C> {
11660 self._name = new_value.to_string();
11661 self
11662 }
11663 /// The list of fields to be updated. Currently only `display_name` and 'input_config'
11664 ///
11665 /// Sets the *update mask* query property to the given value.
11666 pub fn update_mask(
11667 mut self,
11668 new_value: common::FieldMask,
11669 ) -> ProjectLocationGlossaryPatchCall<'a, C> {
11670 self._update_mask = Some(new_value);
11671 self
11672 }
11673 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11674 /// while executing the actual API request.
11675 ///
11676 /// ````text
11677 /// It should be used to handle progress information, and to implement a certain level of resilience.
11678 /// ````
11679 ///
11680 /// Sets the *delegate* property to the given value.
11681 pub fn delegate(
11682 mut self,
11683 new_value: &'a mut dyn common::Delegate,
11684 ) -> ProjectLocationGlossaryPatchCall<'a, C> {
11685 self._delegate = Some(new_value);
11686 self
11687 }
11688
11689 /// Set any additional parameter of the query string used in the request.
11690 /// It should be used to set parameters which are not yet available through their own
11691 /// setters.
11692 ///
11693 /// Please note that this method must not be used to set any of the known parameters
11694 /// which have their own setter method. If done anyway, the request will fail.
11695 ///
11696 /// # Additional Parameters
11697 ///
11698 /// * *$.xgafv* (query-string) - V1 error format.
11699 /// * *access_token* (query-string) - OAuth access token.
11700 /// * *alt* (query-string) - Data format for response.
11701 /// * *callback* (query-string) - JSONP
11702 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11703 /// * *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.
11704 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11705 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11706 /// * *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.
11707 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11708 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11709 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGlossaryPatchCall<'a, C>
11710 where
11711 T: AsRef<str>,
11712 {
11713 self._additional_params
11714 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11715 self
11716 }
11717
11718 /// Identifies the authorization scope for the method you are building.
11719 ///
11720 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11721 /// [`Scope::CloudPlatform`].
11722 ///
11723 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11724 /// tokens for more than one scope.
11725 ///
11726 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11727 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11728 /// sufficient, a read-write scope will do as well.
11729 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGlossaryPatchCall<'a, C>
11730 where
11731 St: AsRef<str>,
11732 {
11733 self._scopes.insert(String::from(scope.as_ref()));
11734 self
11735 }
11736 /// Identifies the authorization scope(s) for the method you are building.
11737 ///
11738 /// See [`Self::add_scope()`] for details.
11739 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGlossaryPatchCall<'a, C>
11740 where
11741 I: IntoIterator<Item = St>,
11742 St: AsRef<str>,
11743 {
11744 self._scopes
11745 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11746 self
11747 }
11748
11749 /// Removes all scopes, and no default scope will be used either.
11750 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11751 /// for details).
11752 pub fn clear_scopes(mut self) -> ProjectLocationGlossaryPatchCall<'a, C> {
11753 self._scopes.clear();
11754 self
11755 }
11756}
11757
11758/// Creates a Model.
11759///
11760/// A builder for the *locations.models.create* method supported by a *project* resource.
11761/// It is not used directly, but through a [`ProjectMethods`] instance.
11762///
11763/// # Example
11764///
11765/// Instantiate a resource method builder
11766///
11767/// ```test_harness,no_run
11768/// # extern crate hyper;
11769/// # extern crate hyper_rustls;
11770/// # extern crate google_translate3 as translate3;
11771/// use translate3::api::Model;
11772/// # async fn dox() {
11773/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11774///
11775/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11776/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11777/// # .with_native_roots()
11778/// # .unwrap()
11779/// # .https_only()
11780/// # .enable_http2()
11781/// # .build();
11782///
11783/// # let executor = hyper_util::rt::TokioExecutor::new();
11784/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11785/// # secret,
11786/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11787/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11788/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11789/// # ),
11790/// # ).build().await.unwrap();
11791///
11792/// # let client = hyper_util::client::legacy::Client::builder(
11793/// # hyper_util::rt::TokioExecutor::new()
11794/// # )
11795/// # .build(
11796/// # hyper_rustls::HttpsConnectorBuilder::new()
11797/// # .with_native_roots()
11798/// # .unwrap()
11799/// # .https_or_http()
11800/// # .enable_http2()
11801/// # .build()
11802/// # );
11803/// # let mut hub = Translate::new(client, auth);
11804/// // As the method needs a request, you would usually fill it with the desired information
11805/// // into the respective structure. Some of the parts shown here might not be applicable !
11806/// // Values shown here are possibly random and not representative !
11807/// let mut req = Model::default();
11808///
11809/// // You can configure optional parameters by calling the respective setters at will, and
11810/// // execute the final call using `doit()`.
11811/// // Values shown here are possibly random and not representative !
11812/// let result = hub.projects().locations_models_create(req, "parent")
11813/// .doit().await;
11814/// # }
11815/// ```
11816pub struct ProjectLocationModelCreateCall<'a, C>
11817where
11818 C: 'a,
11819{
11820 hub: &'a Translate<C>,
11821 _request: Model,
11822 _parent: String,
11823 _delegate: Option<&'a mut dyn common::Delegate>,
11824 _additional_params: HashMap<String, String>,
11825 _scopes: BTreeSet<String>,
11826}
11827
11828impl<'a, C> common::CallBuilder for ProjectLocationModelCreateCall<'a, C> {}
11829
11830impl<'a, C> ProjectLocationModelCreateCall<'a, C>
11831where
11832 C: common::Connector,
11833{
11834 /// Perform the operation you have build so far.
11835 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
11836 use std::borrow::Cow;
11837 use std::io::{Read, Seek};
11838
11839 use common::{url::Params, ToParts};
11840 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11841
11842 let mut dd = common::DefaultDelegate;
11843 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11844 dlg.begin(common::MethodInfo {
11845 id: "translate.projects.locations.models.create",
11846 http_method: hyper::Method::POST,
11847 });
11848
11849 for &field in ["alt", "parent"].iter() {
11850 if self._additional_params.contains_key(field) {
11851 dlg.finished(false);
11852 return Err(common::Error::FieldClash(field));
11853 }
11854 }
11855
11856 let mut params = Params::with_capacity(4 + self._additional_params.len());
11857 params.push("parent", self._parent);
11858
11859 params.extend(self._additional_params.iter());
11860
11861 params.push("alt", "json");
11862 let mut url = self.hub._base_url.clone() + "v3/{+parent}/models";
11863 if self._scopes.is_empty() {
11864 self._scopes
11865 .insert(Scope::CloudPlatform.as_ref().to_string());
11866 }
11867
11868 #[allow(clippy::single_element_loop)]
11869 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
11870 url = params.uri_replacement(url, param_name, find_this, true);
11871 }
11872 {
11873 let to_remove = ["parent"];
11874 params.remove_params(&to_remove);
11875 }
11876
11877 let url = params.parse_with_url(&url);
11878
11879 let mut json_mime_type = mime::APPLICATION_JSON;
11880 let mut request_value_reader = {
11881 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11882 common::remove_json_null_values(&mut value);
11883 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11884 serde_json::to_writer(&mut dst, &value).unwrap();
11885 dst
11886 };
11887 let request_size = request_value_reader
11888 .seek(std::io::SeekFrom::End(0))
11889 .unwrap();
11890 request_value_reader
11891 .seek(std::io::SeekFrom::Start(0))
11892 .unwrap();
11893
11894 loop {
11895 let token = match self
11896 .hub
11897 .auth
11898 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11899 .await
11900 {
11901 Ok(token) => token,
11902 Err(e) => match dlg.token(e) {
11903 Ok(token) => token,
11904 Err(e) => {
11905 dlg.finished(false);
11906 return Err(common::Error::MissingToken(e));
11907 }
11908 },
11909 };
11910 request_value_reader
11911 .seek(std::io::SeekFrom::Start(0))
11912 .unwrap();
11913 let mut req_result = {
11914 let client = &self.hub.client;
11915 dlg.pre_request();
11916 let mut req_builder = hyper::Request::builder()
11917 .method(hyper::Method::POST)
11918 .uri(url.as_str())
11919 .header(USER_AGENT, self.hub._user_agent.clone());
11920
11921 if let Some(token) = token.as_ref() {
11922 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11923 }
11924
11925 let request = req_builder
11926 .header(CONTENT_TYPE, json_mime_type.to_string())
11927 .header(CONTENT_LENGTH, request_size as u64)
11928 .body(common::to_body(
11929 request_value_reader.get_ref().clone().into(),
11930 ));
11931
11932 client.request(request.unwrap()).await
11933 };
11934
11935 match req_result {
11936 Err(err) => {
11937 if let common::Retry::After(d) = dlg.http_error(&err) {
11938 sleep(d).await;
11939 continue;
11940 }
11941 dlg.finished(false);
11942 return Err(common::Error::HttpError(err));
11943 }
11944 Ok(res) => {
11945 let (mut parts, body) = res.into_parts();
11946 let mut body = common::Body::new(body);
11947 if !parts.status.is_success() {
11948 let bytes = common::to_bytes(body).await.unwrap_or_default();
11949 let error = serde_json::from_str(&common::to_string(&bytes));
11950 let response = common::to_response(parts, bytes.into());
11951
11952 if let common::Retry::After(d) =
11953 dlg.http_failure(&response, error.as_ref().ok())
11954 {
11955 sleep(d).await;
11956 continue;
11957 }
11958
11959 dlg.finished(false);
11960
11961 return Err(match error {
11962 Ok(value) => common::Error::BadRequest(value),
11963 _ => common::Error::Failure(response),
11964 });
11965 }
11966 let response = {
11967 let bytes = common::to_bytes(body).await.unwrap_or_default();
11968 let encoded = common::to_string(&bytes);
11969 match serde_json::from_str(&encoded) {
11970 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11971 Err(error) => {
11972 dlg.response_json_decode_error(&encoded, &error);
11973 return Err(common::Error::JsonDecodeError(
11974 encoded.to_string(),
11975 error,
11976 ));
11977 }
11978 }
11979 };
11980
11981 dlg.finished(true);
11982 return Ok(response);
11983 }
11984 }
11985 }
11986 }
11987
11988 ///
11989 /// Sets the *request* property to the given value.
11990 ///
11991 /// Even though the property as already been set when instantiating this call,
11992 /// we provide this method for API completeness.
11993 pub fn request(mut self, new_value: Model) -> ProjectLocationModelCreateCall<'a, C> {
11994 self._request = new_value;
11995 self
11996 }
11997 /// Required. The project name, in form of `projects/{project}/locations/{location}`
11998 ///
11999 /// Sets the *parent* path property to the given value.
12000 ///
12001 /// Even though the property as already been set when instantiating this call,
12002 /// we provide this method for API completeness.
12003 pub fn parent(mut self, new_value: &str) -> ProjectLocationModelCreateCall<'a, C> {
12004 self._parent = new_value.to_string();
12005 self
12006 }
12007 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12008 /// while executing the actual API request.
12009 ///
12010 /// ````text
12011 /// It should be used to handle progress information, and to implement a certain level of resilience.
12012 /// ````
12013 ///
12014 /// Sets the *delegate* property to the given value.
12015 pub fn delegate(
12016 mut self,
12017 new_value: &'a mut dyn common::Delegate,
12018 ) -> ProjectLocationModelCreateCall<'a, C> {
12019 self._delegate = Some(new_value);
12020 self
12021 }
12022
12023 /// Set any additional parameter of the query string used in the request.
12024 /// It should be used to set parameters which are not yet available through their own
12025 /// setters.
12026 ///
12027 /// Please note that this method must not be used to set any of the known parameters
12028 /// which have their own setter method. If done anyway, the request will fail.
12029 ///
12030 /// # Additional Parameters
12031 ///
12032 /// * *$.xgafv* (query-string) - V1 error format.
12033 /// * *access_token* (query-string) - OAuth access token.
12034 /// * *alt* (query-string) - Data format for response.
12035 /// * *callback* (query-string) - JSONP
12036 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12037 /// * *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.
12038 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12039 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12040 /// * *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.
12041 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12042 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12043 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationModelCreateCall<'a, C>
12044 where
12045 T: AsRef<str>,
12046 {
12047 self._additional_params
12048 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12049 self
12050 }
12051
12052 /// Identifies the authorization scope for the method you are building.
12053 ///
12054 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12055 /// [`Scope::CloudPlatform`].
12056 ///
12057 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12058 /// tokens for more than one scope.
12059 ///
12060 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12061 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12062 /// sufficient, a read-write scope will do as well.
12063 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationModelCreateCall<'a, C>
12064 where
12065 St: AsRef<str>,
12066 {
12067 self._scopes.insert(String::from(scope.as_ref()));
12068 self
12069 }
12070 /// Identifies the authorization scope(s) for the method you are building.
12071 ///
12072 /// See [`Self::add_scope()`] for details.
12073 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationModelCreateCall<'a, C>
12074 where
12075 I: IntoIterator<Item = St>,
12076 St: AsRef<str>,
12077 {
12078 self._scopes
12079 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12080 self
12081 }
12082
12083 /// Removes all scopes, and no default scope will be used either.
12084 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12085 /// for details).
12086 pub fn clear_scopes(mut self) -> ProjectLocationModelCreateCall<'a, C> {
12087 self._scopes.clear();
12088 self
12089 }
12090}
12091
12092/// Deletes a model.
12093///
12094/// A builder for the *locations.models.delete* method supported by a *project* resource.
12095/// It is not used directly, but through a [`ProjectMethods`] instance.
12096///
12097/// # Example
12098///
12099/// Instantiate a resource method builder
12100///
12101/// ```test_harness,no_run
12102/// # extern crate hyper;
12103/// # extern crate hyper_rustls;
12104/// # extern crate google_translate3 as translate3;
12105/// # async fn dox() {
12106/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12107///
12108/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12109/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12110/// # .with_native_roots()
12111/// # .unwrap()
12112/// # .https_only()
12113/// # .enable_http2()
12114/// # .build();
12115///
12116/// # let executor = hyper_util::rt::TokioExecutor::new();
12117/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12118/// # secret,
12119/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12120/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12121/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12122/// # ),
12123/// # ).build().await.unwrap();
12124///
12125/// # let client = hyper_util::client::legacy::Client::builder(
12126/// # hyper_util::rt::TokioExecutor::new()
12127/// # )
12128/// # .build(
12129/// # hyper_rustls::HttpsConnectorBuilder::new()
12130/// # .with_native_roots()
12131/// # .unwrap()
12132/// # .https_or_http()
12133/// # .enable_http2()
12134/// # .build()
12135/// # );
12136/// # let mut hub = Translate::new(client, auth);
12137/// // You can configure optional parameters by calling the respective setters at will, and
12138/// // execute the final call using `doit()`.
12139/// // Values shown here are possibly random and not representative !
12140/// let result = hub.projects().locations_models_delete("name")
12141/// .doit().await;
12142/// # }
12143/// ```
12144pub struct ProjectLocationModelDeleteCall<'a, C>
12145where
12146 C: 'a,
12147{
12148 hub: &'a Translate<C>,
12149 _name: String,
12150 _delegate: Option<&'a mut dyn common::Delegate>,
12151 _additional_params: HashMap<String, String>,
12152 _scopes: BTreeSet<String>,
12153}
12154
12155impl<'a, C> common::CallBuilder for ProjectLocationModelDeleteCall<'a, C> {}
12156
12157impl<'a, C> ProjectLocationModelDeleteCall<'a, C>
12158where
12159 C: common::Connector,
12160{
12161 /// Perform the operation you have build so far.
12162 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
12163 use std::borrow::Cow;
12164 use std::io::{Read, Seek};
12165
12166 use common::{url::Params, ToParts};
12167 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12168
12169 let mut dd = common::DefaultDelegate;
12170 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12171 dlg.begin(common::MethodInfo {
12172 id: "translate.projects.locations.models.delete",
12173 http_method: hyper::Method::DELETE,
12174 });
12175
12176 for &field in ["alt", "name"].iter() {
12177 if self._additional_params.contains_key(field) {
12178 dlg.finished(false);
12179 return Err(common::Error::FieldClash(field));
12180 }
12181 }
12182
12183 let mut params = Params::with_capacity(3 + self._additional_params.len());
12184 params.push("name", self._name);
12185
12186 params.extend(self._additional_params.iter());
12187
12188 params.push("alt", "json");
12189 let mut url = self.hub._base_url.clone() + "v3/{+name}";
12190 if self._scopes.is_empty() {
12191 self._scopes
12192 .insert(Scope::CloudPlatform.as_ref().to_string());
12193 }
12194
12195 #[allow(clippy::single_element_loop)]
12196 for &(find_this, param_name) in [("{+name}", "name")].iter() {
12197 url = params.uri_replacement(url, param_name, find_this, true);
12198 }
12199 {
12200 let to_remove = ["name"];
12201 params.remove_params(&to_remove);
12202 }
12203
12204 let url = params.parse_with_url(&url);
12205
12206 loop {
12207 let token = match self
12208 .hub
12209 .auth
12210 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12211 .await
12212 {
12213 Ok(token) => token,
12214 Err(e) => match dlg.token(e) {
12215 Ok(token) => token,
12216 Err(e) => {
12217 dlg.finished(false);
12218 return Err(common::Error::MissingToken(e));
12219 }
12220 },
12221 };
12222 let mut req_result = {
12223 let client = &self.hub.client;
12224 dlg.pre_request();
12225 let mut req_builder = hyper::Request::builder()
12226 .method(hyper::Method::DELETE)
12227 .uri(url.as_str())
12228 .header(USER_AGENT, self.hub._user_agent.clone());
12229
12230 if let Some(token) = token.as_ref() {
12231 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12232 }
12233
12234 let request = req_builder
12235 .header(CONTENT_LENGTH, 0_u64)
12236 .body(common::to_body::<String>(None));
12237
12238 client.request(request.unwrap()).await
12239 };
12240
12241 match req_result {
12242 Err(err) => {
12243 if let common::Retry::After(d) = dlg.http_error(&err) {
12244 sleep(d).await;
12245 continue;
12246 }
12247 dlg.finished(false);
12248 return Err(common::Error::HttpError(err));
12249 }
12250 Ok(res) => {
12251 let (mut parts, body) = res.into_parts();
12252 let mut body = common::Body::new(body);
12253 if !parts.status.is_success() {
12254 let bytes = common::to_bytes(body).await.unwrap_or_default();
12255 let error = serde_json::from_str(&common::to_string(&bytes));
12256 let response = common::to_response(parts, bytes.into());
12257
12258 if let common::Retry::After(d) =
12259 dlg.http_failure(&response, error.as_ref().ok())
12260 {
12261 sleep(d).await;
12262 continue;
12263 }
12264
12265 dlg.finished(false);
12266
12267 return Err(match error {
12268 Ok(value) => common::Error::BadRequest(value),
12269 _ => common::Error::Failure(response),
12270 });
12271 }
12272 let response = {
12273 let bytes = common::to_bytes(body).await.unwrap_or_default();
12274 let encoded = common::to_string(&bytes);
12275 match serde_json::from_str(&encoded) {
12276 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12277 Err(error) => {
12278 dlg.response_json_decode_error(&encoded, &error);
12279 return Err(common::Error::JsonDecodeError(
12280 encoded.to_string(),
12281 error,
12282 ));
12283 }
12284 }
12285 };
12286
12287 dlg.finished(true);
12288 return Ok(response);
12289 }
12290 }
12291 }
12292 }
12293
12294 /// Required. The name of the model to delete.
12295 ///
12296 /// Sets the *name* path property to the given value.
12297 ///
12298 /// Even though the property as already been set when instantiating this call,
12299 /// we provide this method for API completeness.
12300 pub fn name(mut self, new_value: &str) -> ProjectLocationModelDeleteCall<'a, C> {
12301 self._name = new_value.to_string();
12302 self
12303 }
12304 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12305 /// while executing the actual API request.
12306 ///
12307 /// ````text
12308 /// It should be used to handle progress information, and to implement a certain level of resilience.
12309 /// ````
12310 ///
12311 /// Sets the *delegate* property to the given value.
12312 pub fn delegate(
12313 mut self,
12314 new_value: &'a mut dyn common::Delegate,
12315 ) -> ProjectLocationModelDeleteCall<'a, C> {
12316 self._delegate = Some(new_value);
12317 self
12318 }
12319
12320 /// Set any additional parameter of the query string used in the request.
12321 /// It should be used to set parameters which are not yet available through their own
12322 /// setters.
12323 ///
12324 /// Please note that this method must not be used to set any of the known parameters
12325 /// which have their own setter method. If done anyway, the request will fail.
12326 ///
12327 /// # Additional Parameters
12328 ///
12329 /// * *$.xgafv* (query-string) - V1 error format.
12330 /// * *access_token* (query-string) - OAuth access token.
12331 /// * *alt* (query-string) - Data format for response.
12332 /// * *callback* (query-string) - JSONP
12333 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12334 /// * *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.
12335 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12336 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12337 /// * *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.
12338 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12339 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12340 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationModelDeleteCall<'a, C>
12341 where
12342 T: AsRef<str>,
12343 {
12344 self._additional_params
12345 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12346 self
12347 }
12348
12349 /// Identifies the authorization scope for the method you are building.
12350 ///
12351 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12352 /// [`Scope::CloudPlatform`].
12353 ///
12354 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12355 /// tokens for more than one scope.
12356 ///
12357 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12358 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12359 /// sufficient, a read-write scope will do as well.
12360 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationModelDeleteCall<'a, C>
12361 where
12362 St: AsRef<str>,
12363 {
12364 self._scopes.insert(String::from(scope.as_ref()));
12365 self
12366 }
12367 /// Identifies the authorization scope(s) for the method you are building.
12368 ///
12369 /// See [`Self::add_scope()`] for details.
12370 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationModelDeleteCall<'a, C>
12371 where
12372 I: IntoIterator<Item = St>,
12373 St: AsRef<str>,
12374 {
12375 self._scopes
12376 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12377 self
12378 }
12379
12380 /// Removes all scopes, and no default scope will be used either.
12381 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12382 /// for details).
12383 pub fn clear_scopes(mut self) -> ProjectLocationModelDeleteCall<'a, C> {
12384 self._scopes.clear();
12385 self
12386 }
12387}
12388
12389/// Gets a model.
12390///
12391/// A builder for the *locations.models.get* method supported by a *project* resource.
12392/// It is not used directly, but through a [`ProjectMethods`] instance.
12393///
12394/// # Example
12395///
12396/// Instantiate a resource method builder
12397///
12398/// ```test_harness,no_run
12399/// # extern crate hyper;
12400/// # extern crate hyper_rustls;
12401/// # extern crate google_translate3 as translate3;
12402/// # async fn dox() {
12403/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12404///
12405/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12406/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12407/// # .with_native_roots()
12408/// # .unwrap()
12409/// # .https_only()
12410/// # .enable_http2()
12411/// # .build();
12412///
12413/// # let executor = hyper_util::rt::TokioExecutor::new();
12414/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12415/// # secret,
12416/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12417/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12418/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12419/// # ),
12420/// # ).build().await.unwrap();
12421///
12422/// # let client = hyper_util::client::legacy::Client::builder(
12423/// # hyper_util::rt::TokioExecutor::new()
12424/// # )
12425/// # .build(
12426/// # hyper_rustls::HttpsConnectorBuilder::new()
12427/// # .with_native_roots()
12428/// # .unwrap()
12429/// # .https_or_http()
12430/// # .enable_http2()
12431/// # .build()
12432/// # );
12433/// # let mut hub = Translate::new(client, auth);
12434/// // You can configure optional parameters by calling the respective setters at will, and
12435/// // execute the final call using `doit()`.
12436/// // Values shown here are possibly random and not representative !
12437/// let result = hub.projects().locations_models_get("name")
12438/// .doit().await;
12439/// # }
12440/// ```
12441pub struct ProjectLocationModelGetCall<'a, C>
12442where
12443 C: 'a,
12444{
12445 hub: &'a Translate<C>,
12446 _name: String,
12447 _delegate: Option<&'a mut dyn common::Delegate>,
12448 _additional_params: HashMap<String, String>,
12449 _scopes: BTreeSet<String>,
12450}
12451
12452impl<'a, C> common::CallBuilder for ProjectLocationModelGetCall<'a, C> {}
12453
12454impl<'a, C> ProjectLocationModelGetCall<'a, C>
12455where
12456 C: common::Connector,
12457{
12458 /// Perform the operation you have build so far.
12459 pub async fn doit(mut self) -> common::Result<(common::Response, Model)> {
12460 use std::borrow::Cow;
12461 use std::io::{Read, Seek};
12462
12463 use common::{url::Params, ToParts};
12464 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12465
12466 let mut dd = common::DefaultDelegate;
12467 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12468 dlg.begin(common::MethodInfo {
12469 id: "translate.projects.locations.models.get",
12470 http_method: hyper::Method::GET,
12471 });
12472
12473 for &field in ["alt", "name"].iter() {
12474 if self._additional_params.contains_key(field) {
12475 dlg.finished(false);
12476 return Err(common::Error::FieldClash(field));
12477 }
12478 }
12479
12480 let mut params = Params::with_capacity(3 + self._additional_params.len());
12481 params.push("name", self._name);
12482
12483 params.extend(self._additional_params.iter());
12484
12485 params.push("alt", "json");
12486 let mut url = self.hub._base_url.clone() + "v3/{+name}";
12487 if self._scopes.is_empty() {
12488 self._scopes
12489 .insert(Scope::CloudPlatform.as_ref().to_string());
12490 }
12491
12492 #[allow(clippy::single_element_loop)]
12493 for &(find_this, param_name) in [("{+name}", "name")].iter() {
12494 url = params.uri_replacement(url, param_name, find_this, true);
12495 }
12496 {
12497 let to_remove = ["name"];
12498 params.remove_params(&to_remove);
12499 }
12500
12501 let url = params.parse_with_url(&url);
12502
12503 loop {
12504 let token = match self
12505 .hub
12506 .auth
12507 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12508 .await
12509 {
12510 Ok(token) => token,
12511 Err(e) => match dlg.token(e) {
12512 Ok(token) => token,
12513 Err(e) => {
12514 dlg.finished(false);
12515 return Err(common::Error::MissingToken(e));
12516 }
12517 },
12518 };
12519 let mut req_result = {
12520 let client = &self.hub.client;
12521 dlg.pre_request();
12522 let mut req_builder = hyper::Request::builder()
12523 .method(hyper::Method::GET)
12524 .uri(url.as_str())
12525 .header(USER_AGENT, self.hub._user_agent.clone());
12526
12527 if let Some(token) = token.as_ref() {
12528 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12529 }
12530
12531 let request = req_builder
12532 .header(CONTENT_LENGTH, 0_u64)
12533 .body(common::to_body::<String>(None));
12534
12535 client.request(request.unwrap()).await
12536 };
12537
12538 match req_result {
12539 Err(err) => {
12540 if let common::Retry::After(d) = dlg.http_error(&err) {
12541 sleep(d).await;
12542 continue;
12543 }
12544 dlg.finished(false);
12545 return Err(common::Error::HttpError(err));
12546 }
12547 Ok(res) => {
12548 let (mut parts, body) = res.into_parts();
12549 let mut body = common::Body::new(body);
12550 if !parts.status.is_success() {
12551 let bytes = common::to_bytes(body).await.unwrap_or_default();
12552 let error = serde_json::from_str(&common::to_string(&bytes));
12553 let response = common::to_response(parts, bytes.into());
12554
12555 if let common::Retry::After(d) =
12556 dlg.http_failure(&response, error.as_ref().ok())
12557 {
12558 sleep(d).await;
12559 continue;
12560 }
12561
12562 dlg.finished(false);
12563
12564 return Err(match error {
12565 Ok(value) => common::Error::BadRequest(value),
12566 _ => common::Error::Failure(response),
12567 });
12568 }
12569 let response = {
12570 let bytes = common::to_bytes(body).await.unwrap_or_default();
12571 let encoded = common::to_string(&bytes);
12572 match serde_json::from_str(&encoded) {
12573 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12574 Err(error) => {
12575 dlg.response_json_decode_error(&encoded, &error);
12576 return Err(common::Error::JsonDecodeError(
12577 encoded.to_string(),
12578 error,
12579 ));
12580 }
12581 }
12582 };
12583
12584 dlg.finished(true);
12585 return Ok(response);
12586 }
12587 }
12588 }
12589 }
12590
12591 /// Required. The resource name of the model to retrieve.
12592 ///
12593 /// Sets the *name* path property to the given value.
12594 ///
12595 /// Even though the property as already been set when instantiating this call,
12596 /// we provide this method for API completeness.
12597 pub fn name(mut self, new_value: &str) -> ProjectLocationModelGetCall<'a, C> {
12598 self._name = new_value.to_string();
12599 self
12600 }
12601 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12602 /// while executing the actual API request.
12603 ///
12604 /// ````text
12605 /// It should be used to handle progress information, and to implement a certain level of resilience.
12606 /// ````
12607 ///
12608 /// Sets the *delegate* property to the given value.
12609 pub fn delegate(
12610 mut self,
12611 new_value: &'a mut dyn common::Delegate,
12612 ) -> ProjectLocationModelGetCall<'a, C> {
12613 self._delegate = Some(new_value);
12614 self
12615 }
12616
12617 /// Set any additional parameter of the query string used in the request.
12618 /// It should be used to set parameters which are not yet available through their own
12619 /// setters.
12620 ///
12621 /// Please note that this method must not be used to set any of the known parameters
12622 /// which have their own setter method. If done anyway, the request will fail.
12623 ///
12624 /// # Additional Parameters
12625 ///
12626 /// * *$.xgafv* (query-string) - V1 error format.
12627 /// * *access_token* (query-string) - OAuth access token.
12628 /// * *alt* (query-string) - Data format for response.
12629 /// * *callback* (query-string) - JSONP
12630 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12631 /// * *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.
12632 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12633 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12634 /// * *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.
12635 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12636 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12637 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationModelGetCall<'a, C>
12638 where
12639 T: AsRef<str>,
12640 {
12641 self._additional_params
12642 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12643 self
12644 }
12645
12646 /// Identifies the authorization scope for the method you are building.
12647 ///
12648 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12649 /// [`Scope::CloudPlatform`].
12650 ///
12651 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12652 /// tokens for more than one scope.
12653 ///
12654 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12655 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12656 /// sufficient, a read-write scope will do as well.
12657 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationModelGetCall<'a, C>
12658 where
12659 St: AsRef<str>,
12660 {
12661 self._scopes.insert(String::from(scope.as_ref()));
12662 self
12663 }
12664 /// Identifies the authorization scope(s) for the method you are building.
12665 ///
12666 /// See [`Self::add_scope()`] for details.
12667 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationModelGetCall<'a, C>
12668 where
12669 I: IntoIterator<Item = St>,
12670 St: AsRef<str>,
12671 {
12672 self._scopes
12673 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12674 self
12675 }
12676
12677 /// Removes all scopes, and no default scope will be used either.
12678 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12679 /// for details).
12680 pub fn clear_scopes(mut self) -> ProjectLocationModelGetCall<'a, C> {
12681 self._scopes.clear();
12682 self
12683 }
12684}
12685
12686/// Lists models.
12687///
12688/// A builder for the *locations.models.list* method supported by a *project* resource.
12689/// It is not used directly, but through a [`ProjectMethods`] instance.
12690///
12691/// # Example
12692///
12693/// Instantiate a resource method builder
12694///
12695/// ```test_harness,no_run
12696/// # extern crate hyper;
12697/// # extern crate hyper_rustls;
12698/// # extern crate google_translate3 as translate3;
12699/// # async fn dox() {
12700/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12701///
12702/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12703/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12704/// # .with_native_roots()
12705/// # .unwrap()
12706/// # .https_only()
12707/// # .enable_http2()
12708/// # .build();
12709///
12710/// # let executor = hyper_util::rt::TokioExecutor::new();
12711/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12712/// # secret,
12713/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12714/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12715/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12716/// # ),
12717/// # ).build().await.unwrap();
12718///
12719/// # let client = hyper_util::client::legacy::Client::builder(
12720/// # hyper_util::rt::TokioExecutor::new()
12721/// # )
12722/// # .build(
12723/// # hyper_rustls::HttpsConnectorBuilder::new()
12724/// # .with_native_roots()
12725/// # .unwrap()
12726/// # .https_or_http()
12727/// # .enable_http2()
12728/// # .build()
12729/// # );
12730/// # let mut hub = Translate::new(client, auth);
12731/// // You can configure optional parameters by calling the respective setters at will, and
12732/// // execute the final call using `doit()`.
12733/// // Values shown here are possibly random and not representative !
12734/// let result = hub.projects().locations_models_list("parent")
12735/// .page_token("et")
12736/// .page_size(-28)
12737/// .filter("amet.")
12738/// .doit().await;
12739/// # }
12740/// ```
12741pub struct ProjectLocationModelListCall<'a, C>
12742where
12743 C: 'a,
12744{
12745 hub: &'a Translate<C>,
12746 _parent: String,
12747 _page_token: Option<String>,
12748 _page_size: Option<i32>,
12749 _filter: Option<String>,
12750 _delegate: Option<&'a mut dyn common::Delegate>,
12751 _additional_params: HashMap<String, String>,
12752 _scopes: BTreeSet<String>,
12753}
12754
12755impl<'a, C> common::CallBuilder for ProjectLocationModelListCall<'a, C> {}
12756
12757impl<'a, C> ProjectLocationModelListCall<'a, C>
12758where
12759 C: common::Connector,
12760{
12761 /// Perform the operation you have build so far.
12762 pub async fn doit(mut self) -> common::Result<(common::Response, ListModelsResponse)> {
12763 use std::borrow::Cow;
12764 use std::io::{Read, Seek};
12765
12766 use common::{url::Params, ToParts};
12767 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12768
12769 let mut dd = common::DefaultDelegate;
12770 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12771 dlg.begin(common::MethodInfo {
12772 id: "translate.projects.locations.models.list",
12773 http_method: hyper::Method::GET,
12774 });
12775
12776 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
12777 if self._additional_params.contains_key(field) {
12778 dlg.finished(false);
12779 return Err(common::Error::FieldClash(field));
12780 }
12781 }
12782
12783 let mut params = Params::with_capacity(6 + self._additional_params.len());
12784 params.push("parent", self._parent);
12785 if let Some(value) = self._page_token.as_ref() {
12786 params.push("pageToken", value);
12787 }
12788 if let Some(value) = self._page_size.as_ref() {
12789 params.push("pageSize", value.to_string());
12790 }
12791 if let Some(value) = self._filter.as_ref() {
12792 params.push("filter", value);
12793 }
12794
12795 params.extend(self._additional_params.iter());
12796
12797 params.push("alt", "json");
12798 let mut url = self.hub._base_url.clone() + "v3/{+parent}/models";
12799 if self._scopes.is_empty() {
12800 self._scopes
12801 .insert(Scope::CloudPlatform.as_ref().to_string());
12802 }
12803
12804 #[allow(clippy::single_element_loop)]
12805 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
12806 url = params.uri_replacement(url, param_name, find_this, true);
12807 }
12808 {
12809 let to_remove = ["parent"];
12810 params.remove_params(&to_remove);
12811 }
12812
12813 let url = params.parse_with_url(&url);
12814
12815 loop {
12816 let token = match self
12817 .hub
12818 .auth
12819 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12820 .await
12821 {
12822 Ok(token) => token,
12823 Err(e) => match dlg.token(e) {
12824 Ok(token) => token,
12825 Err(e) => {
12826 dlg.finished(false);
12827 return Err(common::Error::MissingToken(e));
12828 }
12829 },
12830 };
12831 let mut req_result = {
12832 let client = &self.hub.client;
12833 dlg.pre_request();
12834 let mut req_builder = hyper::Request::builder()
12835 .method(hyper::Method::GET)
12836 .uri(url.as_str())
12837 .header(USER_AGENT, self.hub._user_agent.clone());
12838
12839 if let Some(token) = token.as_ref() {
12840 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12841 }
12842
12843 let request = req_builder
12844 .header(CONTENT_LENGTH, 0_u64)
12845 .body(common::to_body::<String>(None));
12846
12847 client.request(request.unwrap()).await
12848 };
12849
12850 match req_result {
12851 Err(err) => {
12852 if let common::Retry::After(d) = dlg.http_error(&err) {
12853 sleep(d).await;
12854 continue;
12855 }
12856 dlg.finished(false);
12857 return Err(common::Error::HttpError(err));
12858 }
12859 Ok(res) => {
12860 let (mut parts, body) = res.into_parts();
12861 let mut body = common::Body::new(body);
12862 if !parts.status.is_success() {
12863 let bytes = common::to_bytes(body).await.unwrap_or_default();
12864 let error = serde_json::from_str(&common::to_string(&bytes));
12865 let response = common::to_response(parts, bytes.into());
12866
12867 if let common::Retry::After(d) =
12868 dlg.http_failure(&response, error.as_ref().ok())
12869 {
12870 sleep(d).await;
12871 continue;
12872 }
12873
12874 dlg.finished(false);
12875
12876 return Err(match error {
12877 Ok(value) => common::Error::BadRequest(value),
12878 _ => common::Error::Failure(response),
12879 });
12880 }
12881 let response = {
12882 let bytes = common::to_bytes(body).await.unwrap_or_default();
12883 let encoded = common::to_string(&bytes);
12884 match serde_json::from_str(&encoded) {
12885 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12886 Err(error) => {
12887 dlg.response_json_decode_error(&encoded, &error);
12888 return Err(common::Error::JsonDecodeError(
12889 encoded.to_string(),
12890 error,
12891 ));
12892 }
12893 }
12894 };
12895
12896 dlg.finished(true);
12897 return Ok(response);
12898 }
12899 }
12900 }
12901 }
12902
12903 /// Required. Name of the parent project. In form of `projects/{project-number-or-id}/locations/{location-id}`
12904 ///
12905 /// Sets the *parent* path property to the given value.
12906 ///
12907 /// Even though the property as already been set when instantiating this call,
12908 /// we provide this method for API completeness.
12909 pub fn parent(mut self, new_value: &str) -> ProjectLocationModelListCall<'a, C> {
12910 self._parent = new_value.to_string();
12911 self
12912 }
12913 /// Optional. A token identifying a page of results for the server to return. Typically obtained from next_page_token field in the response of a ListModels call.
12914 ///
12915 /// Sets the *page token* query property to the given value.
12916 pub fn page_token(mut self, new_value: &str) -> ProjectLocationModelListCall<'a, C> {
12917 self._page_token = Some(new_value.to_string());
12918 self
12919 }
12920 /// Optional. Requested page size. The server can return fewer results than requested.
12921 ///
12922 /// Sets the *page size* query property to the given value.
12923 pub fn page_size(mut self, new_value: i32) -> ProjectLocationModelListCall<'a, C> {
12924 self._page_size = Some(new_value);
12925 self
12926 }
12927 /// Optional. An expression for filtering the models that will be returned. Supported filter: `dataset_id=${dataset_id}`
12928 ///
12929 /// Sets the *filter* query property to the given value.
12930 pub fn filter(mut self, new_value: &str) -> ProjectLocationModelListCall<'a, C> {
12931 self._filter = Some(new_value.to_string());
12932 self
12933 }
12934 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12935 /// while executing the actual API request.
12936 ///
12937 /// ````text
12938 /// It should be used to handle progress information, and to implement a certain level of resilience.
12939 /// ````
12940 ///
12941 /// Sets the *delegate* property to the given value.
12942 pub fn delegate(
12943 mut self,
12944 new_value: &'a mut dyn common::Delegate,
12945 ) -> ProjectLocationModelListCall<'a, C> {
12946 self._delegate = Some(new_value);
12947 self
12948 }
12949
12950 /// Set any additional parameter of the query string used in the request.
12951 /// It should be used to set parameters which are not yet available through their own
12952 /// setters.
12953 ///
12954 /// Please note that this method must not be used to set any of the known parameters
12955 /// which have their own setter method. If done anyway, the request will fail.
12956 ///
12957 /// # Additional Parameters
12958 ///
12959 /// * *$.xgafv* (query-string) - V1 error format.
12960 /// * *access_token* (query-string) - OAuth access token.
12961 /// * *alt* (query-string) - Data format for response.
12962 /// * *callback* (query-string) - JSONP
12963 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12964 /// * *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.
12965 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12966 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12967 /// * *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.
12968 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12969 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12970 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationModelListCall<'a, C>
12971 where
12972 T: AsRef<str>,
12973 {
12974 self._additional_params
12975 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12976 self
12977 }
12978
12979 /// Identifies the authorization scope for the method you are building.
12980 ///
12981 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12982 /// [`Scope::CloudPlatform`].
12983 ///
12984 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12985 /// tokens for more than one scope.
12986 ///
12987 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12988 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12989 /// sufficient, a read-write scope will do as well.
12990 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationModelListCall<'a, C>
12991 where
12992 St: AsRef<str>,
12993 {
12994 self._scopes.insert(String::from(scope.as_ref()));
12995 self
12996 }
12997 /// Identifies the authorization scope(s) for the method you are building.
12998 ///
12999 /// See [`Self::add_scope()`] for details.
13000 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationModelListCall<'a, C>
13001 where
13002 I: IntoIterator<Item = St>,
13003 St: AsRef<str>,
13004 {
13005 self._scopes
13006 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13007 self
13008 }
13009
13010 /// Removes all scopes, and no default scope will be used either.
13011 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13012 /// for details).
13013 pub fn clear_scopes(mut self) -> ProjectLocationModelListCall<'a, C> {
13014 self._scopes.clear();
13015 self
13016 }
13017}
13018
13019/// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of `1`, corresponding to `Code.CANCELLED`.
13020///
13021/// A builder for the *locations.operations.cancel* method supported by a *project* resource.
13022/// It is not used directly, but through a [`ProjectMethods`] instance.
13023///
13024/// # Example
13025///
13026/// Instantiate a resource method builder
13027///
13028/// ```test_harness,no_run
13029/// # extern crate hyper;
13030/// # extern crate hyper_rustls;
13031/// # extern crate google_translate3 as translate3;
13032/// use translate3::api::CancelOperationRequest;
13033/// # async fn dox() {
13034/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13035///
13036/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13037/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13038/// # .with_native_roots()
13039/// # .unwrap()
13040/// # .https_only()
13041/// # .enable_http2()
13042/// # .build();
13043///
13044/// # let executor = hyper_util::rt::TokioExecutor::new();
13045/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13046/// # secret,
13047/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13048/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13049/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13050/// # ),
13051/// # ).build().await.unwrap();
13052///
13053/// # let client = hyper_util::client::legacy::Client::builder(
13054/// # hyper_util::rt::TokioExecutor::new()
13055/// # )
13056/// # .build(
13057/// # hyper_rustls::HttpsConnectorBuilder::new()
13058/// # .with_native_roots()
13059/// # .unwrap()
13060/// # .https_or_http()
13061/// # .enable_http2()
13062/// # .build()
13063/// # );
13064/// # let mut hub = Translate::new(client, auth);
13065/// // As the method needs a request, you would usually fill it with the desired information
13066/// // into the respective structure. Some of the parts shown here might not be applicable !
13067/// // Values shown here are possibly random and not representative !
13068/// let mut req = CancelOperationRequest::default();
13069///
13070/// // You can configure optional parameters by calling the respective setters at will, and
13071/// // execute the final call using `doit()`.
13072/// // Values shown here are possibly random and not representative !
13073/// let result = hub.projects().locations_operations_cancel(req, "name")
13074/// .doit().await;
13075/// # }
13076/// ```
13077pub struct ProjectLocationOperationCancelCall<'a, C>
13078where
13079 C: 'a,
13080{
13081 hub: &'a Translate<C>,
13082 _request: CancelOperationRequest,
13083 _name: String,
13084 _delegate: Option<&'a mut dyn common::Delegate>,
13085 _additional_params: HashMap<String, String>,
13086 _scopes: BTreeSet<String>,
13087}
13088
13089impl<'a, C> common::CallBuilder for ProjectLocationOperationCancelCall<'a, C> {}
13090
13091impl<'a, C> ProjectLocationOperationCancelCall<'a, C>
13092where
13093 C: common::Connector,
13094{
13095 /// Perform the operation you have build so far.
13096 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
13097 use std::borrow::Cow;
13098 use std::io::{Read, Seek};
13099
13100 use common::{url::Params, ToParts};
13101 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13102
13103 let mut dd = common::DefaultDelegate;
13104 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13105 dlg.begin(common::MethodInfo {
13106 id: "translate.projects.locations.operations.cancel",
13107 http_method: hyper::Method::POST,
13108 });
13109
13110 for &field in ["alt", "name"].iter() {
13111 if self._additional_params.contains_key(field) {
13112 dlg.finished(false);
13113 return Err(common::Error::FieldClash(field));
13114 }
13115 }
13116
13117 let mut params = Params::with_capacity(4 + self._additional_params.len());
13118 params.push("name", self._name);
13119
13120 params.extend(self._additional_params.iter());
13121
13122 params.push("alt", "json");
13123 let mut url = self.hub._base_url.clone() + "v3/{+name}:cancel";
13124 if self._scopes.is_empty() {
13125 self._scopes
13126 .insert(Scope::CloudPlatform.as_ref().to_string());
13127 }
13128
13129 #[allow(clippy::single_element_loop)]
13130 for &(find_this, param_name) in [("{+name}", "name")].iter() {
13131 url = params.uri_replacement(url, param_name, find_this, true);
13132 }
13133 {
13134 let to_remove = ["name"];
13135 params.remove_params(&to_remove);
13136 }
13137
13138 let url = params.parse_with_url(&url);
13139
13140 let mut json_mime_type = mime::APPLICATION_JSON;
13141 let mut request_value_reader = {
13142 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13143 common::remove_json_null_values(&mut value);
13144 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13145 serde_json::to_writer(&mut dst, &value).unwrap();
13146 dst
13147 };
13148 let request_size = request_value_reader
13149 .seek(std::io::SeekFrom::End(0))
13150 .unwrap();
13151 request_value_reader
13152 .seek(std::io::SeekFrom::Start(0))
13153 .unwrap();
13154
13155 loop {
13156 let token = match self
13157 .hub
13158 .auth
13159 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13160 .await
13161 {
13162 Ok(token) => token,
13163 Err(e) => match dlg.token(e) {
13164 Ok(token) => token,
13165 Err(e) => {
13166 dlg.finished(false);
13167 return Err(common::Error::MissingToken(e));
13168 }
13169 },
13170 };
13171 request_value_reader
13172 .seek(std::io::SeekFrom::Start(0))
13173 .unwrap();
13174 let mut req_result = {
13175 let client = &self.hub.client;
13176 dlg.pre_request();
13177 let mut req_builder = hyper::Request::builder()
13178 .method(hyper::Method::POST)
13179 .uri(url.as_str())
13180 .header(USER_AGENT, self.hub._user_agent.clone());
13181
13182 if let Some(token) = token.as_ref() {
13183 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13184 }
13185
13186 let request = req_builder
13187 .header(CONTENT_TYPE, json_mime_type.to_string())
13188 .header(CONTENT_LENGTH, request_size as u64)
13189 .body(common::to_body(
13190 request_value_reader.get_ref().clone().into(),
13191 ));
13192
13193 client.request(request.unwrap()).await
13194 };
13195
13196 match req_result {
13197 Err(err) => {
13198 if let common::Retry::After(d) = dlg.http_error(&err) {
13199 sleep(d).await;
13200 continue;
13201 }
13202 dlg.finished(false);
13203 return Err(common::Error::HttpError(err));
13204 }
13205 Ok(res) => {
13206 let (mut parts, body) = res.into_parts();
13207 let mut body = common::Body::new(body);
13208 if !parts.status.is_success() {
13209 let bytes = common::to_bytes(body).await.unwrap_or_default();
13210 let error = serde_json::from_str(&common::to_string(&bytes));
13211 let response = common::to_response(parts, bytes.into());
13212
13213 if let common::Retry::After(d) =
13214 dlg.http_failure(&response, error.as_ref().ok())
13215 {
13216 sleep(d).await;
13217 continue;
13218 }
13219
13220 dlg.finished(false);
13221
13222 return Err(match error {
13223 Ok(value) => common::Error::BadRequest(value),
13224 _ => common::Error::Failure(response),
13225 });
13226 }
13227 let response = {
13228 let bytes = common::to_bytes(body).await.unwrap_or_default();
13229 let encoded = common::to_string(&bytes);
13230 match serde_json::from_str(&encoded) {
13231 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13232 Err(error) => {
13233 dlg.response_json_decode_error(&encoded, &error);
13234 return Err(common::Error::JsonDecodeError(
13235 encoded.to_string(),
13236 error,
13237 ));
13238 }
13239 }
13240 };
13241
13242 dlg.finished(true);
13243 return Ok(response);
13244 }
13245 }
13246 }
13247 }
13248
13249 ///
13250 /// Sets the *request* property to the given value.
13251 ///
13252 /// Even though the property as already been set when instantiating this call,
13253 /// we provide this method for API completeness.
13254 pub fn request(
13255 mut self,
13256 new_value: CancelOperationRequest,
13257 ) -> ProjectLocationOperationCancelCall<'a, C> {
13258 self._request = new_value;
13259 self
13260 }
13261 /// The name of the operation resource to be cancelled.
13262 ///
13263 /// Sets the *name* path property to the given value.
13264 ///
13265 /// Even though the property as already been set when instantiating this call,
13266 /// we provide this method for API completeness.
13267 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationCancelCall<'a, C> {
13268 self._name = new_value.to_string();
13269 self
13270 }
13271 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13272 /// while executing the actual API request.
13273 ///
13274 /// ````text
13275 /// It should be used to handle progress information, and to implement a certain level of resilience.
13276 /// ````
13277 ///
13278 /// Sets the *delegate* property to the given value.
13279 pub fn delegate(
13280 mut self,
13281 new_value: &'a mut dyn common::Delegate,
13282 ) -> ProjectLocationOperationCancelCall<'a, C> {
13283 self._delegate = Some(new_value);
13284 self
13285 }
13286
13287 /// Set any additional parameter of the query string used in the request.
13288 /// It should be used to set parameters which are not yet available through their own
13289 /// setters.
13290 ///
13291 /// Please note that this method must not be used to set any of the known parameters
13292 /// which have their own setter method. If done anyway, the request will fail.
13293 ///
13294 /// # Additional Parameters
13295 ///
13296 /// * *$.xgafv* (query-string) - V1 error format.
13297 /// * *access_token* (query-string) - OAuth access token.
13298 /// * *alt* (query-string) - Data format for response.
13299 /// * *callback* (query-string) - JSONP
13300 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13301 /// * *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.
13302 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13303 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13304 /// * *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.
13305 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13306 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13307 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationCancelCall<'a, C>
13308 where
13309 T: AsRef<str>,
13310 {
13311 self._additional_params
13312 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13313 self
13314 }
13315
13316 /// Identifies the authorization scope for the method you are building.
13317 ///
13318 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13319 /// [`Scope::CloudPlatform`].
13320 ///
13321 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13322 /// tokens for more than one scope.
13323 ///
13324 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13325 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13326 /// sufficient, a read-write scope will do as well.
13327 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationCancelCall<'a, C>
13328 where
13329 St: AsRef<str>,
13330 {
13331 self._scopes.insert(String::from(scope.as_ref()));
13332 self
13333 }
13334 /// Identifies the authorization scope(s) for the method you are building.
13335 ///
13336 /// See [`Self::add_scope()`] for details.
13337 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationCancelCall<'a, C>
13338 where
13339 I: IntoIterator<Item = St>,
13340 St: AsRef<str>,
13341 {
13342 self._scopes
13343 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13344 self
13345 }
13346
13347 /// Removes all scopes, and no default scope will be used either.
13348 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13349 /// for details).
13350 pub fn clear_scopes(mut self) -> ProjectLocationOperationCancelCall<'a, C> {
13351 self._scopes.clear();
13352 self
13353 }
13354}
13355
13356/// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`.
13357///
13358/// A builder for the *locations.operations.delete* method supported by a *project* resource.
13359/// It is not used directly, but through a [`ProjectMethods`] instance.
13360///
13361/// # Example
13362///
13363/// Instantiate a resource method builder
13364///
13365/// ```test_harness,no_run
13366/// # extern crate hyper;
13367/// # extern crate hyper_rustls;
13368/// # extern crate google_translate3 as translate3;
13369/// # async fn dox() {
13370/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13371///
13372/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13373/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13374/// # .with_native_roots()
13375/// # .unwrap()
13376/// # .https_only()
13377/// # .enable_http2()
13378/// # .build();
13379///
13380/// # let executor = hyper_util::rt::TokioExecutor::new();
13381/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13382/// # secret,
13383/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13384/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13385/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13386/// # ),
13387/// # ).build().await.unwrap();
13388///
13389/// # let client = hyper_util::client::legacy::Client::builder(
13390/// # hyper_util::rt::TokioExecutor::new()
13391/// # )
13392/// # .build(
13393/// # hyper_rustls::HttpsConnectorBuilder::new()
13394/// # .with_native_roots()
13395/// # .unwrap()
13396/// # .https_or_http()
13397/// # .enable_http2()
13398/// # .build()
13399/// # );
13400/// # let mut hub = Translate::new(client, auth);
13401/// // You can configure optional parameters by calling the respective setters at will, and
13402/// // execute the final call using `doit()`.
13403/// // Values shown here are possibly random and not representative !
13404/// let result = hub.projects().locations_operations_delete("name")
13405/// .doit().await;
13406/// # }
13407/// ```
13408pub struct ProjectLocationOperationDeleteCall<'a, C>
13409where
13410 C: 'a,
13411{
13412 hub: &'a Translate<C>,
13413 _name: String,
13414 _delegate: Option<&'a mut dyn common::Delegate>,
13415 _additional_params: HashMap<String, String>,
13416 _scopes: BTreeSet<String>,
13417}
13418
13419impl<'a, C> common::CallBuilder for ProjectLocationOperationDeleteCall<'a, C> {}
13420
13421impl<'a, C> ProjectLocationOperationDeleteCall<'a, C>
13422where
13423 C: common::Connector,
13424{
13425 /// Perform the operation you have build so far.
13426 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
13427 use std::borrow::Cow;
13428 use std::io::{Read, Seek};
13429
13430 use common::{url::Params, ToParts};
13431 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13432
13433 let mut dd = common::DefaultDelegate;
13434 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13435 dlg.begin(common::MethodInfo {
13436 id: "translate.projects.locations.operations.delete",
13437 http_method: hyper::Method::DELETE,
13438 });
13439
13440 for &field in ["alt", "name"].iter() {
13441 if self._additional_params.contains_key(field) {
13442 dlg.finished(false);
13443 return Err(common::Error::FieldClash(field));
13444 }
13445 }
13446
13447 let mut params = Params::with_capacity(3 + self._additional_params.len());
13448 params.push("name", self._name);
13449
13450 params.extend(self._additional_params.iter());
13451
13452 params.push("alt", "json");
13453 let mut url = self.hub._base_url.clone() + "v3/{+name}";
13454 if self._scopes.is_empty() {
13455 self._scopes
13456 .insert(Scope::CloudPlatform.as_ref().to_string());
13457 }
13458
13459 #[allow(clippy::single_element_loop)]
13460 for &(find_this, param_name) in [("{+name}", "name")].iter() {
13461 url = params.uri_replacement(url, param_name, find_this, true);
13462 }
13463 {
13464 let to_remove = ["name"];
13465 params.remove_params(&to_remove);
13466 }
13467
13468 let url = params.parse_with_url(&url);
13469
13470 loop {
13471 let token = match self
13472 .hub
13473 .auth
13474 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13475 .await
13476 {
13477 Ok(token) => token,
13478 Err(e) => match dlg.token(e) {
13479 Ok(token) => token,
13480 Err(e) => {
13481 dlg.finished(false);
13482 return Err(common::Error::MissingToken(e));
13483 }
13484 },
13485 };
13486 let mut req_result = {
13487 let client = &self.hub.client;
13488 dlg.pre_request();
13489 let mut req_builder = hyper::Request::builder()
13490 .method(hyper::Method::DELETE)
13491 .uri(url.as_str())
13492 .header(USER_AGENT, self.hub._user_agent.clone());
13493
13494 if let Some(token) = token.as_ref() {
13495 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13496 }
13497
13498 let request = req_builder
13499 .header(CONTENT_LENGTH, 0_u64)
13500 .body(common::to_body::<String>(None));
13501
13502 client.request(request.unwrap()).await
13503 };
13504
13505 match req_result {
13506 Err(err) => {
13507 if let common::Retry::After(d) = dlg.http_error(&err) {
13508 sleep(d).await;
13509 continue;
13510 }
13511 dlg.finished(false);
13512 return Err(common::Error::HttpError(err));
13513 }
13514 Ok(res) => {
13515 let (mut parts, body) = res.into_parts();
13516 let mut body = common::Body::new(body);
13517 if !parts.status.is_success() {
13518 let bytes = common::to_bytes(body).await.unwrap_or_default();
13519 let error = serde_json::from_str(&common::to_string(&bytes));
13520 let response = common::to_response(parts, bytes.into());
13521
13522 if let common::Retry::After(d) =
13523 dlg.http_failure(&response, error.as_ref().ok())
13524 {
13525 sleep(d).await;
13526 continue;
13527 }
13528
13529 dlg.finished(false);
13530
13531 return Err(match error {
13532 Ok(value) => common::Error::BadRequest(value),
13533 _ => common::Error::Failure(response),
13534 });
13535 }
13536 let response = {
13537 let bytes = common::to_bytes(body).await.unwrap_or_default();
13538 let encoded = common::to_string(&bytes);
13539 match serde_json::from_str(&encoded) {
13540 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13541 Err(error) => {
13542 dlg.response_json_decode_error(&encoded, &error);
13543 return Err(common::Error::JsonDecodeError(
13544 encoded.to_string(),
13545 error,
13546 ));
13547 }
13548 }
13549 };
13550
13551 dlg.finished(true);
13552 return Ok(response);
13553 }
13554 }
13555 }
13556 }
13557
13558 /// The name of the operation resource to be deleted.
13559 ///
13560 /// Sets the *name* path property to the given value.
13561 ///
13562 /// Even though the property as already been set when instantiating this call,
13563 /// we provide this method for API completeness.
13564 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationDeleteCall<'a, C> {
13565 self._name = new_value.to_string();
13566 self
13567 }
13568 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13569 /// while executing the actual API request.
13570 ///
13571 /// ````text
13572 /// It should be used to handle progress information, and to implement a certain level of resilience.
13573 /// ````
13574 ///
13575 /// Sets the *delegate* property to the given value.
13576 pub fn delegate(
13577 mut self,
13578 new_value: &'a mut dyn common::Delegate,
13579 ) -> ProjectLocationOperationDeleteCall<'a, C> {
13580 self._delegate = Some(new_value);
13581 self
13582 }
13583
13584 /// Set any additional parameter of the query string used in the request.
13585 /// It should be used to set parameters which are not yet available through their own
13586 /// setters.
13587 ///
13588 /// Please note that this method must not be used to set any of the known parameters
13589 /// which have their own setter method. If done anyway, the request will fail.
13590 ///
13591 /// # Additional Parameters
13592 ///
13593 /// * *$.xgafv* (query-string) - V1 error format.
13594 /// * *access_token* (query-string) - OAuth access token.
13595 /// * *alt* (query-string) - Data format for response.
13596 /// * *callback* (query-string) - JSONP
13597 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13598 /// * *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.
13599 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13600 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13601 /// * *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.
13602 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13603 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13604 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationDeleteCall<'a, C>
13605 where
13606 T: AsRef<str>,
13607 {
13608 self._additional_params
13609 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13610 self
13611 }
13612
13613 /// Identifies the authorization scope for the method you are building.
13614 ///
13615 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13616 /// [`Scope::CloudPlatform`].
13617 ///
13618 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13619 /// tokens for more than one scope.
13620 ///
13621 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13622 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13623 /// sufficient, a read-write scope will do as well.
13624 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationDeleteCall<'a, C>
13625 where
13626 St: AsRef<str>,
13627 {
13628 self._scopes.insert(String::from(scope.as_ref()));
13629 self
13630 }
13631 /// Identifies the authorization scope(s) for the method you are building.
13632 ///
13633 /// See [`Self::add_scope()`] for details.
13634 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationDeleteCall<'a, C>
13635 where
13636 I: IntoIterator<Item = St>,
13637 St: AsRef<str>,
13638 {
13639 self._scopes
13640 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13641 self
13642 }
13643
13644 /// Removes all scopes, and no default scope will be used either.
13645 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13646 /// for details).
13647 pub fn clear_scopes(mut self) -> ProjectLocationOperationDeleteCall<'a, C> {
13648 self._scopes.clear();
13649 self
13650 }
13651}
13652
13653/// 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.
13654///
13655/// A builder for the *locations.operations.get* method supported by a *project* resource.
13656/// It is not used directly, but through a [`ProjectMethods`] instance.
13657///
13658/// # Example
13659///
13660/// Instantiate a resource method builder
13661///
13662/// ```test_harness,no_run
13663/// # extern crate hyper;
13664/// # extern crate hyper_rustls;
13665/// # extern crate google_translate3 as translate3;
13666/// # async fn dox() {
13667/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13668///
13669/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13670/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13671/// # .with_native_roots()
13672/// # .unwrap()
13673/// # .https_only()
13674/// # .enable_http2()
13675/// # .build();
13676///
13677/// # let executor = hyper_util::rt::TokioExecutor::new();
13678/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13679/// # secret,
13680/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13681/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13682/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13683/// # ),
13684/// # ).build().await.unwrap();
13685///
13686/// # let client = hyper_util::client::legacy::Client::builder(
13687/// # hyper_util::rt::TokioExecutor::new()
13688/// # )
13689/// # .build(
13690/// # hyper_rustls::HttpsConnectorBuilder::new()
13691/// # .with_native_roots()
13692/// # .unwrap()
13693/// # .https_or_http()
13694/// # .enable_http2()
13695/// # .build()
13696/// # );
13697/// # let mut hub = Translate::new(client, auth);
13698/// // You can configure optional parameters by calling the respective setters at will, and
13699/// // execute the final call using `doit()`.
13700/// // Values shown here are possibly random and not representative !
13701/// let result = hub.projects().locations_operations_get("name")
13702/// .doit().await;
13703/// # }
13704/// ```
13705pub struct ProjectLocationOperationGetCall<'a, C>
13706where
13707 C: 'a,
13708{
13709 hub: &'a Translate<C>,
13710 _name: String,
13711 _delegate: Option<&'a mut dyn common::Delegate>,
13712 _additional_params: HashMap<String, String>,
13713 _scopes: BTreeSet<String>,
13714}
13715
13716impl<'a, C> common::CallBuilder for ProjectLocationOperationGetCall<'a, C> {}
13717
13718impl<'a, C> ProjectLocationOperationGetCall<'a, C>
13719where
13720 C: common::Connector,
13721{
13722 /// Perform the operation you have build so far.
13723 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
13724 use std::borrow::Cow;
13725 use std::io::{Read, Seek};
13726
13727 use common::{url::Params, ToParts};
13728 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13729
13730 let mut dd = common::DefaultDelegate;
13731 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13732 dlg.begin(common::MethodInfo {
13733 id: "translate.projects.locations.operations.get",
13734 http_method: hyper::Method::GET,
13735 });
13736
13737 for &field in ["alt", "name"].iter() {
13738 if self._additional_params.contains_key(field) {
13739 dlg.finished(false);
13740 return Err(common::Error::FieldClash(field));
13741 }
13742 }
13743
13744 let mut params = Params::with_capacity(3 + self._additional_params.len());
13745 params.push("name", self._name);
13746
13747 params.extend(self._additional_params.iter());
13748
13749 params.push("alt", "json");
13750 let mut url = self.hub._base_url.clone() + "v3/{+name}";
13751 if self._scopes.is_empty() {
13752 self._scopes
13753 .insert(Scope::CloudPlatform.as_ref().to_string());
13754 }
13755
13756 #[allow(clippy::single_element_loop)]
13757 for &(find_this, param_name) in [("{+name}", "name")].iter() {
13758 url = params.uri_replacement(url, param_name, find_this, true);
13759 }
13760 {
13761 let to_remove = ["name"];
13762 params.remove_params(&to_remove);
13763 }
13764
13765 let url = params.parse_with_url(&url);
13766
13767 loop {
13768 let token = match self
13769 .hub
13770 .auth
13771 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13772 .await
13773 {
13774 Ok(token) => token,
13775 Err(e) => match dlg.token(e) {
13776 Ok(token) => token,
13777 Err(e) => {
13778 dlg.finished(false);
13779 return Err(common::Error::MissingToken(e));
13780 }
13781 },
13782 };
13783 let mut req_result = {
13784 let client = &self.hub.client;
13785 dlg.pre_request();
13786 let mut req_builder = hyper::Request::builder()
13787 .method(hyper::Method::GET)
13788 .uri(url.as_str())
13789 .header(USER_AGENT, self.hub._user_agent.clone());
13790
13791 if let Some(token) = token.as_ref() {
13792 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13793 }
13794
13795 let request = req_builder
13796 .header(CONTENT_LENGTH, 0_u64)
13797 .body(common::to_body::<String>(None));
13798
13799 client.request(request.unwrap()).await
13800 };
13801
13802 match req_result {
13803 Err(err) => {
13804 if let common::Retry::After(d) = dlg.http_error(&err) {
13805 sleep(d).await;
13806 continue;
13807 }
13808 dlg.finished(false);
13809 return Err(common::Error::HttpError(err));
13810 }
13811 Ok(res) => {
13812 let (mut parts, body) = res.into_parts();
13813 let mut body = common::Body::new(body);
13814 if !parts.status.is_success() {
13815 let bytes = common::to_bytes(body).await.unwrap_or_default();
13816 let error = serde_json::from_str(&common::to_string(&bytes));
13817 let response = common::to_response(parts, bytes.into());
13818
13819 if let common::Retry::After(d) =
13820 dlg.http_failure(&response, error.as_ref().ok())
13821 {
13822 sleep(d).await;
13823 continue;
13824 }
13825
13826 dlg.finished(false);
13827
13828 return Err(match error {
13829 Ok(value) => common::Error::BadRequest(value),
13830 _ => common::Error::Failure(response),
13831 });
13832 }
13833 let response = {
13834 let bytes = common::to_bytes(body).await.unwrap_or_default();
13835 let encoded = common::to_string(&bytes);
13836 match serde_json::from_str(&encoded) {
13837 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13838 Err(error) => {
13839 dlg.response_json_decode_error(&encoded, &error);
13840 return Err(common::Error::JsonDecodeError(
13841 encoded.to_string(),
13842 error,
13843 ));
13844 }
13845 }
13846 };
13847
13848 dlg.finished(true);
13849 return Ok(response);
13850 }
13851 }
13852 }
13853 }
13854
13855 /// The name of the operation resource.
13856 ///
13857 /// Sets the *name* path property to the given value.
13858 ///
13859 /// Even though the property as already been set when instantiating this call,
13860 /// we provide this method for API completeness.
13861 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationGetCall<'a, C> {
13862 self._name = new_value.to_string();
13863 self
13864 }
13865 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13866 /// while executing the actual API request.
13867 ///
13868 /// ````text
13869 /// It should be used to handle progress information, and to implement a certain level of resilience.
13870 /// ````
13871 ///
13872 /// Sets the *delegate* property to the given value.
13873 pub fn delegate(
13874 mut self,
13875 new_value: &'a mut dyn common::Delegate,
13876 ) -> ProjectLocationOperationGetCall<'a, C> {
13877 self._delegate = Some(new_value);
13878 self
13879 }
13880
13881 /// Set any additional parameter of the query string used in the request.
13882 /// It should be used to set parameters which are not yet available through their own
13883 /// setters.
13884 ///
13885 /// Please note that this method must not be used to set any of the known parameters
13886 /// which have their own setter method. If done anyway, the request will fail.
13887 ///
13888 /// # Additional Parameters
13889 ///
13890 /// * *$.xgafv* (query-string) - V1 error format.
13891 /// * *access_token* (query-string) - OAuth access token.
13892 /// * *alt* (query-string) - Data format for response.
13893 /// * *callback* (query-string) - JSONP
13894 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13895 /// * *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.
13896 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13897 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13898 /// * *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.
13899 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13900 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13901 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationGetCall<'a, C>
13902 where
13903 T: AsRef<str>,
13904 {
13905 self._additional_params
13906 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13907 self
13908 }
13909
13910 /// Identifies the authorization scope for the method you are building.
13911 ///
13912 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13913 /// [`Scope::CloudPlatform`].
13914 ///
13915 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13916 /// tokens for more than one scope.
13917 ///
13918 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13919 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13920 /// sufficient, a read-write scope will do as well.
13921 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationGetCall<'a, C>
13922 where
13923 St: AsRef<str>,
13924 {
13925 self._scopes.insert(String::from(scope.as_ref()));
13926 self
13927 }
13928 /// Identifies the authorization scope(s) for the method you are building.
13929 ///
13930 /// See [`Self::add_scope()`] for details.
13931 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationGetCall<'a, C>
13932 where
13933 I: IntoIterator<Item = St>,
13934 St: AsRef<str>,
13935 {
13936 self._scopes
13937 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13938 self
13939 }
13940
13941 /// Removes all scopes, and no default scope will be used either.
13942 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13943 /// for details).
13944 pub fn clear_scopes(mut self) -> ProjectLocationOperationGetCall<'a, C> {
13945 self._scopes.clear();
13946 self
13947 }
13948}
13949
13950/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
13951///
13952/// A builder for the *locations.operations.list* method supported by a *project* resource.
13953/// It is not used directly, but through a [`ProjectMethods`] instance.
13954///
13955/// # Example
13956///
13957/// Instantiate a resource method builder
13958///
13959/// ```test_harness,no_run
13960/// # extern crate hyper;
13961/// # extern crate hyper_rustls;
13962/// # extern crate google_translate3 as translate3;
13963/// # async fn dox() {
13964/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13965///
13966/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13967/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13968/// # .with_native_roots()
13969/// # .unwrap()
13970/// # .https_only()
13971/// # .enable_http2()
13972/// # .build();
13973///
13974/// # let executor = hyper_util::rt::TokioExecutor::new();
13975/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13976/// # secret,
13977/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13978/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13979/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13980/// # ),
13981/// # ).build().await.unwrap();
13982///
13983/// # let client = hyper_util::client::legacy::Client::builder(
13984/// # hyper_util::rt::TokioExecutor::new()
13985/// # )
13986/// # .build(
13987/// # hyper_rustls::HttpsConnectorBuilder::new()
13988/// # .with_native_roots()
13989/// # .unwrap()
13990/// # .https_or_http()
13991/// # .enable_http2()
13992/// # .build()
13993/// # );
13994/// # let mut hub = Translate::new(client, auth);
13995/// // You can configure optional parameters by calling the respective setters at will, and
13996/// // execute the final call using `doit()`.
13997/// // Values shown here are possibly random and not representative !
13998/// let result = hub.projects().locations_operations_list("name")
13999/// .page_token("et")
14000/// .page_size(-95)
14001/// .filter("Stet")
14002/// .doit().await;
14003/// # }
14004/// ```
14005pub struct ProjectLocationOperationListCall<'a, C>
14006where
14007 C: 'a,
14008{
14009 hub: &'a Translate<C>,
14010 _name: String,
14011 _page_token: Option<String>,
14012 _page_size: Option<i32>,
14013 _filter: Option<String>,
14014 _delegate: Option<&'a mut dyn common::Delegate>,
14015 _additional_params: HashMap<String, String>,
14016 _scopes: BTreeSet<String>,
14017}
14018
14019impl<'a, C> common::CallBuilder for ProjectLocationOperationListCall<'a, C> {}
14020
14021impl<'a, C> ProjectLocationOperationListCall<'a, C>
14022where
14023 C: common::Connector,
14024{
14025 /// Perform the operation you have build so far.
14026 pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
14027 use std::borrow::Cow;
14028 use std::io::{Read, Seek};
14029
14030 use common::{url::Params, ToParts};
14031 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14032
14033 let mut dd = common::DefaultDelegate;
14034 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14035 dlg.begin(common::MethodInfo {
14036 id: "translate.projects.locations.operations.list",
14037 http_method: hyper::Method::GET,
14038 });
14039
14040 for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
14041 if self._additional_params.contains_key(field) {
14042 dlg.finished(false);
14043 return Err(common::Error::FieldClash(field));
14044 }
14045 }
14046
14047 let mut params = Params::with_capacity(6 + self._additional_params.len());
14048 params.push("name", self._name);
14049 if let Some(value) = self._page_token.as_ref() {
14050 params.push("pageToken", value);
14051 }
14052 if let Some(value) = self._page_size.as_ref() {
14053 params.push("pageSize", value.to_string());
14054 }
14055 if let Some(value) = self._filter.as_ref() {
14056 params.push("filter", value);
14057 }
14058
14059 params.extend(self._additional_params.iter());
14060
14061 params.push("alt", "json");
14062 let mut url = self.hub._base_url.clone() + "v3/{+name}/operations";
14063 if self._scopes.is_empty() {
14064 self._scopes
14065 .insert(Scope::CloudPlatform.as_ref().to_string());
14066 }
14067
14068 #[allow(clippy::single_element_loop)]
14069 for &(find_this, param_name) in [("{+name}", "name")].iter() {
14070 url = params.uri_replacement(url, param_name, find_this, true);
14071 }
14072 {
14073 let to_remove = ["name"];
14074 params.remove_params(&to_remove);
14075 }
14076
14077 let url = params.parse_with_url(&url);
14078
14079 loop {
14080 let token = match self
14081 .hub
14082 .auth
14083 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14084 .await
14085 {
14086 Ok(token) => token,
14087 Err(e) => match dlg.token(e) {
14088 Ok(token) => token,
14089 Err(e) => {
14090 dlg.finished(false);
14091 return Err(common::Error::MissingToken(e));
14092 }
14093 },
14094 };
14095 let mut req_result = {
14096 let client = &self.hub.client;
14097 dlg.pre_request();
14098 let mut req_builder = hyper::Request::builder()
14099 .method(hyper::Method::GET)
14100 .uri(url.as_str())
14101 .header(USER_AGENT, self.hub._user_agent.clone());
14102
14103 if let Some(token) = token.as_ref() {
14104 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14105 }
14106
14107 let request = req_builder
14108 .header(CONTENT_LENGTH, 0_u64)
14109 .body(common::to_body::<String>(None));
14110
14111 client.request(request.unwrap()).await
14112 };
14113
14114 match req_result {
14115 Err(err) => {
14116 if let common::Retry::After(d) = dlg.http_error(&err) {
14117 sleep(d).await;
14118 continue;
14119 }
14120 dlg.finished(false);
14121 return Err(common::Error::HttpError(err));
14122 }
14123 Ok(res) => {
14124 let (mut parts, body) = res.into_parts();
14125 let mut body = common::Body::new(body);
14126 if !parts.status.is_success() {
14127 let bytes = common::to_bytes(body).await.unwrap_or_default();
14128 let error = serde_json::from_str(&common::to_string(&bytes));
14129 let response = common::to_response(parts, bytes.into());
14130
14131 if let common::Retry::After(d) =
14132 dlg.http_failure(&response, error.as_ref().ok())
14133 {
14134 sleep(d).await;
14135 continue;
14136 }
14137
14138 dlg.finished(false);
14139
14140 return Err(match error {
14141 Ok(value) => common::Error::BadRequest(value),
14142 _ => common::Error::Failure(response),
14143 });
14144 }
14145 let response = {
14146 let bytes = common::to_bytes(body).await.unwrap_or_default();
14147 let encoded = common::to_string(&bytes);
14148 match serde_json::from_str(&encoded) {
14149 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14150 Err(error) => {
14151 dlg.response_json_decode_error(&encoded, &error);
14152 return Err(common::Error::JsonDecodeError(
14153 encoded.to_string(),
14154 error,
14155 ));
14156 }
14157 }
14158 };
14159
14160 dlg.finished(true);
14161 return Ok(response);
14162 }
14163 }
14164 }
14165 }
14166
14167 /// The name of the operation's parent resource.
14168 ///
14169 /// Sets the *name* path property to the given value.
14170 ///
14171 /// Even though the property as already been set when instantiating this call,
14172 /// we provide this method for API completeness.
14173 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
14174 self._name = new_value.to_string();
14175 self
14176 }
14177 /// The standard list page token.
14178 ///
14179 /// Sets the *page token* query property to the given value.
14180 pub fn page_token(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
14181 self._page_token = Some(new_value.to_string());
14182 self
14183 }
14184 /// The standard list page size.
14185 ///
14186 /// Sets the *page size* query property to the given value.
14187 pub fn page_size(mut self, new_value: i32) -> ProjectLocationOperationListCall<'a, C> {
14188 self._page_size = Some(new_value);
14189 self
14190 }
14191 /// The standard list filter.
14192 ///
14193 /// Sets the *filter* query property to the given value.
14194 pub fn filter(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
14195 self._filter = Some(new_value.to_string());
14196 self
14197 }
14198 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14199 /// while executing the actual API request.
14200 ///
14201 /// ````text
14202 /// It should be used to handle progress information, and to implement a certain level of resilience.
14203 /// ````
14204 ///
14205 /// Sets the *delegate* property to the given value.
14206 pub fn delegate(
14207 mut self,
14208 new_value: &'a mut dyn common::Delegate,
14209 ) -> ProjectLocationOperationListCall<'a, C> {
14210 self._delegate = Some(new_value);
14211 self
14212 }
14213
14214 /// Set any additional parameter of the query string used in the request.
14215 /// It should be used to set parameters which are not yet available through their own
14216 /// setters.
14217 ///
14218 /// Please note that this method must not be used to set any of the known parameters
14219 /// which have their own setter method. If done anyway, the request will fail.
14220 ///
14221 /// # Additional Parameters
14222 ///
14223 /// * *$.xgafv* (query-string) - V1 error format.
14224 /// * *access_token* (query-string) - OAuth access token.
14225 /// * *alt* (query-string) - Data format for response.
14226 /// * *callback* (query-string) - JSONP
14227 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14228 /// * *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.
14229 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14230 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14231 /// * *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.
14232 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14233 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14234 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationListCall<'a, C>
14235 where
14236 T: AsRef<str>,
14237 {
14238 self._additional_params
14239 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14240 self
14241 }
14242
14243 /// Identifies the authorization scope for the method you are building.
14244 ///
14245 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14246 /// [`Scope::CloudPlatform`].
14247 ///
14248 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14249 /// tokens for more than one scope.
14250 ///
14251 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14252 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14253 /// sufficient, a read-write scope will do as well.
14254 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationListCall<'a, C>
14255 where
14256 St: AsRef<str>,
14257 {
14258 self._scopes.insert(String::from(scope.as_ref()));
14259 self
14260 }
14261 /// Identifies the authorization scope(s) for the method you are building.
14262 ///
14263 /// See [`Self::add_scope()`] for details.
14264 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationListCall<'a, C>
14265 where
14266 I: IntoIterator<Item = St>,
14267 St: AsRef<str>,
14268 {
14269 self._scopes
14270 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14271 self
14272 }
14273
14274 /// Removes all scopes, and no default scope will be used either.
14275 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14276 /// for details).
14277 pub fn clear_scopes(mut self) -> ProjectLocationOperationListCall<'a, C> {
14278 self._scopes.clear();
14279 self
14280 }
14281}
14282
14283/// Waits until the specified long-running operation is done or reaches at most a specified timeout, returning the latest state. If the operation is already done, the latest state is immediately returned. If the timeout specified is greater than the default HTTP/RPC timeout, the HTTP/RPC timeout is used. If the server does not support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Note that this method is on a best-effort basis. It may return the latest state before the specified timeout (including immediately), meaning even an immediate response is no guarantee that the operation is done.
14284///
14285/// A builder for the *locations.operations.wait* method supported by a *project* resource.
14286/// It is not used directly, but through a [`ProjectMethods`] instance.
14287///
14288/// # Example
14289///
14290/// Instantiate a resource method builder
14291///
14292/// ```test_harness,no_run
14293/// # extern crate hyper;
14294/// # extern crate hyper_rustls;
14295/// # extern crate google_translate3 as translate3;
14296/// use translate3::api::WaitOperationRequest;
14297/// # async fn dox() {
14298/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14299///
14300/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14301/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14302/// # .with_native_roots()
14303/// # .unwrap()
14304/// # .https_only()
14305/// # .enable_http2()
14306/// # .build();
14307///
14308/// # let executor = hyper_util::rt::TokioExecutor::new();
14309/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14310/// # secret,
14311/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14312/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14313/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14314/// # ),
14315/// # ).build().await.unwrap();
14316///
14317/// # let client = hyper_util::client::legacy::Client::builder(
14318/// # hyper_util::rt::TokioExecutor::new()
14319/// # )
14320/// # .build(
14321/// # hyper_rustls::HttpsConnectorBuilder::new()
14322/// # .with_native_roots()
14323/// # .unwrap()
14324/// # .https_or_http()
14325/// # .enable_http2()
14326/// # .build()
14327/// # );
14328/// # let mut hub = Translate::new(client, auth);
14329/// // As the method needs a request, you would usually fill it with the desired information
14330/// // into the respective structure. Some of the parts shown here might not be applicable !
14331/// // Values shown here are possibly random and not representative !
14332/// let mut req = WaitOperationRequest::default();
14333///
14334/// // You can configure optional parameters by calling the respective setters at will, and
14335/// // execute the final call using `doit()`.
14336/// // Values shown here are possibly random and not representative !
14337/// let result = hub.projects().locations_operations_wait(req, "name")
14338/// .doit().await;
14339/// # }
14340/// ```
14341pub struct ProjectLocationOperationWaitCall<'a, C>
14342where
14343 C: 'a,
14344{
14345 hub: &'a Translate<C>,
14346 _request: WaitOperationRequest,
14347 _name: String,
14348 _delegate: Option<&'a mut dyn common::Delegate>,
14349 _additional_params: HashMap<String, String>,
14350 _scopes: BTreeSet<String>,
14351}
14352
14353impl<'a, C> common::CallBuilder for ProjectLocationOperationWaitCall<'a, C> {}
14354
14355impl<'a, C> ProjectLocationOperationWaitCall<'a, C>
14356where
14357 C: common::Connector,
14358{
14359 /// Perform the operation you have build so far.
14360 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
14361 use std::borrow::Cow;
14362 use std::io::{Read, Seek};
14363
14364 use common::{url::Params, ToParts};
14365 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14366
14367 let mut dd = common::DefaultDelegate;
14368 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14369 dlg.begin(common::MethodInfo {
14370 id: "translate.projects.locations.operations.wait",
14371 http_method: hyper::Method::POST,
14372 });
14373
14374 for &field in ["alt", "name"].iter() {
14375 if self._additional_params.contains_key(field) {
14376 dlg.finished(false);
14377 return Err(common::Error::FieldClash(field));
14378 }
14379 }
14380
14381 let mut params = Params::with_capacity(4 + self._additional_params.len());
14382 params.push("name", self._name);
14383
14384 params.extend(self._additional_params.iter());
14385
14386 params.push("alt", "json");
14387 let mut url = self.hub._base_url.clone() + "v3/{+name}:wait";
14388 if self._scopes.is_empty() {
14389 self._scopes
14390 .insert(Scope::CloudPlatform.as_ref().to_string());
14391 }
14392
14393 #[allow(clippy::single_element_loop)]
14394 for &(find_this, param_name) in [("{+name}", "name")].iter() {
14395 url = params.uri_replacement(url, param_name, find_this, true);
14396 }
14397 {
14398 let to_remove = ["name"];
14399 params.remove_params(&to_remove);
14400 }
14401
14402 let url = params.parse_with_url(&url);
14403
14404 let mut json_mime_type = mime::APPLICATION_JSON;
14405 let mut request_value_reader = {
14406 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14407 common::remove_json_null_values(&mut value);
14408 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14409 serde_json::to_writer(&mut dst, &value).unwrap();
14410 dst
14411 };
14412 let request_size = request_value_reader
14413 .seek(std::io::SeekFrom::End(0))
14414 .unwrap();
14415 request_value_reader
14416 .seek(std::io::SeekFrom::Start(0))
14417 .unwrap();
14418
14419 loop {
14420 let token = match self
14421 .hub
14422 .auth
14423 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14424 .await
14425 {
14426 Ok(token) => token,
14427 Err(e) => match dlg.token(e) {
14428 Ok(token) => token,
14429 Err(e) => {
14430 dlg.finished(false);
14431 return Err(common::Error::MissingToken(e));
14432 }
14433 },
14434 };
14435 request_value_reader
14436 .seek(std::io::SeekFrom::Start(0))
14437 .unwrap();
14438 let mut req_result = {
14439 let client = &self.hub.client;
14440 dlg.pre_request();
14441 let mut req_builder = hyper::Request::builder()
14442 .method(hyper::Method::POST)
14443 .uri(url.as_str())
14444 .header(USER_AGENT, self.hub._user_agent.clone());
14445
14446 if let Some(token) = token.as_ref() {
14447 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14448 }
14449
14450 let request = req_builder
14451 .header(CONTENT_TYPE, json_mime_type.to_string())
14452 .header(CONTENT_LENGTH, request_size as u64)
14453 .body(common::to_body(
14454 request_value_reader.get_ref().clone().into(),
14455 ));
14456
14457 client.request(request.unwrap()).await
14458 };
14459
14460 match req_result {
14461 Err(err) => {
14462 if let common::Retry::After(d) = dlg.http_error(&err) {
14463 sleep(d).await;
14464 continue;
14465 }
14466 dlg.finished(false);
14467 return Err(common::Error::HttpError(err));
14468 }
14469 Ok(res) => {
14470 let (mut parts, body) = res.into_parts();
14471 let mut body = common::Body::new(body);
14472 if !parts.status.is_success() {
14473 let bytes = common::to_bytes(body).await.unwrap_or_default();
14474 let error = serde_json::from_str(&common::to_string(&bytes));
14475 let response = common::to_response(parts, bytes.into());
14476
14477 if let common::Retry::After(d) =
14478 dlg.http_failure(&response, error.as_ref().ok())
14479 {
14480 sleep(d).await;
14481 continue;
14482 }
14483
14484 dlg.finished(false);
14485
14486 return Err(match error {
14487 Ok(value) => common::Error::BadRequest(value),
14488 _ => common::Error::Failure(response),
14489 });
14490 }
14491 let response = {
14492 let bytes = common::to_bytes(body).await.unwrap_or_default();
14493 let encoded = common::to_string(&bytes);
14494 match serde_json::from_str(&encoded) {
14495 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14496 Err(error) => {
14497 dlg.response_json_decode_error(&encoded, &error);
14498 return Err(common::Error::JsonDecodeError(
14499 encoded.to_string(),
14500 error,
14501 ));
14502 }
14503 }
14504 };
14505
14506 dlg.finished(true);
14507 return Ok(response);
14508 }
14509 }
14510 }
14511 }
14512
14513 ///
14514 /// Sets the *request* property to the given value.
14515 ///
14516 /// Even though the property as already been set when instantiating this call,
14517 /// we provide this method for API completeness.
14518 pub fn request(
14519 mut self,
14520 new_value: WaitOperationRequest,
14521 ) -> ProjectLocationOperationWaitCall<'a, C> {
14522 self._request = new_value;
14523 self
14524 }
14525 /// The name of the operation resource to wait on.
14526 ///
14527 /// Sets the *name* path property to the given value.
14528 ///
14529 /// Even though the property as already been set when instantiating this call,
14530 /// we provide this method for API completeness.
14531 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationWaitCall<'a, C> {
14532 self._name = new_value.to_string();
14533 self
14534 }
14535 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14536 /// while executing the actual API request.
14537 ///
14538 /// ````text
14539 /// It should be used to handle progress information, and to implement a certain level of resilience.
14540 /// ````
14541 ///
14542 /// Sets the *delegate* property to the given value.
14543 pub fn delegate(
14544 mut self,
14545 new_value: &'a mut dyn common::Delegate,
14546 ) -> ProjectLocationOperationWaitCall<'a, C> {
14547 self._delegate = Some(new_value);
14548 self
14549 }
14550
14551 /// Set any additional parameter of the query string used in the request.
14552 /// It should be used to set parameters which are not yet available through their own
14553 /// setters.
14554 ///
14555 /// Please note that this method must not be used to set any of the known parameters
14556 /// which have their own setter method. If done anyway, the request will fail.
14557 ///
14558 /// # Additional Parameters
14559 ///
14560 /// * *$.xgafv* (query-string) - V1 error format.
14561 /// * *access_token* (query-string) - OAuth access token.
14562 /// * *alt* (query-string) - Data format for response.
14563 /// * *callback* (query-string) - JSONP
14564 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14565 /// * *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.
14566 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14567 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14568 /// * *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.
14569 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14570 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14571 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationWaitCall<'a, C>
14572 where
14573 T: AsRef<str>,
14574 {
14575 self._additional_params
14576 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14577 self
14578 }
14579
14580 /// Identifies the authorization scope for the method you are building.
14581 ///
14582 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14583 /// [`Scope::CloudPlatform`].
14584 ///
14585 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14586 /// tokens for more than one scope.
14587 ///
14588 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14589 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14590 /// sufficient, a read-write scope will do as well.
14591 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationWaitCall<'a, C>
14592 where
14593 St: AsRef<str>,
14594 {
14595 self._scopes.insert(String::from(scope.as_ref()));
14596 self
14597 }
14598 /// Identifies the authorization scope(s) for the method you are building.
14599 ///
14600 /// See [`Self::add_scope()`] for details.
14601 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationWaitCall<'a, C>
14602 where
14603 I: IntoIterator<Item = St>,
14604 St: AsRef<str>,
14605 {
14606 self._scopes
14607 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14608 self
14609 }
14610
14611 /// Removes all scopes, and no default scope will be used either.
14612 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14613 /// for details).
14614 pub fn clear_scopes(mut self) -> ProjectLocationOperationWaitCall<'a, C> {
14615 self._scopes.clear();
14616 self
14617 }
14618}
14619
14620/// Translate text using Adaptive MT.
14621///
14622/// A builder for the *locations.adaptiveMtTranslate* method supported by a *project* resource.
14623/// It is not used directly, but through a [`ProjectMethods`] instance.
14624///
14625/// # Example
14626///
14627/// Instantiate a resource method builder
14628///
14629/// ```test_harness,no_run
14630/// # extern crate hyper;
14631/// # extern crate hyper_rustls;
14632/// # extern crate google_translate3 as translate3;
14633/// use translate3::api::AdaptiveMtTranslateRequest;
14634/// # async fn dox() {
14635/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14636///
14637/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14638/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14639/// # .with_native_roots()
14640/// # .unwrap()
14641/// # .https_only()
14642/// # .enable_http2()
14643/// # .build();
14644///
14645/// # let executor = hyper_util::rt::TokioExecutor::new();
14646/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14647/// # secret,
14648/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14649/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14650/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14651/// # ),
14652/// # ).build().await.unwrap();
14653///
14654/// # let client = hyper_util::client::legacy::Client::builder(
14655/// # hyper_util::rt::TokioExecutor::new()
14656/// # )
14657/// # .build(
14658/// # hyper_rustls::HttpsConnectorBuilder::new()
14659/// # .with_native_roots()
14660/// # .unwrap()
14661/// # .https_or_http()
14662/// # .enable_http2()
14663/// # .build()
14664/// # );
14665/// # let mut hub = Translate::new(client, auth);
14666/// // As the method needs a request, you would usually fill it with the desired information
14667/// // into the respective structure. Some of the parts shown here might not be applicable !
14668/// // Values shown here are possibly random and not representative !
14669/// let mut req = AdaptiveMtTranslateRequest::default();
14670///
14671/// // You can configure optional parameters by calling the respective setters at will, and
14672/// // execute the final call using `doit()`.
14673/// // Values shown here are possibly random and not representative !
14674/// let result = hub.projects().locations_adaptive_mt_translate(req, "parent")
14675/// .doit().await;
14676/// # }
14677/// ```
14678pub struct ProjectLocationAdaptiveMtTranslateCall<'a, C>
14679where
14680 C: 'a,
14681{
14682 hub: &'a Translate<C>,
14683 _request: AdaptiveMtTranslateRequest,
14684 _parent: String,
14685 _delegate: Option<&'a mut dyn common::Delegate>,
14686 _additional_params: HashMap<String, String>,
14687 _scopes: BTreeSet<String>,
14688}
14689
14690impl<'a, C> common::CallBuilder for ProjectLocationAdaptiveMtTranslateCall<'a, C> {}
14691
14692impl<'a, C> ProjectLocationAdaptiveMtTranslateCall<'a, C>
14693where
14694 C: common::Connector,
14695{
14696 /// Perform the operation you have build so far.
14697 pub async fn doit(mut self) -> common::Result<(common::Response, AdaptiveMtTranslateResponse)> {
14698 use std::borrow::Cow;
14699 use std::io::{Read, Seek};
14700
14701 use common::{url::Params, ToParts};
14702 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14703
14704 let mut dd = common::DefaultDelegate;
14705 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14706 dlg.begin(common::MethodInfo {
14707 id: "translate.projects.locations.adaptiveMtTranslate",
14708 http_method: hyper::Method::POST,
14709 });
14710
14711 for &field in ["alt", "parent"].iter() {
14712 if self._additional_params.contains_key(field) {
14713 dlg.finished(false);
14714 return Err(common::Error::FieldClash(field));
14715 }
14716 }
14717
14718 let mut params = Params::with_capacity(4 + self._additional_params.len());
14719 params.push("parent", self._parent);
14720
14721 params.extend(self._additional_params.iter());
14722
14723 params.push("alt", "json");
14724 let mut url = self.hub._base_url.clone() + "v3/{+parent}:adaptiveMtTranslate";
14725 if self._scopes.is_empty() {
14726 self._scopes
14727 .insert(Scope::CloudPlatform.as_ref().to_string());
14728 }
14729
14730 #[allow(clippy::single_element_loop)]
14731 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
14732 url = params.uri_replacement(url, param_name, find_this, true);
14733 }
14734 {
14735 let to_remove = ["parent"];
14736 params.remove_params(&to_remove);
14737 }
14738
14739 let url = params.parse_with_url(&url);
14740
14741 let mut json_mime_type = mime::APPLICATION_JSON;
14742 let mut request_value_reader = {
14743 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14744 common::remove_json_null_values(&mut value);
14745 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14746 serde_json::to_writer(&mut dst, &value).unwrap();
14747 dst
14748 };
14749 let request_size = request_value_reader
14750 .seek(std::io::SeekFrom::End(0))
14751 .unwrap();
14752 request_value_reader
14753 .seek(std::io::SeekFrom::Start(0))
14754 .unwrap();
14755
14756 loop {
14757 let token = match self
14758 .hub
14759 .auth
14760 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14761 .await
14762 {
14763 Ok(token) => token,
14764 Err(e) => match dlg.token(e) {
14765 Ok(token) => token,
14766 Err(e) => {
14767 dlg.finished(false);
14768 return Err(common::Error::MissingToken(e));
14769 }
14770 },
14771 };
14772 request_value_reader
14773 .seek(std::io::SeekFrom::Start(0))
14774 .unwrap();
14775 let mut req_result = {
14776 let client = &self.hub.client;
14777 dlg.pre_request();
14778 let mut req_builder = hyper::Request::builder()
14779 .method(hyper::Method::POST)
14780 .uri(url.as_str())
14781 .header(USER_AGENT, self.hub._user_agent.clone());
14782
14783 if let Some(token) = token.as_ref() {
14784 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14785 }
14786
14787 let request = req_builder
14788 .header(CONTENT_TYPE, json_mime_type.to_string())
14789 .header(CONTENT_LENGTH, request_size as u64)
14790 .body(common::to_body(
14791 request_value_reader.get_ref().clone().into(),
14792 ));
14793
14794 client.request(request.unwrap()).await
14795 };
14796
14797 match req_result {
14798 Err(err) => {
14799 if let common::Retry::After(d) = dlg.http_error(&err) {
14800 sleep(d).await;
14801 continue;
14802 }
14803 dlg.finished(false);
14804 return Err(common::Error::HttpError(err));
14805 }
14806 Ok(res) => {
14807 let (mut parts, body) = res.into_parts();
14808 let mut body = common::Body::new(body);
14809 if !parts.status.is_success() {
14810 let bytes = common::to_bytes(body).await.unwrap_or_default();
14811 let error = serde_json::from_str(&common::to_string(&bytes));
14812 let response = common::to_response(parts, bytes.into());
14813
14814 if let common::Retry::After(d) =
14815 dlg.http_failure(&response, error.as_ref().ok())
14816 {
14817 sleep(d).await;
14818 continue;
14819 }
14820
14821 dlg.finished(false);
14822
14823 return Err(match error {
14824 Ok(value) => common::Error::BadRequest(value),
14825 _ => common::Error::Failure(response),
14826 });
14827 }
14828 let response = {
14829 let bytes = common::to_bytes(body).await.unwrap_or_default();
14830 let encoded = common::to_string(&bytes);
14831 match serde_json::from_str(&encoded) {
14832 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14833 Err(error) => {
14834 dlg.response_json_decode_error(&encoded, &error);
14835 return Err(common::Error::JsonDecodeError(
14836 encoded.to_string(),
14837 error,
14838 ));
14839 }
14840 }
14841 };
14842
14843 dlg.finished(true);
14844 return Ok(response);
14845 }
14846 }
14847 }
14848 }
14849
14850 ///
14851 /// Sets the *request* property to the given value.
14852 ///
14853 /// Even though the property as already been set when instantiating this call,
14854 /// we provide this method for API completeness.
14855 pub fn request(
14856 mut self,
14857 new_value: AdaptiveMtTranslateRequest,
14858 ) -> ProjectLocationAdaptiveMtTranslateCall<'a, C> {
14859 self._request = new_value;
14860 self
14861 }
14862 /// Required. Location to make a regional call. Format: `projects/{project-number-or-id}/locations/{location-id}`.
14863 ///
14864 /// Sets the *parent* path property to the given value.
14865 ///
14866 /// Even though the property as already been set when instantiating this call,
14867 /// we provide this method for API completeness.
14868 pub fn parent(mut self, new_value: &str) -> ProjectLocationAdaptiveMtTranslateCall<'a, C> {
14869 self._parent = new_value.to_string();
14870 self
14871 }
14872 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14873 /// while executing the actual API request.
14874 ///
14875 /// ````text
14876 /// It should be used to handle progress information, and to implement a certain level of resilience.
14877 /// ````
14878 ///
14879 /// Sets the *delegate* property to the given value.
14880 pub fn delegate(
14881 mut self,
14882 new_value: &'a mut dyn common::Delegate,
14883 ) -> ProjectLocationAdaptiveMtTranslateCall<'a, C> {
14884 self._delegate = Some(new_value);
14885 self
14886 }
14887
14888 /// Set any additional parameter of the query string used in the request.
14889 /// It should be used to set parameters which are not yet available through their own
14890 /// setters.
14891 ///
14892 /// Please note that this method must not be used to set any of the known parameters
14893 /// which have their own setter method. If done anyway, the request will fail.
14894 ///
14895 /// # Additional Parameters
14896 ///
14897 /// * *$.xgafv* (query-string) - V1 error format.
14898 /// * *access_token* (query-string) - OAuth access token.
14899 /// * *alt* (query-string) - Data format for response.
14900 /// * *callback* (query-string) - JSONP
14901 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14902 /// * *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.
14903 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14904 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14905 /// * *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.
14906 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14907 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14908 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationAdaptiveMtTranslateCall<'a, C>
14909 where
14910 T: AsRef<str>,
14911 {
14912 self._additional_params
14913 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14914 self
14915 }
14916
14917 /// Identifies the authorization scope for the method you are building.
14918 ///
14919 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14920 /// [`Scope::CloudPlatform`].
14921 ///
14922 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14923 /// tokens for more than one scope.
14924 ///
14925 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14926 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14927 /// sufficient, a read-write scope will do as well.
14928 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationAdaptiveMtTranslateCall<'a, C>
14929 where
14930 St: AsRef<str>,
14931 {
14932 self._scopes.insert(String::from(scope.as_ref()));
14933 self
14934 }
14935 /// Identifies the authorization scope(s) for the method you are building.
14936 ///
14937 /// See [`Self::add_scope()`] for details.
14938 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationAdaptiveMtTranslateCall<'a, C>
14939 where
14940 I: IntoIterator<Item = St>,
14941 St: AsRef<str>,
14942 {
14943 self._scopes
14944 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14945 self
14946 }
14947
14948 /// Removes all scopes, and no default scope will be used either.
14949 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14950 /// for details).
14951 pub fn clear_scopes(mut self) -> ProjectLocationAdaptiveMtTranslateCall<'a, C> {
14952 self._scopes.clear();
14953 self
14954 }
14955}
14956
14957/// Translates a large volume of document in asynchronous batch mode. This function provides real-time output as the inputs are being processed. If caller cancels a request, the partial results (for an input file, it's all or nothing) may still be available on the specified output location. This call returns immediately and you can use google.longrunning.Operation.name to poll the status of the call.
14958///
14959/// A builder for the *locations.batchTranslateDocument* method supported by a *project* resource.
14960/// It is not used directly, but through a [`ProjectMethods`] instance.
14961///
14962/// # Example
14963///
14964/// Instantiate a resource method builder
14965///
14966/// ```test_harness,no_run
14967/// # extern crate hyper;
14968/// # extern crate hyper_rustls;
14969/// # extern crate google_translate3 as translate3;
14970/// use translate3::api::BatchTranslateDocumentRequest;
14971/// # async fn dox() {
14972/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14973///
14974/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14975/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14976/// # .with_native_roots()
14977/// # .unwrap()
14978/// # .https_only()
14979/// # .enable_http2()
14980/// # .build();
14981///
14982/// # let executor = hyper_util::rt::TokioExecutor::new();
14983/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14984/// # secret,
14985/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14986/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14987/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14988/// # ),
14989/// # ).build().await.unwrap();
14990///
14991/// # let client = hyper_util::client::legacy::Client::builder(
14992/// # hyper_util::rt::TokioExecutor::new()
14993/// # )
14994/// # .build(
14995/// # hyper_rustls::HttpsConnectorBuilder::new()
14996/// # .with_native_roots()
14997/// # .unwrap()
14998/// # .https_or_http()
14999/// # .enable_http2()
15000/// # .build()
15001/// # );
15002/// # let mut hub = Translate::new(client, auth);
15003/// // As the method needs a request, you would usually fill it with the desired information
15004/// // into the respective structure. Some of the parts shown here might not be applicable !
15005/// // Values shown here are possibly random and not representative !
15006/// let mut req = BatchTranslateDocumentRequest::default();
15007///
15008/// // You can configure optional parameters by calling the respective setters at will, and
15009/// // execute the final call using `doit()`.
15010/// // Values shown here are possibly random and not representative !
15011/// let result = hub.projects().locations_batch_translate_document(req, "parent")
15012/// .doit().await;
15013/// # }
15014/// ```
15015pub struct ProjectLocationBatchTranslateDocumentCall<'a, C>
15016where
15017 C: 'a,
15018{
15019 hub: &'a Translate<C>,
15020 _request: BatchTranslateDocumentRequest,
15021 _parent: String,
15022 _delegate: Option<&'a mut dyn common::Delegate>,
15023 _additional_params: HashMap<String, String>,
15024 _scopes: BTreeSet<String>,
15025}
15026
15027impl<'a, C> common::CallBuilder for ProjectLocationBatchTranslateDocumentCall<'a, C> {}
15028
15029impl<'a, C> ProjectLocationBatchTranslateDocumentCall<'a, C>
15030where
15031 C: common::Connector,
15032{
15033 /// Perform the operation you have build so far.
15034 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
15035 use std::borrow::Cow;
15036 use std::io::{Read, Seek};
15037
15038 use common::{url::Params, ToParts};
15039 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15040
15041 let mut dd = common::DefaultDelegate;
15042 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15043 dlg.begin(common::MethodInfo {
15044 id: "translate.projects.locations.batchTranslateDocument",
15045 http_method: hyper::Method::POST,
15046 });
15047
15048 for &field in ["alt", "parent"].iter() {
15049 if self._additional_params.contains_key(field) {
15050 dlg.finished(false);
15051 return Err(common::Error::FieldClash(field));
15052 }
15053 }
15054
15055 let mut params = Params::with_capacity(4 + self._additional_params.len());
15056 params.push("parent", self._parent);
15057
15058 params.extend(self._additional_params.iter());
15059
15060 params.push("alt", "json");
15061 let mut url = self.hub._base_url.clone() + "v3/{+parent}:batchTranslateDocument";
15062 if self._scopes.is_empty() {
15063 self._scopes
15064 .insert(Scope::CloudPlatform.as_ref().to_string());
15065 }
15066
15067 #[allow(clippy::single_element_loop)]
15068 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
15069 url = params.uri_replacement(url, param_name, find_this, true);
15070 }
15071 {
15072 let to_remove = ["parent"];
15073 params.remove_params(&to_remove);
15074 }
15075
15076 let url = params.parse_with_url(&url);
15077
15078 let mut json_mime_type = mime::APPLICATION_JSON;
15079 let mut request_value_reader = {
15080 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15081 common::remove_json_null_values(&mut value);
15082 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15083 serde_json::to_writer(&mut dst, &value).unwrap();
15084 dst
15085 };
15086 let request_size = request_value_reader
15087 .seek(std::io::SeekFrom::End(0))
15088 .unwrap();
15089 request_value_reader
15090 .seek(std::io::SeekFrom::Start(0))
15091 .unwrap();
15092
15093 loop {
15094 let token = match self
15095 .hub
15096 .auth
15097 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15098 .await
15099 {
15100 Ok(token) => token,
15101 Err(e) => match dlg.token(e) {
15102 Ok(token) => token,
15103 Err(e) => {
15104 dlg.finished(false);
15105 return Err(common::Error::MissingToken(e));
15106 }
15107 },
15108 };
15109 request_value_reader
15110 .seek(std::io::SeekFrom::Start(0))
15111 .unwrap();
15112 let mut req_result = {
15113 let client = &self.hub.client;
15114 dlg.pre_request();
15115 let mut req_builder = hyper::Request::builder()
15116 .method(hyper::Method::POST)
15117 .uri(url.as_str())
15118 .header(USER_AGENT, self.hub._user_agent.clone());
15119
15120 if let Some(token) = token.as_ref() {
15121 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15122 }
15123
15124 let request = req_builder
15125 .header(CONTENT_TYPE, json_mime_type.to_string())
15126 .header(CONTENT_LENGTH, request_size as u64)
15127 .body(common::to_body(
15128 request_value_reader.get_ref().clone().into(),
15129 ));
15130
15131 client.request(request.unwrap()).await
15132 };
15133
15134 match req_result {
15135 Err(err) => {
15136 if let common::Retry::After(d) = dlg.http_error(&err) {
15137 sleep(d).await;
15138 continue;
15139 }
15140 dlg.finished(false);
15141 return Err(common::Error::HttpError(err));
15142 }
15143 Ok(res) => {
15144 let (mut parts, body) = res.into_parts();
15145 let mut body = common::Body::new(body);
15146 if !parts.status.is_success() {
15147 let bytes = common::to_bytes(body).await.unwrap_or_default();
15148 let error = serde_json::from_str(&common::to_string(&bytes));
15149 let response = common::to_response(parts, bytes.into());
15150
15151 if let common::Retry::After(d) =
15152 dlg.http_failure(&response, error.as_ref().ok())
15153 {
15154 sleep(d).await;
15155 continue;
15156 }
15157
15158 dlg.finished(false);
15159
15160 return Err(match error {
15161 Ok(value) => common::Error::BadRequest(value),
15162 _ => common::Error::Failure(response),
15163 });
15164 }
15165 let response = {
15166 let bytes = common::to_bytes(body).await.unwrap_or_default();
15167 let encoded = common::to_string(&bytes);
15168 match serde_json::from_str(&encoded) {
15169 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15170 Err(error) => {
15171 dlg.response_json_decode_error(&encoded, &error);
15172 return Err(common::Error::JsonDecodeError(
15173 encoded.to_string(),
15174 error,
15175 ));
15176 }
15177 }
15178 };
15179
15180 dlg.finished(true);
15181 return Ok(response);
15182 }
15183 }
15184 }
15185 }
15186
15187 ///
15188 /// Sets the *request* property to the given value.
15189 ///
15190 /// Even though the property as already been set when instantiating this call,
15191 /// we provide this method for API completeness.
15192 pub fn request(
15193 mut self,
15194 new_value: BatchTranslateDocumentRequest,
15195 ) -> ProjectLocationBatchTranslateDocumentCall<'a, C> {
15196 self._request = new_value;
15197 self
15198 }
15199 /// Required. Location to make a regional call. Format: `projects/{project-number-or-id}/locations/{location-id}`. The `global` location is not supported for batch translation. Only AutoML Translation models or glossaries within the same region (have the same location-id) can be used, otherwise an INVALID_ARGUMENT (400) error is returned.
15200 ///
15201 /// Sets the *parent* path property to the given value.
15202 ///
15203 /// Even though the property as already been set when instantiating this call,
15204 /// we provide this method for API completeness.
15205 pub fn parent(mut self, new_value: &str) -> ProjectLocationBatchTranslateDocumentCall<'a, C> {
15206 self._parent = new_value.to_string();
15207 self
15208 }
15209 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15210 /// while executing the actual API request.
15211 ///
15212 /// ````text
15213 /// It should be used to handle progress information, and to implement a certain level of resilience.
15214 /// ````
15215 ///
15216 /// Sets the *delegate* property to the given value.
15217 pub fn delegate(
15218 mut self,
15219 new_value: &'a mut dyn common::Delegate,
15220 ) -> ProjectLocationBatchTranslateDocumentCall<'a, C> {
15221 self._delegate = Some(new_value);
15222 self
15223 }
15224
15225 /// Set any additional parameter of the query string used in the request.
15226 /// It should be used to set parameters which are not yet available through their own
15227 /// setters.
15228 ///
15229 /// Please note that this method must not be used to set any of the known parameters
15230 /// which have their own setter method. If done anyway, the request will fail.
15231 ///
15232 /// # Additional Parameters
15233 ///
15234 /// * *$.xgafv* (query-string) - V1 error format.
15235 /// * *access_token* (query-string) - OAuth access token.
15236 /// * *alt* (query-string) - Data format for response.
15237 /// * *callback* (query-string) - JSONP
15238 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15239 /// * *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.
15240 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15241 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15242 /// * *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.
15243 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15244 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15245 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationBatchTranslateDocumentCall<'a, C>
15246 where
15247 T: AsRef<str>,
15248 {
15249 self._additional_params
15250 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15251 self
15252 }
15253
15254 /// Identifies the authorization scope for the method you are building.
15255 ///
15256 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15257 /// [`Scope::CloudPlatform`].
15258 ///
15259 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15260 /// tokens for more than one scope.
15261 ///
15262 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15263 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15264 /// sufficient, a read-write scope will do as well.
15265 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationBatchTranslateDocumentCall<'a, C>
15266 where
15267 St: AsRef<str>,
15268 {
15269 self._scopes.insert(String::from(scope.as_ref()));
15270 self
15271 }
15272 /// Identifies the authorization scope(s) for the method you are building.
15273 ///
15274 /// See [`Self::add_scope()`] for details.
15275 pub fn add_scopes<I, St>(
15276 mut self,
15277 scopes: I,
15278 ) -> ProjectLocationBatchTranslateDocumentCall<'a, C>
15279 where
15280 I: IntoIterator<Item = St>,
15281 St: AsRef<str>,
15282 {
15283 self._scopes
15284 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15285 self
15286 }
15287
15288 /// Removes all scopes, and no default scope will be used either.
15289 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15290 /// for details).
15291 pub fn clear_scopes(mut self) -> ProjectLocationBatchTranslateDocumentCall<'a, C> {
15292 self._scopes.clear();
15293 self
15294 }
15295}
15296
15297/// Translates a large volume of text in asynchronous batch mode. This function provides real-time output as the inputs are being processed. If caller cancels a request, the partial results (for an input file, it's all or nothing) may still be available on the specified output location. This call returns immediately and you can use google.longrunning.Operation.name to poll the status of the call.
15298///
15299/// A builder for the *locations.batchTranslateText* method supported by a *project* resource.
15300/// It is not used directly, but through a [`ProjectMethods`] instance.
15301///
15302/// # Example
15303///
15304/// Instantiate a resource method builder
15305///
15306/// ```test_harness,no_run
15307/// # extern crate hyper;
15308/// # extern crate hyper_rustls;
15309/// # extern crate google_translate3 as translate3;
15310/// use translate3::api::BatchTranslateTextRequest;
15311/// # async fn dox() {
15312/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15313///
15314/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15315/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15316/// # .with_native_roots()
15317/// # .unwrap()
15318/// # .https_only()
15319/// # .enable_http2()
15320/// # .build();
15321///
15322/// # let executor = hyper_util::rt::TokioExecutor::new();
15323/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15324/// # secret,
15325/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15326/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15327/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15328/// # ),
15329/// # ).build().await.unwrap();
15330///
15331/// # let client = hyper_util::client::legacy::Client::builder(
15332/// # hyper_util::rt::TokioExecutor::new()
15333/// # )
15334/// # .build(
15335/// # hyper_rustls::HttpsConnectorBuilder::new()
15336/// # .with_native_roots()
15337/// # .unwrap()
15338/// # .https_or_http()
15339/// # .enable_http2()
15340/// # .build()
15341/// # );
15342/// # let mut hub = Translate::new(client, auth);
15343/// // As the method needs a request, you would usually fill it with the desired information
15344/// // into the respective structure. Some of the parts shown here might not be applicable !
15345/// // Values shown here are possibly random and not representative !
15346/// let mut req = BatchTranslateTextRequest::default();
15347///
15348/// // You can configure optional parameters by calling the respective setters at will, and
15349/// // execute the final call using `doit()`.
15350/// // Values shown here are possibly random and not representative !
15351/// let result = hub.projects().locations_batch_translate_text(req, "parent")
15352/// .doit().await;
15353/// # }
15354/// ```
15355pub struct ProjectLocationBatchTranslateTextCall<'a, C>
15356where
15357 C: 'a,
15358{
15359 hub: &'a Translate<C>,
15360 _request: BatchTranslateTextRequest,
15361 _parent: String,
15362 _delegate: Option<&'a mut dyn common::Delegate>,
15363 _additional_params: HashMap<String, String>,
15364 _scopes: BTreeSet<String>,
15365}
15366
15367impl<'a, C> common::CallBuilder for ProjectLocationBatchTranslateTextCall<'a, C> {}
15368
15369impl<'a, C> ProjectLocationBatchTranslateTextCall<'a, C>
15370where
15371 C: common::Connector,
15372{
15373 /// Perform the operation you have build so far.
15374 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
15375 use std::borrow::Cow;
15376 use std::io::{Read, Seek};
15377
15378 use common::{url::Params, ToParts};
15379 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15380
15381 let mut dd = common::DefaultDelegate;
15382 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15383 dlg.begin(common::MethodInfo {
15384 id: "translate.projects.locations.batchTranslateText",
15385 http_method: hyper::Method::POST,
15386 });
15387
15388 for &field in ["alt", "parent"].iter() {
15389 if self._additional_params.contains_key(field) {
15390 dlg.finished(false);
15391 return Err(common::Error::FieldClash(field));
15392 }
15393 }
15394
15395 let mut params = Params::with_capacity(4 + self._additional_params.len());
15396 params.push("parent", self._parent);
15397
15398 params.extend(self._additional_params.iter());
15399
15400 params.push("alt", "json");
15401 let mut url = self.hub._base_url.clone() + "v3/{+parent}:batchTranslateText";
15402 if self._scopes.is_empty() {
15403 self._scopes
15404 .insert(Scope::CloudPlatform.as_ref().to_string());
15405 }
15406
15407 #[allow(clippy::single_element_loop)]
15408 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
15409 url = params.uri_replacement(url, param_name, find_this, true);
15410 }
15411 {
15412 let to_remove = ["parent"];
15413 params.remove_params(&to_remove);
15414 }
15415
15416 let url = params.parse_with_url(&url);
15417
15418 let mut json_mime_type = mime::APPLICATION_JSON;
15419 let mut request_value_reader = {
15420 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15421 common::remove_json_null_values(&mut value);
15422 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15423 serde_json::to_writer(&mut dst, &value).unwrap();
15424 dst
15425 };
15426 let request_size = request_value_reader
15427 .seek(std::io::SeekFrom::End(0))
15428 .unwrap();
15429 request_value_reader
15430 .seek(std::io::SeekFrom::Start(0))
15431 .unwrap();
15432
15433 loop {
15434 let token = match self
15435 .hub
15436 .auth
15437 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15438 .await
15439 {
15440 Ok(token) => token,
15441 Err(e) => match dlg.token(e) {
15442 Ok(token) => token,
15443 Err(e) => {
15444 dlg.finished(false);
15445 return Err(common::Error::MissingToken(e));
15446 }
15447 },
15448 };
15449 request_value_reader
15450 .seek(std::io::SeekFrom::Start(0))
15451 .unwrap();
15452 let mut req_result = {
15453 let client = &self.hub.client;
15454 dlg.pre_request();
15455 let mut req_builder = hyper::Request::builder()
15456 .method(hyper::Method::POST)
15457 .uri(url.as_str())
15458 .header(USER_AGENT, self.hub._user_agent.clone());
15459
15460 if let Some(token) = token.as_ref() {
15461 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15462 }
15463
15464 let request = req_builder
15465 .header(CONTENT_TYPE, json_mime_type.to_string())
15466 .header(CONTENT_LENGTH, request_size as u64)
15467 .body(common::to_body(
15468 request_value_reader.get_ref().clone().into(),
15469 ));
15470
15471 client.request(request.unwrap()).await
15472 };
15473
15474 match req_result {
15475 Err(err) => {
15476 if let common::Retry::After(d) = dlg.http_error(&err) {
15477 sleep(d).await;
15478 continue;
15479 }
15480 dlg.finished(false);
15481 return Err(common::Error::HttpError(err));
15482 }
15483 Ok(res) => {
15484 let (mut parts, body) = res.into_parts();
15485 let mut body = common::Body::new(body);
15486 if !parts.status.is_success() {
15487 let bytes = common::to_bytes(body).await.unwrap_or_default();
15488 let error = serde_json::from_str(&common::to_string(&bytes));
15489 let response = common::to_response(parts, bytes.into());
15490
15491 if let common::Retry::After(d) =
15492 dlg.http_failure(&response, error.as_ref().ok())
15493 {
15494 sleep(d).await;
15495 continue;
15496 }
15497
15498 dlg.finished(false);
15499
15500 return Err(match error {
15501 Ok(value) => common::Error::BadRequest(value),
15502 _ => common::Error::Failure(response),
15503 });
15504 }
15505 let response = {
15506 let bytes = common::to_bytes(body).await.unwrap_or_default();
15507 let encoded = common::to_string(&bytes);
15508 match serde_json::from_str(&encoded) {
15509 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15510 Err(error) => {
15511 dlg.response_json_decode_error(&encoded, &error);
15512 return Err(common::Error::JsonDecodeError(
15513 encoded.to_string(),
15514 error,
15515 ));
15516 }
15517 }
15518 };
15519
15520 dlg.finished(true);
15521 return Ok(response);
15522 }
15523 }
15524 }
15525 }
15526
15527 ///
15528 /// Sets the *request* property to the given value.
15529 ///
15530 /// Even though the property as already been set when instantiating this call,
15531 /// we provide this method for API completeness.
15532 pub fn request(
15533 mut self,
15534 new_value: BatchTranslateTextRequest,
15535 ) -> ProjectLocationBatchTranslateTextCall<'a, C> {
15536 self._request = new_value;
15537 self
15538 }
15539 /// Required. Location to make a call. Must refer to a caller's project. Format: `projects/{project-number-or-id}/locations/{location-id}`. The `global` location is not supported for batch translation. Only AutoML Translation models or glossaries within the same region (have the same location-id) can be used, otherwise an INVALID_ARGUMENT (400) error is returned.
15540 ///
15541 /// Sets the *parent* path property to the given value.
15542 ///
15543 /// Even though the property as already been set when instantiating this call,
15544 /// we provide this method for API completeness.
15545 pub fn parent(mut self, new_value: &str) -> ProjectLocationBatchTranslateTextCall<'a, C> {
15546 self._parent = new_value.to_string();
15547 self
15548 }
15549 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15550 /// while executing the actual API request.
15551 ///
15552 /// ````text
15553 /// It should be used to handle progress information, and to implement a certain level of resilience.
15554 /// ````
15555 ///
15556 /// Sets the *delegate* property to the given value.
15557 pub fn delegate(
15558 mut self,
15559 new_value: &'a mut dyn common::Delegate,
15560 ) -> ProjectLocationBatchTranslateTextCall<'a, C> {
15561 self._delegate = Some(new_value);
15562 self
15563 }
15564
15565 /// Set any additional parameter of the query string used in the request.
15566 /// It should be used to set parameters which are not yet available through their own
15567 /// setters.
15568 ///
15569 /// Please note that this method must not be used to set any of the known parameters
15570 /// which have their own setter method. If done anyway, the request will fail.
15571 ///
15572 /// # Additional Parameters
15573 ///
15574 /// * *$.xgafv* (query-string) - V1 error format.
15575 /// * *access_token* (query-string) - OAuth access token.
15576 /// * *alt* (query-string) - Data format for response.
15577 /// * *callback* (query-string) - JSONP
15578 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15579 /// * *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.
15580 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15581 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15582 /// * *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.
15583 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15584 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15585 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationBatchTranslateTextCall<'a, C>
15586 where
15587 T: AsRef<str>,
15588 {
15589 self._additional_params
15590 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15591 self
15592 }
15593
15594 /// Identifies the authorization scope for the method you are building.
15595 ///
15596 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15597 /// [`Scope::CloudPlatform`].
15598 ///
15599 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15600 /// tokens for more than one scope.
15601 ///
15602 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15603 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15604 /// sufficient, a read-write scope will do as well.
15605 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationBatchTranslateTextCall<'a, C>
15606 where
15607 St: AsRef<str>,
15608 {
15609 self._scopes.insert(String::from(scope.as_ref()));
15610 self
15611 }
15612 /// Identifies the authorization scope(s) for the method you are building.
15613 ///
15614 /// See [`Self::add_scope()`] for details.
15615 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationBatchTranslateTextCall<'a, C>
15616 where
15617 I: IntoIterator<Item = St>,
15618 St: AsRef<str>,
15619 {
15620 self._scopes
15621 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15622 self
15623 }
15624
15625 /// Removes all scopes, and no default scope will be used either.
15626 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15627 /// for details).
15628 pub fn clear_scopes(mut self) -> ProjectLocationBatchTranslateTextCall<'a, C> {
15629 self._scopes.clear();
15630 self
15631 }
15632}
15633
15634/// Detects the language of text within a request.
15635///
15636/// A builder for the *locations.detectLanguage* method supported by a *project* resource.
15637/// It is not used directly, but through a [`ProjectMethods`] instance.
15638///
15639/// # Example
15640///
15641/// Instantiate a resource method builder
15642///
15643/// ```test_harness,no_run
15644/// # extern crate hyper;
15645/// # extern crate hyper_rustls;
15646/// # extern crate google_translate3 as translate3;
15647/// use translate3::api::DetectLanguageRequest;
15648/// # async fn dox() {
15649/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15650///
15651/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15652/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15653/// # .with_native_roots()
15654/// # .unwrap()
15655/// # .https_only()
15656/// # .enable_http2()
15657/// # .build();
15658///
15659/// # let executor = hyper_util::rt::TokioExecutor::new();
15660/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15661/// # secret,
15662/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15663/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15664/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15665/// # ),
15666/// # ).build().await.unwrap();
15667///
15668/// # let client = hyper_util::client::legacy::Client::builder(
15669/// # hyper_util::rt::TokioExecutor::new()
15670/// # )
15671/// # .build(
15672/// # hyper_rustls::HttpsConnectorBuilder::new()
15673/// # .with_native_roots()
15674/// # .unwrap()
15675/// # .https_or_http()
15676/// # .enable_http2()
15677/// # .build()
15678/// # );
15679/// # let mut hub = Translate::new(client, auth);
15680/// // As the method needs a request, you would usually fill it with the desired information
15681/// // into the respective structure. Some of the parts shown here might not be applicable !
15682/// // Values shown here are possibly random and not representative !
15683/// let mut req = DetectLanguageRequest::default();
15684///
15685/// // You can configure optional parameters by calling the respective setters at will, and
15686/// // execute the final call using `doit()`.
15687/// // Values shown here are possibly random and not representative !
15688/// let result = hub.projects().locations_detect_language(req, "parent")
15689/// .doit().await;
15690/// # }
15691/// ```
15692pub struct ProjectLocationDetectLanguageCall<'a, C>
15693where
15694 C: 'a,
15695{
15696 hub: &'a Translate<C>,
15697 _request: DetectLanguageRequest,
15698 _parent: String,
15699 _delegate: Option<&'a mut dyn common::Delegate>,
15700 _additional_params: HashMap<String, String>,
15701 _scopes: BTreeSet<String>,
15702}
15703
15704impl<'a, C> common::CallBuilder for ProjectLocationDetectLanguageCall<'a, C> {}
15705
15706impl<'a, C> ProjectLocationDetectLanguageCall<'a, C>
15707where
15708 C: common::Connector,
15709{
15710 /// Perform the operation you have build so far.
15711 pub async fn doit(mut self) -> common::Result<(common::Response, DetectLanguageResponse)> {
15712 use std::borrow::Cow;
15713 use std::io::{Read, Seek};
15714
15715 use common::{url::Params, ToParts};
15716 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15717
15718 let mut dd = common::DefaultDelegate;
15719 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15720 dlg.begin(common::MethodInfo {
15721 id: "translate.projects.locations.detectLanguage",
15722 http_method: hyper::Method::POST,
15723 });
15724
15725 for &field in ["alt", "parent"].iter() {
15726 if self._additional_params.contains_key(field) {
15727 dlg.finished(false);
15728 return Err(common::Error::FieldClash(field));
15729 }
15730 }
15731
15732 let mut params = Params::with_capacity(4 + self._additional_params.len());
15733 params.push("parent", self._parent);
15734
15735 params.extend(self._additional_params.iter());
15736
15737 params.push("alt", "json");
15738 let mut url = self.hub._base_url.clone() + "v3/{+parent}:detectLanguage";
15739 if self._scopes.is_empty() {
15740 self._scopes
15741 .insert(Scope::CloudPlatform.as_ref().to_string());
15742 }
15743
15744 #[allow(clippy::single_element_loop)]
15745 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
15746 url = params.uri_replacement(url, param_name, find_this, true);
15747 }
15748 {
15749 let to_remove = ["parent"];
15750 params.remove_params(&to_remove);
15751 }
15752
15753 let url = params.parse_with_url(&url);
15754
15755 let mut json_mime_type = mime::APPLICATION_JSON;
15756 let mut request_value_reader = {
15757 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15758 common::remove_json_null_values(&mut value);
15759 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15760 serde_json::to_writer(&mut dst, &value).unwrap();
15761 dst
15762 };
15763 let request_size = request_value_reader
15764 .seek(std::io::SeekFrom::End(0))
15765 .unwrap();
15766 request_value_reader
15767 .seek(std::io::SeekFrom::Start(0))
15768 .unwrap();
15769
15770 loop {
15771 let token = match self
15772 .hub
15773 .auth
15774 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15775 .await
15776 {
15777 Ok(token) => token,
15778 Err(e) => match dlg.token(e) {
15779 Ok(token) => token,
15780 Err(e) => {
15781 dlg.finished(false);
15782 return Err(common::Error::MissingToken(e));
15783 }
15784 },
15785 };
15786 request_value_reader
15787 .seek(std::io::SeekFrom::Start(0))
15788 .unwrap();
15789 let mut req_result = {
15790 let client = &self.hub.client;
15791 dlg.pre_request();
15792 let mut req_builder = hyper::Request::builder()
15793 .method(hyper::Method::POST)
15794 .uri(url.as_str())
15795 .header(USER_AGENT, self.hub._user_agent.clone());
15796
15797 if let Some(token) = token.as_ref() {
15798 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15799 }
15800
15801 let request = req_builder
15802 .header(CONTENT_TYPE, json_mime_type.to_string())
15803 .header(CONTENT_LENGTH, request_size as u64)
15804 .body(common::to_body(
15805 request_value_reader.get_ref().clone().into(),
15806 ));
15807
15808 client.request(request.unwrap()).await
15809 };
15810
15811 match req_result {
15812 Err(err) => {
15813 if let common::Retry::After(d) = dlg.http_error(&err) {
15814 sleep(d).await;
15815 continue;
15816 }
15817 dlg.finished(false);
15818 return Err(common::Error::HttpError(err));
15819 }
15820 Ok(res) => {
15821 let (mut parts, body) = res.into_parts();
15822 let mut body = common::Body::new(body);
15823 if !parts.status.is_success() {
15824 let bytes = common::to_bytes(body).await.unwrap_or_default();
15825 let error = serde_json::from_str(&common::to_string(&bytes));
15826 let response = common::to_response(parts, bytes.into());
15827
15828 if let common::Retry::After(d) =
15829 dlg.http_failure(&response, error.as_ref().ok())
15830 {
15831 sleep(d).await;
15832 continue;
15833 }
15834
15835 dlg.finished(false);
15836
15837 return Err(match error {
15838 Ok(value) => common::Error::BadRequest(value),
15839 _ => common::Error::Failure(response),
15840 });
15841 }
15842 let response = {
15843 let bytes = common::to_bytes(body).await.unwrap_or_default();
15844 let encoded = common::to_string(&bytes);
15845 match serde_json::from_str(&encoded) {
15846 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15847 Err(error) => {
15848 dlg.response_json_decode_error(&encoded, &error);
15849 return Err(common::Error::JsonDecodeError(
15850 encoded.to_string(),
15851 error,
15852 ));
15853 }
15854 }
15855 };
15856
15857 dlg.finished(true);
15858 return Ok(response);
15859 }
15860 }
15861 }
15862 }
15863
15864 ///
15865 /// Sets the *request* property to the given value.
15866 ///
15867 /// Even though the property as already been set when instantiating this call,
15868 /// we provide this method for API completeness.
15869 pub fn request(
15870 mut self,
15871 new_value: DetectLanguageRequest,
15872 ) -> ProjectLocationDetectLanguageCall<'a, C> {
15873 self._request = new_value;
15874 self
15875 }
15876 /// Required. Project or location to make a call. Must refer to a caller's project. Format: `projects/{project-number-or-id}/locations/{location-id}` or `projects/{project-number-or-id}`. For global calls, use `projects/{project-number-or-id}/locations/global` or `projects/{project-number-or-id}`. Only models within the same region (has same location-id) can be used. Otherwise an INVALID_ARGUMENT (400) error is returned.
15877 ///
15878 /// Sets the *parent* path property to the given value.
15879 ///
15880 /// Even though the property as already been set when instantiating this call,
15881 /// we provide this method for API completeness.
15882 pub fn parent(mut self, new_value: &str) -> ProjectLocationDetectLanguageCall<'a, C> {
15883 self._parent = new_value.to_string();
15884 self
15885 }
15886 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15887 /// while executing the actual API request.
15888 ///
15889 /// ````text
15890 /// It should be used to handle progress information, and to implement a certain level of resilience.
15891 /// ````
15892 ///
15893 /// Sets the *delegate* property to the given value.
15894 pub fn delegate(
15895 mut self,
15896 new_value: &'a mut dyn common::Delegate,
15897 ) -> ProjectLocationDetectLanguageCall<'a, C> {
15898 self._delegate = Some(new_value);
15899 self
15900 }
15901
15902 /// Set any additional parameter of the query string used in the request.
15903 /// It should be used to set parameters which are not yet available through their own
15904 /// setters.
15905 ///
15906 /// Please note that this method must not be used to set any of the known parameters
15907 /// which have their own setter method. If done anyway, the request will fail.
15908 ///
15909 /// # Additional Parameters
15910 ///
15911 /// * *$.xgafv* (query-string) - V1 error format.
15912 /// * *access_token* (query-string) - OAuth access token.
15913 /// * *alt* (query-string) - Data format for response.
15914 /// * *callback* (query-string) - JSONP
15915 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15916 /// * *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.
15917 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15918 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15919 /// * *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.
15920 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15921 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15922 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationDetectLanguageCall<'a, C>
15923 where
15924 T: AsRef<str>,
15925 {
15926 self._additional_params
15927 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15928 self
15929 }
15930
15931 /// Identifies the authorization scope for the method you are building.
15932 ///
15933 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15934 /// [`Scope::CloudPlatform`].
15935 ///
15936 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15937 /// tokens for more than one scope.
15938 ///
15939 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15940 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15941 /// sufficient, a read-write scope will do as well.
15942 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationDetectLanguageCall<'a, C>
15943 where
15944 St: AsRef<str>,
15945 {
15946 self._scopes.insert(String::from(scope.as_ref()));
15947 self
15948 }
15949 /// Identifies the authorization scope(s) for the method you are building.
15950 ///
15951 /// See [`Self::add_scope()`] for details.
15952 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationDetectLanguageCall<'a, C>
15953 where
15954 I: IntoIterator<Item = St>,
15955 St: AsRef<str>,
15956 {
15957 self._scopes
15958 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15959 self
15960 }
15961
15962 /// Removes all scopes, and no default scope will be used either.
15963 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15964 /// for details).
15965 pub fn clear_scopes(mut self) -> ProjectLocationDetectLanguageCall<'a, C> {
15966 self._scopes.clear();
15967 self
15968 }
15969}
15970
15971/// Gets information about a location.
15972///
15973/// A builder for the *locations.get* method supported by a *project* resource.
15974/// It is not used directly, but through a [`ProjectMethods`] instance.
15975///
15976/// # Example
15977///
15978/// Instantiate a resource method builder
15979///
15980/// ```test_harness,no_run
15981/// # extern crate hyper;
15982/// # extern crate hyper_rustls;
15983/// # extern crate google_translate3 as translate3;
15984/// # async fn dox() {
15985/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15986///
15987/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15988/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15989/// # .with_native_roots()
15990/// # .unwrap()
15991/// # .https_only()
15992/// # .enable_http2()
15993/// # .build();
15994///
15995/// # let executor = hyper_util::rt::TokioExecutor::new();
15996/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15997/// # secret,
15998/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15999/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16000/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16001/// # ),
16002/// # ).build().await.unwrap();
16003///
16004/// # let client = hyper_util::client::legacy::Client::builder(
16005/// # hyper_util::rt::TokioExecutor::new()
16006/// # )
16007/// # .build(
16008/// # hyper_rustls::HttpsConnectorBuilder::new()
16009/// # .with_native_roots()
16010/// # .unwrap()
16011/// # .https_or_http()
16012/// # .enable_http2()
16013/// # .build()
16014/// # );
16015/// # let mut hub = Translate::new(client, auth);
16016/// // You can configure optional parameters by calling the respective setters at will, and
16017/// // execute the final call using `doit()`.
16018/// // Values shown here are possibly random and not representative !
16019/// let result = hub.projects().locations_get("name")
16020/// .doit().await;
16021/// # }
16022/// ```
16023pub struct ProjectLocationGetCall<'a, C>
16024where
16025 C: 'a,
16026{
16027 hub: &'a Translate<C>,
16028 _name: String,
16029 _delegate: Option<&'a mut dyn common::Delegate>,
16030 _additional_params: HashMap<String, String>,
16031 _scopes: BTreeSet<String>,
16032}
16033
16034impl<'a, C> common::CallBuilder for ProjectLocationGetCall<'a, C> {}
16035
16036impl<'a, C> ProjectLocationGetCall<'a, C>
16037where
16038 C: common::Connector,
16039{
16040 /// Perform the operation you have build so far.
16041 pub async fn doit(mut self) -> common::Result<(common::Response, Location)> {
16042 use std::borrow::Cow;
16043 use std::io::{Read, Seek};
16044
16045 use common::{url::Params, ToParts};
16046 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16047
16048 let mut dd = common::DefaultDelegate;
16049 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16050 dlg.begin(common::MethodInfo {
16051 id: "translate.projects.locations.get",
16052 http_method: hyper::Method::GET,
16053 });
16054
16055 for &field in ["alt", "name"].iter() {
16056 if self._additional_params.contains_key(field) {
16057 dlg.finished(false);
16058 return Err(common::Error::FieldClash(field));
16059 }
16060 }
16061
16062 let mut params = Params::with_capacity(3 + self._additional_params.len());
16063 params.push("name", self._name);
16064
16065 params.extend(self._additional_params.iter());
16066
16067 params.push("alt", "json");
16068 let mut url = self.hub._base_url.clone() + "v3/{+name}";
16069 if self._scopes.is_empty() {
16070 self._scopes
16071 .insert(Scope::CloudPlatform.as_ref().to_string());
16072 }
16073
16074 #[allow(clippy::single_element_loop)]
16075 for &(find_this, param_name) in [("{+name}", "name")].iter() {
16076 url = params.uri_replacement(url, param_name, find_this, true);
16077 }
16078 {
16079 let to_remove = ["name"];
16080 params.remove_params(&to_remove);
16081 }
16082
16083 let url = params.parse_with_url(&url);
16084
16085 loop {
16086 let token = match self
16087 .hub
16088 .auth
16089 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16090 .await
16091 {
16092 Ok(token) => token,
16093 Err(e) => match dlg.token(e) {
16094 Ok(token) => token,
16095 Err(e) => {
16096 dlg.finished(false);
16097 return Err(common::Error::MissingToken(e));
16098 }
16099 },
16100 };
16101 let mut req_result = {
16102 let client = &self.hub.client;
16103 dlg.pre_request();
16104 let mut req_builder = hyper::Request::builder()
16105 .method(hyper::Method::GET)
16106 .uri(url.as_str())
16107 .header(USER_AGENT, self.hub._user_agent.clone());
16108
16109 if let Some(token) = token.as_ref() {
16110 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16111 }
16112
16113 let request = req_builder
16114 .header(CONTENT_LENGTH, 0_u64)
16115 .body(common::to_body::<String>(None));
16116
16117 client.request(request.unwrap()).await
16118 };
16119
16120 match req_result {
16121 Err(err) => {
16122 if let common::Retry::After(d) = dlg.http_error(&err) {
16123 sleep(d).await;
16124 continue;
16125 }
16126 dlg.finished(false);
16127 return Err(common::Error::HttpError(err));
16128 }
16129 Ok(res) => {
16130 let (mut parts, body) = res.into_parts();
16131 let mut body = common::Body::new(body);
16132 if !parts.status.is_success() {
16133 let bytes = common::to_bytes(body).await.unwrap_or_default();
16134 let error = serde_json::from_str(&common::to_string(&bytes));
16135 let response = common::to_response(parts, bytes.into());
16136
16137 if let common::Retry::After(d) =
16138 dlg.http_failure(&response, error.as_ref().ok())
16139 {
16140 sleep(d).await;
16141 continue;
16142 }
16143
16144 dlg.finished(false);
16145
16146 return Err(match error {
16147 Ok(value) => common::Error::BadRequest(value),
16148 _ => common::Error::Failure(response),
16149 });
16150 }
16151 let response = {
16152 let bytes = common::to_bytes(body).await.unwrap_or_default();
16153 let encoded = common::to_string(&bytes);
16154 match serde_json::from_str(&encoded) {
16155 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16156 Err(error) => {
16157 dlg.response_json_decode_error(&encoded, &error);
16158 return Err(common::Error::JsonDecodeError(
16159 encoded.to_string(),
16160 error,
16161 ));
16162 }
16163 }
16164 };
16165
16166 dlg.finished(true);
16167 return Ok(response);
16168 }
16169 }
16170 }
16171 }
16172
16173 /// Resource name for the location.
16174 ///
16175 /// Sets the *name* path property to the given value.
16176 ///
16177 /// Even though the property as already been set when instantiating this call,
16178 /// we provide this method for API completeness.
16179 pub fn name(mut self, new_value: &str) -> ProjectLocationGetCall<'a, C> {
16180 self._name = new_value.to_string();
16181 self
16182 }
16183 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16184 /// while executing the actual API request.
16185 ///
16186 /// ````text
16187 /// It should be used to handle progress information, and to implement a certain level of resilience.
16188 /// ````
16189 ///
16190 /// Sets the *delegate* property to the given value.
16191 pub fn delegate(
16192 mut self,
16193 new_value: &'a mut dyn common::Delegate,
16194 ) -> ProjectLocationGetCall<'a, C> {
16195 self._delegate = Some(new_value);
16196 self
16197 }
16198
16199 /// Set any additional parameter of the query string used in the request.
16200 /// It should be used to set parameters which are not yet available through their own
16201 /// setters.
16202 ///
16203 /// Please note that this method must not be used to set any of the known parameters
16204 /// which have their own setter method. If done anyway, the request will fail.
16205 ///
16206 /// # Additional Parameters
16207 ///
16208 /// * *$.xgafv* (query-string) - V1 error format.
16209 /// * *access_token* (query-string) - OAuth access token.
16210 /// * *alt* (query-string) - Data format for response.
16211 /// * *callback* (query-string) - JSONP
16212 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16213 /// * *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.
16214 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16215 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16216 /// * *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.
16217 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16218 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16219 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCall<'a, C>
16220 where
16221 T: AsRef<str>,
16222 {
16223 self._additional_params
16224 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16225 self
16226 }
16227
16228 /// Identifies the authorization scope for the method you are building.
16229 ///
16230 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16231 /// [`Scope::CloudPlatform`].
16232 ///
16233 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16234 /// tokens for more than one scope.
16235 ///
16236 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16237 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16238 /// sufficient, a read-write scope will do as well.
16239 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCall<'a, C>
16240 where
16241 St: AsRef<str>,
16242 {
16243 self._scopes.insert(String::from(scope.as_ref()));
16244 self
16245 }
16246 /// Identifies the authorization scope(s) for the method you are building.
16247 ///
16248 /// See [`Self::add_scope()`] for details.
16249 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCall<'a, C>
16250 where
16251 I: IntoIterator<Item = St>,
16252 St: AsRef<str>,
16253 {
16254 self._scopes
16255 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16256 self
16257 }
16258
16259 /// Removes all scopes, and no default scope will be used either.
16260 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16261 /// for details).
16262 pub fn clear_scopes(mut self) -> ProjectLocationGetCall<'a, C> {
16263 self._scopes.clear();
16264 self
16265 }
16266}
16267
16268/// Returns a list of supported languages for translation.
16269///
16270/// A builder for the *locations.getSupportedLanguages* method supported by a *project* resource.
16271/// It is not used directly, but through a [`ProjectMethods`] instance.
16272///
16273/// # Example
16274///
16275/// Instantiate a resource method builder
16276///
16277/// ```test_harness,no_run
16278/// # extern crate hyper;
16279/// # extern crate hyper_rustls;
16280/// # extern crate google_translate3 as translate3;
16281/// # async fn dox() {
16282/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16283///
16284/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16285/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16286/// # .with_native_roots()
16287/// # .unwrap()
16288/// # .https_only()
16289/// # .enable_http2()
16290/// # .build();
16291///
16292/// # let executor = hyper_util::rt::TokioExecutor::new();
16293/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16294/// # secret,
16295/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16296/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16297/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16298/// # ),
16299/// # ).build().await.unwrap();
16300///
16301/// # let client = hyper_util::client::legacy::Client::builder(
16302/// # hyper_util::rt::TokioExecutor::new()
16303/// # )
16304/// # .build(
16305/// # hyper_rustls::HttpsConnectorBuilder::new()
16306/// # .with_native_roots()
16307/// # .unwrap()
16308/// # .https_or_http()
16309/// # .enable_http2()
16310/// # .build()
16311/// # );
16312/// # let mut hub = Translate::new(client, auth);
16313/// // You can configure optional parameters by calling the respective setters at will, and
16314/// // execute the final call using `doit()`.
16315/// // Values shown here are possibly random and not representative !
16316/// let result = hub.projects().locations_get_supported_languages("parent")
16317/// .model("elitr")
16318/// .display_language_code("Lorem")
16319/// .doit().await;
16320/// # }
16321/// ```
16322pub struct ProjectLocationGetSupportedLanguageCall<'a, C>
16323where
16324 C: 'a,
16325{
16326 hub: &'a Translate<C>,
16327 _parent: String,
16328 _model: Option<String>,
16329 _display_language_code: Option<String>,
16330 _delegate: Option<&'a mut dyn common::Delegate>,
16331 _additional_params: HashMap<String, String>,
16332 _scopes: BTreeSet<String>,
16333}
16334
16335impl<'a, C> common::CallBuilder for ProjectLocationGetSupportedLanguageCall<'a, C> {}
16336
16337impl<'a, C> ProjectLocationGetSupportedLanguageCall<'a, C>
16338where
16339 C: common::Connector,
16340{
16341 /// Perform the operation you have build so far.
16342 pub async fn doit(mut self) -> common::Result<(common::Response, SupportedLanguages)> {
16343 use std::borrow::Cow;
16344 use std::io::{Read, Seek};
16345
16346 use common::{url::Params, ToParts};
16347 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16348
16349 let mut dd = common::DefaultDelegate;
16350 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16351 dlg.begin(common::MethodInfo {
16352 id: "translate.projects.locations.getSupportedLanguages",
16353 http_method: hyper::Method::GET,
16354 });
16355
16356 for &field in ["alt", "parent", "model", "displayLanguageCode"].iter() {
16357 if self._additional_params.contains_key(field) {
16358 dlg.finished(false);
16359 return Err(common::Error::FieldClash(field));
16360 }
16361 }
16362
16363 let mut params = Params::with_capacity(5 + self._additional_params.len());
16364 params.push("parent", self._parent);
16365 if let Some(value) = self._model.as_ref() {
16366 params.push("model", value);
16367 }
16368 if let Some(value) = self._display_language_code.as_ref() {
16369 params.push("displayLanguageCode", value);
16370 }
16371
16372 params.extend(self._additional_params.iter());
16373
16374 params.push("alt", "json");
16375 let mut url = self.hub._base_url.clone() + "v3/{+parent}/supportedLanguages";
16376 if self._scopes.is_empty() {
16377 self._scopes
16378 .insert(Scope::CloudPlatform.as_ref().to_string());
16379 }
16380
16381 #[allow(clippy::single_element_loop)]
16382 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
16383 url = params.uri_replacement(url, param_name, find_this, true);
16384 }
16385 {
16386 let to_remove = ["parent"];
16387 params.remove_params(&to_remove);
16388 }
16389
16390 let url = params.parse_with_url(&url);
16391
16392 loop {
16393 let token = match self
16394 .hub
16395 .auth
16396 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16397 .await
16398 {
16399 Ok(token) => token,
16400 Err(e) => match dlg.token(e) {
16401 Ok(token) => token,
16402 Err(e) => {
16403 dlg.finished(false);
16404 return Err(common::Error::MissingToken(e));
16405 }
16406 },
16407 };
16408 let mut req_result = {
16409 let client = &self.hub.client;
16410 dlg.pre_request();
16411 let mut req_builder = hyper::Request::builder()
16412 .method(hyper::Method::GET)
16413 .uri(url.as_str())
16414 .header(USER_AGENT, self.hub._user_agent.clone());
16415
16416 if let Some(token) = token.as_ref() {
16417 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16418 }
16419
16420 let request = req_builder
16421 .header(CONTENT_LENGTH, 0_u64)
16422 .body(common::to_body::<String>(None));
16423
16424 client.request(request.unwrap()).await
16425 };
16426
16427 match req_result {
16428 Err(err) => {
16429 if let common::Retry::After(d) = dlg.http_error(&err) {
16430 sleep(d).await;
16431 continue;
16432 }
16433 dlg.finished(false);
16434 return Err(common::Error::HttpError(err));
16435 }
16436 Ok(res) => {
16437 let (mut parts, body) = res.into_parts();
16438 let mut body = common::Body::new(body);
16439 if !parts.status.is_success() {
16440 let bytes = common::to_bytes(body).await.unwrap_or_default();
16441 let error = serde_json::from_str(&common::to_string(&bytes));
16442 let response = common::to_response(parts, bytes.into());
16443
16444 if let common::Retry::After(d) =
16445 dlg.http_failure(&response, error.as_ref().ok())
16446 {
16447 sleep(d).await;
16448 continue;
16449 }
16450
16451 dlg.finished(false);
16452
16453 return Err(match error {
16454 Ok(value) => common::Error::BadRequest(value),
16455 _ => common::Error::Failure(response),
16456 });
16457 }
16458 let response = {
16459 let bytes = common::to_bytes(body).await.unwrap_or_default();
16460 let encoded = common::to_string(&bytes);
16461 match serde_json::from_str(&encoded) {
16462 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16463 Err(error) => {
16464 dlg.response_json_decode_error(&encoded, &error);
16465 return Err(common::Error::JsonDecodeError(
16466 encoded.to_string(),
16467 error,
16468 ));
16469 }
16470 }
16471 };
16472
16473 dlg.finished(true);
16474 return Ok(response);
16475 }
16476 }
16477 }
16478 }
16479
16480 /// Required. Project or location to make a call. Must refer to a caller's project. Format: `projects/{project-number-or-id}` or `projects/{project-number-or-id}/locations/{location-id}`. For global calls, use `projects/{project-number-or-id}/locations/global` or `projects/{project-number-or-id}`. Non-global location is required for AutoML models. Only models within the same region (have same location-id) can be used, otherwise an INVALID_ARGUMENT (400) error is returned.
16481 ///
16482 /// Sets the *parent* path property to the given value.
16483 ///
16484 /// Even though the property as already been set when instantiating this call,
16485 /// we provide this method for API completeness.
16486 pub fn parent(mut self, new_value: &str) -> ProjectLocationGetSupportedLanguageCall<'a, C> {
16487 self._parent = new_value.to_string();
16488 self
16489 }
16490 /// Optional. Get supported languages of this model. The format depends on model type: - AutoML Translation models: `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}` - General (built-in) models: `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`, Returns languages supported by the specified model. If missing, we get supported languages of Google general NMT model.
16491 ///
16492 /// Sets the *model* query property to the given value.
16493 pub fn model(mut self, new_value: &str) -> ProjectLocationGetSupportedLanguageCall<'a, C> {
16494 self._model = Some(new_value.to_string());
16495 self
16496 }
16497 /// Optional. The language to use to return localized, human readable names of supported languages. If missing, then display names are not returned in a response.
16498 ///
16499 /// Sets the *display language code* query property to the given value.
16500 pub fn display_language_code(
16501 mut self,
16502 new_value: &str,
16503 ) -> ProjectLocationGetSupportedLanguageCall<'a, C> {
16504 self._display_language_code = Some(new_value.to_string());
16505 self
16506 }
16507 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16508 /// while executing the actual API request.
16509 ///
16510 /// ````text
16511 /// It should be used to handle progress information, and to implement a certain level of resilience.
16512 /// ````
16513 ///
16514 /// Sets the *delegate* property to the given value.
16515 pub fn delegate(
16516 mut self,
16517 new_value: &'a mut dyn common::Delegate,
16518 ) -> ProjectLocationGetSupportedLanguageCall<'a, C> {
16519 self._delegate = Some(new_value);
16520 self
16521 }
16522
16523 /// Set any additional parameter of the query string used in the request.
16524 /// It should be used to set parameters which are not yet available through their own
16525 /// setters.
16526 ///
16527 /// Please note that this method must not be used to set any of the known parameters
16528 /// which have their own setter method. If done anyway, the request will fail.
16529 ///
16530 /// # Additional Parameters
16531 ///
16532 /// * *$.xgafv* (query-string) - V1 error format.
16533 /// * *access_token* (query-string) - OAuth access token.
16534 /// * *alt* (query-string) - Data format for response.
16535 /// * *callback* (query-string) - JSONP
16536 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16537 /// * *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.
16538 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16539 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16540 /// * *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.
16541 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16542 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16543 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetSupportedLanguageCall<'a, C>
16544 where
16545 T: AsRef<str>,
16546 {
16547 self._additional_params
16548 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16549 self
16550 }
16551
16552 /// Identifies the authorization scope for the method you are building.
16553 ///
16554 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16555 /// [`Scope::CloudPlatform`].
16556 ///
16557 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16558 /// tokens for more than one scope.
16559 ///
16560 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16561 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16562 /// sufficient, a read-write scope will do as well.
16563 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetSupportedLanguageCall<'a, C>
16564 where
16565 St: AsRef<str>,
16566 {
16567 self._scopes.insert(String::from(scope.as_ref()));
16568 self
16569 }
16570 /// Identifies the authorization scope(s) for the method you are building.
16571 ///
16572 /// See [`Self::add_scope()`] for details.
16573 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetSupportedLanguageCall<'a, C>
16574 where
16575 I: IntoIterator<Item = St>,
16576 St: AsRef<str>,
16577 {
16578 self._scopes
16579 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16580 self
16581 }
16582
16583 /// Removes all scopes, and no default scope will be used either.
16584 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16585 /// for details).
16586 pub fn clear_scopes(mut self) -> ProjectLocationGetSupportedLanguageCall<'a, C> {
16587 self._scopes.clear();
16588 self
16589 }
16590}
16591
16592/// Lists information about the supported locations for this service.
16593///
16594/// A builder for the *locations.list* method supported by a *project* resource.
16595/// It is not used directly, but through a [`ProjectMethods`] instance.
16596///
16597/// # Example
16598///
16599/// Instantiate a resource method builder
16600///
16601/// ```test_harness,no_run
16602/// # extern crate hyper;
16603/// # extern crate hyper_rustls;
16604/// # extern crate google_translate3 as translate3;
16605/// # async fn dox() {
16606/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16607///
16608/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16609/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16610/// # .with_native_roots()
16611/// # .unwrap()
16612/// # .https_only()
16613/// # .enable_http2()
16614/// # .build();
16615///
16616/// # let executor = hyper_util::rt::TokioExecutor::new();
16617/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16618/// # secret,
16619/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16620/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16621/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16622/// # ),
16623/// # ).build().await.unwrap();
16624///
16625/// # let client = hyper_util::client::legacy::Client::builder(
16626/// # hyper_util::rt::TokioExecutor::new()
16627/// # )
16628/// # .build(
16629/// # hyper_rustls::HttpsConnectorBuilder::new()
16630/// # .with_native_roots()
16631/// # .unwrap()
16632/// # .https_or_http()
16633/// # .enable_http2()
16634/// # .build()
16635/// # );
16636/// # let mut hub = Translate::new(client, auth);
16637/// // You can configure optional parameters by calling the respective setters at will, and
16638/// // execute the final call using `doit()`.
16639/// // Values shown here are possibly random and not representative !
16640/// let result = hub.projects().locations_list("name")
16641/// .page_token("no")
16642/// .page_size(-100)
16643/// .filter("accusam")
16644/// .add_extra_location_types("takimata")
16645/// .doit().await;
16646/// # }
16647/// ```
16648pub struct ProjectLocationListCall<'a, C>
16649where
16650 C: 'a,
16651{
16652 hub: &'a Translate<C>,
16653 _name: String,
16654 _page_token: Option<String>,
16655 _page_size: Option<i32>,
16656 _filter: Option<String>,
16657 _extra_location_types: Vec<String>,
16658 _delegate: Option<&'a mut dyn common::Delegate>,
16659 _additional_params: HashMap<String, String>,
16660 _scopes: BTreeSet<String>,
16661}
16662
16663impl<'a, C> common::CallBuilder for ProjectLocationListCall<'a, C> {}
16664
16665impl<'a, C> ProjectLocationListCall<'a, C>
16666where
16667 C: common::Connector,
16668{
16669 /// Perform the operation you have build so far.
16670 pub async fn doit(mut self) -> common::Result<(common::Response, ListLocationsResponse)> {
16671 use std::borrow::Cow;
16672 use std::io::{Read, Seek};
16673
16674 use common::{url::Params, ToParts};
16675 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16676
16677 let mut dd = common::DefaultDelegate;
16678 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16679 dlg.begin(common::MethodInfo {
16680 id: "translate.projects.locations.list",
16681 http_method: hyper::Method::GET,
16682 });
16683
16684 for &field in [
16685 "alt",
16686 "name",
16687 "pageToken",
16688 "pageSize",
16689 "filter",
16690 "extraLocationTypes",
16691 ]
16692 .iter()
16693 {
16694 if self._additional_params.contains_key(field) {
16695 dlg.finished(false);
16696 return Err(common::Error::FieldClash(field));
16697 }
16698 }
16699
16700 let mut params = Params::with_capacity(7 + self._additional_params.len());
16701 params.push("name", self._name);
16702 if let Some(value) = self._page_token.as_ref() {
16703 params.push("pageToken", value);
16704 }
16705 if let Some(value) = self._page_size.as_ref() {
16706 params.push("pageSize", value.to_string());
16707 }
16708 if let Some(value) = self._filter.as_ref() {
16709 params.push("filter", value);
16710 }
16711 if !self._extra_location_types.is_empty() {
16712 for f in self._extra_location_types.iter() {
16713 params.push("extraLocationTypes", f);
16714 }
16715 }
16716
16717 params.extend(self._additional_params.iter());
16718
16719 params.push("alt", "json");
16720 let mut url = self.hub._base_url.clone() + "v3/{+name}/locations";
16721 if self._scopes.is_empty() {
16722 self._scopes
16723 .insert(Scope::CloudPlatform.as_ref().to_string());
16724 }
16725
16726 #[allow(clippy::single_element_loop)]
16727 for &(find_this, param_name) in [("{+name}", "name")].iter() {
16728 url = params.uri_replacement(url, param_name, find_this, true);
16729 }
16730 {
16731 let to_remove = ["name"];
16732 params.remove_params(&to_remove);
16733 }
16734
16735 let url = params.parse_with_url(&url);
16736
16737 loop {
16738 let token = match self
16739 .hub
16740 .auth
16741 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16742 .await
16743 {
16744 Ok(token) => token,
16745 Err(e) => match dlg.token(e) {
16746 Ok(token) => token,
16747 Err(e) => {
16748 dlg.finished(false);
16749 return Err(common::Error::MissingToken(e));
16750 }
16751 },
16752 };
16753 let mut req_result = {
16754 let client = &self.hub.client;
16755 dlg.pre_request();
16756 let mut req_builder = hyper::Request::builder()
16757 .method(hyper::Method::GET)
16758 .uri(url.as_str())
16759 .header(USER_AGENT, self.hub._user_agent.clone());
16760
16761 if let Some(token) = token.as_ref() {
16762 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16763 }
16764
16765 let request = req_builder
16766 .header(CONTENT_LENGTH, 0_u64)
16767 .body(common::to_body::<String>(None));
16768
16769 client.request(request.unwrap()).await
16770 };
16771
16772 match req_result {
16773 Err(err) => {
16774 if let common::Retry::After(d) = dlg.http_error(&err) {
16775 sleep(d).await;
16776 continue;
16777 }
16778 dlg.finished(false);
16779 return Err(common::Error::HttpError(err));
16780 }
16781 Ok(res) => {
16782 let (mut parts, body) = res.into_parts();
16783 let mut body = common::Body::new(body);
16784 if !parts.status.is_success() {
16785 let bytes = common::to_bytes(body).await.unwrap_or_default();
16786 let error = serde_json::from_str(&common::to_string(&bytes));
16787 let response = common::to_response(parts, bytes.into());
16788
16789 if let common::Retry::After(d) =
16790 dlg.http_failure(&response, error.as_ref().ok())
16791 {
16792 sleep(d).await;
16793 continue;
16794 }
16795
16796 dlg.finished(false);
16797
16798 return Err(match error {
16799 Ok(value) => common::Error::BadRequest(value),
16800 _ => common::Error::Failure(response),
16801 });
16802 }
16803 let response = {
16804 let bytes = common::to_bytes(body).await.unwrap_or_default();
16805 let encoded = common::to_string(&bytes);
16806 match serde_json::from_str(&encoded) {
16807 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16808 Err(error) => {
16809 dlg.response_json_decode_error(&encoded, &error);
16810 return Err(common::Error::JsonDecodeError(
16811 encoded.to_string(),
16812 error,
16813 ));
16814 }
16815 }
16816 };
16817
16818 dlg.finished(true);
16819 return Ok(response);
16820 }
16821 }
16822 }
16823 }
16824
16825 /// The resource that owns the locations collection, if applicable.
16826 ///
16827 /// Sets the *name* path property to the given value.
16828 ///
16829 /// Even though the property as already been set when instantiating this call,
16830 /// we provide this method for API completeness.
16831 pub fn name(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
16832 self._name = new_value.to_string();
16833 self
16834 }
16835 /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
16836 ///
16837 /// Sets the *page token* query property to the given value.
16838 pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
16839 self._page_token = Some(new_value.to_string());
16840 self
16841 }
16842 /// The maximum number of results to return. If not set, the service selects a default.
16843 ///
16844 /// Sets the *page size* query property to the given value.
16845 pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C> {
16846 self._page_size = Some(new_value);
16847 self
16848 }
16849 /// A filter to narrow down results to a preferred subset. The filtering language accepts strings like `"displayName=tokyo"`, and is documented in more detail in [AIP-160](https://google.aip.dev/160).
16850 ///
16851 /// Sets the *filter* query property to the given value.
16852 pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
16853 self._filter = Some(new_value.to_string());
16854 self
16855 }
16856 /// Optional. A list of extra location types that should be used as conditions for controlling the visibility of the locations.
16857 ///
16858 /// Append the given value to the *extra location types* query property.
16859 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
16860 pub fn add_extra_location_types(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
16861 self._extra_location_types.push(new_value.to_string());
16862 self
16863 }
16864 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16865 /// while executing the actual API request.
16866 ///
16867 /// ````text
16868 /// It should be used to handle progress information, and to implement a certain level of resilience.
16869 /// ````
16870 ///
16871 /// Sets the *delegate* property to the given value.
16872 pub fn delegate(
16873 mut self,
16874 new_value: &'a mut dyn common::Delegate,
16875 ) -> ProjectLocationListCall<'a, C> {
16876 self._delegate = Some(new_value);
16877 self
16878 }
16879
16880 /// Set any additional parameter of the query string used in the request.
16881 /// It should be used to set parameters which are not yet available through their own
16882 /// setters.
16883 ///
16884 /// Please note that this method must not be used to set any of the known parameters
16885 /// which have their own setter method. If done anyway, the request will fail.
16886 ///
16887 /// # Additional Parameters
16888 ///
16889 /// * *$.xgafv* (query-string) - V1 error format.
16890 /// * *access_token* (query-string) - OAuth access token.
16891 /// * *alt* (query-string) - Data format for response.
16892 /// * *callback* (query-string) - JSONP
16893 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16894 /// * *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.
16895 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16896 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16897 /// * *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.
16898 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16899 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16900 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C>
16901 where
16902 T: AsRef<str>,
16903 {
16904 self._additional_params
16905 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16906 self
16907 }
16908
16909 /// Identifies the authorization scope for the method you are building.
16910 ///
16911 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16912 /// [`Scope::CloudPlatform`].
16913 ///
16914 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16915 /// tokens for more than one scope.
16916 ///
16917 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16918 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16919 /// sufficient, a read-write scope will do as well.
16920 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationListCall<'a, C>
16921 where
16922 St: AsRef<str>,
16923 {
16924 self._scopes.insert(String::from(scope.as_ref()));
16925 self
16926 }
16927 /// Identifies the authorization scope(s) for the method you are building.
16928 ///
16929 /// See [`Self::add_scope()`] for details.
16930 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationListCall<'a, C>
16931 where
16932 I: IntoIterator<Item = St>,
16933 St: AsRef<str>,
16934 {
16935 self._scopes
16936 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16937 self
16938 }
16939
16940 /// Removes all scopes, and no default scope will be used either.
16941 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16942 /// for details).
16943 pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, C> {
16944 self._scopes.clear();
16945 self
16946 }
16947}
16948
16949/// Romanize input text written in non-Latin scripts to Latin text.
16950///
16951/// A builder for the *locations.romanizeText* method supported by a *project* resource.
16952/// It is not used directly, but through a [`ProjectMethods`] instance.
16953///
16954/// # Example
16955///
16956/// Instantiate a resource method builder
16957///
16958/// ```test_harness,no_run
16959/// # extern crate hyper;
16960/// # extern crate hyper_rustls;
16961/// # extern crate google_translate3 as translate3;
16962/// use translate3::api::RomanizeTextRequest;
16963/// # async fn dox() {
16964/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16965///
16966/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16967/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16968/// # .with_native_roots()
16969/// # .unwrap()
16970/// # .https_only()
16971/// # .enable_http2()
16972/// # .build();
16973///
16974/// # let executor = hyper_util::rt::TokioExecutor::new();
16975/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16976/// # secret,
16977/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16978/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16979/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16980/// # ),
16981/// # ).build().await.unwrap();
16982///
16983/// # let client = hyper_util::client::legacy::Client::builder(
16984/// # hyper_util::rt::TokioExecutor::new()
16985/// # )
16986/// # .build(
16987/// # hyper_rustls::HttpsConnectorBuilder::new()
16988/// # .with_native_roots()
16989/// # .unwrap()
16990/// # .https_or_http()
16991/// # .enable_http2()
16992/// # .build()
16993/// # );
16994/// # let mut hub = Translate::new(client, auth);
16995/// // As the method needs a request, you would usually fill it with the desired information
16996/// // into the respective structure. Some of the parts shown here might not be applicable !
16997/// // Values shown here are possibly random and not representative !
16998/// let mut req = RomanizeTextRequest::default();
16999///
17000/// // You can configure optional parameters by calling the respective setters at will, and
17001/// // execute the final call using `doit()`.
17002/// // Values shown here are possibly random and not representative !
17003/// let result = hub.projects().locations_romanize_text(req, "parent")
17004/// .doit().await;
17005/// # }
17006/// ```
17007pub struct ProjectLocationRomanizeTextCall<'a, C>
17008where
17009 C: 'a,
17010{
17011 hub: &'a Translate<C>,
17012 _request: RomanizeTextRequest,
17013 _parent: String,
17014 _delegate: Option<&'a mut dyn common::Delegate>,
17015 _additional_params: HashMap<String, String>,
17016 _scopes: BTreeSet<String>,
17017}
17018
17019impl<'a, C> common::CallBuilder for ProjectLocationRomanizeTextCall<'a, C> {}
17020
17021impl<'a, C> ProjectLocationRomanizeTextCall<'a, C>
17022where
17023 C: common::Connector,
17024{
17025 /// Perform the operation you have build so far.
17026 pub async fn doit(mut self) -> common::Result<(common::Response, RomanizeTextResponse)> {
17027 use std::borrow::Cow;
17028 use std::io::{Read, Seek};
17029
17030 use common::{url::Params, ToParts};
17031 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17032
17033 let mut dd = common::DefaultDelegate;
17034 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17035 dlg.begin(common::MethodInfo {
17036 id: "translate.projects.locations.romanizeText",
17037 http_method: hyper::Method::POST,
17038 });
17039
17040 for &field in ["alt", "parent"].iter() {
17041 if self._additional_params.contains_key(field) {
17042 dlg.finished(false);
17043 return Err(common::Error::FieldClash(field));
17044 }
17045 }
17046
17047 let mut params = Params::with_capacity(4 + self._additional_params.len());
17048 params.push("parent", self._parent);
17049
17050 params.extend(self._additional_params.iter());
17051
17052 params.push("alt", "json");
17053 let mut url = self.hub._base_url.clone() + "v3/{+parent}:romanizeText";
17054 if self._scopes.is_empty() {
17055 self._scopes
17056 .insert(Scope::CloudPlatform.as_ref().to_string());
17057 }
17058
17059 #[allow(clippy::single_element_loop)]
17060 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
17061 url = params.uri_replacement(url, param_name, find_this, true);
17062 }
17063 {
17064 let to_remove = ["parent"];
17065 params.remove_params(&to_remove);
17066 }
17067
17068 let url = params.parse_with_url(&url);
17069
17070 let mut json_mime_type = mime::APPLICATION_JSON;
17071 let mut request_value_reader = {
17072 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17073 common::remove_json_null_values(&mut value);
17074 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17075 serde_json::to_writer(&mut dst, &value).unwrap();
17076 dst
17077 };
17078 let request_size = request_value_reader
17079 .seek(std::io::SeekFrom::End(0))
17080 .unwrap();
17081 request_value_reader
17082 .seek(std::io::SeekFrom::Start(0))
17083 .unwrap();
17084
17085 loop {
17086 let token = match self
17087 .hub
17088 .auth
17089 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17090 .await
17091 {
17092 Ok(token) => token,
17093 Err(e) => match dlg.token(e) {
17094 Ok(token) => token,
17095 Err(e) => {
17096 dlg.finished(false);
17097 return Err(common::Error::MissingToken(e));
17098 }
17099 },
17100 };
17101 request_value_reader
17102 .seek(std::io::SeekFrom::Start(0))
17103 .unwrap();
17104 let mut req_result = {
17105 let client = &self.hub.client;
17106 dlg.pre_request();
17107 let mut req_builder = hyper::Request::builder()
17108 .method(hyper::Method::POST)
17109 .uri(url.as_str())
17110 .header(USER_AGENT, self.hub._user_agent.clone());
17111
17112 if let Some(token) = token.as_ref() {
17113 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17114 }
17115
17116 let request = req_builder
17117 .header(CONTENT_TYPE, json_mime_type.to_string())
17118 .header(CONTENT_LENGTH, request_size as u64)
17119 .body(common::to_body(
17120 request_value_reader.get_ref().clone().into(),
17121 ));
17122
17123 client.request(request.unwrap()).await
17124 };
17125
17126 match req_result {
17127 Err(err) => {
17128 if let common::Retry::After(d) = dlg.http_error(&err) {
17129 sleep(d).await;
17130 continue;
17131 }
17132 dlg.finished(false);
17133 return Err(common::Error::HttpError(err));
17134 }
17135 Ok(res) => {
17136 let (mut parts, body) = res.into_parts();
17137 let mut body = common::Body::new(body);
17138 if !parts.status.is_success() {
17139 let bytes = common::to_bytes(body).await.unwrap_or_default();
17140 let error = serde_json::from_str(&common::to_string(&bytes));
17141 let response = common::to_response(parts, bytes.into());
17142
17143 if let common::Retry::After(d) =
17144 dlg.http_failure(&response, error.as_ref().ok())
17145 {
17146 sleep(d).await;
17147 continue;
17148 }
17149
17150 dlg.finished(false);
17151
17152 return Err(match error {
17153 Ok(value) => common::Error::BadRequest(value),
17154 _ => common::Error::Failure(response),
17155 });
17156 }
17157 let response = {
17158 let bytes = common::to_bytes(body).await.unwrap_or_default();
17159 let encoded = common::to_string(&bytes);
17160 match serde_json::from_str(&encoded) {
17161 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17162 Err(error) => {
17163 dlg.response_json_decode_error(&encoded, &error);
17164 return Err(common::Error::JsonDecodeError(
17165 encoded.to_string(),
17166 error,
17167 ));
17168 }
17169 }
17170 };
17171
17172 dlg.finished(true);
17173 return Ok(response);
17174 }
17175 }
17176 }
17177 }
17178
17179 ///
17180 /// Sets the *request* property to the given value.
17181 ///
17182 /// Even though the property as already been set when instantiating this call,
17183 /// we provide this method for API completeness.
17184 pub fn request(
17185 mut self,
17186 new_value: RomanizeTextRequest,
17187 ) -> ProjectLocationRomanizeTextCall<'a, C> {
17188 self._request = new_value;
17189 self
17190 }
17191 /// Required. Project or location to make a call. Must refer to a caller's project. Format: `projects/{project-number-or-id}/locations/{location-id}` or `projects/{project-number-or-id}`. For global calls, use `projects/{project-number-or-id}/locations/global` or `projects/{project-number-or-id}`.
17192 ///
17193 /// Sets the *parent* path property to the given value.
17194 ///
17195 /// Even though the property as already been set when instantiating this call,
17196 /// we provide this method for API completeness.
17197 pub fn parent(mut self, new_value: &str) -> ProjectLocationRomanizeTextCall<'a, C> {
17198 self._parent = new_value.to_string();
17199 self
17200 }
17201 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17202 /// while executing the actual API request.
17203 ///
17204 /// ````text
17205 /// It should be used to handle progress information, and to implement a certain level of resilience.
17206 /// ````
17207 ///
17208 /// Sets the *delegate* property to the given value.
17209 pub fn delegate(
17210 mut self,
17211 new_value: &'a mut dyn common::Delegate,
17212 ) -> ProjectLocationRomanizeTextCall<'a, C> {
17213 self._delegate = Some(new_value);
17214 self
17215 }
17216
17217 /// Set any additional parameter of the query string used in the request.
17218 /// It should be used to set parameters which are not yet available through their own
17219 /// setters.
17220 ///
17221 /// Please note that this method must not be used to set any of the known parameters
17222 /// which have their own setter method. If done anyway, the request will fail.
17223 ///
17224 /// # Additional Parameters
17225 ///
17226 /// * *$.xgafv* (query-string) - V1 error format.
17227 /// * *access_token* (query-string) - OAuth access token.
17228 /// * *alt* (query-string) - Data format for response.
17229 /// * *callback* (query-string) - JSONP
17230 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17231 /// * *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.
17232 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17233 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17234 /// * *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.
17235 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17236 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17237 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRomanizeTextCall<'a, C>
17238 where
17239 T: AsRef<str>,
17240 {
17241 self._additional_params
17242 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17243 self
17244 }
17245
17246 /// Identifies the authorization scope for the method you are building.
17247 ///
17248 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17249 /// [`Scope::CloudPlatform`].
17250 ///
17251 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17252 /// tokens for more than one scope.
17253 ///
17254 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17255 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17256 /// sufficient, a read-write scope will do as well.
17257 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRomanizeTextCall<'a, C>
17258 where
17259 St: AsRef<str>,
17260 {
17261 self._scopes.insert(String::from(scope.as_ref()));
17262 self
17263 }
17264 /// Identifies the authorization scope(s) for the method you are building.
17265 ///
17266 /// See [`Self::add_scope()`] for details.
17267 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRomanizeTextCall<'a, C>
17268 where
17269 I: IntoIterator<Item = St>,
17270 St: AsRef<str>,
17271 {
17272 self._scopes
17273 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17274 self
17275 }
17276
17277 /// Removes all scopes, and no default scope will be used either.
17278 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17279 /// for details).
17280 pub fn clear_scopes(mut self) -> ProjectLocationRomanizeTextCall<'a, C> {
17281 self._scopes.clear();
17282 self
17283 }
17284}
17285
17286/// Translates documents in synchronous mode.
17287///
17288/// A builder for the *locations.translateDocument* method supported by a *project* resource.
17289/// It is not used directly, but through a [`ProjectMethods`] instance.
17290///
17291/// # Example
17292///
17293/// Instantiate a resource method builder
17294///
17295/// ```test_harness,no_run
17296/// # extern crate hyper;
17297/// # extern crate hyper_rustls;
17298/// # extern crate google_translate3 as translate3;
17299/// use translate3::api::TranslateDocumentRequest;
17300/// # async fn dox() {
17301/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17302///
17303/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17304/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17305/// # .with_native_roots()
17306/// # .unwrap()
17307/// # .https_only()
17308/// # .enable_http2()
17309/// # .build();
17310///
17311/// # let executor = hyper_util::rt::TokioExecutor::new();
17312/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17313/// # secret,
17314/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17315/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17316/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17317/// # ),
17318/// # ).build().await.unwrap();
17319///
17320/// # let client = hyper_util::client::legacy::Client::builder(
17321/// # hyper_util::rt::TokioExecutor::new()
17322/// # )
17323/// # .build(
17324/// # hyper_rustls::HttpsConnectorBuilder::new()
17325/// # .with_native_roots()
17326/// # .unwrap()
17327/// # .https_or_http()
17328/// # .enable_http2()
17329/// # .build()
17330/// # );
17331/// # let mut hub = Translate::new(client, auth);
17332/// // As the method needs a request, you would usually fill it with the desired information
17333/// // into the respective structure. Some of the parts shown here might not be applicable !
17334/// // Values shown here are possibly random and not representative !
17335/// let mut req = TranslateDocumentRequest::default();
17336///
17337/// // You can configure optional parameters by calling the respective setters at will, and
17338/// // execute the final call using `doit()`.
17339/// // Values shown here are possibly random and not representative !
17340/// let result = hub.projects().locations_translate_document(req, "parent")
17341/// .doit().await;
17342/// # }
17343/// ```
17344pub struct ProjectLocationTranslateDocumentCall<'a, C>
17345where
17346 C: 'a,
17347{
17348 hub: &'a Translate<C>,
17349 _request: TranslateDocumentRequest,
17350 _parent: String,
17351 _delegate: Option<&'a mut dyn common::Delegate>,
17352 _additional_params: HashMap<String, String>,
17353 _scopes: BTreeSet<String>,
17354}
17355
17356impl<'a, C> common::CallBuilder for ProjectLocationTranslateDocumentCall<'a, C> {}
17357
17358impl<'a, C> ProjectLocationTranslateDocumentCall<'a, C>
17359where
17360 C: common::Connector,
17361{
17362 /// Perform the operation you have build so far.
17363 pub async fn doit(mut self) -> common::Result<(common::Response, TranslateDocumentResponse)> {
17364 use std::borrow::Cow;
17365 use std::io::{Read, Seek};
17366
17367 use common::{url::Params, ToParts};
17368 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17369
17370 let mut dd = common::DefaultDelegate;
17371 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17372 dlg.begin(common::MethodInfo {
17373 id: "translate.projects.locations.translateDocument",
17374 http_method: hyper::Method::POST,
17375 });
17376
17377 for &field in ["alt", "parent"].iter() {
17378 if self._additional_params.contains_key(field) {
17379 dlg.finished(false);
17380 return Err(common::Error::FieldClash(field));
17381 }
17382 }
17383
17384 let mut params = Params::with_capacity(4 + self._additional_params.len());
17385 params.push("parent", self._parent);
17386
17387 params.extend(self._additional_params.iter());
17388
17389 params.push("alt", "json");
17390 let mut url = self.hub._base_url.clone() + "v3/{+parent}:translateDocument";
17391 if self._scopes.is_empty() {
17392 self._scopes
17393 .insert(Scope::CloudPlatform.as_ref().to_string());
17394 }
17395
17396 #[allow(clippy::single_element_loop)]
17397 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
17398 url = params.uri_replacement(url, param_name, find_this, true);
17399 }
17400 {
17401 let to_remove = ["parent"];
17402 params.remove_params(&to_remove);
17403 }
17404
17405 let url = params.parse_with_url(&url);
17406
17407 let mut json_mime_type = mime::APPLICATION_JSON;
17408 let mut request_value_reader = {
17409 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17410 common::remove_json_null_values(&mut value);
17411 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17412 serde_json::to_writer(&mut dst, &value).unwrap();
17413 dst
17414 };
17415 let request_size = request_value_reader
17416 .seek(std::io::SeekFrom::End(0))
17417 .unwrap();
17418 request_value_reader
17419 .seek(std::io::SeekFrom::Start(0))
17420 .unwrap();
17421
17422 loop {
17423 let token = match self
17424 .hub
17425 .auth
17426 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17427 .await
17428 {
17429 Ok(token) => token,
17430 Err(e) => match dlg.token(e) {
17431 Ok(token) => token,
17432 Err(e) => {
17433 dlg.finished(false);
17434 return Err(common::Error::MissingToken(e));
17435 }
17436 },
17437 };
17438 request_value_reader
17439 .seek(std::io::SeekFrom::Start(0))
17440 .unwrap();
17441 let mut req_result = {
17442 let client = &self.hub.client;
17443 dlg.pre_request();
17444 let mut req_builder = hyper::Request::builder()
17445 .method(hyper::Method::POST)
17446 .uri(url.as_str())
17447 .header(USER_AGENT, self.hub._user_agent.clone());
17448
17449 if let Some(token) = token.as_ref() {
17450 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17451 }
17452
17453 let request = req_builder
17454 .header(CONTENT_TYPE, json_mime_type.to_string())
17455 .header(CONTENT_LENGTH, request_size as u64)
17456 .body(common::to_body(
17457 request_value_reader.get_ref().clone().into(),
17458 ));
17459
17460 client.request(request.unwrap()).await
17461 };
17462
17463 match req_result {
17464 Err(err) => {
17465 if let common::Retry::After(d) = dlg.http_error(&err) {
17466 sleep(d).await;
17467 continue;
17468 }
17469 dlg.finished(false);
17470 return Err(common::Error::HttpError(err));
17471 }
17472 Ok(res) => {
17473 let (mut parts, body) = res.into_parts();
17474 let mut body = common::Body::new(body);
17475 if !parts.status.is_success() {
17476 let bytes = common::to_bytes(body).await.unwrap_or_default();
17477 let error = serde_json::from_str(&common::to_string(&bytes));
17478 let response = common::to_response(parts, bytes.into());
17479
17480 if let common::Retry::After(d) =
17481 dlg.http_failure(&response, error.as_ref().ok())
17482 {
17483 sleep(d).await;
17484 continue;
17485 }
17486
17487 dlg.finished(false);
17488
17489 return Err(match error {
17490 Ok(value) => common::Error::BadRequest(value),
17491 _ => common::Error::Failure(response),
17492 });
17493 }
17494 let response = {
17495 let bytes = common::to_bytes(body).await.unwrap_or_default();
17496 let encoded = common::to_string(&bytes);
17497 match serde_json::from_str(&encoded) {
17498 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17499 Err(error) => {
17500 dlg.response_json_decode_error(&encoded, &error);
17501 return Err(common::Error::JsonDecodeError(
17502 encoded.to_string(),
17503 error,
17504 ));
17505 }
17506 }
17507 };
17508
17509 dlg.finished(true);
17510 return Ok(response);
17511 }
17512 }
17513 }
17514 }
17515
17516 ///
17517 /// Sets the *request* property to the given value.
17518 ///
17519 /// Even though the property as already been set when instantiating this call,
17520 /// we provide this method for API completeness.
17521 pub fn request(
17522 mut self,
17523 new_value: TranslateDocumentRequest,
17524 ) -> ProjectLocationTranslateDocumentCall<'a, C> {
17525 self._request = new_value;
17526 self
17527 }
17528 /// Required. Location to make a regional call. Format: `projects/{project-number-or-id}/locations/{location-id}`. For global calls, use `projects/{project-number-or-id}/locations/global` or `projects/{project-number-or-id}`. Non-global location is required for requests using AutoML models or custom glossaries. Models and glossaries must be within the same region (have the same location-id), otherwise an INVALID_ARGUMENT (400) error is returned.
17529 ///
17530 /// Sets the *parent* path property to the given value.
17531 ///
17532 /// Even though the property as already been set when instantiating this call,
17533 /// we provide this method for API completeness.
17534 pub fn parent(mut self, new_value: &str) -> ProjectLocationTranslateDocumentCall<'a, C> {
17535 self._parent = new_value.to_string();
17536 self
17537 }
17538 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17539 /// while executing the actual API request.
17540 ///
17541 /// ````text
17542 /// It should be used to handle progress information, and to implement a certain level of resilience.
17543 /// ````
17544 ///
17545 /// Sets the *delegate* property to the given value.
17546 pub fn delegate(
17547 mut self,
17548 new_value: &'a mut dyn common::Delegate,
17549 ) -> ProjectLocationTranslateDocumentCall<'a, C> {
17550 self._delegate = Some(new_value);
17551 self
17552 }
17553
17554 /// Set any additional parameter of the query string used in the request.
17555 /// It should be used to set parameters which are not yet available through their own
17556 /// setters.
17557 ///
17558 /// Please note that this method must not be used to set any of the known parameters
17559 /// which have their own setter method. If done anyway, the request will fail.
17560 ///
17561 /// # Additional Parameters
17562 ///
17563 /// * *$.xgafv* (query-string) - V1 error format.
17564 /// * *access_token* (query-string) - OAuth access token.
17565 /// * *alt* (query-string) - Data format for response.
17566 /// * *callback* (query-string) - JSONP
17567 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17568 /// * *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.
17569 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17570 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17571 /// * *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.
17572 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17573 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17574 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTranslateDocumentCall<'a, C>
17575 where
17576 T: AsRef<str>,
17577 {
17578 self._additional_params
17579 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17580 self
17581 }
17582
17583 /// Identifies the authorization scope for the method you are building.
17584 ///
17585 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17586 /// [`Scope::CloudPlatform`].
17587 ///
17588 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17589 /// tokens for more than one scope.
17590 ///
17591 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17592 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17593 /// sufficient, a read-write scope will do as well.
17594 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTranslateDocumentCall<'a, C>
17595 where
17596 St: AsRef<str>,
17597 {
17598 self._scopes.insert(String::from(scope.as_ref()));
17599 self
17600 }
17601 /// Identifies the authorization scope(s) for the method you are building.
17602 ///
17603 /// See [`Self::add_scope()`] for details.
17604 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTranslateDocumentCall<'a, C>
17605 where
17606 I: IntoIterator<Item = St>,
17607 St: AsRef<str>,
17608 {
17609 self._scopes
17610 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17611 self
17612 }
17613
17614 /// Removes all scopes, and no default scope will be used either.
17615 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17616 /// for details).
17617 pub fn clear_scopes(mut self) -> ProjectLocationTranslateDocumentCall<'a, C> {
17618 self._scopes.clear();
17619 self
17620 }
17621}
17622
17623/// Translates input text and returns translated text.
17624///
17625/// A builder for the *locations.translateText* method supported by a *project* resource.
17626/// It is not used directly, but through a [`ProjectMethods`] instance.
17627///
17628/// # Example
17629///
17630/// Instantiate a resource method builder
17631///
17632/// ```test_harness,no_run
17633/// # extern crate hyper;
17634/// # extern crate hyper_rustls;
17635/// # extern crate google_translate3 as translate3;
17636/// use translate3::api::TranslateTextRequest;
17637/// # async fn dox() {
17638/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17639///
17640/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17641/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17642/// # .with_native_roots()
17643/// # .unwrap()
17644/// # .https_only()
17645/// # .enable_http2()
17646/// # .build();
17647///
17648/// # let executor = hyper_util::rt::TokioExecutor::new();
17649/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17650/// # secret,
17651/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17652/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17653/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17654/// # ),
17655/// # ).build().await.unwrap();
17656///
17657/// # let client = hyper_util::client::legacy::Client::builder(
17658/// # hyper_util::rt::TokioExecutor::new()
17659/// # )
17660/// # .build(
17661/// # hyper_rustls::HttpsConnectorBuilder::new()
17662/// # .with_native_roots()
17663/// # .unwrap()
17664/// # .https_or_http()
17665/// # .enable_http2()
17666/// # .build()
17667/// # );
17668/// # let mut hub = Translate::new(client, auth);
17669/// // As the method needs a request, you would usually fill it with the desired information
17670/// // into the respective structure. Some of the parts shown here might not be applicable !
17671/// // Values shown here are possibly random and not representative !
17672/// let mut req = TranslateTextRequest::default();
17673///
17674/// // You can configure optional parameters by calling the respective setters at will, and
17675/// // execute the final call using `doit()`.
17676/// // Values shown here are possibly random and not representative !
17677/// let result = hub.projects().locations_translate_text(req, "parent")
17678/// .doit().await;
17679/// # }
17680/// ```
17681pub struct ProjectLocationTranslateTextCall<'a, C>
17682where
17683 C: 'a,
17684{
17685 hub: &'a Translate<C>,
17686 _request: TranslateTextRequest,
17687 _parent: String,
17688 _delegate: Option<&'a mut dyn common::Delegate>,
17689 _additional_params: HashMap<String, String>,
17690 _scopes: BTreeSet<String>,
17691}
17692
17693impl<'a, C> common::CallBuilder for ProjectLocationTranslateTextCall<'a, C> {}
17694
17695impl<'a, C> ProjectLocationTranslateTextCall<'a, C>
17696where
17697 C: common::Connector,
17698{
17699 /// Perform the operation you have build so far.
17700 pub async fn doit(mut self) -> common::Result<(common::Response, TranslateTextResponse)> {
17701 use std::borrow::Cow;
17702 use std::io::{Read, Seek};
17703
17704 use common::{url::Params, ToParts};
17705 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17706
17707 let mut dd = common::DefaultDelegate;
17708 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17709 dlg.begin(common::MethodInfo {
17710 id: "translate.projects.locations.translateText",
17711 http_method: hyper::Method::POST,
17712 });
17713
17714 for &field in ["alt", "parent"].iter() {
17715 if self._additional_params.contains_key(field) {
17716 dlg.finished(false);
17717 return Err(common::Error::FieldClash(field));
17718 }
17719 }
17720
17721 let mut params = Params::with_capacity(4 + self._additional_params.len());
17722 params.push("parent", self._parent);
17723
17724 params.extend(self._additional_params.iter());
17725
17726 params.push("alt", "json");
17727 let mut url = self.hub._base_url.clone() + "v3/{+parent}:translateText";
17728 if self._scopes.is_empty() {
17729 self._scopes
17730 .insert(Scope::CloudPlatform.as_ref().to_string());
17731 }
17732
17733 #[allow(clippy::single_element_loop)]
17734 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
17735 url = params.uri_replacement(url, param_name, find_this, true);
17736 }
17737 {
17738 let to_remove = ["parent"];
17739 params.remove_params(&to_remove);
17740 }
17741
17742 let url = params.parse_with_url(&url);
17743
17744 let mut json_mime_type = mime::APPLICATION_JSON;
17745 let mut request_value_reader = {
17746 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17747 common::remove_json_null_values(&mut value);
17748 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17749 serde_json::to_writer(&mut dst, &value).unwrap();
17750 dst
17751 };
17752 let request_size = request_value_reader
17753 .seek(std::io::SeekFrom::End(0))
17754 .unwrap();
17755 request_value_reader
17756 .seek(std::io::SeekFrom::Start(0))
17757 .unwrap();
17758
17759 loop {
17760 let token = match self
17761 .hub
17762 .auth
17763 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17764 .await
17765 {
17766 Ok(token) => token,
17767 Err(e) => match dlg.token(e) {
17768 Ok(token) => token,
17769 Err(e) => {
17770 dlg.finished(false);
17771 return Err(common::Error::MissingToken(e));
17772 }
17773 },
17774 };
17775 request_value_reader
17776 .seek(std::io::SeekFrom::Start(0))
17777 .unwrap();
17778 let mut req_result = {
17779 let client = &self.hub.client;
17780 dlg.pre_request();
17781 let mut req_builder = hyper::Request::builder()
17782 .method(hyper::Method::POST)
17783 .uri(url.as_str())
17784 .header(USER_AGENT, self.hub._user_agent.clone());
17785
17786 if let Some(token) = token.as_ref() {
17787 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17788 }
17789
17790 let request = req_builder
17791 .header(CONTENT_TYPE, json_mime_type.to_string())
17792 .header(CONTENT_LENGTH, request_size as u64)
17793 .body(common::to_body(
17794 request_value_reader.get_ref().clone().into(),
17795 ));
17796
17797 client.request(request.unwrap()).await
17798 };
17799
17800 match req_result {
17801 Err(err) => {
17802 if let common::Retry::After(d) = dlg.http_error(&err) {
17803 sleep(d).await;
17804 continue;
17805 }
17806 dlg.finished(false);
17807 return Err(common::Error::HttpError(err));
17808 }
17809 Ok(res) => {
17810 let (mut parts, body) = res.into_parts();
17811 let mut body = common::Body::new(body);
17812 if !parts.status.is_success() {
17813 let bytes = common::to_bytes(body).await.unwrap_or_default();
17814 let error = serde_json::from_str(&common::to_string(&bytes));
17815 let response = common::to_response(parts, bytes.into());
17816
17817 if let common::Retry::After(d) =
17818 dlg.http_failure(&response, error.as_ref().ok())
17819 {
17820 sleep(d).await;
17821 continue;
17822 }
17823
17824 dlg.finished(false);
17825
17826 return Err(match error {
17827 Ok(value) => common::Error::BadRequest(value),
17828 _ => common::Error::Failure(response),
17829 });
17830 }
17831 let response = {
17832 let bytes = common::to_bytes(body).await.unwrap_or_default();
17833 let encoded = common::to_string(&bytes);
17834 match serde_json::from_str(&encoded) {
17835 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17836 Err(error) => {
17837 dlg.response_json_decode_error(&encoded, &error);
17838 return Err(common::Error::JsonDecodeError(
17839 encoded.to_string(),
17840 error,
17841 ));
17842 }
17843 }
17844 };
17845
17846 dlg.finished(true);
17847 return Ok(response);
17848 }
17849 }
17850 }
17851 }
17852
17853 ///
17854 /// Sets the *request* property to the given value.
17855 ///
17856 /// Even though the property as already been set when instantiating this call,
17857 /// we provide this method for API completeness.
17858 pub fn request(
17859 mut self,
17860 new_value: TranslateTextRequest,
17861 ) -> ProjectLocationTranslateTextCall<'a, C> {
17862 self._request = new_value;
17863 self
17864 }
17865 /// Required. Project or location to make a call. Must refer to a caller's project. Format: `projects/{project-number-or-id}` or `projects/{project-number-or-id}/locations/{location-id}`. For global calls, use `projects/{project-number-or-id}/locations/global` or `projects/{project-number-or-id}`. Non-global location is required for requests using AutoML models or custom glossaries. Models and glossaries must be within the same region (have same location-id), otherwise an INVALID_ARGUMENT (400) error is returned.
17866 ///
17867 /// Sets the *parent* path property to the given value.
17868 ///
17869 /// Even though the property as already been set when instantiating this call,
17870 /// we provide this method for API completeness.
17871 pub fn parent(mut self, new_value: &str) -> ProjectLocationTranslateTextCall<'a, C> {
17872 self._parent = new_value.to_string();
17873 self
17874 }
17875 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17876 /// while executing the actual API request.
17877 ///
17878 /// ````text
17879 /// It should be used to handle progress information, and to implement a certain level of resilience.
17880 /// ````
17881 ///
17882 /// Sets the *delegate* property to the given value.
17883 pub fn delegate(
17884 mut self,
17885 new_value: &'a mut dyn common::Delegate,
17886 ) -> ProjectLocationTranslateTextCall<'a, C> {
17887 self._delegate = Some(new_value);
17888 self
17889 }
17890
17891 /// Set any additional parameter of the query string used in the request.
17892 /// It should be used to set parameters which are not yet available through their own
17893 /// setters.
17894 ///
17895 /// Please note that this method must not be used to set any of the known parameters
17896 /// which have their own setter method. If done anyway, the request will fail.
17897 ///
17898 /// # Additional Parameters
17899 ///
17900 /// * *$.xgafv* (query-string) - V1 error format.
17901 /// * *access_token* (query-string) - OAuth access token.
17902 /// * *alt* (query-string) - Data format for response.
17903 /// * *callback* (query-string) - JSONP
17904 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17905 /// * *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.
17906 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17907 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17908 /// * *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.
17909 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17910 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17911 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTranslateTextCall<'a, C>
17912 where
17913 T: AsRef<str>,
17914 {
17915 self._additional_params
17916 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17917 self
17918 }
17919
17920 /// Identifies the authorization scope for the method you are building.
17921 ///
17922 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17923 /// [`Scope::CloudPlatform`].
17924 ///
17925 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17926 /// tokens for more than one scope.
17927 ///
17928 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17929 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17930 /// sufficient, a read-write scope will do as well.
17931 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTranslateTextCall<'a, C>
17932 where
17933 St: AsRef<str>,
17934 {
17935 self._scopes.insert(String::from(scope.as_ref()));
17936 self
17937 }
17938 /// Identifies the authorization scope(s) for the method you are building.
17939 ///
17940 /// See [`Self::add_scope()`] for details.
17941 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTranslateTextCall<'a, C>
17942 where
17943 I: IntoIterator<Item = St>,
17944 St: AsRef<str>,
17945 {
17946 self._scopes
17947 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17948 self
17949 }
17950
17951 /// Removes all scopes, and no default scope will be used either.
17952 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17953 /// for details).
17954 pub fn clear_scopes(mut self) -> ProjectLocationTranslateTextCall<'a, C> {
17955 self._scopes.clear();
17956 self
17957 }
17958}
17959
17960/// Detects the language of text within a request.
17961///
17962/// A builder for the *detectLanguage* method supported by a *project* resource.
17963/// It is not used directly, but through a [`ProjectMethods`] instance.
17964///
17965/// # Example
17966///
17967/// Instantiate a resource method builder
17968///
17969/// ```test_harness,no_run
17970/// # extern crate hyper;
17971/// # extern crate hyper_rustls;
17972/// # extern crate google_translate3 as translate3;
17973/// use translate3::api::DetectLanguageRequest;
17974/// # async fn dox() {
17975/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17976///
17977/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17978/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17979/// # .with_native_roots()
17980/// # .unwrap()
17981/// # .https_only()
17982/// # .enable_http2()
17983/// # .build();
17984///
17985/// # let executor = hyper_util::rt::TokioExecutor::new();
17986/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17987/// # secret,
17988/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17989/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17990/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17991/// # ),
17992/// # ).build().await.unwrap();
17993///
17994/// # let client = hyper_util::client::legacy::Client::builder(
17995/// # hyper_util::rt::TokioExecutor::new()
17996/// # )
17997/// # .build(
17998/// # hyper_rustls::HttpsConnectorBuilder::new()
17999/// # .with_native_roots()
18000/// # .unwrap()
18001/// # .https_or_http()
18002/// # .enable_http2()
18003/// # .build()
18004/// # );
18005/// # let mut hub = Translate::new(client, auth);
18006/// // As the method needs a request, you would usually fill it with the desired information
18007/// // into the respective structure. Some of the parts shown here might not be applicable !
18008/// // Values shown here are possibly random and not representative !
18009/// let mut req = DetectLanguageRequest::default();
18010///
18011/// // You can configure optional parameters by calling the respective setters at will, and
18012/// // execute the final call using `doit()`.
18013/// // Values shown here are possibly random and not representative !
18014/// let result = hub.projects().detect_language(req, "parent")
18015/// .doit().await;
18016/// # }
18017/// ```
18018pub struct ProjectDetectLanguageCall<'a, C>
18019where
18020 C: 'a,
18021{
18022 hub: &'a Translate<C>,
18023 _request: DetectLanguageRequest,
18024 _parent: String,
18025 _delegate: Option<&'a mut dyn common::Delegate>,
18026 _additional_params: HashMap<String, String>,
18027 _scopes: BTreeSet<String>,
18028}
18029
18030impl<'a, C> common::CallBuilder for ProjectDetectLanguageCall<'a, C> {}
18031
18032impl<'a, C> ProjectDetectLanguageCall<'a, C>
18033where
18034 C: common::Connector,
18035{
18036 /// Perform the operation you have build so far.
18037 pub async fn doit(mut self) -> common::Result<(common::Response, DetectLanguageResponse)> {
18038 use std::borrow::Cow;
18039 use std::io::{Read, Seek};
18040
18041 use common::{url::Params, ToParts};
18042 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18043
18044 let mut dd = common::DefaultDelegate;
18045 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18046 dlg.begin(common::MethodInfo {
18047 id: "translate.projects.detectLanguage",
18048 http_method: hyper::Method::POST,
18049 });
18050
18051 for &field in ["alt", "parent"].iter() {
18052 if self._additional_params.contains_key(field) {
18053 dlg.finished(false);
18054 return Err(common::Error::FieldClash(field));
18055 }
18056 }
18057
18058 let mut params = Params::with_capacity(4 + self._additional_params.len());
18059 params.push("parent", self._parent);
18060
18061 params.extend(self._additional_params.iter());
18062
18063 params.push("alt", "json");
18064 let mut url = self.hub._base_url.clone() + "v3/{+parent}:detectLanguage";
18065 if self._scopes.is_empty() {
18066 self._scopes
18067 .insert(Scope::CloudPlatform.as_ref().to_string());
18068 }
18069
18070 #[allow(clippy::single_element_loop)]
18071 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
18072 url = params.uri_replacement(url, param_name, find_this, true);
18073 }
18074 {
18075 let to_remove = ["parent"];
18076 params.remove_params(&to_remove);
18077 }
18078
18079 let url = params.parse_with_url(&url);
18080
18081 let mut json_mime_type = mime::APPLICATION_JSON;
18082 let mut request_value_reader = {
18083 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18084 common::remove_json_null_values(&mut value);
18085 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18086 serde_json::to_writer(&mut dst, &value).unwrap();
18087 dst
18088 };
18089 let request_size = request_value_reader
18090 .seek(std::io::SeekFrom::End(0))
18091 .unwrap();
18092 request_value_reader
18093 .seek(std::io::SeekFrom::Start(0))
18094 .unwrap();
18095
18096 loop {
18097 let token = match self
18098 .hub
18099 .auth
18100 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18101 .await
18102 {
18103 Ok(token) => token,
18104 Err(e) => match dlg.token(e) {
18105 Ok(token) => token,
18106 Err(e) => {
18107 dlg.finished(false);
18108 return Err(common::Error::MissingToken(e));
18109 }
18110 },
18111 };
18112 request_value_reader
18113 .seek(std::io::SeekFrom::Start(0))
18114 .unwrap();
18115 let mut req_result = {
18116 let client = &self.hub.client;
18117 dlg.pre_request();
18118 let mut req_builder = hyper::Request::builder()
18119 .method(hyper::Method::POST)
18120 .uri(url.as_str())
18121 .header(USER_AGENT, self.hub._user_agent.clone());
18122
18123 if let Some(token) = token.as_ref() {
18124 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18125 }
18126
18127 let request = req_builder
18128 .header(CONTENT_TYPE, json_mime_type.to_string())
18129 .header(CONTENT_LENGTH, request_size as u64)
18130 .body(common::to_body(
18131 request_value_reader.get_ref().clone().into(),
18132 ));
18133
18134 client.request(request.unwrap()).await
18135 };
18136
18137 match req_result {
18138 Err(err) => {
18139 if let common::Retry::After(d) = dlg.http_error(&err) {
18140 sleep(d).await;
18141 continue;
18142 }
18143 dlg.finished(false);
18144 return Err(common::Error::HttpError(err));
18145 }
18146 Ok(res) => {
18147 let (mut parts, body) = res.into_parts();
18148 let mut body = common::Body::new(body);
18149 if !parts.status.is_success() {
18150 let bytes = common::to_bytes(body).await.unwrap_or_default();
18151 let error = serde_json::from_str(&common::to_string(&bytes));
18152 let response = common::to_response(parts, bytes.into());
18153
18154 if let common::Retry::After(d) =
18155 dlg.http_failure(&response, error.as_ref().ok())
18156 {
18157 sleep(d).await;
18158 continue;
18159 }
18160
18161 dlg.finished(false);
18162
18163 return Err(match error {
18164 Ok(value) => common::Error::BadRequest(value),
18165 _ => common::Error::Failure(response),
18166 });
18167 }
18168 let response = {
18169 let bytes = common::to_bytes(body).await.unwrap_or_default();
18170 let encoded = common::to_string(&bytes);
18171 match serde_json::from_str(&encoded) {
18172 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18173 Err(error) => {
18174 dlg.response_json_decode_error(&encoded, &error);
18175 return Err(common::Error::JsonDecodeError(
18176 encoded.to_string(),
18177 error,
18178 ));
18179 }
18180 }
18181 };
18182
18183 dlg.finished(true);
18184 return Ok(response);
18185 }
18186 }
18187 }
18188 }
18189
18190 ///
18191 /// Sets the *request* property to the given value.
18192 ///
18193 /// Even though the property as already been set when instantiating this call,
18194 /// we provide this method for API completeness.
18195 pub fn request(mut self, new_value: DetectLanguageRequest) -> ProjectDetectLanguageCall<'a, C> {
18196 self._request = new_value;
18197 self
18198 }
18199 /// Required. Project or location to make a call. Must refer to a caller's project. Format: `projects/{project-number-or-id}/locations/{location-id}` or `projects/{project-number-or-id}`. For global calls, use `projects/{project-number-or-id}/locations/global` or `projects/{project-number-or-id}`. Only models within the same region (has same location-id) can be used. Otherwise an INVALID_ARGUMENT (400) error is returned.
18200 ///
18201 /// Sets the *parent* path property to the given value.
18202 ///
18203 /// Even though the property as already been set when instantiating this call,
18204 /// we provide this method for API completeness.
18205 pub fn parent(mut self, new_value: &str) -> ProjectDetectLanguageCall<'a, C> {
18206 self._parent = new_value.to_string();
18207 self
18208 }
18209 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18210 /// while executing the actual API request.
18211 ///
18212 /// ````text
18213 /// It should be used to handle progress information, and to implement a certain level of resilience.
18214 /// ````
18215 ///
18216 /// Sets the *delegate* property to the given value.
18217 pub fn delegate(
18218 mut self,
18219 new_value: &'a mut dyn common::Delegate,
18220 ) -> ProjectDetectLanguageCall<'a, C> {
18221 self._delegate = Some(new_value);
18222 self
18223 }
18224
18225 /// Set any additional parameter of the query string used in the request.
18226 /// It should be used to set parameters which are not yet available through their own
18227 /// setters.
18228 ///
18229 /// Please note that this method must not be used to set any of the known parameters
18230 /// which have their own setter method. If done anyway, the request will fail.
18231 ///
18232 /// # Additional Parameters
18233 ///
18234 /// * *$.xgafv* (query-string) - V1 error format.
18235 /// * *access_token* (query-string) - OAuth access token.
18236 /// * *alt* (query-string) - Data format for response.
18237 /// * *callback* (query-string) - JSONP
18238 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18239 /// * *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.
18240 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18241 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18242 /// * *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.
18243 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18244 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18245 pub fn param<T>(mut self, name: T, value: T) -> ProjectDetectLanguageCall<'a, C>
18246 where
18247 T: AsRef<str>,
18248 {
18249 self._additional_params
18250 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18251 self
18252 }
18253
18254 /// Identifies the authorization scope for the method you are building.
18255 ///
18256 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18257 /// [`Scope::CloudPlatform`].
18258 ///
18259 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18260 /// tokens for more than one scope.
18261 ///
18262 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18263 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18264 /// sufficient, a read-write scope will do as well.
18265 pub fn add_scope<St>(mut self, scope: St) -> ProjectDetectLanguageCall<'a, C>
18266 where
18267 St: AsRef<str>,
18268 {
18269 self._scopes.insert(String::from(scope.as_ref()));
18270 self
18271 }
18272 /// Identifies the authorization scope(s) for the method you are building.
18273 ///
18274 /// See [`Self::add_scope()`] for details.
18275 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDetectLanguageCall<'a, C>
18276 where
18277 I: IntoIterator<Item = St>,
18278 St: AsRef<str>,
18279 {
18280 self._scopes
18281 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18282 self
18283 }
18284
18285 /// Removes all scopes, and no default scope will be used either.
18286 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18287 /// for details).
18288 pub fn clear_scopes(mut self) -> ProjectDetectLanguageCall<'a, C> {
18289 self._scopes.clear();
18290 self
18291 }
18292}
18293
18294/// Returns a list of supported languages for translation.
18295///
18296/// A builder for the *getSupportedLanguages* method supported by a *project* resource.
18297/// It is not used directly, but through a [`ProjectMethods`] instance.
18298///
18299/// # Example
18300///
18301/// Instantiate a resource method builder
18302///
18303/// ```test_harness,no_run
18304/// # extern crate hyper;
18305/// # extern crate hyper_rustls;
18306/// # extern crate google_translate3 as translate3;
18307/// # async fn dox() {
18308/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18309///
18310/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18311/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18312/// # .with_native_roots()
18313/// # .unwrap()
18314/// # .https_only()
18315/// # .enable_http2()
18316/// # .build();
18317///
18318/// # let executor = hyper_util::rt::TokioExecutor::new();
18319/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18320/// # secret,
18321/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18322/// # yup_oauth2::client::CustomHyperClientBuilder::from(
18323/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
18324/// # ),
18325/// # ).build().await.unwrap();
18326///
18327/// # let client = hyper_util::client::legacy::Client::builder(
18328/// # hyper_util::rt::TokioExecutor::new()
18329/// # )
18330/// # .build(
18331/// # hyper_rustls::HttpsConnectorBuilder::new()
18332/// # .with_native_roots()
18333/// # .unwrap()
18334/// # .https_or_http()
18335/// # .enable_http2()
18336/// # .build()
18337/// # );
18338/// # let mut hub = Translate::new(client, auth);
18339/// // You can configure optional parameters by calling the respective setters at will, and
18340/// // execute the final call using `doit()`.
18341/// // Values shown here are possibly random and not representative !
18342/// let result = hub.projects().get_supported_languages("parent")
18343/// .model("amet.")
18344/// .display_language_code("sed")
18345/// .doit().await;
18346/// # }
18347/// ```
18348pub struct ProjectGetSupportedLanguageCall<'a, C>
18349where
18350 C: 'a,
18351{
18352 hub: &'a Translate<C>,
18353 _parent: String,
18354 _model: Option<String>,
18355 _display_language_code: Option<String>,
18356 _delegate: Option<&'a mut dyn common::Delegate>,
18357 _additional_params: HashMap<String, String>,
18358 _scopes: BTreeSet<String>,
18359}
18360
18361impl<'a, C> common::CallBuilder for ProjectGetSupportedLanguageCall<'a, C> {}
18362
18363impl<'a, C> ProjectGetSupportedLanguageCall<'a, C>
18364where
18365 C: common::Connector,
18366{
18367 /// Perform the operation you have build so far.
18368 pub async fn doit(mut self) -> common::Result<(common::Response, SupportedLanguages)> {
18369 use std::borrow::Cow;
18370 use std::io::{Read, Seek};
18371
18372 use common::{url::Params, ToParts};
18373 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18374
18375 let mut dd = common::DefaultDelegate;
18376 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18377 dlg.begin(common::MethodInfo {
18378 id: "translate.projects.getSupportedLanguages",
18379 http_method: hyper::Method::GET,
18380 });
18381
18382 for &field in ["alt", "parent", "model", "displayLanguageCode"].iter() {
18383 if self._additional_params.contains_key(field) {
18384 dlg.finished(false);
18385 return Err(common::Error::FieldClash(field));
18386 }
18387 }
18388
18389 let mut params = Params::with_capacity(5 + self._additional_params.len());
18390 params.push("parent", self._parent);
18391 if let Some(value) = self._model.as_ref() {
18392 params.push("model", value);
18393 }
18394 if let Some(value) = self._display_language_code.as_ref() {
18395 params.push("displayLanguageCode", value);
18396 }
18397
18398 params.extend(self._additional_params.iter());
18399
18400 params.push("alt", "json");
18401 let mut url = self.hub._base_url.clone() + "v3/{+parent}/supportedLanguages";
18402 if self._scopes.is_empty() {
18403 self._scopes
18404 .insert(Scope::CloudPlatform.as_ref().to_string());
18405 }
18406
18407 #[allow(clippy::single_element_loop)]
18408 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
18409 url = params.uri_replacement(url, param_name, find_this, true);
18410 }
18411 {
18412 let to_remove = ["parent"];
18413 params.remove_params(&to_remove);
18414 }
18415
18416 let url = params.parse_with_url(&url);
18417
18418 loop {
18419 let token = match self
18420 .hub
18421 .auth
18422 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18423 .await
18424 {
18425 Ok(token) => token,
18426 Err(e) => match dlg.token(e) {
18427 Ok(token) => token,
18428 Err(e) => {
18429 dlg.finished(false);
18430 return Err(common::Error::MissingToken(e));
18431 }
18432 },
18433 };
18434 let mut req_result = {
18435 let client = &self.hub.client;
18436 dlg.pre_request();
18437 let mut req_builder = hyper::Request::builder()
18438 .method(hyper::Method::GET)
18439 .uri(url.as_str())
18440 .header(USER_AGENT, self.hub._user_agent.clone());
18441
18442 if let Some(token) = token.as_ref() {
18443 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18444 }
18445
18446 let request = req_builder
18447 .header(CONTENT_LENGTH, 0_u64)
18448 .body(common::to_body::<String>(None));
18449
18450 client.request(request.unwrap()).await
18451 };
18452
18453 match req_result {
18454 Err(err) => {
18455 if let common::Retry::After(d) = dlg.http_error(&err) {
18456 sleep(d).await;
18457 continue;
18458 }
18459 dlg.finished(false);
18460 return Err(common::Error::HttpError(err));
18461 }
18462 Ok(res) => {
18463 let (mut parts, body) = res.into_parts();
18464 let mut body = common::Body::new(body);
18465 if !parts.status.is_success() {
18466 let bytes = common::to_bytes(body).await.unwrap_or_default();
18467 let error = serde_json::from_str(&common::to_string(&bytes));
18468 let response = common::to_response(parts, bytes.into());
18469
18470 if let common::Retry::After(d) =
18471 dlg.http_failure(&response, error.as_ref().ok())
18472 {
18473 sleep(d).await;
18474 continue;
18475 }
18476
18477 dlg.finished(false);
18478
18479 return Err(match error {
18480 Ok(value) => common::Error::BadRequest(value),
18481 _ => common::Error::Failure(response),
18482 });
18483 }
18484 let response = {
18485 let bytes = common::to_bytes(body).await.unwrap_or_default();
18486 let encoded = common::to_string(&bytes);
18487 match serde_json::from_str(&encoded) {
18488 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18489 Err(error) => {
18490 dlg.response_json_decode_error(&encoded, &error);
18491 return Err(common::Error::JsonDecodeError(
18492 encoded.to_string(),
18493 error,
18494 ));
18495 }
18496 }
18497 };
18498
18499 dlg.finished(true);
18500 return Ok(response);
18501 }
18502 }
18503 }
18504 }
18505
18506 /// Required. Project or location to make a call. Must refer to a caller's project. Format: `projects/{project-number-or-id}` or `projects/{project-number-or-id}/locations/{location-id}`. For global calls, use `projects/{project-number-or-id}/locations/global` or `projects/{project-number-or-id}`. Non-global location is required for AutoML models. Only models within the same region (have same location-id) can be used, otherwise an INVALID_ARGUMENT (400) error is returned.
18507 ///
18508 /// Sets the *parent* path property to the given value.
18509 ///
18510 /// Even though the property as already been set when instantiating this call,
18511 /// we provide this method for API completeness.
18512 pub fn parent(mut self, new_value: &str) -> ProjectGetSupportedLanguageCall<'a, C> {
18513 self._parent = new_value.to_string();
18514 self
18515 }
18516 /// Optional. Get supported languages of this model. The format depends on model type: - AutoML Translation models: `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}` - General (built-in) models: `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`, Returns languages supported by the specified model. If missing, we get supported languages of Google general NMT model.
18517 ///
18518 /// Sets the *model* query property to the given value.
18519 pub fn model(mut self, new_value: &str) -> ProjectGetSupportedLanguageCall<'a, C> {
18520 self._model = Some(new_value.to_string());
18521 self
18522 }
18523 /// Optional. The language to use to return localized, human readable names of supported languages. If missing, then display names are not returned in a response.
18524 ///
18525 /// Sets the *display language code* query property to the given value.
18526 pub fn display_language_code(
18527 mut self,
18528 new_value: &str,
18529 ) -> ProjectGetSupportedLanguageCall<'a, C> {
18530 self._display_language_code = Some(new_value.to_string());
18531 self
18532 }
18533 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18534 /// while executing the actual API request.
18535 ///
18536 /// ````text
18537 /// It should be used to handle progress information, and to implement a certain level of resilience.
18538 /// ````
18539 ///
18540 /// Sets the *delegate* property to the given value.
18541 pub fn delegate(
18542 mut self,
18543 new_value: &'a mut dyn common::Delegate,
18544 ) -> ProjectGetSupportedLanguageCall<'a, C> {
18545 self._delegate = Some(new_value);
18546 self
18547 }
18548
18549 /// Set any additional parameter of the query string used in the request.
18550 /// It should be used to set parameters which are not yet available through their own
18551 /// setters.
18552 ///
18553 /// Please note that this method must not be used to set any of the known parameters
18554 /// which have their own setter method. If done anyway, the request will fail.
18555 ///
18556 /// # Additional Parameters
18557 ///
18558 /// * *$.xgafv* (query-string) - V1 error format.
18559 /// * *access_token* (query-string) - OAuth access token.
18560 /// * *alt* (query-string) - Data format for response.
18561 /// * *callback* (query-string) - JSONP
18562 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18563 /// * *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.
18564 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18565 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18566 /// * *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.
18567 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18568 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18569 pub fn param<T>(mut self, name: T, value: T) -> ProjectGetSupportedLanguageCall<'a, C>
18570 where
18571 T: AsRef<str>,
18572 {
18573 self._additional_params
18574 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18575 self
18576 }
18577
18578 /// Identifies the authorization scope for the method you are building.
18579 ///
18580 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18581 /// [`Scope::CloudPlatform`].
18582 ///
18583 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18584 /// tokens for more than one scope.
18585 ///
18586 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18587 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18588 /// sufficient, a read-write scope will do as well.
18589 pub fn add_scope<St>(mut self, scope: St) -> ProjectGetSupportedLanguageCall<'a, C>
18590 where
18591 St: AsRef<str>,
18592 {
18593 self._scopes.insert(String::from(scope.as_ref()));
18594 self
18595 }
18596 /// Identifies the authorization scope(s) for the method you are building.
18597 ///
18598 /// See [`Self::add_scope()`] for details.
18599 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGetSupportedLanguageCall<'a, C>
18600 where
18601 I: IntoIterator<Item = St>,
18602 St: AsRef<str>,
18603 {
18604 self._scopes
18605 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18606 self
18607 }
18608
18609 /// Removes all scopes, and no default scope will be used either.
18610 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18611 /// for details).
18612 pub fn clear_scopes(mut self) -> ProjectGetSupportedLanguageCall<'a, C> {
18613 self._scopes.clear();
18614 self
18615 }
18616}
18617
18618/// Romanize input text written in non-Latin scripts to Latin text.
18619///
18620/// A builder for the *romanizeText* method supported by a *project* resource.
18621/// It is not used directly, but through a [`ProjectMethods`] instance.
18622///
18623/// # Example
18624///
18625/// Instantiate a resource method builder
18626///
18627/// ```test_harness,no_run
18628/// # extern crate hyper;
18629/// # extern crate hyper_rustls;
18630/// # extern crate google_translate3 as translate3;
18631/// use translate3::api::RomanizeTextRequest;
18632/// # async fn dox() {
18633/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18634///
18635/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18636/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18637/// # .with_native_roots()
18638/// # .unwrap()
18639/// # .https_only()
18640/// # .enable_http2()
18641/// # .build();
18642///
18643/// # let executor = hyper_util::rt::TokioExecutor::new();
18644/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18645/// # secret,
18646/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18647/// # yup_oauth2::client::CustomHyperClientBuilder::from(
18648/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
18649/// # ),
18650/// # ).build().await.unwrap();
18651///
18652/// # let client = hyper_util::client::legacy::Client::builder(
18653/// # hyper_util::rt::TokioExecutor::new()
18654/// # )
18655/// # .build(
18656/// # hyper_rustls::HttpsConnectorBuilder::new()
18657/// # .with_native_roots()
18658/// # .unwrap()
18659/// # .https_or_http()
18660/// # .enable_http2()
18661/// # .build()
18662/// # );
18663/// # let mut hub = Translate::new(client, auth);
18664/// // As the method needs a request, you would usually fill it with the desired information
18665/// // into the respective structure. Some of the parts shown here might not be applicable !
18666/// // Values shown here are possibly random and not representative !
18667/// let mut req = RomanizeTextRequest::default();
18668///
18669/// // You can configure optional parameters by calling the respective setters at will, and
18670/// // execute the final call using `doit()`.
18671/// // Values shown here are possibly random and not representative !
18672/// let result = hub.projects().romanize_text(req, "parent")
18673/// .doit().await;
18674/// # }
18675/// ```
18676pub struct ProjectRomanizeTextCall<'a, C>
18677where
18678 C: 'a,
18679{
18680 hub: &'a Translate<C>,
18681 _request: RomanizeTextRequest,
18682 _parent: String,
18683 _delegate: Option<&'a mut dyn common::Delegate>,
18684 _additional_params: HashMap<String, String>,
18685 _scopes: BTreeSet<String>,
18686}
18687
18688impl<'a, C> common::CallBuilder for ProjectRomanizeTextCall<'a, C> {}
18689
18690impl<'a, C> ProjectRomanizeTextCall<'a, C>
18691where
18692 C: common::Connector,
18693{
18694 /// Perform the operation you have build so far.
18695 pub async fn doit(mut self) -> common::Result<(common::Response, RomanizeTextResponse)> {
18696 use std::borrow::Cow;
18697 use std::io::{Read, Seek};
18698
18699 use common::{url::Params, ToParts};
18700 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18701
18702 let mut dd = common::DefaultDelegate;
18703 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18704 dlg.begin(common::MethodInfo {
18705 id: "translate.projects.romanizeText",
18706 http_method: hyper::Method::POST,
18707 });
18708
18709 for &field in ["alt", "parent"].iter() {
18710 if self._additional_params.contains_key(field) {
18711 dlg.finished(false);
18712 return Err(common::Error::FieldClash(field));
18713 }
18714 }
18715
18716 let mut params = Params::with_capacity(4 + self._additional_params.len());
18717 params.push("parent", self._parent);
18718
18719 params.extend(self._additional_params.iter());
18720
18721 params.push("alt", "json");
18722 let mut url = self.hub._base_url.clone() + "v3/{+parent}:romanizeText";
18723 if self._scopes.is_empty() {
18724 self._scopes
18725 .insert(Scope::CloudPlatform.as_ref().to_string());
18726 }
18727
18728 #[allow(clippy::single_element_loop)]
18729 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
18730 url = params.uri_replacement(url, param_name, find_this, true);
18731 }
18732 {
18733 let to_remove = ["parent"];
18734 params.remove_params(&to_remove);
18735 }
18736
18737 let url = params.parse_with_url(&url);
18738
18739 let mut json_mime_type = mime::APPLICATION_JSON;
18740 let mut request_value_reader = {
18741 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18742 common::remove_json_null_values(&mut value);
18743 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18744 serde_json::to_writer(&mut dst, &value).unwrap();
18745 dst
18746 };
18747 let request_size = request_value_reader
18748 .seek(std::io::SeekFrom::End(0))
18749 .unwrap();
18750 request_value_reader
18751 .seek(std::io::SeekFrom::Start(0))
18752 .unwrap();
18753
18754 loop {
18755 let token = match self
18756 .hub
18757 .auth
18758 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18759 .await
18760 {
18761 Ok(token) => token,
18762 Err(e) => match dlg.token(e) {
18763 Ok(token) => token,
18764 Err(e) => {
18765 dlg.finished(false);
18766 return Err(common::Error::MissingToken(e));
18767 }
18768 },
18769 };
18770 request_value_reader
18771 .seek(std::io::SeekFrom::Start(0))
18772 .unwrap();
18773 let mut req_result = {
18774 let client = &self.hub.client;
18775 dlg.pre_request();
18776 let mut req_builder = hyper::Request::builder()
18777 .method(hyper::Method::POST)
18778 .uri(url.as_str())
18779 .header(USER_AGENT, self.hub._user_agent.clone());
18780
18781 if let Some(token) = token.as_ref() {
18782 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18783 }
18784
18785 let request = req_builder
18786 .header(CONTENT_TYPE, json_mime_type.to_string())
18787 .header(CONTENT_LENGTH, request_size as u64)
18788 .body(common::to_body(
18789 request_value_reader.get_ref().clone().into(),
18790 ));
18791
18792 client.request(request.unwrap()).await
18793 };
18794
18795 match req_result {
18796 Err(err) => {
18797 if let common::Retry::After(d) = dlg.http_error(&err) {
18798 sleep(d).await;
18799 continue;
18800 }
18801 dlg.finished(false);
18802 return Err(common::Error::HttpError(err));
18803 }
18804 Ok(res) => {
18805 let (mut parts, body) = res.into_parts();
18806 let mut body = common::Body::new(body);
18807 if !parts.status.is_success() {
18808 let bytes = common::to_bytes(body).await.unwrap_or_default();
18809 let error = serde_json::from_str(&common::to_string(&bytes));
18810 let response = common::to_response(parts, bytes.into());
18811
18812 if let common::Retry::After(d) =
18813 dlg.http_failure(&response, error.as_ref().ok())
18814 {
18815 sleep(d).await;
18816 continue;
18817 }
18818
18819 dlg.finished(false);
18820
18821 return Err(match error {
18822 Ok(value) => common::Error::BadRequest(value),
18823 _ => common::Error::Failure(response),
18824 });
18825 }
18826 let response = {
18827 let bytes = common::to_bytes(body).await.unwrap_or_default();
18828 let encoded = common::to_string(&bytes);
18829 match serde_json::from_str(&encoded) {
18830 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18831 Err(error) => {
18832 dlg.response_json_decode_error(&encoded, &error);
18833 return Err(common::Error::JsonDecodeError(
18834 encoded.to_string(),
18835 error,
18836 ));
18837 }
18838 }
18839 };
18840
18841 dlg.finished(true);
18842 return Ok(response);
18843 }
18844 }
18845 }
18846 }
18847
18848 ///
18849 /// Sets the *request* property to the given value.
18850 ///
18851 /// Even though the property as already been set when instantiating this call,
18852 /// we provide this method for API completeness.
18853 pub fn request(mut self, new_value: RomanizeTextRequest) -> ProjectRomanizeTextCall<'a, C> {
18854 self._request = new_value;
18855 self
18856 }
18857 /// Required. Project or location to make a call. Must refer to a caller's project. Format: `projects/{project-number-or-id}/locations/{location-id}` or `projects/{project-number-or-id}`. For global calls, use `projects/{project-number-or-id}/locations/global` or `projects/{project-number-or-id}`.
18858 ///
18859 /// Sets the *parent* path property to the given value.
18860 ///
18861 /// Even though the property as already been set when instantiating this call,
18862 /// we provide this method for API completeness.
18863 pub fn parent(mut self, new_value: &str) -> ProjectRomanizeTextCall<'a, C> {
18864 self._parent = new_value.to_string();
18865 self
18866 }
18867 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18868 /// while executing the actual API request.
18869 ///
18870 /// ````text
18871 /// It should be used to handle progress information, and to implement a certain level of resilience.
18872 /// ````
18873 ///
18874 /// Sets the *delegate* property to the given value.
18875 pub fn delegate(
18876 mut self,
18877 new_value: &'a mut dyn common::Delegate,
18878 ) -> ProjectRomanizeTextCall<'a, C> {
18879 self._delegate = Some(new_value);
18880 self
18881 }
18882
18883 /// Set any additional parameter of the query string used in the request.
18884 /// It should be used to set parameters which are not yet available through their own
18885 /// setters.
18886 ///
18887 /// Please note that this method must not be used to set any of the known parameters
18888 /// which have their own setter method. If done anyway, the request will fail.
18889 ///
18890 /// # Additional Parameters
18891 ///
18892 /// * *$.xgafv* (query-string) - V1 error format.
18893 /// * *access_token* (query-string) - OAuth access token.
18894 /// * *alt* (query-string) - Data format for response.
18895 /// * *callback* (query-string) - JSONP
18896 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18897 /// * *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.
18898 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18899 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18900 /// * *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.
18901 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18902 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18903 pub fn param<T>(mut self, name: T, value: T) -> ProjectRomanizeTextCall<'a, C>
18904 where
18905 T: AsRef<str>,
18906 {
18907 self._additional_params
18908 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18909 self
18910 }
18911
18912 /// Identifies the authorization scope for the method you are building.
18913 ///
18914 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18915 /// [`Scope::CloudPlatform`].
18916 ///
18917 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18918 /// tokens for more than one scope.
18919 ///
18920 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18921 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18922 /// sufficient, a read-write scope will do as well.
18923 pub fn add_scope<St>(mut self, scope: St) -> ProjectRomanizeTextCall<'a, C>
18924 where
18925 St: AsRef<str>,
18926 {
18927 self._scopes.insert(String::from(scope.as_ref()));
18928 self
18929 }
18930 /// Identifies the authorization scope(s) for the method you are building.
18931 ///
18932 /// See [`Self::add_scope()`] for details.
18933 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectRomanizeTextCall<'a, C>
18934 where
18935 I: IntoIterator<Item = St>,
18936 St: AsRef<str>,
18937 {
18938 self._scopes
18939 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18940 self
18941 }
18942
18943 /// Removes all scopes, and no default scope will be used either.
18944 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18945 /// for details).
18946 pub fn clear_scopes(mut self) -> ProjectRomanizeTextCall<'a, C> {
18947 self._scopes.clear();
18948 self
18949 }
18950}
18951
18952/// Translates input text and returns translated text.
18953///
18954/// A builder for the *translateText* method supported by a *project* resource.
18955/// It is not used directly, but through a [`ProjectMethods`] instance.
18956///
18957/// # Example
18958///
18959/// Instantiate a resource method builder
18960///
18961/// ```test_harness,no_run
18962/// # extern crate hyper;
18963/// # extern crate hyper_rustls;
18964/// # extern crate google_translate3 as translate3;
18965/// use translate3::api::TranslateTextRequest;
18966/// # async fn dox() {
18967/// # use translate3::{Translate, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18968///
18969/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18970/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18971/// # .with_native_roots()
18972/// # .unwrap()
18973/// # .https_only()
18974/// # .enable_http2()
18975/// # .build();
18976///
18977/// # let executor = hyper_util::rt::TokioExecutor::new();
18978/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18979/// # secret,
18980/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18981/// # yup_oauth2::client::CustomHyperClientBuilder::from(
18982/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
18983/// # ),
18984/// # ).build().await.unwrap();
18985///
18986/// # let client = hyper_util::client::legacy::Client::builder(
18987/// # hyper_util::rt::TokioExecutor::new()
18988/// # )
18989/// # .build(
18990/// # hyper_rustls::HttpsConnectorBuilder::new()
18991/// # .with_native_roots()
18992/// # .unwrap()
18993/// # .https_or_http()
18994/// # .enable_http2()
18995/// # .build()
18996/// # );
18997/// # let mut hub = Translate::new(client, auth);
18998/// // As the method needs a request, you would usually fill it with the desired information
18999/// // into the respective structure. Some of the parts shown here might not be applicable !
19000/// // Values shown here are possibly random and not representative !
19001/// let mut req = TranslateTextRequest::default();
19002///
19003/// // You can configure optional parameters by calling the respective setters at will, and
19004/// // execute the final call using `doit()`.
19005/// // Values shown here are possibly random and not representative !
19006/// let result = hub.projects().translate_text(req, "parent")
19007/// .doit().await;
19008/// # }
19009/// ```
19010pub struct ProjectTranslateTextCall<'a, C>
19011where
19012 C: 'a,
19013{
19014 hub: &'a Translate<C>,
19015 _request: TranslateTextRequest,
19016 _parent: String,
19017 _delegate: Option<&'a mut dyn common::Delegate>,
19018 _additional_params: HashMap<String, String>,
19019 _scopes: BTreeSet<String>,
19020}
19021
19022impl<'a, C> common::CallBuilder for ProjectTranslateTextCall<'a, C> {}
19023
19024impl<'a, C> ProjectTranslateTextCall<'a, C>
19025where
19026 C: common::Connector,
19027{
19028 /// Perform the operation you have build so far.
19029 pub async fn doit(mut self) -> common::Result<(common::Response, TranslateTextResponse)> {
19030 use std::borrow::Cow;
19031 use std::io::{Read, Seek};
19032
19033 use common::{url::Params, ToParts};
19034 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19035
19036 let mut dd = common::DefaultDelegate;
19037 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19038 dlg.begin(common::MethodInfo {
19039 id: "translate.projects.translateText",
19040 http_method: hyper::Method::POST,
19041 });
19042
19043 for &field in ["alt", "parent"].iter() {
19044 if self._additional_params.contains_key(field) {
19045 dlg.finished(false);
19046 return Err(common::Error::FieldClash(field));
19047 }
19048 }
19049
19050 let mut params = Params::with_capacity(4 + self._additional_params.len());
19051 params.push("parent", self._parent);
19052
19053 params.extend(self._additional_params.iter());
19054
19055 params.push("alt", "json");
19056 let mut url = self.hub._base_url.clone() + "v3/{+parent}:translateText";
19057 if self._scopes.is_empty() {
19058 self._scopes
19059 .insert(Scope::CloudPlatform.as_ref().to_string());
19060 }
19061
19062 #[allow(clippy::single_element_loop)]
19063 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
19064 url = params.uri_replacement(url, param_name, find_this, true);
19065 }
19066 {
19067 let to_remove = ["parent"];
19068 params.remove_params(&to_remove);
19069 }
19070
19071 let url = params.parse_with_url(&url);
19072
19073 let mut json_mime_type = mime::APPLICATION_JSON;
19074 let mut request_value_reader = {
19075 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19076 common::remove_json_null_values(&mut value);
19077 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19078 serde_json::to_writer(&mut dst, &value).unwrap();
19079 dst
19080 };
19081 let request_size = request_value_reader
19082 .seek(std::io::SeekFrom::End(0))
19083 .unwrap();
19084 request_value_reader
19085 .seek(std::io::SeekFrom::Start(0))
19086 .unwrap();
19087
19088 loop {
19089 let token = match self
19090 .hub
19091 .auth
19092 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19093 .await
19094 {
19095 Ok(token) => token,
19096 Err(e) => match dlg.token(e) {
19097 Ok(token) => token,
19098 Err(e) => {
19099 dlg.finished(false);
19100 return Err(common::Error::MissingToken(e));
19101 }
19102 },
19103 };
19104 request_value_reader
19105 .seek(std::io::SeekFrom::Start(0))
19106 .unwrap();
19107 let mut req_result = {
19108 let client = &self.hub.client;
19109 dlg.pre_request();
19110 let mut req_builder = hyper::Request::builder()
19111 .method(hyper::Method::POST)
19112 .uri(url.as_str())
19113 .header(USER_AGENT, self.hub._user_agent.clone());
19114
19115 if let Some(token) = token.as_ref() {
19116 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19117 }
19118
19119 let request = req_builder
19120 .header(CONTENT_TYPE, json_mime_type.to_string())
19121 .header(CONTENT_LENGTH, request_size as u64)
19122 .body(common::to_body(
19123 request_value_reader.get_ref().clone().into(),
19124 ));
19125
19126 client.request(request.unwrap()).await
19127 };
19128
19129 match req_result {
19130 Err(err) => {
19131 if let common::Retry::After(d) = dlg.http_error(&err) {
19132 sleep(d).await;
19133 continue;
19134 }
19135 dlg.finished(false);
19136 return Err(common::Error::HttpError(err));
19137 }
19138 Ok(res) => {
19139 let (mut parts, body) = res.into_parts();
19140 let mut body = common::Body::new(body);
19141 if !parts.status.is_success() {
19142 let bytes = common::to_bytes(body).await.unwrap_or_default();
19143 let error = serde_json::from_str(&common::to_string(&bytes));
19144 let response = common::to_response(parts, bytes.into());
19145
19146 if let common::Retry::After(d) =
19147 dlg.http_failure(&response, error.as_ref().ok())
19148 {
19149 sleep(d).await;
19150 continue;
19151 }
19152
19153 dlg.finished(false);
19154
19155 return Err(match error {
19156 Ok(value) => common::Error::BadRequest(value),
19157 _ => common::Error::Failure(response),
19158 });
19159 }
19160 let response = {
19161 let bytes = common::to_bytes(body).await.unwrap_or_default();
19162 let encoded = common::to_string(&bytes);
19163 match serde_json::from_str(&encoded) {
19164 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19165 Err(error) => {
19166 dlg.response_json_decode_error(&encoded, &error);
19167 return Err(common::Error::JsonDecodeError(
19168 encoded.to_string(),
19169 error,
19170 ));
19171 }
19172 }
19173 };
19174
19175 dlg.finished(true);
19176 return Ok(response);
19177 }
19178 }
19179 }
19180 }
19181
19182 ///
19183 /// Sets the *request* property to the given value.
19184 ///
19185 /// Even though the property as already been set when instantiating this call,
19186 /// we provide this method for API completeness.
19187 pub fn request(mut self, new_value: TranslateTextRequest) -> ProjectTranslateTextCall<'a, C> {
19188 self._request = new_value;
19189 self
19190 }
19191 /// Required. Project or location to make a call. Must refer to a caller's project. Format: `projects/{project-number-or-id}` or `projects/{project-number-or-id}/locations/{location-id}`. For global calls, use `projects/{project-number-or-id}/locations/global` or `projects/{project-number-or-id}`. Non-global location is required for requests using AutoML models or custom glossaries. Models and glossaries must be within the same region (have same location-id), otherwise an INVALID_ARGUMENT (400) error is returned.
19192 ///
19193 /// Sets the *parent* path property to the given value.
19194 ///
19195 /// Even though the property as already been set when instantiating this call,
19196 /// we provide this method for API completeness.
19197 pub fn parent(mut self, new_value: &str) -> ProjectTranslateTextCall<'a, C> {
19198 self._parent = new_value.to_string();
19199 self
19200 }
19201 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19202 /// while executing the actual API request.
19203 ///
19204 /// ````text
19205 /// It should be used to handle progress information, and to implement a certain level of resilience.
19206 /// ````
19207 ///
19208 /// Sets the *delegate* property to the given value.
19209 pub fn delegate(
19210 mut self,
19211 new_value: &'a mut dyn common::Delegate,
19212 ) -> ProjectTranslateTextCall<'a, C> {
19213 self._delegate = Some(new_value);
19214 self
19215 }
19216
19217 /// Set any additional parameter of the query string used in the request.
19218 /// It should be used to set parameters which are not yet available through their own
19219 /// setters.
19220 ///
19221 /// Please note that this method must not be used to set any of the known parameters
19222 /// which have their own setter method. If done anyway, the request will fail.
19223 ///
19224 /// # Additional Parameters
19225 ///
19226 /// * *$.xgafv* (query-string) - V1 error format.
19227 /// * *access_token* (query-string) - OAuth access token.
19228 /// * *alt* (query-string) - Data format for response.
19229 /// * *callback* (query-string) - JSONP
19230 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19231 /// * *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.
19232 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19233 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19234 /// * *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.
19235 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19236 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19237 pub fn param<T>(mut self, name: T, value: T) -> ProjectTranslateTextCall<'a, C>
19238 where
19239 T: AsRef<str>,
19240 {
19241 self._additional_params
19242 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19243 self
19244 }
19245
19246 /// Identifies the authorization scope for the method you are building.
19247 ///
19248 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19249 /// [`Scope::CloudPlatform`].
19250 ///
19251 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19252 /// tokens for more than one scope.
19253 ///
19254 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19255 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19256 /// sufficient, a read-write scope will do as well.
19257 pub fn add_scope<St>(mut self, scope: St) -> ProjectTranslateTextCall<'a, C>
19258 where
19259 St: AsRef<str>,
19260 {
19261 self._scopes.insert(String::from(scope.as_ref()));
19262 self
19263 }
19264 /// Identifies the authorization scope(s) for the method you are building.
19265 ///
19266 /// See [`Self::add_scope()`] for details.
19267 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTranslateTextCall<'a, C>
19268 where
19269 I: IntoIterator<Item = St>,
19270 St: AsRef<str>,
19271 {
19272 self._scopes
19273 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19274 self
19275 }
19276
19277 /// Removes all scopes, and no default scope will be used either.
19278 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19279 /// for details).
19280 pub fn clear_scopes(mut self) -> ProjectTranslateTextCall<'a, C> {
19281 self._scopes.clear();
19282 self
19283 }
19284}