google_ml1/
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    /// View your data across Google Cloud services and see the email address of your Google Account
20    CloudPlatformReadOnly,
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::CloudPlatformReadOnly => {
28                "https://www.googleapis.com/auth/cloud-platform.read-only"
29            }
30        }
31    }
32}
33
34#[allow(clippy::derivable_impls)]
35impl Default for Scope {
36    fn default() -> Scope {
37        Scope::CloudPlatform
38    }
39}
40
41// ########
42// HUB ###
43// ######
44
45/// Central instance to access all CloudMachineLearningEngine related resource activities
46///
47/// # Examples
48///
49/// Instantiate a new hub
50///
51/// ```test_harness,no_run
52/// extern crate hyper;
53/// extern crate hyper_rustls;
54/// extern crate google_ml1 as ml1;
55/// use ml1::api::GoogleCloudMlV1__Version;
56/// use ml1::{Result, Error};
57/// # async fn dox() {
58/// use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
59///
60/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
61/// // `client_secret`, among other things.
62/// let secret: yup_oauth2::ApplicationSecret = Default::default();
63/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
64/// // unless you replace  `None` with the desired Flow.
65/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
66/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
67/// // retrieve them from storage.
68/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
69///     .with_native_roots()
70///     .unwrap()
71///     .https_only()
72///     .enable_http2()
73///     .build();
74///
75/// let executor = hyper_util::rt::TokioExecutor::new();
76/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
77///     secret,
78///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
79///     yup_oauth2::client::CustomHyperClientBuilder::from(
80///         hyper_util::client::legacy::Client::builder(executor).build(connector),
81///     ),
82/// ).build().await.unwrap();
83///
84/// let client = hyper_util::client::legacy::Client::builder(
85///     hyper_util::rt::TokioExecutor::new()
86/// )
87/// .build(
88///     hyper_rustls::HttpsConnectorBuilder::new()
89///         .with_native_roots()
90///         .unwrap()
91///         .https_or_http()
92///         .enable_http2()
93///         .build()
94/// );
95/// let mut hub = CloudMachineLearningEngine::new(client, auth);
96/// // As the method needs a request, you would usually fill it with the desired information
97/// // into the respective structure. Some of the parts shown here might not be applicable !
98/// // Values shown here are possibly random and not representative !
99/// let mut req = GoogleCloudMlV1__Version::default();
100///
101/// // You can configure optional parameters by calling the respective setters at will, and
102/// // execute the final call using `doit()`.
103/// // Values shown here are possibly random and not representative !
104/// let result = hub.projects().models_versions_patch(req, "name")
105///              .update_mask(FieldMask::new::<&str>(&[]))
106///              .doit().await;
107///
108/// match result {
109///     Err(e) => match e {
110///         // The Error enum provides details about what exactly happened.
111///         // You can also just use its `Debug`, `Display` or `Error` traits
112///          Error::HttpError(_)
113///         |Error::Io(_)
114///         |Error::MissingAPIKey
115///         |Error::MissingToken(_)
116///         |Error::Cancelled
117///         |Error::UploadSizeLimitExceeded(_, _)
118///         |Error::Failure(_)
119///         |Error::BadRequest(_)
120///         |Error::FieldClash(_)
121///         |Error::JsonDecodeError(_, _) => println!("{}", e),
122///     },
123///     Ok(res) => println!("Success: {:?}", res),
124/// }
125/// # }
126/// ```
127#[derive(Clone)]
128pub struct CloudMachineLearningEngine<C> {
129    pub client: common::Client<C>,
130    pub auth: Box<dyn common::GetToken>,
131    _user_agent: String,
132    _base_url: String,
133    _root_url: String,
134}
135
136impl<C> common::Hub for CloudMachineLearningEngine<C> {}
137
138impl<'a, C> CloudMachineLearningEngine<C> {
139    pub fn new<A: 'static + common::GetToken>(
140        client: common::Client<C>,
141        auth: A,
142    ) -> CloudMachineLearningEngine<C> {
143        CloudMachineLearningEngine {
144            client,
145            auth: Box::new(auth),
146            _user_agent: "google-api-rust-client/7.0.0".to_string(),
147            _base_url: "https://ml.googleapis.com/".to_string(),
148            _root_url: "https://ml.googleapis.com/".to_string(),
149        }
150    }
151
152    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
153        ProjectMethods { hub: self }
154    }
155
156    /// Set the user-agent header field to use in all requests to the server.
157    /// It defaults to `google-api-rust-client/7.0.0`.
158    ///
159    /// Returns the previously set user-agent.
160    pub fn user_agent(&mut self, agent_name: String) -> String {
161        std::mem::replace(&mut self._user_agent, agent_name)
162    }
163
164    /// Set the base url to use in all requests to the server.
165    /// It defaults to `https://ml.googleapis.com/`.
166    ///
167    /// Returns the previously set base url.
168    pub fn base_url(&mut self, new_base_url: String) -> String {
169        std::mem::replace(&mut self._base_url, new_base_url)
170    }
171
172    /// Set the root url to use in all requests to the server.
173    /// It defaults to `https://ml.googleapis.com/`.
174    ///
175    /// Returns the previously set root url.
176    pub fn root_url(&mut self, new_root_url: String) -> String {
177        std::mem::replace(&mut self._root_url, new_root_url)
178    }
179}
180
181// ############
182// SCHEMAS ###
183// ##########
184/// Message that represents an arbitrary HTTP body. It should only be used for payload formats that can’t be represented as JSON, such as raw binary or an HTML page. This message can be used both in streaming and non-streaming API methods in the request as well as the response. It can be used as a top-level request field, which is convenient if one wants to extract parameters from either the URL or HTTP template into the request fields and also want access to the raw HTTP body. Example: message GetResourceRequest { // A unique request id. string request_id = 1; // The raw HTTP body is bound to this field. google.api.HttpBody http_body = 2; } service ResourceService { rpc GetResource(GetResourceRequest) returns (google.api.HttpBody); rpc UpdateResource(google.api.HttpBody) returns (google.protobuf.Empty); } Example with streaming methods: service CaldavService { rpc GetCalendar(stream google.api.HttpBody) returns (stream google.api.HttpBody); rpc UpdateCalendar(stream google.api.HttpBody) returns (stream google.api.HttpBody); } Use of this type only changes how the request and response bodies are handled, all other features will continue to work unchanged.
185///
186/// # Activities
187///
188/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
189/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
190///
191/// * [explain projects](ProjectExplainCall) (response)
192/// * [predict projects](ProjectPredictCall) (response)
193#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
194#[serde_with::serde_as]
195#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
196pub struct GoogleApi__HttpBody {
197    /// The HTTP Content-Type header value specifying the content type of the body.
198    #[serde(rename = "contentType")]
199    pub content_type: Option<String>,
200    /// The HTTP request/response body as raw binary.
201    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
202    pub data: Option<Vec<u8>>,
203    /// Application specific response metadata. Must be set in the first response for streaming APIs.
204    pub extensions: Option<Vec<HashMap<String, serde_json::Value>>>,
205}
206
207impl common::ResponseResult for GoogleApi__HttpBody {}
208
209/// There is no detailed description.
210///
211/// This type is not used in any activity, and only used as *part* of another schema.
212///
213#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
214#[serde_with::serde_as]
215#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
216pub struct GoogleCloudMlV1_AutomatedStoppingConfig_DecayCurveAutomatedStoppingConfig {
217    /// If true, measurement.elapsed_time is used as the x-axis of each Trials Decay Curve. Otherwise, Measurement.steps will be used as the x-axis.
218    #[serde(rename = "useElapsedTime")]
219    pub use_elapsed_time: Option<bool>,
220}
221
222impl common::Part for GoogleCloudMlV1_AutomatedStoppingConfig_DecayCurveAutomatedStoppingConfig {}
223
224/// The median automated stopping rule stops a pending trial if the trial's best objective_value is strictly below the median 'performance' of all completed trials reported up to the trial's last measurement. Currently, 'performance' refers to the running average of the objective values reported by the trial in each measurement.
225///
226/// This type is not used in any activity, and only used as *part* of another schema.
227///
228#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
229#[serde_with::serde_as]
230#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
231pub struct GoogleCloudMlV1_AutomatedStoppingConfig_MedianAutomatedStoppingConfig {
232    /// If true, the median automated stopping rule applies to measurement.use_elapsed_time, which means the elapsed_time field of the current trial's latest measurement is used to compute the median objective value for each completed trial.
233    #[serde(rename = "useElapsedTime")]
234    pub use_elapsed_time: Option<bool>,
235}
236
237impl common::Part for GoogleCloudMlV1_AutomatedStoppingConfig_MedianAutomatedStoppingConfig {}
238
239/// An observed value of a metric.
240///
241/// This type is not used in any activity, and only used as *part* of another schema.
242///
243#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
244#[serde_with::serde_as]
245#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
246pub struct GoogleCloudMlV1_HyperparameterOutput_HyperparameterMetric {
247    /// The objective value at this training step.
248    #[serde(rename = "objectiveValue")]
249    pub objective_value: Option<f64>,
250    /// The global training step for this metric.
251    #[serde(rename = "trainingStep")]
252    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
253    pub training_step: Option<i64>,
254}
255
256impl common::Part for GoogleCloudMlV1_HyperparameterOutput_HyperparameterMetric {}
257
258/// A message representing a metric in the measurement.
259///
260/// This type is not used in any activity, and only used as *part* of another schema.
261///
262#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
263#[serde_with::serde_as]
264#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
265pub struct GoogleCloudMlV1_Measurement_Metric {
266    /// Required. Metric name.
267    pub metric: Option<String>,
268    /// Required. The value for this metric.
269    pub value: Option<f64>,
270}
271
272impl common::Part for GoogleCloudMlV1_Measurement_Metric {}
273
274/// There is no detailed description.
275///
276/// This type is not used in any activity, and only used as *part* of another schema.
277///
278#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
279#[serde_with::serde_as]
280#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
281pub struct GoogleCloudMlV1_StudyConfigParameterSpec_CategoricalValueSpec {
282    /// Must be specified if type is `CATEGORICAL`. The list of possible categories.
283    pub values: Option<Vec<String>>,
284}
285
286impl common::Part for GoogleCloudMlV1_StudyConfigParameterSpec_CategoricalValueSpec {}
287
288/// There is no detailed description.
289///
290/// This type is not used in any activity, and only used as *part* of another schema.
291///
292#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
293#[serde_with::serde_as]
294#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
295pub struct GoogleCloudMlV1_StudyConfigParameterSpec_DiscreteValueSpec {
296    /// Must be specified if type is `DISCRETE`. A list of feasible points. The list should be in strictly increasing order. For instance, this parameter might have possible settings of 1.5, 2.5, and 4.0. This list should not contain more than 1,000 values.
297    pub values: Option<Vec<f64>>,
298}
299
300impl common::Part for GoogleCloudMlV1_StudyConfigParameterSpec_DiscreteValueSpec {}
301
302/// There is no detailed description.
303///
304/// This type is not used in any activity, and only used as *part* of another schema.
305///
306#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
307#[serde_with::serde_as]
308#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
309pub struct GoogleCloudMlV1_StudyConfigParameterSpec_DoubleValueSpec {
310    /// Must be specified if type is `DOUBLE`. Maximum value of the parameter.
311    #[serde(rename = "maxValue")]
312    pub max_value: Option<f64>,
313    /// Must be specified if type is `DOUBLE`. Minimum value of the parameter.
314    #[serde(rename = "minValue")]
315    pub min_value: Option<f64>,
316}
317
318impl common::Part for GoogleCloudMlV1_StudyConfigParameterSpec_DoubleValueSpec {}
319
320/// There is no detailed description.
321///
322/// This type is not used in any activity, and only used as *part* of another schema.
323///
324#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
325#[serde_with::serde_as]
326#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
327pub struct GoogleCloudMlV1_StudyConfigParameterSpec_IntegerValueSpec {
328    /// Must be specified if type is `INTEGER`. Maximum value of the parameter.
329    #[serde(rename = "maxValue")]
330    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
331    pub max_value: Option<i64>,
332    /// Must be specified if type is `INTEGER`. Minimum value of the parameter.
333    #[serde(rename = "minValue")]
334    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
335    pub min_value: Option<i64>,
336}
337
338impl common::Part for GoogleCloudMlV1_StudyConfigParameterSpec_IntegerValueSpec {}
339
340/// Represents the spec to match categorical values from parent parameter.
341///
342/// This type is not used in any activity, and only used as *part* of another schema.
343///
344#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
345#[serde_with::serde_as]
346#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
347pub struct GoogleCloudMlV1_StudyConfigParameterSpec_MatchingParentCategoricalValueSpec {
348    /// Matches values of the parent parameter with type 'CATEGORICAL'. All values must exist in `categorical_value_spec` of parent parameter.
349    pub values: Option<Vec<String>>,
350}
351
352impl common::Part for GoogleCloudMlV1_StudyConfigParameterSpec_MatchingParentCategoricalValueSpec {}
353
354/// Represents the spec to match discrete values from parent parameter.
355///
356/// This type is not used in any activity, and only used as *part* of another schema.
357///
358#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
359#[serde_with::serde_as]
360#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
361pub struct GoogleCloudMlV1_StudyConfigParameterSpec_MatchingParentDiscreteValueSpec {
362    /// Matches values of the parent parameter with type 'DISCRETE'. All values must exist in `discrete_value_spec` of parent parameter.
363    pub values: Option<Vec<f64>>,
364}
365
366impl common::Part for GoogleCloudMlV1_StudyConfigParameterSpec_MatchingParentDiscreteValueSpec {}
367
368/// Represents the spec to match integer values from parent parameter.
369///
370/// This type is not used in any activity, and only used as *part* of another schema.
371///
372#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
373#[serde_with::serde_as]
374#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
375pub struct GoogleCloudMlV1_StudyConfigParameterSpec_MatchingParentIntValueSpec {
376    /// Matches values of the parent parameter with type 'INTEGER'. All values must lie in `integer_value_spec` of parent parameter.
377    #[serde_as(as = "Option<Vec<serde_with::DisplayFromStr>>")]
378    pub values: Option<Vec<i64>>,
379}
380
381impl common::Part for GoogleCloudMlV1_StudyConfigParameterSpec_MatchingParentIntValueSpec {}
382
383/// Represents a metric to optimize.
384///
385/// This type is not used in any activity, and only used as *part* of another schema.
386///
387#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
388#[serde_with::serde_as]
389#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
390pub struct GoogleCloudMlV1_StudyConfig_MetricSpec {
391    /// Required. The optimization goal of the metric.
392    pub goal: Option<String>,
393    /// Required. The name of the metric.
394    pub metric: Option<String>,
395}
396
397impl common::Part for GoogleCloudMlV1_StudyConfig_MetricSpec {}
398
399/// Represents a single parameter to optimize.
400///
401/// This type is not used in any activity, and only used as *part* of another schema.
402///
403#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
404#[serde_with::serde_as]
405#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
406pub struct GoogleCloudMlV1_StudyConfig_ParameterSpec {
407    /// The value spec for a 'CATEGORICAL' parameter.
408    #[serde(rename = "categoricalValueSpec")]
409    pub categorical_value_spec:
410        Option<GoogleCloudMlV1_StudyConfigParameterSpec_CategoricalValueSpec>,
411    /// A child node is active if the parameter's value matches the child node's matching_parent_values. If two items in child_parameter_specs have the same name, they must have disjoint matching_parent_values.
412    #[serde(rename = "childParameterSpecs")]
413    pub child_parameter_specs: Option<Vec<GoogleCloudMlV1_StudyConfig_ParameterSpec>>,
414    /// The value spec for a 'DISCRETE' parameter.
415    #[serde(rename = "discreteValueSpec")]
416    pub discrete_value_spec: Option<GoogleCloudMlV1_StudyConfigParameterSpec_DiscreteValueSpec>,
417    /// The value spec for a 'DOUBLE' parameter.
418    #[serde(rename = "doubleValueSpec")]
419    pub double_value_spec: Option<GoogleCloudMlV1_StudyConfigParameterSpec_DoubleValueSpec>,
420    /// The value spec for an 'INTEGER' parameter.
421    #[serde(rename = "integerValueSpec")]
422    pub integer_value_spec: Option<GoogleCloudMlV1_StudyConfigParameterSpec_IntegerValueSpec>,
423    /// Required. The parameter name must be unique amongst all ParameterSpecs.
424    pub parameter: Option<String>,
425    /// no description provided
426    #[serde(rename = "parentCategoricalValues")]
427    pub parent_categorical_values:
428        Option<GoogleCloudMlV1_StudyConfigParameterSpec_MatchingParentCategoricalValueSpec>,
429    /// no description provided
430    #[serde(rename = "parentDiscreteValues")]
431    pub parent_discrete_values:
432        Option<GoogleCloudMlV1_StudyConfigParameterSpec_MatchingParentDiscreteValueSpec>,
433    /// no description provided
434    #[serde(rename = "parentIntValues")]
435    pub parent_int_values:
436        Option<GoogleCloudMlV1_StudyConfigParameterSpec_MatchingParentIntValueSpec>,
437    /// How the parameter should be scaled. Leave unset for categorical parameters.
438    #[serde(rename = "scaleType")]
439    pub scale_type: Option<String>,
440    /// Required. The type of the parameter.
441    #[serde(rename = "type")]
442    pub type_: Option<String>,
443}
444
445impl common::Part for GoogleCloudMlV1_StudyConfig_ParameterSpec {}
446
447/// A message representing a parameter to be tuned. Contains the name of the parameter and the suggested value to use for this trial.
448///
449/// This type is not used in any activity, and only used as *part* of another schema.
450///
451#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
452#[serde_with::serde_as]
453#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
454pub struct GoogleCloudMlV1_Trial_Parameter {
455    /// Must be set if ParameterType is DOUBLE or DISCRETE.
456    #[serde(rename = "floatValue")]
457    pub float_value: Option<f64>,
458    /// Must be set if ParameterType is INTEGER
459    #[serde(rename = "intValue")]
460    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
461    pub int_value: Option<i64>,
462    /// The name of the parameter.
463    pub parameter: Option<String>,
464    /// Must be set if ParameterTypeis CATEGORICAL
465    #[serde(rename = "stringValue")]
466    pub string_value: Option<String>,
467}
468
469impl common::Part for GoogleCloudMlV1_Trial_Parameter {}
470
471/// Represents a hardware accelerator request config. Note that the AcceleratorConfig can be used in both Jobs and Versions. Learn more about [accelerators for training](https://cloud.google.com/ml-engine/docs/using-gpus) and [accelerators for online prediction](https://cloud.google.com/ml-engine/docs/machine-types-online-prediction#gpus).
472///
473/// This type is not used in any activity, and only used as *part* of another schema.
474#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
475#[serde_with::serde_as]
476#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
477pub struct GoogleCloudMlV1__AcceleratorConfig {
478    /// The number of accelerators to attach to each machine running the job.
479    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
480    pub count: Option<i64>,
481    /// The type of accelerator to use.
482    #[serde(rename = "type")]
483    pub type_: Option<String>,
484}
485
486impl common::Part for GoogleCloudMlV1__AcceleratorConfig {}
487
488/// The request message for the AddTrialMeasurement service method.
489///
490/// # Activities
491///
492/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
493/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
494///
495/// * [locations studies trials add measurement projects](ProjectLocationStudyTrialAddMeasurementCall) (request)
496#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
497#[serde_with::serde_as]
498#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
499pub struct GoogleCloudMlV1__AddTrialMeasurementRequest {
500    /// Required. The measurement to be added to a trial.
501    pub measurement: Option<GoogleCloudMlV1__Measurement>,
502}
503
504impl common::RequestValue for GoogleCloudMlV1__AddTrialMeasurementRequest {}
505
506/// Options for automatically scaling a model.
507///
508/// This type is not used in any activity, and only used as *part* of another schema.
509///
510#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
511#[serde_with::serde_as]
512#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
513pub struct GoogleCloudMlV1__AutoScaling {
514    /// The maximum number of nodes to scale this model under load. The actual value will depend on resource quota and availability.
515    #[serde(rename = "maxNodes")]
516    pub max_nodes: Option<i32>,
517    /// MetricSpec contains the specifications to use to calculate the desired nodes count.
518    pub metrics: Option<Vec<GoogleCloudMlV1__MetricSpec>>,
519    /// Optional. The minimum number of nodes to allocate for this model. These nodes are always up, starting from the time the model is deployed. Therefore, the cost of operating this model will be at least `rate` * `min_nodes` * number of hours since last billing cycle, where `rate` is the cost per node-hour as documented in the [pricing guide](https://cloud.google.com/ml-engine/docs/pricing), even if no predictions are performed. There is additional cost for each prediction performed. Unlike manual scaling, if the load gets too heavy for the nodes that are up, the service will automatically add nodes to handle the increased load as well as scale back as traffic drops, always maintaining at least `min_nodes`. You will be charged for the time in which additional nodes are used. If `min_nodes` is not specified and AutoScaling is used with a [legacy (MLS1) machine type](https://cloud.google.com/ml-engine/docs/machine-types-online-prediction), `min_nodes` defaults to 0, in which case, when traffic to a model stops (and after a cool-down period), nodes will be shut down and no charges will be incurred until traffic to the model resumes. If `min_nodes` is not specified and AutoScaling is used with a [Compute Engine (N1) machine type](https://cloud.google.com/ml-engine/docs/machine-types-online-prediction), `min_nodes` defaults to 1. `min_nodes` must be at least 1 for use with a Compute Engine machine type. You can set `min_nodes` when creating the model version, and you can also update `min_nodes` for an existing version: update_body.json: { ‘autoScaling’: { ‘minNodes’: 5 } } HTTP request: PATCH https://ml.googleapis.com/v1/{name=projects/*/models/*/versions/\*}?update_mask=autoScaling.minNodes -d @./update_body.json
520    #[serde(rename = "minNodes")]
521    pub min_nodes: Option<i32>,
522}
523
524impl common::Part for GoogleCloudMlV1__AutoScaling {}
525
526/// Configuration for Automated Early Stopping of Trials. If no implementation_config is set, automated early stopping will not be run.
527///
528/// This type is not used in any activity, and only used as *part* of another schema.
529///
530#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
531#[serde_with::serde_as]
532#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
533pub struct GoogleCloudMlV1__AutomatedStoppingConfig {
534    /// no description provided
535    #[serde(rename = "decayCurveStoppingConfig")]
536    pub decay_curve_stopping_config:
537        Option<GoogleCloudMlV1_AutomatedStoppingConfig_DecayCurveAutomatedStoppingConfig>,
538    /// no description provided
539    #[serde(rename = "medianAutomatedStoppingConfig")]
540    pub median_automated_stopping_config:
541        Option<GoogleCloudMlV1_AutomatedStoppingConfig_MedianAutomatedStoppingConfig>,
542}
543
544impl common::Part for GoogleCloudMlV1__AutomatedStoppingConfig {}
545
546/// Represents output related to a built-in algorithm Job.
547///
548/// This type is not used in any activity, and only used as *part* of another schema.
549///
550#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
551#[serde_with::serde_as]
552#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
553pub struct GoogleCloudMlV1__BuiltInAlgorithmOutput {
554    /// Framework on which the built-in algorithm was trained.
555    pub framework: Option<String>,
556    /// The Cloud Storage path to the `model/` directory where the training job saves the trained model. Only set for successful jobs that don't use hyperparameter tuning.
557    #[serde(rename = "modelPath")]
558    pub model_path: Option<String>,
559    /// Python version on which the built-in algorithm was trained.
560    #[serde(rename = "pythonVersion")]
561    pub python_version: Option<String>,
562    /// AI Platform runtime version on which the built-in algorithm was trained.
563    #[serde(rename = "runtimeVersion")]
564    pub runtime_version: Option<String>,
565}
566
567impl common::Part for GoogleCloudMlV1__BuiltInAlgorithmOutput {}
568
569/// Request message for the CancelJob method.
570///
571/// # Activities
572///
573/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
574/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
575///
576/// * [jobs cancel projects](ProjectJobCancelCall) (request)
577#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
578#[serde_with::serde_as]
579#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
580pub struct GoogleCloudMlV1__CancelJobRequest {
581    _never_set: Option<bool>,
582}
583
584impl common::RequestValue for GoogleCloudMlV1__CancelJobRequest {}
585
586/// There is no detailed description.
587///
588/// This type is not used in any activity, and only used as *part* of another schema.
589///
590#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
591#[serde_with::serde_as]
592#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
593pub struct GoogleCloudMlV1__Capability {
594    /// Available accelerators for the capability.
595    #[serde(rename = "availableAccelerators")]
596    pub available_accelerators: Option<Vec<String>>,
597    /// no description provided
598    #[serde(rename = "type")]
599    pub type_: Option<String>,
600}
601
602impl common::Part for GoogleCloudMlV1__Capability {}
603
604/// The request message for the CheckTrialEarlyStoppingState service method.
605///
606/// # Activities
607///
608/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
609/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
610///
611/// * [locations studies trials check early stopping state projects](ProjectLocationStudyTrialCheckEarlyStoppingStateCall) (request)
612#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
613#[serde_with::serde_as]
614#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
615pub struct GoogleCloudMlV1__CheckTrialEarlyStoppingStateRequest {
616    _never_set: Option<bool>,
617}
618
619impl common::RequestValue for GoogleCloudMlV1__CheckTrialEarlyStoppingStateRequest {}
620
621/// The request message for the CompleteTrial service method.
622///
623/// # Activities
624///
625/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
626/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
627///
628/// * [locations studies trials complete projects](ProjectLocationStudyTrialCompleteCall) (request)
629#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
630#[serde_with::serde_as]
631#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
632pub struct GoogleCloudMlV1__CompleteTrialRequest {
633    /// Optional. If provided, it will be used as the completed trial's final_measurement; Otherwise, the service will auto-select a previously reported measurement as the final-measurement
634    #[serde(rename = "finalMeasurement")]
635    pub final_measurement: Option<GoogleCloudMlV1__Measurement>,
636    /// Optional. A human readable reason why the trial was infeasible. This should only be provided if `trial_infeasible` is true.
637    #[serde(rename = "infeasibleReason")]
638    pub infeasible_reason: Option<String>,
639    /// Optional. True if the trial cannot be run with the given Parameter, and final_measurement will be ignored.
640    #[serde(rename = "trialInfeasible")]
641    pub trial_infeasible: Option<bool>,
642}
643
644impl common::RequestValue for GoogleCloudMlV1__CompleteTrialRequest {}
645
646/// There is no detailed description.
647///
648/// This type is not used in any activity, and only used as *part* of another schema.
649///
650#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
651#[serde_with::serde_as]
652#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
653pub struct GoogleCloudMlV1__Config {
654    /// The service account Cloud ML uses to run on TPU node.
655    #[serde(rename = "tpuServiceAccount")]
656    pub tpu_service_account: Option<String>,
657}
658
659impl common::Part for GoogleCloudMlV1__Config {}
660
661/// Represents a network port in a single container. This message is a subset of the [Kubernetes ContainerPort v1 core specification](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#containerport-v1-core).
662///
663/// This type is not used in any activity, and only used as *part* of another schema.
664///
665#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
666#[serde_with::serde_as]
667#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
668pub struct GoogleCloudMlV1__ContainerPort {
669    /// Number of the port to expose on the container. This must be a valid port number: 0 < PORT_NUMBER < 65536.
670    #[serde(rename = "containerPort")]
671    pub container_port: Option<i32>,
672}
673
674impl common::Part for GoogleCloudMlV1__ContainerPort {}
675
676/// Specification of a custom container for serving predictions. This message is a subset of the [Kubernetes Container v1 core specification](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#container-v1-core).
677///
678/// This type is not used in any activity, and only used as *part* of another schema.
679///
680#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
681#[serde_with::serde_as]
682#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
683pub struct GoogleCloudMlV1__ContainerSpec {
684    /// Immutable. Specifies arguments for the command that runs when the container starts. This overrides the container’s [`CMD`](https://docs.docker.com/engine/reference/builder/#cmd). Specify this field as an array of executable and arguments, similar to a Docker `CMD`’s “default parameters” form. If you don’t specify this field but do specify the command field, then the command from the `command` field runs without any additional arguments. See the [Kubernetes documentation about how the `command` and `args` fields interact with a container’s `ENTRYPOINT` and `CMD`](https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#notes). If you don’t specify this field and don’t specify the `commmand` field, then the container’s [`ENTRYPOINT`](https://docs.docker.com/engine/reference/builder/#cmd) and `CMD` determine what runs based on their default behavior. See the [Docker documentation about how `CMD` and `ENTRYPOINT` interact](https://docs.docker.com/engine/reference/builder/#understand-how-cmd-and-entrypoint-interact). In this field, you can reference [environment variables set by AI Platform Prediction](https://cloud.google.com/ai-platform/prediction/docs/custom-container-requirements#aip-variables) and environment variables set in the env field. You cannot reference environment variables set in the Docker image. In order for environment variables to be expanded, reference them by using the following syntax: $( VARIABLE_NAME) Note that this differs from Bash variable expansion, which does not use parentheses. If a variable cannot be resolved, the reference in the input string is used unchanged. To avoid variable expansion, you can escape this syntax with `$$`; for example: $$(VARIABLE_NAME) This field corresponds to the `args` field of the [Kubernetes Containers v1 core API](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#container-v1-core).
685    pub args: Option<Vec<String>>,
686    /// Immutable. Specifies the command that runs when the container starts. This overrides the container’s [`ENTRYPOINT`](https://docs.docker.com/engine/reference/builder/#entrypoint). Specify this field as an array of executable and arguments, similar to a Docker `ENTRYPOINT`’s “exec” form, not its “shell” form. If you do not specify this field, then the container’s `ENTRYPOINT` runs, in conjunction with the args field or the container’s [`CMD`](https://docs.docker.com/engine/reference/builder/#cmd), if either exists. If this field is not specified and the container does not have an `ENTRYPOINT`, then refer to the [Docker documentation about how `CMD` and `ENTRYPOINT` interact](https://docs.docker.com/engine/reference/builder/#understand-how-cmd-and-entrypoint-interact). If you specify this field, then you can also specify the `args` field to provide additional arguments for this command. However, if you specify this field, then the container’s `CMD` is ignored. See the [Kubernetes documentation about how the `command` and `args` fields interact with a container’s `ENTRYPOINT` and `CMD`](https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#notes). In this field, you can reference [environment variables set by AI Platform Prediction](https://cloud.google.com/ai-platform/prediction/docs/custom-container-requirements#aip-variables) and environment variables set in the env field. You cannot reference environment variables set in the Docker image. In order for environment variables to be expanded, reference them by using the following syntax: $( VARIABLE_NAME) Note that this differs from Bash variable expansion, which does not use parentheses. If a variable cannot be resolved, the reference in the input string is used unchanged. To avoid variable expansion, you can escape this syntax with `$$`; for example: $$(VARIABLE_NAME) This field corresponds to the `command` field of the [Kubernetes Containers v1 core API](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#container-v1-core).
687    pub command: Option<Vec<String>>,
688    /// Immutable. List of environment variables to set in the container. After the container starts running, code running in the container can read these environment variables. Additionally, the command and args fields can reference these variables. Later entries in this list can also reference earlier entries. For example, the following example sets the variable `VAR_2` to have the value `foo bar`: ```json [ { "name": "VAR_1", "value": "foo" }, { "name": "VAR_2", "value": "$(VAR_1) bar" } ] ``` If you switch the order of the variables in the example, then the expansion does not occur. This field corresponds to the `env` field of the [Kubernetes Containers v1 core API](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#container-v1-core).
689    pub env: Option<Vec<GoogleCloudMlV1__EnvVar>>,
690    /// URI of the Docker image to be used as the custom container for serving predictions. This URI must identify [an image in Artifact Registry](https://cloud.google.com/artifact-registry/docs/overview) and begin with the hostname `{REGION}-docker.pkg.dev`, where `{REGION}` is replaced by the region that matches AI Platform Prediction [regional endpoint](https://cloud.google.com/ai-platform/prediction/docs/regional-endpoints) that you are using. For example, if you are using the `us-central1-ml.googleapis.com` endpoint, then this URI must begin with `us-central1-docker.pkg.dev`. To use a custom container, the [AI Platform Google-managed service account](https://cloud.google.com/ai-platform/prediction/docs/custom-service-account#default) must have permission to pull (read) the Docker image at this URI. The AI Platform Google-managed service account has the following format: `service-{PROJECT_NUMBER}@cloud-ml.google.com.iam.gserviceaccount.com` {PROJECT_NUMBER} is replaced by your Google Cloud project number. By default, this service account has necessary permissions to pull an Artifact Registry image in the same Google Cloud project where you are using AI Platform Prediction. In this case, no configuration is necessary. If you want to use an image from a different Google Cloud project, learn how to [grant the Artifact Registry Reader (roles/artifactregistry.reader) role for a repository](https://cloud.google.com/artifact-registry/docs/access-control#grant-repo) to your projet’s AI Platform Google-managed service account. To learn about the requirements for the Docker image itself, read [Custom container requirements](https://cloud.google.com/ai-platform/prediction/docs/custom-container-requirements).
691    pub image: Option<String>,
692    /// Immutable. List of ports to expose from the container. AI Platform Prediction sends any prediction requests that it receives to the first port on this list. AI Platform Prediction also sends [liveness and health checks](https://cloud.google.com/ai-platform/prediction/docs/custom-container-requirements#health) to this port. If you do not specify this field, it defaults to following value: `json [ { "containerPort": 8080 } ] ` AI Platform Prediction does not use ports other than the first one listed. This field corresponds to the `ports` field of the [Kubernetes Containers v1 core API](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#container-v1-core).
693    pub ports: Option<Vec<GoogleCloudMlV1__ContainerPort>>,
694}
695
696impl common::Part for GoogleCloudMlV1__ContainerSpec {}
697
698/// Represents the config of disk options.
699///
700/// This type is not used in any activity, and only used as *part* of another schema.
701///
702#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
703#[serde_with::serde_as]
704#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
705pub struct GoogleCloudMlV1__DiskConfig {
706    /// Size in GB of the boot disk (default is 100GB).
707    #[serde(rename = "bootDiskSizeGb")]
708    pub boot_disk_size_gb: Option<i32>,
709    /// Type of the boot disk (default is "pd-ssd"). Valid values: "pd-ssd" (Persistent Disk Solid State Drive) or "pd-standard" (Persistent Disk Hard Disk Drive).
710    #[serde(rename = "bootDiskType")]
711    pub boot_disk_type: Option<String>,
712}
713
714impl common::Part for GoogleCloudMlV1__DiskConfig {}
715
716/// Represents a custom encryption key configuration that can be applied to a resource.
717///
718/// This type is not used in any activity, and only used as *part* of another schema.
719///
720#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
721#[serde_with::serde_as]
722#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
723pub struct GoogleCloudMlV1__EncryptionConfig {
724    /// The Cloud KMS resource identifier of the customer-managed encryption key used to protect a resource, such as a training job. It has the following format: `projects/{PROJECT_ID}/locations/{REGION}/keyRings/{KEY_RING_NAME}/cryptoKeys/{KEY_NAME}`
725    #[serde(rename = "kmsKeyName")]
726    pub kms_key_name: Option<String>,
727}
728
729impl common::Part for GoogleCloudMlV1__EncryptionConfig {}
730
731/// Represents an environment variable to be made available in a container. This message is a subset of the [Kubernetes EnvVar v1 core specification](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#envvar-v1-core).
732///
733/// This type is not used in any activity, and only used as *part* of another schema.
734///
735#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
736#[serde_with::serde_as]
737#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
738pub struct GoogleCloudMlV1__EnvVar {
739    /// Name of the environment variable. Must be a [valid C identifier](https://github.com/kubernetes/kubernetes/blob/v1.18.8/staging/src/k8s.io/apimachinery/pkg/util/validation/validation.go#L258) and must not begin with the prefix `AIP_`.
740    pub name: Option<String>,
741    /// Value of the environment variable. Defaults to an empty string. In this field, you can reference [environment variables set by AI Platform Prediction](https://cloud.google.com/ai-platform/prediction/docs/custom-container-requirements#aip-variables) and environment variables set earlier in the same env field as where this message occurs. You cannot reference environment variables set in the Docker image. In order for environment variables to be expanded, reference them by using the following syntax: $(VARIABLE_NAME) Note that this differs from Bash variable expansion, which does not use parentheses. If a variable cannot be resolved, the reference in the input string is used unchanged. To avoid variable expansion, you can escape this syntax with `$$`; for example: $$(VARIABLE_NAME)
742    pub value: Option<String>,
743}
744
745impl common::Part for GoogleCloudMlV1__EnvVar {}
746
747/// Request for explanations to be issued against a trained model.
748///
749/// # Activities
750///
751/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
752/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
753///
754/// * [explain projects](ProjectExplainCall) (request)
755#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
756#[serde_with::serde_as]
757#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
758pub struct GoogleCloudMlV1__ExplainRequest {
759    /// Required. The explanation request body.
760    #[serde(rename = "httpBody")]
761    pub http_body: Option<GoogleApi__HttpBody>,
762}
763
764impl common::RequestValue for GoogleCloudMlV1__ExplainRequest {}
765
766/// Message holding configuration options for explaining model predictions. There are three feature attribution methods supported for TensorFlow models: integrated gradients, sampled Shapley, and XRAI. [Learn more about feature attributions.](https://cloud.google.com/ai-platform/prediction/docs/ai-explanations/overview)
767///
768/// This type is not used in any activity, and only used as *part* of another schema.
769#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
770#[serde_with::serde_as]
771#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
772pub struct GoogleCloudMlV1__ExplanationConfig {
773    /// Attributes credit by computing the Aumann-Shapley value taking advantage of the model's fully differentiable structure. Refer to this paper for more details: https://arxiv.org/abs/1703.01365
774    #[serde(rename = "integratedGradientsAttribution")]
775    pub integrated_gradients_attribution: Option<GoogleCloudMlV1__IntegratedGradientsAttribution>,
776    /// An attribution method that approximates Shapley values for features that contribute to the label being predicted. A sampling strategy is used to approximate the value rather than considering all subsets of features.
777    #[serde(rename = "sampledShapleyAttribution")]
778    pub sampled_shapley_attribution: Option<GoogleCloudMlV1__SampledShapleyAttribution>,
779    /// Attributes credit by computing the XRAI taking advantage of the model's fully differentiable structure. Refer to this paper for more details: https://arxiv.org/abs/1906.02825 Currently only implemented for models with natural image inputs.
780    #[serde(rename = "xraiAttribution")]
781    pub xrai_attribution: Option<GoogleCloudMlV1__XraiAttribution>,
782}
783
784impl common::Part for GoogleCloudMlV1__ExplanationConfig {}
785
786/// Returns service account information associated with a project.
787///
788/// # Activities
789///
790/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
791/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
792///
793/// * [get config projects](ProjectGetConfigCall) (response)
794#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
795#[serde_with::serde_as]
796#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
797pub struct GoogleCloudMlV1__GetConfigResponse {
798    /// no description provided
799    pub config: Option<GoogleCloudMlV1__Config>,
800    /// The service account Cloud ML uses to access resources in the project.
801    #[serde(rename = "serviceAccount")]
802    pub service_account: Option<String>,
803    /// The project number for `service_account`.
804    #[serde(rename = "serviceAccountProject")]
805    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
806    pub service_account_project: Option<i64>,
807}
808
809impl common::ResponseResult for GoogleCloudMlV1__GetConfigResponse {}
810
811/// Represents the result of a single hyperparameter tuning trial from a training job. The TrainingOutput object that is returned on successful completion of a training job with hyperparameter tuning includes a list of HyperparameterOutput objects, one for each successful trial.
812///
813/// This type is not used in any activity, and only used as *part* of another schema.
814///
815#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
816#[serde_with::serde_as]
817#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
818pub struct GoogleCloudMlV1__HyperparameterOutput {
819    /// All recorded object metrics for this trial. This field is not currently populated.
820    #[serde(rename = "allMetrics")]
821    pub all_metrics: Option<Vec<GoogleCloudMlV1_HyperparameterOutput_HyperparameterMetric>>,
822    /// Details related to built-in algorithms jobs. Only set for trials of built-in algorithms jobs that have succeeded.
823    #[serde(rename = "builtInAlgorithmOutput")]
824    pub built_in_algorithm_output: Option<GoogleCloudMlV1__BuiltInAlgorithmOutput>,
825    /// Output only. End time for the trial.
826    #[serde(rename = "endTime")]
827    pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
828    /// The final objective metric seen for this trial.
829    #[serde(rename = "finalMetric")]
830    pub final_metric: Option<GoogleCloudMlV1_HyperparameterOutput_HyperparameterMetric>,
831    /// The hyperparameters given to this trial.
832    pub hyperparameters: Option<HashMap<String, String>>,
833    /// True if the trial is stopped early.
834    #[serde(rename = "isTrialStoppedEarly")]
835    pub is_trial_stopped_early: Option<bool>,
836    /// Output only. Start time for the trial.
837    #[serde(rename = "startTime")]
838    pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
839    /// Output only. The detailed state of the trial.
840    pub state: Option<String>,
841    /// The trial id for these results.
842    #[serde(rename = "trialId")]
843    pub trial_id: Option<String>,
844    /// URIs for accessing [interactive shells](https://cloud.google.com/ai-platform/training/docs/monitor-debug-interactive-shell) (one URI for each training node). Only available if this trial is part of a hyperparameter tuning job and the job's training_input.enable_web_access is `true`. The keys are names of each node in the training job; for example, `master-replica-0` for the master node, `worker-replica-0` for the first worker, and `ps-replica-0` for the first parameter server. The values are the URIs for each node's interactive shell.
845    #[serde(rename = "webAccessUris")]
846    pub web_access_uris: Option<HashMap<String, String>>,
847}
848
849impl common::Part for GoogleCloudMlV1__HyperparameterOutput {}
850
851/// Represents a set of hyperparameters to optimize.
852///
853/// This type is not used in any activity, and only used as *part* of another schema.
854///
855#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
856#[serde_with::serde_as]
857#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
858pub struct GoogleCloudMlV1__HyperparameterSpec {
859    /// Optional. The search algorithm specified for the hyperparameter tuning job. Uses the default AI Platform hyperparameter tuning algorithm if unspecified.
860    pub algorithm: Option<String>,
861    /// Optional. Indicates if the hyperparameter tuning job enables auto trial early stopping.
862    #[serde(rename = "enableTrialEarlyStopping")]
863    pub enable_trial_early_stopping: Option<bool>,
864    /// Required. The type of goal to use for tuning. Available types are `MAXIMIZE` and `MINIMIZE`. Defaults to `MAXIMIZE`.
865    pub goal: Option<String>,
866    /// Optional. The TensorFlow summary tag name to use for optimizing trials. For current versions of TensorFlow, this tag name should exactly match what is shown in TensorBoard, including all scopes. For versions of TensorFlow prior to 0.12, this should be only the tag passed to tf.Summary. By default, "training/hptuning/metric" will be used.
867    #[serde(rename = "hyperparameterMetricTag")]
868    pub hyperparameter_metric_tag: Option<String>,
869    /// Optional. The number of failed trials that need to be seen before failing the hyperparameter tuning job. You can specify this field to override the default failing criteria for AI Platform hyperparameter tuning jobs. Defaults to zero, which means the service decides when a hyperparameter job should fail.
870    #[serde(rename = "maxFailedTrials")]
871    pub max_failed_trials: Option<i32>,
872    /// Optional. The number of training trials to run concurrently. You can reduce the time it takes to perform hyperparameter tuning by adding trials in parallel. However, each trail only benefits from the information gained in completed trials. That means that a trial does not get access to the results of trials running at the same time, which could reduce the quality of the overall optimization. Each trial will use the same scale tier and machine types. Defaults to one.
873    #[serde(rename = "maxParallelTrials")]
874    pub max_parallel_trials: Option<i32>,
875    /// Optional. How many training trials should be attempted to optimize the specified hyperparameters. Defaults to one.
876    #[serde(rename = "maxTrials")]
877    pub max_trials: Option<i32>,
878    /// Required. The set of parameters to tune.
879    pub params: Option<Vec<GoogleCloudMlV1__ParameterSpec>>,
880    /// Optional. The prior hyperparameter tuning job id that users hope to continue with. The job id will be used to find the corresponding vizier study guid and resume the study.
881    #[serde(rename = "resumePreviousJobId")]
882    pub resume_previous_job_id: Option<String>,
883}
884
885impl common::Part for GoogleCloudMlV1__HyperparameterSpec {}
886
887/// Attributes credit by computing the Aumann-Shapley value taking advantage of the model's fully differentiable structure. Refer to this paper for more details: https://arxiv.org/abs/1703.01365
888///
889/// This type is not used in any activity, and only used as *part* of another schema.
890///
891#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
892#[serde_with::serde_as]
893#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
894pub struct GoogleCloudMlV1__IntegratedGradientsAttribution {
895    /// Number of steps for approximating the path integral. A good value to start is 50 and gradually increase until the sum to diff property is met within the desired error range.
896    #[serde(rename = "numIntegralSteps")]
897    pub num_integral_steps: Option<i32>,
898}
899
900impl common::Part for GoogleCloudMlV1__IntegratedGradientsAttribution {}
901
902/// Represents a training or prediction job.
903///
904/// # Activities
905///
906/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
907/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
908///
909/// * [jobs create projects](ProjectJobCreateCall) (request|response)
910/// * [jobs get projects](ProjectJobGetCall) (response)
911/// * [jobs patch projects](ProjectJobPatchCall) (request|response)
912#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
913#[serde_with::serde_as]
914#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
915pub struct GoogleCloudMlV1__Job {
916    /// Output only. When the job was created.
917    #[serde(rename = "createTime")]
918    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
919    /// Output only. When the job processing was completed.
920    #[serde(rename = "endTime")]
921    pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
922    /// Output only. The details of a failure or a cancellation.
923    #[serde(rename = "errorMessage")]
924    pub error_message: Option<String>,
925    /// `etag` is used for optimistic concurrency control as a way to help prevent simultaneous updates of a job from overwriting each other. It is strongly suggested that systems make use of the `etag` in the read-modify-write cycle to perform job updates in order to avoid race conditions: An `etag` is returned in the response to `GetJob`, and systems are expected to put that etag in the request to `UpdateJob` to ensure that their change will be applied to the same version of the job.
926    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
927    pub etag: Option<Vec<u8>>,
928    /// Required. The user-specified id of the job.
929    #[serde(rename = "jobId")]
930    pub job_id: Option<String>,
931    /// Output only. It's only effect when the job is in QUEUED state. If it's positive, it indicates the job's position in the job scheduler. It's 0 when the job is already scheduled.
932    #[serde(rename = "jobPosition")]
933    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
934    pub job_position: Option<i64>,
935    /// Optional. One or more labels that you can add, to organize your jobs. Each label is a key-value pair, where both the key and the value are arbitrary strings that you supply. For more information, see the documentation on using labels.
936    pub labels: Option<HashMap<String, String>>,
937    /// Input parameters to create a prediction job.
938    #[serde(rename = "predictionInput")]
939    pub prediction_input: Option<GoogleCloudMlV1__PredictionInput>,
940    /// The current prediction job result.
941    #[serde(rename = "predictionOutput")]
942    pub prediction_output: Option<GoogleCloudMlV1__PredictionOutput>,
943    /// Output only. When the job processing was started.
944    #[serde(rename = "startTime")]
945    pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
946    /// Output only. The detailed state of a job.
947    pub state: Option<String>,
948    /// Input parameters to create a training job.
949    #[serde(rename = "trainingInput")]
950    pub training_input: Option<GoogleCloudMlV1__TrainingInput>,
951    /// The current training job result.
952    #[serde(rename = "trainingOutput")]
953    pub training_output: Option<GoogleCloudMlV1__TrainingOutput>,
954}
955
956impl common::RequestValue for GoogleCloudMlV1__Job {}
957impl common::ResponseResult for GoogleCloudMlV1__Job {}
958
959/// Response message for the ListJobs method.
960///
961/// # Activities
962///
963/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
964/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
965///
966/// * [jobs list projects](ProjectJobListCall) (response)
967#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
968#[serde_with::serde_as]
969#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
970pub struct GoogleCloudMlV1__ListJobsResponse {
971    /// The list of jobs.
972    pub jobs: Option<Vec<GoogleCloudMlV1__Job>>,
973    /// Optional. Pass this token as the `page_token` field of the request for a subsequent call.
974    #[serde(rename = "nextPageToken")]
975    pub next_page_token: Option<String>,
976}
977
978impl common::ResponseResult for GoogleCloudMlV1__ListJobsResponse {}
979
980/// There is no detailed description.
981///
982/// # Activities
983///
984/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
985/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
986///
987/// * [locations list projects](ProjectLocationListCall) (response)
988#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
989#[serde_with::serde_as]
990#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
991pub struct GoogleCloudMlV1__ListLocationsResponse {
992    /// Locations where at least one type of CMLE capability is available.
993    pub locations: Option<Vec<GoogleCloudMlV1__Location>>,
994    /// Optional. Pass this token as the `page_token` field of the request for a subsequent call.
995    #[serde(rename = "nextPageToken")]
996    pub next_page_token: Option<String>,
997}
998
999impl common::ResponseResult for GoogleCloudMlV1__ListLocationsResponse {}
1000
1001/// Response message for the ListModels method.
1002///
1003/// # Activities
1004///
1005/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1006/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1007///
1008/// * [models list projects](ProjectModelListCall) (response)
1009#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1010#[serde_with::serde_as]
1011#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1012pub struct GoogleCloudMlV1__ListModelsResponse {
1013    /// The list of models.
1014    pub models: Option<Vec<GoogleCloudMlV1__Model>>,
1015    /// Optional. Pass this token as the `page_token` field of the request for a subsequent call.
1016    #[serde(rename = "nextPageToken")]
1017    pub next_page_token: Option<String>,
1018}
1019
1020impl common::ResponseResult for GoogleCloudMlV1__ListModelsResponse {}
1021
1022/// The request message for the ListTrials service method.
1023///
1024/// # Activities
1025///
1026/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1027/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1028///
1029/// * [locations studies trials list optimal trials projects](ProjectLocationStudyTrialListOptimalTrialCall) (request)
1030#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1031#[serde_with::serde_as]
1032#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1033pub struct GoogleCloudMlV1__ListOptimalTrialsRequest {
1034    _never_set: Option<bool>,
1035}
1036
1037impl common::RequestValue for GoogleCloudMlV1__ListOptimalTrialsRequest {}
1038
1039/// The response message for the ListOptimalTrials method.
1040///
1041/// # Activities
1042///
1043/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1044/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1045///
1046/// * [locations studies trials list optimal trials projects](ProjectLocationStudyTrialListOptimalTrialCall) (response)
1047#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1048#[serde_with::serde_as]
1049#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1050pub struct GoogleCloudMlV1__ListOptimalTrialsResponse {
1051    /// The pareto-optimal trials for multiple objective study or the optimal trial for single objective study. The definition of pareto-optimal can be checked in wiki page. https://en.wikipedia.org/wiki/Pareto_efficiency
1052    pub trials: Option<Vec<GoogleCloudMlV1__Trial>>,
1053}
1054
1055impl common::ResponseResult for GoogleCloudMlV1__ListOptimalTrialsResponse {}
1056
1057/// There is no detailed description.
1058///
1059/// # Activities
1060///
1061/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1062/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1063///
1064/// * [locations studies list projects](ProjectLocationStudyListCall) (response)
1065#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1066#[serde_with::serde_as]
1067#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1068pub struct GoogleCloudMlV1__ListStudiesResponse {
1069    /// The studies associated with the project.
1070    pub studies: Option<Vec<GoogleCloudMlV1__Study>>,
1071}
1072
1073impl common::ResponseResult for GoogleCloudMlV1__ListStudiesResponse {}
1074
1075/// The response message for the ListTrials method.
1076///
1077/// # Activities
1078///
1079/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1080/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1081///
1082/// * [locations studies trials list projects](ProjectLocationStudyTrialListCall) (response)
1083#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1084#[serde_with::serde_as]
1085#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1086pub struct GoogleCloudMlV1__ListTrialsResponse {
1087    /// The trials associated with the study.
1088    pub trials: Option<Vec<GoogleCloudMlV1__Trial>>,
1089}
1090
1091impl common::ResponseResult for GoogleCloudMlV1__ListTrialsResponse {}
1092
1093/// Response message for the ListVersions method.
1094///
1095/// # Activities
1096///
1097/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1098/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1099///
1100/// * [models versions list projects](ProjectModelVersionListCall) (response)
1101#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1102#[serde_with::serde_as]
1103#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1104pub struct GoogleCloudMlV1__ListVersionsResponse {
1105    /// Optional. Pass this token as the `page_token` field of the request for a subsequent call.
1106    #[serde(rename = "nextPageToken")]
1107    pub next_page_token: Option<String>,
1108    /// The list of versions.
1109    pub versions: Option<Vec<GoogleCloudMlV1__Version>>,
1110}
1111
1112impl common::ResponseResult for GoogleCloudMlV1__ListVersionsResponse {}
1113
1114/// There is no detailed description.
1115///
1116/// # Activities
1117///
1118/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1119/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1120///
1121/// * [locations get projects](ProjectLocationGetCall) (response)
1122#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1123#[serde_with::serde_as]
1124#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1125pub struct GoogleCloudMlV1__Location {
1126    /// Capabilities available in the location.
1127    pub capabilities: Option<Vec<GoogleCloudMlV1__Capability>>,
1128    /// no description provided
1129    pub name: Option<String>,
1130}
1131
1132impl common::ResponseResult for GoogleCloudMlV1__Location {}
1133
1134/// Options for manually scaling a model.
1135///
1136/// This type is not used in any activity, and only used as *part* of another schema.
1137///
1138#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1139#[serde_with::serde_as]
1140#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1141pub struct GoogleCloudMlV1__ManualScaling {
1142    /// The number of nodes to allocate for this model. These nodes are always up, starting from the time the model is deployed, so the cost of operating this model will be proportional to `nodes` * number of hours since last billing cycle plus the cost for each prediction performed.
1143    pub nodes: Option<i32>,
1144}
1145
1146impl common::Part for GoogleCloudMlV1__ManualScaling {}
1147
1148/// A message representing a measurement.
1149///
1150/// This type is not used in any activity, and only used as *part* of another schema.
1151///
1152#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1153#[serde_with::serde_as]
1154#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1155pub struct GoogleCloudMlV1__Measurement {
1156    /// Output only. Time that the trial has been running at the point of this measurement.
1157    #[serde(rename = "elapsedTime")]
1158    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1159    pub elapsed_time: Option<chrono::Duration>,
1160    /// Provides a list of metrics that act as inputs into the objective function.
1161    pub metrics: Option<Vec<GoogleCloudMlV1_Measurement_Metric>>,
1162    /// The number of steps a machine learning model has been trained for. Must be non-negative.
1163    #[serde(rename = "stepCount")]
1164    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1165    pub step_count: Option<i64>,
1166}
1167
1168impl common::Part for GoogleCloudMlV1__Measurement {}
1169
1170/// MetricSpec contains the specifications to use to calculate the desired nodes count when autoscaling is enabled.
1171///
1172/// This type is not used in any activity, and only used as *part* of another schema.
1173///
1174#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1175#[serde_with::serde_as]
1176#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1177pub struct GoogleCloudMlV1__MetricSpec {
1178    /// metric name.
1179    pub name: Option<String>,
1180    /// Target specifies the target value for the given metric; once real metric deviates from the threshold by a certain percentage, the node count changes.
1181    pub target: Option<i32>,
1182}
1183
1184impl common::Part for GoogleCloudMlV1__MetricSpec {}
1185
1186/// Represents a machine learning solution. A model can have multiple versions, each of which is a deployed, trained model ready to receive prediction requests. The model itself is just a container.
1187///
1188/// # Activities
1189///
1190/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1191/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1192///
1193/// * [models create projects](ProjectModelCreateCall) (request|response)
1194/// * [models get projects](ProjectModelGetCall) (response)
1195/// * [models patch projects](ProjectModelPatchCall) (request)
1196#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1197#[serde_with::serde_as]
1198#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1199pub struct GoogleCloudMlV1__Model {
1200    /// Output only. The default version of the model. This version will be used to handle prediction requests that do not specify a version. You can change the default version by calling projects.models.versions.setDefault.
1201    #[serde(rename = "defaultVersion")]
1202    pub default_version: Option<GoogleCloudMlV1__Version>,
1203    /// Optional. The description specified for the model when it was created.
1204    pub description: Option<String>,
1205    /// `etag` is used for optimistic concurrency control as a way to help prevent simultaneous updates of a model from overwriting each other. It is strongly suggested that systems make use of the `etag` in the read-modify-write cycle to perform model updates in order to avoid race conditions: An `etag` is returned in the response to `GetModel`, and systems are expected to put that etag in the request to `UpdateModel` to ensure that their change will be applied to the model as intended.
1206    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1207    pub etag: Option<Vec<u8>>,
1208    /// Optional. One or more labels that you can add, to organize your models. Each label is a key-value pair, where both the key and the value are arbitrary strings that you supply. For more information, see the documentation on using labels. Note that this field is not updatable for mls1* models.
1209    pub labels: Option<HashMap<String, String>>,
1210    /// Required. The name specified for the model when it was created. The model name must be unique within the project it is created in.
1211    pub name: Option<String>,
1212    /// Optional. If true, online prediction nodes send `stderr` and `stdout` streams to Cloud Logging. These can be more verbose than the standard access logs (see `onlinePredictionLogging`) and can incur higher cost. However, they are helpful for debugging. Note that [logs may incur a cost](https://cloud.google.com/stackdriver/pricing), especially if your project receives prediction requests at a high QPS. Estimate your costs before enabling this option. Default is false.
1213    #[serde(rename = "onlinePredictionConsoleLogging")]
1214    pub online_prediction_console_logging: Option<bool>,
1215    /// Optional. If true, online prediction access logs are sent to Cloud Logging. These logs are like standard server access logs, containing information like timestamp and latency for each request. Note that [logs may incur a cost](https://cloud.google.com/stackdriver/pricing), especially if your project receives prediction requests at a high queries per second rate (QPS). Estimate your costs before enabling this option. Default is false.
1216    #[serde(rename = "onlinePredictionLogging")]
1217    pub online_prediction_logging: Option<bool>,
1218    /// Optional. The list of regions where the model is going to be deployed. Only one region per model is supported. Defaults to 'us-central1' if nothing is set. See the available regions for AI Platform services. Note: * No matter where a model is deployed, it can always be accessed by users from anywhere, both for online and batch prediction. * The region for a batch prediction job is set by the region field when submitting the batch prediction job and does not take its value from this field.
1219    pub regions: Option<Vec<String>>,
1220}
1221
1222impl common::RequestValue for GoogleCloudMlV1__Model {}
1223impl common::ResponseResult for GoogleCloudMlV1__Model {}
1224
1225/// Represents a single hyperparameter to optimize.
1226///
1227/// This type is not used in any activity, and only used as *part* of another schema.
1228///
1229#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1230#[serde_with::serde_as]
1231#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1232pub struct GoogleCloudMlV1__ParameterSpec {
1233    /// Required if type is `CATEGORICAL`. The list of possible categories.
1234    #[serde(rename = "categoricalValues")]
1235    pub categorical_values: Option<Vec<String>>,
1236    /// Required if type is `DISCRETE`. A list of feasible points. The list should be in strictly increasing order. For instance, this parameter might have possible settings of 1.5, 2.5, and 4.0. This list should not contain more than 1,000 values.
1237    #[serde(rename = "discreteValues")]
1238    pub discrete_values: Option<Vec<f64>>,
1239    /// Required if type is `DOUBLE` or `INTEGER`. This field should be unset if type is `CATEGORICAL`. This value should be integers if type is `INTEGER`.
1240    #[serde(rename = "maxValue")]
1241    pub max_value: Option<f64>,
1242    /// Required if type is `DOUBLE` or `INTEGER`. This field should be unset if type is `CATEGORICAL`. This value should be integers if type is INTEGER.
1243    #[serde(rename = "minValue")]
1244    pub min_value: Option<f64>,
1245    /// Required. The parameter name must be unique amongst all ParameterConfigs in a HyperparameterSpec message. E.g., "learning_rate".
1246    #[serde(rename = "parameterName")]
1247    pub parameter_name: Option<String>,
1248    /// Optional. How the parameter should be scaled to the hypercube. Leave unset for categorical parameters. Some kind of scaling is strongly recommended for real or integral parameters (e.g., `UNIT_LINEAR_SCALE`).
1249    #[serde(rename = "scaleType")]
1250    pub scale_type: Option<String>,
1251    /// Required. The type of the parameter.
1252    #[serde(rename = "type")]
1253    pub type_: Option<String>,
1254}
1255
1256impl common::Part for GoogleCloudMlV1__ParameterSpec {}
1257
1258/// Request for predictions to be issued against a trained model.
1259///
1260/// # Activities
1261///
1262/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1263/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1264///
1265/// * [predict projects](ProjectPredictCall) (request)
1266#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1267#[serde_with::serde_as]
1268#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1269pub struct GoogleCloudMlV1__PredictRequest {
1270    /// Required. The prediction request body. Refer to the [request body details section](#request-body-details) for more information on how to structure your request.
1271    #[serde(rename = "httpBody")]
1272    pub http_body: Option<GoogleApi__HttpBody>,
1273}
1274
1275impl common::RequestValue for GoogleCloudMlV1__PredictRequest {}
1276
1277/// Represents input parameters for a prediction job.
1278///
1279/// This type is not used in any activity, and only used as *part* of another schema.
1280///
1281#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1282#[serde_with::serde_as]
1283#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1284pub struct GoogleCloudMlV1__PredictionInput {
1285    /// Optional. Number of records per batch, defaults to 64. The service will buffer batch_size number of records in memory before invoking one Tensorflow prediction call internally. So take the record size and memory available into consideration when setting this parameter.
1286    #[serde(rename = "batchSize")]
1287    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1288    pub batch_size: Option<i64>,
1289    /// Required. The format of the input data files.
1290    #[serde(rename = "dataFormat")]
1291    pub data_format: Option<String>,
1292    /// Required. The Cloud Storage location of the input data files. May contain wildcards.
1293    #[serde(rename = "inputPaths")]
1294    pub input_paths: Option<Vec<String>>,
1295    /// Optional. The maximum number of workers to be used for parallel processing. Defaults to 10 if not specified.
1296    #[serde(rename = "maxWorkerCount")]
1297    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1298    pub max_worker_count: Option<i64>,
1299    /// Use this field if you want to use the default version for the specified model. The string must use the following format: `"projects/YOUR_PROJECT/models/YOUR_MODEL"`
1300    #[serde(rename = "modelName")]
1301    pub model_name: Option<String>,
1302    /// Optional. Format of the output data files, defaults to JSON.
1303    #[serde(rename = "outputDataFormat")]
1304    pub output_data_format: Option<String>,
1305    /// Required. The output Google Cloud Storage location.
1306    #[serde(rename = "outputPath")]
1307    pub output_path: Option<String>,
1308    /// Required. The Google Compute Engine region to run the prediction job in. See the available regions for AI Platform services.
1309    pub region: Option<String>,
1310    /// Optional. The AI Platform runtime version to use for this batch prediction. If not set, AI Platform will pick the runtime version used during the CreateVersion request for this model version, or choose the latest stable version when model version information is not available such as when the model is specified by uri.
1311    #[serde(rename = "runtimeVersion")]
1312    pub runtime_version: Option<String>,
1313    /// Optional. The name of the signature defined in the SavedModel to use for this job. Please refer to [SavedModel](https://tensorflow.github.io/serving/serving_basic.html) for information about how to use signatures. Defaults to [DEFAULT_SERVING_SIGNATURE_DEF_KEY](https://www.tensorflow.org/api_docs/python/tf/saved_model/signature_constants) , which is "serving_default".
1314    #[serde(rename = "signatureName")]
1315    pub signature_name: Option<String>,
1316    /// Use this field if you want to specify a Google Cloud Storage path for the model to use.
1317    pub uri: Option<String>,
1318    /// Use this field if you want to specify a version of the model to use. The string is formatted the same way as `model_version`, with the addition of the version information: `"projects/YOUR_PROJECT/models/YOUR_MODEL/versions/YOUR_VERSION"`
1319    #[serde(rename = "versionName")]
1320    pub version_name: Option<String>,
1321}
1322
1323impl common::Part for GoogleCloudMlV1__PredictionInput {}
1324
1325/// Represents results of a prediction job.
1326///
1327/// This type is not used in any activity, and only used as *part* of another schema.
1328///
1329#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1330#[serde_with::serde_as]
1331#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1332pub struct GoogleCloudMlV1__PredictionOutput {
1333    /// The number of data instances which resulted in errors.
1334    #[serde(rename = "errorCount")]
1335    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1336    pub error_count: Option<i64>,
1337    /// Node hours used by the batch prediction job.
1338    #[serde(rename = "nodeHours")]
1339    pub node_hours: Option<f64>,
1340    /// The output Google Cloud Storage location provided at the job creation time.
1341    #[serde(rename = "outputPath")]
1342    pub output_path: Option<String>,
1343    /// The number of generated predictions.
1344    #[serde(rename = "predictionCount")]
1345    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1346    pub prediction_count: Option<i64>,
1347}
1348
1349impl common::Part for GoogleCloudMlV1__PredictionOutput {}
1350
1351/// Represents the configuration for a replica in a cluster.
1352///
1353/// This type is not used in any activity, and only used as *part* of another schema.
1354///
1355#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1356#[serde_with::serde_as]
1357#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1358pub struct GoogleCloudMlV1__ReplicaConfig {
1359    /// Represents the type and number of accelerators used by the replica. [Learn about restrictions on accelerator configurations for training.](https://cloud.google.com/ai-platform/training/docs/using-gpus#compute-engine-machine-types-with-gpu)
1360    #[serde(rename = "acceleratorConfig")]
1361    pub accelerator_config: Option<GoogleCloudMlV1__AcceleratorConfig>,
1362    /// Arguments to the entrypoint command. The following rules apply for container_command and container_args: - If you do not supply command or args: The defaults defined in the Docker image are used. - If you supply a command but no args: The default EntryPoint and the default Cmd defined in the Docker image are ignored. Your command is run without any arguments. - If you supply only args: The default Entrypoint defined in the Docker image is run with the args that you supplied. - If you supply a command and args: The default Entrypoint and the default Cmd defined in the Docker image are ignored. Your command is run with your args. It cannot be set if custom container image is not provided. Note that this field and [TrainingInput.args] are mutually exclusive, i.e., both cannot be set at the same time.
1363    #[serde(rename = "containerArgs")]
1364    pub container_args: Option<Vec<String>>,
1365    /// The command with which the replica's custom container is run. If provided, it will override default ENTRYPOINT of the docker image. If not provided, the docker image's ENTRYPOINT is used. It cannot be set if custom container image is not provided. Note that this field and [TrainingInput.args] are mutually exclusive, i.e., both cannot be set at the same time.
1366    #[serde(rename = "containerCommand")]
1367    pub container_command: Option<Vec<String>>,
1368    /// Represents the configuration of disk options.
1369    #[serde(rename = "diskConfig")]
1370    pub disk_config: Option<GoogleCloudMlV1__DiskConfig>,
1371    /// The Docker image to run on the replica. This image must be in Container Registry. Learn more about [configuring custom containers](https://cloud.google.com/ai-platform/training/docs/distributed-training-containers).
1372    #[serde(rename = "imageUri")]
1373    pub image_uri: Option<String>,
1374    /// The AI Platform runtime version that includes a TensorFlow version matching the one used in the custom container. This field is required if the replica is a TPU worker that uses a custom container. Otherwise, do not specify this field. This must be a [runtime version that currently supports training with TPUs](https://cloud.google.com/ml-engine/docs/tensorflow/runtime-version-list#tpu-support). Note that the version of TensorFlow included in a runtime version may differ from the numbering of the runtime version itself, because it may have a different [patch version](https://www.tensorflow.org/guide/version_compat#semantic_versioning_20). In this field, you must specify the runtime version (TensorFlow minor version). For example, if your custom container runs TensorFlow `1.x.y`, specify `1.x`.
1375    #[serde(rename = "tpuTfVersion")]
1376    pub tpu_tf_version: Option<String>,
1377}
1378
1379impl common::Part for GoogleCloudMlV1__ReplicaConfig {}
1380
1381/// Configuration for logging request-response pairs to a BigQuery table. Online prediction requests to a model version and the responses to these requests are converted to raw strings and saved to the specified BigQuery table. Logging is constrained by [BigQuery quotas and limits](https://cloud.google.com/bigquery/quotas). If your project exceeds BigQuery quotas or limits, AI Platform Prediction does not log request-response pairs, but it continues to serve predictions. If you are using [continuous evaluation](https://cloud.google.com/ml-engine/docs/continuous-evaluation/), you do not need to specify this configuration manually. Setting up continuous evaluation automatically enables logging of request-response pairs.
1382///
1383/// This type is not used in any activity, and only used as *part* of another schema.
1384#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1385#[serde_with::serde_as]
1386#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1387pub struct GoogleCloudMlV1__RequestLoggingConfig {
1388    /// Required. Fully qualified BigQuery table name in the following format: “ project_id.dataset_name.table_name“ The specified table must already exist, and the “Cloud ML Service Agent” for your project must have permission to write to it. The table must have the following [schema](https://cloud.google.com/bigquery/docs/schemas): Field name Type Mode model STRING REQUIRED model_version STRING REQUIRED time TIMESTAMP REQUIRED raw_data STRING REQUIRED raw_prediction STRING NULLABLE groundtruth STRING NULLABLE
1389    #[serde(rename = "bigqueryTableName")]
1390    pub bigquery_table_name: Option<String>,
1391    /// Percentage of requests to be logged, expressed as a fraction from 0 to 1. For example, if you want to log 10% of requests, enter `0.1`. The sampling window is the lifetime of the model version. Defaults to 0.
1392    #[serde(rename = "samplingPercentage")]
1393    pub sampling_percentage: Option<f64>,
1394}
1395
1396impl common::Part for GoogleCloudMlV1__RequestLoggingConfig {}
1397
1398/// Specifies HTTP paths served by a custom container. AI Platform Prediction sends requests to these paths on the container; the custom container must run an HTTP server that responds to these requests with appropriate responses. Read [Custom container requirements](https://cloud.google.com/ai-platform/prediction/docs/custom-container-requirements) for details on how to create your container image to meet these requirements.
1399///
1400/// This type is not used in any activity, and only used as *part* of another schema.
1401#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1402#[serde_with::serde_as]
1403#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1404pub struct GoogleCloudMlV1__RouteMap {
1405    /// HTTP path on the container to send health checkss to. AI Platform Prediction intermittently sends GET requests to this path on the container’s IP address and port to check that the container is healthy. Read more about [health checks](https://cloud.google.com/ai-platform/prediction/docs/custom-container-requirements#checks). For example, if you set this field to `/bar`, then AI Platform Prediction intermittently sends a GET request to the `/bar` path on the port of your container specified by the first value of Version.container.ports. If you don’t specify this field, it defaults to the following value: /v1/models/ MODEL/versions/VERSION The placeholders in this value are replaced as follows: * MODEL: The name of the parent Model. This does not include the “projects/PROJECT_ID/models/” prefix that the API returns in output; it is the bare model name, as provided to projects.models.create. * VERSION: The name of the model version. This does not include the “projects/PROJECT_ID /models/MODEL/versions/” prefix that the API returns in output; it is the bare version name, as provided to projects.models.versions.create.
1406    pub health: Option<String>,
1407    /// HTTP path on the container to send prediction requests to. AI Platform Prediction forwards requests sent using projects.predict to this path on the container's IP address and port. AI Platform Prediction then returns the container's response in the API response. For example, if you set this field to `/foo`, then when AI Platform Prediction receives a prediction request, it forwards the request body in a POST request to the `/foo` path on the port of your container specified by the first value of Version.container.ports. If you don't specify this field, it defaults to the following value: /v1/models/MODEL/versions/VERSION:predict The placeholders in this value are replaced as follows: * MODEL: The name of the parent Model. This does not include the "projects/PROJECT_ID/models/" prefix that the API returns in output; it is the bare model name, as provided to projects.models.create. * VERSION: The name of the model version. This does not include the "projects/PROJECT_ID/models/MODEL/versions/" prefix that the API returns in output; it is the bare version name, as provided to projects.models.versions.create.
1408    pub predict: Option<String>,
1409}
1410
1411impl common::Part for GoogleCloudMlV1__RouteMap {}
1412
1413/// An attribution method that approximates Shapley values for features that contribute to the label being predicted. A sampling strategy is used to approximate the value rather than considering all subsets of features.
1414///
1415/// This type is not used in any activity, and only used as *part* of another schema.
1416///
1417#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1418#[serde_with::serde_as]
1419#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1420pub struct GoogleCloudMlV1__SampledShapleyAttribution {
1421    /// The number of feature permutations to consider when approximating the Shapley values.
1422    #[serde(rename = "numPaths")]
1423    pub num_paths: Option<i32>,
1424}
1425
1426impl common::Part for GoogleCloudMlV1__SampledShapleyAttribution {}
1427
1428/// All parameters related to scheduling of training jobs.
1429///
1430/// This type is not used in any activity, and only used as *part* of another schema.
1431///
1432#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1433#[serde_with::serde_as]
1434#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1435pub struct GoogleCloudMlV1__Scheduling {
1436    /// Optional. The maximum job running time, expressed in seconds. The field can contain up to nine fractional digits, terminated by `s`. If not specified, this field defaults to `604800s` (seven days). If the training job is still running after this duration, AI Platform Training cancels it. The duration is measured from when the job enters the `RUNNING` state; therefore it does not overlap with the duration limited by Scheduling.max_wait_time. For example, if you want to ensure your job runs for no more than 2 hours, set this field to `7200s` (2 hours * 60 minutes / hour * 60 seconds / minute). If you submit your training job using the `gcloud` tool, you can [specify this field in a `config.yaml` file](https://cloud.google.com/ai-platform/training/docs/training-jobs#formatting_your_configuration_parameters). For example: `yaml trainingInput: scheduling: maxRunningTime: 7200s `
1437    #[serde(rename = "maxRunningTime")]
1438    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1439    pub max_running_time: Option<chrono::Duration>,
1440    /// Optional. The maximum job wait time, expressed in seconds. The field can contain up to nine fractional digits, terminated by `s`. If not specified, there is no limit to the wait time. The minimum for this field is `1800s` (30 minutes). If the training job has not entered the `RUNNING` state after this duration, AI Platform Training cancels it. After the job begins running, it can no longer be cancelled due to the maximum wait time. Therefore the duration limited by this field does not overlap with the duration limited by Scheduling.max_running_time. For example, if the job temporarily stops running and retries due to a [VM restart](https://cloud.google.com/ai-platform/training/docs/overview#restarts), this cannot lead to a maximum wait time cancellation. However, independently of this constraint, AI Platform Training might stop a job if there are too many retries due to exhausted resources in a region. The following example describes how you might use this field: To cancel your job if it doesn’t start running within 1 hour, set this field to `3600s` (1 hour * 60 minutes / hour * 60 seconds / minute). If the job is still in the `QUEUED` or `PREPARING` state after an hour of waiting, AI Platform Training cancels the job. If you submit your training job using the `gcloud` tool, you can [specify this field in a `config.yaml` file](https://cloud.google.com/ai-platform/training/docs/training-jobs#formatting_your_configuration_parameters). For example: `yaml trainingInput: scheduling: maxWaitTime: 3600s `
1441    #[serde(rename = "maxWaitTime")]
1442    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1443    pub max_wait_time: Option<chrono::Duration>,
1444    /// Optional. Job scheduling will be based on this priority, which in the range [0, 1000]. The bigger the number, the higher the priority. Default to 0 if not set. If there are multiple jobs requesting same type of accelerators, the high priority job will be scheduled prior to ones with low priority.
1445    pub priority: Option<i32>,
1446}
1447
1448impl common::Part for GoogleCloudMlV1__Scheduling {}
1449
1450/// Request message for the SetDefaultVersion request.
1451///
1452/// # Activities
1453///
1454/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1455/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1456///
1457/// * [models versions set default projects](ProjectModelVersionSetDefaultCall) (request)
1458#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1459#[serde_with::serde_as]
1460#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1461pub struct GoogleCloudMlV1__SetDefaultVersionRequest {
1462    _never_set: Option<bool>,
1463}
1464
1465impl common::RequestValue for GoogleCloudMlV1__SetDefaultVersionRequest {}
1466
1467/// There is no detailed description.
1468///
1469/// # Activities
1470///
1471/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1472/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1473///
1474/// * [locations studies trials stop projects](ProjectLocationStudyTrialStopCall) (request)
1475#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1476#[serde_with::serde_as]
1477#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1478pub struct GoogleCloudMlV1__StopTrialRequest {
1479    _never_set: Option<bool>,
1480}
1481
1482impl common::RequestValue for GoogleCloudMlV1__StopTrialRequest {}
1483
1484/// A message representing a Study.
1485///
1486/// # Activities
1487///
1488/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1489/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1490///
1491/// * [locations studies create projects](ProjectLocationStudyCreateCall) (request|response)
1492/// * [locations studies get projects](ProjectLocationStudyGetCall) (response)
1493#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1494#[serde_with::serde_as]
1495#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1496pub struct GoogleCloudMlV1__Study {
1497    /// Output only. Time at which the study was created.
1498    #[serde(rename = "createTime")]
1499    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1500    /// Output only. A human readable reason why the Study is inactive. This should be empty if a study is ACTIVE or COMPLETED.
1501    #[serde(rename = "inactiveReason")]
1502    pub inactive_reason: Option<String>,
1503    /// Output only. The name of a study.
1504    pub name: Option<String>,
1505    /// Output only. The detailed state of a study.
1506    pub state: Option<String>,
1507    /// Required. Configuration of the study.
1508    #[serde(rename = "studyConfig")]
1509    pub study_config: Option<GoogleCloudMlV1__StudyConfig>,
1510}
1511
1512impl common::RequestValue for GoogleCloudMlV1__Study {}
1513impl common::ResponseResult for GoogleCloudMlV1__Study {}
1514
1515/// Represents configuration of a study.
1516///
1517/// This type is not used in any activity, and only used as *part* of another schema.
1518///
1519#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1520#[serde_with::serde_as]
1521#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1522pub struct GoogleCloudMlV1__StudyConfig {
1523    /// The search algorithm specified for the study.
1524    pub algorithm: Option<String>,
1525    /// Configuration for automated stopping of unpromising Trials.
1526    #[serde(rename = "automatedStoppingConfig")]
1527    pub automated_stopping_config: Option<GoogleCloudMlV1__AutomatedStoppingConfig>,
1528    /// Metric specs for the study.
1529    pub metrics: Option<Vec<GoogleCloudMlV1_StudyConfig_MetricSpec>>,
1530    /// Required. The set of parameters to tune.
1531    pub parameters: Option<Vec<GoogleCloudMlV1_StudyConfig_ParameterSpec>>,
1532}
1533
1534impl common::Part for GoogleCloudMlV1__StudyConfig {}
1535
1536/// The request message for the SuggestTrial service method.
1537///
1538/// # Activities
1539///
1540/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1541/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1542///
1543/// * [locations studies trials suggest projects](ProjectLocationStudyTrialSuggestCall) (request)
1544#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1545#[serde_with::serde_as]
1546#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1547pub struct GoogleCloudMlV1__SuggestTrialsRequest {
1548    /// Required. The identifier of the client that is requesting the suggestion. If multiple SuggestTrialsRequests have the same `client_id`, the service will return the identical suggested trial if the trial is pending, and provide a new trial if the last suggested trial was completed.
1549    #[serde(rename = "clientId")]
1550    pub client_id: Option<String>,
1551    /// Required. The number of suggestions requested.
1552    #[serde(rename = "suggestionCount")]
1553    pub suggestion_count: Option<i32>,
1554}
1555
1556impl common::RequestValue for GoogleCloudMlV1__SuggestTrialsRequest {}
1557
1558/// Represents input parameters for a training job. When using the gcloud command to submit your training job, you can specify the input parameters as command-line arguments and/or in a YAML configuration file referenced from the –config command-line argument. For details, see the guide to [submitting a training job](https://cloud.google.com/ai-platform/training/docs/training-jobs).
1559///
1560/// This type is not used in any activity, and only used as *part* of another schema.
1561#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1562#[serde_with::serde_as]
1563#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1564pub struct GoogleCloudMlV1__TrainingInput {
1565    /// Optional. Command-line arguments passed to the training application when it starts. If your job uses a custom container, then the arguments are passed to the container's `ENTRYPOINT` command.
1566    pub args: Option<Vec<String>>,
1567    /// Optional. Whether you want AI Platform Training to enable [interactive shell access](https://cloud.google.com/ai-platform/training/docs/monitor-debug-interactive-shell) to training containers. If set to `true`, you can access interactive shells at the URIs given by TrainingOutput.web_access_uris or HyperparameterOutput.web_access_uris (within TrainingOutput.trials).
1568    #[serde(rename = "enableWebAccess")]
1569    pub enable_web_access: Option<bool>,
1570    /// Optional. Options for using customer-managed encryption keys (CMEK) to protect resources created by a training job, instead of using Google’s default encryption. If this is set, then all resources created by the training job will be encrypted with the customer-managed encryption key that you specify. [Learn how and when to use CMEK with AI Platform Training](https://cloud.google.com/ai-platform/training/docs/cmek).
1571    #[serde(rename = "encryptionConfig")]
1572    pub encryption_config: Option<GoogleCloudMlV1__EncryptionConfig>,
1573    /// Optional. The configuration for evaluators. You should only set `evaluatorConfig.acceleratorConfig` if `evaluatorType` is set to a Compute Engine machine type. [Learn about restrictions on accelerator configurations for training.](https://cloud.google.com/ai-platform/training/docs/using-gpus#compute-engine-machine-types-with-gpu) Set `evaluatorConfig.imageUri` only if you build a custom image for your evaluator. If `evaluatorConfig.imageUri` has not been set, AI Platform uses the value of `masterConfig.imageUri`. Learn more about [configuring custom containers](https://cloud.google.com/ai-platform/training/docs/distributed-training-containers).
1574    #[serde(rename = "evaluatorConfig")]
1575    pub evaluator_config: Option<GoogleCloudMlV1__ReplicaConfig>,
1576    /// Optional. The number of evaluator replicas to use for the training job. Each replica in the cluster will be of the type specified in `evaluator_type`. This value can only be used when `scale_tier` is set to `CUSTOM`. If you set this value, you must also set `evaluator_type`. The default value is zero.
1577    #[serde(rename = "evaluatorCount")]
1578    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1579    pub evaluator_count: Option<i64>,
1580    /// Optional. Specifies the type of virtual machine to use for your training job's evaluator nodes. The supported values are the same as those described in the entry for `masterType`. This value must be consistent with the category of machine type that `masterType` uses. In other words, both must be Compute Engine machine types or both must be legacy machine types. This value must be present when `scaleTier` is set to `CUSTOM` and `evaluatorCount` is greater than zero.
1581    #[serde(rename = "evaluatorType")]
1582    pub evaluator_type: Option<String>,
1583    /// Optional. The set of Hyperparameters to tune.
1584    pub hyperparameters: Option<GoogleCloudMlV1__HyperparameterSpec>,
1585    /// Optional. A Google Cloud Storage path in which to store training outputs and other data needed for training. This path is passed to your TensorFlow program as the '--job-dir' command-line argument. The benefit of specifying this field is that Cloud ML validates the path for use in training.
1586    #[serde(rename = "jobDir")]
1587    pub job_dir: Option<String>,
1588    /// Optional. The configuration for your master worker. You should only set `masterConfig.acceleratorConfig` if `masterType` is set to a Compute Engine machine type. Learn about [restrictions on accelerator configurations for training.](https://cloud.google.com/ai-platform/training/docs/using-gpus#compute-engine-machine-types-with-gpu) Set `masterConfig.imageUri` only if you build a custom image. Only one of `masterConfig.imageUri` and `runtimeVersion` should be set. Learn more about [configuring custom containers](https://cloud.google.com/ai-platform/training/docs/distributed-training-containers).
1589    #[serde(rename = "masterConfig")]
1590    pub master_config: Option<GoogleCloudMlV1__ReplicaConfig>,
1591    /// Optional. Specifies the type of virtual machine to use for your training job’s master worker. You must specify this field when `scaleTier` is set to `CUSTOM`. You can use certain Compute Engine machine types directly in this field. See the [list of compatible Compute Engine machine types](https://cloud.google.com/ai-platform/training/docs/machine-types#compute-engine-machine-types). Alternatively, you can use the certain legacy machine types in this field. See the [list of legacy machine types](https://cloud.google.com/ai-platform/training/docs/machine-types#legacy-machine-types). Finally, if you want to use a TPU for training, specify `cloud_tpu` in this field. Learn more about the [special configuration options for training with TPUs](https://cloud.google.com/ai-platform/training/docs/using-tpus#configuring_a_custom_tpu_machine).
1592    #[serde(rename = "masterType")]
1593    pub master_type: Option<String>,
1594    /// Optional. The full name of the [Compute Engine network](https://cloud.google.com/vpc/docs/vpc) to which the Job is peered. For example, `projects/12345/global/networks/myVPC`. The format of this field is `projects/{project}/global/networks/{network}`, where {project} is a project number (like `12345`) and {network} is network name. Private services access must already be configured for the network. If left unspecified, the Job is not peered with any network. [Learn about using VPC Network Peering.](https://cloud.google.com/ai-platform/training/docs/vpc-peering).
1595    pub network: Option<String>,
1596    /// Required. The Google Cloud Storage location of the packages with the training program and any additional dependencies. The maximum number of package URIs is 100.
1597    #[serde(rename = "packageUris")]
1598    pub package_uris: Option<Vec<String>>,
1599    /// Optional. The configuration for parameter servers. You should only set `parameterServerConfig.acceleratorConfig` if `parameterServerType` is set to a Compute Engine machine type. [Learn about restrictions on accelerator configurations for training.](https://cloud.google.com/ai-platform/training/docs/using-gpus#compute-engine-machine-types-with-gpu) Set `parameterServerConfig.imageUri` only if you build a custom image for your parameter server. If `parameterServerConfig.imageUri` has not been set, AI Platform uses the value of `masterConfig.imageUri`. Learn more about [configuring custom containers](https://cloud.google.com/ai-platform/training/docs/distributed-training-containers).
1600    #[serde(rename = "parameterServerConfig")]
1601    pub parameter_server_config: Option<GoogleCloudMlV1__ReplicaConfig>,
1602    /// Optional. The number of parameter server replicas to use for the training job. Each replica in the cluster will be of the type specified in `parameter_server_type`. This value can only be used when `scale_tier` is set to `CUSTOM`. If you set this value, you must also set `parameter_server_type`. The default value is zero.
1603    #[serde(rename = "parameterServerCount")]
1604    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1605    pub parameter_server_count: Option<i64>,
1606    /// Optional. Specifies the type of virtual machine to use for your training job's parameter server. The supported values are the same as those described in the entry for `master_type`. This value must be consistent with the category of machine type that `masterType` uses. In other words, both must be Compute Engine machine types or both must be legacy machine types. This value must be present when `scaleTier` is set to `CUSTOM` and `parameter_server_count` is greater than zero.
1607    #[serde(rename = "parameterServerType")]
1608    pub parameter_server_type: Option<String>,
1609    /// Required. The Python module name to run after installing the packages.
1610    #[serde(rename = "pythonModule")]
1611    pub python_module: Option<String>,
1612    /// Optional. The version of Python used in training. You must either specify this field or specify `masterConfig.imageUri`. The following Python versions are available: * Python ‘3.7’ is available when `runtime_version` is set to ‘1.15’ or later. * Python ‘3.5’ is available when `runtime_version` is set to a version from ‘1.4’ to ‘1.14’. * Python ‘2.7’ is available when `runtime_version` is set to ‘1.15’ or earlier. Read more about the Python versions available for [each runtime version](https://cloud.google.com/ml-engine/docs/runtime-version-list).
1613    #[serde(rename = "pythonVersion")]
1614    pub python_version: Option<String>,
1615    /// Required. The region to run the training job in. See the [available regions](https://cloud.google.com/ai-platform/training/docs/regions) for AI Platform Training.
1616    pub region: Option<String>,
1617    /// Optional. The AI Platform runtime version to use for training. You must either specify this field or specify `masterConfig.imageUri`. For more information, see the [runtime version list](https://cloud.google.com/ai-platform/training/docs/runtime-version-list) and learn [how to manage runtime versions](https://cloud.google.com/ai-platform/training/docs/versioning).
1618    #[serde(rename = "runtimeVersion")]
1619    pub runtime_version: Option<String>,
1620    /// Required. Specifies the machine types, the number of replicas for workers and parameter servers.
1621    #[serde(rename = "scaleTier")]
1622    pub scale_tier: Option<String>,
1623    /// Optional. Scheduling options for a training job.
1624    pub scheduling: Option<GoogleCloudMlV1__Scheduling>,
1625    /// Optional. The email address of a service account to use when running the training appplication. You must have the `iam.serviceAccounts.actAs` permission for the specified service account. In addition, the AI Platform Training Google-managed service account must have the `roles/iam.serviceAccountAdmin` role for the specified service account. [Learn more about configuring a service account.](https://cloud.google.com/ai-platform/training/docs/custom-service-account) If not specified, the AI Platform Training Google-managed service account is used by default.
1626    #[serde(rename = "serviceAccount")]
1627    pub service_account: Option<String>,
1628    /// Optional. Use `chief` instead of `master` in the `TF_CONFIG` environment variable when training with a custom container. Defaults to `false`. [Learn more about this field.](https://cloud.google.com/ai-platform/training/docs/distributed-training-details#chief-versus-master) This field has no effect for training jobs that don’t use a custom container.
1629    #[serde(rename = "useChiefInTfConfig")]
1630    pub use_chief_in_tf_config: Option<bool>,
1631    /// Optional. The configuration for workers. You should only set `workerConfig.acceleratorConfig` if `workerType` is set to a Compute Engine machine type. [Learn about restrictions on accelerator configurations for training.](https://cloud.google.com/ai-platform/training/docs/using-gpus#compute-engine-machine-types-with-gpu) Set `workerConfig.imageUri` only if you build a custom image for your worker. If `workerConfig.imageUri` has not been set, AI Platform uses the value of `masterConfig.imageUri`. Learn more about [configuring custom containers](https://cloud.google.com/ai-platform/training/docs/distributed-training-containers).
1632    #[serde(rename = "workerConfig")]
1633    pub worker_config: Option<GoogleCloudMlV1__ReplicaConfig>,
1634    /// Optional. The number of worker replicas to use for the training job. Each replica in the cluster will be of the type specified in `worker_type`. This value can only be used when `scale_tier` is set to `CUSTOM`. If you set this value, you must also set `worker_type`. The default value is zero.
1635    #[serde(rename = "workerCount")]
1636    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1637    pub worker_count: Option<i64>,
1638    /// Optional. Specifies the type of virtual machine to use for your training job’s worker nodes. The supported values are the same as those described in the entry for `masterType`. This value must be consistent with the category of machine type that `masterType` uses. In other words, both must be Compute Engine machine types or both must be legacy machine types. If you use `cloud_tpu` for this value, see special instructions for [configuring a custom TPU machine](https://cloud.google.com/ml-engine/docs/tensorflow/using-tpus#configuring_a_custom_tpu_machine). This value must be present when `scaleTier` is set to `CUSTOM` and `workerCount` is greater than zero.
1639    #[serde(rename = "workerType")]
1640    pub worker_type: Option<String>,
1641}
1642
1643impl common::Part for GoogleCloudMlV1__TrainingInput {}
1644
1645/// Represents results of a training job. Output only.
1646///
1647/// This type is not used in any activity, and only used as *part* of another schema.
1648///
1649#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1650#[serde_with::serde_as]
1651#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1652pub struct GoogleCloudMlV1__TrainingOutput {
1653    /// Details related to built-in algorithms jobs. Only set for built-in algorithms jobs.
1654    #[serde(rename = "builtInAlgorithmOutput")]
1655    pub built_in_algorithm_output: Option<GoogleCloudMlV1__BuiltInAlgorithmOutput>,
1656    /// The number of hyperparameter tuning trials that completed successfully. Only set for hyperparameter tuning jobs.
1657    #[serde(rename = "completedTrialCount")]
1658    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1659    pub completed_trial_count: Option<i64>,
1660    /// The amount of ML units consumed by the job.
1661    #[serde(rename = "consumedMLUnits")]
1662    pub consumed_ml_units: Option<f64>,
1663    /// The TensorFlow summary tag name used for optimizing hyperparameter tuning trials. See [`HyperparameterSpec.hyperparameterMetricTag`](#HyperparameterSpec.FIELDS.hyperparameter_metric_tag) for more information. Only set for hyperparameter tuning jobs.
1664    #[serde(rename = "hyperparameterMetricTag")]
1665    pub hyperparameter_metric_tag: Option<String>,
1666    /// Whether this job is a built-in Algorithm job.
1667    #[serde(rename = "isBuiltInAlgorithmJob")]
1668    pub is_built_in_algorithm_job: Option<bool>,
1669    /// Whether this job is a hyperparameter tuning job.
1670    #[serde(rename = "isHyperparameterTuningJob")]
1671    pub is_hyperparameter_tuning_job: Option<bool>,
1672    /// Results for individual Hyperparameter trials. Only set for hyperparameter tuning jobs.
1673    pub trials: Option<Vec<GoogleCloudMlV1__HyperparameterOutput>>,
1674    /// Output only. URIs for accessing [interactive shells](https://cloud.google.com/ai-platform/training/docs/monitor-debug-interactive-shell) (one URI for each training node). Only available if training_input.enable_web_access is `true`. The keys are names of each node in the training job; for example, `master-replica-0` for the master node, `worker-replica-0` for the first worker, and `ps-replica-0` for the first parameter server. The values are the URIs for each node's interactive shell.
1675    #[serde(rename = "webAccessUris")]
1676    pub web_access_uris: Option<HashMap<String, String>>,
1677}
1678
1679impl common::Part for GoogleCloudMlV1__TrainingOutput {}
1680
1681/// A message representing a trial.
1682///
1683/// # Activities
1684///
1685/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1686/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1687///
1688/// * [locations studies trials add measurement projects](ProjectLocationStudyTrialAddMeasurementCall) (response)
1689/// * [locations studies trials complete projects](ProjectLocationStudyTrialCompleteCall) (response)
1690/// * [locations studies trials create projects](ProjectLocationStudyTrialCreateCall) (request|response)
1691/// * [locations studies trials get projects](ProjectLocationStudyTrialGetCall) (response)
1692/// * [locations studies trials stop projects](ProjectLocationStudyTrialStopCall) (response)
1693#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1694#[serde_with::serde_as]
1695#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1696pub struct GoogleCloudMlV1__Trial {
1697    /// Output only. The identifier of the client that originally requested this trial.
1698    #[serde(rename = "clientId")]
1699    pub client_id: Option<String>,
1700    /// Output only. Time at which the trial's status changed to COMPLETED.
1701    #[serde(rename = "endTime")]
1702    pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1703    /// The final measurement containing the objective value.
1704    #[serde(rename = "finalMeasurement")]
1705    pub final_measurement: Option<GoogleCloudMlV1__Measurement>,
1706    /// Output only. A human readable string describing why the trial is infeasible. This should only be set if trial_infeasible is true.
1707    #[serde(rename = "infeasibleReason")]
1708    pub infeasible_reason: Option<String>,
1709    /// A list of measurements that are strictly lexicographically ordered by their induced tuples (steps, elapsed_time). These are used for early stopping computations.
1710    pub measurements: Option<Vec<GoogleCloudMlV1__Measurement>>,
1711    /// Output only. Name of the trial assigned by the service.
1712    pub name: Option<String>,
1713    /// The parameters of the trial.
1714    pub parameters: Option<Vec<GoogleCloudMlV1_Trial_Parameter>>,
1715    /// Output only. Time at which the trial was started.
1716    #[serde(rename = "startTime")]
1717    pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1718    /// The detailed state of a trial.
1719    pub state: Option<String>,
1720    /// Output only. If true, the parameters in this trial are not attempted again.
1721    #[serde(rename = "trialInfeasible")]
1722    pub trial_infeasible: Option<bool>,
1723}
1724
1725impl common::RequestValue for GoogleCloudMlV1__Trial {}
1726impl common::ResponseResult for GoogleCloudMlV1__Trial {}
1727
1728/// Represents a version of the model. Each version is a trained model deployed in the cloud, ready to handle prediction requests. A model can have multiple versions. You can get information about all of the versions of a given model by calling projects.models.versions.list.
1729///
1730/// # Activities
1731///
1732/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1733/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1734///
1735/// * [models versions create projects](ProjectModelVersionCreateCall) (request)
1736/// * [models versions get projects](ProjectModelVersionGetCall) (response)
1737/// * [models versions patch projects](ProjectModelVersionPatchCall) (request)
1738/// * [models versions set default projects](ProjectModelVersionSetDefaultCall) (response)
1739#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1740#[serde_with::serde_as]
1741#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1742pub struct GoogleCloudMlV1__Version {
1743    /// Optional. Accelerator config for using GPUs for online prediction (beta). Only specify this field if you have specified a Compute Engine (N1) machine type in the `machineType` field. Learn more about [using GPUs for online prediction](https://cloud.google.com/ml-engine/docs/machine-types-online-prediction#gpus).
1744    #[serde(rename = "acceleratorConfig")]
1745    pub accelerator_config: Option<GoogleCloudMlV1__AcceleratorConfig>,
1746    /// Automatically scale the number of nodes used to serve the model in response to increases and decreases in traffic. Care should be taken to ramp up traffic according to the model's ability to scale or you will start seeing increases in latency and 429 response codes.
1747    #[serde(rename = "autoScaling")]
1748    pub auto_scaling: Option<GoogleCloudMlV1__AutoScaling>,
1749    /// Optional. Specifies a custom container to use for serving predictions. If you specify this field, then `machineType` is required. If you specify this field, then `deploymentUri` is optional. If you specify this field, then you must not specify `runtimeVersion`, `packageUris`, `framework`, `pythonVersion`, or `predictionClass`.
1750    pub container: Option<GoogleCloudMlV1__ContainerSpec>,
1751    /// Output only. The time the version was created.
1752    #[serde(rename = "createTime")]
1753    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1754    /// The Cloud Storage URI of a directory containing trained model artifacts to be used to create the model version. See the [guide to deploying models](https://cloud.google.com/ai-platform/prediction/docs/deploying-models) for more information. The total number of files under this directory must not exceed 1000. During projects.models.versions.create, AI Platform Prediction copies all files from the specified directory to a location managed by the service. From then on, AI Platform Prediction uses these copies of the model artifacts to serve predictions, not the original files in Cloud Storage, so this location is useful only as a historical record. If you specify container, then this field is optional. Otherwise, it is required. Learn [how to use this field with a custom container](https://cloud.google.com/ai-platform/prediction/docs/custom-container-requirements#artifacts).
1755    #[serde(rename = "deploymentUri")]
1756    pub deployment_uri: Option<String>,
1757    /// Optional. The description specified for the version when it was created.
1758    pub description: Option<String>,
1759    /// Output only. The details of a failure or a cancellation.
1760    #[serde(rename = "errorMessage")]
1761    pub error_message: Option<String>,
1762    /// `etag` is used for optimistic concurrency control as a way to help prevent simultaneous updates of a model from overwriting each other. It is strongly suggested that systems make use of the `etag` in the read-modify-write cycle to perform model updates in order to avoid race conditions: An `etag` is returned in the response to `GetVersion`, and systems are expected to put that etag in the request to `UpdateVersion` to ensure that their change will be applied to the model as intended.
1763    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1764    pub etag: Option<Vec<u8>>,
1765    /// Optional. Configures explainability features on the model's version. Some explanation features require additional metadata to be loaded as part of the model payload.
1766    #[serde(rename = "explanationConfig")]
1767    pub explanation_config: Option<GoogleCloudMlV1__ExplanationConfig>,
1768    /// Optional. The machine learning framework AI Platform uses to train this version of the model. Valid values are `TENSORFLOW`, `SCIKIT_LEARN`, `XGBOOST`. If you do not specify a framework, AI Platform will analyze files in the deployment_uri to determine a framework. If you choose `SCIKIT_LEARN` or `XGBOOST`, you must also set the runtime version of the model to 1.4 or greater. Do **not** specify a framework if you’re deploying a [custom prediction routine](https://cloud.google.com/ai-platform/prediction/docs/custom-prediction-routines) or if you’re using a [custom container](https://cloud.google.com/ai-platform/prediction/docs/use-custom-container).
1769    pub framework: Option<String>,
1770    /// Output only. If true, this version will be used to handle prediction requests that do not specify a version. You can change the default version by calling projects.methods.versions.setDefault.
1771    #[serde(rename = "isDefault")]
1772    pub is_default: Option<bool>,
1773    /// Optional. One or more labels that you can add, to organize your model versions. Each label is a key-value pair, where both the key and the value are arbitrary strings that you supply. For more information, see the documentation on using labels. Note that this field is not updatable for mls1* models.
1774    pub labels: Option<HashMap<String, String>>,
1775    /// Output only. The [AI Platform (Unified) `Model`](https://cloud.google.com/ai-platform-unified/docs/reference/rest/v1beta1/projects.locations.models) ID for the last [model migration](https://cloud.google.com/ai-platform-unified/docs/start/migrating-to-ai-platform-unified).
1776    #[serde(rename = "lastMigrationModelId")]
1777    pub last_migration_model_id: Option<String>,
1778    /// Output only. The last time this version was successfully [migrated to AI Platform (Unified)](https://cloud.google.com/ai-platform-unified/docs/start/migrating-to-ai-platform-unified).
1779    #[serde(rename = "lastMigrationTime")]
1780    pub last_migration_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1781    /// Output only. The time the version was last used for prediction.
1782    #[serde(rename = "lastUseTime")]
1783    pub last_use_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1784    /// Optional. The type of machine on which to serve the model. Currently only applies to online prediction service. To learn about valid values for this field, read [Choosing a machine type for online prediction](https://cloud.google.com/ai-platform/prediction/docs/machine-types-online-prediction). If this field is not specified and you are using a [regional endpoint](https://cloud.google.com/ai-platform/prediction/docs/regional-endpoints), then the machine type defaults to `n1-standard-2`. If this field is not specified and you are using the global endpoint (`ml.googleapis.com`), then the machine type defaults to `mls1-c1-m2`.
1785    #[serde(rename = "machineType")]
1786    pub machine_type: Option<String>,
1787    /// Manually select the number of nodes to use for serving the model. You should generally use `auto_scaling` with an appropriate `min_nodes` instead, but this option is available if you want more predictable billing. Beware that latency and error rates will increase if the traffic exceeds that capability of the system to serve it based on the selected number of nodes.
1788    #[serde(rename = "manualScaling")]
1789    pub manual_scaling: Option<GoogleCloudMlV1__ManualScaling>,
1790    /// Required. The name specified for the version when it was created. The version name must be unique within the model it is created in.
1791    pub name: Option<String>,
1792    /// Optional. Cloud Storage paths (`gs://…`) of packages for [custom prediction routines](https://cloud.google.com/ml-engine/docs/tensorflow/custom-prediction-routines) or [scikit-learn pipelines with custom code](https://cloud.google.com/ml-engine/docs/scikit/exporting-for-prediction#custom-pipeline-code). For a custom prediction routine, one of these packages must contain your Predictor class (see [`predictionClass`](#Version.FIELDS.prediction_class)). Additionally, include any dependencies used by your Predictor or scikit-learn pipeline uses that are not already included in your selected [runtime version](https://cloud.google.com/ml-engine/docs/tensorflow/runtime-version-list). If you specify this field, you must also set [`runtimeVersion`](#Version.FIELDS.runtime_version) to 1.4 or greater.
1793    #[serde(rename = "packageUris")]
1794    pub package_uris: Option<Vec<String>>,
1795    /// Optional. The fully qualified name (module_name.class_name) of a class that implements the Predictor interface described in this reference field. The module containing this class should be included in a package provided to the [`packageUris` field](#Version.FIELDS.package_uris). Specify this field if and only if you are deploying a [custom prediction routine (beta)](https://cloud.google.com/ml-engine/docs/tensorflow/custom-prediction-routines). If you specify this field, you must set [`runtimeVersion`](#Version.FIELDS.runtime_version) to 1.4 or greater and you must set `machineType` to a [legacy (MLS1) machine type](https://cloud.google.com/ml-engine/docs/machine-types-online-prediction). The following code sample provides the Predictor interface: class Predictor(object): “”“Interface for constructing custom predictors.”“” def predict(self, instances, \*\*kwargs): “”“Performs custom prediction. Instances are the decoded values from the request. They have already been deserialized from JSON. Args: instances: A list of prediction input instances. \*\*kwargs: A dictionary of keyword args provided as additional fields on the predict request body. Returns: A list of outputs containing the prediction results. This list must be JSON serializable. “”“ raise NotImplementedError() @classmethod def from_path(cls, model_dir): “”“Creates an instance of Predictor using the given path. Loading of the predictor should be done in this method. Args: model_dir: The local directory that contains the exported model file along with any additional files uploaded when creating the version resource. Returns: An instance implementing this Predictor class. “”“ raise NotImplementedError() Learn more about [the Predictor interface and custom prediction routines](https://cloud.google.com/ml-engine/docs/tensorflow/custom-prediction-routines).
1796    #[serde(rename = "predictionClass")]
1797    pub prediction_class: Option<String>,
1798    /// Required. The version of Python used in prediction. The following Python versions are available: * Python ‘3.7’ is available when `runtime_version` is set to ‘1.15’ or later. * Python ‘3.5’ is available when `runtime_version` is set to a version from ‘1.4’ to ‘1.14’. * Python ‘2.7’ is available when `runtime_version` is set to ‘1.15’ or earlier. Read more about the Python versions available for [each runtime version](https://cloud.google.com/ml-engine/docs/runtime-version-list).
1799    #[serde(rename = "pythonVersion")]
1800    pub python_version: Option<String>,
1801    /// Optional. *Only* specify this field in a projects.models.versions.patch request. Specifying it in a projects.models.versions.create request has no effect. Configures the request-response pair logging on predictions from this Version.
1802    #[serde(rename = "requestLoggingConfig")]
1803    pub request_logging_config: Option<GoogleCloudMlV1__RequestLoggingConfig>,
1804    /// Optional. Specifies paths on a custom container's HTTP server where AI Platform Prediction sends certain requests. If you specify this field, then you must also specify the `container` field. If you specify the `container` field and do not specify this field, it defaults to the following: ```json { "predict": "/v1/models/MODEL/versions/VERSION:predict", "health": "/v1/models/MODEL/versions/VERSION" } ``` See RouteMap for more details about these default values.
1805    pub routes: Option<GoogleCloudMlV1__RouteMap>,
1806    /// Required. The AI Platform runtime version to use for this deployment. For more information, see the [runtime version list](https://cloud.google.com/ml-engine/docs/runtime-version-list) and [how to manage runtime versions](https://cloud.google.com/ml-engine/docs/versioning).
1807    #[serde(rename = "runtimeVersion")]
1808    pub runtime_version: Option<String>,
1809    /// Optional. Specifies the service account for resource access control. If you specify this field, then you must also specify either the `containerSpec` or the `predictionClass` field. Learn more about [using a custom service account](https://cloud.google.com/ai-platform/prediction/docs/custom-service-account).
1810    #[serde(rename = "serviceAccount")]
1811    pub service_account: Option<String>,
1812    /// Output only. The state of a version.
1813    pub state: Option<String>,
1814}
1815
1816impl common::RequestValue for GoogleCloudMlV1__Version {}
1817impl common::ResponseResult for GoogleCloudMlV1__Version {}
1818
1819/// Attributes credit by computing the XRAI taking advantage of the model's fully differentiable structure. Refer to this paper for more details: https://arxiv.org/abs/1906.02825 Currently only implemented for models with natural image inputs.
1820///
1821/// This type is not used in any activity, and only used as *part* of another schema.
1822///
1823#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1824#[serde_with::serde_as]
1825#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1826pub struct GoogleCloudMlV1__XraiAttribution {
1827    /// Number of steps for approximating the path integral. A good value to start is 50 and gradually increase until the sum to diff property is met within the desired error range.
1828    #[serde(rename = "numIntegralSteps")]
1829    pub num_integral_steps: Option<i32>,
1830}
1831
1832impl common::Part for GoogleCloudMlV1__XraiAttribution {}
1833
1834/// Specifies the audit configuration for a service. The configuration determines which permission types are logged, and what identities, if any, are exempted from logging. An AuditConfig must have one or more AuditLogConfigs. If there are AuditConfigs for both `allServices` and a specific service, the union of the two AuditConfigs is used for that service: the log_types specified in each AuditConfig are enabled, and the exempted_members in each AuditLogConfig are exempted. Example Policy with multiple AuditConfigs: { "audit_configs": [ { "service": "allServices", "audit_log_configs": [ { "log_type": "DATA_READ", "exempted_members": [ "user:jose@example.com" ] }, { "log_type": "DATA_WRITE" }, { "log_type": "ADMIN_READ" } ] }, { "service": "sampleservice.googleapis.com", "audit_log_configs": [ { "log_type": "DATA_READ" }, { "log_type": "DATA_WRITE", "exempted_members": [ "user:aliya@example.com" ] } ] } ] } For sampleservice, this policy enables DATA_READ, DATA_WRITE and ADMIN_READ logging. It also exempts `jose@example.com` from DATA_READ logging, and `aliya@example.com` from DATA_WRITE logging.
1835///
1836/// This type is not used in any activity, and only used as *part* of another schema.
1837///
1838#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1839#[serde_with::serde_as]
1840#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1841pub struct GoogleIamV1__AuditConfig {
1842    /// The configuration for logging of each type of permission.
1843    #[serde(rename = "auditLogConfigs")]
1844    pub audit_log_configs: Option<Vec<GoogleIamV1__AuditLogConfig>>,
1845    /// Specifies a service that will be enabled for audit logging. For example, `storage.googleapis.com`, `cloudsql.googleapis.com`. `allServices` is a special value that covers all services.
1846    pub service: Option<String>,
1847}
1848
1849impl common::Part for GoogleIamV1__AuditConfig {}
1850
1851/// Provides the configuration for logging a type of permissions. Example: { "audit_log_configs": [ { "log_type": "DATA_READ", "exempted_members": [ "user:jose@example.com" ] }, { "log_type": "DATA_WRITE" } ] } This enables 'DATA_READ' and 'DATA_WRITE' logging, while exempting jose@example.com from DATA_READ logging.
1852///
1853/// This type is not used in any activity, and only used as *part* of another schema.
1854///
1855#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1856#[serde_with::serde_as]
1857#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1858pub struct GoogleIamV1__AuditLogConfig {
1859    /// Specifies the identities that do not cause logging for this type of permission. Follows the same format of Binding.members.
1860    #[serde(rename = "exemptedMembers")]
1861    pub exempted_members: Option<Vec<String>>,
1862    /// The log type that this config enables.
1863    #[serde(rename = "logType")]
1864    pub log_type: Option<String>,
1865}
1866
1867impl common::Part for GoogleIamV1__AuditLogConfig {}
1868
1869/// Associates `members`, or principals, with a `role`.
1870///
1871/// This type is not used in any activity, and only used as *part* of another schema.
1872///
1873#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1874#[serde_with::serde_as]
1875#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1876pub struct GoogleIamV1__Binding {
1877    /// The condition that is associated with this binding. If the condition evaluates to `true`, then this binding applies to the current request. If the condition evaluates to `false`, then this binding does not apply to the current request. However, a different role binding might grant the same role to one or more of the principals in this binding. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
1878    pub condition: Option<GoogleType__Expr>,
1879    /// Specifies the principals requesting access for a Google Cloud resource. `members` can have the following values: * `allUsers`: A special identifier that represents anyone who is on the internet; with or without a Google account. * `allAuthenticatedUsers`: A special identifier that represents anyone who is authenticated with a Google account or a service account. Does not include identities that come from external identity providers (IdPs) through identity federation. * `user:{emailid}`: An email address that represents a specific Google account. For example, `alice@example.com` . * `serviceAccount:{emailid}`: An email address that represents a Google service account. For example, `my-other-app@appspot.gserviceaccount.com`. * `serviceAccount:{projectid}.svc.id.goog[{namespace}/{kubernetes-sa}]`: An identifier for a [Kubernetes service account](https://cloud.google.com/kubernetes-engine/docs/how-to/kubernetes-service-accounts). For example, `my-project.svc.id.goog[my-namespace/my-kubernetes-sa]`. * `group:{emailid}`: An email address that represents a Google group. For example, `admins@example.com`. * `domain:{domain}`: The G Suite domain (primary) that represents all the users of that domain. For example, `google.com` or `example.com`. * `principal://iam.googleapis.com/locations/global/workforcePools/{pool_id}/subject/{subject_attribute_value}`: A single identity in a workforce identity pool. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/group/{group_id}`: All workforce identities in a group. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/attribute.{attribute_name}/{attribute_value}`: All workforce identities with a specific attribute value. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/*`: All identities in a workforce identity pool. * `principal://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/subject/{subject_attribute_value}`: A single identity in a workload identity pool. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/group/{group_id}`: A workload identity pool group. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/attribute.{attribute_name}/{attribute_value}`: All identities in a workload identity pool with a certain attribute. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/*`: All identities in a workload identity pool. * `deleted:user:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a user that has been recently deleted. For example, `alice@example.com?uid=123456789012345678901`. If the user is recovered, this value reverts to `user:{emailid}` and the recovered user retains the role in the binding. * `deleted:serviceAccount:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a service account that has been recently deleted. For example, `my-other-app@appspot.gserviceaccount.com?uid=123456789012345678901`. If the service account is undeleted, this value reverts to `serviceAccount:{emailid}` and the undeleted service account retains the role in the binding. * `deleted:group:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a Google group that has been recently deleted. For example, `admins@example.com?uid=123456789012345678901`. If the group is recovered, this value reverts to `group:{emailid}` and the recovered group retains the role in the binding. * `deleted:principal://iam.googleapis.com/locations/global/workforcePools/{pool_id}/subject/{subject_attribute_value}`: Deleted single identity in a workforce identity pool. For example, `deleted:principal://iam.googleapis.com/locations/global/workforcePools/my-pool-id/subject/my-subject-attribute-value`.
1880    pub members: Option<Vec<String>>,
1881    /// Role that is assigned to the list of `members`, or principals. For example, `roles/viewer`, `roles/editor`, or `roles/owner`. For an overview of the IAM roles and permissions, see the [IAM documentation](https://cloud.google.com/iam/docs/roles-overview). For a list of the available pre-defined roles, see [here](https://cloud.google.com/iam/docs/understanding-roles).
1882    pub role: Option<String>,
1883}
1884
1885impl common::Part for GoogleIamV1__Binding {}
1886
1887/// An Identity and Access Management (IAM) policy, which specifies access controls for Google Cloud resources. A `Policy` is a collection of `bindings`. A `binding` binds one or more `members`, or principals, to a single `role`. Principals can be user accounts, service accounts, Google groups, and domains (such as G Suite). A `role` is a named list of permissions; each `role` can be an IAM predefined role or a user-created custom role. For some types of Google Cloud resources, a `binding` can also specify a `condition`, which is a logical expression that allows access to a resource only if the expression evaluates to `true`. A condition can add constraints based on attributes of the request, the resource, or both. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies). **JSON example:** `{ "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }` **YAML example:** `bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3` For a description of IAM and its features, see the [IAM documentation](https://cloud.google.com/iam/docs/).
1888///
1889/// # Activities
1890///
1891/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1892/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1893///
1894/// * [jobs get iam policy projects](ProjectJobGetIamPolicyCall) (response)
1895/// * [jobs set iam policy projects](ProjectJobSetIamPolicyCall) (response)
1896/// * [models get iam policy projects](ProjectModelGetIamPolicyCall) (response)
1897/// * [models set iam policy projects](ProjectModelSetIamPolicyCall) (response)
1898#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1899#[serde_with::serde_as]
1900#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1901pub struct GoogleIamV1__Policy {
1902    /// Specifies cloud audit logging configuration for this policy.
1903    #[serde(rename = "auditConfigs")]
1904    pub audit_configs: Option<Vec<GoogleIamV1__AuditConfig>>,
1905    /// Associates a list of `members`, or principals, with a `role`. Optionally, may specify a `condition` that determines how and when the `bindings` are applied. Each of the `bindings` must contain at least one principal. The `bindings` in a `Policy` can refer to up to 1,500 principals; up to 250 of these principals can be Google groups. Each occurrence of a principal counts towards these limits. For example, if the `bindings` grant 50 different roles to `user:alice@example.com`, and not to any other principal, then you can add another 1,450 principals to the `bindings` in the `Policy`.
1906    pub bindings: Option<Vec<GoogleIamV1__Binding>>,
1907    /// `etag` is used for optimistic concurrency control as a way to help prevent simultaneous updates of a policy from overwriting each other. It is strongly suggested that systems make use of the `etag` in the read-modify-write cycle to perform policy updates in order to avoid race conditions: An `etag` is returned in the response to `getIamPolicy`, and systems are expected to put that etag in the request to `setIamPolicy` to ensure that their change will be applied to the same version of the policy. **Important:** If you use IAM Conditions, you must include the `etag` field whenever you call `setIamPolicy`. If you omit this field, then IAM allows you to overwrite a version `3` policy with a version `1` policy, and all of the conditions in the version `3` policy are lost.
1908    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1909    pub etag: Option<Vec<u8>>,
1910    /// Specifies the format of the policy. Valid values are `0`, `1`, and `3`. Requests that specify an invalid value are rejected. Any operation that affects conditional role bindings must specify version `3`. This requirement applies to the following operations: * Getting a policy that includes a conditional role binding * Adding a conditional role binding to a policy * Changing a conditional role binding in a policy * Removing any role binding, with or without a condition, from a policy that includes conditions **Important:** If you use IAM Conditions, you must include the `etag` field whenever you call `setIamPolicy`. If you omit this field, then IAM allows you to overwrite a version `3` policy with a version `1` policy, and all of the conditions in the version `3` policy are lost. If a policy does not include any conditions, operations on that policy may specify any valid version or leave the field unset. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
1911    pub version: Option<i32>,
1912}
1913
1914impl common::ResponseResult for GoogleIamV1__Policy {}
1915
1916/// Request message for `SetIamPolicy` method.
1917///
1918/// # Activities
1919///
1920/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1921/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1922///
1923/// * [jobs set iam policy projects](ProjectJobSetIamPolicyCall) (request)
1924/// * [models set iam policy projects](ProjectModelSetIamPolicyCall) (request)
1925#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1926#[serde_with::serde_as]
1927#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1928pub struct GoogleIamV1__SetIamPolicyRequest {
1929    /// REQUIRED: The complete policy to be applied to the `resource`. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Google Cloud services (such as Projects) might reject them.
1930    pub policy: Option<GoogleIamV1__Policy>,
1931    /// OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only the fields in the mask will be modified. If no mask is provided, the following default mask is used: `paths: "bindings, etag"`
1932    #[serde(rename = "updateMask")]
1933    pub update_mask: Option<common::FieldMask>,
1934}
1935
1936impl common::RequestValue for GoogleIamV1__SetIamPolicyRequest {}
1937
1938/// Request message for `TestIamPermissions` method.
1939///
1940/// # Activities
1941///
1942/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1943/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1944///
1945/// * [jobs test iam permissions projects](ProjectJobTestIamPermissionCall) (request)
1946/// * [models test iam permissions projects](ProjectModelTestIamPermissionCall) (request)
1947#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1948#[serde_with::serde_as]
1949#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1950pub struct GoogleIamV1__TestIamPermissionsRequest {
1951    /// The set of permissions to check for the `resource`. Permissions with wildcards (such as `*` or `storage.*`) are not allowed. For more information see [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
1952    pub permissions: Option<Vec<String>>,
1953}
1954
1955impl common::RequestValue for GoogleIamV1__TestIamPermissionsRequest {}
1956
1957/// Response message for `TestIamPermissions` method.
1958///
1959/// # Activities
1960///
1961/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1962/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1963///
1964/// * [jobs test iam permissions projects](ProjectJobTestIamPermissionCall) (response)
1965/// * [models test iam permissions projects](ProjectModelTestIamPermissionCall) (response)
1966#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1967#[serde_with::serde_as]
1968#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1969pub struct GoogleIamV1__TestIamPermissionsResponse {
1970    /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed.
1971    pub permissions: Option<Vec<String>>,
1972}
1973
1974impl common::ResponseResult for GoogleIamV1__TestIamPermissionsResponse {}
1975
1976/// The response message for Operations.ListOperations.
1977///
1978/// # Activities
1979///
1980/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1981/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1982///
1983/// * [operations list projects](ProjectOperationListCall) (response)
1984#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1985#[serde_with::serde_as]
1986#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1987pub struct GoogleLongrunning__ListOperationsResponse {
1988    /// The standard List next-page token.
1989    #[serde(rename = "nextPageToken")]
1990    pub next_page_token: Option<String>,
1991    /// A list of operations that matches the specified filter in the request.
1992    pub operations: Option<Vec<GoogleLongrunning__Operation>>,
1993}
1994
1995impl common::ResponseResult for GoogleLongrunning__ListOperationsResponse {}
1996
1997/// This resource represents a long-running operation that is the result of a network API call.
1998///
1999/// # Activities
2000///
2001/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2002/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2003///
2004/// * [locations operations get projects](ProjectLocationOperationGetCall) (response)
2005/// * [locations studies trials check early stopping state projects](ProjectLocationStudyTrialCheckEarlyStoppingStateCall) (response)
2006/// * [locations studies trials suggest projects](ProjectLocationStudyTrialSuggestCall) (response)
2007/// * [models versions create projects](ProjectModelVersionCreateCall) (response)
2008/// * [models versions delete projects](ProjectModelVersionDeleteCall) (response)
2009/// * [models versions patch projects](ProjectModelVersionPatchCall) (response)
2010/// * [models delete projects](ProjectModelDeleteCall) (response)
2011/// * [models patch projects](ProjectModelPatchCall) (response)
2012/// * [operations get projects](ProjectOperationGetCall) (response)
2013#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2014#[serde_with::serde_as]
2015#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2016pub struct GoogleLongrunning__Operation {
2017    /// 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.
2018    pub done: Option<bool>,
2019    /// The error result of the operation in case of failure or cancellation.
2020    pub error: Option<GoogleRpc__Status>,
2021    /// 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.
2022    pub metadata: Option<HashMap<String, serde_json::Value>>,
2023    /// 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}`.
2024    pub name: Option<String>,
2025    /// 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`.
2026    pub response: Option<HashMap<String, serde_json::Value>>,
2027}
2028
2029impl common::ResponseResult for GoogleLongrunning__Operation {}
2030
2031/// 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); }
2032///
2033/// # Activities
2034///
2035/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2036/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2037///
2038/// * [jobs cancel projects](ProjectJobCancelCall) (response)
2039/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (response)
2040/// * [locations studies trials delete projects](ProjectLocationStudyTrialDeleteCall) (response)
2041/// * [locations studies delete projects](ProjectLocationStudyDeleteCall) (response)
2042/// * [operations cancel projects](ProjectOperationCancelCall) (response)
2043#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2044#[serde_with::serde_as]
2045#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2046pub struct GoogleProtobuf__Empty {
2047    _never_set: Option<bool>,
2048}
2049
2050impl common::ResponseResult for GoogleProtobuf__Empty {}
2051
2052/// 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).
2053///
2054/// This type is not used in any activity, and only used as *part* of another schema.
2055///
2056#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2057#[serde_with::serde_as]
2058#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2059pub struct GoogleRpc__Status {
2060    /// The status code, which should be an enum value of google.rpc.Code.
2061    pub code: Option<i32>,
2062    /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
2063    pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
2064    /// 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.
2065    pub message: Option<String>,
2066}
2067
2068impl common::Part for GoogleRpc__Status {}
2069
2070/// Represents a textual expression in the Common Expression Language (CEL) syntax. CEL is a C-like expression language. The syntax and semantics of CEL are documented at https://github.com/google/cel-spec. Example (Comparison): title: "Summary size limit" description: "Determines if a summary is less than 100 chars" expression: "document.summary.size() < 100" Example (Equality): title: "Requestor is owner" description: "Determines if requestor is the document owner" expression: "document.owner == request.auth.claims.email" Example (Logic): title: "Public documents" description: "Determine whether the document should be publicly visible" expression: "document.type != 'private' && document.type != 'internal'" Example (Data Manipulation): title: "Notification string" description: "Create a notification string with a timestamp." expression: "'New message received at ' + string(document.create_time)" The exact variables and functions that may be referenced within an expression are determined by the service that evaluates it. See the service documentation for additional information.
2071///
2072/// This type is not used in any activity, and only used as *part* of another schema.
2073///
2074#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2075#[serde_with::serde_as]
2076#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2077pub struct GoogleType__Expr {
2078    /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
2079    pub description: Option<String>,
2080    /// Textual representation of an expression in Common Expression Language syntax.
2081    pub expression: Option<String>,
2082    /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
2083    pub location: Option<String>,
2084    /// Optional. Title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression.
2085    pub title: Option<String>,
2086}
2087
2088impl common::Part for GoogleType__Expr {}
2089
2090// ###################
2091// MethodBuilders ###
2092// #################
2093
2094/// A builder providing access to all methods supported on *project* resources.
2095/// It is not used directly, but through the [`CloudMachineLearningEngine`] hub.
2096///
2097/// # Example
2098///
2099/// Instantiate a resource builder
2100///
2101/// ```test_harness,no_run
2102/// extern crate hyper;
2103/// extern crate hyper_rustls;
2104/// extern crate google_ml1 as ml1;
2105///
2106/// # async fn dox() {
2107/// use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2108///
2109/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2110/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2111///     .with_native_roots()
2112///     .unwrap()
2113///     .https_only()
2114///     .enable_http2()
2115///     .build();
2116///
2117/// let executor = hyper_util::rt::TokioExecutor::new();
2118/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2119///     secret,
2120///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2121///     yup_oauth2::client::CustomHyperClientBuilder::from(
2122///         hyper_util::client::legacy::Client::builder(executor).build(connector),
2123///     ),
2124/// ).build().await.unwrap();
2125///
2126/// let client = hyper_util::client::legacy::Client::builder(
2127///     hyper_util::rt::TokioExecutor::new()
2128/// )
2129/// .build(
2130///     hyper_rustls::HttpsConnectorBuilder::new()
2131///         .with_native_roots()
2132///         .unwrap()
2133///         .https_or_http()
2134///         .enable_http2()
2135///         .build()
2136/// );
2137/// let mut hub = CloudMachineLearningEngine::new(client, auth);
2138/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2139/// // like `explain(...)`, `get_config(...)`, `jobs_cancel(...)`, `jobs_create(...)`, `jobs_get(...)`, `jobs_get_iam_policy(...)`, `jobs_list(...)`, `jobs_patch(...)`, `jobs_set_iam_policy(...)`, `jobs_test_iam_permissions(...)`, `locations_get(...)`, `locations_list(...)`, `locations_operations_cancel(...)`, `locations_operations_get(...)`, `locations_studies_create(...)`, `locations_studies_delete(...)`, `locations_studies_get(...)`, `locations_studies_list(...)`, `locations_studies_trials_add_measurement(...)`, `locations_studies_trials_check_early_stopping_state(...)`, `locations_studies_trials_complete(...)`, `locations_studies_trials_create(...)`, `locations_studies_trials_delete(...)`, `locations_studies_trials_get(...)`, `locations_studies_trials_list(...)`, `locations_studies_trials_list_optimal_trials(...)`, `locations_studies_trials_stop(...)`, `locations_studies_trials_suggest(...)`, `models_create(...)`, `models_delete(...)`, `models_get(...)`, `models_get_iam_policy(...)`, `models_list(...)`, `models_patch(...)`, `models_set_iam_policy(...)`, `models_test_iam_permissions(...)`, `models_versions_create(...)`, `models_versions_delete(...)`, `models_versions_get(...)`, `models_versions_list(...)`, `models_versions_patch(...)`, `models_versions_set_default(...)`, `operations_cancel(...)`, `operations_get(...)`, `operations_list(...)` and `predict(...)`
2140/// // to build up your call.
2141/// let rb = hub.projects();
2142/// # }
2143/// ```
2144pub struct ProjectMethods<'a, C>
2145where
2146    C: 'a,
2147{
2148    hub: &'a CloudMachineLearningEngine<C>,
2149}
2150
2151impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
2152
2153impl<'a, C> ProjectMethods<'a, C> {
2154    /// Create a builder to help you perform the following task:
2155    ///
2156    /// Cancels a running job.
2157    ///
2158    /// # Arguments
2159    ///
2160    /// * `request` - No description provided.
2161    /// * `name` - Required. The name of the job to cancel.
2162    pub fn jobs_cancel(
2163        &self,
2164        request: GoogleCloudMlV1__CancelJobRequest,
2165        name: &str,
2166    ) -> ProjectJobCancelCall<'a, C> {
2167        ProjectJobCancelCall {
2168            hub: self.hub,
2169            _request: request,
2170            _name: name.to_string(),
2171            _delegate: Default::default(),
2172            _additional_params: Default::default(),
2173            _scopes: Default::default(),
2174        }
2175    }
2176
2177    /// Create a builder to help you perform the following task:
2178    ///
2179    /// Creates a training or a batch prediction job.
2180    ///
2181    /// # Arguments
2182    ///
2183    /// * `request` - No description provided.
2184    /// * `parent` - Required. The project name.
2185    pub fn jobs_create(
2186        &self,
2187        request: GoogleCloudMlV1__Job,
2188        parent: &str,
2189    ) -> ProjectJobCreateCall<'a, C> {
2190        ProjectJobCreateCall {
2191            hub: self.hub,
2192            _request: request,
2193            _parent: parent.to_string(),
2194            _delegate: Default::default(),
2195            _additional_params: Default::default(),
2196            _scopes: Default::default(),
2197        }
2198    }
2199
2200    /// Create a builder to help you perform the following task:
2201    ///
2202    /// Describes a job.
2203    ///
2204    /// # Arguments
2205    ///
2206    /// * `name` - Required. The name of the job to get the description of.
2207    pub fn jobs_get(&self, name: &str) -> ProjectJobGetCall<'a, C> {
2208        ProjectJobGetCall {
2209            hub: self.hub,
2210            _name: name.to_string(),
2211            _delegate: Default::default(),
2212            _additional_params: Default::default(),
2213            _scopes: Default::default(),
2214        }
2215    }
2216
2217    /// Create a builder to help you perform the following task:
2218    ///
2219    /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
2220    ///
2221    /// # Arguments
2222    ///
2223    /// * `resource` - REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
2224    pub fn jobs_get_iam_policy(&self, resource: &str) -> ProjectJobGetIamPolicyCall<'a, C> {
2225        ProjectJobGetIamPolicyCall {
2226            hub: self.hub,
2227            _resource: resource.to_string(),
2228            _options_requested_policy_version: Default::default(),
2229            _delegate: Default::default(),
2230            _additional_params: Default::default(),
2231            _scopes: Default::default(),
2232        }
2233    }
2234
2235    /// Create a builder to help you perform the following task:
2236    ///
2237    /// Lists the jobs in the project. If there are no jobs that match the request parameters, the list request returns an empty response body: {}.
2238    ///
2239    /// # Arguments
2240    ///
2241    /// * `parent` - Required. The name of the project for which to list jobs.
2242    pub fn jobs_list(&self, parent: &str) -> ProjectJobListCall<'a, C> {
2243        ProjectJobListCall {
2244            hub: self.hub,
2245            _parent: parent.to_string(),
2246            _page_token: Default::default(),
2247            _page_size: Default::default(),
2248            _filter: Default::default(),
2249            _delegate: Default::default(),
2250            _additional_params: Default::default(),
2251            _scopes: Default::default(),
2252        }
2253    }
2254
2255    /// Create a builder to help you perform the following task:
2256    ///
2257    /// Updates a specific job resource. Currently the only supported fields to update are `labels`.
2258    ///
2259    /// # Arguments
2260    ///
2261    /// * `request` - No description provided.
2262    /// * `name` - Required. The job name.
2263    pub fn jobs_patch(
2264        &self,
2265        request: GoogleCloudMlV1__Job,
2266        name: &str,
2267    ) -> ProjectJobPatchCall<'a, C> {
2268        ProjectJobPatchCall {
2269            hub: self.hub,
2270            _request: request,
2271            _name: name.to_string(),
2272            _update_mask: Default::default(),
2273            _delegate: Default::default(),
2274            _additional_params: Default::default(),
2275            _scopes: Default::default(),
2276        }
2277    }
2278
2279    /// Create a builder to help you perform the following task:
2280    ///
2281    /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
2282    ///
2283    /// # Arguments
2284    ///
2285    /// * `request` - No description provided.
2286    /// * `resource` - REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
2287    pub fn jobs_set_iam_policy(
2288        &self,
2289        request: GoogleIamV1__SetIamPolicyRequest,
2290        resource: &str,
2291    ) -> ProjectJobSetIamPolicyCall<'a, C> {
2292        ProjectJobSetIamPolicyCall {
2293            hub: self.hub,
2294            _request: request,
2295            _resource: resource.to_string(),
2296            _delegate: Default::default(),
2297            _additional_params: Default::default(),
2298            _scopes: Default::default(),
2299        }
2300    }
2301
2302    /// Create a builder to help you perform the following task:
2303    ///
2304    /// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
2305    ///
2306    /// # Arguments
2307    ///
2308    /// * `request` - No description provided.
2309    /// * `resource` - REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
2310    pub fn jobs_test_iam_permissions(
2311        &self,
2312        request: GoogleIamV1__TestIamPermissionsRequest,
2313        resource: &str,
2314    ) -> ProjectJobTestIamPermissionCall<'a, C> {
2315        ProjectJobTestIamPermissionCall {
2316            hub: self.hub,
2317            _request: request,
2318            _resource: resource.to_string(),
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    /// 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`.
2328    ///
2329    /// # Arguments
2330    ///
2331    /// * `name` - The name of the operation resource to be cancelled.
2332    pub fn locations_operations_cancel(
2333        &self,
2334        name: &str,
2335    ) -> ProjectLocationOperationCancelCall<'a, C> {
2336        ProjectLocationOperationCancelCall {
2337            hub: self.hub,
2338            _name: name.to_string(),
2339            _delegate: Default::default(),
2340            _additional_params: Default::default(),
2341            _scopes: Default::default(),
2342        }
2343    }
2344
2345    /// Create a builder to help you perform the following task:
2346    ///
2347    /// 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.
2348    ///
2349    /// # Arguments
2350    ///
2351    /// * `name` - The name of the operation resource.
2352    pub fn locations_operations_get(&self, name: &str) -> ProjectLocationOperationGetCall<'a, C> {
2353        ProjectLocationOperationGetCall {
2354            hub: self.hub,
2355            _name: name.to_string(),
2356            _delegate: Default::default(),
2357            _additional_params: Default::default(),
2358            _scopes: Default::default(),
2359        }
2360    }
2361
2362    /// Create a builder to help you perform the following task:
2363    ///
2364    /// Adds a measurement of the objective metrics to a trial. This measurement is assumed to have been taken before the trial is complete.
2365    ///
2366    /// # Arguments
2367    ///
2368    /// * `request` - No description provided.
2369    /// * `name` - Required. The trial name.
2370    pub fn locations_studies_trials_add_measurement(
2371        &self,
2372        request: GoogleCloudMlV1__AddTrialMeasurementRequest,
2373        name: &str,
2374    ) -> ProjectLocationStudyTrialAddMeasurementCall<'a, C> {
2375        ProjectLocationStudyTrialAddMeasurementCall {
2376            hub: self.hub,
2377            _request: request,
2378            _name: name.to_string(),
2379            _delegate: Default::default(),
2380            _additional_params: Default::default(),
2381            _scopes: Default::default(),
2382        }
2383    }
2384
2385    /// Create a builder to help you perform the following task:
2386    ///
2387    /// Checks whether a trial should stop or not. Returns a long-running operation. When the operation is successful, it will contain a CheckTrialEarlyStoppingStateResponse.
2388    ///
2389    /// # Arguments
2390    ///
2391    /// * `request` - No description provided.
2392    /// * `name` - Required. The trial name.
2393    pub fn locations_studies_trials_check_early_stopping_state(
2394        &self,
2395        request: GoogleCloudMlV1__CheckTrialEarlyStoppingStateRequest,
2396        name: &str,
2397    ) -> ProjectLocationStudyTrialCheckEarlyStoppingStateCall<'a, C> {
2398        ProjectLocationStudyTrialCheckEarlyStoppingStateCall {
2399            hub: self.hub,
2400            _request: request,
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    /// Marks a trial as complete.
2411    ///
2412    /// # Arguments
2413    ///
2414    /// * `request` - No description provided.
2415    /// * `name` - Required. The trial name.metat
2416    pub fn locations_studies_trials_complete(
2417        &self,
2418        request: GoogleCloudMlV1__CompleteTrialRequest,
2419        name: &str,
2420    ) -> ProjectLocationStudyTrialCompleteCall<'a, C> {
2421        ProjectLocationStudyTrialCompleteCall {
2422            hub: self.hub,
2423            _request: request,
2424            _name: name.to_string(),
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    /// Adds a user provided trial to a study.
2434    ///
2435    /// # Arguments
2436    ///
2437    /// * `request` - No description provided.
2438    /// * `parent` - Required. The name of the study that the trial belongs to.
2439    pub fn locations_studies_trials_create(
2440        &self,
2441        request: GoogleCloudMlV1__Trial,
2442        parent: &str,
2443    ) -> ProjectLocationStudyTrialCreateCall<'a, C> {
2444        ProjectLocationStudyTrialCreateCall {
2445            hub: self.hub,
2446            _request: request,
2447            _parent: parent.to_string(),
2448            _delegate: Default::default(),
2449            _additional_params: Default::default(),
2450            _scopes: Default::default(),
2451        }
2452    }
2453
2454    /// Create a builder to help you perform the following task:
2455    ///
2456    /// Deletes a trial.
2457    ///
2458    /// # Arguments
2459    ///
2460    /// * `name` - Required. The trial name.
2461    pub fn locations_studies_trials_delete(
2462        &self,
2463        name: &str,
2464    ) -> ProjectLocationStudyTrialDeleteCall<'a, C> {
2465        ProjectLocationStudyTrialDeleteCall {
2466            hub: self.hub,
2467            _name: name.to_string(),
2468            _delegate: Default::default(),
2469            _additional_params: Default::default(),
2470            _scopes: Default::default(),
2471        }
2472    }
2473
2474    /// Create a builder to help you perform the following task:
2475    ///
2476    /// Gets a trial.
2477    ///
2478    /// # Arguments
2479    ///
2480    /// * `name` - Required. The trial name.
2481    pub fn locations_studies_trials_get(
2482        &self,
2483        name: &str,
2484    ) -> ProjectLocationStudyTrialGetCall<'a, C> {
2485        ProjectLocationStudyTrialGetCall {
2486            hub: self.hub,
2487            _name: name.to_string(),
2488            _delegate: Default::default(),
2489            _additional_params: Default::default(),
2490            _scopes: Default::default(),
2491        }
2492    }
2493
2494    /// Create a builder to help you perform the following task:
2495    ///
2496    /// Lists the trials associated with a study.
2497    ///
2498    /// # Arguments
2499    ///
2500    /// * `parent` - Required. The name of the study that the trial belongs to.
2501    pub fn locations_studies_trials_list(
2502        &self,
2503        parent: &str,
2504    ) -> ProjectLocationStudyTrialListCall<'a, C> {
2505        ProjectLocationStudyTrialListCall {
2506            hub: self.hub,
2507            _parent: parent.to_string(),
2508            _delegate: Default::default(),
2509            _additional_params: Default::default(),
2510            _scopes: Default::default(),
2511        }
2512    }
2513
2514    /// Create a builder to help you perform the following task:
2515    ///
2516    /// Lists the pareto-optimal trials for multi-objective study or the optimal trials for single-objective study. The definition of pareto-optimal can be checked in wiki page. https://en.wikipedia.org/wiki/Pareto_efficiency
2517    ///
2518    /// # Arguments
2519    ///
2520    /// * `request` - No description provided.
2521    /// * `parent` - Required. The name of the study that the pareto-optimal trial belongs to.
2522    pub fn locations_studies_trials_list_optimal_trials(
2523        &self,
2524        request: GoogleCloudMlV1__ListOptimalTrialsRequest,
2525        parent: &str,
2526    ) -> ProjectLocationStudyTrialListOptimalTrialCall<'a, C> {
2527        ProjectLocationStudyTrialListOptimalTrialCall {
2528            hub: self.hub,
2529            _request: request,
2530            _parent: parent.to_string(),
2531            _delegate: Default::default(),
2532            _additional_params: Default::default(),
2533            _scopes: Default::default(),
2534        }
2535    }
2536
2537    /// Create a builder to help you perform the following task:
2538    ///
2539    /// Stops a trial.
2540    ///
2541    /// # Arguments
2542    ///
2543    /// * `request` - No description provided.
2544    /// * `name` - Required. The trial name.
2545    pub fn locations_studies_trials_stop(
2546        &self,
2547        request: GoogleCloudMlV1__StopTrialRequest,
2548        name: &str,
2549    ) -> ProjectLocationStudyTrialStopCall<'a, C> {
2550        ProjectLocationStudyTrialStopCall {
2551            hub: self.hub,
2552            _request: request,
2553            _name: name.to_string(),
2554            _delegate: Default::default(),
2555            _additional_params: Default::default(),
2556            _scopes: Default::default(),
2557        }
2558    }
2559
2560    /// Create a builder to help you perform the following task:
2561    ///
2562    /// Adds one or more trials to a study, with parameter values suggested by AI Platform Vizier. Returns a long-running operation associated with the generation of trial suggestions. When this long-running operation succeeds, it will contain a SuggestTrialsResponse.
2563    ///
2564    /// # Arguments
2565    ///
2566    /// * `request` - No description provided.
2567    /// * `parent` - Required. The name of the study that the trial belongs to.
2568    pub fn locations_studies_trials_suggest(
2569        &self,
2570        request: GoogleCloudMlV1__SuggestTrialsRequest,
2571        parent: &str,
2572    ) -> ProjectLocationStudyTrialSuggestCall<'a, C> {
2573        ProjectLocationStudyTrialSuggestCall {
2574            hub: self.hub,
2575            _request: request,
2576            _parent: parent.to_string(),
2577            _delegate: Default::default(),
2578            _additional_params: Default::default(),
2579            _scopes: Default::default(),
2580        }
2581    }
2582
2583    /// Create a builder to help you perform the following task:
2584    ///
2585    /// Creates a study.
2586    ///
2587    /// # Arguments
2588    ///
2589    /// * `request` - No description provided.
2590    /// * `parent` - Required. The project and location that the study belongs to. Format: projects/{project}/locations/{location}
2591    pub fn locations_studies_create(
2592        &self,
2593        request: GoogleCloudMlV1__Study,
2594        parent: &str,
2595    ) -> ProjectLocationStudyCreateCall<'a, C> {
2596        ProjectLocationStudyCreateCall {
2597            hub: self.hub,
2598            _request: request,
2599            _parent: parent.to_string(),
2600            _study_id: Default::default(),
2601            _delegate: Default::default(),
2602            _additional_params: Default::default(),
2603            _scopes: Default::default(),
2604        }
2605    }
2606
2607    /// Create a builder to help you perform the following task:
2608    ///
2609    /// Deletes a study.
2610    ///
2611    /// # Arguments
2612    ///
2613    /// * `name` - Required. The study name.
2614    pub fn locations_studies_delete(&self, name: &str) -> ProjectLocationStudyDeleteCall<'a, C> {
2615        ProjectLocationStudyDeleteCall {
2616            hub: self.hub,
2617            _name: name.to_string(),
2618            _delegate: Default::default(),
2619            _additional_params: Default::default(),
2620            _scopes: Default::default(),
2621        }
2622    }
2623
2624    /// Create a builder to help you perform the following task:
2625    ///
2626    /// Gets a study.
2627    ///
2628    /// # Arguments
2629    ///
2630    /// * `name` - Required. The study name.
2631    pub fn locations_studies_get(&self, name: &str) -> ProjectLocationStudyGetCall<'a, C> {
2632        ProjectLocationStudyGetCall {
2633            hub: self.hub,
2634            _name: name.to_string(),
2635            _delegate: Default::default(),
2636            _additional_params: Default::default(),
2637            _scopes: Default::default(),
2638        }
2639    }
2640
2641    /// Create a builder to help you perform the following task:
2642    ///
2643    /// Lists all the studies in a region for an associated project.
2644    ///
2645    /// # Arguments
2646    ///
2647    /// * `parent` - Required. The project and location that the study belongs to. Format: projects/{project}/locations/{location}
2648    pub fn locations_studies_list(&self, parent: &str) -> ProjectLocationStudyListCall<'a, C> {
2649        ProjectLocationStudyListCall {
2650            hub: self.hub,
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    /// Get the complete list of CMLE capabilities in a location, along with their location-specific properties.
2661    ///
2662    /// # Arguments
2663    ///
2664    /// * `name` - Required. The name of the location.
2665    pub fn locations_get(&self, name: &str) -> ProjectLocationGetCall<'a, C> {
2666        ProjectLocationGetCall {
2667            hub: self.hub,
2668            _name: name.to_string(),
2669            _delegate: Default::default(),
2670            _additional_params: Default::default(),
2671            _scopes: Default::default(),
2672        }
2673    }
2674
2675    /// Create a builder to help you perform the following task:
2676    ///
2677    /// List all locations that provides at least one type of CMLE capability.
2678    ///
2679    /// # Arguments
2680    ///
2681    /// * `parent` - Required. The name of the project for which available locations are to be listed (since some locations might be whitelisted for specific projects).
2682    pub fn locations_list(&self, parent: &str) -> ProjectLocationListCall<'a, C> {
2683        ProjectLocationListCall {
2684            hub: self.hub,
2685            _parent: parent.to_string(),
2686            _page_token: Default::default(),
2687            _page_size: Default::default(),
2688            _delegate: Default::default(),
2689            _additional_params: Default::default(),
2690            _scopes: Default::default(),
2691        }
2692    }
2693
2694    /// Create a builder to help you perform the following task:
2695    ///
2696    /// Creates a new version of a model from a trained TensorFlow model. If the version created in the cloud by this call is the first deployed version of the specified model, it will be made the default version of the model. When you add a version to a model that already has one or more versions, the default version does not automatically change. If you want a new version to be the default, you must call projects.models.versions.setDefault.
2697    ///
2698    /// # Arguments
2699    ///
2700    /// * `request` - No description provided.
2701    /// * `parent` - Required. The name of the model.
2702    pub fn models_versions_create(
2703        &self,
2704        request: GoogleCloudMlV1__Version,
2705        parent: &str,
2706    ) -> ProjectModelVersionCreateCall<'a, C> {
2707        ProjectModelVersionCreateCall {
2708            hub: self.hub,
2709            _request: request,
2710            _parent: parent.to_string(),
2711            _delegate: Default::default(),
2712            _additional_params: Default::default(),
2713            _scopes: Default::default(),
2714        }
2715    }
2716
2717    /// Create a builder to help you perform the following task:
2718    ///
2719    /// Deletes a model version. Each model can have multiple versions deployed and in use at any given time. Use this method to remove a single version. Note: You cannot delete the version that is set as the default version of the model unless it is the only remaining version.
2720    ///
2721    /// # Arguments
2722    ///
2723    /// * `name` - Required. The name of the version. You can get the names of all the versions of a model by calling projects.models.versions.list.
2724    pub fn models_versions_delete(&self, name: &str) -> ProjectModelVersionDeleteCall<'a, C> {
2725        ProjectModelVersionDeleteCall {
2726            hub: self.hub,
2727            _name: name.to_string(),
2728            _delegate: Default::default(),
2729            _additional_params: Default::default(),
2730            _scopes: Default::default(),
2731        }
2732    }
2733
2734    /// Create a builder to help you perform the following task:
2735    ///
2736    /// Gets information about a model version. Models can have multiple versions. You can call projects.models.versions.list to get the same information that this method returns for all of the versions of a model.
2737    ///
2738    /// # Arguments
2739    ///
2740    /// * `name` - Required. The name of the version.
2741    pub fn models_versions_get(&self, name: &str) -> ProjectModelVersionGetCall<'a, C> {
2742        ProjectModelVersionGetCall {
2743            hub: self.hub,
2744            _name: name.to_string(),
2745            _delegate: Default::default(),
2746            _additional_params: Default::default(),
2747            _scopes: Default::default(),
2748        }
2749    }
2750
2751    /// Create a builder to help you perform the following task:
2752    ///
2753    /// Gets basic information about all the versions of a model. If you expect that a model has many versions, or if you need to handle only a limited number of results at a time, you can request that the list be retrieved in batches (called pages). If there are no versions that match the request parameters, the list request returns an empty response body: {}.
2754    ///
2755    /// # Arguments
2756    ///
2757    /// * `parent` - Required. The name of the model for which to list the version.
2758    pub fn models_versions_list(&self, parent: &str) -> ProjectModelVersionListCall<'a, C> {
2759        ProjectModelVersionListCall {
2760            hub: self.hub,
2761            _parent: parent.to_string(),
2762            _page_token: Default::default(),
2763            _page_size: Default::default(),
2764            _filter: Default::default(),
2765            _delegate: Default::default(),
2766            _additional_params: Default::default(),
2767            _scopes: Default::default(),
2768        }
2769    }
2770
2771    /// Create a builder to help you perform the following task:
2772    ///
2773    /// Updates the specified Version resource. Currently the only update-able fields are `description`, `requestLoggingConfig`, `autoScaling.minNodes`, and `manualScaling.nodes`.
2774    ///
2775    /// # Arguments
2776    ///
2777    /// * `request` - No description provided.
2778    /// * `name` - Required. The name of the model.
2779    pub fn models_versions_patch(
2780        &self,
2781        request: GoogleCloudMlV1__Version,
2782        name: &str,
2783    ) -> ProjectModelVersionPatchCall<'a, C> {
2784        ProjectModelVersionPatchCall {
2785            hub: self.hub,
2786            _request: request,
2787            _name: name.to_string(),
2788            _update_mask: Default::default(),
2789            _delegate: Default::default(),
2790            _additional_params: Default::default(),
2791            _scopes: Default::default(),
2792        }
2793    }
2794
2795    /// Create a builder to help you perform the following task:
2796    ///
2797    /// Designates a version to be the default for the model. The default version is used for prediction requests made against the model that don't specify a version. The first version to be created for a model is automatically set as the default. You must make any subsequent changes to the default version setting manually using this method.
2798    ///
2799    /// # Arguments
2800    ///
2801    /// * `request` - No description provided.
2802    /// * `name` - Required. The name of the version to make the default for the model. You can get the names of all the versions of a model by calling projects.models.versions.list.
2803    pub fn models_versions_set_default(
2804        &self,
2805        request: GoogleCloudMlV1__SetDefaultVersionRequest,
2806        name: &str,
2807    ) -> ProjectModelVersionSetDefaultCall<'a, C> {
2808        ProjectModelVersionSetDefaultCall {
2809            hub: self.hub,
2810            _request: request,
2811            _name: name.to_string(),
2812            _delegate: Default::default(),
2813            _additional_params: Default::default(),
2814            _scopes: Default::default(),
2815        }
2816    }
2817
2818    /// Create a builder to help you perform the following task:
2819    ///
2820    /// Creates a model which will later contain one or more versions. You must add at least one version before you can request predictions from the model. Add versions by calling projects.models.versions.create.
2821    ///
2822    /// # Arguments
2823    ///
2824    /// * `request` - No description provided.
2825    /// * `parent` - Required. The project name.
2826    pub fn models_create(
2827        &self,
2828        request: GoogleCloudMlV1__Model,
2829        parent: &str,
2830    ) -> ProjectModelCreateCall<'a, C> {
2831        ProjectModelCreateCall {
2832            hub: self.hub,
2833            _request: request,
2834            _parent: parent.to_string(),
2835            _delegate: Default::default(),
2836            _additional_params: Default::default(),
2837            _scopes: Default::default(),
2838        }
2839    }
2840
2841    /// Create a builder to help you perform the following task:
2842    ///
2843    /// Deletes a model. You can only delete a model if there are no versions in it. You can delete versions by calling projects.models.versions.delete.
2844    ///
2845    /// # Arguments
2846    ///
2847    /// * `name` - Required. The name of the model.
2848    pub fn models_delete(&self, name: &str) -> ProjectModelDeleteCall<'a, C> {
2849        ProjectModelDeleteCall {
2850            hub: self.hub,
2851            _name: name.to_string(),
2852            _delegate: Default::default(),
2853            _additional_params: Default::default(),
2854            _scopes: Default::default(),
2855        }
2856    }
2857
2858    /// Create a builder to help you perform the following task:
2859    ///
2860    /// Gets information about a model, including its name, the description (if set), and the default version (if at least one version of the model has been deployed).
2861    ///
2862    /// # Arguments
2863    ///
2864    /// * `name` - Required. The name of the model.
2865    pub fn models_get(&self, name: &str) -> ProjectModelGetCall<'a, C> {
2866        ProjectModelGetCall {
2867            hub: self.hub,
2868            _name: name.to_string(),
2869            _delegate: Default::default(),
2870            _additional_params: Default::default(),
2871            _scopes: Default::default(),
2872        }
2873    }
2874
2875    /// Create a builder to help you perform the following task:
2876    ///
2877    /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
2878    ///
2879    /// # Arguments
2880    ///
2881    /// * `resource` - REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
2882    pub fn models_get_iam_policy(&self, resource: &str) -> ProjectModelGetIamPolicyCall<'a, C> {
2883        ProjectModelGetIamPolicyCall {
2884            hub: self.hub,
2885            _resource: resource.to_string(),
2886            _options_requested_policy_version: Default::default(),
2887            _delegate: Default::default(),
2888            _additional_params: Default::default(),
2889            _scopes: Default::default(),
2890        }
2891    }
2892
2893    /// Create a builder to help you perform the following task:
2894    ///
2895    /// Lists the models in a project. Each project can contain multiple models, and each model can have multiple versions. If there are no models that match the request parameters, the list request returns an empty response body: {}.
2896    ///
2897    /// # Arguments
2898    ///
2899    /// * `parent` - Required. The name of the project whose models are to be listed.
2900    pub fn models_list(&self, parent: &str) -> ProjectModelListCall<'a, C> {
2901        ProjectModelListCall {
2902            hub: self.hub,
2903            _parent: parent.to_string(),
2904            _page_token: Default::default(),
2905            _page_size: Default::default(),
2906            _filter: Default::default(),
2907            _delegate: Default::default(),
2908            _additional_params: Default::default(),
2909            _scopes: Default::default(),
2910        }
2911    }
2912
2913    /// Create a builder to help you perform the following task:
2914    ///
2915    /// Updates a specific model resource. Currently the only supported fields to update are `description` and `default_version.name`.
2916    ///
2917    /// # Arguments
2918    ///
2919    /// * `request` - No description provided.
2920    /// * `name` - Required. The project name.
2921    pub fn models_patch(
2922        &self,
2923        request: GoogleCloudMlV1__Model,
2924        name: &str,
2925    ) -> ProjectModelPatchCall<'a, C> {
2926        ProjectModelPatchCall {
2927            hub: self.hub,
2928            _request: request,
2929            _name: name.to_string(),
2930            _update_mask: Default::default(),
2931            _delegate: Default::default(),
2932            _additional_params: Default::default(),
2933            _scopes: Default::default(),
2934        }
2935    }
2936
2937    /// Create a builder to help you perform the following task:
2938    ///
2939    /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
2940    ///
2941    /// # Arguments
2942    ///
2943    /// * `request` - No description provided.
2944    /// * `resource` - REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
2945    pub fn models_set_iam_policy(
2946        &self,
2947        request: GoogleIamV1__SetIamPolicyRequest,
2948        resource: &str,
2949    ) -> ProjectModelSetIamPolicyCall<'a, C> {
2950        ProjectModelSetIamPolicyCall {
2951            hub: self.hub,
2952            _request: request,
2953            _resource: resource.to_string(),
2954            _delegate: Default::default(),
2955            _additional_params: Default::default(),
2956            _scopes: Default::default(),
2957        }
2958    }
2959
2960    /// Create a builder to help you perform the following task:
2961    ///
2962    /// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
2963    ///
2964    /// # Arguments
2965    ///
2966    /// * `request` - No description provided.
2967    /// * `resource` - REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
2968    pub fn models_test_iam_permissions(
2969        &self,
2970        request: GoogleIamV1__TestIamPermissionsRequest,
2971        resource: &str,
2972    ) -> ProjectModelTestIamPermissionCall<'a, C> {
2973        ProjectModelTestIamPermissionCall {
2974            hub: self.hub,
2975            _request: request,
2976            _resource: resource.to_string(),
2977            _delegate: Default::default(),
2978            _additional_params: Default::default(),
2979            _scopes: Default::default(),
2980        }
2981    }
2982
2983    /// Create a builder to help you perform the following task:
2984    ///
2985    /// 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`.
2986    ///
2987    /// # Arguments
2988    ///
2989    /// * `name` - The name of the operation resource to be cancelled.
2990    pub fn operations_cancel(&self, name: &str) -> ProjectOperationCancelCall<'a, C> {
2991        ProjectOperationCancelCall {
2992            hub: self.hub,
2993            _name: name.to_string(),
2994            _delegate: Default::default(),
2995            _additional_params: Default::default(),
2996            _scopes: Default::default(),
2997        }
2998    }
2999
3000    /// Create a builder to help you perform the following task:
3001    ///
3002    /// 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.
3003    ///
3004    /// # Arguments
3005    ///
3006    /// * `name` - The name of the operation resource.
3007    pub fn operations_get(&self, name: &str) -> ProjectOperationGetCall<'a, C> {
3008        ProjectOperationGetCall {
3009            hub: self.hub,
3010            _name: name.to_string(),
3011            _delegate: Default::default(),
3012            _additional_params: Default::default(),
3013            _scopes: Default::default(),
3014        }
3015    }
3016
3017    /// Create a builder to help you perform the following task:
3018    ///
3019    /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
3020    ///
3021    /// # Arguments
3022    ///
3023    /// * `name` - The name of the operation's parent resource.
3024    pub fn operations_list(&self, name: &str) -> ProjectOperationListCall<'a, C> {
3025        ProjectOperationListCall {
3026            hub: self.hub,
3027            _name: name.to_string(),
3028            _page_token: Default::default(),
3029            _page_size: Default::default(),
3030            _filter: Default::default(),
3031            _delegate: Default::default(),
3032            _additional_params: Default::default(),
3033            _scopes: Default::default(),
3034        }
3035    }
3036
3037    /// Create a builder to help you perform the following task:
3038    ///
3039    /// Performs explanation on the data in the request. {% dynamic include "/ai-platform/includes/___explain-request" %}
3040    ///
3041    /// # Arguments
3042    ///
3043    /// * `request` - No description provided.
3044    /// * `name` - Required. The resource name of a model or a version. Authorization: requires the `predict` permission on the specified resource.
3045    pub fn explain(
3046        &self,
3047        request: GoogleCloudMlV1__ExplainRequest,
3048        name: &str,
3049    ) -> ProjectExplainCall<'a, C> {
3050        ProjectExplainCall {
3051            hub: self.hub,
3052            _request: request,
3053            _name: name.to_string(),
3054            _delegate: Default::default(),
3055            _additional_params: Default::default(),
3056            _scopes: Default::default(),
3057        }
3058    }
3059
3060    /// Create a builder to help you perform the following task:
3061    ///
3062    /// Get the service account information associated with your project. You need this information in order to grant the service account permissions for the Google Cloud Storage location where you put your model training code for training the model with Google Cloud Machine Learning.
3063    ///
3064    /// # Arguments
3065    ///
3066    /// * `name` - Required. The project name.
3067    pub fn get_config(&self, name: &str) -> ProjectGetConfigCall<'a, C> {
3068        ProjectGetConfigCall {
3069            hub: self.hub,
3070            _name: name.to_string(),
3071            _delegate: Default::default(),
3072            _additional_params: Default::default(),
3073            _scopes: Default::default(),
3074        }
3075    }
3076
3077    /// Create a builder to help you perform the following task:
3078    ///
3079    /// Performs online prediction on the data in the request. {% dynamic include "/ai-platform/includes/___predict-request" %}
3080    ///
3081    /// # Arguments
3082    ///
3083    /// * `request` - No description provided.
3084    /// * `name` - Required. The resource name of a model or a version. Authorization: requires the `predict` permission on the specified resource.
3085    pub fn predict(
3086        &self,
3087        request: GoogleCloudMlV1__PredictRequest,
3088        name: &str,
3089    ) -> ProjectPredictCall<'a, C> {
3090        ProjectPredictCall {
3091            hub: self.hub,
3092            _request: request,
3093            _name: name.to_string(),
3094            _delegate: Default::default(),
3095            _additional_params: Default::default(),
3096            _scopes: Default::default(),
3097        }
3098    }
3099}
3100
3101// ###################
3102// CallBuilders   ###
3103// #################
3104
3105/// Cancels a running job.
3106///
3107/// A builder for the *jobs.cancel* method supported by a *project* resource.
3108/// It is not used directly, but through a [`ProjectMethods`] instance.
3109///
3110/// # Example
3111///
3112/// Instantiate a resource method builder
3113///
3114/// ```test_harness,no_run
3115/// # extern crate hyper;
3116/// # extern crate hyper_rustls;
3117/// # extern crate google_ml1 as ml1;
3118/// use ml1::api::GoogleCloudMlV1__CancelJobRequest;
3119/// # async fn dox() {
3120/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3121///
3122/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3123/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3124/// #     .with_native_roots()
3125/// #     .unwrap()
3126/// #     .https_only()
3127/// #     .enable_http2()
3128/// #     .build();
3129///
3130/// # let executor = hyper_util::rt::TokioExecutor::new();
3131/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3132/// #     secret,
3133/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3134/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3135/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3136/// #     ),
3137/// # ).build().await.unwrap();
3138///
3139/// # let client = hyper_util::client::legacy::Client::builder(
3140/// #     hyper_util::rt::TokioExecutor::new()
3141/// # )
3142/// # .build(
3143/// #     hyper_rustls::HttpsConnectorBuilder::new()
3144/// #         .with_native_roots()
3145/// #         .unwrap()
3146/// #         .https_or_http()
3147/// #         .enable_http2()
3148/// #         .build()
3149/// # );
3150/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
3151/// // As the method needs a request, you would usually fill it with the desired information
3152/// // into the respective structure. Some of the parts shown here might not be applicable !
3153/// // Values shown here are possibly random and not representative !
3154/// let mut req = GoogleCloudMlV1__CancelJobRequest::default();
3155///
3156/// // You can configure optional parameters by calling the respective setters at will, and
3157/// // execute the final call using `doit()`.
3158/// // Values shown here are possibly random and not representative !
3159/// let result = hub.projects().jobs_cancel(req, "name")
3160///              .doit().await;
3161/// # }
3162/// ```
3163pub struct ProjectJobCancelCall<'a, C>
3164where
3165    C: 'a,
3166{
3167    hub: &'a CloudMachineLearningEngine<C>,
3168    _request: GoogleCloudMlV1__CancelJobRequest,
3169    _name: String,
3170    _delegate: Option<&'a mut dyn common::Delegate>,
3171    _additional_params: HashMap<String, String>,
3172    _scopes: BTreeSet<String>,
3173}
3174
3175impl<'a, C> common::CallBuilder for ProjectJobCancelCall<'a, C> {}
3176
3177impl<'a, C> ProjectJobCancelCall<'a, C>
3178where
3179    C: common::Connector,
3180{
3181    /// Perform the operation you have build so far.
3182    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleProtobuf__Empty)> {
3183        use std::borrow::Cow;
3184        use std::io::{Read, Seek};
3185
3186        use common::{url::Params, ToParts};
3187        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3188
3189        let mut dd = common::DefaultDelegate;
3190        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3191        dlg.begin(common::MethodInfo {
3192            id: "ml.projects.jobs.cancel",
3193            http_method: hyper::Method::POST,
3194        });
3195
3196        for &field in ["alt", "name"].iter() {
3197            if self._additional_params.contains_key(field) {
3198                dlg.finished(false);
3199                return Err(common::Error::FieldClash(field));
3200            }
3201        }
3202
3203        let mut params = Params::with_capacity(4 + self._additional_params.len());
3204        params.push("name", self._name);
3205
3206        params.extend(self._additional_params.iter());
3207
3208        params.push("alt", "json");
3209        let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
3210        if self._scopes.is_empty() {
3211            self._scopes
3212                .insert(Scope::CloudPlatform.as_ref().to_string());
3213        }
3214
3215        #[allow(clippy::single_element_loop)]
3216        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3217            url = params.uri_replacement(url, param_name, find_this, true);
3218        }
3219        {
3220            let to_remove = ["name"];
3221            params.remove_params(&to_remove);
3222        }
3223
3224        let url = params.parse_with_url(&url);
3225
3226        let mut json_mime_type = mime::APPLICATION_JSON;
3227        let mut request_value_reader = {
3228            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3229            common::remove_json_null_values(&mut value);
3230            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3231            serde_json::to_writer(&mut dst, &value).unwrap();
3232            dst
3233        };
3234        let request_size = request_value_reader
3235            .seek(std::io::SeekFrom::End(0))
3236            .unwrap();
3237        request_value_reader
3238            .seek(std::io::SeekFrom::Start(0))
3239            .unwrap();
3240
3241        loop {
3242            let token = match self
3243                .hub
3244                .auth
3245                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3246                .await
3247            {
3248                Ok(token) => token,
3249                Err(e) => match dlg.token(e) {
3250                    Ok(token) => token,
3251                    Err(e) => {
3252                        dlg.finished(false);
3253                        return Err(common::Error::MissingToken(e));
3254                    }
3255                },
3256            };
3257            request_value_reader
3258                .seek(std::io::SeekFrom::Start(0))
3259                .unwrap();
3260            let mut req_result = {
3261                let client = &self.hub.client;
3262                dlg.pre_request();
3263                let mut req_builder = hyper::Request::builder()
3264                    .method(hyper::Method::POST)
3265                    .uri(url.as_str())
3266                    .header(USER_AGENT, self.hub._user_agent.clone());
3267
3268                if let Some(token) = token.as_ref() {
3269                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3270                }
3271
3272                let request = req_builder
3273                    .header(CONTENT_TYPE, json_mime_type.to_string())
3274                    .header(CONTENT_LENGTH, request_size as u64)
3275                    .body(common::to_body(
3276                        request_value_reader.get_ref().clone().into(),
3277                    ));
3278
3279                client.request(request.unwrap()).await
3280            };
3281
3282            match req_result {
3283                Err(err) => {
3284                    if let common::Retry::After(d) = dlg.http_error(&err) {
3285                        sleep(d).await;
3286                        continue;
3287                    }
3288                    dlg.finished(false);
3289                    return Err(common::Error::HttpError(err));
3290                }
3291                Ok(res) => {
3292                    let (mut parts, body) = res.into_parts();
3293                    let mut body = common::Body::new(body);
3294                    if !parts.status.is_success() {
3295                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3296                        let error = serde_json::from_str(&common::to_string(&bytes));
3297                        let response = common::to_response(parts, bytes.into());
3298
3299                        if let common::Retry::After(d) =
3300                            dlg.http_failure(&response, error.as_ref().ok())
3301                        {
3302                            sleep(d).await;
3303                            continue;
3304                        }
3305
3306                        dlg.finished(false);
3307
3308                        return Err(match error {
3309                            Ok(value) => common::Error::BadRequest(value),
3310                            _ => common::Error::Failure(response),
3311                        });
3312                    }
3313                    let response = {
3314                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3315                        let encoded = common::to_string(&bytes);
3316                        match serde_json::from_str(&encoded) {
3317                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3318                            Err(error) => {
3319                                dlg.response_json_decode_error(&encoded, &error);
3320                                return Err(common::Error::JsonDecodeError(
3321                                    encoded.to_string(),
3322                                    error,
3323                                ));
3324                            }
3325                        }
3326                    };
3327
3328                    dlg.finished(true);
3329                    return Ok(response);
3330                }
3331            }
3332        }
3333    }
3334
3335    ///
3336    /// Sets the *request* property to the given value.
3337    ///
3338    /// Even though the property as already been set when instantiating this call,
3339    /// we provide this method for API completeness.
3340    pub fn request(
3341        mut self,
3342        new_value: GoogleCloudMlV1__CancelJobRequest,
3343    ) -> ProjectJobCancelCall<'a, C> {
3344        self._request = new_value;
3345        self
3346    }
3347    /// Required. The name of the job to cancel.
3348    ///
3349    /// Sets the *name* path property to the given value.
3350    ///
3351    /// Even though the property as already been set when instantiating this call,
3352    /// we provide this method for API completeness.
3353    pub fn name(mut self, new_value: &str) -> ProjectJobCancelCall<'a, C> {
3354        self._name = new_value.to_string();
3355        self
3356    }
3357    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3358    /// while executing the actual API request.
3359    ///
3360    /// ````text
3361    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3362    /// ````
3363    ///
3364    /// Sets the *delegate* property to the given value.
3365    pub fn delegate(
3366        mut self,
3367        new_value: &'a mut dyn common::Delegate,
3368    ) -> ProjectJobCancelCall<'a, C> {
3369        self._delegate = Some(new_value);
3370        self
3371    }
3372
3373    /// Set any additional parameter of the query string used in the request.
3374    /// It should be used to set parameters which are not yet available through their own
3375    /// setters.
3376    ///
3377    /// Please note that this method must not be used to set any of the known parameters
3378    /// which have their own setter method. If done anyway, the request will fail.
3379    ///
3380    /// # Additional Parameters
3381    ///
3382    /// * *$.xgafv* (query-string) - V1 error format.
3383    /// * *access_token* (query-string) - OAuth access token.
3384    /// * *alt* (query-string) - Data format for response.
3385    /// * *callback* (query-string) - JSONP
3386    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3387    /// * *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.
3388    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3389    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3390    /// * *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.
3391    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3392    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3393    pub fn param<T>(mut self, name: T, value: T) -> ProjectJobCancelCall<'a, C>
3394    where
3395        T: AsRef<str>,
3396    {
3397        self._additional_params
3398            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3399        self
3400    }
3401
3402    /// Identifies the authorization scope for the method you are building.
3403    ///
3404    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3405    /// [`Scope::CloudPlatform`].
3406    ///
3407    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3408    /// tokens for more than one scope.
3409    ///
3410    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3411    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3412    /// sufficient, a read-write scope will do as well.
3413    pub fn add_scope<St>(mut self, scope: St) -> ProjectJobCancelCall<'a, C>
3414    where
3415        St: AsRef<str>,
3416    {
3417        self._scopes.insert(String::from(scope.as_ref()));
3418        self
3419    }
3420    /// Identifies the authorization scope(s) for the method you are building.
3421    ///
3422    /// See [`Self::add_scope()`] for details.
3423    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectJobCancelCall<'a, C>
3424    where
3425        I: IntoIterator<Item = St>,
3426        St: AsRef<str>,
3427    {
3428        self._scopes
3429            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3430        self
3431    }
3432
3433    /// Removes all scopes, and no default scope will be used either.
3434    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3435    /// for details).
3436    pub fn clear_scopes(mut self) -> ProjectJobCancelCall<'a, C> {
3437        self._scopes.clear();
3438        self
3439    }
3440}
3441
3442/// Creates a training or a batch prediction job.
3443///
3444/// A builder for the *jobs.create* method supported by a *project* resource.
3445/// It is not used directly, but through a [`ProjectMethods`] instance.
3446///
3447/// # Example
3448///
3449/// Instantiate a resource method builder
3450///
3451/// ```test_harness,no_run
3452/// # extern crate hyper;
3453/// # extern crate hyper_rustls;
3454/// # extern crate google_ml1 as ml1;
3455/// use ml1::api::GoogleCloudMlV1__Job;
3456/// # async fn dox() {
3457/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3458///
3459/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3460/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3461/// #     .with_native_roots()
3462/// #     .unwrap()
3463/// #     .https_only()
3464/// #     .enable_http2()
3465/// #     .build();
3466///
3467/// # let executor = hyper_util::rt::TokioExecutor::new();
3468/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3469/// #     secret,
3470/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3471/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3472/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3473/// #     ),
3474/// # ).build().await.unwrap();
3475///
3476/// # let client = hyper_util::client::legacy::Client::builder(
3477/// #     hyper_util::rt::TokioExecutor::new()
3478/// # )
3479/// # .build(
3480/// #     hyper_rustls::HttpsConnectorBuilder::new()
3481/// #         .with_native_roots()
3482/// #         .unwrap()
3483/// #         .https_or_http()
3484/// #         .enable_http2()
3485/// #         .build()
3486/// # );
3487/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
3488/// // As the method needs a request, you would usually fill it with the desired information
3489/// // into the respective structure. Some of the parts shown here might not be applicable !
3490/// // Values shown here are possibly random and not representative !
3491/// let mut req = GoogleCloudMlV1__Job::default();
3492///
3493/// // You can configure optional parameters by calling the respective setters at will, and
3494/// // execute the final call using `doit()`.
3495/// // Values shown here are possibly random and not representative !
3496/// let result = hub.projects().jobs_create(req, "parent")
3497///              .doit().await;
3498/// # }
3499/// ```
3500pub struct ProjectJobCreateCall<'a, C>
3501where
3502    C: 'a,
3503{
3504    hub: &'a CloudMachineLearningEngine<C>,
3505    _request: GoogleCloudMlV1__Job,
3506    _parent: String,
3507    _delegate: Option<&'a mut dyn common::Delegate>,
3508    _additional_params: HashMap<String, String>,
3509    _scopes: BTreeSet<String>,
3510}
3511
3512impl<'a, C> common::CallBuilder for ProjectJobCreateCall<'a, C> {}
3513
3514impl<'a, C> ProjectJobCreateCall<'a, C>
3515where
3516    C: common::Connector,
3517{
3518    /// Perform the operation you have build so far.
3519    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleCloudMlV1__Job)> {
3520        use std::borrow::Cow;
3521        use std::io::{Read, Seek};
3522
3523        use common::{url::Params, ToParts};
3524        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3525
3526        let mut dd = common::DefaultDelegate;
3527        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3528        dlg.begin(common::MethodInfo {
3529            id: "ml.projects.jobs.create",
3530            http_method: hyper::Method::POST,
3531        });
3532
3533        for &field in ["alt", "parent"].iter() {
3534            if self._additional_params.contains_key(field) {
3535                dlg.finished(false);
3536                return Err(common::Error::FieldClash(field));
3537            }
3538        }
3539
3540        let mut params = Params::with_capacity(4 + self._additional_params.len());
3541        params.push("parent", self._parent);
3542
3543        params.extend(self._additional_params.iter());
3544
3545        params.push("alt", "json");
3546        let mut url = self.hub._base_url.clone() + "v1/{+parent}/jobs";
3547        if self._scopes.is_empty() {
3548            self._scopes
3549                .insert(Scope::CloudPlatform.as_ref().to_string());
3550        }
3551
3552        #[allow(clippy::single_element_loop)]
3553        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3554            url = params.uri_replacement(url, param_name, find_this, true);
3555        }
3556        {
3557            let to_remove = ["parent"];
3558            params.remove_params(&to_remove);
3559        }
3560
3561        let url = params.parse_with_url(&url);
3562
3563        let mut json_mime_type = mime::APPLICATION_JSON;
3564        let mut request_value_reader = {
3565            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3566            common::remove_json_null_values(&mut value);
3567            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3568            serde_json::to_writer(&mut dst, &value).unwrap();
3569            dst
3570        };
3571        let request_size = request_value_reader
3572            .seek(std::io::SeekFrom::End(0))
3573            .unwrap();
3574        request_value_reader
3575            .seek(std::io::SeekFrom::Start(0))
3576            .unwrap();
3577
3578        loop {
3579            let token = match self
3580                .hub
3581                .auth
3582                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3583                .await
3584            {
3585                Ok(token) => token,
3586                Err(e) => match dlg.token(e) {
3587                    Ok(token) => token,
3588                    Err(e) => {
3589                        dlg.finished(false);
3590                        return Err(common::Error::MissingToken(e));
3591                    }
3592                },
3593            };
3594            request_value_reader
3595                .seek(std::io::SeekFrom::Start(0))
3596                .unwrap();
3597            let mut req_result = {
3598                let client = &self.hub.client;
3599                dlg.pre_request();
3600                let mut req_builder = hyper::Request::builder()
3601                    .method(hyper::Method::POST)
3602                    .uri(url.as_str())
3603                    .header(USER_AGENT, self.hub._user_agent.clone());
3604
3605                if let Some(token) = token.as_ref() {
3606                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3607                }
3608
3609                let request = req_builder
3610                    .header(CONTENT_TYPE, json_mime_type.to_string())
3611                    .header(CONTENT_LENGTH, request_size as u64)
3612                    .body(common::to_body(
3613                        request_value_reader.get_ref().clone().into(),
3614                    ));
3615
3616                client.request(request.unwrap()).await
3617            };
3618
3619            match req_result {
3620                Err(err) => {
3621                    if let common::Retry::After(d) = dlg.http_error(&err) {
3622                        sleep(d).await;
3623                        continue;
3624                    }
3625                    dlg.finished(false);
3626                    return Err(common::Error::HttpError(err));
3627                }
3628                Ok(res) => {
3629                    let (mut parts, body) = res.into_parts();
3630                    let mut body = common::Body::new(body);
3631                    if !parts.status.is_success() {
3632                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3633                        let error = serde_json::from_str(&common::to_string(&bytes));
3634                        let response = common::to_response(parts, bytes.into());
3635
3636                        if let common::Retry::After(d) =
3637                            dlg.http_failure(&response, error.as_ref().ok())
3638                        {
3639                            sleep(d).await;
3640                            continue;
3641                        }
3642
3643                        dlg.finished(false);
3644
3645                        return Err(match error {
3646                            Ok(value) => common::Error::BadRequest(value),
3647                            _ => common::Error::Failure(response),
3648                        });
3649                    }
3650                    let response = {
3651                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3652                        let encoded = common::to_string(&bytes);
3653                        match serde_json::from_str(&encoded) {
3654                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3655                            Err(error) => {
3656                                dlg.response_json_decode_error(&encoded, &error);
3657                                return Err(common::Error::JsonDecodeError(
3658                                    encoded.to_string(),
3659                                    error,
3660                                ));
3661                            }
3662                        }
3663                    };
3664
3665                    dlg.finished(true);
3666                    return Ok(response);
3667                }
3668            }
3669        }
3670    }
3671
3672    ///
3673    /// Sets the *request* property to the given value.
3674    ///
3675    /// Even though the property as already been set when instantiating this call,
3676    /// we provide this method for API completeness.
3677    pub fn request(mut self, new_value: GoogleCloudMlV1__Job) -> ProjectJobCreateCall<'a, C> {
3678        self._request = new_value;
3679        self
3680    }
3681    /// Required. The project name.
3682    ///
3683    /// Sets the *parent* path property to the given value.
3684    ///
3685    /// Even though the property as already been set when instantiating this call,
3686    /// we provide this method for API completeness.
3687    pub fn parent(mut self, new_value: &str) -> ProjectJobCreateCall<'a, C> {
3688        self._parent = new_value.to_string();
3689        self
3690    }
3691    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3692    /// while executing the actual API request.
3693    ///
3694    /// ````text
3695    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3696    /// ````
3697    ///
3698    /// Sets the *delegate* property to the given value.
3699    pub fn delegate(
3700        mut self,
3701        new_value: &'a mut dyn common::Delegate,
3702    ) -> ProjectJobCreateCall<'a, C> {
3703        self._delegate = Some(new_value);
3704        self
3705    }
3706
3707    /// Set any additional parameter of the query string used in the request.
3708    /// It should be used to set parameters which are not yet available through their own
3709    /// setters.
3710    ///
3711    /// Please note that this method must not be used to set any of the known parameters
3712    /// which have their own setter method. If done anyway, the request will fail.
3713    ///
3714    /// # Additional Parameters
3715    ///
3716    /// * *$.xgafv* (query-string) - V1 error format.
3717    /// * *access_token* (query-string) - OAuth access token.
3718    /// * *alt* (query-string) - Data format for response.
3719    /// * *callback* (query-string) - JSONP
3720    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3721    /// * *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.
3722    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3723    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3724    /// * *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.
3725    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3726    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3727    pub fn param<T>(mut self, name: T, value: T) -> ProjectJobCreateCall<'a, C>
3728    where
3729        T: AsRef<str>,
3730    {
3731        self._additional_params
3732            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3733        self
3734    }
3735
3736    /// Identifies the authorization scope for the method you are building.
3737    ///
3738    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3739    /// [`Scope::CloudPlatform`].
3740    ///
3741    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3742    /// tokens for more than one scope.
3743    ///
3744    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3745    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3746    /// sufficient, a read-write scope will do as well.
3747    pub fn add_scope<St>(mut self, scope: St) -> ProjectJobCreateCall<'a, C>
3748    where
3749        St: AsRef<str>,
3750    {
3751        self._scopes.insert(String::from(scope.as_ref()));
3752        self
3753    }
3754    /// Identifies the authorization scope(s) for the method you are building.
3755    ///
3756    /// See [`Self::add_scope()`] for details.
3757    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectJobCreateCall<'a, C>
3758    where
3759        I: IntoIterator<Item = St>,
3760        St: AsRef<str>,
3761    {
3762        self._scopes
3763            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3764        self
3765    }
3766
3767    /// Removes all scopes, and no default scope will be used either.
3768    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3769    /// for details).
3770    pub fn clear_scopes(mut self) -> ProjectJobCreateCall<'a, C> {
3771        self._scopes.clear();
3772        self
3773    }
3774}
3775
3776/// Describes a job.
3777///
3778/// A builder for the *jobs.get* method supported by a *project* resource.
3779/// It is not used directly, but through a [`ProjectMethods`] instance.
3780///
3781/// # Example
3782///
3783/// Instantiate a resource method builder
3784///
3785/// ```test_harness,no_run
3786/// # extern crate hyper;
3787/// # extern crate hyper_rustls;
3788/// # extern crate google_ml1 as ml1;
3789/// # async fn dox() {
3790/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3791///
3792/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3793/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3794/// #     .with_native_roots()
3795/// #     .unwrap()
3796/// #     .https_only()
3797/// #     .enable_http2()
3798/// #     .build();
3799///
3800/// # let executor = hyper_util::rt::TokioExecutor::new();
3801/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3802/// #     secret,
3803/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3804/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3805/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3806/// #     ),
3807/// # ).build().await.unwrap();
3808///
3809/// # let client = hyper_util::client::legacy::Client::builder(
3810/// #     hyper_util::rt::TokioExecutor::new()
3811/// # )
3812/// # .build(
3813/// #     hyper_rustls::HttpsConnectorBuilder::new()
3814/// #         .with_native_roots()
3815/// #         .unwrap()
3816/// #         .https_or_http()
3817/// #         .enable_http2()
3818/// #         .build()
3819/// # );
3820/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
3821/// // You can configure optional parameters by calling the respective setters at will, and
3822/// // execute the final call using `doit()`.
3823/// // Values shown here are possibly random and not representative !
3824/// let result = hub.projects().jobs_get("name")
3825///              .doit().await;
3826/// # }
3827/// ```
3828pub struct ProjectJobGetCall<'a, C>
3829where
3830    C: 'a,
3831{
3832    hub: &'a CloudMachineLearningEngine<C>,
3833    _name: String,
3834    _delegate: Option<&'a mut dyn common::Delegate>,
3835    _additional_params: HashMap<String, String>,
3836    _scopes: BTreeSet<String>,
3837}
3838
3839impl<'a, C> common::CallBuilder for ProjectJobGetCall<'a, C> {}
3840
3841impl<'a, C> ProjectJobGetCall<'a, C>
3842where
3843    C: common::Connector,
3844{
3845    /// Perform the operation you have build so far.
3846    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleCloudMlV1__Job)> {
3847        use std::borrow::Cow;
3848        use std::io::{Read, Seek};
3849
3850        use common::{url::Params, ToParts};
3851        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3852
3853        let mut dd = common::DefaultDelegate;
3854        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3855        dlg.begin(common::MethodInfo {
3856            id: "ml.projects.jobs.get",
3857            http_method: hyper::Method::GET,
3858        });
3859
3860        for &field in ["alt", "name"].iter() {
3861            if self._additional_params.contains_key(field) {
3862                dlg.finished(false);
3863                return Err(common::Error::FieldClash(field));
3864            }
3865        }
3866
3867        let mut params = Params::with_capacity(3 + self._additional_params.len());
3868        params.push("name", self._name);
3869
3870        params.extend(self._additional_params.iter());
3871
3872        params.push("alt", "json");
3873        let mut url = self.hub._base_url.clone() + "v1/{+name}";
3874        if self._scopes.is_empty() {
3875            self._scopes
3876                .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
3877        }
3878
3879        #[allow(clippy::single_element_loop)]
3880        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3881            url = params.uri_replacement(url, param_name, find_this, true);
3882        }
3883        {
3884            let to_remove = ["name"];
3885            params.remove_params(&to_remove);
3886        }
3887
3888        let url = params.parse_with_url(&url);
3889
3890        loop {
3891            let token = match self
3892                .hub
3893                .auth
3894                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3895                .await
3896            {
3897                Ok(token) => token,
3898                Err(e) => match dlg.token(e) {
3899                    Ok(token) => token,
3900                    Err(e) => {
3901                        dlg.finished(false);
3902                        return Err(common::Error::MissingToken(e));
3903                    }
3904                },
3905            };
3906            let mut req_result = {
3907                let client = &self.hub.client;
3908                dlg.pre_request();
3909                let mut req_builder = hyper::Request::builder()
3910                    .method(hyper::Method::GET)
3911                    .uri(url.as_str())
3912                    .header(USER_AGENT, self.hub._user_agent.clone());
3913
3914                if let Some(token) = token.as_ref() {
3915                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3916                }
3917
3918                let request = req_builder
3919                    .header(CONTENT_LENGTH, 0_u64)
3920                    .body(common::to_body::<String>(None));
3921
3922                client.request(request.unwrap()).await
3923            };
3924
3925            match req_result {
3926                Err(err) => {
3927                    if let common::Retry::After(d) = dlg.http_error(&err) {
3928                        sleep(d).await;
3929                        continue;
3930                    }
3931                    dlg.finished(false);
3932                    return Err(common::Error::HttpError(err));
3933                }
3934                Ok(res) => {
3935                    let (mut parts, body) = res.into_parts();
3936                    let mut body = common::Body::new(body);
3937                    if !parts.status.is_success() {
3938                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3939                        let error = serde_json::from_str(&common::to_string(&bytes));
3940                        let response = common::to_response(parts, bytes.into());
3941
3942                        if let common::Retry::After(d) =
3943                            dlg.http_failure(&response, error.as_ref().ok())
3944                        {
3945                            sleep(d).await;
3946                            continue;
3947                        }
3948
3949                        dlg.finished(false);
3950
3951                        return Err(match error {
3952                            Ok(value) => common::Error::BadRequest(value),
3953                            _ => common::Error::Failure(response),
3954                        });
3955                    }
3956                    let response = {
3957                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3958                        let encoded = common::to_string(&bytes);
3959                        match serde_json::from_str(&encoded) {
3960                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3961                            Err(error) => {
3962                                dlg.response_json_decode_error(&encoded, &error);
3963                                return Err(common::Error::JsonDecodeError(
3964                                    encoded.to_string(),
3965                                    error,
3966                                ));
3967                            }
3968                        }
3969                    };
3970
3971                    dlg.finished(true);
3972                    return Ok(response);
3973                }
3974            }
3975        }
3976    }
3977
3978    /// Required. The name of the job to get the description of.
3979    ///
3980    /// Sets the *name* path property to the given value.
3981    ///
3982    /// Even though the property as already been set when instantiating this call,
3983    /// we provide this method for API completeness.
3984    pub fn name(mut self, new_value: &str) -> ProjectJobGetCall<'a, C> {
3985        self._name = new_value.to_string();
3986        self
3987    }
3988    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3989    /// while executing the actual API request.
3990    ///
3991    /// ````text
3992    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3993    /// ````
3994    ///
3995    /// Sets the *delegate* property to the given value.
3996    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ProjectJobGetCall<'a, C> {
3997        self._delegate = Some(new_value);
3998        self
3999    }
4000
4001    /// Set any additional parameter of the query string used in the request.
4002    /// It should be used to set parameters which are not yet available through their own
4003    /// setters.
4004    ///
4005    /// Please note that this method must not be used to set any of the known parameters
4006    /// which have their own setter method. If done anyway, the request will fail.
4007    ///
4008    /// # Additional Parameters
4009    ///
4010    /// * *$.xgafv* (query-string) - V1 error format.
4011    /// * *access_token* (query-string) - OAuth access token.
4012    /// * *alt* (query-string) - Data format for response.
4013    /// * *callback* (query-string) - JSONP
4014    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4015    /// * *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.
4016    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4017    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4018    /// * *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.
4019    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4020    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4021    pub fn param<T>(mut self, name: T, value: T) -> ProjectJobGetCall<'a, C>
4022    where
4023        T: AsRef<str>,
4024    {
4025        self._additional_params
4026            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4027        self
4028    }
4029
4030    /// Identifies the authorization scope for the method you are building.
4031    ///
4032    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4033    /// [`Scope::CloudPlatformReadOnly`].
4034    ///
4035    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4036    /// tokens for more than one scope.
4037    ///
4038    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4039    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4040    /// sufficient, a read-write scope will do as well.
4041    pub fn add_scope<St>(mut self, scope: St) -> ProjectJobGetCall<'a, C>
4042    where
4043        St: AsRef<str>,
4044    {
4045        self._scopes.insert(String::from(scope.as_ref()));
4046        self
4047    }
4048    /// Identifies the authorization scope(s) for the method you are building.
4049    ///
4050    /// See [`Self::add_scope()`] for details.
4051    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectJobGetCall<'a, C>
4052    where
4053        I: IntoIterator<Item = St>,
4054        St: AsRef<str>,
4055    {
4056        self._scopes
4057            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4058        self
4059    }
4060
4061    /// Removes all scopes, and no default scope will be used either.
4062    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4063    /// for details).
4064    pub fn clear_scopes(mut self) -> ProjectJobGetCall<'a, C> {
4065        self._scopes.clear();
4066        self
4067    }
4068}
4069
4070/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
4071///
4072/// A builder for the *jobs.getIamPolicy* method supported by a *project* resource.
4073/// It is not used directly, but through a [`ProjectMethods`] instance.
4074///
4075/// # Example
4076///
4077/// Instantiate a resource method builder
4078///
4079/// ```test_harness,no_run
4080/// # extern crate hyper;
4081/// # extern crate hyper_rustls;
4082/// # extern crate google_ml1 as ml1;
4083/// # async fn dox() {
4084/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4085///
4086/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4087/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4088/// #     .with_native_roots()
4089/// #     .unwrap()
4090/// #     .https_only()
4091/// #     .enable_http2()
4092/// #     .build();
4093///
4094/// # let executor = hyper_util::rt::TokioExecutor::new();
4095/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4096/// #     secret,
4097/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4098/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4099/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4100/// #     ),
4101/// # ).build().await.unwrap();
4102///
4103/// # let client = hyper_util::client::legacy::Client::builder(
4104/// #     hyper_util::rt::TokioExecutor::new()
4105/// # )
4106/// # .build(
4107/// #     hyper_rustls::HttpsConnectorBuilder::new()
4108/// #         .with_native_roots()
4109/// #         .unwrap()
4110/// #         .https_or_http()
4111/// #         .enable_http2()
4112/// #         .build()
4113/// # );
4114/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
4115/// // You can configure optional parameters by calling the respective setters at will, and
4116/// // execute the final call using `doit()`.
4117/// // Values shown here are possibly random and not representative !
4118/// let result = hub.projects().jobs_get_iam_policy("resource")
4119///              .options_requested_policy_version(-80)
4120///              .doit().await;
4121/// # }
4122/// ```
4123pub struct ProjectJobGetIamPolicyCall<'a, C>
4124where
4125    C: 'a,
4126{
4127    hub: &'a CloudMachineLearningEngine<C>,
4128    _resource: String,
4129    _options_requested_policy_version: Option<i32>,
4130    _delegate: Option<&'a mut dyn common::Delegate>,
4131    _additional_params: HashMap<String, String>,
4132    _scopes: BTreeSet<String>,
4133}
4134
4135impl<'a, C> common::CallBuilder for ProjectJobGetIamPolicyCall<'a, C> {}
4136
4137impl<'a, C> ProjectJobGetIamPolicyCall<'a, C>
4138where
4139    C: common::Connector,
4140{
4141    /// Perform the operation you have build so far.
4142    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleIamV1__Policy)> {
4143        use std::borrow::Cow;
4144        use std::io::{Read, Seek};
4145
4146        use common::{url::Params, ToParts};
4147        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4148
4149        let mut dd = common::DefaultDelegate;
4150        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4151        dlg.begin(common::MethodInfo {
4152            id: "ml.projects.jobs.getIamPolicy",
4153            http_method: hyper::Method::GET,
4154        });
4155
4156        for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
4157            if self._additional_params.contains_key(field) {
4158                dlg.finished(false);
4159                return Err(common::Error::FieldClash(field));
4160            }
4161        }
4162
4163        let mut params = Params::with_capacity(4 + self._additional_params.len());
4164        params.push("resource", self._resource);
4165        if let Some(value) = self._options_requested_policy_version.as_ref() {
4166            params.push("options.requestedPolicyVersion", value.to_string());
4167        }
4168
4169        params.extend(self._additional_params.iter());
4170
4171        params.push("alt", "json");
4172        let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
4173        if self._scopes.is_empty() {
4174            self._scopes
4175                .insert(Scope::CloudPlatform.as_ref().to_string());
4176        }
4177
4178        #[allow(clippy::single_element_loop)]
4179        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
4180            url = params.uri_replacement(url, param_name, find_this, true);
4181        }
4182        {
4183            let to_remove = ["resource"];
4184            params.remove_params(&to_remove);
4185        }
4186
4187        let url = params.parse_with_url(&url);
4188
4189        loop {
4190            let token = match self
4191                .hub
4192                .auth
4193                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4194                .await
4195            {
4196                Ok(token) => token,
4197                Err(e) => match dlg.token(e) {
4198                    Ok(token) => token,
4199                    Err(e) => {
4200                        dlg.finished(false);
4201                        return Err(common::Error::MissingToken(e));
4202                    }
4203                },
4204            };
4205            let mut req_result = {
4206                let client = &self.hub.client;
4207                dlg.pre_request();
4208                let mut req_builder = hyper::Request::builder()
4209                    .method(hyper::Method::GET)
4210                    .uri(url.as_str())
4211                    .header(USER_AGENT, self.hub._user_agent.clone());
4212
4213                if let Some(token) = token.as_ref() {
4214                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4215                }
4216
4217                let request = req_builder
4218                    .header(CONTENT_LENGTH, 0_u64)
4219                    .body(common::to_body::<String>(None));
4220
4221                client.request(request.unwrap()).await
4222            };
4223
4224            match req_result {
4225                Err(err) => {
4226                    if let common::Retry::After(d) = dlg.http_error(&err) {
4227                        sleep(d).await;
4228                        continue;
4229                    }
4230                    dlg.finished(false);
4231                    return Err(common::Error::HttpError(err));
4232                }
4233                Ok(res) => {
4234                    let (mut parts, body) = res.into_parts();
4235                    let mut body = common::Body::new(body);
4236                    if !parts.status.is_success() {
4237                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4238                        let error = serde_json::from_str(&common::to_string(&bytes));
4239                        let response = common::to_response(parts, bytes.into());
4240
4241                        if let common::Retry::After(d) =
4242                            dlg.http_failure(&response, error.as_ref().ok())
4243                        {
4244                            sleep(d).await;
4245                            continue;
4246                        }
4247
4248                        dlg.finished(false);
4249
4250                        return Err(match error {
4251                            Ok(value) => common::Error::BadRequest(value),
4252                            _ => common::Error::Failure(response),
4253                        });
4254                    }
4255                    let response = {
4256                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4257                        let encoded = common::to_string(&bytes);
4258                        match serde_json::from_str(&encoded) {
4259                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4260                            Err(error) => {
4261                                dlg.response_json_decode_error(&encoded, &error);
4262                                return Err(common::Error::JsonDecodeError(
4263                                    encoded.to_string(),
4264                                    error,
4265                                ));
4266                            }
4267                        }
4268                    };
4269
4270                    dlg.finished(true);
4271                    return Ok(response);
4272                }
4273            }
4274        }
4275    }
4276
4277    /// REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
4278    ///
4279    /// Sets the *resource* path property to the given value.
4280    ///
4281    /// Even though the property as already been set when instantiating this call,
4282    /// we provide this method for API completeness.
4283    pub fn resource(mut self, new_value: &str) -> ProjectJobGetIamPolicyCall<'a, C> {
4284        self._resource = new_value.to_string();
4285        self
4286    }
4287    /// Optional. The maximum policy version that will be used to format the policy. Valid values are 0, 1, and 3. Requests specifying an invalid value will be rejected. Requests for policies with any conditional role bindings must specify version 3. Policies with no conditional role bindings may specify any valid value or leave the field unset. The policy in the response might use the policy version that you specified, or it might use a lower policy version. For example, if you specify version 3, but the policy has no conditional role bindings, the response uses version 1. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
4288    ///
4289    /// Sets the *options.requested policy version* query property to the given value.
4290    pub fn options_requested_policy_version(
4291        mut self,
4292        new_value: i32,
4293    ) -> ProjectJobGetIamPolicyCall<'a, C> {
4294        self._options_requested_policy_version = Some(new_value);
4295        self
4296    }
4297    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4298    /// while executing the actual API request.
4299    ///
4300    /// ````text
4301    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4302    /// ````
4303    ///
4304    /// Sets the *delegate* property to the given value.
4305    pub fn delegate(
4306        mut self,
4307        new_value: &'a mut dyn common::Delegate,
4308    ) -> ProjectJobGetIamPolicyCall<'a, C> {
4309        self._delegate = Some(new_value);
4310        self
4311    }
4312
4313    /// Set any additional parameter of the query string used in the request.
4314    /// It should be used to set parameters which are not yet available through their own
4315    /// setters.
4316    ///
4317    /// Please note that this method must not be used to set any of the known parameters
4318    /// which have their own setter method. If done anyway, the request will fail.
4319    ///
4320    /// # Additional Parameters
4321    ///
4322    /// * *$.xgafv* (query-string) - V1 error format.
4323    /// * *access_token* (query-string) - OAuth access token.
4324    /// * *alt* (query-string) - Data format for response.
4325    /// * *callback* (query-string) - JSONP
4326    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4327    /// * *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.
4328    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4329    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4330    /// * *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.
4331    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4332    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4333    pub fn param<T>(mut self, name: T, value: T) -> ProjectJobGetIamPolicyCall<'a, C>
4334    where
4335        T: AsRef<str>,
4336    {
4337        self._additional_params
4338            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4339        self
4340    }
4341
4342    /// Identifies the authorization scope for the method you are building.
4343    ///
4344    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4345    /// [`Scope::CloudPlatform`].
4346    ///
4347    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4348    /// tokens for more than one scope.
4349    ///
4350    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4351    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4352    /// sufficient, a read-write scope will do as well.
4353    pub fn add_scope<St>(mut self, scope: St) -> ProjectJobGetIamPolicyCall<'a, C>
4354    where
4355        St: AsRef<str>,
4356    {
4357        self._scopes.insert(String::from(scope.as_ref()));
4358        self
4359    }
4360    /// Identifies the authorization scope(s) for the method you are building.
4361    ///
4362    /// See [`Self::add_scope()`] for details.
4363    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectJobGetIamPolicyCall<'a, C>
4364    where
4365        I: IntoIterator<Item = St>,
4366        St: AsRef<str>,
4367    {
4368        self._scopes
4369            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4370        self
4371    }
4372
4373    /// Removes all scopes, and no default scope will be used either.
4374    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4375    /// for details).
4376    pub fn clear_scopes(mut self) -> ProjectJobGetIamPolicyCall<'a, C> {
4377        self._scopes.clear();
4378        self
4379    }
4380}
4381
4382/// Lists the jobs in the project. If there are no jobs that match the request parameters, the list request returns an empty response body: {}.
4383///
4384/// A builder for the *jobs.list* method supported by a *project* resource.
4385/// It is not used directly, but through a [`ProjectMethods`] instance.
4386///
4387/// # Example
4388///
4389/// Instantiate a resource method builder
4390///
4391/// ```test_harness,no_run
4392/// # extern crate hyper;
4393/// # extern crate hyper_rustls;
4394/// # extern crate google_ml1 as ml1;
4395/// # async fn dox() {
4396/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4397///
4398/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4399/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4400/// #     .with_native_roots()
4401/// #     .unwrap()
4402/// #     .https_only()
4403/// #     .enable_http2()
4404/// #     .build();
4405///
4406/// # let executor = hyper_util::rt::TokioExecutor::new();
4407/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4408/// #     secret,
4409/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4410/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4411/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4412/// #     ),
4413/// # ).build().await.unwrap();
4414///
4415/// # let client = hyper_util::client::legacy::Client::builder(
4416/// #     hyper_util::rt::TokioExecutor::new()
4417/// # )
4418/// # .build(
4419/// #     hyper_rustls::HttpsConnectorBuilder::new()
4420/// #         .with_native_roots()
4421/// #         .unwrap()
4422/// #         .https_or_http()
4423/// #         .enable_http2()
4424/// #         .build()
4425/// # );
4426/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
4427/// // You can configure optional parameters by calling the respective setters at will, and
4428/// // execute the final call using `doit()`.
4429/// // Values shown here are possibly random and not representative !
4430/// let result = hub.projects().jobs_list("parent")
4431///              .page_token("takimata")
4432///              .page_size(-52)
4433///              .filter("duo")
4434///              .doit().await;
4435/// # }
4436/// ```
4437pub struct ProjectJobListCall<'a, C>
4438where
4439    C: 'a,
4440{
4441    hub: &'a CloudMachineLearningEngine<C>,
4442    _parent: String,
4443    _page_token: Option<String>,
4444    _page_size: Option<i32>,
4445    _filter: Option<String>,
4446    _delegate: Option<&'a mut dyn common::Delegate>,
4447    _additional_params: HashMap<String, String>,
4448    _scopes: BTreeSet<String>,
4449}
4450
4451impl<'a, C> common::CallBuilder for ProjectJobListCall<'a, C> {}
4452
4453impl<'a, C> ProjectJobListCall<'a, C>
4454where
4455    C: common::Connector,
4456{
4457    /// Perform the operation you have build so far.
4458    pub async fn doit(
4459        mut self,
4460    ) -> common::Result<(common::Response, GoogleCloudMlV1__ListJobsResponse)> {
4461        use std::borrow::Cow;
4462        use std::io::{Read, Seek};
4463
4464        use common::{url::Params, ToParts};
4465        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4466
4467        let mut dd = common::DefaultDelegate;
4468        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4469        dlg.begin(common::MethodInfo {
4470            id: "ml.projects.jobs.list",
4471            http_method: hyper::Method::GET,
4472        });
4473
4474        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
4475            if self._additional_params.contains_key(field) {
4476                dlg.finished(false);
4477                return Err(common::Error::FieldClash(field));
4478            }
4479        }
4480
4481        let mut params = Params::with_capacity(6 + self._additional_params.len());
4482        params.push("parent", self._parent);
4483        if let Some(value) = self._page_token.as_ref() {
4484            params.push("pageToken", value);
4485        }
4486        if let Some(value) = self._page_size.as_ref() {
4487            params.push("pageSize", value.to_string());
4488        }
4489        if let Some(value) = self._filter.as_ref() {
4490            params.push("filter", value);
4491        }
4492
4493        params.extend(self._additional_params.iter());
4494
4495        params.push("alt", "json");
4496        let mut url = self.hub._base_url.clone() + "v1/{+parent}/jobs";
4497        if self._scopes.is_empty() {
4498            self._scopes
4499                .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
4500        }
4501
4502        #[allow(clippy::single_element_loop)]
4503        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4504            url = params.uri_replacement(url, param_name, find_this, true);
4505        }
4506        {
4507            let to_remove = ["parent"];
4508            params.remove_params(&to_remove);
4509        }
4510
4511        let url = params.parse_with_url(&url);
4512
4513        loop {
4514            let token = match self
4515                .hub
4516                .auth
4517                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4518                .await
4519            {
4520                Ok(token) => token,
4521                Err(e) => match dlg.token(e) {
4522                    Ok(token) => token,
4523                    Err(e) => {
4524                        dlg.finished(false);
4525                        return Err(common::Error::MissingToken(e));
4526                    }
4527                },
4528            };
4529            let mut req_result = {
4530                let client = &self.hub.client;
4531                dlg.pre_request();
4532                let mut req_builder = hyper::Request::builder()
4533                    .method(hyper::Method::GET)
4534                    .uri(url.as_str())
4535                    .header(USER_AGENT, self.hub._user_agent.clone());
4536
4537                if let Some(token) = token.as_ref() {
4538                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4539                }
4540
4541                let request = req_builder
4542                    .header(CONTENT_LENGTH, 0_u64)
4543                    .body(common::to_body::<String>(None));
4544
4545                client.request(request.unwrap()).await
4546            };
4547
4548            match req_result {
4549                Err(err) => {
4550                    if let common::Retry::After(d) = dlg.http_error(&err) {
4551                        sleep(d).await;
4552                        continue;
4553                    }
4554                    dlg.finished(false);
4555                    return Err(common::Error::HttpError(err));
4556                }
4557                Ok(res) => {
4558                    let (mut parts, body) = res.into_parts();
4559                    let mut body = common::Body::new(body);
4560                    if !parts.status.is_success() {
4561                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4562                        let error = serde_json::from_str(&common::to_string(&bytes));
4563                        let response = common::to_response(parts, bytes.into());
4564
4565                        if let common::Retry::After(d) =
4566                            dlg.http_failure(&response, error.as_ref().ok())
4567                        {
4568                            sleep(d).await;
4569                            continue;
4570                        }
4571
4572                        dlg.finished(false);
4573
4574                        return Err(match error {
4575                            Ok(value) => common::Error::BadRequest(value),
4576                            _ => common::Error::Failure(response),
4577                        });
4578                    }
4579                    let response = {
4580                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4581                        let encoded = common::to_string(&bytes);
4582                        match serde_json::from_str(&encoded) {
4583                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4584                            Err(error) => {
4585                                dlg.response_json_decode_error(&encoded, &error);
4586                                return Err(common::Error::JsonDecodeError(
4587                                    encoded.to_string(),
4588                                    error,
4589                                ));
4590                            }
4591                        }
4592                    };
4593
4594                    dlg.finished(true);
4595                    return Ok(response);
4596                }
4597            }
4598        }
4599    }
4600
4601    /// Required. The name of the project for which to list jobs.
4602    ///
4603    /// Sets the *parent* path property to the given value.
4604    ///
4605    /// Even though the property as already been set when instantiating this call,
4606    /// we provide this method for API completeness.
4607    pub fn parent(mut self, new_value: &str) -> ProjectJobListCall<'a, C> {
4608        self._parent = new_value.to_string();
4609        self
4610    }
4611    /// Optional. A page token to request the next page of results. You get the token from the `next_page_token` field of the response from the previous call.
4612    ///
4613    /// Sets the *page token* query property to the given value.
4614    pub fn page_token(mut self, new_value: &str) -> ProjectJobListCall<'a, C> {
4615        self._page_token = Some(new_value.to_string());
4616        self
4617    }
4618    /// Optional. The number of jobs to retrieve per "page" of results. If there are more remaining results than this number, the response message will contain a valid value in the `next_page_token` field. The default value is 20, and the maximum page size is 100.
4619    ///
4620    /// Sets the *page size* query property to the given value.
4621    pub fn page_size(mut self, new_value: i32) -> ProjectJobListCall<'a, C> {
4622        self._page_size = Some(new_value);
4623        self
4624    }
4625    /// Optional. Specifies the subset of jobs to retrieve. You can filter on the value of one or more attributes of the job object. For example, retrieve jobs with a job identifier that starts with 'census': gcloud ai-platform jobs list --filter='jobId:census*' List all failed jobs with names that start with 'rnn': gcloud ai-platform jobs list --filter='jobId:rnn* AND state:FAILED' For more examples, see the guide to monitoring jobs.
4626    ///
4627    /// Sets the *filter* query property to the given value.
4628    pub fn filter(mut self, new_value: &str) -> ProjectJobListCall<'a, C> {
4629        self._filter = Some(new_value.to_string());
4630        self
4631    }
4632    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4633    /// while executing the actual API request.
4634    ///
4635    /// ````text
4636    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4637    /// ````
4638    ///
4639    /// Sets the *delegate* property to the given value.
4640    pub fn delegate(
4641        mut self,
4642        new_value: &'a mut dyn common::Delegate,
4643    ) -> ProjectJobListCall<'a, C> {
4644        self._delegate = Some(new_value);
4645        self
4646    }
4647
4648    /// Set any additional parameter of the query string used in the request.
4649    /// It should be used to set parameters which are not yet available through their own
4650    /// setters.
4651    ///
4652    /// Please note that this method must not be used to set any of the known parameters
4653    /// which have their own setter method. If done anyway, the request will fail.
4654    ///
4655    /// # Additional Parameters
4656    ///
4657    /// * *$.xgafv* (query-string) - V1 error format.
4658    /// * *access_token* (query-string) - OAuth access token.
4659    /// * *alt* (query-string) - Data format for response.
4660    /// * *callback* (query-string) - JSONP
4661    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4662    /// * *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.
4663    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4664    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4665    /// * *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.
4666    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4667    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4668    pub fn param<T>(mut self, name: T, value: T) -> ProjectJobListCall<'a, C>
4669    where
4670        T: AsRef<str>,
4671    {
4672        self._additional_params
4673            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4674        self
4675    }
4676
4677    /// Identifies the authorization scope for the method you are building.
4678    ///
4679    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4680    /// [`Scope::CloudPlatformReadOnly`].
4681    ///
4682    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4683    /// tokens for more than one scope.
4684    ///
4685    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4686    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4687    /// sufficient, a read-write scope will do as well.
4688    pub fn add_scope<St>(mut self, scope: St) -> ProjectJobListCall<'a, C>
4689    where
4690        St: AsRef<str>,
4691    {
4692        self._scopes.insert(String::from(scope.as_ref()));
4693        self
4694    }
4695    /// Identifies the authorization scope(s) for the method you are building.
4696    ///
4697    /// See [`Self::add_scope()`] for details.
4698    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectJobListCall<'a, C>
4699    where
4700        I: IntoIterator<Item = St>,
4701        St: AsRef<str>,
4702    {
4703        self._scopes
4704            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4705        self
4706    }
4707
4708    /// Removes all scopes, and no default scope will be used either.
4709    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4710    /// for details).
4711    pub fn clear_scopes(mut self) -> ProjectJobListCall<'a, C> {
4712        self._scopes.clear();
4713        self
4714    }
4715}
4716
4717/// Updates a specific job resource. Currently the only supported fields to update are `labels`.
4718///
4719/// A builder for the *jobs.patch* method supported by a *project* resource.
4720/// It is not used directly, but through a [`ProjectMethods`] instance.
4721///
4722/// # Example
4723///
4724/// Instantiate a resource method builder
4725///
4726/// ```test_harness,no_run
4727/// # extern crate hyper;
4728/// # extern crate hyper_rustls;
4729/// # extern crate google_ml1 as ml1;
4730/// use ml1::api::GoogleCloudMlV1__Job;
4731/// # async fn dox() {
4732/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4733///
4734/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4735/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4736/// #     .with_native_roots()
4737/// #     .unwrap()
4738/// #     .https_only()
4739/// #     .enable_http2()
4740/// #     .build();
4741///
4742/// # let executor = hyper_util::rt::TokioExecutor::new();
4743/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4744/// #     secret,
4745/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4746/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4747/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4748/// #     ),
4749/// # ).build().await.unwrap();
4750///
4751/// # let client = hyper_util::client::legacy::Client::builder(
4752/// #     hyper_util::rt::TokioExecutor::new()
4753/// # )
4754/// # .build(
4755/// #     hyper_rustls::HttpsConnectorBuilder::new()
4756/// #         .with_native_roots()
4757/// #         .unwrap()
4758/// #         .https_or_http()
4759/// #         .enable_http2()
4760/// #         .build()
4761/// # );
4762/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
4763/// // As the method needs a request, you would usually fill it with the desired information
4764/// // into the respective structure. Some of the parts shown here might not be applicable !
4765/// // Values shown here are possibly random and not representative !
4766/// let mut req = GoogleCloudMlV1__Job::default();
4767///
4768/// // You can configure optional parameters by calling the respective setters at will, and
4769/// // execute the final call using `doit()`.
4770/// // Values shown here are possibly random and not representative !
4771/// let result = hub.projects().jobs_patch(req, "name")
4772///              .update_mask(FieldMask::new::<&str>(&[]))
4773///              .doit().await;
4774/// # }
4775/// ```
4776pub struct ProjectJobPatchCall<'a, C>
4777where
4778    C: 'a,
4779{
4780    hub: &'a CloudMachineLearningEngine<C>,
4781    _request: GoogleCloudMlV1__Job,
4782    _name: String,
4783    _update_mask: Option<common::FieldMask>,
4784    _delegate: Option<&'a mut dyn common::Delegate>,
4785    _additional_params: HashMap<String, String>,
4786    _scopes: BTreeSet<String>,
4787}
4788
4789impl<'a, C> common::CallBuilder for ProjectJobPatchCall<'a, C> {}
4790
4791impl<'a, C> ProjectJobPatchCall<'a, C>
4792where
4793    C: common::Connector,
4794{
4795    /// Perform the operation you have build so far.
4796    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleCloudMlV1__Job)> {
4797        use std::borrow::Cow;
4798        use std::io::{Read, Seek};
4799
4800        use common::{url::Params, ToParts};
4801        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4802
4803        let mut dd = common::DefaultDelegate;
4804        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4805        dlg.begin(common::MethodInfo {
4806            id: "ml.projects.jobs.patch",
4807            http_method: hyper::Method::PATCH,
4808        });
4809
4810        for &field in ["alt", "name", "updateMask"].iter() {
4811            if self._additional_params.contains_key(field) {
4812                dlg.finished(false);
4813                return Err(common::Error::FieldClash(field));
4814            }
4815        }
4816
4817        let mut params = Params::with_capacity(5 + self._additional_params.len());
4818        params.push("name", self._name);
4819        if let Some(value) = self._update_mask.as_ref() {
4820            params.push("updateMask", value.to_string());
4821        }
4822
4823        params.extend(self._additional_params.iter());
4824
4825        params.push("alt", "json");
4826        let mut url = self.hub._base_url.clone() + "v1/{+name}";
4827        if self._scopes.is_empty() {
4828            self._scopes
4829                .insert(Scope::CloudPlatform.as_ref().to_string());
4830        }
4831
4832        #[allow(clippy::single_element_loop)]
4833        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4834            url = params.uri_replacement(url, param_name, find_this, true);
4835        }
4836        {
4837            let to_remove = ["name"];
4838            params.remove_params(&to_remove);
4839        }
4840
4841        let url = params.parse_with_url(&url);
4842
4843        let mut json_mime_type = mime::APPLICATION_JSON;
4844        let mut request_value_reader = {
4845            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4846            common::remove_json_null_values(&mut value);
4847            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4848            serde_json::to_writer(&mut dst, &value).unwrap();
4849            dst
4850        };
4851        let request_size = request_value_reader
4852            .seek(std::io::SeekFrom::End(0))
4853            .unwrap();
4854        request_value_reader
4855            .seek(std::io::SeekFrom::Start(0))
4856            .unwrap();
4857
4858        loop {
4859            let token = match self
4860                .hub
4861                .auth
4862                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4863                .await
4864            {
4865                Ok(token) => token,
4866                Err(e) => match dlg.token(e) {
4867                    Ok(token) => token,
4868                    Err(e) => {
4869                        dlg.finished(false);
4870                        return Err(common::Error::MissingToken(e));
4871                    }
4872                },
4873            };
4874            request_value_reader
4875                .seek(std::io::SeekFrom::Start(0))
4876                .unwrap();
4877            let mut req_result = {
4878                let client = &self.hub.client;
4879                dlg.pre_request();
4880                let mut req_builder = hyper::Request::builder()
4881                    .method(hyper::Method::PATCH)
4882                    .uri(url.as_str())
4883                    .header(USER_AGENT, self.hub._user_agent.clone());
4884
4885                if let Some(token) = token.as_ref() {
4886                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4887                }
4888
4889                let request = req_builder
4890                    .header(CONTENT_TYPE, json_mime_type.to_string())
4891                    .header(CONTENT_LENGTH, request_size as u64)
4892                    .body(common::to_body(
4893                        request_value_reader.get_ref().clone().into(),
4894                    ));
4895
4896                client.request(request.unwrap()).await
4897            };
4898
4899            match req_result {
4900                Err(err) => {
4901                    if let common::Retry::After(d) = dlg.http_error(&err) {
4902                        sleep(d).await;
4903                        continue;
4904                    }
4905                    dlg.finished(false);
4906                    return Err(common::Error::HttpError(err));
4907                }
4908                Ok(res) => {
4909                    let (mut parts, body) = res.into_parts();
4910                    let mut body = common::Body::new(body);
4911                    if !parts.status.is_success() {
4912                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4913                        let error = serde_json::from_str(&common::to_string(&bytes));
4914                        let response = common::to_response(parts, bytes.into());
4915
4916                        if let common::Retry::After(d) =
4917                            dlg.http_failure(&response, error.as_ref().ok())
4918                        {
4919                            sleep(d).await;
4920                            continue;
4921                        }
4922
4923                        dlg.finished(false);
4924
4925                        return Err(match error {
4926                            Ok(value) => common::Error::BadRequest(value),
4927                            _ => common::Error::Failure(response),
4928                        });
4929                    }
4930                    let response = {
4931                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4932                        let encoded = common::to_string(&bytes);
4933                        match serde_json::from_str(&encoded) {
4934                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4935                            Err(error) => {
4936                                dlg.response_json_decode_error(&encoded, &error);
4937                                return Err(common::Error::JsonDecodeError(
4938                                    encoded.to_string(),
4939                                    error,
4940                                ));
4941                            }
4942                        }
4943                    };
4944
4945                    dlg.finished(true);
4946                    return Ok(response);
4947                }
4948            }
4949        }
4950    }
4951
4952    ///
4953    /// Sets the *request* property to the given value.
4954    ///
4955    /// Even though the property as already been set when instantiating this call,
4956    /// we provide this method for API completeness.
4957    pub fn request(mut self, new_value: GoogleCloudMlV1__Job) -> ProjectJobPatchCall<'a, C> {
4958        self._request = new_value;
4959        self
4960    }
4961    /// Required. The job name.
4962    ///
4963    /// Sets the *name* path property to the given value.
4964    ///
4965    /// Even though the property as already been set when instantiating this call,
4966    /// we provide this method for API completeness.
4967    pub fn name(mut self, new_value: &str) -> ProjectJobPatchCall<'a, C> {
4968        self._name = new_value.to_string();
4969        self
4970    }
4971    /// Required. Specifies the path, relative to `Job`, of the field to update. To adopt etag mechanism, include `etag` field in the mask, and include the `etag` value in your job resource. For example, to change the labels of a job, the `update_mask` parameter would be specified as `labels`, `etag`, and the `PATCH` request body would specify the new value, as follows: { "labels": { "owner": "Google", "color": "Blue" } "etag": "33a64df551425fcc55e4d42a148795d9f25f89d4" } If `etag` matches the one on the server, the labels of the job will be replaced with the given ones, and the server end `etag` will be recalculated. Currently the only supported update masks are `labels` and `etag`.
4972    ///
4973    /// Sets the *update mask* query property to the given value.
4974    pub fn update_mask(mut self, new_value: common::FieldMask) -> ProjectJobPatchCall<'a, C> {
4975        self._update_mask = Some(new_value);
4976        self
4977    }
4978    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4979    /// while executing the actual API request.
4980    ///
4981    /// ````text
4982    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4983    /// ````
4984    ///
4985    /// Sets the *delegate* property to the given value.
4986    pub fn delegate(
4987        mut self,
4988        new_value: &'a mut dyn common::Delegate,
4989    ) -> ProjectJobPatchCall<'a, C> {
4990        self._delegate = Some(new_value);
4991        self
4992    }
4993
4994    /// Set any additional parameter of the query string used in the request.
4995    /// It should be used to set parameters which are not yet available through their own
4996    /// setters.
4997    ///
4998    /// Please note that this method must not be used to set any of the known parameters
4999    /// which have their own setter method. If done anyway, the request will fail.
5000    ///
5001    /// # Additional Parameters
5002    ///
5003    /// * *$.xgafv* (query-string) - V1 error format.
5004    /// * *access_token* (query-string) - OAuth access token.
5005    /// * *alt* (query-string) - Data format for response.
5006    /// * *callback* (query-string) - JSONP
5007    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5008    /// * *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.
5009    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5010    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5011    /// * *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.
5012    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5013    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5014    pub fn param<T>(mut self, name: T, value: T) -> ProjectJobPatchCall<'a, C>
5015    where
5016        T: AsRef<str>,
5017    {
5018        self._additional_params
5019            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5020        self
5021    }
5022
5023    /// Identifies the authorization scope for the method you are building.
5024    ///
5025    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5026    /// [`Scope::CloudPlatform`].
5027    ///
5028    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5029    /// tokens for more than one scope.
5030    ///
5031    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5032    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5033    /// sufficient, a read-write scope will do as well.
5034    pub fn add_scope<St>(mut self, scope: St) -> ProjectJobPatchCall<'a, C>
5035    where
5036        St: AsRef<str>,
5037    {
5038        self._scopes.insert(String::from(scope.as_ref()));
5039        self
5040    }
5041    /// Identifies the authorization scope(s) for the method you are building.
5042    ///
5043    /// See [`Self::add_scope()`] for details.
5044    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectJobPatchCall<'a, C>
5045    where
5046        I: IntoIterator<Item = St>,
5047        St: AsRef<str>,
5048    {
5049        self._scopes
5050            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5051        self
5052    }
5053
5054    /// Removes all scopes, and no default scope will be used either.
5055    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5056    /// for details).
5057    pub fn clear_scopes(mut self) -> ProjectJobPatchCall<'a, C> {
5058        self._scopes.clear();
5059        self
5060    }
5061}
5062
5063/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
5064///
5065/// A builder for the *jobs.setIamPolicy* method supported by a *project* resource.
5066/// It is not used directly, but through a [`ProjectMethods`] instance.
5067///
5068/// # Example
5069///
5070/// Instantiate a resource method builder
5071///
5072/// ```test_harness,no_run
5073/// # extern crate hyper;
5074/// # extern crate hyper_rustls;
5075/// # extern crate google_ml1 as ml1;
5076/// use ml1::api::GoogleIamV1__SetIamPolicyRequest;
5077/// # async fn dox() {
5078/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5079///
5080/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5081/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5082/// #     .with_native_roots()
5083/// #     .unwrap()
5084/// #     .https_only()
5085/// #     .enable_http2()
5086/// #     .build();
5087///
5088/// # let executor = hyper_util::rt::TokioExecutor::new();
5089/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5090/// #     secret,
5091/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5092/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5093/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5094/// #     ),
5095/// # ).build().await.unwrap();
5096///
5097/// # let client = hyper_util::client::legacy::Client::builder(
5098/// #     hyper_util::rt::TokioExecutor::new()
5099/// # )
5100/// # .build(
5101/// #     hyper_rustls::HttpsConnectorBuilder::new()
5102/// #         .with_native_roots()
5103/// #         .unwrap()
5104/// #         .https_or_http()
5105/// #         .enable_http2()
5106/// #         .build()
5107/// # );
5108/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
5109/// // As the method needs a request, you would usually fill it with the desired information
5110/// // into the respective structure. Some of the parts shown here might not be applicable !
5111/// // Values shown here are possibly random and not representative !
5112/// let mut req = GoogleIamV1__SetIamPolicyRequest::default();
5113///
5114/// // You can configure optional parameters by calling the respective setters at will, and
5115/// // execute the final call using `doit()`.
5116/// // Values shown here are possibly random and not representative !
5117/// let result = hub.projects().jobs_set_iam_policy(req, "resource")
5118///              .doit().await;
5119/// # }
5120/// ```
5121pub struct ProjectJobSetIamPolicyCall<'a, C>
5122where
5123    C: 'a,
5124{
5125    hub: &'a CloudMachineLearningEngine<C>,
5126    _request: GoogleIamV1__SetIamPolicyRequest,
5127    _resource: String,
5128    _delegate: Option<&'a mut dyn common::Delegate>,
5129    _additional_params: HashMap<String, String>,
5130    _scopes: BTreeSet<String>,
5131}
5132
5133impl<'a, C> common::CallBuilder for ProjectJobSetIamPolicyCall<'a, C> {}
5134
5135impl<'a, C> ProjectJobSetIamPolicyCall<'a, C>
5136where
5137    C: common::Connector,
5138{
5139    /// Perform the operation you have build so far.
5140    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleIamV1__Policy)> {
5141        use std::borrow::Cow;
5142        use std::io::{Read, Seek};
5143
5144        use common::{url::Params, ToParts};
5145        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5146
5147        let mut dd = common::DefaultDelegate;
5148        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5149        dlg.begin(common::MethodInfo {
5150            id: "ml.projects.jobs.setIamPolicy",
5151            http_method: hyper::Method::POST,
5152        });
5153
5154        for &field in ["alt", "resource"].iter() {
5155            if self._additional_params.contains_key(field) {
5156                dlg.finished(false);
5157                return Err(common::Error::FieldClash(field));
5158            }
5159        }
5160
5161        let mut params = Params::with_capacity(4 + self._additional_params.len());
5162        params.push("resource", self._resource);
5163
5164        params.extend(self._additional_params.iter());
5165
5166        params.push("alt", "json");
5167        let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
5168        if self._scopes.is_empty() {
5169            self._scopes
5170                .insert(Scope::CloudPlatform.as_ref().to_string());
5171        }
5172
5173        #[allow(clippy::single_element_loop)]
5174        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
5175            url = params.uri_replacement(url, param_name, find_this, true);
5176        }
5177        {
5178            let to_remove = ["resource"];
5179            params.remove_params(&to_remove);
5180        }
5181
5182        let url = params.parse_with_url(&url);
5183
5184        let mut json_mime_type = mime::APPLICATION_JSON;
5185        let mut request_value_reader = {
5186            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5187            common::remove_json_null_values(&mut value);
5188            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5189            serde_json::to_writer(&mut dst, &value).unwrap();
5190            dst
5191        };
5192        let request_size = request_value_reader
5193            .seek(std::io::SeekFrom::End(0))
5194            .unwrap();
5195        request_value_reader
5196            .seek(std::io::SeekFrom::Start(0))
5197            .unwrap();
5198
5199        loop {
5200            let token = match self
5201                .hub
5202                .auth
5203                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5204                .await
5205            {
5206                Ok(token) => token,
5207                Err(e) => match dlg.token(e) {
5208                    Ok(token) => token,
5209                    Err(e) => {
5210                        dlg.finished(false);
5211                        return Err(common::Error::MissingToken(e));
5212                    }
5213                },
5214            };
5215            request_value_reader
5216                .seek(std::io::SeekFrom::Start(0))
5217                .unwrap();
5218            let mut req_result = {
5219                let client = &self.hub.client;
5220                dlg.pre_request();
5221                let mut req_builder = hyper::Request::builder()
5222                    .method(hyper::Method::POST)
5223                    .uri(url.as_str())
5224                    .header(USER_AGENT, self.hub._user_agent.clone());
5225
5226                if let Some(token) = token.as_ref() {
5227                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5228                }
5229
5230                let request = req_builder
5231                    .header(CONTENT_TYPE, json_mime_type.to_string())
5232                    .header(CONTENT_LENGTH, request_size as u64)
5233                    .body(common::to_body(
5234                        request_value_reader.get_ref().clone().into(),
5235                    ));
5236
5237                client.request(request.unwrap()).await
5238            };
5239
5240            match req_result {
5241                Err(err) => {
5242                    if let common::Retry::After(d) = dlg.http_error(&err) {
5243                        sleep(d).await;
5244                        continue;
5245                    }
5246                    dlg.finished(false);
5247                    return Err(common::Error::HttpError(err));
5248                }
5249                Ok(res) => {
5250                    let (mut parts, body) = res.into_parts();
5251                    let mut body = common::Body::new(body);
5252                    if !parts.status.is_success() {
5253                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5254                        let error = serde_json::from_str(&common::to_string(&bytes));
5255                        let response = common::to_response(parts, bytes.into());
5256
5257                        if let common::Retry::After(d) =
5258                            dlg.http_failure(&response, error.as_ref().ok())
5259                        {
5260                            sleep(d).await;
5261                            continue;
5262                        }
5263
5264                        dlg.finished(false);
5265
5266                        return Err(match error {
5267                            Ok(value) => common::Error::BadRequest(value),
5268                            _ => common::Error::Failure(response),
5269                        });
5270                    }
5271                    let response = {
5272                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5273                        let encoded = common::to_string(&bytes);
5274                        match serde_json::from_str(&encoded) {
5275                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5276                            Err(error) => {
5277                                dlg.response_json_decode_error(&encoded, &error);
5278                                return Err(common::Error::JsonDecodeError(
5279                                    encoded.to_string(),
5280                                    error,
5281                                ));
5282                            }
5283                        }
5284                    };
5285
5286                    dlg.finished(true);
5287                    return Ok(response);
5288                }
5289            }
5290        }
5291    }
5292
5293    ///
5294    /// Sets the *request* property to the given value.
5295    ///
5296    /// Even though the property as already been set when instantiating this call,
5297    /// we provide this method for API completeness.
5298    pub fn request(
5299        mut self,
5300        new_value: GoogleIamV1__SetIamPolicyRequest,
5301    ) -> ProjectJobSetIamPolicyCall<'a, C> {
5302        self._request = new_value;
5303        self
5304    }
5305    /// REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
5306    ///
5307    /// Sets the *resource* path property to the given value.
5308    ///
5309    /// Even though the property as already been set when instantiating this call,
5310    /// we provide this method for API completeness.
5311    pub fn resource(mut self, new_value: &str) -> ProjectJobSetIamPolicyCall<'a, C> {
5312        self._resource = new_value.to_string();
5313        self
5314    }
5315    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5316    /// while executing the actual API request.
5317    ///
5318    /// ````text
5319    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5320    /// ````
5321    ///
5322    /// Sets the *delegate* property to the given value.
5323    pub fn delegate(
5324        mut self,
5325        new_value: &'a mut dyn common::Delegate,
5326    ) -> ProjectJobSetIamPolicyCall<'a, C> {
5327        self._delegate = Some(new_value);
5328        self
5329    }
5330
5331    /// Set any additional parameter of the query string used in the request.
5332    /// It should be used to set parameters which are not yet available through their own
5333    /// setters.
5334    ///
5335    /// Please note that this method must not be used to set any of the known parameters
5336    /// which have their own setter method. If done anyway, the request will fail.
5337    ///
5338    /// # Additional Parameters
5339    ///
5340    /// * *$.xgafv* (query-string) - V1 error format.
5341    /// * *access_token* (query-string) - OAuth access token.
5342    /// * *alt* (query-string) - Data format for response.
5343    /// * *callback* (query-string) - JSONP
5344    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5345    /// * *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.
5346    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5347    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5348    /// * *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.
5349    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5350    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5351    pub fn param<T>(mut self, name: T, value: T) -> ProjectJobSetIamPolicyCall<'a, C>
5352    where
5353        T: AsRef<str>,
5354    {
5355        self._additional_params
5356            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5357        self
5358    }
5359
5360    /// Identifies the authorization scope for the method you are building.
5361    ///
5362    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5363    /// [`Scope::CloudPlatform`].
5364    ///
5365    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5366    /// tokens for more than one scope.
5367    ///
5368    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5369    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5370    /// sufficient, a read-write scope will do as well.
5371    pub fn add_scope<St>(mut self, scope: St) -> ProjectJobSetIamPolicyCall<'a, C>
5372    where
5373        St: AsRef<str>,
5374    {
5375        self._scopes.insert(String::from(scope.as_ref()));
5376        self
5377    }
5378    /// Identifies the authorization scope(s) for the method you are building.
5379    ///
5380    /// See [`Self::add_scope()`] for details.
5381    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectJobSetIamPolicyCall<'a, C>
5382    where
5383        I: IntoIterator<Item = St>,
5384        St: AsRef<str>,
5385    {
5386        self._scopes
5387            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5388        self
5389    }
5390
5391    /// Removes all scopes, and no default scope will be used either.
5392    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5393    /// for details).
5394    pub fn clear_scopes(mut self) -> ProjectJobSetIamPolicyCall<'a, C> {
5395        self._scopes.clear();
5396        self
5397    }
5398}
5399
5400/// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
5401///
5402/// A builder for the *jobs.testIamPermissions* method supported by a *project* resource.
5403/// It is not used directly, but through a [`ProjectMethods`] instance.
5404///
5405/// # Example
5406///
5407/// Instantiate a resource method builder
5408///
5409/// ```test_harness,no_run
5410/// # extern crate hyper;
5411/// # extern crate hyper_rustls;
5412/// # extern crate google_ml1 as ml1;
5413/// use ml1::api::GoogleIamV1__TestIamPermissionsRequest;
5414/// # async fn dox() {
5415/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5416///
5417/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5418/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5419/// #     .with_native_roots()
5420/// #     .unwrap()
5421/// #     .https_only()
5422/// #     .enable_http2()
5423/// #     .build();
5424///
5425/// # let executor = hyper_util::rt::TokioExecutor::new();
5426/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5427/// #     secret,
5428/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5429/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5430/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5431/// #     ),
5432/// # ).build().await.unwrap();
5433///
5434/// # let client = hyper_util::client::legacy::Client::builder(
5435/// #     hyper_util::rt::TokioExecutor::new()
5436/// # )
5437/// # .build(
5438/// #     hyper_rustls::HttpsConnectorBuilder::new()
5439/// #         .with_native_roots()
5440/// #         .unwrap()
5441/// #         .https_or_http()
5442/// #         .enable_http2()
5443/// #         .build()
5444/// # );
5445/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
5446/// // As the method needs a request, you would usually fill it with the desired information
5447/// // into the respective structure. Some of the parts shown here might not be applicable !
5448/// // Values shown here are possibly random and not representative !
5449/// let mut req = GoogleIamV1__TestIamPermissionsRequest::default();
5450///
5451/// // You can configure optional parameters by calling the respective setters at will, and
5452/// // execute the final call using `doit()`.
5453/// // Values shown here are possibly random and not representative !
5454/// let result = hub.projects().jobs_test_iam_permissions(req, "resource")
5455///              .doit().await;
5456/// # }
5457/// ```
5458pub struct ProjectJobTestIamPermissionCall<'a, C>
5459where
5460    C: 'a,
5461{
5462    hub: &'a CloudMachineLearningEngine<C>,
5463    _request: GoogleIamV1__TestIamPermissionsRequest,
5464    _resource: String,
5465    _delegate: Option<&'a mut dyn common::Delegate>,
5466    _additional_params: HashMap<String, String>,
5467    _scopes: BTreeSet<String>,
5468}
5469
5470impl<'a, C> common::CallBuilder for ProjectJobTestIamPermissionCall<'a, C> {}
5471
5472impl<'a, C> ProjectJobTestIamPermissionCall<'a, C>
5473where
5474    C: common::Connector,
5475{
5476    /// Perform the operation you have build so far.
5477    pub async fn doit(
5478        mut self,
5479    ) -> common::Result<(common::Response, GoogleIamV1__TestIamPermissionsResponse)> {
5480        use std::borrow::Cow;
5481        use std::io::{Read, Seek};
5482
5483        use common::{url::Params, ToParts};
5484        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5485
5486        let mut dd = common::DefaultDelegate;
5487        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5488        dlg.begin(common::MethodInfo {
5489            id: "ml.projects.jobs.testIamPermissions",
5490            http_method: hyper::Method::POST,
5491        });
5492
5493        for &field in ["alt", "resource"].iter() {
5494            if self._additional_params.contains_key(field) {
5495                dlg.finished(false);
5496                return Err(common::Error::FieldClash(field));
5497            }
5498        }
5499
5500        let mut params = Params::with_capacity(4 + self._additional_params.len());
5501        params.push("resource", self._resource);
5502
5503        params.extend(self._additional_params.iter());
5504
5505        params.push("alt", "json");
5506        let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
5507        if self._scopes.is_empty() {
5508            self._scopes
5509                .insert(Scope::CloudPlatform.as_ref().to_string());
5510        }
5511
5512        #[allow(clippy::single_element_loop)]
5513        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
5514            url = params.uri_replacement(url, param_name, find_this, true);
5515        }
5516        {
5517            let to_remove = ["resource"];
5518            params.remove_params(&to_remove);
5519        }
5520
5521        let url = params.parse_with_url(&url);
5522
5523        let mut json_mime_type = mime::APPLICATION_JSON;
5524        let mut request_value_reader = {
5525            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5526            common::remove_json_null_values(&mut value);
5527            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5528            serde_json::to_writer(&mut dst, &value).unwrap();
5529            dst
5530        };
5531        let request_size = request_value_reader
5532            .seek(std::io::SeekFrom::End(0))
5533            .unwrap();
5534        request_value_reader
5535            .seek(std::io::SeekFrom::Start(0))
5536            .unwrap();
5537
5538        loop {
5539            let token = match self
5540                .hub
5541                .auth
5542                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5543                .await
5544            {
5545                Ok(token) => token,
5546                Err(e) => match dlg.token(e) {
5547                    Ok(token) => token,
5548                    Err(e) => {
5549                        dlg.finished(false);
5550                        return Err(common::Error::MissingToken(e));
5551                    }
5552                },
5553            };
5554            request_value_reader
5555                .seek(std::io::SeekFrom::Start(0))
5556                .unwrap();
5557            let mut req_result = {
5558                let client = &self.hub.client;
5559                dlg.pre_request();
5560                let mut req_builder = hyper::Request::builder()
5561                    .method(hyper::Method::POST)
5562                    .uri(url.as_str())
5563                    .header(USER_AGENT, self.hub._user_agent.clone());
5564
5565                if let Some(token) = token.as_ref() {
5566                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5567                }
5568
5569                let request = req_builder
5570                    .header(CONTENT_TYPE, json_mime_type.to_string())
5571                    .header(CONTENT_LENGTH, request_size as u64)
5572                    .body(common::to_body(
5573                        request_value_reader.get_ref().clone().into(),
5574                    ));
5575
5576                client.request(request.unwrap()).await
5577            };
5578
5579            match req_result {
5580                Err(err) => {
5581                    if let common::Retry::After(d) = dlg.http_error(&err) {
5582                        sleep(d).await;
5583                        continue;
5584                    }
5585                    dlg.finished(false);
5586                    return Err(common::Error::HttpError(err));
5587                }
5588                Ok(res) => {
5589                    let (mut parts, body) = res.into_parts();
5590                    let mut body = common::Body::new(body);
5591                    if !parts.status.is_success() {
5592                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5593                        let error = serde_json::from_str(&common::to_string(&bytes));
5594                        let response = common::to_response(parts, bytes.into());
5595
5596                        if let common::Retry::After(d) =
5597                            dlg.http_failure(&response, error.as_ref().ok())
5598                        {
5599                            sleep(d).await;
5600                            continue;
5601                        }
5602
5603                        dlg.finished(false);
5604
5605                        return Err(match error {
5606                            Ok(value) => common::Error::BadRequest(value),
5607                            _ => common::Error::Failure(response),
5608                        });
5609                    }
5610                    let response = {
5611                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5612                        let encoded = common::to_string(&bytes);
5613                        match serde_json::from_str(&encoded) {
5614                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5615                            Err(error) => {
5616                                dlg.response_json_decode_error(&encoded, &error);
5617                                return Err(common::Error::JsonDecodeError(
5618                                    encoded.to_string(),
5619                                    error,
5620                                ));
5621                            }
5622                        }
5623                    };
5624
5625                    dlg.finished(true);
5626                    return Ok(response);
5627                }
5628            }
5629        }
5630    }
5631
5632    ///
5633    /// Sets the *request* property to the given value.
5634    ///
5635    /// Even though the property as already been set when instantiating this call,
5636    /// we provide this method for API completeness.
5637    pub fn request(
5638        mut self,
5639        new_value: GoogleIamV1__TestIamPermissionsRequest,
5640    ) -> ProjectJobTestIamPermissionCall<'a, C> {
5641        self._request = new_value;
5642        self
5643    }
5644    /// REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
5645    ///
5646    /// Sets the *resource* path property to the given value.
5647    ///
5648    /// Even though the property as already been set when instantiating this call,
5649    /// we provide this method for API completeness.
5650    pub fn resource(mut self, new_value: &str) -> ProjectJobTestIamPermissionCall<'a, C> {
5651        self._resource = new_value.to_string();
5652        self
5653    }
5654    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5655    /// while executing the actual API request.
5656    ///
5657    /// ````text
5658    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5659    /// ````
5660    ///
5661    /// Sets the *delegate* property to the given value.
5662    pub fn delegate(
5663        mut self,
5664        new_value: &'a mut dyn common::Delegate,
5665    ) -> ProjectJobTestIamPermissionCall<'a, C> {
5666        self._delegate = Some(new_value);
5667        self
5668    }
5669
5670    /// Set any additional parameter of the query string used in the request.
5671    /// It should be used to set parameters which are not yet available through their own
5672    /// setters.
5673    ///
5674    /// Please note that this method must not be used to set any of the known parameters
5675    /// which have their own setter method. If done anyway, the request will fail.
5676    ///
5677    /// # Additional Parameters
5678    ///
5679    /// * *$.xgafv* (query-string) - V1 error format.
5680    /// * *access_token* (query-string) - OAuth access token.
5681    /// * *alt* (query-string) - Data format for response.
5682    /// * *callback* (query-string) - JSONP
5683    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5684    /// * *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.
5685    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5686    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5687    /// * *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.
5688    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5689    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5690    pub fn param<T>(mut self, name: T, value: T) -> ProjectJobTestIamPermissionCall<'a, C>
5691    where
5692        T: AsRef<str>,
5693    {
5694        self._additional_params
5695            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5696        self
5697    }
5698
5699    /// Identifies the authorization scope for the method you are building.
5700    ///
5701    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5702    /// [`Scope::CloudPlatform`].
5703    ///
5704    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5705    /// tokens for more than one scope.
5706    ///
5707    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5708    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5709    /// sufficient, a read-write scope will do as well.
5710    pub fn add_scope<St>(mut self, scope: St) -> ProjectJobTestIamPermissionCall<'a, C>
5711    where
5712        St: AsRef<str>,
5713    {
5714        self._scopes.insert(String::from(scope.as_ref()));
5715        self
5716    }
5717    /// Identifies the authorization scope(s) for the method you are building.
5718    ///
5719    /// See [`Self::add_scope()`] for details.
5720    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectJobTestIamPermissionCall<'a, C>
5721    where
5722        I: IntoIterator<Item = St>,
5723        St: AsRef<str>,
5724    {
5725        self._scopes
5726            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5727        self
5728    }
5729
5730    /// Removes all scopes, and no default scope will be used either.
5731    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5732    /// for details).
5733    pub fn clear_scopes(mut self) -> ProjectJobTestIamPermissionCall<'a, C> {
5734        self._scopes.clear();
5735        self
5736    }
5737}
5738
5739/// 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`.
5740///
5741/// A builder for the *locations.operations.cancel* method supported by a *project* resource.
5742/// It is not used directly, but through a [`ProjectMethods`] instance.
5743///
5744/// # Example
5745///
5746/// Instantiate a resource method builder
5747///
5748/// ```test_harness,no_run
5749/// # extern crate hyper;
5750/// # extern crate hyper_rustls;
5751/// # extern crate google_ml1 as ml1;
5752/// # async fn dox() {
5753/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5754///
5755/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5756/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5757/// #     .with_native_roots()
5758/// #     .unwrap()
5759/// #     .https_only()
5760/// #     .enable_http2()
5761/// #     .build();
5762///
5763/// # let executor = hyper_util::rt::TokioExecutor::new();
5764/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5765/// #     secret,
5766/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5767/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5768/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5769/// #     ),
5770/// # ).build().await.unwrap();
5771///
5772/// # let client = hyper_util::client::legacy::Client::builder(
5773/// #     hyper_util::rt::TokioExecutor::new()
5774/// # )
5775/// # .build(
5776/// #     hyper_rustls::HttpsConnectorBuilder::new()
5777/// #         .with_native_roots()
5778/// #         .unwrap()
5779/// #         .https_or_http()
5780/// #         .enable_http2()
5781/// #         .build()
5782/// # );
5783/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
5784/// // You can configure optional parameters by calling the respective setters at will, and
5785/// // execute the final call using `doit()`.
5786/// // Values shown here are possibly random and not representative !
5787/// let result = hub.projects().locations_operations_cancel("name")
5788///              .doit().await;
5789/// # }
5790/// ```
5791pub struct ProjectLocationOperationCancelCall<'a, C>
5792where
5793    C: 'a,
5794{
5795    hub: &'a CloudMachineLearningEngine<C>,
5796    _name: String,
5797    _delegate: Option<&'a mut dyn common::Delegate>,
5798    _additional_params: HashMap<String, String>,
5799    _scopes: BTreeSet<String>,
5800}
5801
5802impl<'a, C> common::CallBuilder for ProjectLocationOperationCancelCall<'a, C> {}
5803
5804impl<'a, C> ProjectLocationOperationCancelCall<'a, C>
5805where
5806    C: common::Connector,
5807{
5808    /// Perform the operation you have build so far.
5809    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleProtobuf__Empty)> {
5810        use std::borrow::Cow;
5811        use std::io::{Read, Seek};
5812
5813        use common::{url::Params, ToParts};
5814        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5815
5816        let mut dd = common::DefaultDelegate;
5817        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5818        dlg.begin(common::MethodInfo {
5819            id: "ml.projects.locations.operations.cancel",
5820            http_method: hyper::Method::POST,
5821        });
5822
5823        for &field in ["alt", "name"].iter() {
5824            if self._additional_params.contains_key(field) {
5825                dlg.finished(false);
5826                return Err(common::Error::FieldClash(field));
5827            }
5828        }
5829
5830        let mut params = Params::with_capacity(3 + self._additional_params.len());
5831        params.push("name", self._name);
5832
5833        params.extend(self._additional_params.iter());
5834
5835        params.push("alt", "json");
5836        let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
5837        if self._scopes.is_empty() {
5838            self._scopes
5839                .insert(Scope::CloudPlatform.as_ref().to_string());
5840        }
5841
5842        #[allow(clippy::single_element_loop)]
5843        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5844            url = params.uri_replacement(url, param_name, find_this, true);
5845        }
5846        {
5847            let to_remove = ["name"];
5848            params.remove_params(&to_remove);
5849        }
5850
5851        let url = params.parse_with_url(&url);
5852
5853        loop {
5854            let token = match self
5855                .hub
5856                .auth
5857                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5858                .await
5859            {
5860                Ok(token) => token,
5861                Err(e) => match dlg.token(e) {
5862                    Ok(token) => token,
5863                    Err(e) => {
5864                        dlg.finished(false);
5865                        return Err(common::Error::MissingToken(e));
5866                    }
5867                },
5868            };
5869            let mut req_result = {
5870                let client = &self.hub.client;
5871                dlg.pre_request();
5872                let mut req_builder = hyper::Request::builder()
5873                    .method(hyper::Method::POST)
5874                    .uri(url.as_str())
5875                    .header(USER_AGENT, self.hub._user_agent.clone());
5876
5877                if let Some(token) = token.as_ref() {
5878                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5879                }
5880
5881                let request = req_builder
5882                    .header(CONTENT_LENGTH, 0_u64)
5883                    .body(common::to_body::<String>(None));
5884
5885                client.request(request.unwrap()).await
5886            };
5887
5888            match req_result {
5889                Err(err) => {
5890                    if let common::Retry::After(d) = dlg.http_error(&err) {
5891                        sleep(d).await;
5892                        continue;
5893                    }
5894                    dlg.finished(false);
5895                    return Err(common::Error::HttpError(err));
5896                }
5897                Ok(res) => {
5898                    let (mut parts, body) = res.into_parts();
5899                    let mut body = common::Body::new(body);
5900                    if !parts.status.is_success() {
5901                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5902                        let error = serde_json::from_str(&common::to_string(&bytes));
5903                        let response = common::to_response(parts, bytes.into());
5904
5905                        if let common::Retry::After(d) =
5906                            dlg.http_failure(&response, error.as_ref().ok())
5907                        {
5908                            sleep(d).await;
5909                            continue;
5910                        }
5911
5912                        dlg.finished(false);
5913
5914                        return Err(match error {
5915                            Ok(value) => common::Error::BadRequest(value),
5916                            _ => common::Error::Failure(response),
5917                        });
5918                    }
5919                    let response = {
5920                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5921                        let encoded = common::to_string(&bytes);
5922                        match serde_json::from_str(&encoded) {
5923                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5924                            Err(error) => {
5925                                dlg.response_json_decode_error(&encoded, &error);
5926                                return Err(common::Error::JsonDecodeError(
5927                                    encoded.to_string(),
5928                                    error,
5929                                ));
5930                            }
5931                        }
5932                    };
5933
5934                    dlg.finished(true);
5935                    return Ok(response);
5936                }
5937            }
5938        }
5939    }
5940
5941    /// The name of the operation resource to be cancelled.
5942    ///
5943    /// Sets the *name* path property to the given value.
5944    ///
5945    /// Even though the property as already been set when instantiating this call,
5946    /// we provide this method for API completeness.
5947    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationCancelCall<'a, C> {
5948        self._name = new_value.to_string();
5949        self
5950    }
5951    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5952    /// while executing the actual API request.
5953    ///
5954    /// ````text
5955    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5956    /// ````
5957    ///
5958    /// Sets the *delegate* property to the given value.
5959    pub fn delegate(
5960        mut self,
5961        new_value: &'a mut dyn common::Delegate,
5962    ) -> ProjectLocationOperationCancelCall<'a, C> {
5963        self._delegate = Some(new_value);
5964        self
5965    }
5966
5967    /// Set any additional parameter of the query string used in the request.
5968    /// It should be used to set parameters which are not yet available through their own
5969    /// setters.
5970    ///
5971    /// Please note that this method must not be used to set any of the known parameters
5972    /// which have their own setter method. If done anyway, the request will fail.
5973    ///
5974    /// # Additional Parameters
5975    ///
5976    /// * *$.xgafv* (query-string) - V1 error format.
5977    /// * *access_token* (query-string) - OAuth access token.
5978    /// * *alt* (query-string) - Data format for response.
5979    /// * *callback* (query-string) - JSONP
5980    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5981    /// * *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.
5982    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5983    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5984    /// * *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.
5985    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5986    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5987    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationCancelCall<'a, C>
5988    where
5989        T: AsRef<str>,
5990    {
5991        self._additional_params
5992            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5993        self
5994    }
5995
5996    /// Identifies the authorization scope for the method you are building.
5997    ///
5998    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5999    /// [`Scope::CloudPlatform`].
6000    ///
6001    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6002    /// tokens for more than one scope.
6003    ///
6004    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6005    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6006    /// sufficient, a read-write scope will do as well.
6007    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationCancelCall<'a, C>
6008    where
6009        St: AsRef<str>,
6010    {
6011        self._scopes.insert(String::from(scope.as_ref()));
6012        self
6013    }
6014    /// Identifies the authorization scope(s) for the method you are building.
6015    ///
6016    /// See [`Self::add_scope()`] for details.
6017    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationCancelCall<'a, C>
6018    where
6019        I: IntoIterator<Item = St>,
6020        St: AsRef<str>,
6021    {
6022        self._scopes
6023            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6024        self
6025    }
6026
6027    /// Removes all scopes, and no default scope will be used either.
6028    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6029    /// for details).
6030    pub fn clear_scopes(mut self) -> ProjectLocationOperationCancelCall<'a, C> {
6031        self._scopes.clear();
6032        self
6033    }
6034}
6035
6036/// 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.
6037///
6038/// A builder for the *locations.operations.get* method supported by a *project* resource.
6039/// It is not used directly, but through a [`ProjectMethods`] instance.
6040///
6041/// # Example
6042///
6043/// Instantiate a resource method builder
6044///
6045/// ```test_harness,no_run
6046/// # extern crate hyper;
6047/// # extern crate hyper_rustls;
6048/// # extern crate google_ml1 as ml1;
6049/// # async fn dox() {
6050/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6051///
6052/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6053/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6054/// #     .with_native_roots()
6055/// #     .unwrap()
6056/// #     .https_only()
6057/// #     .enable_http2()
6058/// #     .build();
6059///
6060/// # let executor = hyper_util::rt::TokioExecutor::new();
6061/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6062/// #     secret,
6063/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6064/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6065/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6066/// #     ),
6067/// # ).build().await.unwrap();
6068///
6069/// # let client = hyper_util::client::legacy::Client::builder(
6070/// #     hyper_util::rt::TokioExecutor::new()
6071/// # )
6072/// # .build(
6073/// #     hyper_rustls::HttpsConnectorBuilder::new()
6074/// #         .with_native_roots()
6075/// #         .unwrap()
6076/// #         .https_or_http()
6077/// #         .enable_http2()
6078/// #         .build()
6079/// # );
6080/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
6081/// // You can configure optional parameters by calling the respective setters at will, and
6082/// // execute the final call using `doit()`.
6083/// // Values shown here are possibly random and not representative !
6084/// let result = hub.projects().locations_operations_get("name")
6085///              .doit().await;
6086/// # }
6087/// ```
6088pub struct ProjectLocationOperationGetCall<'a, C>
6089where
6090    C: 'a,
6091{
6092    hub: &'a CloudMachineLearningEngine<C>,
6093    _name: String,
6094    _delegate: Option<&'a mut dyn common::Delegate>,
6095    _additional_params: HashMap<String, String>,
6096    _scopes: BTreeSet<String>,
6097}
6098
6099impl<'a, C> common::CallBuilder for ProjectLocationOperationGetCall<'a, C> {}
6100
6101impl<'a, C> ProjectLocationOperationGetCall<'a, C>
6102where
6103    C: common::Connector,
6104{
6105    /// Perform the operation you have build so far.
6106    pub async fn doit(
6107        mut self,
6108    ) -> common::Result<(common::Response, GoogleLongrunning__Operation)> {
6109        use std::borrow::Cow;
6110        use std::io::{Read, Seek};
6111
6112        use common::{url::Params, ToParts};
6113        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6114
6115        let mut dd = common::DefaultDelegate;
6116        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6117        dlg.begin(common::MethodInfo {
6118            id: "ml.projects.locations.operations.get",
6119            http_method: hyper::Method::GET,
6120        });
6121
6122        for &field in ["alt", "name"].iter() {
6123            if self._additional_params.contains_key(field) {
6124                dlg.finished(false);
6125                return Err(common::Error::FieldClash(field));
6126            }
6127        }
6128
6129        let mut params = Params::with_capacity(3 + self._additional_params.len());
6130        params.push("name", self._name);
6131
6132        params.extend(self._additional_params.iter());
6133
6134        params.push("alt", "json");
6135        let mut url = self.hub._base_url.clone() + "v1/{+name}";
6136        if self._scopes.is_empty() {
6137            self._scopes
6138                .insert(Scope::CloudPlatform.as_ref().to_string());
6139        }
6140
6141        #[allow(clippy::single_element_loop)]
6142        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6143            url = params.uri_replacement(url, param_name, find_this, true);
6144        }
6145        {
6146            let to_remove = ["name"];
6147            params.remove_params(&to_remove);
6148        }
6149
6150        let url = params.parse_with_url(&url);
6151
6152        loop {
6153            let token = match self
6154                .hub
6155                .auth
6156                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6157                .await
6158            {
6159                Ok(token) => token,
6160                Err(e) => match dlg.token(e) {
6161                    Ok(token) => token,
6162                    Err(e) => {
6163                        dlg.finished(false);
6164                        return Err(common::Error::MissingToken(e));
6165                    }
6166                },
6167            };
6168            let mut req_result = {
6169                let client = &self.hub.client;
6170                dlg.pre_request();
6171                let mut req_builder = hyper::Request::builder()
6172                    .method(hyper::Method::GET)
6173                    .uri(url.as_str())
6174                    .header(USER_AGENT, self.hub._user_agent.clone());
6175
6176                if let Some(token) = token.as_ref() {
6177                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6178                }
6179
6180                let request = req_builder
6181                    .header(CONTENT_LENGTH, 0_u64)
6182                    .body(common::to_body::<String>(None));
6183
6184                client.request(request.unwrap()).await
6185            };
6186
6187            match req_result {
6188                Err(err) => {
6189                    if let common::Retry::After(d) = dlg.http_error(&err) {
6190                        sleep(d).await;
6191                        continue;
6192                    }
6193                    dlg.finished(false);
6194                    return Err(common::Error::HttpError(err));
6195                }
6196                Ok(res) => {
6197                    let (mut parts, body) = res.into_parts();
6198                    let mut body = common::Body::new(body);
6199                    if !parts.status.is_success() {
6200                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6201                        let error = serde_json::from_str(&common::to_string(&bytes));
6202                        let response = common::to_response(parts, bytes.into());
6203
6204                        if let common::Retry::After(d) =
6205                            dlg.http_failure(&response, error.as_ref().ok())
6206                        {
6207                            sleep(d).await;
6208                            continue;
6209                        }
6210
6211                        dlg.finished(false);
6212
6213                        return Err(match error {
6214                            Ok(value) => common::Error::BadRequest(value),
6215                            _ => common::Error::Failure(response),
6216                        });
6217                    }
6218                    let response = {
6219                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6220                        let encoded = common::to_string(&bytes);
6221                        match serde_json::from_str(&encoded) {
6222                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6223                            Err(error) => {
6224                                dlg.response_json_decode_error(&encoded, &error);
6225                                return Err(common::Error::JsonDecodeError(
6226                                    encoded.to_string(),
6227                                    error,
6228                                ));
6229                            }
6230                        }
6231                    };
6232
6233                    dlg.finished(true);
6234                    return Ok(response);
6235                }
6236            }
6237        }
6238    }
6239
6240    /// The name of the operation resource.
6241    ///
6242    /// Sets the *name* path property to the given value.
6243    ///
6244    /// Even though the property as already been set when instantiating this call,
6245    /// we provide this method for API completeness.
6246    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationGetCall<'a, C> {
6247        self._name = new_value.to_string();
6248        self
6249    }
6250    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6251    /// while executing the actual API request.
6252    ///
6253    /// ````text
6254    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6255    /// ````
6256    ///
6257    /// Sets the *delegate* property to the given value.
6258    pub fn delegate(
6259        mut self,
6260        new_value: &'a mut dyn common::Delegate,
6261    ) -> ProjectLocationOperationGetCall<'a, C> {
6262        self._delegate = Some(new_value);
6263        self
6264    }
6265
6266    /// Set any additional parameter of the query string used in the request.
6267    /// It should be used to set parameters which are not yet available through their own
6268    /// setters.
6269    ///
6270    /// Please note that this method must not be used to set any of the known parameters
6271    /// which have their own setter method. If done anyway, the request will fail.
6272    ///
6273    /// # Additional Parameters
6274    ///
6275    /// * *$.xgafv* (query-string) - V1 error format.
6276    /// * *access_token* (query-string) - OAuth access token.
6277    /// * *alt* (query-string) - Data format for response.
6278    /// * *callback* (query-string) - JSONP
6279    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6280    /// * *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.
6281    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6282    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6283    /// * *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.
6284    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6285    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6286    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationGetCall<'a, C>
6287    where
6288        T: AsRef<str>,
6289    {
6290        self._additional_params
6291            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6292        self
6293    }
6294
6295    /// Identifies the authorization scope for the method you are building.
6296    ///
6297    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6298    /// [`Scope::CloudPlatform`].
6299    ///
6300    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6301    /// tokens for more than one scope.
6302    ///
6303    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6304    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6305    /// sufficient, a read-write scope will do as well.
6306    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationGetCall<'a, C>
6307    where
6308        St: AsRef<str>,
6309    {
6310        self._scopes.insert(String::from(scope.as_ref()));
6311        self
6312    }
6313    /// Identifies the authorization scope(s) for the method you are building.
6314    ///
6315    /// See [`Self::add_scope()`] for details.
6316    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationGetCall<'a, C>
6317    where
6318        I: IntoIterator<Item = St>,
6319        St: AsRef<str>,
6320    {
6321        self._scopes
6322            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6323        self
6324    }
6325
6326    /// Removes all scopes, and no default scope will be used either.
6327    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6328    /// for details).
6329    pub fn clear_scopes(mut self) -> ProjectLocationOperationGetCall<'a, C> {
6330        self._scopes.clear();
6331        self
6332    }
6333}
6334
6335/// Adds a measurement of the objective metrics to a trial. This measurement is assumed to have been taken before the trial is complete.
6336///
6337/// A builder for the *locations.studies.trials.addMeasurement* method supported by a *project* resource.
6338/// It is not used directly, but through a [`ProjectMethods`] instance.
6339///
6340/// # Example
6341///
6342/// Instantiate a resource method builder
6343///
6344/// ```test_harness,no_run
6345/// # extern crate hyper;
6346/// # extern crate hyper_rustls;
6347/// # extern crate google_ml1 as ml1;
6348/// use ml1::api::GoogleCloudMlV1__AddTrialMeasurementRequest;
6349/// # async fn dox() {
6350/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6351///
6352/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6353/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6354/// #     .with_native_roots()
6355/// #     .unwrap()
6356/// #     .https_only()
6357/// #     .enable_http2()
6358/// #     .build();
6359///
6360/// # let executor = hyper_util::rt::TokioExecutor::new();
6361/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6362/// #     secret,
6363/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6364/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6365/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6366/// #     ),
6367/// # ).build().await.unwrap();
6368///
6369/// # let client = hyper_util::client::legacy::Client::builder(
6370/// #     hyper_util::rt::TokioExecutor::new()
6371/// # )
6372/// # .build(
6373/// #     hyper_rustls::HttpsConnectorBuilder::new()
6374/// #         .with_native_roots()
6375/// #         .unwrap()
6376/// #         .https_or_http()
6377/// #         .enable_http2()
6378/// #         .build()
6379/// # );
6380/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
6381/// // As the method needs a request, you would usually fill it with the desired information
6382/// // into the respective structure. Some of the parts shown here might not be applicable !
6383/// // Values shown here are possibly random and not representative !
6384/// let mut req = GoogleCloudMlV1__AddTrialMeasurementRequest::default();
6385///
6386/// // You can configure optional parameters by calling the respective setters at will, and
6387/// // execute the final call using `doit()`.
6388/// // Values shown here are possibly random and not representative !
6389/// let result = hub.projects().locations_studies_trials_add_measurement(req, "name")
6390///              .doit().await;
6391/// # }
6392/// ```
6393pub struct ProjectLocationStudyTrialAddMeasurementCall<'a, C>
6394where
6395    C: 'a,
6396{
6397    hub: &'a CloudMachineLearningEngine<C>,
6398    _request: GoogleCloudMlV1__AddTrialMeasurementRequest,
6399    _name: String,
6400    _delegate: Option<&'a mut dyn common::Delegate>,
6401    _additional_params: HashMap<String, String>,
6402    _scopes: BTreeSet<String>,
6403}
6404
6405impl<'a, C> common::CallBuilder for ProjectLocationStudyTrialAddMeasurementCall<'a, C> {}
6406
6407impl<'a, C> ProjectLocationStudyTrialAddMeasurementCall<'a, C>
6408where
6409    C: common::Connector,
6410{
6411    /// Perform the operation you have build so far.
6412    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleCloudMlV1__Trial)> {
6413        use std::borrow::Cow;
6414        use std::io::{Read, Seek};
6415
6416        use common::{url::Params, ToParts};
6417        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6418
6419        let mut dd = common::DefaultDelegate;
6420        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6421        dlg.begin(common::MethodInfo {
6422            id: "ml.projects.locations.studies.trials.addMeasurement",
6423            http_method: hyper::Method::POST,
6424        });
6425
6426        for &field in ["alt", "name"].iter() {
6427            if self._additional_params.contains_key(field) {
6428                dlg.finished(false);
6429                return Err(common::Error::FieldClash(field));
6430            }
6431        }
6432
6433        let mut params = Params::with_capacity(4 + self._additional_params.len());
6434        params.push("name", self._name);
6435
6436        params.extend(self._additional_params.iter());
6437
6438        params.push("alt", "json");
6439        let mut url = self.hub._base_url.clone() + "v1/{+name}:addMeasurement";
6440        if self._scopes.is_empty() {
6441            self._scopes
6442                .insert(Scope::CloudPlatform.as_ref().to_string());
6443        }
6444
6445        #[allow(clippy::single_element_loop)]
6446        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6447            url = params.uri_replacement(url, param_name, find_this, true);
6448        }
6449        {
6450            let to_remove = ["name"];
6451            params.remove_params(&to_remove);
6452        }
6453
6454        let url = params.parse_with_url(&url);
6455
6456        let mut json_mime_type = mime::APPLICATION_JSON;
6457        let mut request_value_reader = {
6458            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6459            common::remove_json_null_values(&mut value);
6460            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6461            serde_json::to_writer(&mut dst, &value).unwrap();
6462            dst
6463        };
6464        let request_size = request_value_reader
6465            .seek(std::io::SeekFrom::End(0))
6466            .unwrap();
6467        request_value_reader
6468            .seek(std::io::SeekFrom::Start(0))
6469            .unwrap();
6470
6471        loop {
6472            let token = match self
6473                .hub
6474                .auth
6475                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6476                .await
6477            {
6478                Ok(token) => token,
6479                Err(e) => match dlg.token(e) {
6480                    Ok(token) => token,
6481                    Err(e) => {
6482                        dlg.finished(false);
6483                        return Err(common::Error::MissingToken(e));
6484                    }
6485                },
6486            };
6487            request_value_reader
6488                .seek(std::io::SeekFrom::Start(0))
6489                .unwrap();
6490            let mut req_result = {
6491                let client = &self.hub.client;
6492                dlg.pre_request();
6493                let mut req_builder = hyper::Request::builder()
6494                    .method(hyper::Method::POST)
6495                    .uri(url.as_str())
6496                    .header(USER_AGENT, self.hub._user_agent.clone());
6497
6498                if let Some(token) = token.as_ref() {
6499                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6500                }
6501
6502                let request = req_builder
6503                    .header(CONTENT_TYPE, json_mime_type.to_string())
6504                    .header(CONTENT_LENGTH, request_size as u64)
6505                    .body(common::to_body(
6506                        request_value_reader.get_ref().clone().into(),
6507                    ));
6508
6509                client.request(request.unwrap()).await
6510            };
6511
6512            match req_result {
6513                Err(err) => {
6514                    if let common::Retry::After(d) = dlg.http_error(&err) {
6515                        sleep(d).await;
6516                        continue;
6517                    }
6518                    dlg.finished(false);
6519                    return Err(common::Error::HttpError(err));
6520                }
6521                Ok(res) => {
6522                    let (mut parts, body) = res.into_parts();
6523                    let mut body = common::Body::new(body);
6524                    if !parts.status.is_success() {
6525                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6526                        let error = serde_json::from_str(&common::to_string(&bytes));
6527                        let response = common::to_response(parts, bytes.into());
6528
6529                        if let common::Retry::After(d) =
6530                            dlg.http_failure(&response, error.as_ref().ok())
6531                        {
6532                            sleep(d).await;
6533                            continue;
6534                        }
6535
6536                        dlg.finished(false);
6537
6538                        return Err(match error {
6539                            Ok(value) => common::Error::BadRequest(value),
6540                            _ => common::Error::Failure(response),
6541                        });
6542                    }
6543                    let response = {
6544                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6545                        let encoded = common::to_string(&bytes);
6546                        match serde_json::from_str(&encoded) {
6547                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6548                            Err(error) => {
6549                                dlg.response_json_decode_error(&encoded, &error);
6550                                return Err(common::Error::JsonDecodeError(
6551                                    encoded.to_string(),
6552                                    error,
6553                                ));
6554                            }
6555                        }
6556                    };
6557
6558                    dlg.finished(true);
6559                    return Ok(response);
6560                }
6561            }
6562        }
6563    }
6564
6565    ///
6566    /// Sets the *request* property to the given value.
6567    ///
6568    /// Even though the property as already been set when instantiating this call,
6569    /// we provide this method for API completeness.
6570    pub fn request(
6571        mut self,
6572        new_value: GoogleCloudMlV1__AddTrialMeasurementRequest,
6573    ) -> ProjectLocationStudyTrialAddMeasurementCall<'a, C> {
6574        self._request = new_value;
6575        self
6576    }
6577    /// Required. The trial name.
6578    ///
6579    /// Sets the *name* path property to the given value.
6580    ///
6581    /// Even though the property as already been set when instantiating this call,
6582    /// we provide this method for API completeness.
6583    pub fn name(mut self, new_value: &str) -> ProjectLocationStudyTrialAddMeasurementCall<'a, C> {
6584        self._name = new_value.to_string();
6585        self
6586    }
6587    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6588    /// while executing the actual API request.
6589    ///
6590    /// ````text
6591    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6592    /// ````
6593    ///
6594    /// Sets the *delegate* property to the given value.
6595    pub fn delegate(
6596        mut self,
6597        new_value: &'a mut dyn common::Delegate,
6598    ) -> ProjectLocationStudyTrialAddMeasurementCall<'a, C> {
6599        self._delegate = Some(new_value);
6600        self
6601    }
6602
6603    /// Set any additional parameter of the query string used in the request.
6604    /// It should be used to set parameters which are not yet available through their own
6605    /// setters.
6606    ///
6607    /// Please note that this method must not be used to set any of the known parameters
6608    /// which have their own setter method. If done anyway, the request will fail.
6609    ///
6610    /// # Additional Parameters
6611    ///
6612    /// * *$.xgafv* (query-string) - V1 error format.
6613    /// * *access_token* (query-string) - OAuth access token.
6614    /// * *alt* (query-string) - Data format for response.
6615    /// * *callback* (query-string) - JSONP
6616    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6617    /// * *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.
6618    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6619    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6620    /// * *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.
6621    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6622    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6623    pub fn param<T>(
6624        mut self,
6625        name: T,
6626        value: T,
6627    ) -> ProjectLocationStudyTrialAddMeasurementCall<'a, C>
6628    where
6629        T: AsRef<str>,
6630    {
6631        self._additional_params
6632            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6633        self
6634    }
6635
6636    /// Identifies the authorization scope for the method you are building.
6637    ///
6638    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6639    /// [`Scope::CloudPlatform`].
6640    ///
6641    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6642    /// tokens for more than one scope.
6643    ///
6644    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6645    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6646    /// sufficient, a read-write scope will do as well.
6647    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationStudyTrialAddMeasurementCall<'a, C>
6648    where
6649        St: AsRef<str>,
6650    {
6651        self._scopes.insert(String::from(scope.as_ref()));
6652        self
6653    }
6654    /// Identifies the authorization scope(s) for the method you are building.
6655    ///
6656    /// See [`Self::add_scope()`] for details.
6657    pub fn add_scopes<I, St>(
6658        mut self,
6659        scopes: I,
6660    ) -> ProjectLocationStudyTrialAddMeasurementCall<'a, C>
6661    where
6662        I: IntoIterator<Item = St>,
6663        St: AsRef<str>,
6664    {
6665        self._scopes
6666            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6667        self
6668    }
6669
6670    /// Removes all scopes, and no default scope will be used either.
6671    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6672    /// for details).
6673    pub fn clear_scopes(mut self) -> ProjectLocationStudyTrialAddMeasurementCall<'a, C> {
6674        self._scopes.clear();
6675        self
6676    }
6677}
6678
6679/// Checks whether a trial should stop or not. Returns a long-running operation. When the operation is successful, it will contain a CheckTrialEarlyStoppingStateResponse.
6680///
6681/// A builder for the *locations.studies.trials.checkEarlyStoppingState* method supported by a *project* resource.
6682/// It is not used directly, but through a [`ProjectMethods`] instance.
6683///
6684/// # Example
6685///
6686/// Instantiate a resource method builder
6687///
6688/// ```test_harness,no_run
6689/// # extern crate hyper;
6690/// # extern crate hyper_rustls;
6691/// # extern crate google_ml1 as ml1;
6692/// use ml1::api::GoogleCloudMlV1__CheckTrialEarlyStoppingStateRequest;
6693/// # async fn dox() {
6694/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6695///
6696/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6697/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6698/// #     .with_native_roots()
6699/// #     .unwrap()
6700/// #     .https_only()
6701/// #     .enable_http2()
6702/// #     .build();
6703///
6704/// # let executor = hyper_util::rt::TokioExecutor::new();
6705/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6706/// #     secret,
6707/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6708/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6709/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6710/// #     ),
6711/// # ).build().await.unwrap();
6712///
6713/// # let client = hyper_util::client::legacy::Client::builder(
6714/// #     hyper_util::rt::TokioExecutor::new()
6715/// # )
6716/// # .build(
6717/// #     hyper_rustls::HttpsConnectorBuilder::new()
6718/// #         .with_native_roots()
6719/// #         .unwrap()
6720/// #         .https_or_http()
6721/// #         .enable_http2()
6722/// #         .build()
6723/// # );
6724/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
6725/// // As the method needs a request, you would usually fill it with the desired information
6726/// // into the respective structure. Some of the parts shown here might not be applicable !
6727/// // Values shown here are possibly random and not representative !
6728/// let mut req = GoogleCloudMlV1__CheckTrialEarlyStoppingStateRequest::default();
6729///
6730/// // You can configure optional parameters by calling the respective setters at will, and
6731/// // execute the final call using `doit()`.
6732/// // Values shown here are possibly random and not representative !
6733/// let result = hub.projects().locations_studies_trials_check_early_stopping_state(req, "name")
6734///              .doit().await;
6735/// # }
6736/// ```
6737pub struct ProjectLocationStudyTrialCheckEarlyStoppingStateCall<'a, C>
6738where
6739    C: 'a,
6740{
6741    hub: &'a CloudMachineLearningEngine<C>,
6742    _request: GoogleCloudMlV1__CheckTrialEarlyStoppingStateRequest,
6743    _name: String,
6744    _delegate: Option<&'a mut dyn common::Delegate>,
6745    _additional_params: HashMap<String, String>,
6746    _scopes: BTreeSet<String>,
6747}
6748
6749impl<'a, C> common::CallBuilder for ProjectLocationStudyTrialCheckEarlyStoppingStateCall<'a, C> {}
6750
6751impl<'a, C> ProjectLocationStudyTrialCheckEarlyStoppingStateCall<'a, C>
6752where
6753    C: common::Connector,
6754{
6755    /// Perform the operation you have build so far.
6756    pub async fn doit(
6757        mut self,
6758    ) -> common::Result<(common::Response, GoogleLongrunning__Operation)> {
6759        use std::borrow::Cow;
6760        use std::io::{Read, Seek};
6761
6762        use common::{url::Params, ToParts};
6763        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6764
6765        let mut dd = common::DefaultDelegate;
6766        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6767        dlg.begin(common::MethodInfo {
6768            id: "ml.projects.locations.studies.trials.checkEarlyStoppingState",
6769            http_method: hyper::Method::POST,
6770        });
6771
6772        for &field in ["alt", "name"].iter() {
6773            if self._additional_params.contains_key(field) {
6774                dlg.finished(false);
6775                return Err(common::Error::FieldClash(field));
6776            }
6777        }
6778
6779        let mut params = Params::with_capacity(4 + self._additional_params.len());
6780        params.push("name", self._name);
6781
6782        params.extend(self._additional_params.iter());
6783
6784        params.push("alt", "json");
6785        let mut url = self.hub._base_url.clone() + "v1/{+name}:checkEarlyStoppingState";
6786        if self._scopes.is_empty() {
6787            self._scopes
6788                .insert(Scope::CloudPlatform.as_ref().to_string());
6789        }
6790
6791        #[allow(clippy::single_element_loop)]
6792        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6793            url = params.uri_replacement(url, param_name, find_this, true);
6794        }
6795        {
6796            let to_remove = ["name"];
6797            params.remove_params(&to_remove);
6798        }
6799
6800        let url = params.parse_with_url(&url);
6801
6802        let mut json_mime_type = mime::APPLICATION_JSON;
6803        let mut request_value_reader = {
6804            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6805            common::remove_json_null_values(&mut value);
6806            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6807            serde_json::to_writer(&mut dst, &value).unwrap();
6808            dst
6809        };
6810        let request_size = request_value_reader
6811            .seek(std::io::SeekFrom::End(0))
6812            .unwrap();
6813        request_value_reader
6814            .seek(std::io::SeekFrom::Start(0))
6815            .unwrap();
6816
6817        loop {
6818            let token = match self
6819                .hub
6820                .auth
6821                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6822                .await
6823            {
6824                Ok(token) => token,
6825                Err(e) => match dlg.token(e) {
6826                    Ok(token) => token,
6827                    Err(e) => {
6828                        dlg.finished(false);
6829                        return Err(common::Error::MissingToken(e));
6830                    }
6831                },
6832            };
6833            request_value_reader
6834                .seek(std::io::SeekFrom::Start(0))
6835                .unwrap();
6836            let mut req_result = {
6837                let client = &self.hub.client;
6838                dlg.pre_request();
6839                let mut req_builder = hyper::Request::builder()
6840                    .method(hyper::Method::POST)
6841                    .uri(url.as_str())
6842                    .header(USER_AGENT, self.hub._user_agent.clone());
6843
6844                if let Some(token) = token.as_ref() {
6845                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6846                }
6847
6848                let request = req_builder
6849                    .header(CONTENT_TYPE, json_mime_type.to_string())
6850                    .header(CONTENT_LENGTH, request_size as u64)
6851                    .body(common::to_body(
6852                        request_value_reader.get_ref().clone().into(),
6853                    ));
6854
6855                client.request(request.unwrap()).await
6856            };
6857
6858            match req_result {
6859                Err(err) => {
6860                    if let common::Retry::After(d) = dlg.http_error(&err) {
6861                        sleep(d).await;
6862                        continue;
6863                    }
6864                    dlg.finished(false);
6865                    return Err(common::Error::HttpError(err));
6866                }
6867                Ok(res) => {
6868                    let (mut parts, body) = res.into_parts();
6869                    let mut body = common::Body::new(body);
6870                    if !parts.status.is_success() {
6871                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6872                        let error = serde_json::from_str(&common::to_string(&bytes));
6873                        let response = common::to_response(parts, bytes.into());
6874
6875                        if let common::Retry::After(d) =
6876                            dlg.http_failure(&response, error.as_ref().ok())
6877                        {
6878                            sleep(d).await;
6879                            continue;
6880                        }
6881
6882                        dlg.finished(false);
6883
6884                        return Err(match error {
6885                            Ok(value) => common::Error::BadRequest(value),
6886                            _ => common::Error::Failure(response),
6887                        });
6888                    }
6889                    let response = {
6890                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6891                        let encoded = common::to_string(&bytes);
6892                        match serde_json::from_str(&encoded) {
6893                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6894                            Err(error) => {
6895                                dlg.response_json_decode_error(&encoded, &error);
6896                                return Err(common::Error::JsonDecodeError(
6897                                    encoded.to_string(),
6898                                    error,
6899                                ));
6900                            }
6901                        }
6902                    };
6903
6904                    dlg.finished(true);
6905                    return Ok(response);
6906                }
6907            }
6908        }
6909    }
6910
6911    ///
6912    /// Sets the *request* property to the given value.
6913    ///
6914    /// Even though the property as already been set when instantiating this call,
6915    /// we provide this method for API completeness.
6916    pub fn request(
6917        mut self,
6918        new_value: GoogleCloudMlV1__CheckTrialEarlyStoppingStateRequest,
6919    ) -> ProjectLocationStudyTrialCheckEarlyStoppingStateCall<'a, C> {
6920        self._request = new_value;
6921        self
6922    }
6923    /// Required. The trial name.
6924    ///
6925    /// Sets the *name* path property to the given value.
6926    ///
6927    /// Even though the property as already been set when instantiating this call,
6928    /// we provide this method for API completeness.
6929    pub fn name(
6930        mut self,
6931        new_value: &str,
6932    ) -> ProjectLocationStudyTrialCheckEarlyStoppingStateCall<'a, C> {
6933        self._name = new_value.to_string();
6934        self
6935    }
6936    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6937    /// while executing the actual API request.
6938    ///
6939    /// ````text
6940    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6941    /// ````
6942    ///
6943    /// Sets the *delegate* property to the given value.
6944    pub fn delegate(
6945        mut self,
6946        new_value: &'a mut dyn common::Delegate,
6947    ) -> ProjectLocationStudyTrialCheckEarlyStoppingStateCall<'a, C> {
6948        self._delegate = Some(new_value);
6949        self
6950    }
6951
6952    /// Set any additional parameter of the query string used in the request.
6953    /// It should be used to set parameters which are not yet available through their own
6954    /// setters.
6955    ///
6956    /// Please note that this method must not be used to set any of the known parameters
6957    /// which have their own setter method. If done anyway, the request will fail.
6958    ///
6959    /// # Additional Parameters
6960    ///
6961    /// * *$.xgafv* (query-string) - V1 error format.
6962    /// * *access_token* (query-string) - OAuth access token.
6963    /// * *alt* (query-string) - Data format for response.
6964    /// * *callback* (query-string) - JSONP
6965    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6966    /// * *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.
6967    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6968    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6969    /// * *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.
6970    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6971    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6972    pub fn param<T>(
6973        mut self,
6974        name: T,
6975        value: T,
6976    ) -> ProjectLocationStudyTrialCheckEarlyStoppingStateCall<'a, C>
6977    where
6978        T: AsRef<str>,
6979    {
6980        self._additional_params
6981            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6982        self
6983    }
6984
6985    /// Identifies the authorization scope for the method you are building.
6986    ///
6987    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6988    /// [`Scope::CloudPlatform`].
6989    ///
6990    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6991    /// tokens for more than one scope.
6992    ///
6993    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6994    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6995    /// sufficient, a read-write scope will do as well.
6996    pub fn add_scope<St>(
6997        mut self,
6998        scope: St,
6999    ) -> ProjectLocationStudyTrialCheckEarlyStoppingStateCall<'a, C>
7000    where
7001        St: AsRef<str>,
7002    {
7003        self._scopes.insert(String::from(scope.as_ref()));
7004        self
7005    }
7006    /// Identifies the authorization scope(s) for the method you are building.
7007    ///
7008    /// See [`Self::add_scope()`] for details.
7009    pub fn add_scopes<I, St>(
7010        mut self,
7011        scopes: I,
7012    ) -> ProjectLocationStudyTrialCheckEarlyStoppingStateCall<'a, C>
7013    where
7014        I: IntoIterator<Item = St>,
7015        St: AsRef<str>,
7016    {
7017        self._scopes
7018            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7019        self
7020    }
7021
7022    /// Removes all scopes, and no default scope will be used either.
7023    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7024    /// for details).
7025    pub fn clear_scopes(mut self) -> ProjectLocationStudyTrialCheckEarlyStoppingStateCall<'a, C> {
7026        self._scopes.clear();
7027        self
7028    }
7029}
7030
7031/// Marks a trial as complete.
7032///
7033/// A builder for the *locations.studies.trials.complete* method supported by a *project* resource.
7034/// It is not used directly, but through a [`ProjectMethods`] instance.
7035///
7036/// # Example
7037///
7038/// Instantiate a resource method builder
7039///
7040/// ```test_harness,no_run
7041/// # extern crate hyper;
7042/// # extern crate hyper_rustls;
7043/// # extern crate google_ml1 as ml1;
7044/// use ml1::api::GoogleCloudMlV1__CompleteTrialRequest;
7045/// # async fn dox() {
7046/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7047///
7048/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7049/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7050/// #     .with_native_roots()
7051/// #     .unwrap()
7052/// #     .https_only()
7053/// #     .enable_http2()
7054/// #     .build();
7055///
7056/// # let executor = hyper_util::rt::TokioExecutor::new();
7057/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7058/// #     secret,
7059/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7060/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7061/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7062/// #     ),
7063/// # ).build().await.unwrap();
7064///
7065/// # let client = hyper_util::client::legacy::Client::builder(
7066/// #     hyper_util::rt::TokioExecutor::new()
7067/// # )
7068/// # .build(
7069/// #     hyper_rustls::HttpsConnectorBuilder::new()
7070/// #         .with_native_roots()
7071/// #         .unwrap()
7072/// #         .https_or_http()
7073/// #         .enable_http2()
7074/// #         .build()
7075/// # );
7076/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
7077/// // As the method needs a request, you would usually fill it with the desired information
7078/// // into the respective structure. Some of the parts shown here might not be applicable !
7079/// // Values shown here are possibly random and not representative !
7080/// let mut req = GoogleCloudMlV1__CompleteTrialRequest::default();
7081///
7082/// // You can configure optional parameters by calling the respective setters at will, and
7083/// // execute the final call using `doit()`.
7084/// // Values shown here are possibly random and not representative !
7085/// let result = hub.projects().locations_studies_trials_complete(req, "name")
7086///              .doit().await;
7087/// # }
7088/// ```
7089pub struct ProjectLocationStudyTrialCompleteCall<'a, C>
7090where
7091    C: 'a,
7092{
7093    hub: &'a CloudMachineLearningEngine<C>,
7094    _request: GoogleCloudMlV1__CompleteTrialRequest,
7095    _name: String,
7096    _delegate: Option<&'a mut dyn common::Delegate>,
7097    _additional_params: HashMap<String, String>,
7098    _scopes: BTreeSet<String>,
7099}
7100
7101impl<'a, C> common::CallBuilder for ProjectLocationStudyTrialCompleteCall<'a, C> {}
7102
7103impl<'a, C> ProjectLocationStudyTrialCompleteCall<'a, C>
7104where
7105    C: common::Connector,
7106{
7107    /// Perform the operation you have build so far.
7108    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleCloudMlV1__Trial)> {
7109        use std::borrow::Cow;
7110        use std::io::{Read, Seek};
7111
7112        use common::{url::Params, ToParts};
7113        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7114
7115        let mut dd = common::DefaultDelegate;
7116        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7117        dlg.begin(common::MethodInfo {
7118            id: "ml.projects.locations.studies.trials.complete",
7119            http_method: hyper::Method::POST,
7120        });
7121
7122        for &field in ["alt", "name"].iter() {
7123            if self._additional_params.contains_key(field) {
7124                dlg.finished(false);
7125                return Err(common::Error::FieldClash(field));
7126            }
7127        }
7128
7129        let mut params = Params::with_capacity(4 + self._additional_params.len());
7130        params.push("name", self._name);
7131
7132        params.extend(self._additional_params.iter());
7133
7134        params.push("alt", "json");
7135        let mut url = self.hub._base_url.clone() + "v1/{+name}:complete";
7136        if self._scopes.is_empty() {
7137            self._scopes
7138                .insert(Scope::CloudPlatform.as_ref().to_string());
7139        }
7140
7141        #[allow(clippy::single_element_loop)]
7142        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7143            url = params.uri_replacement(url, param_name, find_this, true);
7144        }
7145        {
7146            let to_remove = ["name"];
7147            params.remove_params(&to_remove);
7148        }
7149
7150        let url = params.parse_with_url(&url);
7151
7152        let mut json_mime_type = mime::APPLICATION_JSON;
7153        let mut request_value_reader = {
7154            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7155            common::remove_json_null_values(&mut value);
7156            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7157            serde_json::to_writer(&mut dst, &value).unwrap();
7158            dst
7159        };
7160        let request_size = request_value_reader
7161            .seek(std::io::SeekFrom::End(0))
7162            .unwrap();
7163        request_value_reader
7164            .seek(std::io::SeekFrom::Start(0))
7165            .unwrap();
7166
7167        loop {
7168            let token = match self
7169                .hub
7170                .auth
7171                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7172                .await
7173            {
7174                Ok(token) => token,
7175                Err(e) => match dlg.token(e) {
7176                    Ok(token) => token,
7177                    Err(e) => {
7178                        dlg.finished(false);
7179                        return Err(common::Error::MissingToken(e));
7180                    }
7181                },
7182            };
7183            request_value_reader
7184                .seek(std::io::SeekFrom::Start(0))
7185                .unwrap();
7186            let mut req_result = {
7187                let client = &self.hub.client;
7188                dlg.pre_request();
7189                let mut req_builder = hyper::Request::builder()
7190                    .method(hyper::Method::POST)
7191                    .uri(url.as_str())
7192                    .header(USER_AGENT, self.hub._user_agent.clone());
7193
7194                if let Some(token) = token.as_ref() {
7195                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7196                }
7197
7198                let request = req_builder
7199                    .header(CONTENT_TYPE, json_mime_type.to_string())
7200                    .header(CONTENT_LENGTH, request_size as u64)
7201                    .body(common::to_body(
7202                        request_value_reader.get_ref().clone().into(),
7203                    ));
7204
7205                client.request(request.unwrap()).await
7206            };
7207
7208            match req_result {
7209                Err(err) => {
7210                    if let common::Retry::After(d) = dlg.http_error(&err) {
7211                        sleep(d).await;
7212                        continue;
7213                    }
7214                    dlg.finished(false);
7215                    return Err(common::Error::HttpError(err));
7216                }
7217                Ok(res) => {
7218                    let (mut parts, body) = res.into_parts();
7219                    let mut body = common::Body::new(body);
7220                    if !parts.status.is_success() {
7221                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7222                        let error = serde_json::from_str(&common::to_string(&bytes));
7223                        let response = common::to_response(parts, bytes.into());
7224
7225                        if let common::Retry::After(d) =
7226                            dlg.http_failure(&response, error.as_ref().ok())
7227                        {
7228                            sleep(d).await;
7229                            continue;
7230                        }
7231
7232                        dlg.finished(false);
7233
7234                        return Err(match error {
7235                            Ok(value) => common::Error::BadRequest(value),
7236                            _ => common::Error::Failure(response),
7237                        });
7238                    }
7239                    let response = {
7240                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7241                        let encoded = common::to_string(&bytes);
7242                        match serde_json::from_str(&encoded) {
7243                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7244                            Err(error) => {
7245                                dlg.response_json_decode_error(&encoded, &error);
7246                                return Err(common::Error::JsonDecodeError(
7247                                    encoded.to_string(),
7248                                    error,
7249                                ));
7250                            }
7251                        }
7252                    };
7253
7254                    dlg.finished(true);
7255                    return Ok(response);
7256                }
7257            }
7258        }
7259    }
7260
7261    ///
7262    /// Sets the *request* property to the given value.
7263    ///
7264    /// Even though the property as already been set when instantiating this call,
7265    /// we provide this method for API completeness.
7266    pub fn request(
7267        mut self,
7268        new_value: GoogleCloudMlV1__CompleteTrialRequest,
7269    ) -> ProjectLocationStudyTrialCompleteCall<'a, C> {
7270        self._request = new_value;
7271        self
7272    }
7273    /// Required. The trial name.metat
7274    ///
7275    /// Sets the *name* path property to the given value.
7276    ///
7277    /// Even though the property as already been set when instantiating this call,
7278    /// we provide this method for API completeness.
7279    pub fn name(mut self, new_value: &str) -> ProjectLocationStudyTrialCompleteCall<'a, C> {
7280        self._name = new_value.to_string();
7281        self
7282    }
7283    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7284    /// while executing the actual API request.
7285    ///
7286    /// ````text
7287    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7288    /// ````
7289    ///
7290    /// Sets the *delegate* property to the given value.
7291    pub fn delegate(
7292        mut self,
7293        new_value: &'a mut dyn common::Delegate,
7294    ) -> ProjectLocationStudyTrialCompleteCall<'a, C> {
7295        self._delegate = Some(new_value);
7296        self
7297    }
7298
7299    /// Set any additional parameter of the query string used in the request.
7300    /// It should be used to set parameters which are not yet available through their own
7301    /// setters.
7302    ///
7303    /// Please note that this method must not be used to set any of the known parameters
7304    /// which have their own setter method. If done anyway, the request will fail.
7305    ///
7306    /// # Additional Parameters
7307    ///
7308    /// * *$.xgafv* (query-string) - V1 error format.
7309    /// * *access_token* (query-string) - OAuth access token.
7310    /// * *alt* (query-string) - Data format for response.
7311    /// * *callback* (query-string) - JSONP
7312    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7313    /// * *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.
7314    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7315    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7316    /// * *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.
7317    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7318    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7319    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationStudyTrialCompleteCall<'a, C>
7320    where
7321        T: AsRef<str>,
7322    {
7323        self._additional_params
7324            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7325        self
7326    }
7327
7328    /// Identifies the authorization scope for the method you are building.
7329    ///
7330    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7331    /// [`Scope::CloudPlatform`].
7332    ///
7333    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7334    /// tokens for more than one scope.
7335    ///
7336    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7337    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7338    /// sufficient, a read-write scope will do as well.
7339    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationStudyTrialCompleteCall<'a, C>
7340    where
7341        St: AsRef<str>,
7342    {
7343        self._scopes.insert(String::from(scope.as_ref()));
7344        self
7345    }
7346    /// Identifies the authorization scope(s) for the method you are building.
7347    ///
7348    /// See [`Self::add_scope()`] for details.
7349    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationStudyTrialCompleteCall<'a, C>
7350    where
7351        I: IntoIterator<Item = St>,
7352        St: AsRef<str>,
7353    {
7354        self._scopes
7355            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7356        self
7357    }
7358
7359    /// Removes all scopes, and no default scope will be used either.
7360    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7361    /// for details).
7362    pub fn clear_scopes(mut self) -> ProjectLocationStudyTrialCompleteCall<'a, C> {
7363        self._scopes.clear();
7364        self
7365    }
7366}
7367
7368/// Adds a user provided trial to a study.
7369///
7370/// A builder for the *locations.studies.trials.create* method supported by a *project* resource.
7371/// It is not used directly, but through a [`ProjectMethods`] instance.
7372///
7373/// # Example
7374///
7375/// Instantiate a resource method builder
7376///
7377/// ```test_harness,no_run
7378/// # extern crate hyper;
7379/// # extern crate hyper_rustls;
7380/// # extern crate google_ml1 as ml1;
7381/// use ml1::api::GoogleCloudMlV1__Trial;
7382/// # async fn dox() {
7383/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7384///
7385/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7386/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7387/// #     .with_native_roots()
7388/// #     .unwrap()
7389/// #     .https_only()
7390/// #     .enable_http2()
7391/// #     .build();
7392///
7393/// # let executor = hyper_util::rt::TokioExecutor::new();
7394/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7395/// #     secret,
7396/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7397/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7398/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7399/// #     ),
7400/// # ).build().await.unwrap();
7401///
7402/// # let client = hyper_util::client::legacy::Client::builder(
7403/// #     hyper_util::rt::TokioExecutor::new()
7404/// # )
7405/// # .build(
7406/// #     hyper_rustls::HttpsConnectorBuilder::new()
7407/// #         .with_native_roots()
7408/// #         .unwrap()
7409/// #         .https_or_http()
7410/// #         .enable_http2()
7411/// #         .build()
7412/// # );
7413/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
7414/// // As the method needs a request, you would usually fill it with the desired information
7415/// // into the respective structure. Some of the parts shown here might not be applicable !
7416/// // Values shown here are possibly random and not representative !
7417/// let mut req = GoogleCloudMlV1__Trial::default();
7418///
7419/// // You can configure optional parameters by calling the respective setters at will, and
7420/// // execute the final call using `doit()`.
7421/// // Values shown here are possibly random and not representative !
7422/// let result = hub.projects().locations_studies_trials_create(req, "parent")
7423///              .doit().await;
7424/// # }
7425/// ```
7426pub struct ProjectLocationStudyTrialCreateCall<'a, C>
7427where
7428    C: 'a,
7429{
7430    hub: &'a CloudMachineLearningEngine<C>,
7431    _request: GoogleCloudMlV1__Trial,
7432    _parent: String,
7433    _delegate: Option<&'a mut dyn common::Delegate>,
7434    _additional_params: HashMap<String, String>,
7435    _scopes: BTreeSet<String>,
7436}
7437
7438impl<'a, C> common::CallBuilder for ProjectLocationStudyTrialCreateCall<'a, C> {}
7439
7440impl<'a, C> ProjectLocationStudyTrialCreateCall<'a, C>
7441where
7442    C: common::Connector,
7443{
7444    /// Perform the operation you have build so far.
7445    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleCloudMlV1__Trial)> {
7446        use std::borrow::Cow;
7447        use std::io::{Read, Seek};
7448
7449        use common::{url::Params, ToParts};
7450        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7451
7452        let mut dd = common::DefaultDelegate;
7453        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7454        dlg.begin(common::MethodInfo {
7455            id: "ml.projects.locations.studies.trials.create",
7456            http_method: hyper::Method::POST,
7457        });
7458
7459        for &field in ["alt", "parent"].iter() {
7460            if self._additional_params.contains_key(field) {
7461                dlg.finished(false);
7462                return Err(common::Error::FieldClash(field));
7463            }
7464        }
7465
7466        let mut params = Params::with_capacity(4 + self._additional_params.len());
7467        params.push("parent", self._parent);
7468
7469        params.extend(self._additional_params.iter());
7470
7471        params.push("alt", "json");
7472        let mut url = self.hub._base_url.clone() + "v1/{+parent}/trials";
7473        if self._scopes.is_empty() {
7474            self._scopes
7475                .insert(Scope::CloudPlatform.as_ref().to_string());
7476        }
7477
7478        #[allow(clippy::single_element_loop)]
7479        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7480            url = params.uri_replacement(url, param_name, find_this, true);
7481        }
7482        {
7483            let to_remove = ["parent"];
7484            params.remove_params(&to_remove);
7485        }
7486
7487        let url = params.parse_with_url(&url);
7488
7489        let mut json_mime_type = mime::APPLICATION_JSON;
7490        let mut request_value_reader = {
7491            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7492            common::remove_json_null_values(&mut value);
7493            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7494            serde_json::to_writer(&mut dst, &value).unwrap();
7495            dst
7496        };
7497        let request_size = request_value_reader
7498            .seek(std::io::SeekFrom::End(0))
7499            .unwrap();
7500        request_value_reader
7501            .seek(std::io::SeekFrom::Start(0))
7502            .unwrap();
7503
7504        loop {
7505            let token = match self
7506                .hub
7507                .auth
7508                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7509                .await
7510            {
7511                Ok(token) => token,
7512                Err(e) => match dlg.token(e) {
7513                    Ok(token) => token,
7514                    Err(e) => {
7515                        dlg.finished(false);
7516                        return Err(common::Error::MissingToken(e));
7517                    }
7518                },
7519            };
7520            request_value_reader
7521                .seek(std::io::SeekFrom::Start(0))
7522                .unwrap();
7523            let mut req_result = {
7524                let client = &self.hub.client;
7525                dlg.pre_request();
7526                let mut req_builder = hyper::Request::builder()
7527                    .method(hyper::Method::POST)
7528                    .uri(url.as_str())
7529                    .header(USER_AGENT, self.hub._user_agent.clone());
7530
7531                if let Some(token) = token.as_ref() {
7532                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7533                }
7534
7535                let request = req_builder
7536                    .header(CONTENT_TYPE, json_mime_type.to_string())
7537                    .header(CONTENT_LENGTH, request_size as u64)
7538                    .body(common::to_body(
7539                        request_value_reader.get_ref().clone().into(),
7540                    ));
7541
7542                client.request(request.unwrap()).await
7543            };
7544
7545            match req_result {
7546                Err(err) => {
7547                    if let common::Retry::After(d) = dlg.http_error(&err) {
7548                        sleep(d).await;
7549                        continue;
7550                    }
7551                    dlg.finished(false);
7552                    return Err(common::Error::HttpError(err));
7553                }
7554                Ok(res) => {
7555                    let (mut parts, body) = res.into_parts();
7556                    let mut body = common::Body::new(body);
7557                    if !parts.status.is_success() {
7558                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7559                        let error = serde_json::from_str(&common::to_string(&bytes));
7560                        let response = common::to_response(parts, bytes.into());
7561
7562                        if let common::Retry::After(d) =
7563                            dlg.http_failure(&response, error.as_ref().ok())
7564                        {
7565                            sleep(d).await;
7566                            continue;
7567                        }
7568
7569                        dlg.finished(false);
7570
7571                        return Err(match error {
7572                            Ok(value) => common::Error::BadRequest(value),
7573                            _ => common::Error::Failure(response),
7574                        });
7575                    }
7576                    let response = {
7577                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7578                        let encoded = common::to_string(&bytes);
7579                        match serde_json::from_str(&encoded) {
7580                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7581                            Err(error) => {
7582                                dlg.response_json_decode_error(&encoded, &error);
7583                                return Err(common::Error::JsonDecodeError(
7584                                    encoded.to_string(),
7585                                    error,
7586                                ));
7587                            }
7588                        }
7589                    };
7590
7591                    dlg.finished(true);
7592                    return Ok(response);
7593                }
7594            }
7595        }
7596    }
7597
7598    ///
7599    /// Sets the *request* property to the given value.
7600    ///
7601    /// Even though the property as already been set when instantiating this call,
7602    /// we provide this method for API completeness.
7603    pub fn request(
7604        mut self,
7605        new_value: GoogleCloudMlV1__Trial,
7606    ) -> ProjectLocationStudyTrialCreateCall<'a, C> {
7607        self._request = new_value;
7608        self
7609    }
7610    /// Required. The name of the study that the trial belongs to.
7611    ///
7612    /// Sets the *parent* path property to the given value.
7613    ///
7614    /// Even though the property as already been set when instantiating this call,
7615    /// we provide this method for API completeness.
7616    pub fn parent(mut self, new_value: &str) -> ProjectLocationStudyTrialCreateCall<'a, C> {
7617        self._parent = new_value.to_string();
7618        self
7619    }
7620    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7621    /// while executing the actual API request.
7622    ///
7623    /// ````text
7624    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7625    /// ````
7626    ///
7627    /// Sets the *delegate* property to the given value.
7628    pub fn delegate(
7629        mut self,
7630        new_value: &'a mut dyn common::Delegate,
7631    ) -> ProjectLocationStudyTrialCreateCall<'a, C> {
7632        self._delegate = Some(new_value);
7633        self
7634    }
7635
7636    /// Set any additional parameter of the query string used in the request.
7637    /// It should be used to set parameters which are not yet available through their own
7638    /// setters.
7639    ///
7640    /// Please note that this method must not be used to set any of the known parameters
7641    /// which have their own setter method. If done anyway, the request will fail.
7642    ///
7643    /// # Additional Parameters
7644    ///
7645    /// * *$.xgafv* (query-string) - V1 error format.
7646    /// * *access_token* (query-string) - OAuth access token.
7647    /// * *alt* (query-string) - Data format for response.
7648    /// * *callback* (query-string) - JSONP
7649    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7650    /// * *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.
7651    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7652    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7653    /// * *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.
7654    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7655    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7656    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationStudyTrialCreateCall<'a, C>
7657    where
7658        T: AsRef<str>,
7659    {
7660        self._additional_params
7661            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7662        self
7663    }
7664
7665    /// Identifies the authorization scope for the method you are building.
7666    ///
7667    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7668    /// [`Scope::CloudPlatform`].
7669    ///
7670    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7671    /// tokens for more than one scope.
7672    ///
7673    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7674    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7675    /// sufficient, a read-write scope will do as well.
7676    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationStudyTrialCreateCall<'a, C>
7677    where
7678        St: AsRef<str>,
7679    {
7680        self._scopes.insert(String::from(scope.as_ref()));
7681        self
7682    }
7683    /// Identifies the authorization scope(s) for the method you are building.
7684    ///
7685    /// See [`Self::add_scope()`] for details.
7686    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationStudyTrialCreateCall<'a, C>
7687    where
7688        I: IntoIterator<Item = St>,
7689        St: AsRef<str>,
7690    {
7691        self._scopes
7692            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7693        self
7694    }
7695
7696    /// Removes all scopes, and no default scope will be used either.
7697    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7698    /// for details).
7699    pub fn clear_scopes(mut self) -> ProjectLocationStudyTrialCreateCall<'a, C> {
7700        self._scopes.clear();
7701        self
7702    }
7703}
7704
7705/// Deletes a trial.
7706///
7707/// A builder for the *locations.studies.trials.delete* method supported by a *project* resource.
7708/// It is not used directly, but through a [`ProjectMethods`] instance.
7709///
7710/// # Example
7711///
7712/// Instantiate a resource method builder
7713///
7714/// ```test_harness,no_run
7715/// # extern crate hyper;
7716/// # extern crate hyper_rustls;
7717/// # extern crate google_ml1 as ml1;
7718/// # async fn dox() {
7719/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7720///
7721/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7722/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7723/// #     .with_native_roots()
7724/// #     .unwrap()
7725/// #     .https_only()
7726/// #     .enable_http2()
7727/// #     .build();
7728///
7729/// # let executor = hyper_util::rt::TokioExecutor::new();
7730/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7731/// #     secret,
7732/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7733/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7734/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7735/// #     ),
7736/// # ).build().await.unwrap();
7737///
7738/// # let client = hyper_util::client::legacy::Client::builder(
7739/// #     hyper_util::rt::TokioExecutor::new()
7740/// # )
7741/// # .build(
7742/// #     hyper_rustls::HttpsConnectorBuilder::new()
7743/// #         .with_native_roots()
7744/// #         .unwrap()
7745/// #         .https_or_http()
7746/// #         .enable_http2()
7747/// #         .build()
7748/// # );
7749/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
7750/// // You can configure optional parameters by calling the respective setters at will, and
7751/// // execute the final call using `doit()`.
7752/// // Values shown here are possibly random and not representative !
7753/// let result = hub.projects().locations_studies_trials_delete("name")
7754///              .doit().await;
7755/// # }
7756/// ```
7757pub struct ProjectLocationStudyTrialDeleteCall<'a, C>
7758where
7759    C: 'a,
7760{
7761    hub: &'a CloudMachineLearningEngine<C>,
7762    _name: String,
7763    _delegate: Option<&'a mut dyn common::Delegate>,
7764    _additional_params: HashMap<String, String>,
7765    _scopes: BTreeSet<String>,
7766}
7767
7768impl<'a, C> common::CallBuilder for ProjectLocationStudyTrialDeleteCall<'a, C> {}
7769
7770impl<'a, C> ProjectLocationStudyTrialDeleteCall<'a, C>
7771where
7772    C: common::Connector,
7773{
7774    /// Perform the operation you have build so far.
7775    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleProtobuf__Empty)> {
7776        use std::borrow::Cow;
7777        use std::io::{Read, Seek};
7778
7779        use common::{url::Params, ToParts};
7780        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7781
7782        let mut dd = common::DefaultDelegate;
7783        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7784        dlg.begin(common::MethodInfo {
7785            id: "ml.projects.locations.studies.trials.delete",
7786            http_method: hyper::Method::DELETE,
7787        });
7788
7789        for &field in ["alt", "name"].iter() {
7790            if self._additional_params.contains_key(field) {
7791                dlg.finished(false);
7792                return Err(common::Error::FieldClash(field));
7793            }
7794        }
7795
7796        let mut params = Params::with_capacity(3 + self._additional_params.len());
7797        params.push("name", self._name);
7798
7799        params.extend(self._additional_params.iter());
7800
7801        params.push("alt", "json");
7802        let mut url = self.hub._base_url.clone() + "v1/{+name}";
7803        if self._scopes.is_empty() {
7804            self._scopes
7805                .insert(Scope::CloudPlatform.as_ref().to_string());
7806        }
7807
7808        #[allow(clippy::single_element_loop)]
7809        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7810            url = params.uri_replacement(url, param_name, find_this, true);
7811        }
7812        {
7813            let to_remove = ["name"];
7814            params.remove_params(&to_remove);
7815        }
7816
7817        let url = params.parse_with_url(&url);
7818
7819        loop {
7820            let token = match self
7821                .hub
7822                .auth
7823                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7824                .await
7825            {
7826                Ok(token) => token,
7827                Err(e) => match dlg.token(e) {
7828                    Ok(token) => token,
7829                    Err(e) => {
7830                        dlg.finished(false);
7831                        return Err(common::Error::MissingToken(e));
7832                    }
7833                },
7834            };
7835            let mut req_result = {
7836                let client = &self.hub.client;
7837                dlg.pre_request();
7838                let mut req_builder = hyper::Request::builder()
7839                    .method(hyper::Method::DELETE)
7840                    .uri(url.as_str())
7841                    .header(USER_AGENT, self.hub._user_agent.clone());
7842
7843                if let Some(token) = token.as_ref() {
7844                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7845                }
7846
7847                let request = req_builder
7848                    .header(CONTENT_LENGTH, 0_u64)
7849                    .body(common::to_body::<String>(None));
7850
7851                client.request(request.unwrap()).await
7852            };
7853
7854            match req_result {
7855                Err(err) => {
7856                    if let common::Retry::After(d) = dlg.http_error(&err) {
7857                        sleep(d).await;
7858                        continue;
7859                    }
7860                    dlg.finished(false);
7861                    return Err(common::Error::HttpError(err));
7862                }
7863                Ok(res) => {
7864                    let (mut parts, body) = res.into_parts();
7865                    let mut body = common::Body::new(body);
7866                    if !parts.status.is_success() {
7867                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7868                        let error = serde_json::from_str(&common::to_string(&bytes));
7869                        let response = common::to_response(parts, bytes.into());
7870
7871                        if let common::Retry::After(d) =
7872                            dlg.http_failure(&response, error.as_ref().ok())
7873                        {
7874                            sleep(d).await;
7875                            continue;
7876                        }
7877
7878                        dlg.finished(false);
7879
7880                        return Err(match error {
7881                            Ok(value) => common::Error::BadRequest(value),
7882                            _ => common::Error::Failure(response),
7883                        });
7884                    }
7885                    let response = {
7886                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7887                        let encoded = common::to_string(&bytes);
7888                        match serde_json::from_str(&encoded) {
7889                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7890                            Err(error) => {
7891                                dlg.response_json_decode_error(&encoded, &error);
7892                                return Err(common::Error::JsonDecodeError(
7893                                    encoded.to_string(),
7894                                    error,
7895                                ));
7896                            }
7897                        }
7898                    };
7899
7900                    dlg.finished(true);
7901                    return Ok(response);
7902                }
7903            }
7904        }
7905    }
7906
7907    /// Required. The trial name.
7908    ///
7909    /// Sets the *name* path property to the given value.
7910    ///
7911    /// Even though the property as already been set when instantiating this call,
7912    /// we provide this method for API completeness.
7913    pub fn name(mut self, new_value: &str) -> ProjectLocationStudyTrialDeleteCall<'a, C> {
7914        self._name = new_value.to_string();
7915        self
7916    }
7917    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7918    /// while executing the actual API request.
7919    ///
7920    /// ````text
7921    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7922    /// ````
7923    ///
7924    /// Sets the *delegate* property to the given value.
7925    pub fn delegate(
7926        mut self,
7927        new_value: &'a mut dyn common::Delegate,
7928    ) -> ProjectLocationStudyTrialDeleteCall<'a, C> {
7929        self._delegate = Some(new_value);
7930        self
7931    }
7932
7933    /// Set any additional parameter of the query string used in the request.
7934    /// It should be used to set parameters which are not yet available through their own
7935    /// setters.
7936    ///
7937    /// Please note that this method must not be used to set any of the known parameters
7938    /// which have their own setter method. If done anyway, the request will fail.
7939    ///
7940    /// # Additional Parameters
7941    ///
7942    /// * *$.xgafv* (query-string) - V1 error format.
7943    /// * *access_token* (query-string) - OAuth access token.
7944    /// * *alt* (query-string) - Data format for response.
7945    /// * *callback* (query-string) - JSONP
7946    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7947    /// * *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.
7948    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7949    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7950    /// * *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.
7951    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7952    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7953    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationStudyTrialDeleteCall<'a, C>
7954    where
7955        T: AsRef<str>,
7956    {
7957        self._additional_params
7958            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7959        self
7960    }
7961
7962    /// Identifies the authorization scope for the method you are building.
7963    ///
7964    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7965    /// [`Scope::CloudPlatform`].
7966    ///
7967    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7968    /// tokens for more than one scope.
7969    ///
7970    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7971    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7972    /// sufficient, a read-write scope will do as well.
7973    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationStudyTrialDeleteCall<'a, C>
7974    where
7975        St: AsRef<str>,
7976    {
7977        self._scopes.insert(String::from(scope.as_ref()));
7978        self
7979    }
7980    /// Identifies the authorization scope(s) for the method you are building.
7981    ///
7982    /// See [`Self::add_scope()`] for details.
7983    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationStudyTrialDeleteCall<'a, C>
7984    where
7985        I: IntoIterator<Item = St>,
7986        St: AsRef<str>,
7987    {
7988        self._scopes
7989            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7990        self
7991    }
7992
7993    /// Removes all scopes, and no default scope will be used either.
7994    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7995    /// for details).
7996    pub fn clear_scopes(mut self) -> ProjectLocationStudyTrialDeleteCall<'a, C> {
7997        self._scopes.clear();
7998        self
7999    }
8000}
8001
8002/// Gets a trial.
8003///
8004/// A builder for the *locations.studies.trials.get* method supported by a *project* resource.
8005/// It is not used directly, but through a [`ProjectMethods`] instance.
8006///
8007/// # Example
8008///
8009/// Instantiate a resource method builder
8010///
8011/// ```test_harness,no_run
8012/// # extern crate hyper;
8013/// # extern crate hyper_rustls;
8014/// # extern crate google_ml1 as ml1;
8015/// # async fn dox() {
8016/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8017///
8018/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8019/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8020/// #     .with_native_roots()
8021/// #     .unwrap()
8022/// #     .https_only()
8023/// #     .enable_http2()
8024/// #     .build();
8025///
8026/// # let executor = hyper_util::rt::TokioExecutor::new();
8027/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8028/// #     secret,
8029/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8030/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8031/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8032/// #     ),
8033/// # ).build().await.unwrap();
8034///
8035/// # let client = hyper_util::client::legacy::Client::builder(
8036/// #     hyper_util::rt::TokioExecutor::new()
8037/// # )
8038/// # .build(
8039/// #     hyper_rustls::HttpsConnectorBuilder::new()
8040/// #         .with_native_roots()
8041/// #         .unwrap()
8042/// #         .https_or_http()
8043/// #         .enable_http2()
8044/// #         .build()
8045/// # );
8046/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
8047/// // You can configure optional parameters by calling the respective setters at will, and
8048/// // execute the final call using `doit()`.
8049/// // Values shown here are possibly random and not representative !
8050/// let result = hub.projects().locations_studies_trials_get("name")
8051///              .doit().await;
8052/// # }
8053/// ```
8054pub struct ProjectLocationStudyTrialGetCall<'a, C>
8055where
8056    C: 'a,
8057{
8058    hub: &'a CloudMachineLearningEngine<C>,
8059    _name: String,
8060    _delegate: Option<&'a mut dyn common::Delegate>,
8061    _additional_params: HashMap<String, String>,
8062    _scopes: BTreeSet<String>,
8063}
8064
8065impl<'a, C> common::CallBuilder for ProjectLocationStudyTrialGetCall<'a, C> {}
8066
8067impl<'a, C> ProjectLocationStudyTrialGetCall<'a, C>
8068where
8069    C: common::Connector,
8070{
8071    /// Perform the operation you have build so far.
8072    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleCloudMlV1__Trial)> {
8073        use std::borrow::Cow;
8074        use std::io::{Read, Seek};
8075
8076        use common::{url::Params, ToParts};
8077        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8078
8079        let mut dd = common::DefaultDelegate;
8080        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8081        dlg.begin(common::MethodInfo {
8082            id: "ml.projects.locations.studies.trials.get",
8083            http_method: hyper::Method::GET,
8084        });
8085
8086        for &field in ["alt", "name"].iter() {
8087            if self._additional_params.contains_key(field) {
8088                dlg.finished(false);
8089                return Err(common::Error::FieldClash(field));
8090            }
8091        }
8092
8093        let mut params = Params::with_capacity(3 + self._additional_params.len());
8094        params.push("name", self._name);
8095
8096        params.extend(self._additional_params.iter());
8097
8098        params.push("alt", "json");
8099        let mut url = self.hub._base_url.clone() + "v1/{+name}";
8100        if self._scopes.is_empty() {
8101            self._scopes
8102                .insert(Scope::CloudPlatform.as_ref().to_string());
8103        }
8104
8105        #[allow(clippy::single_element_loop)]
8106        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8107            url = params.uri_replacement(url, param_name, find_this, true);
8108        }
8109        {
8110            let to_remove = ["name"];
8111            params.remove_params(&to_remove);
8112        }
8113
8114        let url = params.parse_with_url(&url);
8115
8116        loop {
8117            let token = match self
8118                .hub
8119                .auth
8120                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8121                .await
8122            {
8123                Ok(token) => token,
8124                Err(e) => match dlg.token(e) {
8125                    Ok(token) => token,
8126                    Err(e) => {
8127                        dlg.finished(false);
8128                        return Err(common::Error::MissingToken(e));
8129                    }
8130                },
8131            };
8132            let mut req_result = {
8133                let client = &self.hub.client;
8134                dlg.pre_request();
8135                let mut req_builder = hyper::Request::builder()
8136                    .method(hyper::Method::GET)
8137                    .uri(url.as_str())
8138                    .header(USER_AGENT, self.hub._user_agent.clone());
8139
8140                if let Some(token) = token.as_ref() {
8141                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8142                }
8143
8144                let request = req_builder
8145                    .header(CONTENT_LENGTH, 0_u64)
8146                    .body(common::to_body::<String>(None));
8147
8148                client.request(request.unwrap()).await
8149            };
8150
8151            match req_result {
8152                Err(err) => {
8153                    if let common::Retry::After(d) = dlg.http_error(&err) {
8154                        sleep(d).await;
8155                        continue;
8156                    }
8157                    dlg.finished(false);
8158                    return Err(common::Error::HttpError(err));
8159                }
8160                Ok(res) => {
8161                    let (mut parts, body) = res.into_parts();
8162                    let mut body = common::Body::new(body);
8163                    if !parts.status.is_success() {
8164                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8165                        let error = serde_json::from_str(&common::to_string(&bytes));
8166                        let response = common::to_response(parts, bytes.into());
8167
8168                        if let common::Retry::After(d) =
8169                            dlg.http_failure(&response, error.as_ref().ok())
8170                        {
8171                            sleep(d).await;
8172                            continue;
8173                        }
8174
8175                        dlg.finished(false);
8176
8177                        return Err(match error {
8178                            Ok(value) => common::Error::BadRequest(value),
8179                            _ => common::Error::Failure(response),
8180                        });
8181                    }
8182                    let response = {
8183                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8184                        let encoded = common::to_string(&bytes);
8185                        match serde_json::from_str(&encoded) {
8186                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8187                            Err(error) => {
8188                                dlg.response_json_decode_error(&encoded, &error);
8189                                return Err(common::Error::JsonDecodeError(
8190                                    encoded.to_string(),
8191                                    error,
8192                                ));
8193                            }
8194                        }
8195                    };
8196
8197                    dlg.finished(true);
8198                    return Ok(response);
8199                }
8200            }
8201        }
8202    }
8203
8204    /// Required. The trial name.
8205    ///
8206    /// Sets the *name* path property to the given value.
8207    ///
8208    /// Even though the property as already been set when instantiating this call,
8209    /// we provide this method for API completeness.
8210    pub fn name(mut self, new_value: &str) -> ProjectLocationStudyTrialGetCall<'a, C> {
8211        self._name = new_value.to_string();
8212        self
8213    }
8214    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8215    /// while executing the actual API request.
8216    ///
8217    /// ````text
8218    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8219    /// ````
8220    ///
8221    /// Sets the *delegate* property to the given value.
8222    pub fn delegate(
8223        mut self,
8224        new_value: &'a mut dyn common::Delegate,
8225    ) -> ProjectLocationStudyTrialGetCall<'a, C> {
8226        self._delegate = Some(new_value);
8227        self
8228    }
8229
8230    /// Set any additional parameter of the query string used in the request.
8231    /// It should be used to set parameters which are not yet available through their own
8232    /// setters.
8233    ///
8234    /// Please note that this method must not be used to set any of the known parameters
8235    /// which have their own setter method. If done anyway, the request will fail.
8236    ///
8237    /// # Additional Parameters
8238    ///
8239    /// * *$.xgafv* (query-string) - V1 error format.
8240    /// * *access_token* (query-string) - OAuth access token.
8241    /// * *alt* (query-string) - Data format for response.
8242    /// * *callback* (query-string) - JSONP
8243    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8244    /// * *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.
8245    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8246    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8247    /// * *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.
8248    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8249    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8250    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationStudyTrialGetCall<'a, C>
8251    where
8252        T: AsRef<str>,
8253    {
8254        self._additional_params
8255            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8256        self
8257    }
8258
8259    /// Identifies the authorization scope for the method you are building.
8260    ///
8261    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8262    /// [`Scope::CloudPlatform`].
8263    ///
8264    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8265    /// tokens for more than one scope.
8266    ///
8267    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8268    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8269    /// sufficient, a read-write scope will do as well.
8270    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationStudyTrialGetCall<'a, C>
8271    where
8272        St: AsRef<str>,
8273    {
8274        self._scopes.insert(String::from(scope.as_ref()));
8275        self
8276    }
8277    /// Identifies the authorization scope(s) for the method you are building.
8278    ///
8279    /// See [`Self::add_scope()`] for details.
8280    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationStudyTrialGetCall<'a, C>
8281    where
8282        I: IntoIterator<Item = St>,
8283        St: AsRef<str>,
8284    {
8285        self._scopes
8286            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8287        self
8288    }
8289
8290    /// Removes all scopes, and no default scope will be used either.
8291    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8292    /// for details).
8293    pub fn clear_scopes(mut self) -> ProjectLocationStudyTrialGetCall<'a, C> {
8294        self._scopes.clear();
8295        self
8296    }
8297}
8298
8299/// Lists the trials associated with a study.
8300///
8301/// A builder for the *locations.studies.trials.list* method supported by a *project* resource.
8302/// It is not used directly, but through a [`ProjectMethods`] instance.
8303///
8304/// # Example
8305///
8306/// Instantiate a resource method builder
8307///
8308/// ```test_harness,no_run
8309/// # extern crate hyper;
8310/// # extern crate hyper_rustls;
8311/// # extern crate google_ml1 as ml1;
8312/// # async fn dox() {
8313/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8314///
8315/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8316/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8317/// #     .with_native_roots()
8318/// #     .unwrap()
8319/// #     .https_only()
8320/// #     .enable_http2()
8321/// #     .build();
8322///
8323/// # let executor = hyper_util::rt::TokioExecutor::new();
8324/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8325/// #     secret,
8326/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8327/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8328/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8329/// #     ),
8330/// # ).build().await.unwrap();
8331///
8332/// # let client = hyper_util::client::legacy::Client::builder(
8333/// #     hyper_util::rt::TokioExecutor::new()
8334/// # )
8335/// # .build(
8336/// #     hyper_rustls::HttpsConnectorBuilder::new()
8337/// #         .with_native_roots()
8338/// #         .unwrap()
8339/// #         .https_or_http()
8340/// #         .enable_http2()
8341/// #         .build()
8342/// # );
8343/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
8344/// // You can configure optional parameters by calling the respective setters at will, and
8345/// // execute the final call using `doit()`.
8346/// // Values shown here are possibly random and not representative !
8347/// let result = hub.projects().locations_studies_trials_list("parent")
8348///              .doit().await;
8349/// # }
8350/// ```
8351pub struct ProjectLocationStudyTrialListCall<'a, C>
8352where
8353    C: 'a,
8354{
8355    hub: &'a CloudMachineLearningEngine<C>,
8356    _parent: String,
8357    _delegate: Option<&'a mut dyn common::Delegate>,
8358    _additional_params: HashMap<String, String>,
8359    _scopes: BTreeSet<String>,
8360}
8361
8362impl<'a, C> common::CallBuilder for ProjectLocationStudyTrialListCall<'a, C> {}
8363
8364impl<'a, C> ProjectLocationStudyTrialListCall<'a, C>
8365where
8366    C: common::Connector,
8367{
8368    /// Perform the operation you have build so far.
8369    pub async fn doit(
8370        mut self,
8371    ) -> common::Result<(common::Response, GoogleCloudMlV1__ListTrialsResponse)> {
8372        use std::borrow::Cow;
8373        use std::io::{Read, Seek};
8374
8375        use common::{url::Params, ToParts};
8376        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8377
8378        let mut dd = common::DefaultDelegate;
8379        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8380        dlg.begin(common::MethodInfo {
8381            id: "ml.projects.locations.studies.trials.list",
8382            http_method: hyper::Method::GET,
8383        });
8384
8385        for &field in ["alt", "parent"].iter() {
8386            if self._additional_params.contains_key(field) {
8387                dlg.finished(false);
8388                return Err(common::Error::FieldClash(field));
8389            }
8390        }
8391
8392        let mut params = Params::with_capacity(3 + self._additional_params.len());
8393        params.push("parent", self._parent);
8394
8395        params.extend(self._additional_params.iter());
8396
8397        params.push("alt", "json");
8398        let mut url = self.hub._base_url.clone() + "v1/{+parent}/trials";
8399        if self._scopes.is_empty() {
8400            self._scopes
8401                .insert(Scope::CloudPlatform.as_ref().to_string());
8402        }
8403
8404        #[allow(clippy::single_element_loop)]
8405        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8406            url = params.uri_replacement(url, param_name, find_this, true);
8407        }
8408        {
8409            let to_remove = ["parent"];
8410            params.remove_params(&to_remove);
8411        }
8412
8413        let url = params.parse_with_url(&url);
8414
8415        loop {
8416            let token = match self
8417                .hub
8418                .auth
8419                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8420                .await
8421            {
8422                Ok(token) => token,
8423                Err(e) => match dlg.token(e) {
8424                    Ok(token) => token,
8425                    Err(e) => {
8426                        dlg.finished(false);
8427                        return Err(common::Error::MissingToken(e));
8428                    }
8429                },
8430            };
8431            let mut req_result = {
8432                let client = &self.hub.client;
8433                dlg.pre_request();
8434                let mut req_builder = hyper::Request::builder()
8435                    .method(hyper::Method::GET)
8436                    .uri(url.as_str())
8437                    .header(USER_AGENT, self.hub._user_agent.clone());
8438
8439                if let Some(token) = token.as_ref() {
8440                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8441                }
8442
8443                let request = req_builder
8444                    .header(CONTENT_LENGTH, 0_u64)
8445                    .body(common::to_body::<String>(None));
8446
8447                client.request(request.unwrap()).await
8448            };
8449
8450            match req_result {
8451                Err(err) => {
8452                    if let common::Retry::After(d) = dlg.http_error(&err) {
8453                        sleep(d).await;
8454                        continue;
8455                    }
8456                    dlg.finished(false);
8457                    return Err(common::Error::HttpError(err));
8458                }
8459                Ok(res) => {
8460                    let (mut parts, body) = res.into_parts();
8461                    let mut body = common::Body::new(body);
8462                    if !parts.status.is_success() {
8463                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8464                        let error = serde_json::from_str(&common::to_string(&bytes));
8465                        let response = common::to_response(parts, bytes.into());
8466
8467                        if let common::Retry::After(d) =
8468                            dlg.http_failure(&response, error.as_ref().ok())
8469                        {
8470                            sleep(d).await;
8471                            continue;
8472                        }
8473
8474                        dlg.finished(false);
8475
8476                        return Err(match error {
8477                            Ok(value) => common::Error::BadRequest(value),
8478                            _ => common::Error::Failure(response),
8479                        });
8480                    }
8481                    let response = {
8482                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8483                        let encoded = common::to_string(&bytes);
8484                        match serde_json::from_str(&encoded) {
8485                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8486                            Err(error) => {
8487                                dlg.response_json_decode_error(&encoded, &error);
8488                                return Err(common::Error::JsonDecodeError(
8489                                    encoded.to_string(),
8490                                    error,
8491                                ));
8492                            }
8493                        }
8494                    };
8495
8496                    dlg.finished(true);
8497                    return Ok(response);
8498                }
8499            }
8500        }
8501    }
8502
8503    /// Required. The name of the study that the trial belongs to.
8504    ///
8505    /// Sets the *parent* path property to the given value.
8506    ///
8507    /// Even though the property as already been set when instantiating this call,
8508    /// we provide this method for API completeness.
8509    pub fn parent(mut self, new_value: &str) -> ProjectLocationStudyTrialListCall<'a, C> {
8510        self._parent = new_value.to_string();
8511        self
8512    }
8513    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8514    /// while executing the actual API request.
8515    ///
8516    /// ````text
8517    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8518    /// ````
8519    ///
8520    /// Sets the *delegate* property to the given value.
8521    pub fn delegate(
8522        mut self,
8523        new_value: &'a mut dyn common::Delegate,
8524    ) -> ProjectLocationStudyTrialListCall<'a, C> {
8525        self._delegate = Some(new_value);
8526        self
8527    }
8528
8529    /// Set any additional parameter of the query string used in the request.
8530    /// It should be used to set parameters which are not yet available through their own
8531    /// setters.
8532    ///
8533    /// Please note that this method must not be used to set any of the known parameters
8534    /// which have their own setter method. If done anyway, the request will fail.
8535    ///
8536    /// # Additional Parameters
8537    ///
8538    /// * *$.xgafv* (query-string) - V1 error format.
8539    /// * *access_token* (query-string) - OAuth access token.
8540    /// * *alt* (query-string) - Data format for response.
8541    /// * *callback* (query-string) - JSONP
8542    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8543    /// * *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.
8544    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8545    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8546    /// * *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.
8547    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8548    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8549    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationStudyTrialListCall<'a, C>
8550    where
8551        T: AsRef<str>,
8552    {
8553        self._additional_params
8554            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8555        self
8556    }
8557
8558    /// Identifies the authorization scope for the method you are building.
8559    ///
8560    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8561    /// [`Scope::CloudPlatform`].
8562    ///
8563    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8564    /// tokens for more than one scope.
8565    ///
8566    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8567    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8568    /// sufficient, a read-write scope will do as well.
8569    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationStudyTrialListCall<'a, C>
8570    where
8571        St: AsRef<str>,
8572    {
8573        self._scopes.insert(String::from(scope.as_ref()));
8574        self
8575    }
8576    /// Identifies the authorization scope(s) for the method you are building.
8577    ///
8578    /// See [`Self::add_scope()`] for details.
8579    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationStudyTrialListCall<'a, C>
8580    where
8581        I: IntoIterator<Item = St>,
8582        St: AsRef<str>,
8583    {
8584        self._scopes
8585            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8586        self
8587    }
8588
8589    /// Removes all scopes, and no default scope will be used either.
8590    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8591    /// for details).
8592    pub fn clear_scopes(mut self) -> ProjectLocationStudyTrialListCall<'a, C> {
8593        self._scopes.clear();
8594        self
8595    }
8596}
8597
8598/// Lists the pareto-optimal trials for multi-objective study or the optimal trials for single-objective study. The definition of pareto-optimal can be checked in wiki page. https://en.wikipedia.org/wiki/Pareto_efficiency
8599///
8600/// A builder for the *locations.studies.trials.listOptimalTrials* method supported by a *project* resource.
8601/// It is not used directly, but through a [`ProjectMethods`] instance.
8602///
8603/// # Example
8604///
8605/// Instantiate a resource method builder
8606///
8607/// ```test_harness,no_run
8608/// # extern crate hyper;
8609/// # extern crate hyper_rustls;
8610/// # extern crate google_ml1 as ml1;
8611/// use ml1::api::GoogleCloudMlV1__ListOptimalTrialsRequest;
8612/// # async fn dox() {
8613/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8614///
8615/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8616/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8617/// #     .with_native_roots()
8618/// #     .unwrap()
8619/// #     .https_only()
8620/// #     .enable_http2()
8621/// #     .build();
8622///
8623/// # let executor = hyper_util::rt::TokioExecutor::new();
8624/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8625/// #     secret,
8626/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8627/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8628/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8629/// #     ),
8630/// # ).build().await.unwrap();
8631///
8632/// # let client = hyper_util::client::legacy::Client::builder(
8633/// #     hyper_util::rt::TokioExecutor::new()
8634/// # )
8635/// # .build(
8636/// #     hyper_rustls::HttpsConnectorBuilder::new()
8637/// #         .with_native_roots()
8638/// #         .unwrap()
8639/// #         .https_or_http()
8640/// #         .enable_http2()
8641/// #         .build()
8642/// # );
8643/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
8644/// // As the method needs a request, you would usually fill it with the desired information
8645/// // into the respective structure. Some of the parts shown here might not be applicable !
8646/// // Values shown here are possibly random and not representative !
8647/// let mut req = GoogleCloudMlV1__ListOptimalTrialsRequest::default();
8648///
8649/// // You can configure optional parameters by calling the respective setters at will, and
8650/// // execute the final call using `doit()`.
8651/// // Values shown here are possibly random and not representative !
8652/// let result = hub.projects().locations_studies_trials_list_optimal_trials(req, "parent")
8653///              .doit().await;
8654/// # }
8655/// ```
8656pub struct ProjectLocationStudyTrialListOptimalTrialCall<'a, C>
8657where
8658    C: 'a,
8659{
8660    hub: &'a CloudMachineLearningEngine<C>,
8661    _request: GoogleCloudMlV1__ListOptimalTrialsRequest,
8662    _parent: String,
8663    _delegate: Option<&'a mut dyn common::Delegate>,
8664    _additional_params: HashMap<String, String>,
8665    _scopes: BTreeSet<String>,
8666}
8667
8668impl<'a, C> common::CallBuilder for ProjectLocationStudyTrialListOptimalTrialCall<'a, C> {}
8669
8670impl<'a, C> ProjectLocationStudyTrialListOptimalTrialCall<'a, C>
8671where
8672    C: common::Connector,
8673{
8674    /// Perform the operation you have build so far.
8675    pub async fn doit(
8676        mut self,
8677    ) -> common::Result<(common::Response, GoogleCloudMlV1__ListOptimalTrialsResponse)> {
8678        use std::borrow::Cow;
8679        use std::io::{Read, Seek};
8680
8681        use common::{url::Params, ToParts};
8682        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8683
8684        let mut dd = common::DefaultDelegate;
8685        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8686        dlg.begin(common::MethodInfo {
8687            id: "ml.projects.locations.studies.trials.listOptimalTrials",
8688            http_method: hyper::Method::POST,
8689        });
8690
8691        for &field in ["alt", "parent"].iter() {
8692            if self._additional_params.contains_key(field) {
8693                dlg.finished(false);
8694                return Err(common::Error::FieldClash(field));
8695            }
8696        }
8697
8698        let mut params = Params::with_capacity(4 + self._additional_params.len());
8699        params.push("parent", self._parent);
8700
8701        params.extend(self._additional_params.iter());
8702
8703        params.push("alt", "json");
8704        let mut url = self.hub._base_url.clone() + "v1/{+parent}/trials:listOptimalTrials";
8705        if self._scopes.is_empty() {
8706            self._scopes
8707                .insert(Scope::CloudPlatform.as_ref().to_string());
8708        }
8709
8710        #[allow(clippy::single_element_loop)]
8711        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8712            url = params.uri_replacement(url, param_name, find_this, true);
8713        }
8714        {
8715            let to_remove = ["parent"];
8716            params.remove_params(&to_remove);
8717        }
8718
8719        let url = params.parse_with_url(&url);
8720
8721        let mut json_mime_type = mime::APPLICATION_JSON;
8722        let mut request_value_reader = {
8723            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8724            common::remove_json_null_values(&mut value);
8725            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8726            serde_json::to_writer(&mut dst, &value).unwrap();
8727            dst
8728        };
8729        let request_size = request_value_reader
8730            .seek(std::io::SeekFrom::End(0))
8731            .unwrap();
8732        request_value_reader
8733            .seek(std::io::SeekFrom::Start(0))
8734            .unwrap();
8735
8736        loop {
8737            let token = match self
8738                .hub
8739                .auth
8740                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8741                .await
8742            {
8743                Ok(token) => token,
8744                Err(e) => match dlg.token(e) {
8745                    Ok(token) => token,
8746                    Err(e) => {
8747                        dlg.finished(false);
8748                        return Err(common::Error::MissingToken(e));
8749                    }
8750                },
8751            };
8752            request_value_reader
8753                .seek(std::io::SeekFrom::Start(0))
8754                .unwrap();
8755            let mut req_result = {
8756                let client = &self.hub.client;
8757                dlg.pre_request();
8758                let mut req_builder = hyper::Request::builder()
8759                    .method(hyper::Method::POST)
8760                    .uri(url.as_str())
8761                    .header(USER_AGENT, self.hub._user_agent.clone());
8762
8763                if let Some(token) = token.as_ref() {
8764                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8765                }
8766
8767                let request = req_builder
8768                    .header(CONTENT_TYPE, json_mime_type.to_string())
8769                    .header(CONTENT_LENGTH, request_size as u64)
8770                    .body(common::to_body(
8771                        request_value_reader.get_ref().clone().into(),
8772                    ));
8773
8774                client.request(request.unwrap()).await
8775            };
8776
8777            match req_result {
8778                Err(err) => {
8779                    if let common::Retry::After(d) = dlg.http_error(&err) {
8780                        sleep(d).await;
8781                        continue;
8782                    }
8783                    dlg.finished(false);
8784                    return Err(common::Error::HttpError(err));
8785                }
8786                Ok(res) => {
8787                    let (mut parts, body) = res.into_parts();
8788                    let mut body = common::Body::new(body);
8789                    if !parts.status.is_success() {
8790                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8791                        let error = serde_json::from_str(&common::to_string(&bytes));
8792                        let response = common::to_response(parts, bytes.into());
8793
8794                        if let common::Retry::After(d) =
8795                            dlg.http_failure(&response, error.as_ref().ok())
8796                        {
8797                            sleep(d).await;
8798                            continue;
8799                        }
8800
8801                        dlg.finished(false);
8802
8803                        return Err(match error {
8804                            Ok(value) => common::Error::BadRequest(value),
8805                            _ => common::Error::Failure(response),
8806                        });
8807                    }
8808                    let response = {
8809                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8810                        let encoded = common::to_string(&bytes);
8811                        match serde_json::from_str(&encoded) {
8812                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8813                            Err(error) => {
8814                                dlg.response_json_decode_error(&encoded, &error);
8815                                return Err(common::Error::JsonDecodeError(
8816                                    encoded.to_string(),
8817                                    error,
8818                                ));
8819                            }
8820                        }
8821                    };
8822
8823                    dlg.finished(true);
8824                    return Ok(response);
8825                }
8826            }
8827        }
8828    }
8829
8830    ///
8831    /// Sets the *request* property to the given value.
8832    ///
8833    /// Even though the property as already been set when instantiating this call,
8834    /// we provide this method for API completeness.
8835    pub fn request(
8836        mut self,
8837        new_value: GoogleCloudMlV1__ListOptimalTrialsRequest,
8838    ) -> ProjectLocationStudyTrialListOptimalTrialCall<'a, C> {
8839        self._request = new_value;
8840        self
8841    }
8842    /// Required. The name of the study that the pareto-optimal trial belongs to.
8843    ///
8844    /// Sets the *parent* path property to the given value.
8845    ///
8846    /// Even though the property as already been set when instantiating this call,
8847    /// we provide this method for API completeness.
8848    pub fn parent(
8849        mut self,
8850        new_value: &str,
8851    ) -> ProjectLocationStudyTrialListOptimalTrialCall<'a, C> {
8852        self._parent = new_value.to_string();
8853        self
8854    }
8855    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8856    /// while executing the actual API request.
8857    ///
8858    /// ````text
8859    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8860    /// ````
8861    ///
8862    /// Sets the *delegate* property to the given value.
8863    pub fn delegate(
8864        mut self,
8865        new_value: &'a mut dyn common::Delegate,
8866    ) -> ProjectLocationStudyTrialListOptimalTrialCall<'a, C> {
8867        self._delegate = Some(new_value);
8868        self
8869    }
8870
8871    /// Set any additional parameter of the query string used in the request.
8872    /// It should be used to set parameters which are not yet available through their own
8873    /// setters.
8874    ///
8875    /// Please note that this method must not be used to set any of the known parameters
8876    /// which have their own setter method. If done anyway, the request will fail.
8877    ///
8878    /// # Additional Parameters
8879    ///
8880    /// * *$.xgafv* (query-string) - V1 error format.
8881    /// * *access_token* (query-string) - OAuth access token.
8882    /// * *alt* (query-string) - Data format for response.
8883    /// * *callback* (query-string) - JSONP
8884    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8885    /// * *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.
8886    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8887    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8888    /// * *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.
8889    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8890    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8891    pub fn param<T>(
8892        mut self,
8893        name: T,
8894        value: T,
8895    ) -> ProjectLocationStudyTrialListOptimalTrialCall<'a, C>
8896    where
8897        T: AsRef<str>,
8898    {
8899        self._additional_params
8900            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8901        self
8902    }
8903
8904    /// Identifies the authorization scope for the method you are building.
8905    ///
8906    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8907    /// [`Scope::CloudPlatform`].
8908    ///
8909    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8910    /// tokens for more than one scope.
8911    ///
8912    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8913    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8914    /// sufficient, a read-write scope will do as well.
8915    pub fn add_scope<St>(
8916        mut self,
8917        scope: St,
8918    ) -> ProjectLocationStudyTrialListOptimalTrialCall<'a, C>
8919    where
8920        St: AsRef<str>,
8921    {
8922        self._scopes.insert(String::from(scope.as_ref()));
8923        self
8924    }
8925    /// Identifies the authorization scope(s) for the method you are building.
8926    ///
8927    /// See [`Self::add_scope()`] for details.
8928    pub fn add_scopes<I, St>(
8929        mut self,
8930        scopes: I,
8931    ) -> ProjectLocationStudyTrialListOptimalTrialCall<'a, C>
8932    where
8933        I: IntoIterator<Item = St>,
8934        St: AsRef<str>,
8935    {
8936        self._scopes
8937            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8938        self
8939    }
8940
8941    /// Removes all scopes, and no default scope will be used either.
8942    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8943    /// for details).
8944    pub fn clear_scopes(mut self) -> ProjectLocationStudyTrialListOptimalTrialCall<'a, C> {
8945        self._scopes.clear();
8946        self
8947    }
8948}
8949
8950/// Stops a trial.
8951///
8952/// A builder for the *locations.studies.trials.stop* method supported by a *project* resource.
8953/// It is not used directly, but through a [`ProjectMethods`] instance.
8954///
8955/// # Example
8956///
8957/// Instantiate a resource method builder
8958///
8959/// ```test_harness,no_run
8960/// # extern crate hyper;
8961/// # extern crate hyper_rustls;
8962/// # extern crate google_ml1 as ml1;
8963/// use ml1::api::GoogleCloudMlV1__StopTrialRequest;
8964/// # async fn dox() {
8965/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8966///
8967/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8968/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8969/// #     .with_native_roots()
8970/// #     .unwrap()
8971/// #     .https_only()
8972/// #     .enable_http2()
8973/// #     .build();
8974///
8975/// # let executor = hyper_util::rt::TokioExecutor::new();
8976/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8977/// #     secret,
8978/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8979/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8980/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8981/// #     ),
8982/// # ).build().await.unwrap();
8983///
8984/// # let client = hyper_util::client::legacy::Client::builder(
8985/// #     hyper_util::rt::TokioExecutor::new()
8986/// # )
8987/// # .build(
8988/// #     hyper_rustls::HttpsConnectorBuilder::new()
8989/// #         .with_native_roots()
8990/// #         .unwrap()
8991/// #         .https_or_http()
8992/// #         .enable_http2()
8993/// #         .build()
8994/// # );
8995/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
8996/// // As the method needs a request, you would usually fill it with the desired information
8997/// // into the respective structure. Some of the parts shown here might not be applicable !
8998/// // Values shown here are possibly random and not representative !
8999/// let mut req = GoogleCloudMlV1__StopTrialRequest::default();
9000///
9001/// // You can configure optional parameters by calling the respective setters at will, and
9002/// // execute the final call using `doit()`.
9003/// // Values shown here are possibly random and not representative !
9004/// let result = hub.projects().locations_studies_trials_stop(req, "name")
9005///              .doit().await;
9006/// # }
9007/// ```
9008pub struct ProjectLocationStudyTrialStopCall<'a, C>
9009where
9010    C: 'a,
9011{
9012    hub: &'a CloudMachineLearningEngine<C>,
9013    _request: GoogleCloudMlV1__StopTrialRequest,
9014    _name: String,
9015    _delegate: Option<&'a mut dyn common::Delegate>,
9016    _additional_params: HashMap<String, String>,
9017    _scopes: BTreeSet<String>,
9018}
9019
9020impl<'a, C> common::CallBuilder for ProjectLocationStudyTrialStopCall<'a, C> {}
9021
9022impl<'a, C> ProjectLocationStudyTrialStopCall<'a, C>
9023where
9024    C: common::Connector,
9025{
9026    /// Perform the operation you have build so far.
9027    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleCloudMlV1__Trial)> {
9028        use std::borrow::Cow;
9029        use std::io::{Read, Seek};
9030
9031        use common::{url::Params, ToParts};
9032        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9033
9034        let mut dd = common::DefaultDelegate;
9035        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9036        dlg.begin(common::MethodInfo {
9037            id: "ml.projects.locations.studies.trials.stop",
9038            http_method: hyper::Method::POST,
9039        });
9040
9041        for &field in ["alt", "name"].iter() {
9042            if self._additional_params.contains_key(field) {
9043                dlg.finished(false);
9044                return Err(common::Error::FieldClash(field));
9045            }
9046        }
9047
9048        let mut params = Params::with_capacity(4 + self._additional_params.len());
9049        params.push("name", self._name);
9050
9051        params.extend(self._additional_params.iter());
9052
9053        params.push("alt", "json");
9054        let mut url = self.hub._base_url.clone() + "v1/{+name}:stop";
9055        if self._scopes.is_empty() {
9056            self._scopes
9057                .insert(Scope::CloudPlatform.as_ref().to_string());
9058        }
9059
9060        #[allow(clippy::single_element_loop)]
9061        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9062            url = params.uri_replacement(url, param_name, find_this, true);
9063        }
9064        {
9065            let to_remove = ["name"];
9066            params.remove_params(&to_remove);
9067        }
9068
9069        let url = params.parse_with_url(&url);
9070
9071        let mut json_mime_type = mime::APPLICATION_JSON;
9072        let mut request_value_reader = {
9073            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9074            common::remove_json_null_values(&mut value);
9075            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9076            serde_json::to_writer(&mut dst, &value).unwrap();
9077            dst
9078        };
9079        let request_size = request_value_reader
9080            .seek(std::io::SeekFrom::End(0))
9081            .unwrap();
9082        request_value_reader
9083            .seek(std::io::SeekFrom::Start(0))
9084            .unwrap();
9085
9086        loop {
9087            let token = match self
9088                .hub
9089                .auth
9090                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9091                .await
9092            {
9093                Ok(token) => token,
9094                Err(e) => match dlg.token(e) {
9095                    Ok(token) => token,
9096                    Err(e) => {
9097                        dlg.finished(false);
9098                        return Err(common::Error::MissingToken(e));
9099                    }
9100                },
9101            };
9102            request_value_reader
9103                .seek(std::io::SeekFrom::Start(0))
9104                .unwrap();
9105            let mut req_result = {
9106                let client = &self.hub.client;
9107                dlg.pre_request();
9108                let mut req_builder = hyper::Request::builder()
9109                    .method(hyper::Method::POST)
9110                    .uri(url.as_str())
9111                    .header(USER_AGENT, self.hub._user_agent.clone());
9112
9113                if let Some(token) = token.as_ref() {
9114                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9115                }
9116
9117                let request = req_builder
9118                    .header(CONTENT_TYPE, json_mime_type.to_string())
9119                    .header(CONTENT_LENGTH, request_size as u64)
9120                    .body(common::to_body(
9121                        request_value_reader.get_ref().clone().into(),
9122                    ));
9123
9124                client.request(request.unwrap()).await
9125            };
9126
9127            match req_result {
9128                Err(err) => {
9129                    if let common::Retry::After(d) = dlg.http_error(&err) {
9130                        sleep(d).await;
9131                        continue;
9132                    }
9133                    dlg.finished(false);
9134                    return Err(common::Error::HttpError(err));
9135                }
9136                Ok(res) => {
9137                    let (mut parts, body) = res.into_parts();
9138                    let mut body = common::Body::new(body);
9139                    if !parts.status.is_success() {
9140                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9141                        let error = serde_json::from_str(&common::to_string(&bytes));
9142                        let response = common::to_response(parts, bytes.into());
9143
9144                        if let common::Retry::After(d) =
9145                            dlg.http_failure(&response, error.as_ref().ok())
9146                        {
9147                            sleep(d).await;
9148                            continue;
9149                        }
9150
9151                        dlg.finished(false);
9152
9153                        return Err(match error {
9154                            Ok(value) => common::Error::BadRequest(value),
9155                            _ => common::Error::Failure(response),
9156                        });
9157                    }
9158                    let response = {
9159                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9160                        let encoded = common::to_string(&bytes);
9161                        match serde_json::from_str(&encoded) {
9162                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9163                            Err(error) => {
9164                                dlg.response_json_decode_error(&encoded, &error);
9165                                return Err(common::Error::JsonDecodeError(
9166                                    encoded.to_string(),
9167                                    error,
9168                                ));
9169                            }
9170                        }
9171                    };
9172
9173                    dlg.finished(true);
9174                    return Ok(response);
9175                }
9176            }
9177        }
9178    }
9179
9180    ///
9181    /// Sets the *request* property to the given value.
9182    ///
9183    /// Even though the property as already been set when instantiating this call,
9184    /// we provide this method for API completeness.
9185    pub fn request(
9186        mut self,
9187        new_value: GoogleCloudMlV1__StopTrialRequest,
9188    ) -> ProjectLocationStudyTrialStopCall<'a, C> {
9189        self._request = new_value;
9190        self
9191    }
9192    /// Required. The trial name.
9193    ///
9194    /// Sets the *name* path property to the given value.
9195    ///
9196    /// Even though the property as already been set when instantiating this call,
9197    /// we provide this method for API completeness.
9198    pub fn name(mut self, new_value: &str) -> ProjectLocationStudyTrialStopCall<'a, C> {
9199        self._name = new_value.to_string();
9200        self
9201    }
9202    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9203    /// while executing the actual API request.
9204    ///
9205    /// ````text
9206    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9207    /// ````
9208    ///
9209    /// Sets the *delegate* property to the given value.
9210    pub fn delegate(
9211        mut self,
9212        new_value: &'a mut dyn common::Delegate,
9213    ) -> ProjectLocationStudyTrialStopCall<'a, C> {
9214        self._delegate = Some(new_value);
9215        self
9216    }
9217
9218    /// Set any additional parameter of the query string used in the request.
9219    /// It should be used to set parameters which are not yet available through their own
9220    /// setters.
9221    ///
9222    /// Please note that this method must not be used to set any of the known parameters
9223    /// which have their own setter method. If done anyway, the request will fail.
9224    ///
9225    /// # Additional Parameters
9226    ///
9227    /// * *$.xgafv* (query-string) - V1 error format.
9228    /// * *access_token* (query-string) - OAuth access token.
9229    /// * *alt* (query-string) - Data format for response.
9230    /// * *callback* (query-string) - JSONP
9231    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9232    /// * *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.
9233    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9234    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9235    /// * *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.
9236    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9237    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9238    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationStudyTrialStopCall<'a, C>
9239    where
9240        T: AsRef<str>,
9241    {
9242        self._additional_params
9243            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9244        self
9245    }
9246
9247    /// Identifies the authorization scope for the method you are building.
9248    ///
9249    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9250    /// [`Scope::CloudPlatform`].
9251    ///
9252    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9253    /// tokens for more than one scope.
9254    ///
9255    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9256    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9257    /// sufficient, a read-write scope will do as well.
9258    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationStudyTrialStopCall<'a, C>
9259    where
9260        St: AsRef<str>,
9261    {
9262        self._scopes.insert(String::from(scope.as_ref()));
9263        self
9264    }
9265    /// Identifies the authorization scope(s) for the method you are building.
9266    ///
9267    /// See [`Self::add_scope()`] for details.
9268    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationStudyTrialStopCall<'a, C>
9269    where
9270        I: IntoIterator<Item = St>,
9271        St: AsRef<str>,
9272    {
9273        self._scopes
9274            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9275        self
9276    }
9277
9278    /// Removes all scopes, and no default scope will be used either.
9279    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9280    /// for details).
9281    pub fn clear_scopes(mut self) -> ProjectLocationStudyTrialStopCall<'a, C> {
9282        self._scopes.clear();
9283        self
9284    }
9285}
9286
9287/// Adds one or more trials to a study, with parameter values suggested by AI Platform Vizier. Returns a long-running operation associated with the generation of trial suggestions. When this long-running operation succeeds, it will contain a SuggestTrialsResponse.
9288///
9289/// A builder for the *locations.studies.trials.suggest* method supported by a *project* resource.
9290/// It is not used directly, but through a [`ProjectMethods`] instance.
9291///
9292/// # Example
9293///
9294/// Instantiate a resource method builder
9295///
9296/// ```test_harness,no_run
9297/// # extern crate hyper;
9298/// # extern crate hyper_rustls;
9299/// # extern crate google_ml1 as ml1;
9300/// use ml1::api::GoogleCloudMlV1__SuggestTrialsRequest;
9301/// # async fn dox() {
9302/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9303///
9304/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9305/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9306/// #     .with_native_roots()
9307/// #     .unwrap()
9308/// #     .https_only()
9309/// #     .enable_http2()
9310/// #     .build();
9311///
9312/// # let executor = hyper_util::rt::TokioExecutor::new();
9313/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9314/// #     secret,
9315/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9316/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9317/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9318/// #     ),
9319/// # ).build().await.unwrap();
9320///
9321/// # let client = hyper_util::client::legacy::Client::builder(
9322/// #     hyper_util::rt::TokioExecutor::new()
9323/// # )
9324/// # .build(
9325/// #     hyper_rustls::HttpsConnectorBuilder::new()
9326/// #         .with_native_roots()
9327/// #         .unwrap()
9328/// #         .https_or_http()
9329/// #         .enable_http2()
9330/// #         .build()
9331/// # );
9332/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
9333/// // As the method needs a request, you would usually fill it with the desired information
9334/// // into the respective structure. Some of the parts shown here might not be applicable !
9335/// // Values shown here are possibly random and not representative !
9336/// let mut req = GoogleCloudMlV1__SuggestTrialsRequest::default();
9337///
9338/// // You can configure optional parameters by calling the respective setters at will, and
9339/// // execute the final call using `doit()`.
9340/// // Values shown here are possibly random and not representative !
9341/// let result = hub.projects().locations_studies_trials_suggest(req, "parent")
9342///              .doit().await;
9343/// # }
9344/// ```
9345pub struct ProjectLocationStudyTrialSuggestCall<'a, C>
9346where
9347    C: 'a,
9348{
9349    hub: &'a CloudMachineLearningEngine<C>,
9350    _request: GoogleCloudMlV1__SuggestTrialsRequest,
9351    _parent: String,
9352    _delegate: Option<&'a mut dyn common::Delegate>,
9353    _additional_params: HashMap<String, String>,
9354    _scopes: BTreeSet<String>,
9355}
9356
9357impl<'a, C> common::CallBuilder for ProjectLocationStudyTrialSuggestCall<'a, C> {}
9358
9359impl<'a, C> ProjectLocationStudyTrialSuggestCall<'a, C>
9360where
9361    C: common::Connector,
9362{
9363    /// Perform the operation you have build so far.
9364    pub async fn doit(
9365        mut self,
9366    ) -> common::Result<(common::Response, GoogleLongrunning__Operation)> {
9367        use std::borrow::Cow;
9368        use std::io::{Read, Seek};
9369
9370        use common::{url::Params, ToParts};
9371        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9372
9373        let mut dd = common::DefaultDelegate;
9374        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9375        dlg.begin(common::MethodInfo {
9376            id: "ml.projects.locations.studies.trials.suggest",
9377            http_method: hyper::Method::POST,
9378        });
9379
9380        for &field in ["alt", "parent"].iter() {
9381            if self._additional_params.contains_key(field) {
9382                dlg.finished(false);
9383                return Err(common::Error::FieldClash(field));
9384            }
9385        }
9386
9387        let mut params = Params::with_capacity(4 + self._additional_params.len());
9388        params.push("parent", self._parent);
9389
9390        params.extend(self._additional_params.iter());
9391
9392        params.push("alt", "json");
9393        let mut url = self.hub._base_url.clone() + "v1/{+parent}/trials:suggest";
9394        if self._scopes.is_empty() {
9395            self._scopes
9396                .insert(Scope::CloudPlatform.as_ref().to_string());
9397        }
9398
9399        #[allow(clippy::single_element_loop)]
9400        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9401            url = params.uri_replacement(url, param_name, find_this, true);
9402        }
9403        {
9404            let to_remove = ["parent"];
9405            params.remove_params(&to_remove);
9406        }
9407
9408        let url = params.parse_with_url(&url);
9409
9410        let mut json_mime_type = mime::APPLICATION_JSON;
9411        let mut request_value_reader = {
9412            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9413            common::remove_json_null_values(&mut value);
9414            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9415            serde_json::to_writer(&mut dst, &value).unwrap();
9416            dst
9417        };
9418        let request_size = request_value_reader
9419            .seek(std::io::SeekFrom::End(0))
9420            .unwrap();
9421        request_value_reader
9422            .seek(std::io::SeekFrom::Start(0))
9423            .unwrap();
9424
9425        loop {
9426            let token = match self
9427                .hub
9428                .auth
9429                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9430                .await
9431            {
9432                Ok(token) => token,
9433                Err(e) => match dlg.token(e) {
9434                    Ok(token) => token,
9435                    Err(e) => {
9436                        dlg.finished(false);
9437                        return Err(common::Error::MissingToken(e));
9438                    }
9439                },
9440            };
9441            request_value_reader
9442                .seek(std::io::SeekFrom::Start(0))
9443                .unwrap();
9444            let mut req_result = {
9445                let client = &self.hub.client;
9446                dlg.pre_request();
9447                let mut req_builder = hyper::Request::builder()
9448                    .method(hyper::Method::POST)
9449                    .uri(url.as_str())
9450                    .header(USER_AGENT, self.hub._user_agent.clone());
9451
9452                if let Some(token) = token.as_ref() {
9453                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9454                }
9455
9456                let request = req_builder
9457                    .header(CONTENT_TYPE, json_mime_type.to_string())
9458                    .header(CONTENT_LENGTH, request_size as u64)
9459                    .body(common::to_body(
9460                        request_value_reader.get_ref().clone().into(),
9461                    ));
9462
9463                client.request(request.unwrap()).await
9464            };
9465
9466            match req_result {
9467                Err(err) => {
9468                    if let common::Retry::After(d) = dlg.http_error(&err) {
9469                        sleep(d).await;
9470                        continue;
9471                    }
9472                    dlg.finished(false);
9473                    return Err(common::Error::HttpError(err));
9474                }
9475                Ok(res) => {
9476                    let (mut parts, body) = res.into_parts();
9477                    let mut body = common::Body::new(body);
9478                    if !parts.status.is_success() {
9479                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9480                        let error = serde_json::from_str(&common::to_string(&bytes));
9481                        let response = common::to_response(parts, bytes.into());
9482
9483                        if let common::Retry::After(d) =
9484                            dlg.http_failure(&response, error.as_ref().ok())
9485                        {
9486                            sleep(d).await;
9487                            continue;
9488                        }
9489
9490                        dlg.finished(false);
9491
9492                        return Err(match error {
9493                            Ok(value) => common::Error::BadRequest(value),
9494                            _ => common::Error::Failure(response),
9495                        });
9496                    }
9497                    let response = {
9498                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9499                        let encoded = common::to_string(&bytes);
9500                        match serde_json::from_str(&encoded) {
9501                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9502                            Err(error) => {
9503                                dlg.response_json_decode_error(&encoded, &error);
9504                                return Err(common::Error::JsonDecodeError(
9505                                    encoded.to_string(),
9506                                    error,
9507                                ));
9508                            }
9509                        }
9510                    };
9511
9512                    dlg.finished(true);
9513                    return Ok(response);
9514                }
9515            }
9516        }
9517    }
9518
9519    ///
9520    /// Sets the *request* property to the given value.
9521    ///
9522    /// Even though the property as already been set when instantiating this call,
9523    /// we provide this method for API completeness.
9524    pub fn request(
9525        mut self,
9526        new_value: GoogleCloudMlV1__SuggestTrialsRequest,
9527    ) -> ProjectLocationStudyTrialSuggestCall<'a, C> {
9528        self._request = new_value;
9529        self
9530    }
9531    /// Required. The name of the study that the trial belongs to.
9532    ///
9533    /// Sets the *parent* path property to the given value.
9534    ///
9535    /// Even though the property as already been set when instantiating this call,
9536    /// we provide this method for API completeness.
9537    pub fn parent(mut self, new_value: &str) -> ProjectLocationStudyTrialSuggestCall<'a, C> {
9538        self._parent = new_value.to_string();
9539        self
9540    }
9541    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9542    /// while executing the actual API request.
9543    ///
9544    /// ````text
9545    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9546    /// ````
9547    ///
9548    /// Sets the *delegate* property to the given value.
9549    pub fn delegate(
9550        mut self,
9551        new_value: &'a mut dyn common::Delegate,
9552    ) -> ProjectLocationStudyTrialSuggestCall<'a, C> {
9553        self._delegate = Some(new_value);
9554        self
9555    }
9556
9557    /// Set any additional parameter of the query string used in the request.
9558    /// It should be used to set parameters which are not yet available through their own
9559    /// setters.
9560    ///
9561    /// Please note that this method must not be used to set any of the known parameters
9562    /// which have their own setter method. If done anyway, the request will fail.
9563    ///
9564    /// # Additional Parameters
9565    ///
9566    /// * *$.xgafv* (query-string) - V1 error format.
9567    /// * *access_token* (query-string) - OAuth access token.
9568    /// * *alt* (query-string) - Data format for response.
9569    /// * *callback* (query-string) - JSONP
9570    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9571    /// * *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.
9572    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9573    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9574    /// * *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.
9575    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9576    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9577    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationStudyTrialSuggestCall<'a, C>
9578    where
9579        T: AsRef<str>,
9580    {
9581        self._additional_params
9582            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9583        self
9584    }
9585
9586    /// Identifies the authorization scope for the method you are building.
9587    ///
9588    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9589    /// [`Scope::CloudPlatform`].
9590    ///
9591    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9592    /// tokens for more than one scope.
9593    ///
9594    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9595    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9596    /// sufficient, a read-write scope will do as well.
9597    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationStudyTrialSuggestCall<'a, C>
9598    where
9599        St: AsRef<str>,
9600    {
9601        self._scopes.insert(String::from(scope.as_ref()));
9602        self
9603    }
9604    /// Identifies the authorization scope(s) for the method you are building.
9605    ///
9606    /// See [`Self::add_scope()`] for details.
9607    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationStudyTrialSuggestCall<'a, C>
9608    where
9609        I: IntoIterator<Item = St>,
9610        St: AsRef<str>,
9611    {
9612        self._scopes
9613            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9614        self
9615    }
9616
9617    /// Removes all scopes, and no default scope will be used either.
9618    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9619    /// for details).
9620    pub fn clear_scopes(mut self) -> ProjectLocationStudyTrialSuggestCall<'a, C> {
9621        self._scopes.clear();
9622        self
9623    }
9624}
9625
9626/// Creates a study.
9627///
9628/// A builder for the *locations.studies.create* method supported by a *project* resource.
9629/// It is not used directly, but through a [`ProjectMethods`] instance.
9630///
9631/// # Example
9632///
9633/// Instantiate a resource method builder
9634///
9635/// ```test_harness,no_run
9636/// # extern crate hyper;
9637/// # extern crate hyper_rustls;
9638/// # extern crate google_ml1 as ml1;
9639/// use ml1::api::GoogleCloudMlV1__Study;
9640/// # async fn dox() {
9641/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9642///
9643/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9644/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9645/// #     .with_native_roots()
9646/// #     .unwrap()
9647/// #     .https_only()
9648/// #     .enable_http2()
9649/// #     .build();
9650///
9651/// # let executor = hyper_util::rt::TokioExecutor::new();
9652/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9653/// #     secret,
9654/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9655/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9656/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9657/// #     ),
9658/// # ).build().await.unwrap();
9659///
9660/// # let client = hyper_util::client::legacy::Client::builder(
9661/// #     hyper_util::rt::TokioExecutor::new()
9662/// # )
9663/// # .build(
9664/// #     hyper_rustls::HttpsConnectorBuilder::new()
9665/// #         .with_native_roots()
9666/// #         .unwrap()
9667/// #         .https_or_http()
9668/// #         .enable_http2()
9669/// #         .build()
9670/// # );
9671/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
9672/// // As the method needs a request, you would usually fill it with the desired information
9673/// // into the respective structure. Some of the parts shown here might not be applicable !
9674/// // Values shown here are possibly random and not representative !
9675/// let mut req = GoogleCloudMlV1__Study::default();
9676///
9677/// // You can configure optional parameters by calling the respective setters at will, and
9678/// // execute the final call using `doit()`.
9679/// // Values shown here are possibly random and not representative !
9680/// let result = hub.projects().locations_studies_create(req, "parent")
9681///              .study_id("est")
9682///              .doit().await;
9683/// # }
9684/// ```
9685pub struct ProjectLocationStudyCreateCall<'a, C>
9686where
9687    C: 'a,
9688{
9689    hub: &'a CloudMachineLearningEngine<C>,
9690    _request: GoogleCloudMlV1__Study,
9691    _parent: String,
9692    _study_id: Option<String>,
9693    _delegate: Option<&'a mut dyn common::Delegate>,
9694    _additional_params: HashMap<String, String>,
9695    _scopes: BTreeSet<String>,
9696}
9697
9698impl<'a, C> common::CallBuilder for ProjectLocationStudyCreateCall<'a, C> {}
9699
9700impl<'a, C> ProjectLocationStudyCreateCall<'a, C>
9701where
9702    C: common::Connector,
9703{
9704    /// Perform the operation you have build so far.
9705    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleCloudMlV1__Study)> {
9706        use std::borrow::Cow;
9707        use std::io::{Read, Seek};
9708
9709        use common::{url::Params, ToParts};
9710        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9711
9712        let mut dd = common::DefaultDelegate;
9713        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9714        dlg.begin(common::MethodInfo {
9715            id: "ml.projects.locations.studies.create",
9716            http_method: hyper::Method::POST,
9717        });
9718
9719        for &field in ["alt", "parent", "studyId"].iter() {
9720            if self._additional_params.contains_key(field) {
9721                dlg.finished(false);
9722                return Err(common::Error::FieldClash(field));
9723            }
9724        }
9725
9726        let mut params = Params::with_capacity(5 + self._additional_params.len());
9727        params.push("parent", self._parent);
9728        if let Some(value) = self._study_id.as_ref() {
9729            params.push("studyId", value);
9730        }
9731
9732        params.extend(self._additional_params.iter());
9733
9734        params.push("alt", "json");
9735        let mut url = self.hub._base_url.clone() + "v1/{+parent}/studies";
9736        if self._scopes.is_empty() {
9737            self._scopes
9738                .insert(Scope::CloudPlatform.as_ref().to_string());
9739        }
9740
9741        #[allow(clippy::single_element_loop)]
9742        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9743            url = params.uri_replacement(url, param_name, find_this, true);
9744        }
9745        {
9746            let to_remove = ["parent"];
9747            params.remove_params(&to_remove);
9748        }
9749
9750        let url = params.parse_with_url(&url);
9751
9752        let mut json_mime_type = mime::APPLICATION_JSON;
9753        let mut request_value_reader = {
9754            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9755            common::remove_json_null_values(&mut value);
9756            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9757            serde_json::to_writer(&mut dst, &value).unwrap();
9758            dst
9759        };
9760        let request_size = request_value_reader
9761            .seek(std::io::SeekFrom::End(0))
9762            .unwrap();
9763        request_value_reader
9764            .seek(std::io::SeekFrom::Start(0))
9765            .unwrap();
9766
9767        loop {
9768            let token = match self
9769                .hub
9770                .auth
9771                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9772                .await
9773            {
9774                Ok(token) => token,
9775                Err(e) => match dlg.token(e) {
9776                    Ok(token) => token,
9777                    Err(e) => {
9778                        dlg.finished(false);
9779                        return Err(common::Error::MissingToken(e));
9780                    }
9781                },
9782            };
9783            request_value_reader
9784                .seek(std::io::SeekFrom::Start(0))
9785                .unwrap();
9786            let mut req_result = {
9787                let client = &self.hub.client;
9788                dlg.pre_request();
9789                let mut req_builder = hyper::Request::builder()
9790                    .method(hyper::Method::POST)
9791                    .uri(url.as_str())
9792                    .header(USER_AGENT, self.hub._user_agent.clone());
9793
9794                if let Some(token) = token.as_ref() {
9795                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9796                }
9797
9798                let request = req_builder
9799                    .header(CONTENT_TYPE, json_mime_type.to_string())
9800                    .header(CONTENT_LENGTH, request_size as u64)
9801                    .body(common::to_body(
9802                        request_value_reader.get_ref().clone().into(),
9803                    ));
9804
9805                client.request(request.unwrap()).await
9806            };
9807
9808            match req_result {
9809                Err(err) => {
9810                    if let common::Retry::After(d) = dlg.http_error(&err) {
9811                        sleep(d).await;
9812                        continue;
9813                    }
9814                    dlg.finished(false);
9815                    return Err(common::Error::HttpError(err));
9816                }
9817                Ok(res) => {
9818                    let (mut parts, body) = res.into_parts();
9819                    let mut body = common::Body::new(body);
9820                    if !parts.status.is_success() {
9821                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9822                        let error = serde_json::from_str(&common::to_string(&bytes));
9823                        let response = common::to_response(parts, bytes.into());
9824
9825                        if let common::Retry::After(d) =
9826                            dlg.http_failure(&response, error.as_ref().ok())
9827                        {
9828                            sleep(d).await;
9829                            continue;
9830                        }
9831
9832                        dlg.finished(false);
9833
9834                        return Err(match error {
9835                            Ok(value) => common::Error::BadRequest(value),
9836                            _ => common::Error::Failure(response),
9837                        });
9838                    }
9839                    let response = {
9840                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9841                        let encoded = common::to_string(&bytes);
9842                        match serde_json::from_str(&encoded) {
9843                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9844                            Err(error) => {
9845                                dlg.response_json_decode_error(&encoded, &error);
9846                                return Err(common::Error::JsonDecodeError(
9847                                    encoded.to_string(),
9848                                    error,
9849                                ));
9850                            }
9851                        }
9852                    };
9853
9854                    dlg.finished(true);
9855                    return Ok(response);
9856                }
9857            }
9858        }
9859    }
9860
9861    ///
9862    /// Sets the *request* property to the given value.
9863    ///
9864    /// Even though the property as already been set when instantiating this call,
9865    /// we provide this method for API completeness.
9866    pub fn request(
9867        mut self,
9868        new_value: GoogleCloudMlV1__Study,
9869    ) -> ProjectLocationStudyCreateCall<'a, C> {
9870        self._request = new_value;
9871        self
9872    }
9873    /// Required. The project and location that the study belongs to. Format: projects/{project}/locations/{location}
9874    ///
9875    /// Sets the *parent* path property to the given value.
9876    ///
9877    /// Even though the property as already been set when instantiating this call,
9878    /// we provide this method for API completeness.
9879    pub fn parent(mut self, new_value: &str) -> ProjectLocationStudyCreateCall<'a, C> {
9880        self._parent = new_value.to_string();
9881        self
9882    }
9883    /// Required. The ID to use for the study, which will become the final component of the study's resource name.
9884    ///
9885    /// Sets the *study id* query property to the given value.
9886    pub fn study_id(mut self, new_value: &str) -> ProjectLocationStudyCreateCall<'a, C> {
9887        self._study_id = Some(new_value.to_string());
9888        self
9889    }
9890    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9891    /// while executing the actual API request.
9892    ///
9893    /// ````text
9894    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9895    /// ````
9896    ///
9897    /// Sets the *delegate* property to the given value.
9898    pub fn delegate(
9899        mut self,
9900        new_value: &'a mut dyn common::Delegate,
9901    ) -> ProjectLocationStudyCreateCall<'a, C> {
9902        self._delegate = Some(new_value);
9903        self
9904    }
9905
9906    /// Set any additional parameter of the query string used in the request.
9907    /// It should be used to set parameters which are not yet available through their own
9908    /// setters.
9909    ///
9910    /// Please note that this method must not be used to set any of the known parameters
9911    /// which have their own setter method. If done anyway, the request will fail.
9912    ///
9913    /// # Additional Parameters
9914    ///
9915    /// * *$.xgafv* (query-string) - V1 error format.
9916    /// * *access_token* (query-string) - OAuth access token.
9917    /// * *alt* (query-string) - Data format for response.
9918    /// * *callback* (query-string) - JSONP
9919    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9920    /// * *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.
9921    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9922    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9923    /// * *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.
9924    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9925    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9926    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationStudyCreateCall<'a, C>
9927    where
9928        T: AsRef<str>,
9929    {
9930        self._additional_params
9931            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9932        self
9933    }
9934
9935    /// Identifies the authorization scope for the method you are building.
9936    ///
9937    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9938    /// [`Scope::CloudPlatform`].
9939    ///
9940    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9941    /// tokens for more than one scope.
9942    ///
9943    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9944    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9945    /// sufficient, a read-write scope will do as well.
9946    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationStudyCreateCall<'a, C>
9947    where
9948        St: AsRef<str>,
9949    {
9950        self._scopes.insert(String::from(scope.as_ref()));
9951        self
9952    }
9953    /// Identifies the authorization scope(s) for the method you are building.
9954    ///
9955    /// See [`Self::add_scope()`] for details.
9956    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationStudyCreateCall<'a, C>
9957    where
9958        I: IntoIterator<Item = St>,
9959        St: AsRef<str>,
9960    {
9961        self._scopes
9962            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9963        self
9964    }
9965
9966    /// Removes all scopes, and no default scope will be used either.
9967    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9968    /// for details).
9969    pub fn clear_scopes(mut self) -> ProjectLocationStudyCreateCall<'a, C> {
9970        self._scopes.clear();
9971        self
9972    }
9973}
9974
9975/// Deletes a study.
9976///
9977/// A builder for the *locations.studies.delete* method supported by a *project* resource.
9978/// It is not used directly, but through a [`ProjectMethods`] instance.
9979///
9980/// # Example
9981///
9982/// Instantiate a resource method builder
9983///
9984/// ```test_harness,no_run
9985/// # extern crate hyper;
9986/// # extern crate hyper_rustls;
9987/// # extern crate google_ml1 as ml1;
9988/// # async fn dox() {
9989/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9990///
9991/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9992/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9993/// #     .with_native_roots()
9994/// #     .unwrap()
9995/// #     .https_only()
9996/// #     .enable_http2()
9997/// #     .build();
9998///
9999/// # let executor = hyper_util::rt::TokioExecutor::new();
10000/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10001/// #     secret,
10002/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10003/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10004/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10005/// #     ),
10006/// # ).build().await.unwrap();
10007///
10008/// # let client = hyper_util::client::legacy::Client::builder(
10009/// #     hyper_util::rt::TokioExecutor::new()
10010/// # )
10011/// # .build(
10012/// #     hyper_rustls::HttpsConnectorBuilder::new()
10013/// #         .with_native_roots()
10014/// #         .unwrap()
10015/// #         .https_or_http()
10016/// #         .enable_http2()
10017/// #         .build()
10018/// # );
10019/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
10020/// // You can configure optional parameters by calling the respective setters at will, and
10021/// // execute the final call using `doit()`.
10022/// // Values shown here are possibly random and not representative !
10023/// let result = hub.projects().locations_studies_delete("name")
10024///              .doit().await;
10025/// # }
10026/// ```
10027pub struct ProjectLocationStudyDeleteCall<'a, C>
10028where
10029    C: 'a,
10030{
10031    hub: &'a CloudMachineLearningEngine<C>,
10032    _name: String,
10033    _delegate: Option<&'a mut dyn common::Delegate>,
10034    _additional_params: HashMap<String, String>,
10035    _scopes: BTreeSet<String>,
10036}
10037
10038impl<'a, C> common::CallBuilder for ProjectLocationStudyDeleteCall<'a, C> {}
10039
10040impl<'a, C> ProjectLocationStudyDeleteCall<'a, C>
10041where
10042    C: common::Connector,
10043{
10044    /// Perform the operation you have build so far.
10045    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleProtobuf__Empty)> {
10046        use std::borrow::Cow;
10047        use std::io::{Read, Seek};
10048
10049        use common::{url::Params, ToParts};
10050        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10051
10052        let mut dd = common::DefaultDelegate;
10053        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10054        dlg.begin(common::MethodInfo {
10055            id: "ml.projects.locations.studies.delete",
10056            http_method: hyper::Method::DELETE,
10057        });
10058
10059        for &field in ["alt", "name"].iter() {
10060            if self._additional_params.contains_key(field) {
10061                dlg.finished(false);
10062                return Err(common::Error::FieldClash(field));
10063            }
10064        }
10065
10066        let mut params = Params::with_capacity(3 + self._additional_params.len());
10067        params.push("name", self._name);
10068
10069        params.extend(self._additional_params.iter());
10070
10071        params.push("alt", "json");
10072        let mut url = self.hub._base_url.clone() + "v1/{+name}";
10073        if self._scopes.is_empty() {
10074            self._scopes
10075                .insert(Scope::CloudPlatform.as_ref().to_string());
10076        }
10077
10078        #[allow(clippy::single_element_loop)]
10079        for &(find_this, param_name) in [("{+name}", "name")].iter() {
10080            url = params.uri_replacement(url, param_name, find_this, true);
10081        }
10082        {
10083            let to_remove = ["name"];
10084            params.remove_params(&to_remove);
10085        }
10086
10087        let url = params.parse_with_url(&url);
10088
10089        loop {
10090            let token = match self
10091                .hub
10092                .auth
10093                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10094                .await
10095            {
10096                Ok(token) => token,
10097                Err(e) => match dlg.token(e) {
10098                    Ok(token) => token,
10099                    Err(e) => {
10100                        dlg.finished(false);
10101                        return Err(common::Error::MissingToken(e));
10102                    }
10103                },
10104            };
10105            let mut req_result = {
10106                let client = &self.hub.client;
10107                dlg.pre_request();
10108                let mut req_builder = hyper::Request::builder()
10109                    .method(hyper::Method::DELETE)
10110                    .uri(url.as_str())
10111                    .header(USER_AGENT, self.hub._user_agent.clone());
10112
10113                if let Some(token) = token.as_ref() {
10114                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10115                }
10116
10117                let request = req_builder
10118                    .header(CONTENT_LENGTH, 0_u64)
10119                    .body(common::to_body::<String>(None));
10120
10121                client.request(request.unwrap()).await
10122            };
10123
10124            match req_result {
10125                Err(err) => {
10126                    if let common::Retry::After(d) = dlg.http_error(&err) {
10127                        sleep(d).await;
10128                        continue;
10129                    }
10130                    dlg.finished(false);
10131                    return Err(common::Error::HttpError(err));
10132                }
10133                Ok(res) => {
10134                    let (mut parts, body) = res.into_parts();
10135                    let mut body = common::Body::new(body);
10136                    if !parts.status.is_success() {
10137                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10138                        let error = serde_json::from_str(&common::to_string(&bytes));
10139                        let response = common::to_response(parts, bytes.into());
10140
10141                        if let common::Retry::After(d) =
10142                            dlg.http_failure(&response, error.as_ref().ok())
10143                        {
10144                            sleep(d).await;
10145                            continue;
10146                        }
10147
10148                        dlg.finished(false);
10149
10150                        return Err(match error {
10151                            Ok(value) => common::Error::BadRequest(value),
10152                            _ => common::Error::Failure(response),
10153                        });
10154                    }
10155                    let response = {
10156                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10157                        let encoded = common::to_string(&bytes);
10158                        match serde_json::from_str(&encoded) {
10159                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10160                            Err(error) => {
10161                                dlg.response_json_decode_error(&encoded, &error);
10162                                return Err(common::Error::JsonDecodeError(
10163                                    encoded.to_string(),
10164                                    error,
10165                                ));
10166                            }
10167                        }
10168                    };
10169
10170                    dlg.finished(true);
10171                    return Ok(response);
10172                }
10173            }
10174        }
10175    }
10176
10177    /// Required. The study name.
10178    ///
10179    /// Sets the *name* path property to the given value.
10180    ///
10181    /// Even though the property as already been set when instantiating this call,
10182    /// we provide this method for API completeness.
10183    pub fn name(mut self, new_value: &str) -> ProjectLocationStudyDeleteCall<'a, C> {
10184        self._name = new_value.to_string();
10185        self
10186    }
10187    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10188    /// while executing the actual API request.
10189    ///
10190    /// ````text
10191    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10192    /// ````
10193    ///
10194    /// Sets the *delegate* property to the given value.
10195    pub fn delegate(
10196        mut self,
10197        new_value: &'a mut dyn common::Delegate,
10198    ) -> ProjectLocationStudyDeleteCall<'a, C> {
10199        self._delegate = Some(new_value);
10200        self
10201    }
10202
10203    /// Set any additional parameter of the query string used in the request.
10204    /// It should be used to set parameters which are not yet available through their own
10205    /// setters.
10206    ///
10207    /// Please note that this method must not be used to set any of the known parameters
10208    /// which have their own setter method. If done anyway, the request will fail.
10209    ///
10210    /// # Additional Parameters
10211    ///
10212    /// * *$.xgafv* (query-string) - V1 error format.
10213    /// * *access_token* (query-string) - OAuth access token.
10214    /// * *alt* (query-string) - Data format for response.
10215    /// * *callback* (query-string) - JSONP
10216    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10217    /// * *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.
10218    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10219    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10220    /// * *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.
10221    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10222    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10223    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationStudyDeleteCall<'a, C>
10224    where
10225        T: AsRef<str>,
10226    {
10227        self._additional_params
10228            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10229        self
10230    }
10231
10232    /// Identifies the authorization scope for the method you are building.
10233    ///
10234    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10235    /// [`Scope::CloudPlatform`].
10236    ///
10237    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10238    /// tokens for more than one scope.
10239    ///
10240    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10241    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10242    /// sufficient, a read-write scope will do as well.
10243    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationStudyDeleteCall<'a, C>
10244    where
10245        St: AsRef<str>,
10246    {
10247        self._scopes.insert(String::from(scope.as_ref()));
10248        self
10249    }
10250    /// Identifies the authorization scope(s) for the method you are building.
10251    ///
10252    /// See [`Self::add_scope()`] for details.
10253    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationStudyDeleteCall<'a, C>
10254    where
10255        I: IntoIterator<Item = St>,
10256        St: AsRef<str>,
10257    {
10258        self._scopes
10259            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10260        self
10261    }
10262
10263    /// Removes all scopes, and no default scope will be used either.
10264    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10265    /// for details).
10266    pub fn clear_scopes(mut self) -> ProjectLocationStudyDeleteCall<'a, C> {
10267        self._scopes.clear();
10268        self
10269    }
10270}
10271
10272/// Gets a study.
10273///
10274/// A builder for the *locations.studies.get* method supported by a *project* resource.
10275/// It is not used directly, but through a [`ProjectMethods`] instance.
10276///
10277/// # Example
10278///
10279/// Instantiate a resource method builder
10280///
10281/// ```test_harness,no_run
10282/// # extern crate hyper;
10283/// # extern crate hyper_rustls;
10284/// # extern crate google_ml1 as ml1;
10285/// # async fn dox() {
10286/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10287///
10288/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10289/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10290/// #     .with_native_roots()
10291/// #     .unwrap()
10292/// #     .https_only()
10293/// #     .enable_http2()
10294/// #     .build();
10295///
10296/// # let executor = hyper_util::rt::TokioExecutor::new();
10297/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10298/// #     secret,
10299/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10300/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10301/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10302/// #     ),
10303/// # ).build().await.unwrap();
10304///
10305/// # let client = hyper_util::client::legacy::Client::builder(
10306/// #     hyper_util::rt::TokioExecutor::new()
10307/// # )
10308/// # .build(
10309/// #     hyper_rustls::HttpsConnectorBuilder::new()
10310/// #         .with_native_roots()
10311/// #         .unwrap()
10312/// #         .https_or_http()
10313/// #         .enable_http2()
10314/// #         .build()
10315/// # );
10316/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
10317/// // You can configure optional parameters by calling the respective setters at will, and
10318/// // execute the final call using `doit()`.
10319/// // Values shown here are possibly random and not representative !
10320/// let result = hub.projects().locations_studies_get("name")
10321///              .doit().await;
10322/// # }
10323/// ```
10324pub struct ProjectLocationStudyGetCall<'a, C>
10325where
10326    C: 'a,
10327{
10328    hub: &'a CloudMachineLearningEngine<C>,
10329    _name: String,
10330    _delegate: Option<&'a mut dyn common::Delegate>,
10331    _additional_params: HashMap<String, String>,
10332    _scopes: BTreeSet<String>,
10333}
10334
10335impl<'a, C> common::CallBuilder for ProjectLocationStudyGetCall<'a, C> {}
10336
10337impl<'a, C> ProjectLocationStudyGetCall<'a, C>
10338where
10339    C: common::Connector,
10340{
10341    /// Perform the operation you have build so far.
10342    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleCloudMlV1__Study)> {
10343        use std::borrow::Cow;
10344        use std::io::{Read, Seek};
10345
10346        use common::{url::Params, ToParts};
10347        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10348
10349        let mut dd = common::DefaultDelegate;
10350        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10351        dlg.begin(common::MethodInfo {
10352            id: "ml.projects.locations.studies.get",
10353            http_method: hyper::Method::GET,
10354        });
10355
10356        for &field in ["alt", "name"].iter() {
10357            if self._additional_params.contains_key(field) {
10358                dlg.finished(false);
10359                return Err(common::Error::FieldClash(field));
10360            }
10361        }
10362
10363        let mut params = Params::with_capacity(3 + self._additional_params.len());
10364        params.push("name", self._name);
10365
10366        params.extend(self._additional_params.iter());
10367
10368        params.push("alt", "json");
10369        let mut url = self.hub._base_url.clone() + "v1/{+name}";
10370        if self._scopes.is_empty() {
10371            self._scopes
10372                .insert(Scope::CloudPlatform.as_ref().to_string());
10373        }
10374
10375        #[allow(clippy::single_element_loop)]
10376        for &(find_this, param_name) in [("{+name}", "name")].iter() {
10377            url = params.uri_replacement(url, param_name, find_this, true);
10378        }
10379        {
10380            let to_remove = ["name"];
10381            params.remove_params(&to_remove);
10382        }
10383
10384        let url = params.parse_with_url(&url);
10385
10386        loop {
10387            let token = match self
10388                .hub
10389                .auth
10390                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10391                .await
10392            {
10393                Ok(token) => token,
10394                Err(e) => match dlg.token(e) {
10395                    Ok(token) => token,
10396                    Err(e) => {
10397                        dlg.finished(false);
10398                        return Err(common::Error::MissingToken(e));
10399                    }
10400                },
10401            };
10402            let mut req_result = {
10403                let client = &self.hub.client;
10404                dlg.pre_request();
10405                let mut req_builder = hyper::Request::builder()
10406                    .method(hyper::Method::GET)
10407                    .uri(url.as_str())
10408                    .header(USER_AGENT, self.hub._user_agent.clone());
10409
10410                if let Some(token) = token.as_ref() {
10411                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10412                }
10413
10414                let request = req_builder
10415                    .header(CONTENT_LENGTH, 0_u64)
10416                    .body(common::to_body::<String>(None));
10417
10418                client.request(request.unwrap()).await
10419            };
10420
10421            match req_result {
10422                Err(err) => {
10423                    if let common::Retry::After(d) = dlg.http_error(&err) {
10424                        sleep(d).await;
10425                        continue;
10426                    }
10427                    dlg.finished(false);
10428                    return Err(common::Error::HttpError(err));
10429                }
10430                Ok(res) => {
10431                    let (mut parts, body) = res.into_parts();
10432                    let mut body = common::Body::new(body);
10433                    if !parts.status.is_success() {
10434                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10435                        let error = serde_json::from_str(&common::to_string(&bytes));
10436                        let response = common::to_response(parts, bytes.into());
10437
10438                        if let common::Retry::After(d) =
10439                            dlg.http_failure(&response, error.as_ref().ok())
10440                        {
10441                            sleep(d).await;
10442                            continue;
10443                        }
10444
10445                        dlg.finished(false);
10446
10447                        return Err(match error {
10448                            Ok(value) => common::Error::BadRequest(value),
10449                            _ => common::Error::Failure(response),
10450                        });
10451                    }
10452                    let response = {
10453                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10454                        let encoded = common::to_string(&bytes);
10455                        match serde_json::from_str(&encoded) {
10456                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10457                            Err(error) => {
10458                                dlg.response_json_decode_error(&encoded, &error);
10459                                return Err(common::Error::JsonDecodeError(
10460                                    encoded.to_string(),
10461                                    error,
10462                                ));
10463                            }
10464                        }
10465                    };
10466
10467                    dlg.finished(true);
10468                    return Ok(response);
10469                }
10470            }
10471        }
10472    }
10473
10474    /// Required. The study name.
10475    ///
10476    /// Sets the *name* path property to the given value.
10477    ///
10478    /// Even though the property as already been set when instantiating this call,
10479    /// we provide this method for API completeness.
10480    pub fn name(mut self, new_value: &str) -> ProjectLocationStudyGetCall<'a, C> {
10481        self._name = new_value.to_string();
10482        self
10483    }
10484    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10485    /// while executing the actual API request.
10486    ///
10487    /// ````text
10488    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10489    /// ````
10490    ///
10491    /// Sets the *delegate* property to the given value.
10492    pub fn delegate(
10493        mut self,
10494        new_value: &'a mut dyn common::Delegate,
10495    ) -> ProjectLocationStudyGetCall<'a, C> {
10496        self._delegate = Some(new_value);
10497        self
10498    }
10499
10500    /// Set any additional parameter of the query string used in the request.
10501    /// It should be used to set parameters which are not yet available through their own
10502    /// setters.
10503    ///
10504    /// Please note that this method must not be used to set any of the known parameters
10505    /// which have their own setter method. If done anyway, the request will fail.
10506    ///
10507    /// # Additional Parameters
10508    ///
10509    /// * *$.xgafv* (query-string) - V1 error format.
10510    /// * *access_token* (query-string) - OAuth access token.
10511    /// * *alt* (query-string) - Data format for response.
10512    /// * *callback* (query-string) - JSONP
10513    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10514    /// * *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.
10515    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10516    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10517    /// * *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.
10518    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10519    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10520    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationStudyGetCall<'a, C>
10521    where
10522        T: AsRef<str>,
10523    {
10524        self._additional_params
10525            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10526        self
10527    }
10528
10529    /// Identifies the authorization scope for the method you are building.
10530    ///
10531    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10532    /// [`Scope::CloudPlatform`].
10533    ///
10534    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10535    /// tokens for more than one scope.
10536    ///
10537    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10538    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10539    /// sufficient, a read-write scope will do as well.
10540    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationStudyGetCall<'a, C>
10541    where
10542        St: AsRef<str>,
10543    {
10544        self._scopes.insert(String::from(scope.as_ref()));
10545        self
10546    }
10547    /// Identifies the authorization scope(s) for the method you are building.
10548    ///
10549    /// See [`Self::add_scope()`] for details.
10550    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationStudyGetCall<'a, C>
10551    where
10552        I: IntoIterator<Item = St>,
10553        St: AsRef<str>,
10554    {
10555        self._scopes
10556            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10557        self
10558    }
10559
10560    /// Removes all scopes, and no default scope will be used either.
10561    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10562    /// for details).
10563    pub fn clear_scopes(mut self) -> ProjectLocationStudyGetCall<'a, C> {
10564        self._scopes.clear();
10565        self
10566    }
10567}
10568
10569/// Lists all the studies in a region for an associated project.
10570///
10571/// A builder for the *locations.studies.list* method supported by a *project* resource.
10572/// It is not used directly, but through a [`ProjectMethods`] instance.
10573///
10574/// # Example
10575///
10576/// Instantiate a resource method builder
10577///
10578/// ```test_harness,no_run
10579/// # extern crate hyper;
10580/// # extern crate hyper_rustls;
10581/// # extern crate google_ml1 as ml1;
10582/// # async fn dox() {
10583/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10584///
10585/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10586/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10587/// #     .with_native_roots()
10588/// #     .unwrap()
10589/// #     .https_only()
10590/// #     .enable_http2()
10591/// #     .build();
10592///
10593/// # let executor = hyper_util::rt::TokioExecutor::new();
10594/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10595/// #     secret,
10596/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10597/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10598/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10599/// #     ),
10600/// # ).build().await.unwrap();
10601///
10602/// # let client = hyper_util::client::legacy::Client::builder(
10603/// #     hyper_util::rt::TokioExecutor::new()
10604/// # )
10605/// # .build(
10606/// #     hyper_rustls::HttpsConnectorBuilder::new()
10607/// #         .with_native_roots()
10608/// #         .unwrap()
10609/// #         .https_or_http()
10610/// #         .enable_http2()
10611/// #         .build()
10612/// # );
10613/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
10614/// // You can configure optional parameters by calling the respective setters at will, and
10615/// // execute the final call using `doit()`.
10616/// // Values shown here are possibly random and not representative !
10617/// let result = hub.projects().locations_studies_list("parent")
10618///              .doit().await;
10619/// # }
10620/// ```
10621pub struct ProjectLocationStudyListCall<'a, C>
10622where
10623    C: 'a,
10624{
10625    hub: &'a CloudMachineLearningEngine<C>,
10626    _parent: String,
10627    _delegate: Option<&'a mut dyn common::Delegate>,
10628    _additional_params: HashMap<String, String>,
10629    _scopes: BTreeSet<String>,
10630}
10631
10632impl<'a, C> common::CallBuilder for ProjectLocationStudyListCall<'a, C> {}
10633
10634impl<'a, C> ProjectLocationStudyListCall<'a, C>
10635where
10636    C: common::Connector,
10637{
10638    /// Perform the operation you have build so far.
10639    pub async fn doit(
10640        mut self,
10641    ) -> common::Result<(common::Response, GoogleCloudMlV1__ListStudiesResponse)> {
10642        use std::borrow::Cow;
10643        use std::io::{Read, Seek};
10644
10645        use common::{url::Params, ToParts};
10646        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10647
10648        let mut dd = common::DefaultDelegate;
10649        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10650        dlg.begin(common::MethodInfo {
10651            id: "ml.projects.locations.studies.list",
10652            http_method: hyper::Method::GET,
10653        });
10654
10655        for &field in ["alt", "parent"].iter() {
10656            if self._additional_params.contains_key(field) {
10657                dlg.finished(false);
10658                return Err(common::Error::FieldClash(field));
10659            }
10660        }
10661
10662        let mut params = Params::with_capacity(3 + self._additional_params.len());
10663        params.push("parent", self._parent);
10664
10665        params.extend(self._additional_params.iter());
10666
10667        params.push("alt", "json");
10668        let mut url = self.hub._base_url.clone() + "v1/{+parent}/studies";
10669        if self._scopes.is_empty() {
10670            self._scopes
10671                .insert(Scope::CloudPlatform.as_ref().to_string());
10672        }
10673
10674        #[allow(clippy::single_element_loop)]
10675        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
10676            url = params.uri_replacement(url, param_name, find_this, true);
10677        }
10678        {
10679            let to_remove = ["parent"];
10680            params.remove_params(&to_remove);
10681        }
10682
10683        let url = params.parse_with_url(&url);
10684
10685        loop {
10686            let token = match self
10687                .hub
10688                .auth
10689                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10690                .await
10691            {
10692                Ok(token) => token,
10693                Err(e) => match dlg.token(e) {
10694                    Ok(token) => token,
10695                    Err(e) => {
10696                        dlg.finished(false);
10697                        return Err(common::Error::MissingToken(e));
10698                    }
10699                },
10700            };
10701            let mut req_result = {
10702                let client = &self.hub.client;
10703                dlg.pre_request();
10704                let mut req_builder = hyper::Request::builder()
10705                    .method(hyper::Method::GET)
10706                    .uri(url.as_str())
10707                    .header(USER_AGENT, self.hub._user_agent.clone());
10708
10709                if let Some(token) = token.as_ref() {
10710                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10711                }
10712
10713                let request = req_builder
10714                    .header(CONTENT_LENGTH, 0_u64)
10715                    .body(common::to_body::<String>(None));
10716
10717                client.request(request.unwrap()).await
10718            };
10719
10720            match req_result {
10721                Err(err) => {
10722                    if let common::Retry::After(d) = dlg.http_error(&err) {
10723                        sleep(d).await;
10724                        continue;
10725                    }
10726                    dlg.finished(false);
10727                    return Err(common::Error::HttpError(err));
10728                }
10729                Ok(res) => {
10730                    let (mut parts, body) = res.into_parts();
10731                    let mut body = common::Body::new(body);
10732                    if !parts.status.is_success() {
10733                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10734                        let error = serde_json::from_str(&common::to_string(&bytes));
10735                        let response = common::to_response(parts, bytes.into());
10736
10737                        if let common::Retry::After(d) =
10738                            dlg.http_failure(&response, error.as_ref().ok())
10739                        {
10740                            sleep(d).await;
10741                            continue;
10742                        }
10743
10744                        dlg.finished(false);
10745
10746                        return Err(match error {
10747                            Ok(value) => common::Error::BadRequest(value),
10748                            _ => common::Error::Failure(response),
10749                        });
10750                    }
10751                    let response = {
10752                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10753                        let encoded = common::to_string(&bytes);
10754                        match serde_json::from_str(&encoded) {
10755                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10756                            Err(error) => {
10757                                dlg.response_json_decode_error(&encoded, &error);
10758                                return Err(common::Error::JsonDecodeError(
10759                                    encoded.to_string(),
10760                                    error,
10761                                ));
10762                            }
10763                        }
10764                    };
10765
10766                    dlg.finished(true);
10767                    return Ok(response);
10768                }
10769            }
10770        }
10771    }
10772
10773    /// Required. The project and location that the study belongs to. Format: projects/{project}/locations/{location}
10774    ///
10775    /// Sets the *parent* path property to the given value.
10776    ///
10777    /// Even though the property as already been set when instantiating this call,
10778    /// we provide this method for API completeness.
10779    pub fn parent(mut self, new_value: &str) -> ProjectLocationStudyListCall<'a, C> {
10780        self._parent = new_value.to_string();
10781        self
10782    }
10783    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10784    /// while executing the actual API request.
10785    ///
10786    /// ````text
10787    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10788    /// ````
10789    ///
10790    /// Sets the *delegate* property to the given value.
10791    pub fn delegate(
10792        mut self,
10793        new_value: &'a mut dyn common::Delegate,
10794    ) -> ProjectLocationStudyListCall<'a, C> {
10795        self._delegate = Some(new_value);
10796        self
10797    }
10798
10799    /// Set any additional parameter of the query string used in the request.
10800    /// It should be used to set parameters which are not yet available through their own
10801    /// setters.
10802    ///
10803    /// Please note that this method must not be used to set any of the known parameters
10804    /// which have their own setter method. If done anyway, the request will fail.
10805    ///
10806    /// # Additional Parameters
10807    ///
10808    /// * *$.xgafv* (query-string) - V1 error format.
10809    /// * *access_token* (query-string) - OAuth access token.
10810    /// * *alt* (query-string) - Data format for response.
10811    /// * *callback* (query-string) - JSONP
10812    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10813    /// * *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.
10814    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10815    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10816    /// * *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.
10817    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10818    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10819    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationStudyListCall<'a, C>
10820    where
10821        T: AsRef<str>,
10822    {
10823        self._additional_params
10824            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10825        self
10826    }
10827
10828    /// Identifies the authorization scope for the method you are building.
10829    ///
10830    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10831    /// [`Scope::CloudPlatform`].
10832    ///
10833    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10834    /// tokens for more than one scope.
10835    ///
10836    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10837    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10838    /// sufficient, a read-write scope will do as well.
10839    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationStudyListCall<'a, C>
10840    where
10841        St: AsRef<str>,
10842    {
10843        self._scopes.insert(String::from(scope.as_ref()));
10844        self
10845    }
10846    /// Identifies the authorization scope(s) for the method you are building.
10847    ///
10848    /// See [`Self::add_scope()`] for details.
10849    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationStudyListCall<'a, C>
10850    where
10851        I: IntoIterator<Item = St>,
10852        St: AsRef<str>,
10853    {
10854        self._scopes
10855            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10856        self
10857    }
10858
10859    /// Removes all scopes, and no default scope will be used either.
10860    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10861    /// for details).
10862    pub fn clear_scopes(mut self) -> ProjectLocationStudyListCall<'a, C> {
10863        self._scopes.clear();
10864        self
10865    }
10866}
10867
10868/// Get the complete list of CMLE capabilities in a location, along with their location-specific properties.
10869///
10870/// A builder for the *locations.get* method supported by a *project* resource.
10871/// It is not used directly, but through a [`ProjectMethods`] instance.
10872///
10873/// # Example
10874///
10875/// Instantiate a resource method builder
10876///
10877/// ```test_harness,no_run
10878/// # extern crate hyper;
10879/// # extern crate hyper_rustls;
10880/// # extern crate google_ml1 as ml1;
10881/// # async fn dox() {
10882/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10883///
10884/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10885/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10886/// #     .with_native_roots()
10887/// #     .unwrap()
10888/// #     .https_only()
10889/// #     .enable_http2()
10890/// #     .build();
10891///
10892/// # let executor = hyper_util::rt::TokioExecutor::new();
10893/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10894/// #     secret,
10895/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10896/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10897/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10898/// #     ),
10899/// # ).build().await.unwrap();
10900///
10901/// # let client = hyper_util::client::legacy::Client::builder(
10902/// #     hyper_util::rt::TokioExecutor::new()
10903/// # )
10904/// # .build(
10905/// #     hyper_rustls::HttpsConnectorBuilder::new()
10906/// #         .with_native_roots()
10907/// #         .unwrap()
10908/// #         .https_or_http()
10909/// #         .enable_http2()
10910/// #         .build()
10911/// # );
10912/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
10913/// // You can configure optional parameters by calling the respective setters at will, and
10914/// // execute the final call using `doit()`.
10915/// // Values shown here are possibly random and not representative !
10916/// let result = hub.projects().locations_get("name")
10917///              .doit().await;
10918/// # }
10919/// ```
10920pub struct ProjectLocationGetCall<'a, C>
10921where
10922    C: 'a,
10923{
10924    hub: &'a CloudMachineLearningEngine<C>,
10925    _name: String,
10926    _delegate: Option<&'a mut dyn common::Delegate>,
10927    _additional_params: HashMap<String, String>,
10928    _scopes: BTreeSet<String>,
10929}
10930
10931impl<'a, C> common::CallBuilder for ProjectLocationGetCall<'a, C> {}
10932
10933impl<'a, C> ProjectLocationGetCall<'a, C>
10934where
10935    C: common::Connector,
10936{
10937    /// Perform the operation you have build so far.
10938    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleCloudMlV1__Location)> {
10939        use std::borrow::Cow;
10940        use std::io::{Read, Seek};
10941
10942        use common::{url::Params, ToParts};
10943        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10944
10945        let mut dd = common::DefaultDelegate;
10946        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10947        dlg.begin(common::MethodInfo {
10948            id: "ml.projects.locations.get",
10949            http_method: hyper::Method::GET,
10950        });
10951
10952        for &field in ["alt", "name"].iter() {
10953            if self._additional_params.contains_key(field) {
10954                dlg.finished(false);
10955                return Err(common::Error::FieldClash(field));
10956            }
10957        }
10958
10959        let mut params = Params::with_capacity(3 + self._additional_params.len());
10960        params.push("name", self._name);
10961
10962        params.extend(self._additional_params.iter());
10963
10964        params.push("alt", "json");
10965        let mut url = self.hub._base_url.clone() + "v1/{+name}";
10966        if self._scopes.is_empty() {
10967            self._scopes
10968                .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
10969        }
10970
10971        #[allow(clippy::single_element_loop)]
10972        for &(find_this, param_name) in [("{+name}", "name")].iter() {
10973            url = params.uri_replacement(url, param_name, find_this, true);
10974        }
10975        {
10976            let to_remove = ["name"];
10977            params.remove_params(&to_remove);
10978        }
10979
10980        let url = params.parse_with_url(&url);
10981
10982        loop {
10983            let token = match self
10984                .hub
10985                .auth
10986                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10987                .await
10988            {
10989                Ok(token) => token,
10990                Err(e) => match dlg.token(e) {
10991                    Ok(token) => token,
10992                    Err(e) => {
10993                        dlg.finished(false);
10994                        return Err(common::Error::MissingToken(e));
10995                    }
10996                },
10997            };
10998            let mut req_result = {
10999                let client = &self.hub.client;
11000                dlg.pre_request();
11001                let mut req_builder = hyper::Request::builder()
11002                    .method(hyper::Method::GET)
11003                    .uri(url.as_str())
11004                    .header(USER_AGENT, self.hub._user_agent.clone());
11005
11006                if let Some(token) = token.as_ref() {
11007                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11008                }
11009
11010                let request = req_builder
11011                    .header(CONTENT_LENGTH, 0_u64)
11012                    .body(common::to_body::<String>(None));
11013
11014                client.request(request.unwrap()).await
11015            };
11016
11017            match req_result {
11018                Err(err) => {
11019                    if let common::Retry::After(d) = dlg.http_error(&err) {
11020                        sleep(d).await;
11021                        continue;
11022                    }
11023                    dlg.finished(false);
11024                    return Err(common::Error::HttpError(err));
11025                }
11026                Ok(res) => {
11027                    let (mut parts, body) = res.into_parts();
11028                    let mut body = common::Body::new(body);
11029                    if !parts.status.is_success() {
11030                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11031                        let error = serde_json::from_str(&common::to_string(&bytes));
11032                        let response = common::to_response(parts, bytes.into());
11033
11034                        if let common::Retry::After(d) =
11035                            dlg.http_failure(&response, error.as_ref().ok())
11036                        {
11037                            sleep(d).await;
11038                            continue;
11039                        }
11040
11041                        dlg.finished(false);
11042
11043                        return Err(match error {
11044                            Ok(value) => common::Error::BadRequest(value),
11045                            _ => common::Error::Failure(response),
11046                        });
11047                    }
11048                    let response = {
11049                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11050                        let encoded = common::to_string(&bytes);
11051                        match serde_json::from_str(&encoded) {
11052                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11053                            Err(error) => {
11054                                dlg.response_json_decode_error(&encoded, &error);
11055                                return Err(common::Error::JsonDecodeError(
11056                                    encoded.to_string(),
11057                                    error,
11058                                ));
11059                            }
11060                        }
11061                    };
11062
11063                    dlg.finished(true);
11064                    return Ok(response);
11065                }
11066            }
11067        }
11068    }
11069
11070    /// Required. The name of the location.
11071    ///
11072    /// Sets the *name* path property to the given value.
11073    ///
11074    /// Even though the property as already been set when instantiating this call,
11075    /// we provide this method for API completeness.
11076    pub fn name(mut self, new_value: &str) -> ProjectLocationGetCall<'a, C> {
11077        self._name = new_value.to_string();
11078        self
11079    }
11080    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11081    /// while executing the actual API request.
11082    ///
11083    /// ````text
11084    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11085    /// ````
11086    ///
11087    /// Sets the *delegate* property to the given value.
11088    pub fn delegate(
11089        mut self,
11090        new_value: &'a mut dyn common::Delegate,
11091    ) -> ProjectLocationGetCall<'a, C> {
11092        self._delegate = Some(new_value);
11093        self
11094    }
11095
11096    /// Set any additional parameter of the query string used in the request.
11097    /// It should be used to set parameters which are not yet available through their own
11098    /// setters.
11099    ///
11100    /// Please note that this method must not be used to set any of the known parameters
11101    /// which have their own setter method. If done anyway, the request will fail.
11102    ///
11103    /// # Additional Parameters
11104    ///
11105    /// * *$.xgafv* (query-string) - V1 error format.
11106    /// * *access_token* (query-string) - OAuth access token.
11107    /// * *alt* (query-string) - Data format for response.
11108    /// * *callback* (query-string) - JSONP
11109    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11110    /// * *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.
11111    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11112    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11113    /// * *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.
11114    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11115    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11116    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCall<'a, C>
11117    where
11118        T: AsRef<str>,
11119    {
11120        self._additional_params
11121            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11122        self
11123    }
11124
11125    /// Identifies the authorization scope for the method you are building.
11126    ///
11127    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11128    /// [`Scope::CloudPlatformReadOnly`].
11129    ///
11130    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11131    /// tokens for more than one scope.
11132    ///
11133    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11134    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11135    /// sufficient, a read-write scope will do as well.
11136    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCall<'a, C>
11137    where
11138        St: AsRef<str>,
11139    {
11140        self._scopes.insert(String::from(scope.as_ref()));
11141        self
11142    }
11143    /// Identifies the authorization scope(s) for the method you are building.
11144    ///
11145    /// See [`Self::add_scope()`] for details.
11146    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCall<'a, C>
11147    where
11148        I: IntoIterator<Item = St>,
11149        St: AsRef<str>,
11150    {
11151        self._scopes
11152            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11153        self
11154    }
11155
11156    /// Removes all scopes, and no default scope will be used either.
11157    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11158    /// for details).
11159    pub fn clear_scopes(mut self) -> ProjectLocationGetCall<'a, C> {
11160        self._scopes.clear();
11161        self
11162    }
11163}
11164
11165/// List all locations that provides at least one type of CMLE capability.
11166///
11167/// A builder for the *locations.list* method supported by a *project* resource.
11168/// It is not used directly, but through a [`ProjectMethods`] instance.
11169///
11170/// # Example
11171///
11172/// Instantiate a resource method builder
11173///
11174/// ```test_harness,no_run
11175/// # extern crate hyper;
11176/// # extern crate hyper_rustls;
11177/// # extern crate google_ml1 as ml1;
11178/// # async fn dox() {
11179/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11180///
11181/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11182/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11183/// #     .with_native_roots()
11184/// #     .unwrap()
11185/// #     .https_only()
11186/// #     .enable_http2()
11187/// #     .build();
11188///
11189/// # let executor = hyper_util::rt::TokioExecutor::new();
11190/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11191/// #     secret,
11192/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11193/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11194/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11195/// #     ),
11196/// # ).build().await.unwrap();
11197///
11198/// # let client = hyper_util::client::legacy::Client::builder(
11199/// #     hyper_util::rt::TokioExecutor::new()
11200/// # )
11201/// # .build(
11202/// #     hyper_rustls::HttpsConnectorBuilder::new()
11203/// #         .with_native_roots()
11204/// #         .unwrap()
11205/// #         .https_or_http()
11206/// #         .enable_http2()
11207/// #         .build()
11208/// # );
11209/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
11210/// // You can configure optional parameters by calling the respective setters at will, and
11211/// // execute the final call using `doit()`.
11212/// // Values shown here are possibly random and not representative !
11213/// let result = hub.projects().locations_list("parent")
11214///              .page_token("dolor")
11215///              .page_size(-56)
11216///              .doit().await;
11217/// # }
11218/// ```
11219pub struct ProjectLocationListCall<'a, C>
11220where
11221    C: 'a,
11222{
11223    hub: &'a CloudMachineLearningEngine<C>,
11224    _parent: String,
11225    _page_token: Option<String>,
11226    _page_size: Option<i32>,
11227    _delegate: Option<&'a mut dyn common::Delegate>,
11228    _additional_params: HashMap<String, String>,
11229    _scopes: BTreeSet<String>,
11230}
11231
11232impl<'a, C> common::CallBuilder for ProjectLocationListCall<'a, C> {}
11233
11234impl<'a, C> ProjectLocationListCall<'a, C>
11235where
11236    C: common::Connector,
11237{
11238    /// Perform the operation you have build so far.
11239    pub async fn doit(
11240        mut self,
11241    ) -> common::Result<(common::Response, GoogleCloudMlV1__ListLocationsResponse)> {
11242        use std::borrow::Cow;
11243        use std::io::{Read, Seek};
11244
11245        use common::{url::Params, ToParts};
11246        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11247
11248        let mut dd = common::DefaultDelegate;
11249        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11250        dlg.begin(common::MethodInfo {
11251            id: "ml.projects.locations.list",
11252            http_method: hyper::Method::GET,
11253        });
11254
11255        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
11256            if self._additional_params.contains_key(field) {
11257                dlg.finished(false);
11258                return Err(common::Error::FieldClash(field));
11259            }
11260        }
11261
11262        let mut params = Params::with_capacity(5 + self._additional_params.len());
11263        params.push("parent", self._parent);
11264        if let Some(value) = self._page_token.as_ref() {
11265            params.push("pageToken", value);
11266        }
11267        if let Some(value) = self._page_size.as_ref() {
11268            params.push("pageSize", value.to_string());
11269        }
11270
11271        params.extend(self._additional_params.iter());
11272
11273        params.push("alt", "json");
11274        let mut url = self.hub._base_url.clone() + "v1/{+parent}/locations";
11275        if self._scopes.is_empty() {
11276            self._scopes
11277                .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
11278        }
11279
11280        #[allow(clippy::single_element_loop)]
11281        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
11282            url = params.uri_replacement(url, param_name, find_this, true);
11283        }
11284        {
11285            let to_remove = ["parent"];
11286            params.remove_params(&to_remove);
11287        }
11288
11289        let url = params.parse_with_url(&url);
11290
11291        loop {
11292            let token = match self
11293                .hub
11294                .auth
11295                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11296                .await
11297            {
11298                Ok(token) => token,
11299                Err(e) => match dlg.token(e) {
11300                    Ok(token) => token,
11301                    Err(e) => {
11302                        dlg.finished(false);
11303                        return Err(common::Error::MissingToken(e));
11304                    }
11305                },
11306            };
11307            let mut req_result = {
11308                let client = &self.hub.client;
11309                dlg.pre_request();
11310                let mut req_builder = hyper::Request::builder()
11311                    .method(hyper::Method::GET)
11312                    .uri(url.as_str())
11313                    .header(USER_AGENT, self.hub._user_agent.clone());
11314
11315                if let Some(token) = token.as_ref() {
11316                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11317                }
11318
11319                let request = req_builder
11320                    .header(CONTENT_LENGTH, 0_u64)
11321                    .body(common::to_body::<String>(None));
11322
11323                client.request(request.unwrap()).await
11324            };
11325
11326            match req_result {
11327                Err(err) => {
11328                    if let common::Retry::After(d) = dlg.http_error(&err) {
11329                        sleep(d).await;
11330                        continue;
11331                    }
11332                    dlg.finished(false);
11333                    return Err(common::Error::HttpError(err));
11334                }
11335                Ok(res) => {
11336                    let (mut parts, body) = res.into_parts();
11337                    let mut body = common::Body::new(body);
11338                    if !parts.status.is_success() {
11339                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11340                        let error = serde_json::from_str(&common::to_string(&bytes));
11341                        let response = common::to_response(parts, bytes.into());
11342
11343                        if let common::Retry::After(d) =
11344                            dlg.http_failure(&response, error.as_ref().ok())
11345                        {
11346                            sleep(d).await;
11347                            continue;
11348                        }
11349
11350                        dlg.finished(false);
11351
11352                        return Err(match error {
11353                            Ok(value) => common::Error::BadRequest(value),
11354                            _ => common::Error::Failure(response),
11355                        });
11356                    }
11357                    let response = {
11358                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11359                        let encoded = common::to_string(&bytes);
11360                        match serde_json::from_str(&encoded) {
11361                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11362                            Err(error) => {
11363                                dlg.response_json_decode_error(&encoded, &error);
11364                                return Err(common::Error::JsonDecodeError(
11365                                    encoded.to_string(),
11366                                    error,
11367                                ));
11368                            }
11369                        }
11370                    };
11371
11372                    dlg.finished(true);
11373                    return Ok(response);
11374                }
11375            }
11376        }
11377    }
11378
11379    /// Required. The name of the project for which available locations are to be listed (since some locations might be whitelisted for specific projects).
11380    ///
11381    /// Sets the *parent* path property to the given value.
11382    ///
11383    /// Even though the property as already been set when instantiating this call,
11384    /// we provide this method for API completeness.
11385    pub fn parent(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
11386        self._parent = new_value.to_string();
11387        self
11388    }
11389    /// Optional. A page token to request the next page of results. You get the token from the `next_page_token` field of the response from the previous call.
11390    ///
11391    /// Sets the *page token* query property to the given value.
11392    pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
11393        self._page_token = Some(new_value.to_string());
11394        self
11395    }
11396    /// Optional. The number of locations to retrieve per "page" of results. If there are more remaining results than this number, the response message will contain a valid value in the `next_page_token` field. The default value is 20, and the maximum page size is 100.
11397    ///
11398    /// Sets the *page size* query property to the given value.
11399    pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C> {
11400        self._page_size = Some(new_value);
11401        self
11402    }
11403    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11404    /// while executing the actual API request.
11405    ///
11406    /// ````text
11407    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11408    /// ````
11409    ///
11410    /// Sets the *delegate* property to the given value.
11411    pub fn delegate(
11412        mut self,
11413        new_value: &'a mut dyn common::Delegate,
11414    ) -> ProjectLocationListCall<'a, C> {
11415        self._delegate = Some(new_value);
11416        self
11417    }
11418
11419    /// Set any additional parameter of the query string used in the request.
11420    /// It should be used to set parameters which are not yet available through their own
11421    /// setters.
11422    ///
11423    /// Please note that this method must not be used to set any of the known parameters
11424    /// which have their own setter method. If done anyway, the request will fail.
11425    ///
11426    /// # Additional Parameters
11427    ///
11428    /// * *$.xgafv* (query-string) - V1 error format.
11429    /// * *access_token* (query-string) - OAuth access token.
11430    /// * *alt* (query-string) - Data format for response.
11431    /// * *callback* (query-string) - JSONP
11432    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11433    /// * *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.
11434    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11435    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11436    /// * *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.
11437    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11438    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11439    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C>
11440    where
11441        T: AsRef<str>,
11442    {
11443        self._additional_params
11444            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11445        self
11446    }
11447
11448    /// Identifies the authorization scope for the method you are building.
11449    ///
11450    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11451    /// [`Scope::CloudPlatformReadOnly`].
11452    ///
11453    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11454    /// tokens for more than one scope.
11455    ///
11456    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11457    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11458    /// sufficient, a read-write scope will do as well.
11459    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationListCall<'a, C>
11460    where
11461        St: AsRef<str>,
11462    {
11463        self._scopes.insert(String::from(scope.as_ref()));
11464        self
11465    }
11466    /// Identifies the authorization scope(s) for the method you are building.
11467    ///
11468    /// See [`Self::add_scope()`] for details.
11469    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationListCall<'a, C>
11470    where
11471        I: IntoIterator<Item = St>,
11472        St: AsRef<str>,
11473    {
11474        self._scopes
11475            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11476        self
11477    }
11478
11479    /// Removes all scopes, and no default scope will be used either.
11480    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11481    /// for details).
11482    pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, C> {
11483        self._scopes.clear();
11484        self
11485    }
11486}
11487
11488/// Creates a new version of a model from a trained TensorFlow model. If the version created in the cloud by this call is the first deployed version of the specified model, it will be made the default version of the model. When you add a version to a model that already has one or more versions, the default version does not automatically change. If you want a new version to be the default, you must call projects.models.versions.setDefault.
11489///
11490/// A builder for the *models.versions.create* method supported by a *project* resource.
11491/// It is not used directly, but through a [`ProjectMethods`] instance.
11492///
11493/// # Example
11494///
11495/// Instantiate a resource method builder
11496///
11497/// ```test_harness,no_run
11498/// # extern crate hyper;
11499/// # extern crate hyper_rustls;
11500/// # extern crate google_ml1 as ml1;
11501/// use ml1::api::GoogleCloudMlV1__Version;
11502/// # async fn dox() {
11503/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11504///
11505/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11506/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11507/// #     .with_native_roots()
11508/// #     .unwrap()
11509/// #     .https_only()
11510/// #     .enable_http2()
11511/// #     .build();
11512///
11513/// # let executor = hyper_util::rt::TokioExecutor::new();
11514/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11515/// #     secret,
11516/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11517/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11518/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11519/// #     ),
11520/// # ).build().await.unwrap();
11521///
11522/// # let client = hyper_util::client::legacy::Client::builder(
11523/// #     hyper_util::rt::TokioExecutor::new()
11524/// # )
11525/// # .build(
11526/// #     hyper_rustls::HttpsConnectorBuilder::new()
11527/// #         .with_native_roots()
11528/// #         .unwrap()
11529/// #         .https_or_http()
11530/// #         .enable_http2()
11531/// #         .build()
11532/// # );
11533/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
11534/// // As the method needs a request, you would usually fill it with the desired information
11535/// // into the respective structure. Some of the parts shown here might not be applicable !
11536/// // Values shown here are possibly random and not representative !
11537/// let mut req = GoogleCloudMlV1__Version::default();
11538///
11539/// // You can configure optional parameters by calling the respective setters at will, and
11540/// // execute the final call using `doit()`.
11541/// // Values shown here are possibly random and not representative !
11542/// let result = hub.projects().models_versions_create(req, "parent")
11543///              .doit().await;
11544/// # }
11545/// ```
11546pub struct ProjectModelVersionCreateCall<'a, C>
11547where
11548    C: 'a,
11549{
11550    hub: &'a CloudMachineLearningEngine<C>,
11551    _request: GoogleCloudMlV1__Version,
11552    _parent: String,
11553    _delegate: Option<&'a mut dyn common::Delegate>,
11554    _additional_params: HashMap<String, String>,
11555    _scopes: BTreeSet<String>,
11556}
11557
11558impl<'a, C> common::CallBuilder for ProjectModelVersionCreateCall<'a, C> {}
11559
11560impl<'a, C> ProjectModelVersionCreateCall<'a, C>
11561where
11562    C: common::Connector,
11563{
11564    /// Perform the operation you have build so far.
11565    pub async fn doit(
11566        mut self,
11567    ) -> common::Result<(common::Response, GoogleLongrunning__Operation)> {
11568        use std::borrow::Cow;
11569        use std::io::{Read, Seek};
11570
11571        use common::{url::Params, ToParts};
11572        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11573
11574        let mut dd = common::DefaultDelegate;
11575        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11576        dlg.begin(common::MethodInfo {
11577            id: "ml.projects.models.versions.create",
11578            http_method: hyper::Method::POST,
11579        });
11580
11581        for &field in ["alt", "parent"].iter() {
11582            if self._additional_params.contains_key(field) {
11583                dlg.finished(false);
11584                return Err(common::Error::FieldClash(field));
11585            }
11586        }
11587
11588        let mut params = Params::with_capacity(4 + self._additional_params.len());
11589        params.push("parent", self._parent);
11590
11591        params.extend(self._additional_params.iter());
11592
11593        params.push("alt", "json");
11594        let mut url = self.hub._base_url.clone() + "v1/{+parent}/versions";
11595        if self._scopes.is_empty() {
11596            self._scopes
11597                .insert(Scope::CloudPlatform.as_ref().to_string());
11598        }
11599
11600        #[allow(clippy::single_element_loop)]
11601        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
11602            url = params.uri_replacement(url, param_name, find_this, true);
11603        }
11604        {
11605            let to_remove = ["parent"];
11606            params.remove_params(&to_remove);
11607        }
11608
11609        let url = params.parse_with_url(&url);
11610
11611        let mut json_mime_type = mime::APPLICATION_JSON;
11612        let mut request_value_reader = {
11613            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11614            common::remove_json_null_values(&mut value);
11615            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11616            serde_json::to_writer(&mut dst, &value).unwrap();
11617            dst
11618        };
11619        let request_size = request_value_reader
11620            .seek(std::io::SeekFrom::End(0))
11621            .unwrap();
11622        request_value_reader
11623            .seek(std::io::SeekFrom::Start(0))
11624            .unwrap();
11625
11626        loop {
11627            let token = match self
11628                .hub
11629                .auth
11630                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11631                .await
11632            {
11633                Ok(token) => token,
11634                Err(e) => match dlg.token(e) {
11635                    Ok(token) => token,
11636                    Err(e) => {
11637                        dlg.finished(false);
11638                        return Err(common::Error::MissingToken(e));
11639                    }
11640                },
11641            };
11642            request_value_reader
11643                .seek(std::io::SeekFrom::Start(0))
11644                .unwrap();
11645            let mut req_result = {
11646                let client = &self.hub.client;
11647                dlg.pre_request();
11648                let mut req_builder = hyper::Request::builder()
11649                    .method(hyper::Method::POST)
11650                    .uri(url.as_str())
11651                    .header(USER_AGENT, self.hub._user_agent.clone());
11652
11653                if let Some(token) = token.as_ref() {
11654                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11655                }
11656
11657                let request = req_builder
11658                    .header(CONTENT_TYPE, json_mime_type.to_string())
11659                    .header(CONTENT_LENGTH, request_size as u64)
11660                    .body(common::to_body(
11661                        request_value_reader.get_ref().clone().into(),
11662                    ));
11663
11664                client.request(request.unwrap()).await
11665            };
11666
11667            match req_result {
11668                Err(err) => {
11669                    if let common::Retry::After(d) = dlg.http_error(&err) {
11670                        sleep(d).await;
11671                        continue;
11672                    }
11673                    dlg.finished(false);
11674                    return Err(common::Error::HttpError(err));
11675                }
11676                Ok(res) => {
11677                    let (mut parts, body) = res.into_parts();
11678                    let mut body = common::Body::new(body);
11679                    if !parts.status.is_success() {
11680                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11681                        let error = serde_json::from_str(&common::to_string(&bytes));
11682                        let response = common::to_response(parts, bytes.into());
11683
11684                        if let common::Retry::After(d) =
11685                            dlg.http_failure(&response, error.as_ref().ok())
11686                        {
11687                            sleep(d).await;
11688                            continue;
11689                        }
11690
11691                        dlg.finished(false);
11692
11693                        return Err(match error {
11694                            Ok(value) => common::Error::BadRequest(value),
11695                            _ => common::Error::Failure(response),
11696                        });
11697                    }
11698                    let response = {
11699                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11700                        let encoded = common::to_string(&bytes);
11701                        match serde_json::from_str(&encoded) {
11702                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11703                            Err(error) => {
11704                                dlg.response_json_decode_error(&encoded, &error);
11705                                return Err(common::Error::JsonDecodeError(
11706                                    encoded.to_string(),
11707                                    error,
11708                                ));
11709                            }
11710                        }
11711                    };
11712
11713                    dlg.finished(true);
11714                    return Ok(response);
11715                }
11716            }
11717        }
11718    }
11719
11720    ///
11721    /// Sets the *request* property to the given value.
11722    ///
11723    /// Even though the property as already been set when instantiating this call,
11724    /// we provide this method for API completeness.
11725    pub fn request(
11726        mut self,
11727        new_value: GoogleCloudMlV1__Version,
11728    ) -> ProjectModelVersionCreateCall<'a, C> {
11729        self._request = new_value;
11730        self
11731    }
11732    /// Required. The name of the model.
11733    ///
11734    /// Sets the *parent* path property to the given value.
11735    ///
11736    /// Even though the property as already been set when instantiating this call,
11737    /// we provide this method for API completeness.
11738    pub fn parent(mut self, new_value: &str) -> ProjectModelVersionCreateCall<'a, C> {
11739        self._parent = new_value.to_string();
11740        self
11741    }
11742    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11743    /// while executing the actual API request.
11744    ///
11745    /// ````text
11746    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11747    /// ````
11748    ///
11749    /// Sets the *delegate* property to the given value.
11750    pub fn delegate(
11751        mut self,
11752        new_value: &'a mut dyn common::Delegate,
11753    ) -> ProjectModelVersionCreateCall<'a, C> {
11754        self._delegate = Some(new_value);
11755        self
11756    }
11757
11758    /// Set any additional parameter of the query string used in the request.
11759    /// It should be used to set parameters which are not yet available through their own
11760    /// setters.
11761    ///
11762    /// Please note that this method must not be used to set any of the known parameters
11763    /// which have their own setter method. If done anyway, the request will fail.
11764    ///
11765    /// # Additional Parameters
11766    ///
11767    /// * *$.xgafv* (query-string) - V1 error format.
11768    /// * *access_token* (query-string) - OAuth access token.
11769    /// * *alt* (query-string) - Data format for response.
11770    /// * *callback* (query-string) - JSONP
11771    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11772    /// * *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.
11773    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11774    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11775    /// * *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.
11776    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11777    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11778    pub fn param<T>(mut self, name: T, value: T) -> ProjectModelVersionCreateCall<'a, C>
11779    where
11780        T: AsRef<str>,
11781    {
11782        self._additional_params
11783            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11784        self
11785    }
11786
11787    /// Identifies the authorization scope for the method you are building.
11788    ///
11789    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11790    /// [`Scope::CloudPlatform`].
11791    ///
11792    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11793    /// tokens for more than one scope.
11794    ///
11795    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11796    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11797    /// sufficient, a read-write scope will do as well.
11798    pub fn add_scope<St>(mut self, scope: St) -> ProjectModelVersionCreateCall<'a, C>
11799    where
11800        St: AsRef<str>,
11801    {
11802        self._scopes.insert(String::from(scope.as_ref()));
11803        self
11804    }
11805    /// Identifies the authorization scope(s) for the method you are building.
11806    ///
11807    /// See [`Self::add_scope()`] for details.
11808    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectModelVersionCreateCall<'a, C>
11809    where
11810        I: IntoIterator<Item = St>,
11811        St: AsRef<str>,
11812    {
11813        self._scopes
11814            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11815        self
11816    }
11817
11818    /// Removes all scopes, and no default scope will be used either.
11819    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11820    /// for details).
11821    pub fn clear_scopes(mut self) -> ProjectModelVersionCreateCall<'a, C> {
11822        self._scopes.clear();
11823        self
11824    }
11825}
11826
11827/// Deletes a model version. Each model can have multiple versions deployed and in use at any given time. Use this method to remove a single version. Note: You cannot delete the version that is set as the default version of the model unless it is the only remaining version.
11828///
11829/// A builder for the *models.versions.delete* method supported by a *project* resource.
11830/// It is not used directly, but through a [`ProjectMethods`] instance.
11831///
11832/// # Example
11833///
11834/// Instantiate a resource method builder
11835///
11836/// ```test_harness,no_run
11837/// # extern crate hyper;
11838/// # extern crate hyper_rustls;
11839/// # extern crate google_ml1 as ml1;
11840/// # async fn dox() {
11841/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11842///
11843/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11844/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11845/// #     .with_native_roots()
11846/// #     .unwrap()
11847/// #     .https_only()
11848/// #     .enable_http2()
11849/// #     .build();
11850///
11851/// # let executor = hyper_util::rt::TokioExecutor::new();
11852/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11853/// #     secret,
11854/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11855/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11856/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11857/// #     ),
11858/// # ).build().await.unwrap();
11859///
11860/// # let client = hyper_util::client::legacy::Client::builder(
11861/// #     hyper_util::rt::TokioExecutor::new()
11862/// # )
11863/// # .build(
11864/// #     hyper_rustls::HttpsConnectorBuilder::new()
11865/// #         .with_native_roots()
11866/// #         .unwrap()
11867/// #         .https_or_http()
11868/// #         .enable_http2()
11869/// #         .build()
11870/// # );
11871/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
11872/// // You can configure optional parameters by calling the respective setters at will, and
11873/// // execute the final call using `doit()`.
11874/// // Values shown here are possibly random and not representative !
11875/// let result = hub.projects().models_versions_delete("name")
11876///              .doit().await;
11877/// # }
11878/// ```
11879pub struct ProjectModelVersionDeleteCall<'a, C>
11880where
11881    C: 'a,
11882{
11883    hub: &'a CloudMachineLearningEngine<C>,
11884    _name: String,
11885    _delegate: Option<&'a mut dyn common::Delegate>,
11886    _additional_params: HashMap<String, String>,
11887    _scopes: BTreeSet<String>,
11888}
11889
11890impl<'a, C> common::CallBuilder for ProjectModelVersionDeleteCall<'a, C> {}
11891
11892impl<'a, C> ProjectModelVersionDeleteCall<'a, C>
11893where
11894    C: common::Connector,
11895{
11896    /// Perform the operation you have build so far.
11897    pub async fn doit(
11898        mut self,
11899    ) -> common::Result<(common::Response, GoogleLongrunning__Operation)> {
11900        use std::borrow::Cow;
11901        use std::io::{Read, Seek};
11902
11903        use common::{url::Params, ToParts};
11904        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11905
11906        let mut dd = common::DefaultDelegate;
11907        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11908        dlg.begin(common::MethodInfo {
11909            id: "ml.projects.models.versions.delete",
11910            http_method: hyper::Method::DELETE,
11911        });
11912
11913        for &field in ["alt", "name"].iter() {
11914            if self._additional_params.contains_key(field) {
11915                dlg.finished(false);
11916                return Err(common::Error::FieldClash(field));
11917            }
11918        }
11919
11920        let mut params = Params::with_capacity(3 + self._additional_params.len());
11921        params.push("name", self._name);
11922
11923        params.extend(self._additional_params.iter());
11924
11925        params.push("alt", "json");
11926        let mut url = self.hub._base_url.clone() + "v1/{+name}";
11927        if self._scopes.is_empty() {
11928            self._scopes
11929                .insert(Scope::CloudPlatform.as_ref().to_string());
11930        }
11931
11932        #[allow(clippy::single_element_loop)]
11933        for &(find_this, param_name) in [("{+name}", "name")].iter() {
11934            url = params.uri_replacement(url, param_name, find_this, true);
11935        }
11936        {
11937            let to_remove = ["name"];
11938            params.remove_params(&to_remove);
11939        }
11940
11941        let url = params.parse_with_url(&url);
11942
11943        loop {
11944            let token = match self
11945                .hub
11946                .auth
11947                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11948                .await
11949            {
11950                Ok(token) => token,
11951                Err(e) => match dlg.token(e) {
11952                    Ok(token) => token,
11953                    Err(e) => {
11954                        dlg.finished(false);
11955                        return Err(common::Error::MissingToken(e));
11956                    }
11957                },
11958            };
11959            let mut req_result = {
11960                let client = &self.hub.client;
11961                dlg.pre_request();
11962                let mut req_builder = hyper::Request::builder()
11963                    .method(hyper::Method::DELETE)
11964                    .uri(url.as_str())
11965                    .header(USER_AGENT, self.hub._user_agent.clone());
11966
11967                if let Some(token) = token.as_ref() {
11968                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11969                }
11970
11971                let request = req_builder
11972                    .header(CONTENT_LENGTH, 0_u64)
11973                    .body(common::to_body::<String>(None));
11974
11975                client.request(request.unwrap()).await
11976            };
11977
11978            match req_result {
11979                Err(err) => {
11980                    if let common::Retry::After(d) = dlg.http_error(&err) {
11981                        sleep(d).await;
11982                        continue;
11983                    }
11984                    dlg.finished(false);
11985                    return Err(common::Error::HttpError(err));
11986                }
11987                Ok(res) => {
11988                    let (mut parts, body) = res.into_parts();
11989                    let mut body = common::Body::new(body);
11990                    if !parts.status.is_success() {
11991                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11992                        let error = serde_json::from_str(&common::to_string(&bytes));
11993                        let response = common::to_response(parts, bytes.into());
11994
11995                        if let common::Retry::After(d) =
11996                            dlg.http_failure(&response, error.as_ref().ok())
11997                        {
11998                            sleep(d).await;
11999                            continue;
12000                        }
12001
12002                        dlg.finished(false);
12003
12004                        return Err(match error {
12005                            Ok(value) => common::Error::BadRequest(value),
12006                            _ => common::Error::Failure(response),
12007                        });
12008                    }
12009                    let response = {
12010                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12011                        let encoded = common::to_string(&bytes);
12012                        match serde_json::from_str(&encoded) {
12013                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12014                            Err(error) => {
12015                                dlg.response_json_decode_error(&encoded, &error);
12016                                return Err(common::Error::JsonDecodeError(
12017                                    encoded.to_string(),
12018                                    error,
12019                                ));
12020                            }
12021                        }
12022                    };
12023
12024                    dlg.finished(true);
12025                    return Ok(response);
12026                }
12027            }
12028        }
12029    }
12030
12031    /// Required. The name of the version. You can get the names of all the versions of a model by calling projects.models.versions.list.
12032    ///
12033    /// Sets the *name* path property to the given value.
12034    ///
12035    /// Even though the property as already been set when instantiating this call,
12036    /// we provide this method for API completeness.
12037    pub fn name(mut self, new_value: &str) -> ProjectModelVersionDeleteCall<'a, C> {
12038        self._name = new_value.to_string();
12039        self
12040    }
12041    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12042    /// while executing the actual API request.
12043    ///
12044    /// ````text
12045    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12046    /// ````
12047    ///
12048    /// Sets the *delegate* property to the given value.
12049    pub fn delegate(
12050        mut self,
12051        new_value: &'a mut dyn common::Delegate,
12052    ) -> ProjectModelVersionDeleteCall<'a, C> {
12053        self._delegate = Some(new_value);
12054        self
12055    }
12056
12057    /// Set any additional parameter of the query string used in the request.
12058    /// It should be used to set parameters which are not yet available through their own
12059    /// setters.
12060    ///
12061    /// Please note that this method must not be used to set any of the known parameters
12062    /// which have their own setter method. If done anyway, the request will fail.
12063    ///
12064    /// # Additional Parameters
12065    ///
12066    /// * *$.xgafv* (query-string) - V1 error format.
12067    /// * *access_token* (query-string) - OAuth access token.
12068    /// * *alt* (query-string) - Data format for response.
12069    /// * *callback* (query-string) - JSONP
12070    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12071    /// * *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.
12072    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12073    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12074    /// * *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.
12075    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12076    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12077    pub fn param<T>(mut self, name: T, value: T) -> ProjectModelVersionDeleteCall<'a, C>
12078    where
12079        T: AsRef<str>,
12080    {
12081        self._additional_params
12082            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12083        self
12084    }
12085
12086    /// Identifies the authorization scope for the method you are building.
12087    ///
12088    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12089    /// [`Scope::CloudPlatform`].
12090    ///
12091    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12092    /// tokens for more than one scope.
12093    ///
12094    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12095    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12096    /// sufficient, a read-write scope will do as well.
12097    pub fn add_scope<St>(mut self, scope: St) -> ProjectModelVersionDeleteCall<'a, C>
12098    where
12099        St: AsRef<str>,
12100    {
12101        self._scopes.insert(String::from(scope.as_ref()));
12102        self
12103    }
12104    /// Identifies the authorization scope(s) for the method you are building.
12105    ///
12106    /// See [`Self::add_scope()`] for details.
12107    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectModelVersionDeleteCall<'a, C>
12108    where
12109        I: IntoIterator<Item = St>,
12110        St: AsRef<str>,
12111    {
12112        self._scopes
12113            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12114        self
12115    }
12116
12117    /// Removes all scopes, and no default scope will be used either.
12118    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12119    /// for details).
12120    pub fn clear_scopes(mut self) -> ProjectModelVersionDeleteCall<'a, C> {
12121        self._scopes.clear();
12122        self
12123    }
12124}
12125
12126/// Gets information about a model version. Models can have multiple versions. You can call projects.models.versions.list to get the same information that this method returns for all of the versions of a model.
12127///
12128/// A builder for the *models.versions.get* method supported by a *project* resource.
12129/// It is not used directly, but through a [`ProjectMethods`] instance.
12130///
12131/// # Example
12132///
12133/// Instantiate a resource method builder
12134///
12135/// ```test_harness,no_run
12136/// # extern crate hyper;
12137/// # extern crate hyper_rustls;
12138/// # extern crate google_ml1 as ml1;
12139/// # async fn dox() {
12140/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12141///
12142/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12143/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12144/// #     .with_native_roots()
12145/// #     .unwrap()
12146/// #     .https_only()
12147/// #     .enable_http2()
12148/// #     .build();
12149///
12150/// # let executor = hyper_util::rt::TokioExecutor::new();
12151/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12152/// #     secret,
12153/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12154/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12155/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12156/// #     ),
12157/// # ).build().await.unwrap();
12158///
12159/// # let client = hyper_util::client::legacy::Client::builder(
12160/// #     hyper_util::rt::TokioExecutor::new()
12161/// # )
12162/// # .build(
12163/// #     hyper_rustls::HttpsConnectorBuilder::new()
12164/// #         .with_native_roots()
12165/// #         .unwrap()
12166/// #         .https_or_http()
12167/// #         .enable_http2()
12168/// #         .build()
12169/// # );
12170/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
12171/// // You can configure optional parameters by calling the respective setters at will, and
12172/// // execute the final call using `doit()`.
12173/// // Values shown here are possibly random and not representative !
12174/// let result = hub.projects().models_versions_get("name")
12175///              .doit().await;
12176/// # }
12177/// ```
12178pub struct ProjectModelVersionGetCall<'a, C>
12179where
12180    C: 'a,
12181{
12182    hub: &'a CloudMachineLearningEngine<C>,
12183    _name: String,
12184    _delegate: Option<&'a mut dyn common::Delegate>,
12185    _additional_params: HashMap<String, String>,
12186    _scopes: BTreeSet<String>,
12187}
12188
12189impl<'a, C> common::CallBuilder for ProjectModelVersionGetCall<'a, C> {}
12190
12191impl<'a, C> ProjectModelVersionGetCall<'a, C>
12192where
12193    C: common::Connector,
12194{
12195    /// Perform the operation you have build so far.
12196    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleCloudMlV1__Version)> {
12197        use std::borrow::Cow;
12198        use std::io::{Read, Seek};
12199
12200        use common::{url::Params, ToParts};
12201        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12202
12203        let mut dd = common::DefaultDelegate;
12204        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12205        dlg.begin(common::MethodInfo {
12206            id: "ml.projects.models.versions.get",
12207            http_method: hyper::Method::GET,
12208        });
12209
12210        for &field in ["alt", "name"].iter() {
12211            if self._additional_params.contains_key(field) {
12212                dlg.finished(false);
12213                return Err(common::Error::FieldClash(field));
12214            }
12215        }
12216
12217        let mut params = Params::with_capacity(3 + self._additional_params.len());
12218        params.push("name", self._name);
12219
12220        params.extend(self._additional_params.iter());
12221
12222        params.push("alt", "json");
12223        let mut url = self.hub._base_url.clone() + "v1/{+name}";
12224        if self._scopes.is_empty() {
12225            self._scopes
12226                .insert(Scope::CloudPlatform.as_ref().to_string());
12227        }
12228
12229        #[allow(clippy::single_element_loop)]
12230        for &(find_this, param_name) in [("{+name}", "name")].iter() {
12231            url = params.uri_replacement(url, param_name, find_this, true);
12232        }
12233        {
12234            let to_remove = ["name"];
12235            params.remove_params(&to_remove);
12236        }
12237
12238        let url = params.parse_with_url(&url);
12239
12240        loop {
12241            let token = match self
12242                .hub
12243                .auth
12244                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12245                .await
12246            {
12247                Ok(token) => token,
12248                Err(e) => match dlg.token(e) {
12249                    Ok(token) => token,
12250                    Err(e) => {
12251                        dlg.finished(false);
12252                        return Err(common::Error::MissingToken(e));
12253                    }
12254                },
12255            };
12256            let mut req_result = {
12257                let client = &self.hub.client;
12258                dlg.pre_request();
12259                let mut req_builder = hyper::Request::builder()
12260                    .method(hyper::Method::GET)
12261                    .uri(url.as_str())
12262                    .header(USER_AGENT, self.hub._user_agent.clone());
12263
12264                if let Some(token) = token.as_ref() {
12265                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12266                }
12267
12268                let request = req_builder
12269                    .header(CONTENT_LENGTH, 0_u64)
12270                    .body(common::to_body::<String>(None));
12271
12272                client.request(request.unwrap()).await
12273            };
12274
12275            match req_result {
12276                Err(err) => {
12277                    if let common::Retry::After(d) = dlg.http_error(&err) {
12278                        sleep(d).await;
12279                        continue;
12280                    }
12281                    dlg.finished(false);
12282                    return Err(common::Error::HttpError(err));
12283                }
12284                Ok(res) => {
12285                    let (mut parts, body) = res.into_parts();
12286                    let mut body = common::Body::new(body);
12287                    if !parts.status.is_success() {
12288                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12289                        let error = serde_json::from_str(&common::to_string(&bytes));
12290                        let response = common::to_response(parts, bytes.into());
12291
12292                        if let common::Retry::After(d) =
12293                            dlg.http_failure(&response, error.as_ref().ok())
12294                        {
12295                            sleep(d).await;
12296                            continue;
12297                        }
12298
12299                        dlg.finished(false);
12300
12301                        return Err(match error {
12302                            Ok(value) => common::Error::BadRequest(value),
12303                            _ => common::Error::Failure(response),
12304                        });
12305                    }
12306                    let response = {
12307                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12308                        let encoded = common::to_string(&bytes);
12309                        match serde_json::from_str(&encoded) {
12310                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12311                            Err(error) => {
12312                                dlg.response_json_decode_error(&encoded, &error);
12313                                return Err(common::Error::JsonDecodeError(
12314                                    encoded.to_string(),
12315                                    error,
12316                                ));
12317                            }
12318                        }
12319                    };
12320
12321                    dlg.finished(true);
12322                    return Ok(response);
12323                }
12324            }
12325        }
12326    }
12327
12328    /// Required. The name of the version.
12329    ///
12330    /// Sets the *name* path property to the given value.
12331    ///
12332    /// Even though the property as already been set when instantiating this call,
12333    /// we provide this method for API completeness.
12334    pub fn name(mut self, new_value: &str) -> ProjectModelVersionGetCall<'a, C> {
12335        self._name = new_value.to_string();
12336        self
12337    }
12338    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12339    /// while executing the actual API request.
12340    ///
12341    /// ````text
12342    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12343    /// ````
12344    ///
12345    /// Sets the *delegate* property to the given value.
12346    pub fn delegate(
12347        mut self,
12348        new_value: &'a mut dyn common::Delegate,
12349    ) -> ProjectModelVersionGetCall<'a, C> {
12350        self._delegate = Some(new_value);
12351        self
12352    }
12353
12354    /// Set any additional parameter of the query string used in the request.
12355    /// It should be used to set parameters which are not yet available through their own
12356    /// setters.
12357    ///
12358    /// Please note that this method must not be used to set any of the known parameters
12359    /// which have their own setter method. If done anyway, the request will fail.
12360    ///
12361    /// # Additional Parameters
12362    ///
12363    /// * *$.xgafv* (query-string) - V1 error format.
12364    /// * *access_token* (query-string) - OAuth access token.
12365    /// * *alt* (query-string) - Data format for response.
12366    /// * *callback* (query-string) - JSONP
12367    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12368    /// * *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.
12369    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12370    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12371    /// * *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.
12372    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12373    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12374    pub fn param<T>(mut self, name: T, value: T) -> ProjectModelVersionGetCall<'a, C>
12375    where
12376        T: AsRef<str>,
12377    {
12378        self._additional_params
12379            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12380        self
12381    }
12382
12383    /// Identifies the authorization scope for the method you are building.
12384    ///
12385    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12386    /// [`Scope::CloudPlatform`].
12387    ///
12388    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12389    /// tokens for more than one scope.
12390    ///
12391    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12392    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12393    /// sufficient, a read-write scope will do as well.
12394    pub fn add_scope<St>(mut self, scope: St) -> ProjectModelVersionGetCall<'a, C>
12395    where
12396        St: AsRef<str>,
12397    {
12398        self._scopes.insert(String::from(scope.as_ref()));
12399        self
12400    }
12401    /// Identifies the authorization scope(s) for the method you are building.
12402    ///
12403    /// See [`Self::add_scope()`] for details.
12404    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectModelVersionGetCall<'a, C>
12405    where
12406        I: IntoIterator<Item = St>,
12407        St: AsRef<str>,
12408    {
12409        self._scopes
12410            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12411        self
12412    }
12413
12414    /// Removes all scopes, and no default scope will be used either.
12415    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12416    /// for details).
12417    pub fn clear_scopes(mut self) -> ProjectModelVersionGetCall<'a, C> {
12418        self._scopes.clear();
12419        self
12420    }
12421}
12422
12423/// Gets basic information about all the versions of a model. If you expect that a model has many versions, or if you need to handle only a limited number of results at a time, you can request that the list be retrieved in batches (called pages). If there are no versions that match the request parameters, the list request returns an empty response body: {}.
12424///
12425/// A builder for the *models.versions.list* method supported by a *project* resource.
12426/// It is not used directly, but through a [`ProjectMethods`] instance.
12427///
12428/// # Example
12429///
12430/// Instantiate a resource method builder
12431///
12432/// ```test_harness,no_run
12433/// # extern crate hyper;
12434/// # extern crate hyper_rustls;
12435/// # extern crate google_ml1 as ml1;
12436/// # async fn dox() {
12437/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12438///
12439/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12440/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12441/// #     .with_native_roots()
12442/// #     .unwrap()
12443/// #     .https_only()
12444/// #     .enable_http2()
12445/// #     .build();
12446///
12447/// # let executor = hyper_util::rt::TokioExecutor::new();
12448/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12449/// #     secret,
12450/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12451/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12452/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12453/// #     ),
12454/// # ).build().await.unwrap();
12455///
12456/// # let client = hyper_util::client::legacy::Client::builder(
12457/// #     hyper_util::rt::TokioExecutor::new()
12458/// # )
12459/// # .build(
12460/// #     hyper_rustls::HttpsConnectorBuilder::new()
12461/// #         .with_native_roots()
12462/// #         .unwrap()
12463/// #         .https_or_http()
12464/// #         .enable_http2()
12465/// #         .build()
12466/// # );
12467/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
12468/// // You can configure optional parameters by calling the respective setters at will, and
12469/// // execute the final call using `doit()`.
12470/// // Values shown here are possibly random and not representative !
12471/// let result = hub.projects().models_versions_list("parent")
12472///              .page_token("sed")
12473///              .page_size(-61)
12474///              .filter("Stet")
12475///              .doit().await;
12476/// # }
12477/// ```
12478pub struct ProjectModelVersionListCall<'a, C>
12479where
12480    C: 'a,
12481{
12482    hub: &'a CloudMachineLearningEngine<C>,
12483    _parent: String,
12484    _page_token: Option<String>,
12485    _page_size: Option<i32>,
12486    _filter: Option<String>,
12487    _delegate: Option<&'a mut dyn common::Delegate>,
12488    _additional_params: HashMap<String, String>,
12489    _scopes: BTreeSet<String>,
12490}
12491
12492impl<'a, C> common::CallBuilder for ProjectModelVersionListCall<'a, C> {}
12493
12494impl<'a, C> ProjectModelVersionListCall<'a, C>
12495where
12496    C: common::Connector,
12497{
12498    /// Perform the operation you have build so far.
12499    pub async fn doit(
12500        mut self,
12501    ) -> common::Result<(common::Response, GoogleCloudMlV1__ListVersionsResponse)> {
12502        use std::borrow::Cow;
12503        use std::io::{Read, Seek};
12504
12505        use common::{url::Params, ToParts};
12506        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12507
12508        let mut dd = common::DefaultDelegate;
12509        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12510        dlg.begin(common::MethodInfo {
12511            id: "ml.projects.models.versions.list",
12512            http_method: hyper::Method::GET,
12513        });
12514
12515        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
12516            if self._additional_params.contains_key(field) {
12517                dlg.finished(false);
12518                return Err(common::Error::FieldClash(field));
12519            }
12520        }
12521
12522        let mut params = Params::with_capacity(6 + self._additional_params.len());
12523        params.push("parent", self._parent);
12524        if let Some(value) = self._page_token.as_ref() {
12525            params.push("pageToken", value);
12526        }
12527        if let Some(value) = self._page_size.as_ref() {
12528            params.push("pageSize", value.to_string());
12529        }
12530        if let Some(value) = self._filter.as_ref() {
12531            params.push("filter", value);
12532        }
12533
12534        params.extend(self._additional_params.iter());
12535
12536        params.push("alt", "json");
12537        let mut url = self.hub._base_url.clone() + "v1/{+parent}/versions";
12538        if self._scopes.is_empty() {
12539            self._scopes
12540                .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
12541        }
12542
12543        #[allow(clippy::single_element_loop)]
12544        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
12545            url = params.uri_replacement(url, param_name, find_this, true);
12546        }
12547        {
12548            let to_remove = ["parent"];
12549            params.remove_params(&to_remove);
12550        }
12551
12552        let url = params.parse_with_url(&url);
12553
12554        loop {
12555            let token = match self
12556                .hub
12557                .auth
12558                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12559                .await
12560            {
12561                Ok(token) => token,
12562                Err(e) => match dlg.token(e) {
12563                    Ok(token) => token,
12564                    Err(e) => {
12565                        dlg.finished(false);
12566                        return Err(common::Error::MissingToken(e));
12567                    }
12568                },
12569            };
12570            let mut req_result = {
12571                let client = &self.hub.client;
12572                dlg.pre_request();
12573                let mut req_builder = hyper::Request::builder()
12574                    .method(hyper::Method::GET)
12575                    .uri(url.as_str())
12576                    .header(USER_AGENT, self.hub._user_agent.clone());
12577
12578                if let Some(token) = token.as_ref() {
12579                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12580                }
12581
12582                let request = req_builder
12583                    .header(CONTENT_LENGTH, 0_u64)
12584                    .body(common::to_body::<String>(None));
12585
12586                client.request(request.unwrap()).await
12587            };
12588
12589            match req_result {
12590                Err(err) => {
12591                    if let common::Retry::After(d) = dlg.http_error(&err) {
12592                        sleep(d).await;
12593                        continue;
12594                    }
12595                    dlg.finished(false);
12596                    return Err(common::Error::HttpError(err));
12597                }
12598                Ok(res) => {
12599                    let (mut parts, body) = res.into_parts();
12600                    let mut body = common::Body::new(body);
12601                    if !parts.status.is_success() {
12602                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12603                        let error = serde_json::from_str(&common::to_string(&bytes));
12604                        let response = common::to_response(parts, bytes.into());
12605
12606                        if let common::Retry::After(d) =
12607                            dlg.http_failure(&response, error.as_ref().ok())
12608                        {
12609                            sleep(d).await;
12610                            continue;
12611                        }
12612
12613                        dlg.finished(false);
12614
12615                        return Err(match error {
12616                            Ok(value) => common::Error::BadRequest(value),
12617                            _ => common::Error::Failure(response),
12618                        });
12619                    }
12620                    let response = {
12621                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12622                        let encoded = common::to_string(&bytes);
12623                        match serde_json::from_str(&encoded) {
12624                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12625                            Err(error) => {
12626                                dlg.response_json_decode_error(&encoded, &error);
12627                                return Err(common::Error::JsonDecodeError(
12628                                    encoded.to_string(),
12629                                    error,
12630                                ));
12631                            }
12632                        }
12633                    };
12634
12635                    dlg.finished(true);
12636                    return Ok(response);
12637                }
12638            }
12639        }
12640    }
12641
12642    /// Required. The name of the model for which to list the version.
12643    ///
12644    /// Sets the *parent* path property to the given value.
12645    ///
12646    /// Even though the property as already been set when instantiating this call,
12647    /// we provide this method for API completeness.
12648    pub fn parent(mut self, new_value: &str) -> ProjectModelVersionListCall<'a, C> {
12649        self._parent = new_value.to_string();
12650        self
12651    }
12652    /// Optional. A page token to request the next page of results. You get the token from the `next_page_token` field of the response from the previous call.
12653    ///
12654    /// Sets the *page token* query property to the given value.
12655    pub fn page_token(mut self, new_value: &str) -> ProjectModelVersionListCall<'a, C> {
12656        self._page_token = Some(new_value.to_string());
12657        self
12658    }
12659    /// Optional. The number of versions to retrieve per "page" of results. If there are more remaining results than this number, the response message will contain a valid value in the `next_page_token` field. The default value is 20, and the maximum page size is 100.
12660    ///
12661    /// Sets the *page size* query property to the given value.
12662    pub fn page_size(mut self, new_value: i32) -> ProjectModelVersionListCall<'a, C> {
12663        self._page_size = Some(new_value);
12664        self
12665    }
12666    /// Optional. Specifies the subset of versions to retrieve.
12667    ///
12668    /// Sets the *filter* query property to the given value.
12669    pub fn filter(mut self, new_value: &str) -> ProjectModelVersionListCall<'a, C> {
12670        self._filter = Some(new_value.to_string());
12671        self
12672    }
12673    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12674    /// while executing the actual API request.
12675    ///
12676    /// ````text
12677    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12678    /// ````
12679    ///
12680    /// Sets the *delegate* property to the given value.
12681    pub fn delegate(
12682        mut self,
12683        new_value: &'a mut dyn common::Delegate,
12684    ) -> ProjectModelVersionListCall<'a, C> {
12685        self._delegate = Some(new_value);
12686        self
12687    }
12688
12689    /// Set any additional parameter of the query string used in the request.
12690    /// It should be used to set parameters which are not yet available through their own
12691    /// setters.
12692    ///
12693    /// Please note that this method must not be used to set any of the known parameters
12694    /// which have their own setter method. If done anyway, the request will fail.
12695    ///
12696    /// # Additional Parameters
12697    ///
12698    /// * *$.xgafv* (query-string) - V1 error format.
12699    /// * *access_token* (query-string) - OAuth access token.
12700    /// * *alt* (query-string) - Data format for response.
12701    /// * *callback* (query-string) - JSONP
12702    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12703    /// * *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.
12704    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12705    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12706    /// * *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.
12707    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12708    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12709    pub fn param<T>(mut self, name: T, value: T) -> ProjectModelVersionListCall<'a, C>
12710    where
12711        T: AsRef<str>,
12712    {
12713        self._additional_params
12714            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12715        self
12716    }
12717
12718    /// Identifies the authorization scope for the method you are building.
12719    ///
12720    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12721    /// [`Scope::CloudPlatformReadOnly`].
12722    ///
12723    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12724    /// tokens for more than one scope.
12725    ///
12726    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12727    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12728    /// sufficient, a read-write scope will do as well.
12729    pub fn add_scope<St>(mut self, scope: St) -> ProjectModelVersionListCall<'a, C>
12730    where
12731        St: AsRef<str>,
12732    {
12733        self._scopes.insert(String::from(scope.as_ref()));
12734        self
12735    }
12736    /// Identifies the authorization scope(s) for the method you are building.
12737    ///
12738    /// See [`Self::add_scope()`] for details.
12739    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectModelVersionListCall<'a, C>
12740    where
12741        I: IntoIterator<Item = St>,
12742        St: AsRef<str>,
12743    {
12744        self._scopes
12745            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12746        self
12747    }
12748
12749    /// Removes all scopes, and no default scope will be used either.
12750    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12751    /// for details).
12752    pub fn clear_scopes(mut self) -> ProjectModelVersionListCall<'a, C> {
12753        self._scopes.clear();
12754        self
12755    }
12756}
12757
12758/// Updates the specified Version resource. Currently the only update-able fields are `description`, `requestLoggingConfig`, `autoScaling.minNodes`, and `manualScaling.nodes`.
12759///
12760/// A builder for the *models.versions.patch* method supported by a *project* resource.
12761/// It is not used directly, but through a [`ProjectMethods`] instance.
12762///
12763/// # Example
12764///
12765/// Instantiate a resource method builder
12766///
12767/// ```test_harness,no_run
12768/// # extern crate hyper;
12769/// # extern crate hyper_rustls;
12770/// # extern crate google_ml1 as ml1;
12771/// use ml1::api::GoogleCloudMlV1__Version;
12772/// # async fn dox() {
12773/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12774///
12775/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12776/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12777/// #     .with_native_roots()
12778/// #     .unwrap()
12779/// #     .https_only()
12780/// #     .enable_http2()
12781/// #     .build();
12782///
12783/// # let executor = hyper_util::rt::TokioExecutor::new();
12784/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12785/// #     secret,
12786/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12787/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12788/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12789/// #     ),
12790/// # ).build().await.unwrap();
12791///
12792/// # let client = hyper_util::client::legacy::Client::builder(
12793/// #     hyper_util::rt::TokioExecutor::new()
12794/// # )
12795/// # .build(
12796/// #     hyper_rustls::HttpsConnectorBuilder::new()
12797/// #         .with_native_roots()
12798/// #         .unwrap()
12799/// #         .https_or_http()
12800/// #         .enable_http2()
12801/// #         .build()
12802/// # );
12803/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
12804/// // As the method needs a request, you would usually fill it with the desired information
12805/// // into the respective structure. Some of the parts shown here might not be applicable !
12806/// // Values shown here are possibly random and not representative !
12807/// let mut req = GoogleCloudMlV1__Version::default();
12808///
12809/// // You can configure optional parameters by calling the respective setters at will, and
12810/// // execute the final call using `doit()`.
12811/// // Values shown here are possibly random and not representative !
12812/// let result = hub.projects().models_versions_patch(req, "name")
12813///              .update_mask(FieldMask::new::<&str>(&[]))
12814///              .doit().await;
12815/// # }
12816/// ```
12817pub struct ProjectModelVersionPatchCall<'a, C>
12818where
12819    C: 'a,
12820{
12821    hub: &'a CloudMachineLearningEngine<C>,
12822    _request: GoogleCloudMlV1__Version,
12823    _name: String,
12824    _update_mask: Option<common::FieldMask>,
12825    _delegate: Option<&'a mut dyn common::Delegate>,
12826    _additional_params: HashMap<String, String>,
12827    _scopes: BTreeSet<String>,
12828}
12829
12830impl<'a, C> common::CallBuilder for ProjectModelVersionPatchCall<'a, C> {}
12831
12832impl<'a, C> ProjectModelVersionPatchCall<'a, C>
12833where
12834    C: common::Connector,
12835{
12836    /// Perform the operation you have build so far.
12837    pub async fn doit(
12838        mut self,
12839    ) -> common::Result<(common::Response, GoogleLongrunning__Operation)> {
12840        use std::borrow::Cow;
12841        use std::io::{Read, Seek};
12842
12843        use common::{url::Params, ToParts};
12844        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12845
12846        let mut dd = common::DefaultDelegate;
12847        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12848        dlg.begin(common::MethodInfo {
12849            id: "ml.projects.models.versions.patch",
12850            http_method: hyper::Method::PATCH,
12851        });
12852
12853        for &field in ["alt", "name", "updateMask"].iter() {
12854            if self._additional_params.contains_key(field) {
12855                dlg.finished(false);
12856                return Err(common::Error::FieldClash(field));
12857            }
12858        }
12859
12860        let mut params = Params::with_capacity(5 + self._additional_params.len());
12861        params.push("name", self._name);
12862        if let Some(value) = self._update_mask.as_ref() {
12863            params.push("updateMask", value.to_string());
12864        }
12865
12866        params.extend(self._additional_params.iter());
12867
12868        params.push("alt", "json");
12869        let mut url = self.hub._base_url.clone() + "v1/{+name}";
12870        if self._scopes.is_empty() {
12871            self._scopes
12872                .insert(Scope::CloudPlatform.as_ref().to_string());
12873        }
12874
12875        #[allow(clippy::single_element_loop)]
12876        for &(find_this, param_name) in [("{+name}", "name")].iter() {
12877            url = params.uri_replacement(url, param_name, find_this, true);
12878        }
12879        {
12880            let to_remove = ["name"];
12881            params.remove_params(&to_remove);
12882        }
12883
12884        let url = params.parse_with_url(&url);
12885
12886        let mut json_mime_type = mime::APPLICATION_JSON;
12887        let mut request_value_reader = {
12888            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12889            common::remove_json_null_values(&mut value);
12890            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12891            serde_json::to_writer(&mut dst, &value).unwrap();
12892            dst
12893        };
12894        let request_size = request_value_reader
12895            .seek(std::io::SeekFrom::End(0))
12896            .unwrap();
12897        request_value_reader
12898            .seek(std::io::SeekFrom::Start(0))
12899            .unwrap();
12900
12901        loop {
12902            let token = match self
12903                .hub
12904                .auth
12905                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12906                .await
12907            {
12908                Ok(token) => token,
12909                Err(e) => match dlg.token(e) {
12910                    Ok(token) => token,
12911                    Err(e) => {
12912                        dlg.finished(false);
12913                        return Err(common::Error::MissingToken(e));
12914                    }
12915                },
12916            };
12917            request_value_reader
12918                .seek(std::io::SeekFrom::Start(0))
12919                .unwrap();
12920            let mut req_result = {
12921                let client = &self.hub.client;
12922                dlg.pre_request();
12923                let mut req_builder = hyper::Request::builder()
12924                    .method(hyper::Method::PATCH)
12925                    .uri(url.as_str())
12926                    .header(USER_AGENT, self.hub._user_agent.clone());
12927
12928                if let Some(token) = token.as_ref() {
12929                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12930                }
12931
12932                let request = req_builder
12933                    .header(CONTENT_TYPE, json_mime_type.to_string())
12934                    .header(CONTENT_LENGTH, request_size as u64)
12935                    .body(common::to_body(
12936                        request_value_reader.get_ref().clone().into(),
12937                    ));
12938
12939                client.request(request.unwrap()).await
12940            };
12941
12942            match req_result {
12943                Err(err) => {
12944                    if let common::Retry::After(d) = dlg.http_error(&err) {
12945                        sleep(d).await;
12946                        continue;
12947                    }
12948                    dlg.finished(false);
12949                    return Err(common::Error::HttpError(err));
12950                }
12951                Ok(res) => {
12952                    let (mut parts, body) = res.into_parts();
12953                    let mut body = common::Body::new(body);
12954                    if !parts.status.is_success() {
12955                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12956                        let error = serde_json::from_str(&common::to_string(&bytes));
12957                        let response = common::to_response(parts, bytes.into());
12958
12959                        if let common::Retry::After(d) =
12960                            dlg.http_failure(&response, error.as_ref().ok())
12961                        {
12962                            sleep(d).await;
12963                            continue;
12964                        }
12965
12966                        dlg.finished(false);
12967
12968                        return Err(match error {
12969                            Ok(value) => common::Error::BadRequest(value),
12970                            _ => common::Error::Failure(response),
12971                        });
12972                    }
12973                    let response = {
12974                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12975                        let encoded = common::to_string(&bytes);
12976                        match serde_json::from_str(&encoded) {
12977                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12978                            Err(error) => {
12979                                dlg.response_json_decode_error(&encoded, &error);
12980                                return Err(common::Error::JsonDecodeError(
12981                                    encoded.to_string(),
12982                                    error,
12983                                ));
12984                            }
12985                        }
12986                    };
12987
12988                    dlg.finished(true);
12989                    return Ok(response);
12990                }
12991            }
12992        }
12993    }
12994
12995    ///
12996    /// Sets the *request* property to the given value.
12997    ///
12998    /// Even though the property as already been set when instantiating this call,
12999    /// we provide this method for API completeness.
13000    pub fn request(
13001        mut self,
13002        new_value: GoogleCloudMlV1__Version,
13003    ) -> ProjectModelVersionPatchCall<'a, C> {
13004        self._request = new_value;
13005        self
13006    }
13007    /// Required. The name of the model.
13008    ///
13009    /// Sets the *name* path property to the given value.
13010    ///
13011    /// Even though the property as already been set when instantiating this call,
13012    /// we provide this method for API completeness.
13013    pub fn name(mut self, new_value: &str) -> ProjectModelVersionPatchCall<'a, C> {
13014        self._name = new_value.to_string();
13015        self
13016    }
13017    /// Required. Specifies the path, relative to `Version`, of the field to update. Must be present and non-empty. For example, to change the description of a version to “foo”, the `update_mask` parameter would be specified as `description`, and the `PATCH` request body would specify the new value, as follows: `{ "description": "foo" }` Currently the only supported update mask fields are `description`, `requestLoggingConfig`, `autoScaling.minNodes`, and `manualScaling.nodes`. However, you can only update `manualScaling.nodes` if the version uses a [Compute Engine (N1) machine type](https://cloud.google.com/ml-engine/docs/machine-types-online-prediction).
13018    ///
13019    /// Sets the *update mask* query property to the given value.
13020    pub fn update_mask(
13021        mut self,
13022        new_value: common::FieldMask,
13023    ) -> ProjectModelVersionPatchCall<'a, C> {
13024        self._update_mask = Some(new_value);
13025        self
13026    }
13027    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13028    /// while executing the actual API request.
13029    ///
13030    /// ````text
13031    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13032    /// ````
13033    ///
13034    /// Sets the *delegate* property to the given value.
13035    pub fn delegate(
13036        mut self,
13037        new_value: &'a mut dyn common::Delegate,
13038    ) -> ProjectModelVersionPatchCall<'a, C> {
13039        self._delegate = Some(new_value);
13040        self
13041    }
13042
13043    /// Set any additional parameter of the query string used in the request.
13044    /// It should be used to set parameters which are not yet available through their own
13045    /// setters.
13046    ///
13047    /// Please note that this method must not be used to set any of the known parameters
13048    /// which have their own setter method. If done anyway, the request will fail.
13049    ///
13050    /// # Additional Parameters
13051    ///
13052    /// * *$.xgafv* (query-string) - V1 error format.
13053    /// * *access_token* (query-string) - OAuth access token.
13054    /// * *alt* (query-string) - Data format for response.
13055    /// * *callback* (query-string) - JSONP
13056    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13057    /// * *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.
13058    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13059    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13060    /// * *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.
13061    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13062    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13063    pub fn param<T>(mut self, name: T, value: T) -> ProjectModelVersionPatchCall<'a, C>
13064    where
13065        T: AsRef<str>,
13066    {
13067        self._additional_params
13068            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13069        self
13070    }
13071
13072    /// Identifies the authorization scope for the method you are building.
13073    ///
13074    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13075    /// [`Scope::CloudPlatform`].
13076    ///
13077    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13078    /// tokens for more than one scope.
13079    ///
13080    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13081    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13082    /// sufficient, a read-write scope will do as well.
13083    pub fn add_scope<St>(mut self, scope: St) -> ProjectModelVersionPatchCall<'a, C>
13084    where
13085        St: AsRef<str>,
13086    {
13087        self._scopes.insert(String::from(scope.as_ref()));
13088        self
13089    }
13090    /// Identifies the authorization scope(s) for the method you are building.
13091    ///
13092    /// See [`Self::add_scope()`] for details.
13093    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectModelVersionPatchCall<'a, C>
13094    where
13095        I: IntoIterator<Item = St>,
13096        St: AsRef<str>,
13097    {
13098        self._scopes
13099            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13100        self
13101    }
13102
13103    /// Removes all scopes, and no default scope will be used either.
13104    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13105    /// for details).
13106    pub fn clear_scopes(mut self) -> ProjectModelVersionPatchCall<'a, C> {
13107        self._scopes.clear();
13108        self
13109    }
13110}
13111
13112/// Designates a version to be the default for the model. The default version is used for prediction requests made against the model that don't specify a version. The first version to be created for a model is automatically set as the default. You must make any subsequent changes to the default version setting manually using this method.
13113///
13114/// A builder for the *models.versions.setDefault* method supported by a *project* resource.
13115/// It is not used directly, but through a [`ProjectMethods`] instance.
13116///
13117/// # Example
13118///
13119/// Instantiate a resource method builder
13120///
13121/// ```test_harness,no_run
13122/// # extern crate hyper;
13123/// # extern crate hyper_rustls;
13124/// # extern crate google_ml1 as ml1;
13125/// use ml1::api::GoogleCloudMlV1__SetDefaultVersionRequest;
13126/// # async fn dox() {
13127/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13128///
13129/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13130/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13131/// #     .with_native_roots()
13132/// #     .unwrap()
13133/// #     .https_only()
13134/// #     .enable_http2()
13135/// #     .build();
13136///
13137/// # let executor = hyper_util::rt::TokioExecutor::new();
13138/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13139/// #     secret,
13140/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13141/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13142/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13143/// #     ),
13144/// # ).build().await.unwrap();
13145///
13146/// # let client = hyper_util::client::legacy::Client::builder(
13147/// #     hyper_util::rt::TokioExecutor::new()
13148/// # )
13149/// # .build(
13150/// #     hyper_rustls::HttpsConnectorBuilder::new()
13151/// #         .with_native_roots()
13152/// #         .unwrap()
13153/// #         .https_or_http()
13154/// #         .enable_http2()
13155/// #         .build()
13156/// # );
13157/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
13158/// // As the method needs a request, you would usually fill it with the desired information
13159/// // into the respective structure. Some of the parts shown here might not be applicable !
13160/// // Values shown here are possibly random and not representative !
13161/// let mut req = GoogleCloudMlV1__SetDefaultVersionRequest::default();
13162///
13163/// // You can configure optional parameters by calling the respective setters at will, and
13164/// // execute the final call using `doit()`.
13165/// // Values shown here are possibly random and not representative !
13166/// let result = hub.projects().models_versions_set_default(req, "name")
13167///              .doit().await;
13168/// # }
13169/// ```
13170pub struct ProjectModelVersionSetDefaultCall<'a, C>
13171where
13172    C: 'a,
13173{
13174    hub: &'a CloudMachineLearningEngine<C>,
13175    _request: GoogleCloudMlV1__SetDefaultVersionRequest,
13176    _name: String,
13177    _delegate: Option<&'a mut dyn common::Delegate>,
13178    _additional_params: HashMap<String, String>,
13179    _scopes: BTreeSet<String>,
13180}
13181
13182impl<'a, C> common::CallBuilder for ProjectModelVersionSetDefaultCall<'a, C> {}
13183
13184impl<'a, C> ProjectModelVersionSetDefaultCall<'a, C>
13185where
13186    C: common::Connector,
13187{
13188    /// Perform the operation you have build so far.
13189    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleCloudMlV1__Version)> {
13190        use std::borrow::Cow;
13191        use std::io::{Read, Seek};
13192
13193        use common::{url::Params, ToParts};
13194        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13195
13196        let mut dd = common::DefaultDelegate;
13197        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13198        dlg.begin(common::MethodInfo {
13199            id: "ml.projects.models.versions.setDefault",
13200            http_method: hyper::Method::POST,
13201        });
13202
13203        for &field in ["alt", "name"].iter() {
13204            if self._additional_params.contains_key(field) {
13205                dlg.finished(false);
13206                return Err(common::Error::FieldClash(field));
13207            }
13208        }
13209
13210        let mut params = Params::with_capacity(4 + self._additional_params.len());
13211        params.push("name", self._name);
13212
13213        params.extend(self._additional_params.iter());
13214
13215        params.push("alt", "json");
13216        let mut url = self.hub._base_url.clone() + "v1/{+name}:setDefault";
13217        if self._scopes.is_empty() {
13218            self._scopes
13219                .insert(Scope::CloudPlatform.as_ref().to_string());
13220        }
13221
13222        #[allow(clippy::single_element_loop)]
13223        for &(find_this, param_name) in [("{+name}", "name")].iter() {
13224            url = params.uri_replacement(url, param_name, find_this, true);
13225        }
13226        {
13227            let to_remove = ["name"];
13228            params.remove_params(&to_remove);
13229        }
13230
13231        let url = params.parse_with_url(&url);
13232
13233        let mut json_mime_type = mime::APPLICATION_JSON;
13234        let mut request_value_reader = {
13235            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13236            common::remove_json_null_values(&mut value);
13237            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13238            serde_json::to_writer(&mut dst, &value).unwrap();
13239            dst
13240        };
13241        let request_size = request_value_reader
13242            .seek(std::io::SeekFrom::End(0))
13243            .unwrap();
13244        request_value_reader
13245            .seek(std::io::SeekFrom::Start(0))
13246            .unwrap();
13247
13248        loop {
13249            let token = match self
13250                .hub
13251                .auth
13252                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13253                .await
13254            {
13255                Ok(token) => token,
13256                Err(e) => match dlg.token(e) {
13257                    Ok(token) => token,
13258                    Err(e) => {
13259                        dlg.finished(false);
13260                        return Err(common::Error::MissingToken(e));
13261                    }
13262                },
13263            };
13264            request_value_reader
13265                .seek(std::io::SeekFrom::Start(0))
13266                .unwrap();
13267            let mut req_result = {
13268                let client = &self.hub.client;
13269                dlg.pre_request();
13270                let mut req_builder = hyper::Request::builder()
13271                    .method(hyper::Method::POST)
13272                    .uri(url.as_str())
13273                    .header(USER_AGENT, self.hub._user_agent.clone());
13274
13275                if let Some(token) = token.as_ref() {
13276                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13277                }
13278
13279                let request = req_builder
13280                    .header(CONTENT_TYPE, json_mime_type.to_string())
13281                    .header(CONTENT_LENGTH, request_size as u64)
13282                    .body(common::to_body(
13283                        request_value_reader.get_ref().clone().into(),
13284                    ));
13285
13286                client.request(request.unwrap()).await
13287            };
13288
13289            match req_result {
13290                Err(err) => {
13291                    if let common::Retry::After(d) = dlg.http_error(&err) {
13292                        sleep(d).await;
13293                        continue;
13294                    }
13295                    dlg.finished(false);
13296                    return Err(common::Error::HttpError(err));
13297                }
13298                Ok(res) => {
13299                    let (mut parts, body) = res.into_parts();
13300                    let mut body = common::Body::new(body);
13301                    if !parts.status.is_success() {
13302                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13303                        let error = serde_json::from_str(&common::to_string(&bytes));
13304                        let response = common::to_response(parts, bytes.into());
13305
13306                        if let common::Retry::After(d) =
13307                            dlg.http_failure(&response, error.as_ref().ok())
13308                        {
13309                            sleep(d).await;
13310                            continue;
13311                        }
13312
13313                        dlg.finished(false);
13314
13315                        return Err(match error {
13316                            Ok(value) => common::Error::BadRequest(value),
13317                            _ => common::Error::Failure(response),
13318                        });
13319                    }
13320                    let response = {
13321                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13322                        let encoded = common::to_string(&bytes);
13323                        match serde_json::from_str(&encoded) {
13324                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13325                            Err(error) => {
13326                                dlg.response_json_decode_error(&encoded, &error);
13327                                return Err(common::Error::JsonDecodeError(
13328                                    encoded.to_string(),
13329                                    error,
13330                                ));
13331                            }
13332                        }
13333                    };
13334
13335                    dlg.finished(true);
13336                    return Ok(response);
13337                }
13338            }
13339        }
13340    }
13341
13342    ///
13343    /// Sets the *request* property to the given value.
13344    ///
13345    /// Even though the property as already been set when instantiating this call,
13346    /// we provide this method for API completeness.
13347    pub fn request(
13348        mut self,
13349        new_value: GoogleCloudMlV1__SetDefaultVersionRequest,
13350    ) -> ProjectModelVersionSetDefaultCall<'a, C> {
13351        self._request = new_value;
13352        self
13353    }
13354    /// Required. The name of the version to make the default for the model. You can get the names of all the versions of a model by calling projects.models.versions.list.
13355    ///
13356    /// Sets the *name* path property to the given value.
13357    ///
13358    /// Even though the property as already been set when instantiating this call,
13359    /// we provide this method for API completeness.
13360    pub fn name(mut self, new_value: &str) -> ProjectModelVersionSetDefaultCall<'a, C> {
13361        self._name = new_value.to_string();
13362        self
13363    }
13364    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13365    /// while executing the actual API request.
13366    ///
13367    /// ````text
13368    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13369    /// ````
13370    ///
13371    /// Sets the *delegate* property to the given value.
13372    pub fn delegate(
13373        mut self,
13374        new_value: &'a mut dyn common::Delegate,
13375    ) -> ProjectModelVersionSetDefaultCall<'a, C> {
13376        self._delegate = Some(new_value);
13377        self
13378    }
13379
13380    /// Set any additional parameter of the query string used in the request.
13381    /// It should be used to set parameters which are not yet available through their own
13382    /// setters.
13383    ///
13384    /// Please note that this method must not be used to set any of the known parameters
13385    /// which have their own setter method. If done anyway, the request will fail.
13386    ///
13387    /// # Additional Parameters
13388    ///
13389    /// * *$.xgafv* (query-string) - V1 error format.
13390    /// * *access_token* (query-string) - OAuth access token.
13391    /// * *alt* (query-string) - Data format for response.
13392    /// * *callback* (query-string) - JSONP
13393    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13394    /// * *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.
13395    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13396    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13397    /// * *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.
13398    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13399    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13400    pub fn param<T>(mut self, name: T, value: T) -> ProjectModelVersionSetDefaultCall<'a, C>
13401    where
13402        T: AsRef<str>,
13403    {
13404        self._additional_params
13405            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13406        self
13407    }
13408
13409    /// Identifies the authorization scope for the method you are building.
13410    ///
13411    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13412    /// [`Scope::CloudPlatform`].
13413    ///
13414    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13415    /// tokens for more than one scope.
13416    ///
13417    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13418    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13419    /// sufficient, a read-write scope will do as well.
13420    pub fn add_scope<St>(mut self, scope: St) -> ProjectModelVersionSetDefaultCall<'a, C>
13421    where
13422        St: AsRef<str>,
13423    {
13424        self._scopes.insert(String::from(scope.as_ref()));
13425        self
13426    }
13427    /// Identifies the authorization scope(s) for the method you are building.
13428    ///
13429    /// See [`Self::add_scope()`] for details.
13430    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectModelVersionSetDefaultCall<'a, C>
13431    where
13432        I: IntoIterator<Item = St>,
13433        St: AsRef<str>,
13434    {
13435        self._scopes
13436            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13437        self
13438    }
13439
13440    /// Removes all scopes, and no default scope will be used either.
13441    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13442    /// for details).
13443    pub fn clear_scopes(mut self) -> ProjectModelVersionSetDefaultCall<'a, C> {
13444        self._scopes.clear();
13445        self
13446    }
13447}
13448
13449/// Creates a model which will later contain one or more versions. You must add at least one version before you can request predictions from the model. Add versions by calling projects.models.versions.create.
13450///
13451/// A builder for the *models.create* method supported by a *project* resource.
13452/// It is not used directly, but through a [`ProjectMethods`] instance.
13453///
13454/// # Example
13455///
13456/// Instantiate a resource method builder
13457///
13458/// ```test_harness,no_run
13459/// # extern crate hyper;
13460/// # extern crate hyper_rustls;
13461/// # extern crate google_ml1 as ml1;
13462/// use ml1::api::GoogleCloudMlV1__Model;
13463/// # async fn dox() {
13464/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13465///
13466/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13467/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13468/// #     .with_native_roots()
13469/// #     .unwrap()
13470/// #     .https_only()
13471/// #     .enable_http2()
13472/// #     .build();
13473///
13474/// # let executor = hyper_util::rt::TokioExecutor::new();
13475/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13476/// #     secret,
13477/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13478/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13479/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13480/// #     ),
13481/// # ).build().await.unwrap();
13482///
13483/// # let client = hyper_util::client::legacy::Client::builder(
13484/// #     hyper_util::rt::TokioExecutor::new()
13485/// # )
13486/// # .build(
13487/// #     hyper_rustls::HttpsConnectorBuilder::new()
13488/// #         .with_native_roots()
13489/// #         .unwrap()
13490/// #         .https_or_http()
13491/// #         .enable_http2()
13492/// #         .build()
13493/// # );
13494/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
13495/// // As the method needs a request, you would usually fill it with the desired information
13496/// // into the respective structure. Some of the parts shown here might not be applicable !
13497/// // Values shown here are possibly random and not representative !
13498/// let mut req = GoogleCloudMlV1__Model::default();
13499///
13500/// // You can configure optional parameters by calling the respective setters at will, and
13501/// // execute the final call using `doit()`.
13502/// // Values shown here are possibly random and not representative !
13503/// let result = hub.projects().models_create(req, "parent")
13504///              .doit().await;
13505/// # }
13506/// ```
13507pub struct ProjectModelCreateCall<'a, C>
13508where
13509    C: 'a,
13510{
13511    hub: &'a CloudMachineLearningEngine<C>,
13512    _request: GoogleCloudMlV1__Model,
13513    _parent: String,
13514    _delegate: Option<&'a mut dyn common::Delegate>,
13515    _additional_params: HashMap<String, String>,
13516    _scopes: BTreeSet<String>,
13517}
13518
13519impl<'a, C> common::CallBuilder for ProjectModelCreateCall<'a, C> {}
13520
13521impl<'a, C> ProjectModelCreateCall<'a, C>
13522where
13523    C: common::Connector,
13524{
13525    /// Perform the operation you have build so far.
13526    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleCloudMlV1__Model)> {
13527        use std::borrow::Cow;
13528        use std::io::{Read, Seek};
13529
13530        use common::{url::Params, ToParts};
13531        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13532
13533        let mut dd = common::DefaultDelegate;
13534        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13535        dlg.begin(common::MethodInfo {
13536            id: "ml.projects.models.create",
13537            http_method: hyper::Method::POST,
13538        });
13539
13540        for &field in ["alt", "parent"].iter() {
13541            if self._additional_params.contains_key(field) {
13542                dlg.finished(false);
13543                return Err(common::Error::FieldClash(field));
13544            }
13545        }
13546
13547        let mut params = Params::with_capacity(4 + self._additional_params.len());
13548        params.push("parent", self._parent);
13549
13550        params.extend(self._additional_params.iter());
13551
13552        params.push("alt", "json");
13553        let mut url = self.hub._base_url.clone() + "v1/{+parent}/models";
13554        if self._scopes.is_empty() {
13555            self._scopes
13556                .insert(Scope::CloudPlatform.as_ref().to_string());
13557        }
13558
13559        #[allow(clippy::single_element_loop)]
13560        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
13561            url = params.uri_replacement(url, param_name, find_this, true);
13562        }
13563        {
13564            let to_remove = ["parent"];
13565            params.remove_params(&to_remove);
13566        }
13567
13568        let url = params.parse_with_url(&url);
13569
13570        let mut json_mime_type = mime::APPLICATION_JSON;
13571        let mut request_value_reader = {
13572            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13573            common::remove_json_null_values(&mut value);
13574            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13575            serde_json::to_writer(&mut dst, &value).unwrap();
13576            dst
13577        };
13578        let request_size = request_value_reader
13579            .seek(std::io::SeekFrom::End(0))
13580            .unwrap();
13581        request_value_reader
13582            .seek(std::io::SeekFrom::Start(0))
13583            .unwrap();
13584
13585        loop {
13586            let token = match self
13587                .hub
13588                .auth
13589                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13590                .await
13591            {
13592                Ok(token) => token,
13593                Err(e) => match dlg.token(e) {
13594                    Ok(token) => token,
13595                    Err(e) => {
13596                        dlg.finished(false);
13597                        return Err(common::Error::MissingToken(e));
13598                    }
13599                },
13600            };
13601            request_value_reader
13602                .seek(std::io::SeekFrom::Start(0))
13603                .unwrap();
13604            let mut req_result = {
13605                let client = &self.hub.client;
13606                dlg.pre_request();
13607                let mut req_builder = hyper::Request::builder()
13608                    .method(hyper::Method::POST)
13609                    .uri(url.as_str())
13610                    .header(USER_AGENT, self.hub._user_agent.clone());
13611
13612                if let Some(token) = token.as_ref() {
13613                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13614                }
13615
13616                let request = req_builder
13617                    .header(CONTENT_TYPE, json_mime_type.to_string())
13618                    .header(CONTENT_LENGTH, request_size as u64)
13619                    .body(common::to_body(
13620                        request_value_reader.get_ref().clone().into(),
13621                    ));
13622
13623                client.request(request.unwrap()).await
13624            };
13625
13626            match req_result {
13627                Err(err) => {
13628                    if let common::Retry::After(d) = dlg.http_error(&err) {
13629                        sleep(d).await;
13630                        continue;
13631                    }
13632                    dlg.finished(false);
13633                    return Err(common::Error::HttpError(err));
13634                }
13635                Ok(res) => {
13636                    let (mut parts, body) = res.into_parts();
13637                    let mut body = common::Body::new(body);
13638                    if !parts.status.is_success() {
13639                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13640                        let error = serde_json::from_str(&common::to_string(&bytes));
13641                        let response = common::to_response(parts, bytes.into());
13642
13643                        if let common::Retry::After(d) =
13644                            dlg.http_failure(&response, error.as_ref().ok())
13645                        {
13646                            sleep(d).await;
13647                            continue;
13648                        }
13649
13650                        dlg.finished(false);
13651
13652                        return Err(match error {
13653                            Ok(value) => common::Error::BadRequest(value),
13654                            _ => common::Error::Failure(response),
13655                        });
13656                    }
13657                    let response = {
13658                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13659                        let encoded = common::to_string(&bytes);
13660                        match serde_json::from_str(&encoded) {
13661                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13662                            Err(error) => {
13663                                dlg.response_json_decode_error(&encoded, &error);
13664                                return Err(common::Error::JsonDecodeError(
13665                                    encoded.to_string(),
13666                                    error,
13667                                ));
13668                            }
13669                        }
13670                    };
13671
13672                    dlg.finished(true);
13673                    return Ok(response);
13674                }
13675            }
13676        }
13677    }
13678
13679    ///
13680    /// Sets the *request* property to the given value.
13681    ///
13682    /// Even though the property as already been set when instantiating this call,
13683    /// we provide this method for API completeness.
13684    pub fn request(mut self, new_value: GoogleCloudMlV1__Model) -> ProjectModelCreateCall<'a, C> {
13685        self._request = new_value;
13686        self
13687    }
13688    /// Required. The project name.
13689    ///
13690    /// Sets the *parent* path property to the given value.
13691    ///
13692    /// Even though the property as already been set when instantiating this call,
13693    /// we provide this method for API completeness.
13694    pub fn parent(mut self, new_value: &str) -> ProjectModelCreateCall<'a, C> {
13695        self._parent = new_value.to_string();
13696        self
13697    }
13698    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13699    /// while executing the actual API request.
13700    ///
13701    /// ````text
13702    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13703    /// ````
13704    ///
13705    /// Sets the *delegate* property to the given value.
13706    pub fn delegate(
13707        mut self,
13708        new_value: &'a mut dyn common::Delegate,
13709    ) -> ProjectModelCreateCall<'a, C> {
13710        self._delegate = Some(new_value);
13711        self
13712    }
13713
13714    /// Set any additional parameter of the query string used in the request.
13715    /// It should be used to set parameters which are not yet available through their own
13716    /// setters.
13717    ///
13718    /// Please note that this method must not be used to set any of the known parameters
13719    /// which have their own setter method. If done anyway, the request will fail.
13720    ///
13721    /// # Additional Parameters
13722    ///
13723    /// * *$.xgafv* (query-string) - V1 error format.
13724    /// * *access_token* (query-string) - OAuth access token.
13725    /// * *alt* (query-string) - Data format for response.
13726    /// * *callback* (query-string) - JSONP
13727    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13728    /// * *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.
13729    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13730    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13731    /// * *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.
13732    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13733    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13734    pub fn param<T>(mut self, name: T, value: T) -> ProjectModelCreateCall<'a, C>
13735    where
13736        T: AsRef<str>,
13737    {
13738        self._additional_params
13739            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13740        self
13741    }
13742
13743    /// Identifies the authorization scope for the method you are building.
13744    ///
13745    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13746    /// [`Scope::CloudPlatform`].
13747    ///
13748    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13749    /// tokens for more than one scope.
13750    ///
13751    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13752    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13753    /// sufficient, a read-write scope will do as well.
13754    pub fn add_scope<St>(mut self, scope: St) -> ProjectModelCreateCall<'a, C>
13755    where
13756        St: AsRef<str>,
13757    {
13758        self._scopes.insert(String::from(scope.as_ref()));
13759        self
13760    }
13761    /// Identifies the authorization scope(s) for the method you are building.
13762    ///
13763    /// See [`Self::add_scope()`] for details.
13764    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectModelCreateCall<'a, C>
13765    where
13766        I: IntoIterator<Item = St>,
13767        St: AsRef<str>,
13768    {
13769        self._scopes
13770            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13771        self
13772    }
13773
13774    /// Removes all scopes, and no default scope will be used either.
13775    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13776    /// for details).
13777    pub fn clear_scopes(mut self) -> ProjectModelCreateCall<'a, C> {
13778        self._scopes.clear();
13779        self
13780    }
13781}
13782
13783/// Deletes a model. You can only delete a model if there are no versions in it. You can delete versions by calling projects.models.versions.delete.
13784///
13785/// A builder for the *models.delete* method supported by a *project* resource.
13786/// It is not used directly, but through a [`ProjectMethods`] instance.
13787///
13788/// # Example
13789///
13790/// Instantiate a resource method builder
13791///
13792/// ```test_harness,no_run
13793/// # extern crate hyper;
13794/// # extern crate hyper_rustls;
13795/// # extern crate google_ml1 as ml1;
13796/// # async fn dox() {
13797/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13798///
13799/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13800/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13801/// #     .with_native_roots()
13802/// #     .unwrap()
13803/// #     .https_only()
13804/// #     .enable_http2()
13805/// #     .build();
13806///
13807/// # let executor = hyper_util::rt::TokioExecutor::new();
13808/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13809/// #     secret,
13810/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13811/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13812/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13813/// #     ),
13814/// # ).build().await.unwrap();
13815///
13816/// # let client = hyper_util::client::legacy::Client::builder(
13817/// #     hyper_util::rt::TokioExecutor::new()
13818/// # )
13819/// # .build(
13820/// #     hyper_rustls::HttpsConnectorBuilder::new()
13821/// #         .with_native_roots()
13822/// #         .unwrap()
13823/// #         .https_or_http()
13824/// #         .enable_http2()
13825/// #         .build()
13826/// # );
13827/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
13828/// // You can configure optional parameters by calling the respective setters at will, and
13829/// // execute the final call using `doit()`.
13830/// // Values shown here are possibly random and not representative !
13831/// let result = hub.projects().models_delete("name")
13832///              .doit().await;
13833/// # }
13834/// ```
13835pub struct ProjectModelDeleteCall<'a, C>
13836where
13837    C: 'a,
13838{
13839    hub: &'a CloudMachineLearningEngine<C>,
13840    _name: String,
13841    _delegate: Option<&'a mut dyn common::Delegate>,
13842    _additional_params: HashMap<String, String>,
13843    _scopes: BTreeSet<String>,
13844}
13845
13846impl<'a, C> common::CallBuilder for ProjectModelDeleteCall<'a, C> {}
13847
13848impl<'a, C> ProjectModelDeleteCall<'a, C>
13849where
13850    C: common::Connector,
13851{
13852    /// Perform the operation you have build so far.
13853    pub async fn doit(
13854        mut self,
13855    ) -> common::Result<(common::Response, GoogleLongrunning__Operation)> {
13856        use std::borrow::Cow;
13857        use std::io::{Read, Seek};
13858
13859        use common::{url::Params, ToParts};
13860        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13861
13862        let mut dd = common::DefaultDelegate;
13863        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13864        dlg.begin(common::MethodInfo {
13865            id: "ml.projects.models.delete",
13866            http_method: hyper::Method::DELETE,
13867        });
13868
13869        for &field in ["alt", "name"].iter() {
13870            if self._additional_params.contains_key(field) {
13871                dlg.finished(false);
13872                return Err(common::Error::FieldClash(field));
13873            }
13874        }
13875
13876        let mut params = Params::with_capacity(3 + self._additional_params.len());
13877        params.push("name", self._name);
13878
13879        params.extend(self._additional_params.iter());
13880
13881        params.push("alt", "json");
13882        let mut url = self.hub._base_url.clone() + "v1/{+name}";
13883        if self._scopes.is_empty() {
13884            self._scopes
13885                .insert(Scope::CloudPlatform.as_ref().to_string());
13886        }
13887
13888        #[allow(clippy::single_element_loop)]
13889        for &(find_this, param_name) in [("{+name}", "name")].iter() {
13890            url = params.uri_replacement(url, param_name, find_this, true);
13891        }
13892        {
13893            let to_remove = ["name"];
13894            params.remove_params(&to_remove);
13895        }
13896
13897        let url = params.parse_with_url(&url);
13898
13899        loop {
13900            let token = match self
13901                .hub
13902                .auth
13903                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13904                .await
13905            {
13906                Ok(token) => token,
13907                Err(e) => match dlg.token(e) {
13908                    Ok(token) => token,
13909                    Err(e) => {
13910                        dlg.finished(false);
13911                        return Err(common::Error::MissingToken(e));
13912                    }
13913                },
13914            };
13915            let mut req_result = {
13916                let client = &self.hub.client;
13917                dlg.pre_request();
13918                let mut req_builder = hyper::Request::builder()
13919                    .method(hyper::Method::DELETE)
13920                    .uri(url.as_str())
13921                    .header(USER_AGENT, self.hub._user_agent.clone());
13922
13923                if let Some(token) = token.as_ref() {
13924                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13925                }
13926
13927                let request = req_builder
13928                    .header(CONTENT_LENGTH, 0_u64)
13929                    .body(common::to_body::<String>(None));
13930
13931                client.request(request.unwrap()).await
13932            };
13933
13934            match req_result {
13935                Err(err) => {
13936                    if let common::Retry::After(d) = dlg.http_error(&err) {
13937                        sleep(d).await;
13938                        continue;
13939                    }
13940                    dlg.finished(false);
13941                    return Err(common::Error::HttpError(err));
13942                }
13943                Ok(res) => {
13944                    let (mut parts, body) = res.into_parts();
13945                    let mut body = common::Body::new(body);
13946                    if !parts.status.is_success() {
13947                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13948                        let error = serde_json::from_str(&common::to_string(&bytes));
13949                        let response = common::to_response(parts, bytes.into());
13950
13951                        if let common::Retry::After(d) =
13952                            dlg.http_failure(&response, error.as_ref().ok())
13953                        {
13954                            sleep(d).await;
13955                            continue;
13956                        }
13957
13958                        dlg.finished(false);
13959
13960                        return Err(match error {
13961                            Ok(value) => common::Error::BadRequest(value),
13962                            _ => common::Error::Failure(response),
13963                        });
13964                    }
13965                    let response = {
13966                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13967                        let encoded = common::to_string(&bytes);
13968                        match serde_json::from_str(&encoded) {
13969                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13970                            Err(error) => {
13971                                dlg.response_json_decode_error(&encoded, &error);
13972                                return Err(common::Error::JsonDecodeError(
13973                                    encoded.to_string(),
13974                                    error,
13975                                ));
13976                            }
13977                        }
13978                    };
13979
13980                    dlg.finished(true);
13981                    return Ok(response);
13982                }
13983            }
13984        }
13985    }
13986
13987    /// Required. The name of the model.
13988    ///
13989    /// Sets the *name* path property to the given value.
13990    ///
13991    /// Even though the property as already been set when instantiating this call,
13992    /// we provide this method for API completeness.
13993    pub fn name(mut self, new_value: &str) -> ProjectModelDeleteCall<'a, C> {
13994        self._name = new_value.to_string();
13995        self
13996    }
13997    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13998    /// while executing the actual API request.
13999    ///
14000    /// ````text
14001    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14002    /// ````
14003    ///
14004    /// Sets the *delegate* property to the given value.
14005    pub fn delegate(
14006        mut self,
14007        new_value: &'a mut dyn common::Delegate,
14008    ) -> ProjectModelDeleteCall<'a, C> {
14009        self._delegate = Some(new_value);
14010        self
14011    }
14012
14013    /// Set any additional parameter of the query string used in the request.
14014    /// It should be used to set parameters which are not yet available through their own
14015    /// setters.
14016    ///
14017    /// Please note that this method must not be used to set any of the known parameters
14018    /// which have their own setter method. If done anyway, the request will fail.
14019    ///
14020    /// # Additional Parameters
14021    ///
14022    /// * *$.xgafv* (query-string) - V1 error format.
14023    /// * *access_token* (query-string) - OAuth access token.
14024    /// * *alt* (query-string) - Data format for response.
14025    /// * *callback* (query-string) - JSONP
14026    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14027    /// * *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.
14028    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14029    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14030    /// * *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.
14031    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14032    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14033    pub fn param<T>(mut self, name: T, value: T) -> ProjectModelDeleteCall<'a, C>
14034    where
14035        T: AsRef<str>,
14036    {
14037        self._additional_params
14038            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14039        self
14040    }
14041
14042    /// Identifies the authorization scope for the method you are building.
14043    ///
14044    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14045    /// [`Scope::CloudPlatform`].
14046    ///
14047    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14048    /// tokens for more than one scope.
14049    ///
14050    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14051    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14052    /// sufficient, a read-write scope will do as well.
14053    pub fn add_scope<St>(mut self, scope: St) -> ProjectModelDeleteCall<'a, C>
14054    where
14055        St: AsRef<str>,
14056    {
14057        self._scopes.insert(String::from(scope.as_ref()));
14058        self
14059    }
14060    /// Identifies the authorization scope(s) for the method you are building.
14061    ///
14062    /// See [`Self::add_scope()`] for details.
14063    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectModelDeleteCall<'a, C>
14064    where
14065        I: IntoIterator<Item = St>,
14066        St: AsRef<str>,
14067    {
14068        self._scopes
14069            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14070        self
14071    }
14072
14073    /// Removes all scopes, and no default scope will be used either.
14074    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14075    /// for details).
14076    pub fn clear_scopes(mut self) -> ProjectModelDeleteCall<'a, C> {
14077        self._scopes.clear();
14078        self
14079    }
14080}
14081
14082/// Gets information about a model, including its name, the description (if set), and the default version (if at least one version of the model has been deployed).
14083///
14084/// A builder for the *models.get* method supported by a *project* resource.
14085/// It is not used directly, but through a [`ProjectMethods`] instance.
14086///
14087/// # Example
14088///
14089/// Instantiate a resource method builder
14090///
14091/// ```test_harness,no_run
14092/// # extern crate hyper;
14093/// # extern crate hyper_rustls;
14094/// # extern crate google_ml1 as ml1;
14095/// # async fn dox() {
14096/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14097///
14098/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14099/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14100/// #     .with_native_roots()
14101/// #     .unwrap()
14102/// #     .https_only()
14103/// #     .enable_http2()
14104/// #     .build();
14105///
14106/// # let executor = hyper_util::rt::TokioExecutor::new();
14107/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14108/// #     secret,
14109/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14110/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14111/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14112/// #     ),
14113/// # ).build().await.unwrap();
14114///
14115/// # let client = hyper_util::client::legacy::Client::builder(
14116/// #     hyper_util::rt::TokioExecutor::new()
14117/// # )
14118/// # .build(
14119/// #     hyper_rustls::HttpsConnectorBuilder::new()
14120/// #         .with_native_roots()
14121/// #         .unwrap()
14122/// #         .https_or_http()
14123/// #         .enable_http2()
14124/// #         .build()
14125/// # );
14126/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
14127/// // You can configure optional parameters by calling the respective setters at will, and
14128/// // execute the final call using `doit()`.
14129/// // Values shown here are possibly random and not representative !
14130/// let result = hub.projects().models_get("name")
14131///              .doit().await;
14132/// # }
14133/// ```
14134pub struct ProjectModelGetCall<'a, C>
14135where
14136    C: 'a,
14137{
14138    hub: &'a CloudMachineLearningEngine<C>,
14139    _name: String,
14140    _delegate: Option<&'a mut dyn common::Delegate>,
14141    _additional_params: HashMap<String, String>,
14142    _scopes: BTreeSet<String>,
14143}
14144
14145impl<'a, C> common::CallBuilder for ProjectModelGetCall<'a, C> {}
14146
14147impl<'a, C> ProjectModelGetCall<'a, C>
14148where
14149    C: common::Connector,
14150{
14151    /// Perform the operation you have build so far.
14152    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleCloudMlV1__Model)> {
14153        use std::borrow::Cow;
14154        use std::io::{Read, Seek};
14155
14156        use common::{url::Params, ToParts};
14157        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14158
14159        let mut dd = common::DefaultDelegate;
14160        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14161        dlg.begin(common::MethodInfo {
14162            id: "ml.projects.models.get",
14163            http_method: hyper::Method::GET,
14164        });
14165
14166        for &field in ["alt", "name"].iter() {
14167            if self._additional_params.contains_key(field) {
14168                dlg.finished(false);
14169                return Err(common::Error::FieldClash(field));
14170            }
14171        }
14172
14173        let mut params = Params::with_capacity(3 + self._additional_params.len());
14174        params.push("name", self._name);
14175
14176        params.extend(self._additional_params.iter());
14177
14178        params.push("alt", "json");
14179        let mut url = self.hub._base_url.clone() + "v1/{+name}";
14180        if self._scopes.is_empty() {
14181            self._scopes
14182                .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
14183        }
14184
14185        #[allow(clippy::single_element_loop)]
14186        for &(find_this, param_name) in [("{+name}", "name")].iter() {
14187            url = params.uri_replacement(url, param_name, find_this, true);
14188        }
14189        {
14190            let to_remove = ["name"];
14191            params.remove_params(&to_remove);
14192        }
14193
14194        let url = params.parse_with_url(&url);
14195
14196        loop {
14197            let token = match self
14198                .hub
14199                .auth
14200                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14201                .await
14202            {
14203                Ok(token) => token,
14204                Err(e) => match dlg.token(e) {
14205                    Ok(token) => token,
14206                    Err(e) => {
14207                        dlg.finished(false);
14208                        return Err(common::Error::MissingToken(e));
14209                    }
14210                },
14211            };
14212            let mut req_result = {
14213                let client = &self.hub.client;
14214                dlg.pre_request();
14215                let mut req_builder = hyper::Request::builder()
14216                    .method(hyper::Method::GET)
14217                    .uri(url.as_str())
14218                    .header(USER_AGENT, self.hub._user_agent.clone());
14219
14220                if let Some(token) = token.as_ref() {
14221                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14222                }
14223
14224                let request = req_builder
14225                    .header(CONTENT_LENGTH, 0_u64)
14226                    .body(common::to_body::<String>(None));
14227
14228                client.request(request.unwrap()).await
14229            };
14230
14231            match req_result {
14232                Err(err) => {
14233                    if let common::Retry::After(d) = dlg.http_error(&err) {
14234                        sleep(d).await;
14235                        continue;
14236                    }
14237                    dlg.finished(false);
14238                    return Err(common::Error::HttpError(err));
14239                }
14240                Ok(res) => {
14241                    let (mut parts, body) = res.into_parts();
14242                    let mut body = common::Body::new(body);
14243                    if !parts.status.is_success() {
14244                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14245                        let error = serde_json::from_str(&common::to_string(&bytes));
14246                        let response = common::to_response(parts, bytes.into());
14247
14248                        if let common::Retry::After(d) =
14249                            dlg.http_failure(&response, error.as_ref().ok())
14250                        {
14251                            sleep(d).await;
14252                            continue;
14253                        }
14254
14255                        dlg.finished(false);
14256
14257                        return Err(match error {
14258                            Ok(value) => common::Error::BadRequest(value),
14259                            _ => common::Error::Failure(response),
14260                        });
14261                    }
14262                    let response = {
14263                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14264                        let encoded = common::to_string(&bytes);
14265                        match serde_json::from_str(&encoded) {
14266                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14267                            Err(error) => {
14268                                dlg.response_json_decode_error(&encoded, &error);
14269                                return Err(common::Error::JsonDecodeError(
14270                                    encoded.to_string(),
14271                                    error,
14272                                ));
14273                            }
14274                        }
14275                    };
14276
14277                    dlg.finished(true);
14278                    return Ok(response);
14279                }
14280            }
14281        }
14282    }
14283
14284    /// Required. The name of the model.
14285    ///
14286    /// Sets the *name* path property to the given value.
14287    ///
14288    /// Even though the property as already been set when instantiating this call,
14289    /// we provide this method for API completeness.
14290    pub fn name(mut self, new_value: &str) -> ProjectModelGetCall<'a, C> {
14291        self._name = new_value.to_string();
14292        self
14293    }
14294    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14295    /// while executing the actual API request.
14296    ///
14297    /// ````text
14298    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14299    /// ````
14300    ///
14301    /// Sets the *delegate* property to the given value.
14302    pub fn delegate(
14303        mut self,
14304        new_value: &'a mut dyn common::Delegate,
14305    ) -> ProjectModelGetCall<'a, C> {
14306        self._delegate = Some(new_value);
14307        self
14308    }
14309
14310    /// Set any additional parameter of the query string used in the request.
14311    /// It should be used to set parameters which are not yet available through their own
14312    /// setters.
14313    ///
14314    /// Please note that this method must not be used to set any of the known parameters
14315    /// which have their own setter method. If done anyway, the request will fail.
14316    ///
14317    /// # Additional Parameters
14318    ///
14319    /// * *$.xgafv* (query-string) - V1 error format.
14320    /// * *access_token* (query-string) - OAuth access token.
14321    /// * *alt* (query-string) - Data format for response.
14322    /// * *callback* (query-string) - JSONP
14323    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14324    /// * *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.
14325    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14326    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14327    /// * *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.
14328    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14329    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14330    pub fn param<T>(mut self, name: T, value: T) -> ProjectModelGetCall<'a, C>
14331    where
14332        T: AsRef<str>,
14333    {
14334        self._additional_params
14335            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14336        self
14337    }
14338
14339    /// Identifies the authorization scope for the method you are building.
14340    ///
14341    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14342    /// [`Scope::CloudPlatformReadOnly`].
14343    ///
14344    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14345    /// tokens for more than one scope.
14346    ///
14347    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14348    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14349    /// sufficient, a read-write scope will do as well.
14350    pub fn add_scope<St>(mut self, scope: St) -> ProjectModelGetCall<'a, C>
14351    where
14352        St: AsRef<str>,
14353    {
14354        self._scopes.insert(String::from(scope.as_ref()));
14355        self
14356    }
14357    /// Identifies the authorization scope(s) for the method you are building.
14358    ///
14359    /// See [`Self::add_scope()`] for details.
14360    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectModelGetCall<'a, C>
14361    where
14362        I: IntoIterator<Item = St>,
14363        St: AsRef<str>,
14364    {
14365        self._scopes
14366            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14367        self
14368    }
14369
14370    /// Removes all scopes, and no default scope will be used either.
14371    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14372    /// for details).
14373    pub fn clear_scopes(mut self) -> ProjectModelGetCall<'a, C> {
14374        self._scopes.clear();
14375        self
14376    }
14377}
14378
14379/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
14380///
14381/// A builder for the *models.getIamPolicy* method supported by a *project* resource.
14382/// It is not used directly, but through a [`ProjectMethods`] instance.
14383///
14384/// # Example
14385///
14386/// Instantiate a resource method builder
14387///
14388/// ```test_harness,no_run
14389/// # extern crate hyper;
14390/// # extern crate hyper_rustls;
14391/// # extern crate google_ml1 as ml1;
14392/// # async fn dox() {
14393/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14394///
14395/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14396/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14397/// #     .with_native_roots()
14398/// #     .unwrap()
14399/// #     .https_only()
14400/// #     .enable_http2()
14401/// #     .build();
14402///
14403/// # let executor = hyper_util::rt::TokioExecutor::new();
14404/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14405/// #     secret,
14406/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14407/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14408/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14409/// #     ),
14410/// # ).build().await.unwrap();
14411///
14412/// # let client = hyper_util::client::legacy::Client::builder(
14413/// #     hyper_util::rt::TokioExecutor::new()
14414/// # )
14415/// # .build(
14416/// #     hyper_rustls::HttpsConnectorBuilder::new()
14417/// #         .with_native_roots()
14418/// #         .unwrap()
14419/// #         .https_or_http()
14420/// #         .enable_http2()
14421/// #         .build()
14422/// # );
14423/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
14424/// // You can configure optional parameters by calling the respective setters at will, and
14425/// // execute the final call using `doit()`.
14426/// // Values shown here are possibly random and not representative !
14427/// let result = hub.projects().models_get_iam_policy("resource")
14428///              .options_requested_policy_version(-31)
14429///              .doit().await;
14430/// # }
14431/// ```
14432pub struct ProjectModelGetIamPolicyCall<'a, C>
14433where
14434    C: 'a,
14435{
14436    hub: &'a CloudMachineLearningEngine<C>,
14437    _resource: String,
14438    _options_requested_policy_version: Option<i32>,
14439    _delegate: Option<&'a mut dyn common::Delegate>,
14440    _additional_params: HashMap<String, String>,
14441    _scopes: BTreeSet<String>,
14442}
14443
14444impl<'a, C> common::CallBuilder for ProjectModelGetIamPolicyCall<'a, C> {}
14445
14446impl<'a, C> ProjectModelGetIamPolicyCall<'a, C>
14447where
14448    C: common::Connector,
14449{
14450    /// Perform the operation you have build so far.
14451    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleIamV1__Policy)> {
14452        use std::borrow::Cow;
14453        use std::io::{Read, Seek};
14454
14455        use common::{url::Params, ToParts};
14456        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14457
14458        let mut dd = common::DefaultDelegate;
14459        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14460        dlg.begin(common::MethodInfo {
14461            id: "ml.projects.models.getIamPolicy",
14462            http_method: hyper::Method::GET,
14463        });
14464
14465        for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
14466            if self._additional_params.contains_key(field) {
14467                dlg.finished(false);
14468                return Err(common::Error::FieldClash(field));
14469            }
14470        }
14471
14472        let mut params = Params::with_capacity(4 + self._additional_params.len());
14473        params.push("resource", self._resource);
14474        if let Some(value) = self._options_requested_policy_version.as_ref() {
14475            params.push("options.requestedPolicyVersion", value.to_string());
14476        }
14477
14478        params.extend(self._additional_params.iter());
14479
14480        params.push("alt", "json");
14481        let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
14482        if self._scopes.is_empty() {
14483            self._scopes
14484                .insert(Scope::CloudPlatform.as_ref().to_string());
14485        }
14486
14487        #[allow(clippy::single_element_loop)]
14488        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
14489            url = params.uri_replacement(url, param_name, find_this, true);
14490        }
14491        {
14492            let to_remove = ["resource"];
14493            params.remove_params(&to_remove);
14494        }
14495
14496        let url = params.parse_with_url(&url);
14497
14498        loop {
14499            let token = match self
14500                .hub
14501                .auth
14502                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14503                .await
14504            {
14505                Ok(token) => token,
14506                Err(e) => match dlg.token(e) {
14507                    Ok(token) => token,
14508                    Err(e) => {
14509                        dlg.finished(false);
14510                        return Err(common::Error::MissingToken(e));
14511                    }
14512                },
14513            };
14514            let mut req_result = {
14515                let client = &self.hub.client;
14516                dlg.pre_request();
14517                let mut req_builder = hyper::Request::builder()
14518                    .method(hyper::Method::GET)
14519                    .uri(url.as_str())
14520                    .header(USER_AGENT, self.hub._user_agent.clone());
14521
14522                if let Some(token) = token.as_ref() {
14523                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14524                }
14525
14526                let request = req_builder
14527                    .header(CONTENT_LENGTH, 0_u64)
14528                    .body(common::to_body::<String>(None));
14529
14530                client.request(request.unwrap()).await
14531            };
14532
14533            match req_result {
14534                Err(err) => {
14535                    if let common::Retry::After(d) = dlg.http_error(&err) {
14536                        sleep(d).await;
14537                        continue;
14538                    }
14539                    dlg.finished(false);
14540                    return Err(common::Error::HttpError(err));
14541                }
14542                Ok(res) => {
14543                    let (mut parts, body) = res.into_parts();
14544                    let mut body = common::Body::new(body);
14545                    if !parts.status.is_success() {
14546                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14547                        let error = serde_json::from_str(&common::to_string(&bytes));
14548                        let response = common::to_response(parts, bytes.into());
14549
14550                        if let common::Retry::After(d) =
14551                            dlg.http_failure(&response, error.as_ref().ok())
14552                        {
14553                            sleep(d).await;
14554                            continue;
14555                        }
14556
14557                        dlg.finished(false);
14558
14559                        return Err(match error {
14560                            Ok(value) => common::Error::BadRequest(value),
14561                            _ => common::Error::Failure(response),
14562                        });
14563                    }
14564                    let response = {
14565                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14566                        let encoded = common::to_string(&bytes);
14567                        match serde_json::from_str(&encoded) {
14568                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14569                            Err(error) => {
14570                                dlg.response_json_decode_error(&encoded, &error);
14571                                return Err(common::Error::JsonDecodeError(
14572                                    encoded.to_string(),
14573                                    error,
14574                                ));
14575                            }
14576                        }
14577                    };
14578
14579                    dlg.finished(true);
14580                    return Ok(response);
14581                }
14582            }
14583        }
14584    }
14585
14586    /// REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
14587    ///
14588    /// Sets the *resource* path property to the given value.
14589    ///
14590    /// Even though the property as already been set when instantiating this call,
14591    /// we provide this method for API completeness.
14592    pub fn resource(mut self, new_value: &str) -> ProjectModelGetIamPolicyCall<'a, C> {
14593        self._resource = new_value.to_string();
14594        self
14595    }
14596    /// Optional. The maximum policy version that will be used to format the policy. Valid values are 0, 1, and 3. Requests specifying an invalid value will be rejected. Requests for policies with any conditional role bindings must specify version 3. Policies with no conditional role bindings may specify any valid value or leave the field unset. The policy in the response might use the policy version that you specified, or it might use a lower policy version. For example, if you specify version 3, but the policy has no conditional role bindings, the response uses version 1. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
14597    ///
14598    /// Sets the *options.requested policy version* query property to the given value.
14599    pub fn options_requested_policy_version(
14600        mut self,
14601        new_value: i32,
14602    ) -> ProjectModelGetIamPolicyCall<'a, C> {
14603        self._options_requested_policy_version = Some(new_value);
14604        self
14605    }
14606    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14607    /// while executing the actual API request.
14608    ///
14609    /// ````text
14610    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14611    /// ````
14612    ///
14613    /// Sets the *delegate* property to the given value.
14614    pub fn delegate(
14615        mut self,
14616        new_value: &'a mut dyn common::Delegate,
14617    ) -> ProjectModelGetIamPolicyCall<'a, C> {
14618        self._delegate = Some(new_value);
14619        self
14620    }
14621
14622    /// Set any additional parameter of the query string used in the request.
14623    /// It should be used to set parameters which are not yet available through their own
14624    /// setters.
14625    ///
14626    /// Please note that this method must not be used to set any of the known parameters
14627    /// which have their own setter method. If done anyway, the request will fail.
14628    ///
14629    /// # Additional Parameters
14630    ///
14631    /// * *$.xgafv* (query-string) - V1 error format.
14632    /// * *access_token* (query-string) - OAuth access token.
14633    /// * *alt* (query-string) - Data format for response.
14634    /// * *callback* (query-string) - JSONP
14635    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14636    /// * *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.
14637    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14638    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14639    /// * *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.
14640    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14641    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14642    pub fn param<T>(mut self, name: T, value: T) -> ProjectModelGetIamPolicyCall<'a, C>
14643    where
14644        T: AsRef<str>,
14645    {
14646        self._additional_params
14647            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14648        self
14649    }
14650
14651    /// Identifies the authorization scope for the method you are building.
14652    ///
14653    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14654    /// [`Scope::CloudPlatform`].
14655    ///
14656    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14657    /// tokens for more than one scope.
14658    ///
14659    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14660    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14661    /// sufficient, a read-write scope will do as well.
14662    pub fn add_scope<St>(mut self, scope: St) -> ProjectModelGetIamPolicyCall<'a, C>
14663    where
14664        St: AsRef<str>,
14665    {
14666        self._scopes.insert(String::from(scope.as_ref()));
14667        self
14668    }
14669    /// Identifies the authorization scope(s) for the method you are building.
14670    ///
14671    /// See [`Self::add_scope()`] for details.
14672    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectModelGetIamPolicyCall<'a, C>
14673    where
14674        I: IntoIterator<Item = St>,
14675        St: AsRef<str>,
14676    {
14677        self._scopes
14678            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14679        self
14680    }
14681
14682    /// Removes all scopes, and no default scope will be used either.
14683    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14684    /// for details).
14685    pub fn clear_scopes(mut self) -> ProjectModelGetIamPolicyCall<'a, C> {
14686        self._scopes.clear();
14687        self
14688    }
14689}
14690
14691/// Lists the models in a project. Each project can contain multiple models, and each model can have multiple versions. If there are no models that match the request parameters, the list request returns an empty response body: {}.
14692///
14693/// A builder for the *models.list* method supported by a *project* resource.
14694/// It is not used directly, but through a [`ProjectMethods`] instance.
14695///
14696/// # Example
14697///
14698/// Instantiate a resource method builder
14699///
14700/// ```test_harness,no_run
14701/// # extern crate hyper;
14702/// # extern crate hyper_rustls;
14703/// # extern crate google_ml1 as ml1;
14704/// # async fn dox() {
14705/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14706///
14707/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14708/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14709/// #     .with_native_roots()
14710/// #     .unwrap()
14711/// #     .https_only()
14712/// #     .enable_http2()
14713/// #     .build();
14714///
14715/// # let executor = hyper_util::rt::TokioExecutor::new();
14716/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14717/// #     secret,
14718/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14719/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14720/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14721/// #     ),
14722/// # ).build().await.unwrap();
14723///
14724/// # let client = hyper_util::client::legacy::Client::builder(
14725/// #     hyper_util::rt::TokioExecutor::new()
14726/// # )
14727/// # .build(
14728/// #     hyper_rustls::HttpsConnectorBuilder::new()
14729/// #         .with_native_roots()
14730/// #         .unwrap()
14731/// #         .https_or_http()
14732/// #         .enable_http2()
14733/// #         .build()
14734/// # );
14735/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
14736/// // You can configure optional parameters by calling the respective setters at will, and
14737/// // execute the final call using `doit()`.
14738/// // Values shown here are possibly random and not representative !
14739/// let result = hub.projects().models_list("parent")
14740///              .page_token("duo")
14741///              .page_size(-34)
14742///              .filter("et")
14743///              .doit().await;
14744/// # }
14745/// ```
14746pub struct ProjectModelListCall<'a, C>
14747where
14748    C: 'a,
14749{
14750    hub: &'a CloudMachineLearningEngine<C>,
14751    _parent: String,
14752    _page_token: Option<String>,
14753    _page_size: Option<i32>,
14754    _filter: Option<String>,
14755    _delegate: Option<&'a mut dyn common::Delegate>,
14756    _additional_params: HashMap<String, String>,
14757    _scopes: BTreeSet<String>,
14758}
14759
14760impl<'a, C> common::CallBuilder for ProjectModelListCall<'a, C> {}
14761
14762impl<'a, C> ProjectModelListCall<'a, C>
14763where
14764    C: common::Connector,
14765{
14766    /// Perform the operation you have build so far.
14767    pub async fn doit(
14768        mut self,
14769    ) -> common::Result<(common::Response, GoogleCloudMlV1__ListModelsResponse)> {
14770        use std::borrow::Cow;
14771        use std::io::{Read, Seek};
14772
14773        use common::{url::Params, ToParts};
14774        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14775
14776        let mut dd = common::DefaultDelegate;
14777        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14778        dlg.begin(common::MethodInfo {
14779            id: "ml.projects.models.list",
14780            http_method: hyper::Method::GET,
14781        });
14782
14783        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
14784            if self._additional_params.contains_key(field) {
14785                dlg.finished(false);
14786                return Err(common::Error::FieldClash(field));
14787            }
14788        }
14789
14790        let mut params = Params::with_capacity(6 + self._additional_params.len());
14791        params.push("parent", self._parent);
14792        if let Some(value) = self._page_token.as_ref() {
14793            params.push("pageToken", value);
14794        }
14795        if let Some(value) = self._page_size.as_ref() {
14796            params.push("pageSize", value.to_string());
14797        }
14798        if let Some(value) = self._filter.as_ref() {
14799            params.push("filter", value);
14800        }
14801
14802        params.extend(self._additional_params.iter());
14803
14804        params.push("alt", "json");
14805        let mut url = self.hub._base_url.clone() + "v1/{+parent}/models";
14806        if self._scopes.is_empty() {
14807            self._scopes
14808                .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
14809        }
14810
14811        #[allow(clippy::single_element_loop)]
14812        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
14813            url = params.uri_replacement(url, param_name, find_this, true);
14814        }
14815        {
14816            let to_remove = ["parent"];
14817            params.remove_params(&to_remove);
14818        }
14819
14820        let url = params.parse_with_url(&url);
14821
14822        loop {
14823            let token = match self
14824                .hub
14825                .auth
14826                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14827                .await
14828            {
14829                Ok(token) => token,
14830                Err(e) => match dlg.token(e) {
14831                    Ok(token) => token,
14832                    Err(e) => {
14833                        dlg.finished(false);
14834                        return Err(common::Error::MissingToken(e));
14835                    }
14836                },
14837            };
14838            let mut req_result = {
14839                let client = &self.hub.client;
14840                dlg.pre_request();
14841                let mut req_builder = hyper::Request::builder()
14842                    .method(hyper::Method::GET)
14843                    .uri(url.as_str())
14844                    .header(USER_AGENT, self.hub._user_agent.clone());
14845
14846                if let Some(token) = token.as_ref() {
14847                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14848                }
14849
14850                let request = req_builder
14851                    .header(CONTENT_LENGTH, 0_u64)
14852                    .body(common::to_body::<String>(None));
14853
14854                client.request(request.unwrap()).await
14855            };
14856
14857            match req_result {
14858                Err(err) => {
14859                    if let common::Retry::After(d) = dlg.http_error(&err) {
14860                        sleep(d).await;
14861                        continue;
14862                    }
14863                    dlg.finished(false);
14864                    return Err(common::Error::HttpError(err));
14865                }
14866                Ok(res) => {
14867                    let (mut parts, body) = res.into_parts();
14868                    let mut body = common::Body::new(body);
14869                    if !parts.status.is_success() {
14870                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14871                        let error = serde_json::from_str(&common::to_string(&bytes));
14872                        let response = common::to_response(parts, bytes.into());
14873
14874                        if let common::Retry::After(d) =
14875                            dlg.http_failure(&response, error.as_ref().ok())
14876                        {
14877                            sleep(d).await;
14878                            continue;
14879                        }
14880
14881                        dlg.finished(false);
14882
14883                        return Err(match error {
14884                            Ok(value) => common::Error::BadRequest(value),
14885                            _ => common::Error::Failure(response),
14886                        });
14887                    }
14888                    let response = {
14889                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14890                        let encoded = common::to_string(&bytes);
14891                        match serde_json::from_str(&encoded) {
14892                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14893                            Err(error) => {
14894                                dlg.response_json_decode_error(&encoded, &error);
14895                                return Err(common::Error::JsonDecodeError(
14896                                    encoded.to_string(),
14897                                    error,
14898                                ));
14899                            }
14900                        }
14901                    };
14902
14903                    dlg.finished(true);
14904                    return Ok(response);
14905                }
14906            }
14907        }
14908    }
14909
14910    /// Required. The name of the project whose models are to be listed.
14911    ///
14912    /// Sets the *parent* path property to the given value.
14913    ///
14914    /// Even though the property as already been set when instantiating this call,
14915    /// we provide this method for API completeness.
14916    pub fn parent(mut self, new_value: &str) -> ProjectModelListCall<'a, C> {
14917        self._parent = new_value.to_string();
14918        self
14919    }
14920    /// Optional. A page token to request the next page of results. You get the token from the `next_page_token` field of the response from the previous call.
14921    ///
14922    /// Sets the *page token* query property to the given value.
14923    pub fn page_token(mut self, new_value: &str) -> ProjectModelListCall<'a, C> {
14924        self._page_token = Some(new_value.to_string());
14925        self
14926    }
14927    /// Optional. The number of models to retrieve per "page" of results. If there are more remaining results than this number, the response message will contain a valid value in the `next_page_token` field. The default value is 20, and the maximum page size is 100.
14928    ///
14929    /// Sets the *page size* query property to the given value.
14930    pub fn page_size(mut self, new_value: i32) -> ProjectModelListCall<'a, C> {
14931        self._page_size = Some(new_value);
14932        self
14933    }
14934    /// Optional. Specifies the subset of models to retrieve.
14935    ///
14936    /// Sets the *filter* query property to the given value.
14937    pub fn filter(mut self, new_value: &str) -> ProjectModelListCall<'a, C> {
14938        self._filter = Some(new_value.to_string());
14939        self
14940    }
14941    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14942    /// while executing the actual API request.
14943    ///
14944    /// ````text
14945    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14946    /// ````
14947    ///
14948    /// Sets the *delegate* property to the given value.
14949    pub fn delegate(
14950        mut self,
14951        new_value: &'a mut dyn common::Delegate,
14952    ) -> ProjectModelListCall<'a, C> {
14953        self._delegate = Some(new_value);
14954        self
14955    }
14956
14957    /// Set any additional parameter of the query string used in the request.
14958    /// It should be used to set parameters which are not yet available through their own
14959    /// setters.
14960    ///
14961    /// Please note that this method must not be used to set any of the known parameters
14962    /// which have their own setter method. If done anyway, the request will fail.
14963    ///
14964    /// # Additional Parameters
14965    ///
14966    /// * *$.xgafv* (query-string) - V1 error format.
14967    /// * *access_token* (query-string) - OAuth access token.
14968    /// * *alt* (query-string) - Data format for response.
14969    /// * *callback* (query-string) - JSONP
14970    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14971    /// * *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.
14972    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14973    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14974    /// * *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.
14975    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14976    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14977    pub fn param<T>(mut self, name: T, value: T) -> ProjectModelListCall<'a, C>
14978    where
14979        T: AsRef<str>,
14980    {
14981        self._additional_params
14982            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14983        self
14984    }
14985
14986    /// Identifies the authorization scope for the method you are building.
14987    ///
14988    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14989    /// [`Scope::CloudPlatformReadOnly`].
14990    ///
14991    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14992    /// tokens for more than one scope.
14993    ///
14994    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14995    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14996    /// sufficient, a read-write scope will do as well.
14997    pub fn add_scope<St>(mut self, scope: St) -> ProjectModelListCall<'a, C>
14998    where
14999        St: AsRef<str>,
15000    {
15001        self._scopes.insert(String::from(scope.as_ref()));
15002        self
15003    }
15004    /// Identifies the authorization scope(s) for the method you are building.
15005    ///
15006    /// See [`Self::add_scope()`] for details.
15007    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectModelListCall<'a, C>
15008    where
15009        I: IntoIterator<Item = St>,
15010        St: AsRef<str>,
15011    {
15012        self._scopes
15013            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15014        self
15015    }
15016
15017    /// Removes all scopes, and no default scope will be used either.
15018    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15019    /// for details).
15020    pub fn clear_scopes(mut self) -> ProjectModelListCall<'a, C> {
15021        self._scopes.clear();
15022        self
15023    }
15024}
15025
15026/// Updates a specific model resource. Currently the only supported fields to update are `description` and `default_version.name`.
15027///
15028/// A builder for the *models.patch* method supported by a *project* resource.
15029/// It is not used directly, but through a [`ProjectMethods`] instance.
15030///
15031/// # Example
15032///
15033/// Instantiate a resource method builder
15034///
15035/// ```test_harness,no_run
15036/// # extern crate hyper;
15037/// # extern crate hyper_rustls;
15038/// # extern crate google_ml1 as ml1;
15039/// use ml1::api::GoogleCloudMlV1__Model;
15040/// # async fn dox() {
15041/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15042///
15043/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15044/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15045/// #     .with_native_roots()
15046/// #     .unwrap()
15047/// #     .https_only()
15048/// #     .enable_http2()
15049/// #     .build();
15050///
15051/// # let executor = hyper_util::rt::TokioExecutor::new();
15052/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15053/// #     secret,
15054/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15055/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15056/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15057/// #     ),
15058/// # ).build().await.unwrap();
15059///
15060/// # let client = hyper_util::client::legacy::Client::builder(
15061/// #     hyper_util::rt::TokioExecutor::new()
15062/// # )
15063/// # .build(
15064/// #     hyper_rustls::HttpsConnectorBuilder::new()
15065/// #         .with_native_roots()
15066/// #         .unwrap()
15067/// #         .https_or_http()
15068/// #         .enable_http2()
15069/// #         .build()
15070/// # );
15071/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
15072/// // As the method needs a request, you would usually fill it with the desired information
15073/// // into the respective structure. Some of the parts shown here might not be applicable !
15074/// // Values shown here are possibly random and not representative !
15075/// let mut req = GoogleCloudMlV1__Model::default();
15076///
15077/// // You can configure optional parameters by calling the respective setters at will, and
15078/// // execute the final call using `doit()`.
15079/// // Values shown here are possibly random and not representative !
15080/// let result = hub.projects().models_patch(req, "name")
15081///              .update_mask(FieldMask::new::<&str>(&[]))
15082///              .doit().await;
15083/// # }
15084/// ```
15085pub struct ProjectModelPatchCall<'a, C>
15086where
15087    C: 'a,
15088{
15089    hub: &'a CloudMachineLearningEngine<C>,
15090    _request: GoogleCloudMlV1__Model,
15091    _name: String,
15092    _update_mask: Option<common::FieldMask>,
15093    _delegate: Option<&'a mut dyn common::Delegate>,
15094    _additional_params: HashMap<String, String>,
15095    _scopes: BTreeSet<String>,
15096}
15097
15098impl<'a, C> common::CallBuilder for ProjectModelPatchCall<'a, C> {}
15099
15100impl<'a, C> ProjectModelPatchCall<'a, C>
15101where
15102    C: common::Connector,
15103{
15104    /// Perform the operation you have build so far.
15105    pub async fn doit(
15106        mut self,
15107    ) -> common::Result<(common::Response, GoogleLongrunning__Operation)> {
15108        use std::borrow::Cow;
15109        use std::io::{Read, Seek};
15110
15111        use common::{url::Params, ToParts};
15112        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15113
15114        let mut dd = common::DefaultDelegate;
15115        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15116        dlg.begin(common::MethodInfo {
15117            id: "ml.projects.models.patch",
15118            http_method: hyper::Method::PATCH,
15119        });
15120
15121        for &field in ["alt", "name", "updateMask"].iter() {
15122            if self._additional_params.contains_key(field) {
15123                dlg.finished(false);
15124                return Err(common::Error::FieldClash(field));
15125            }
15126        }
15127
15128        let mut params = Params::with_capacity(5 + self._additional_params.len());
15129        params.push("name", self._name);
15130        if let Some(value) = self._update_mask.as_ref() {
15131            params.push("updateMask", value.to_string());
15132        }
15133
15134        params.extend(self._additional_params.iter());
15135
15136        params.push("alt", "json");
15137        let mut url = self.hub._base_url.clone() + "v1/{+name}";
15138        if self._scopes.is_empty() {
15139            self._scopes
15140                .insert(Scope::CloudPlatform.as_ref().to_string());
15141        }
15142
15143        #[allow(clippy::single_element_loop)]
15144        for &(find_this, param_name) in [("{+name}", "name")].iter() {
15145            url = params.uri_replacement(url, param_name, find_this, true);
15146        }
15147        {
15148            let to_remove = ["name"];
15149            params.remove_params(&to_remove);
15150        }
15151
15152        let url = params.parse_with_url(&url);
15153
15154        let mut json_mime_type = mime::APPLICATION_JSON;
15155        let mut request_value_reader = {
15156            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15157            common::remove_json_null_values(&mut value);
15158            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15159            serde_json::to_writer(&mut dst, &value).unwrap();
15160            dst
15161        };
15162        let request_size = request_value_reader
15163            .seek(std::io::SeekFrom::End(0))
15164            .unwrap();
15165        request_value_reader
15166            .seek(std::io::SeekFrom::Start(0))
15167            .unwrap();
15168
15169        loop {
15170            let token = match self
15171                .hub
15172                .auth
15173                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15174                .await
15175            {
15176                Ok(token) => token,
15177                Err(e) => match dlg.token(e) {
15178                    Ok(token) => token,
15179                    Err(e) => {
15180                        dlg.finished(false);
15181                        return Err(common::Error::MissingToken(e));
15182                    }
15183                },
15184            };
15185            request_value_reader
15186                .seek(std::io::SeekFrom::Start(0))
15187                .unwrap();
15188            let mut req_result = {
15189                let client = &self.hub.client;
15190                dlg.pre_request();
15191                let mut req_builder = hyper::Request::builder()
15192                    .method(hyper::Method::PATCH)
15193                    .uri(url.as_str())
15194                    .header(USER_AGENT, self.hub._user_agent.clone());
15195
15196                if let Some(token) = token.as_ref() {
15197                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15198                }
15199
15200                let request = req_builder
15201                    .header(CONTENT_TYPE, json_mime_type.to_string())
15202                    .header(CONTENT_LENGTH, request_size as u64)
15203                    .body(common::to_body(
15204                        request_value_reader.get_ref().clone().into(),
15205                    ));
15206
15207                client.request(request.unwrap()).await
15208            };
15209
15210            match req_result {
15211                Err(err) => {
15212                    if let common::Retry::After(d) = dlg.http_error(&err) {
15213                        sleep(d).await;
15214                        continue;
15215                    }
15216                    dlg.finished(false);
15217                    return Err(common::Error::HttpError(err));
15218                }
15219                Ok(res) => {
15220                    let (mut parts, body) = res.into_parts();
15221                    let mut body = common::Body::new(body);
15222                    if !parts.status.is_success() {
15223                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15224                        let error = serde_json::from_str(&common::to_string(&bytes));
15225                        let response = common::to_response(parts, bytes.into());
15226
15227                        if let common::Retry::After(d) =
15228                            dlg.http_failure(&response, error.as_ref().ok())
15229                        {
15230                            sleep(d).await;
15231                            continue;
15232                        }
15233
15234                        dlg.finished(false);
15235
15236                        return Err(match error {
15237                            Ok(value) => common::Error::BadRequest(value),
15238                            _ => common::Error::Failure(response),
15239                        });
15240                    }
15241                    let response = {
15242                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15243                        let encoded = common::to_string(&bytes);
15244                        match serde_json::from_str(&encoded) {
15245                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15246                            Err(error) => {
15247                                dlg.response_json_decode_error(&encoded, &error);
15248                                return Err(common::Error::JsonDecodeError(
15249                                    encoded.to_string(),
15250                                    error,
15251                                ));
15252                            }
15253                        }
15254                    };
15255
15256                    dlg.finished(true);
15257                    return Ok(response);
15258                }
15259            }
15260        }
15261    }
15262
15263    ///
15264    /// Sets the *request* property to the given value.
15265    ///
15266    /// Even though the property as already been set when instantiating this call,
15267    /// we provide this method for API completeness.
15268    pub fn request(mut self, new_value: GoogleCloudMlV1__Model) -> ProjectModelPatchCall<'a, C> {
15269        self._request = new_value;
15270        self
15271    }
15272    /// Required. The project name.
15273    ///
15274    /// Sets the *name* path property to the given value.
15275    ///
15276    /// Even though the property as already been set when instantiating this call,
15277    /// we provide this method for API completeness.
15278    pub fn name(mut self, new_value: &str) -> ProjectModelPatchCall<'a, C> {
15279        self._name = new_value.to_string();
15280        self
15281    }
15282    /// Required. Specifies the path, relative to `Model`, of the field to update. For example, to change the description of a model to "foo" and set its default version to "version_1", the `update_mask` parameter would be specified as `description`, `default_version.name`, and the `PATCH` request body would specify the new value, as follows: { "description": "foo", "defaultVersion": { "name":"version_1" } } Currently the supported update masks are `description` and `default_version.name`.
15283    ///
15284    /// Sets the *update mask* query property to the given value.
15285    pub fn update_mask(mut self, new_value: common::FieldMask) -> ProjectModelPatchCall<'a, C> {
15286        self._update_mask = Some(new_value);
15287        self
15288    }
15289    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15290    /// while executing the actual API request.
15291    ///
15292    /// ````text
15293    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15294    /// ````
15295    ///
15296    /// Sets the *delegate* property to the given value.
15297    pub fn delegate(
15298        mut self,
15299        new_value: &'a mut dyn common::Delegate,
15300    ) -> ProjectModelPatchCall<'a, C> {
15301        self._delegate = Some(new_value);
15302        self
15303    }
15304
15305    /// Set any additional parameter of the query string used in the request.
15306    /// It should be used to set parameters which are not yet available through their own
15307    /// setters.
15308    ///
15309    /// Please note that this method must not be used to set any of the known parameters
15310    /// which have their own setter method. If done anyway, the request will fail.
15311    ///
15312    /// # Additional Parameters
15313    ///
15314    /// * *$.xgafv* (query-string) - V1 error format.
15315    /// * *access_token* (query-string) - OAuth access token.
15316    /// * *alt* (query-string) - Data format for response.
15317    /// * *callback* (query-string) - JSONP
15318    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15319    /// * *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.
15320    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15321    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15322    /// * *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.
15323    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15324    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15325    pub fn param<T>(mut self, name: T, value: T) -> ProjectModelPatchCall<'a, C>
15326    where
15327        T: AsRef<str>,
15328    {
15329        self._additional_params
15330            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15331        self
15332    }
15333
15334    /// Identifies the authorization scope for the method you are building.
15335    ///
15336    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15337    /// [`Scope::CloudPlatform`].
15338    ///
15339    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15340    /// tokens for more than one scope.
15341    ///
15342    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15343    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15344    /// sufficient, a read-write scope will do as well.
15345    pub fn add_scope<St>(mut self, scope: St) -> ProjectModelPatchCall<'a, C>
15346    where
15347        St: AsRef<str>,
15348    {
15349        self._scopes.insert(String::from(scope.as_ref()));
15350        self
15351    }
15352    /// Identifies the authorization scope(s) for the method you are building.
15353    ///
15354    /// See [`Self::add_scope()`] for details.
15355    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectModelPatchCall<'a, C>
15356    where
15357        I: IntoIterator<Item = St>,
15358        St: AsRef<str>,
15359    {
15360        self._scopes
15361            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15362        self
15363    }
15364
15365    /// Removes all scopes, and no default scope will be used either.
15366    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15367    /// for details).
15368    pub fn clear_scopes(mut self) -> ProjectModelPatchCall<'a, C> {
15369        self._scopes.clear();
15370        self
15371    }
15372}
15373
15374/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
15375///
15376/// A builder for the *models.setIamPolicy* method supported by a *project* resource.
15377/// It is not used directly, but through a [`ProjectMethods`] instance.
15378///
15379/// # Example
15380///
15381/// Instantiate a resource method builder
15382///
15383/// ```test_harness,no_run
15384/// # extern crate hyper;
15385/// # extern crate hyper_rustls;
15386/// # extern crate google_ml1 as ml1;
15387/// use ml1::api::GoogleIamV1__SetIamPolicyRequest;
15388/// # async fn dox() {
15389/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15390///
15391/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15392/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15393/// #     .with_native_roots()
15394/// #     .unwrap()
15395/// #     .https_only()
15396/// #     .enable_http2()
15397/// #     .build();
15398///
15399/// # let executor = hyper_util::rt::TokioExecutor::new();
15400/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15401/// #     secret,
15402/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15403/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15404/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15405/// #     ),
15406/// # ).build().await.unwrap();
15407///
15408/// # let client = hyper_util::client::legacy::Client::builder(
15409/// #     hyper_util::rt::TokioExecutor::new()
15410/// # )
15411/// # .build(
15412/// #     hyper_rustls::HttpsConnectorBuilder::new()
15413/// #         .with_native_roots()
15414/// #         .unwrap()
15415/// #         .https_or_http()
15416/// #         .enable_http2()
15417/// #         .build()
15418/// # );
15419/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
15420/// // As the method needs a request, you would usually fill it with the desired information
15421/// // into the respective structure. Some of the parts shown here might not be applicable !
15422/// // Values shown here are possibly random and not representative !
15423/// let mut req = GoogleIamV1__SetIamPolicyRequest::default();
15424///
15425/// // You can configure optional parameters by calling the respective setters at will, and
15426/// // execute the final call using `doit()`.
15427/// // Values shown here are possibly random and not representative !
15428/// let result = hub.projects().models_set_iam_policy(req, "resource")
15429///              .doit().await;
15430/// # }
15431/// ```
15432pub struct ProjectModelSetIamPolicyCall<'a, C>
15433where
15434    C: 'a,
15435{
15436    hub: &'a CloudMachineLearningEngine<C>,
15437    _request: GoogleIamV1__SetIamPolicyRequest,
15438    _resource: String,
15439    _delegate: Option<&'a mut dyn common::Delegate>,
15440    _additional_params: HashMap<String, String>,
15441    _scopes: BTreeSet<String>,
15442}
15443
15444impl<'a, C> common::CallBuilder for ProjectModelSetIamPolicyCall<'a, C> {}
15445
15446impl<'a, C> ProjectModelSetIamPolicyCall<'a, C>
15447where
15448    C: common::Connector,
15449{
15450    /// Perform the operation you have build so far.
15451    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleIamV1__Policy)> {
15452        use std::borrow::Cow;
15453        use std::io::{Read, Seek};
15454
15455        use common::{url::Params, ToParts};
15456        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15457
15458        let mut dd = common::DefaultDelegate;
15459        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15460        dlg.begin(common::MethodInfo {
15461            id: "ml.projects.models.setIamPolicy",
15462            http_method: hyper::Method::POST,
15463        });
15464
15465        for &field in ["alt", "resource"].iter() {
15466            if self._additional_params.contains_key(field) {
15467                dlg.finished(false);
15468                return Err(common::Error::FieldClash(field));
15469            }
15470        }
15471
15472        let mut params = Params::with_capacity(4 + self._additional_params.len());
15473        params.push("resource", self._resource);
15474
15475        params.extend(self._additional_params.iter());
15476
15477        params.push("alt", "json");
15478        let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
15479        if self._scopes.is_empty() {
15480            self._scopes
15481                .insert(Scope::CloudPlatform.as_ref().to_string());
15482        }
15483
15484        #[allow(clippy::single_element_loop)]
15485        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
15486            url = params.uri_replacement(url, param_name, find_this, true);
15487        }
15488        {
15489            let to_remove = ["resource"];
15490            params.remove_params(&to_remove);
15491        }
15492
15493        let url = params.parse_with_url(&url);
15494
15495        let mut json_mime_type = mime::APPLICATION_JSON;
15496        let mut request_value_reader = {
15497            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15498            common::remove_json_null_values(&mut value);
15499            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15500            serde_json::to_writer(&mut dst, &value).unwrap();
15501            dst
15502        };
15503        let request_size = request_value_reader
15504            .seek(std::io::SeekFrom::End(0))
15505            .unwrap();
15506        request_value_reader
15507            .seek(std::io::SeekFrom::Start(0))
15508            .unwrap();
15509
15510        loop {
15511            let token = match self
15512                .hub
15513                .auth
15514                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15515                .await
15516            {
15517                Ok(token) => token,
15518                Err(e) => match dlg.token(e) {
15519                    Ok(token) => token,
15520                    Err(e) => {
15521                        dlg.finished(false);
15522                        return Err(common::Error::MissingToken(e));
15523                    }
15524                },
15525            };
15526            request_value_reader
15527                .seek(std::io::SeekFrom::Start(0))
15528                .unwrap();
15529            let mut req_result = {
15530                let client = &self.hub.client;
15531                dlg.pre_request();
15532                let mut req_builder = hyper::Request::builder()
15533                    .method(hyper::Method::POST)
15534                    .uri(url.as_str())
15535                    .header(USER_AGENT, self.hub._user_agent.clone());
15536
15537                if let Some(token) = token.as_ref() {
15538                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15539                }
15540
15541                let request = req_builder
15542                    .header(CONTENT_TYPE, json_mime_type.to_string())
15543                    .header(CONTENT_LENGTH, request_size as u64)
15544                    .body(common::to_body(
15545                        request_value_reader.get_ref().clone().into(),
15546                    ));
15547
15548                client.request(request.unwrap()).await
15549            };
15550
15551            match req_result {
15552                Err(err) => {
15553                    if let common::Retry::After(d) = dlg.http_error(&err) {
15554                        sleep(d).await;
15555                        continue;
15556                    }
15557                    dlg.finished(false);
15558                    return Err(common::Error::HttpError(err));
15559                }
15560                Ok(res) => {
15561                    let (mut parts, body) = res.into_parts();
15562                    let mut body = common::Body::new(body);
15563                    if !parts.status.is_success() {
15564                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15565                        let error = serde_json::from_str(&common::to_string(&bytes));
15566                        let response = common::to_response(parts, bytes.into());
15567
15568                        if let common::Retry::After(d) =
15569                            dlg.http_failure(&response, error.as_ref().ok())
15570                        {
15571                            sleep(d).await;
15572                            continue;
15573                        }
15574
15575                        dlg.finished(false);
15576
15577                        return Err(match error {
15578                            Ok(value) => common::Error::BadRequest(value),
15579                            _ => common::Error::Failure(response),
15580                        });
15581                    }
15582                    let response = {
15583                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15584                        let encoded = common::to_string(&bytes);
15585                        match serde_json::from_str(&encoded) {
15586                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15587                            Err(error) => {
15588                                dlg.response_json_decode_error(&encoded, &error);
15589                                return Err(common::Error::JsonDecodeError(
15590                                    encoded.to_string(),
15591                                    error,
15592                                ));
15593                            }
15594                        }
15595                    };
15596
15597                    dlg.finished(true);
15598                    return Ok(response);
15599                }
15600            }
15601        }
15602    }
15603
15604    ///
15605    /// Sets the *request* property to the given value.
15606    ///
15607    /// Even though the property as already been set when instantiating this call,
15608    /// we provide this method for API completeness.
15609    pub fn request(
15610        mut self,
15611        new_value: GoogleIamV1__SetIamPolicyRequest,
15612    ) -> ProjectModelSetIamPolicyCall<'a, C> {
15613        self._request = new_value;
15614        self
15615    }
15616    /// REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
15617    ///
15618    /// Sets the *resource* path property to the given value.
15619    ///
15620    /// Even though the property as already been set when instantiating this call,
15621    /// we provide this method for API completeness.
15622    pub fn resource(mut self, new_value: &str) -> ProjectModelSetIamPolicyCall<'a, C> {
15623        self._resource = new_value.to_string();
15624        self
15625    }
15626    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15627    /// while executing the actual API request.
15628    ///
15629    /// ````text
15630    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15631    /// ````
15632    ///
15633    /// Sets the *delegate* property to the given value.
15634    pub fn delegate(
15635        mut self,
15636        new_value: &'a mut dyn common::Delegate,
15637    ) -> ProjectModelSetIamPolicyCall<'a, C> {
15638        self._delegate = Some(new_value);
15639        self
15640    }
15641
15642    /// Set any additional parameter of the query string used in the request.
15643    /// It should be used to set parameters which are not yet available through their own
15644    /// setters.
15645    ///
15646    /// Please note that this method must not be used to set any of the known parameters
15647    /// which have their own setter method. If done anyway, the request will fail.
15648    ///
15649    /// # Additional Parameters
15650    ///
15651    /// * *$.xgafv* (query-string) - V1 error format.
15652    /// * *access_token* (query-string) - OAuth access token.
15653    /// * *alt* (query-string) - Data format for response.
15654    /// * *callback* (query-string) - JSONP
15655    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15656    /// * *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.
15657    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15658    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15659    /// * *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.
15660    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15661    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15662    pub fn param<T>(mut self, name: T, value: T) -> ProjectModelSetIamPolicyCall<'a, C>
15663    where
15664        T: AsRef<str>,
15665    {
15666        self._additional_params
15667            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15668        self
15669    }
15670
15671    /// Identifies the authorization scope for the method you are building.
15672    ///
15673    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15674    /// [`Scope::CloudPlatform`].
15675    ///
15676    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15677    /// tokens for more than one scope.
15678    ///
15679    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15680    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15681    /// sufficient, a read-write scope will do as well.
15682    pub fn add_scope<St>(mut self, scope: St) -> ProjectModelSetIamPolicyCall<'a, C>
15683    where
15684        St: AsRef<str>,
15685    {
15686        self._scopes.insert(String::from(scope.as_ref()));
15687        self
15688    }
15689    /// Identifies the authorization scope(s) for the method you are building.
15690    ///
15691    /// See [`Self::add_scope()`] for details.
15692    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectModelSetIamPolicyCall<'a, C>
15693    where
15694        I: IntoIterator<Item = St>,
15695        St: AsRef<str>,
15696    {
15697        self._scopes
15698            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15699        self
15700    }
15701
15702    /// Removes all scopes, and no default scope will be used either.
15703    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15704    /// for details).
15705    pub fn clear_scopes(mut self) -> ProjectModelSetIamPolicyCall<'a, C> {
15706        self._scopes.clear();
15707        self
15708    }
15709}
15710
15711/// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
15712///
15713/// A builder for the *models.testIamPermissions* method supported by a *project* resource.
15714/// It is not used directly, but through a [`ProjectMethods`] instance.
15715///
15716/// # Example
15717///
15718/// Instantiate a resource method builder
15719///
15720/// ```test_harness,no_run
15721/// # extern crate hyper;
15722/// # extern crate hyper_rustls;
15723/// # extern crate google_ml1 as ml1;
15724/// use ml1::api::GoogleIamV1__TestIamPermissionsRequest;
15725/// # async fn dox() {
15726/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15727///
15728/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15729/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15730/// #     .with_native_roots()
15731/// #     .unwrap()
15732/// #     .https_only()
15733/// #     .enable_http2()
15734/// #     .build();
15735///
15736/// # let executor = hyper_util::rt::TokioExecutor::new();
15737/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15738/// #     secret,
15739/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15740/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15741/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15742/// #     ),
15743/// # ).build().await.unwrap();
15744///
15745/// # let client = hyper_util::client::legacy::Client::builder(
15746/// #     hyper_util::rt::TokioExecutor::new()
15747/// # )
15748/// # .build(
15749/// #     hyper_rustls::HttpsConnectorBuilder::new()
15750/// #         .with_native_roots()
15751/// #         .unwrap()
15752/// #         .https_or_http()
15753/// #         .enable_http2()
15754/// #         .build()
15755/// # );
15756/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
15757/// // As the method needs a request, you would usually fill it with the desired information
15758/// // into the respective structure. Some of the parts shown here might not be applicable !
15759/// // Values shown here are possibly random and not representative !
15760/// let mut req = GoogleIamV1__TestIamPermissionsRequest::default();
15761///
15762/// // You can configure optional parameters by calling the respective setters at will, and
15763/// // execute the final call using `doit()`.
15764/// // Values shown here are possibly random and not representative !
15765/// let result = hub.projects().models_test_iam_permissions(req, "resource")
15766///              .doit().await;
15767/// # }
15768/// ```
15769pub struct ProjectModelTestIamPermissionCall<'a, C>
15770where
15771    C: 'a,
15772{
15773    hub: &'a CloudMachineLearningEngine<C>,
15774    _request: GoogleIamV1__TestIamPermissionsRequest,
15775    _resource: String,
15776    _delegate: Option<&'a mut dyn common::Delegate>,
15777    _additional_params: HashMap<String, String>,
15778    _scopes: BTreeSet<String>,
15779}
15780
15781impl<'a, C> common::CallBuilder for ProjectModelTestIamPermissionCall<'a, C> {}
15782
15783impl<'a, C> ProjectModelTestIamPermissionCall<'a, C>
15784where
15785    C: common::Connector,
15786{
15787    /// Perform the operation you have build so far.
15788    pub async fn doit(
15789        mut self,
15790    ) -> common::Result<(common::Response, GoogleIamV1__TestIamPermissionsResponse)> {
15791        use std::borrow::Cow;
15792        use std::io::{Read, Seek};
15793
15794        use common::{url::Params, ToParts};
15795        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15796
15797        let mut dd = common::DefaultDelegate;
15798        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15799        dlg.begin(common::MethodInfo {
15800            id: "ml.projects.models.testIamPermissions",
15801            http_method: hyper::Method::POST,
15802        });
15803
15804        for &field in ["alt", "resource"].iter() {
15805            if self._additional_params.contains_key(field) {
15806                dlg.finished(false);
15807                return Err(common::Error::FieldClash(field));
15808            }
15809        }
15810
15811        let mut params = Params::with_capacity(4 + self._additional_params.len());
15812        params.push("resource", self._resource);
15813
15814        params.extend(self._additional_params.iter());
15815
15816        params.push("alt", "json");
15817        let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
15818        if self._scopes.is_empty() {
15819            self._scopes
15820                .insert(Scope::CloudPlatform.as_ref().to_string());
15821        }
15822
15823        #[allow(clippy::single_element_loop)]
15824        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
15825            url = params.uri_replacement(url, param_name, find_this, true);
15826        }
15827        {
15828            let to_remove = ["resource"];
15829            params.remove_params(&to_remove);
15830        }
15831
15832        let url = params.parse_with_url(&url);
15833
15834        let mut json_mime_type = mime::APPLICATION_JSON;
15835        let mut request_value_reader = {
15836            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15837            common::remove_json_null_values(&mut value);
15838            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15839            serde_json::to_writer(&mut dst, &value).unwrap();
15840            dst
15841        };
15842        let request_size = request_value_reader
15843            .seek(std::io::SeekFrom::End(0))
15844            .unwrap();
15845        request_value_reader
15846            .seek(std::io::SeekFrom::Start(0))
15847            .unwrap();
15848
15849        loop {
15850            let token = match self
15851                .hub
15852                .auth
15853                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15854                .await
15855            {
15856                Ok(token) => token,
15857                Err(e) => match dlg.token(e) {
15858                    Ok(token) => token,
15859                    Err(e) => {
15860                        dlg.finished(false);
15861                        return Err(common::Error::MissingToken(e));
15862                    }
15863                },
15864            };
15865            request_value_reader
15866                .seek(std::io::SeekFrom::Start(0))
15867                .unwrap();
15868            let mut req_result = {
15869                let client = &self.hub.client;
15870                dlg.pre_request();
15871                let mut req_builder = hyper::Request::builder()
15872                    .method(hyper::Method::POST)
15873                    .uri(url.as_str())
15874                    .header(USER_AGENT, self.hub._user_agent.clone());
15875
15876                if let Some(token) = token.as_ref() {
15877                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15878                }
15879
15880                let request = req_builder
15881                    .header(CONTENT_TYPE, json_mime_type.to_string())
15882                    .header(CONTENT_LENGTH, request_size as u64)
15883                    .body(common::to_body(
15884                        request_value_reader.get_ref().clone().into(),
15885                    ));
15886
15887                client.request(request.unwrap()).await
15888            };
15889
15890            match req_result {
15891                Err(err) => {
15892                    if let common::Retry::After(d) = dlg.http_error(&err) {
15893                        sleep(d).await;
15894                        continue;
15895                    }
15896                    dlg.finished(false);
15897                    return Err(common::Error::HttpError(err));
15898                }
15899                Ok(res) => {
15900                    let (mut parts, body) = res.into_parts();
15901                    let mut body = common::Body::new(body);
15902                    if !parts.status.is_success() {
15903                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15904                        let error = serde_json::from_str(&common::to_string(&bytes));
15905                        let response = common::to_response(parts, bytes.into());
15906
15907                        if let common::Retry::After(d) =
15908                            dlg.http_failure(&response, error.as_ref().ok())
15909                        {
15910                            sleep(d).await;
15911                            continue;
15912                        }
15913
15914                        dlg.finished(false);
15915
15916                        return Err(match error {
15917                            Ok(value) => common::Error::BadRequest(value),
15918                            _ => common::Error::Failure(response),
15919                        });
15920                    }
15921                    let response = {
15922                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15923                        let encoded = common::to_string(&bytes);
15924                        match serde_json::from_str(&encoded) {
15925                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15926                            Err(error) => {
15927                                dlg.response_json_decode_error(&encoded, &error);
15928                                return Err(common::Error::JsonDecodeError(
15929                                    encoded.to_string(),
15930                                    error,
15931                                ));
15932                            }
15933                        }
15934                    };
15935
15936                    dlg.finished(true);
15937                    return Ok(response);
15938                }
15939            }
15940        }
15941    }
15942
15943    ///
15944    /// Sets the *request* property to the given value.
15945    ///
15946    /// Even though the property as already been set when instantiating this call,
15947    /// we provide this method for API completeness.
15948    pub fn request(
15949        mut self,
15950        new_value: GoogleIamV1__TestIamPermissionsRequest,
15951    ) -> ProjectModelTestIamPermissionCall<'a, C> {
15952        self._request = new_value;
15953        self
15954    }
15955    /// REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
15956    ///
15957    /// Sets the *resource* path property to the given value.
15958    ///
15959    /// Even though the property as already been set when instantiating this call,
15960    /// we provide this method for API completeness.
15961    pub fn resource(mut self, new_value: &str) -> ProjectModelTestIamPermissionCall<'a, C> {
15962        self._resource = new_value.to_string();
15963        self
15964    }
15965    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15966    /// while executing the actual API request.
15967    ///
15968    /// ````text
15969    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15970    /// ````
15971    ///
15972    /// Sets the *delegate* property to the given value.
15973    pub fn delegate(
15974        mut self,
15975        new_value: &'a mut dyn common::Delegate,
15976    ) -> ProjectModelTestIamPermissionCall<'a, C> {
15977        self._delegate = Some(new_value);
15978        self
15979    }
15980
15981    /// Set any additional parameter of the query string used in the request.
15982    /// It should be used to set parameters which are not yet available through their own
15983    /// setters.
15984    ///
15985    /// Please note that this method must not be used to set any of the known parameters
15986    /// which have their own setter method. If done anyway, the request will fail.
15987    ///
15988    /// # Additional Parameters
15989    ///
15990    /// * *$.xgafv* (query-string) - V1 error format.
15991    /// * *access_token* (query-string) - OAuth access token.
15992    /// * *alt* (query-string) - Data format for response.
15993    /// * *callback* (query-string) - JSONP
15994    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15995    /// * *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.
15996    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15997    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15998    /// * *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.
15999    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16000    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16001    pub fn param<T>(mut self, name: T, value: T) -> ProjectModelTestIamPermissionCall<'a, C>
16002    where
16003        T: AsRef<str>,
16004    {
16005        self._additional_params
16006            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16007        self
16008    }
16009
16010    /// Identifies the authorization scope for the method you are building.
16011    ///
16012    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16013    /// [`Scope::CloudPlatform`].
16014    ///
16015    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16016    /// tokens for more than one scope.
16017    ///
16018    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16019    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16020    /// sufficient, a read-write scope will do as well.
16021    pub fn add_scope<St>(mut self, scope: St) -> ProjectModelTestIamPermissionCall<'a, C>
16022    where
16023        St: AsRef<str>,
16024    {
16025        self._scopes.insert(String::from(scope.as_ref()));
16026        self
16027    }
16028    /// Identifies the authorization scope(s) for the method you are building.
16029    ///
16030    /// See [`Self::add_scope()`] for details.
16031    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectModelTestIamPermissionCall<'a, C>
16032    where
16033        I: IntoIterator<Item = St>,
16034        St: AsRef<str>,
16035    {
16036        self._scopes
16037            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16038        self
16039    }
16040
16041    /// Removes all scopes, and no default scope will be used either.
16042    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16043    /// for details).
16044    pub fn clear_scopes(mut self) -> ProjectModelTestIamPermissionCall<'a, C> {
16045        self._scopes.clear();
16046        self
16047    }
16048}
16049
16050/// 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`.
16051///
16052/// A builder for the *operations.cancel* method supported by a *project* resource.
16053/// It is not used directly, but through a [`ProjectMethods`] instance.
16054///
16055/// # Example
16056///
16057/// Instantiate a resource method builder
16058///
16059/// ```test_harness,no_run
16060/// # extern crate hyper;
16061/// # extern crate hyper_rustls;
16062/// # extern crate google_ml1 as ml1;
16063/// # async fn dox() {
16064/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16065///
16066/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16067/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16068/// #     .with_native_roots()
16069/// #     .unwrap()
16070/// #     .https_only()
16071/// #     .enable_http2()
16072/// #     .build();
16073///
16074/// # let executor = hyper_util::rt::TokioExecutor::new();
16075/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16076/// #     secret,
16077/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16078/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16079/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16080/// #     ),
16081/// # ).build().await.unwrap();
16082///
16083/// # let client = hyper_util::client::legacy::Client::builder(
16084/// #     hyper_util::rt::TokioExecutor::new()
16085/// # )
16086/// # .build(
16087/// #     hyper_rustls::HttpsConnectorBuilder::new()
16088/// #         .with_native_roots()
16089/// #         .unwrap()
16090/// #         .https_or_http()
16091/// #         .enable_http2()
16092/// #         .build()
16093/// # );
16094/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
16095/// // You can configure optional parameters by calling the respective setters at will, and
16096/// // execute the final call using `doit()`.
16097/// // Values shown here are possibly random and not representative !
16098/// let result = hub.projects().operations_cancel("name")
16099///              .doit().await;
16100/// # }
16101/// ```
16102pub struct ProjectOperationCancelCall<'a, C>
16103where
16104    C: 'a,
16105{
16106    hub: &'a CloudMachineLearningEngine<C>,
16107    _name: String,
16108    _delegate: Option<&'a mut dyn common::Delegate>,
16109    _additional_params: HashMap<String, String>,
16110    _scopes: BTreeSet<String>,
16111}
16112
16113impl<'a, C> common::CallBuilder for ProjectOperationCancelCall<'a, C> {}
16114
16115impl<'a, C> ProjectOperationCancelCall<'a, C>
16116where
16117    C: common::Connector,
16118{
16119    /// Perform the operation you have build so far.
16120    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleProtobuf__Empty)> {
16121        use std::borrow::Cow;
16122        use std::io::{Read, Seek};
16123
16124        use common::{url::Params, ToParts};
16125        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16126
16127        let mut dd = common::DefaultDelegate;
16128        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16129        dlg.begin(common::MethodInfo {
16130            id: "ml.projects.operations.cancel",
16131            http_method: hyper::Method::POST,
16132        });
16133
16134        for &field in ["alt", "name"].iter() {
16135            if self._additional_params.contains_key(field) {
16136                dlg.finished(false);
16137                return Err(common::Error::FieldClash(field));
16138            }
16139        }
16140
16141        let mut params = Params::with_capacity(3 + self._additional_params.len());
16142        params.push("name", self._name);
16143
16144        params.extend(self._additional_params.iter());
16145
16146        params.push("alt", "json");
16147        let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
16148        if self._scopes.is_empty() {
16149            self._scopes
16150                .insert(Scope::CloudPlatform.as_ref().to_string());
16151        }
16152
16153        #[allow(clippy::single_element_loop)]
16154        for &(find_this, param_name) in [("{+name}", "name")].iter() {
16155            url = params.uri_replacement(url, param_name, find_this, true);
16156        }
16157        {
16158            let to_remove = ["name"];
16159            params.remove_params(&to_remove);
16160        }
16161
16162        let url = params.parse_with_url(&url);
16163
16164        loop {
16165            let token = match self
16166                .hub
16167                .auth
16168                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16169                .await
16170            {
16171                Ok(token) => token,
16172                Err(e) => match dlg.token(e) {
16173                    Ok(token) => token,
16174                    Err(e) => {
16175                        dlg.finished(false);
16176                        return Err(common::Error::MissingToken(e));
16177                    }
16178                },
16179            };
16180            let mut req_result = {
16181                let client = &self.hub.client;
16182                dlg.pre_request();
16183                let mut req_builder = hyper::Request::builder()
16184                    .method(hyper::Method::POST)
16185                    .uri(url.as_str())
16186                    .header(USER_AGENT, self.hub._user_agent.clone());
16187
16188                if let Some(token) = token.as_ref() {
16189                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16190                }
16191
16192                let request = req_builder
16193                    .header(CONTENT_LENGTH, 0_u64)
16194                    .body(common::to_body::<String>(None));
16195
16196                client.request(request.unwrap()).await
16197            };
16198
16199            match req_result {
16200                Err(err) => {
16201                    if let common::Retry::After(d) = dlg.http_error(&err) {
16202                        sleep(d).await;
16203                        continue;
16204                    }
16205                    dlg.finished(false);
16206                    return Err(common::Error::HttpError(err));
16207                }
16208                Ok(res) => {
16209                    let (mut parts, body) = res.into_parts();
16210                    let mut body = common::Body::new(body);
16211                    if !parts.status.is_success() {
16212                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16213                        let error = serde_json::from_str(&common::to_string(&bytes));
16214                        let response = common::to_response(parts, bytes.into());
16215
16216                        if let common::Retry::After(d) =
16217                            dlg.http_failure(&response, error.as_ref().ok())
16218                        {
16219                            sleep(d).await;
16220                            continue;
16221                        }
16222
16223                        dlg.finished(false);
16224
16225                        return Err(match error {
16226                            Ok(value) => common::Error::BadRequest(value),
16227                            _ => common::Error::Failure(response),
16228                        });
16229                    }
16230                    let response = {
16231                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16232                        let encoded = common::to_string(&bytes);
16233                        match serde_json::from_str(&encoded) {
16234                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16235                            Err(error) => {
16236                                dlg.response_json_decode_error(&encoded, &error);
16237                                return Err(common::Error::JsonDecodeError(
16238                                    encoded.to_string(),
16239                                    error,
16240                                ));
16241                            }
16242                        }
16243                    };
16244
16245                    dlg.finished(true);
16246                    return Ok(response);
16247                }
16248            }
16249        }
16250    }
16251
16252    /// The name of the operation resource to be cancelled.
16253    ///
16254    /// Sets the *name* path property to the given value.
16255    ///
16256    /// Even though the property as already been set when instantiating this call,
16257    /// we provide this method for API completeness.
16258    pub fn name(mut self, new_value: &str) -> ProjectOperationCancelCall<'a, C> {
16259        self._name = new_value.to_string();
16260        self
16261    }
16262    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16263    /// while executing the actual API request.
16264    ///
16265    /// ````text
16266    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16267    /// ````
16268    ///
16269    /// Sets the *delegate* property to the given value.
16270    pub fn delegate(
16271        mut self,
16272        new_value: &'a mut dyn common::Delegate,
16273    ) -> ProjectOperationCancelCall<'a, C> {
16274        self._delegate = Some(new_value);
16275        self
16276    }
16277
16278    /// Set any additional parameter of the query string used in the request.
16279    /// It should be used to set parameters which are not yet available through their own
16280    /// setters.
16281    ///
16282    /// Please note that this method must not be used to set any of the known parameters
16283    /// which have their own setter method. If done anyway, the request will fail.
16284    ///
16285    /// # Additional Parameters
16286    ///
16287    /// * *$.xgafv* (query-string) - V1 error format.
16288    /// * *access_token* (query-string) - OAuth access token.
16289    /// * *alt* (query-string) - Data format for response.
16290    /// * *callback* (query-string) - JSONP
16291    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16292    /// * *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.
16293    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16294    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16295    /// * *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.
16296    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16297    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16298    pub fn param<T>(mut self, name: T, value: T) -> ProjectOperationCancelCall<'a, C>
16299    where
16300        T: AsRef<str>,
16301    {
16302        self._additional_params
16303            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16304        self
16305    }
16306
16307    /// Identifies the authorization scope for the method you are building.
16308    ///
16309    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16310    /// [`Scope::CloudPlatform`].
16311    ///
16312    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16313    /// tokens for more than one scope.
16314    ///
16315    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16316    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16317    /// sufficient, a read-write scope will do as well.
16318    pub fn add_scope<St>(mut self, scope: St) -> ProjectOperationCancelCall<'a, C>
16319    where
16320        St: AsRef<str>,
16321    {
16322        self._scopes.insert(String::from(scope.as_ref()));
16323        self
16324    }
16325    /// Identifies the authorization scope(s) for the method you are building.
16326    ///
16327    /// See [`Self::add_scope()`] for details.
16328    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOperationCancelCall<'a, C>
16329    where
16330        I: IntoIterator<Item = St>,
16331        St: AsRef<str>,
16332    {
16333        self._scopes
16334            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16335        self
16336    }
16337
16338    /// Removes all scopes, and no default scope will be used either.
16339    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16340    /// for details).
16341    pub fn clear_scopes(mut self) -> ProjectOperationCancelCall<'a, C> {
16342        self._scopes.clear();
16343        self
16344    }
16345}
16346
16347/// 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.
16348///
16349/// A builder for the *operations.get* method supported by a *project* resource.
16350/// It is not used directly, but through a [`ProjectMethods`] instance.
16351///
16352/// # Example
16353///
16354/// Instantiate a resource method builder
16355///
16356/// ```test_harness,no_run
16357/// # extern crate hyper;
16358/// # extern crate hyper_rustls;
16359/// # extern crate google_ml1 as ml1;
16360/// # async fn dox() {
16361/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16362///
16363/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16364/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16365/// #     .with_native_roots()
16366/// #     .unwrap()
16367/// #     .https_only()
16368/// #     .enable_http2()
16369/// #     .build();
16370///
16371/// # let executor = hyper_util::rt::TokioExecutor::new();
16372/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16373/// #     secret,
16374/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16375/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16376/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16377/// #     ),
16378/// # ).build().await.unwrap();
16379///
16380/// # let client = hyper_util::client::legacy::Client::builder(
16381/// #     hyper_util::rt::TokioExecutor::new()
16382/// # )
16383/// # .build(
16384/// #     hyper_rustls::HttpsConnectorBuilder::new()
16385/// #         .with_native_roots()
16386/// #         .unwrap()
16387/// #         .https_or_http()
16388/// #         .enable_http2()
16389/// #         .build()
16390/// # );
16391/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
16392/// // You can configure optional parameters by calling the respective setters at will, and
16393/// // execute the final call using `doit()`.
16394/// // Values shown here are possibly random and not representative !
16395/// let result = hub.projects().operations_get("name")
16396///              .doit().await;
16397/// # }
16398/// ```
16399pub struct ProjectOperationGetCall<'a, C>
16400where
16401    C: 'a,
16402{
16403    hub: &'a CloudMachineLearningEngine<C>,
16404    _name: String,
16405    _delegate: Option<&'a mut dyn common::Delegate>,
16406    _additional_params: HashMap<String, String>,
16407    _scopes: BTreeSet<String>,
16408}
16409
16410impl<'a, C> common::CallBuilder for ProjectOperationGetCall<'a, C> {}
16411
16412impl<'a, C> ProjectOperationGetCall<'a, C>
16413where
16414    C: common::Connector,
16415{
16416    /// Perform the operation you have build so far.
16417    pub async fn doit(
16418        mut self,
16419    ) -> common::Result<(common::Response, GoogleLongrunning__Operation)> {
16420        use std::borrow::Cow;
16421        use std::io::{Read, Seek};
16422
16423        use common::{url::Params, ToParts};
16424        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16425
16426        let mut dd = common::DefaultDelegate;
16427        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16428        dlg.begin(common::MethodInfo {
16429            id: "ml.projects.operations.get",
16430            http_method: hyper::Method::GET,
16431        });
16432
16433        for &field in ["alt", "name"].iter() {
16434            if self._additional_params.contains_key(field) {
16435                dlg.finished(false);
16436                return Err(common::Error::FieldClash(field));
16437            }
16438        }
16439
16440        let mut params = Params::with_capacity(3 + self._additional_params.len());
16441        params.push("name", self._name);
16442
16443        params.extend(self._additional_params.iter());
16444
16445        params.push("alt", "json");
16446        let mut url = self.hub._base_url.clone() + "v1/{+name}";
16447        if self._scopes.is_empty() {
16448            self._scopes
16449                .insert(Scope::CloudPlatform.as_ref().to_string());
16450        }
16451
16452        #[allow(clippy::single_element_loop)]
16453        for &(find_this, param_name) in [("{+name}", "name")].iter() {
16454            url = params.uri_replacement(url, param_name, find_this, true);
16455        }
16456        {
16457            let to_remove = ["name"];
16458            params.remove_params(&to_remove);
16459        }
16460
16461        let url = params.parse_with_url(&url);
16462
16463        loop {
16464            let token = match self
16465                .hub
16466                .auth
16467                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16468                .await
16469            {
16470                Ok(token) => token,
16471                Err(e) => match dlg.token(e) {
16472                    Ok(token) => token,
16473                    Err(e) => {
16474                        dlg.finished(false);
16475                        return Err(common::Error::MissingToken(e));
16476                    }
16477                },
16478            };
16479            let mut req_result = {
16480                let client = &self.hub.client;
16481                dlg.pre_request();
16482                let mut req_builder = hyper::Request::builder()
16483                    .method(hyper::Method::GET)
16484                    .uri(url.as_str())
16485                    .header(USER_AGENT, self.hub._user_agent.clone());
16486
16487                if let Some(token) = token.as_ref() {
16488                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16489                }
16490
16491                let request = req_builder
16492                    .header(CONTENT_LENGTH, 0_u64)
16493                    .body(common::to_body::<String>(None));
16494
16495                client.request(request.unwrap()).await
16496            };
16497
16498            match req_result {
16499                Err(err) => {
16500                    if let common::Retry::After(d) = dlg.http_error(&err) {
16501                        sleep(d).await;
16502                        continue;
16503                    }
16504                    dlg.finished(false);
16505                    return Err(common::Error::HttpError(err));
16506                }
16507                Ok(res) => {
16508                    let (mut parts, body) = res.into_parts();
16509                    let mut body = common::Body::new(body);
16510                    if !parts.status.is_success() {
16511                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16512                        let error = serde_json::from_str(&common::to_string(&bytes));
16513                        let response = common::to_response(parts, bytes.into());
16514
16515                        if let common::Retry::After(d) =
16516                            dlg.http_failure(&response, error.as_ref().ok())
16517                        {
16518                            sleep(d).await;
16519                            continue;
16520                        }
16521
16522                        dlg.finished(false);
16523
16524                        return Err(match error {
16525                            Ok(value) => common::Error::BadRequest(value),
16526                            _ => common::Error::Failure(response),
16527                        });
16528                    }
16529                    let response = {
16530                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16531                        let encoded = common::to_string(&bytes);
16532                        match serde_json::from_str(&encoded) {
16533                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16534                            Err(error) => {
16535                                dlg.response_json_decode_error(&encoded, &error);
16536                                return Err(common::Error::JsonDecodeError(
16537                                    encoded.to_string(),
16538                                    error,
16539                                ));
16540                            }
16541                        }
16542                    };
16543
16544                    dlg.finished(true);
16545                    return Ok(response);
16546                }
16547            }
16548        }
16549    }
16550
16551    /// The name of the operation resource.
16552    ///
16553    /// Sets the *name* path property to the given value.
16554    ///
16555    /// Even though the property as already been set when instantiating this call,
16556    /// we provide this method for API completeness.
16557    pub fn name(mut self, new_value: &str) -> ProjectOperationGetCall<'a, C> {
16558        self._name = new_value.to_string();
16559        self
16560    }
16561    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16562    /// while executing the actual API request.
16563    ///
16564    /// ````text
16565    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16566    /// ````
16567    ///
16568    /// Sets the *delegate* property to the given value.
16569    pub fn delegate(
16570        mut self,
16571        new_value: &'a mut dyn common::Delegate,
16572    ) -> ProjectOperationGetCall<'a, C> {
16573        self._delegate = Some(new_value);
16574        self
16575    }
16576
16577    /// Set any additional parameter of the query string used in the request.
16578    /// It should be used to set parameters which are not yet available through their own
16579    /// setters.
16580    ///
16581    /// Please note that this method must not be used to set any of the known parameters
16582    /// which have their own setter method. If done anyway, the request will fail.
16583    ///
16584    /// # Additional Parameters
16585    ///
16586    /// * *$.xgafv* (query-string) - V1 error format.
16587    /// * *access_token* (query-string) - OAuth access token.
16588    /// * *alt* (query-string) - Data format for response.
16589    /// * *callback* (query-string) - JSONP
16590    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16591    /// * *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.
16592    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16593    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16594    /// * *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.
16595    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16596    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16597    pub fn param<T>(mut self, name: T, value: T) -> ProjectOperationGetCall<'a, C>
16598    where
16599        T: AsRef<str>,
16600    {
16601        self._additional_params
16602            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16603        self
16604    }
16605
16606    /// Identifies the authorization scope for the method you are building.
16607    ///
16608    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16609    /// [`Scope::CloudPlatform`].
16610    ///
16611    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16612    /// tokens for more than one scope.
16613    ///
16614    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16615    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16616    /// sufficient, a read-write scope will do as well.
16617    pub fn add_scope<St>(mut self, scope: St) -> ProjectOperationGetCall<'a, C>
16618    where
16619        St: AsRef<str>,
16620    {
16621        self._scopes.insert(String::from(scope.as_ref()));
16622        self
16623    }
16624    /// Identifies the authorization scope(s) for the method you are building.
16625    ///
16626    /// See [`Self::add_scope()`] for details.
16627    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOperationGetCall<'a, C>
16628    where
16629        I: IntoIterator<Item = St>,
16630        St: AsRef<str>,
16631    {
16632        self._scopes
16633            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16634        self
16635    }
16636
16637    /// Removes all scopes, and no default scope will be used either.
16638    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16639    /// for details).
16640    pub fn clear_scopes(mut self) -> ProjectOperationGetCall<'a, C> {
16641        self._scopes.clear();
16642        self
16643    }
16644}
16645
16646/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
16647///
16648/// A builder for the *operations.list* method supported by a *project* resource.
16649/// It is not used directly, but through a [`ProjectMethods`] instance.
16650///
16651/// # Example
16652///
16653/// Instantiate a resource method builder
16654///
16655/// ```test_harness,no_run
16656/// # extern crate hyper;
16657/// # extern crate hyper_rustls;
16658/// # extern crate google_ml1 as ml1;
16659/// # async fn dox() {
16660/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16661///
16662/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16663/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16664/// #     .with_native_roots()
16665/// #     .unwrap()
16666/// #     .https_only()
16667/// #     .enable_http2()
16668/// #     .build();
16669///
16670/// # let executor = hyper_util::rt::TokioExecutor::new();
16671/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16672/// #     secret,
16673/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16674/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16675/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16676/// #     ),
16677/// # ).build().await.unwrap();
16678///
16679/// # let client = hyper_util::client::legacy::Client::builder(
16680/// #     hyper_util::rt::TokioExecutor::new()
16681/// # )
16682/// # .build(
16683/// #     hyper_rustls::HttpsConnectorBuilder::new()
16684/// #         .with_native_roots()
16685/// #         .unwrap()
16686/// #         .https_or_http()
16687/// #         .enable_http2()
16688/// #         .build()
16689/// # );
16690/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
16691/// // You can configure optional parameters by calling the respective setters at will, and
16692/// // execute the final call using `doit()`.
16693/// // Values shown here are possibly random and not representative !
16694/// let result = hub.projects().operations_list("name")
16695///              .page_token("et")
16696///              .page_size(-95)
16697///              .filter("Stet")
16698///              .doit().await;
16699/// # }
16700/// ```
16701pub struct ProjectOperationListCall<'a, C>
16702where
16703    C: 'a,
16704{
16705    hub: &'a CloudMachineLearningEngine<C>,
16706    _name: String,
16707    _page_token: Option<String>,
16708    _page_size: Option<i32>,
16709    _filter: Option<String>,
16710    _delegate: Option<&'a mut dyn common::Delegate>,
16711    _additional_params: HashMap<String, String>,
16712    _scopes: BTreeSet<String>,
16713}
16714
16715impl<'a, C> common::CallBuilder for ProjectOperationListCall<'a, C> {}
16716
16717impl<'a, C> ProjectOperationListCall<'a, C>
16718where
16719    C: common::Connector,
16720{
16721    /// Perform the operation you have build so far.
16722    pub async fn doit(
16723        mut self,
16724    ) -> common::Result<(common::Response, GoogleLongrunning__ListOperationsResponse)> {
16725        use std::borrow::Cow;
16726        use std::io::{Read, Seek};
16727
16728        use common::{url::Params, ToParts};
16729        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16730
16731        let mut dd = common::DefaultDelegate;
16732        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16733        dlg.begin(common::MethodInfo {
16734            id: "ml.projects.operations.list",
16735            http_method: hyper::Method::GET,
16736        });
16737
16738        for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
16739            if self._additional_params.contains_key(field) {
16740                dlg.finished(false);
16741                return Err(common::Error::FieldClash(field));
16742            }
16743        }
16744
16745        let mut params = Params::with_capacity(6 + self._additional_params.len());
16746        params.push("name", self._name);
16747        if let Some(value) = self._page_token.as_ref() {
16748            params.push("pageToken", value);
16749        }
16750        if let Some(value) = self._page_size.as_ref() {
16751            params.push("pageSize", value.to_string());
16752        }
16753        if let Some(value) = self._filter.as_ref() {
16754            params.push("filter", value);
16755        }
16756
16757        params.extend(self._additional_params.iter());
16758
16759        params.push("alt", "json");
16760        let mut url = self.hub._base_url.clone() + "v1/{+name}/operations";
16761        if self._scopes.is_empty() {
16762            self._scopes
16763                .insert(Scope::CloudPlatform.as_ref().to_string());
16764        }
16765
16766        #[allow(clippy::single_element_loop)]
16767        for &(find_this, param_name) in [("{+name}", "name")].iter() {
16768            url = params.uri_replacement(url, param_name, find_this, true);
16769        }
16770        {
16771            let to_remove = ["name"];
16772            params.remove_params(&to_remove);
16773        }
16774
16775        let url = params.parse_with_url(&url);
16776
16777        loop {
16778            let token = match self
16779                .hub
16780                .auth
16781                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16782                .await
16783            {
16784                Ok(token) => token,
16785                Err(e) => match dlg.token(e) {
16786                    Ok(token) => token,
16787                    Err(e) => {
16788                        dlg.finished(false);
16789                        return Err(common::Error::MissingToken(e));
16790                    }
16791                },
16792            };
16793            let mut req_result = {
16794                let client = &self.hub.client;
16795                dlg.pre_request();
16796                let mut req_builder = hyper::Request::builder()
16797                    .method(hyper::Method::GET)
16798                    .uri(url.as_str())
16799                    .header(USER_AGENT, self.hub._user_agent.clone());
16800
16801                if let Some(token) = token.as_ref() {
16802                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16803                }
16804
16805                let request = req_builder
16806                    .header(CONTENT_LENGTH, 0_u64)
16807                    .body(common::to_body::<String>(None));
16808
16809                client.request(request.unwrap()).await
16810            };
16811
16812            match req_result {
16813                Err(err) => {
16814                    if let common::Retry::After(d) = dlg.http_error(&err) {
16815                        sleep(d).await;
16816                        continue;
16817                    }
16818                    dlg.finished(false);
16819                    return Err(common::Error::HttpError(err));
16820                }
16821                Ok(res) => {
16822                    let (mut parts, body) = res.into_parts();
16823                    let mut body = common::Body::new(body);
16824                    if !parts.status.is_success() {
16825                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16826                        let error = serde_json::from_str(&common::to_string(&bytes));
16827                        let response = common::to_response(parts, bytes.into());
16828
16829                        if let common::Retry::After(d) =
16830                            dlg.http_failure(&response, error.as_ref().ok())
16831                        {
16832                            sleep(d).await;
16833                            continue;
16834                        }
16835
16836                        dlg.finished(false);
16837
16838                        return Err(match error {
16839                            Ok(value) => common::Error::BadRequest(value),
16840                            _ => common::Error::Failure(response),
16841                        });
16842                    }
16843                    let response = {
16844                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16845                        let encoded = common::to_string(&bytes);
16846                        match serde_json::from_str(&encoded) {
16847                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16848                            Err(error) => {
16849                                dlg.response_json_decode_error(&encoded, &error);
16850                                return Err(common::Error::JsonDecodeError(
16851                                    encoded.to_string(),
16852                                    error,
16853                                ));
16854                            }
16855                        }
16856                    };
16857
16858                    dlg.finished(true);
16859                    return Ok(response);
16860                }
16861            }
16862        }
16863    }
16864
16865    /// The name of the operation's parent resource.
16866    ///
16867    /// Sets the *name* path property to the given value.
16868    ///
16869    /// Even though the property as already been set when instantiating this call,
16870    /// we provide this method for API completeness.
16871    pub fn name(mut self, new_value: &str) -> ProjectOperationListCall<'a, C> {
16872        self._name = new_value.to_string();
16873        self
16874    }
16875    /// The standard list page token.
16876    ///
16877    /// Sets the *page token* query property to the given value.
16878    pub fn page_token(mut self, new_value: &str) -> ProjectOperationListCall<'a, C> {
16879        self._page_token = Some(new_value.to_string());
16880        self
16881    }
16882    /// The standard list page size.
16883    ///
16884    /// Sets the *page size* query property to the given value.
16885    pub fn page_size(mut self, new_value: i32) -> ProjectOperationListCall<'a, C> {
16886        self._page_size = Some(new_value);
16887        self
16888    }
16889    /// The standard list filter.
16890    ///
16891    /// Sets the *filter* query property to the given value.
16892    pub fn filter(mut self, new_value: &str) -> ProjectOperationListCall<'a, C> {
16893        self._filter = Some(new_value.to_string());
16894        self
16895    }
16896    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16897    /// while executing the actual API request.
16898    ///
16899    /// ````text
16900    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16901    /// ````
16902    ///
16903    /// Sets the *delegate* property to the given value.
16904    pub fn delegate(
16905        mut self,
16906        new_value: &'a mut dyn common::Delegate,
16907    ) -> ProjectOperationListCall<'a, C> {
16908        self._delegate = Some(new_value);
16909        self
16910    }
16911
16912    /// Set any additional parameter of the query string used in the request.
16913    /// It should be used to set parameters which are not yet available through their own
16914    /// setters.
16915    ///
16916    /// Please note that this method must not be used to set any of the known parameters
16917    /// which have their own setter method. If done anyway, the request will fail.
16918    ///
16919    /// # Additional Parameters
16920    ///
16921    /// * *$.xgafv* (query-string) - V1 error format.
16922    /// * *access_token* (query-string) - OAuth access token.
16923    /// * *alt* (query-string) - Data format for response.
16924    /// * *callback* (query-string) - JSONP
16925    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16926    /// * *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.
16927    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16928    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16929    /// * *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.
16930    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16931    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16932    pub fn param<T>(mut self, name: T, value: T) -> ProjectOperationListCall<'a, C>
16933    where
16934        T: AsRef<str>,
16935    {
16936        self._additional_params
16937            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16938        self
16939    }
16940
16941    /// Identifies the authorization scope for the method you are building.
16942    ///
16943    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16944    /// [`Scope::CloudPlatform`].
16945    ///
16946    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16947    /// tokens for more than one scope.
16948    ///
16949    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16950    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16951    /// sufficient, a read-write scope will do as well.
16952    pub fn add_scope<St>(mut self, scope: St) -> ProjectOperationListCall<'a, C>
16953    where
16954        St: AsRef<str>,
16955    {
16956        self._scopes.insert(String::from(scope.as_ref()));
16957        self
16958    }
16959    /// Identifies the authorization scope(s) for the method you are building.
16960    ///
16961    /// See [`Self::add_scope()`] for details.
16962    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOperationListCall<'a, C>
16963    where
16964        I: IntoIterator<Item = St>,
16965        St: AsRef<str>,
16966    {
16967        self._scopes
16968            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16969        self
16970    }
16971
16972    /// Removes all scopes, and no default scope will be used either.
16973    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16974    /// for details).
16975    pub fn clear_scopes(mut self) -> ProjectOperationListCall<'a, C> {
16976        self._scopes.clear();
16977        self
16978    }
16979}
16980
16981/// Performs explanation on the data in the request. {% dynamic include "/ai-platform/includes/___explain-request" %}
16982///
16983/// A builder for the *explain* method supported by a *project* resource.
16984/// It is not used directly, but through a [`ProjectMethods`] instance.
16985///
16986/// # Example
16987///
16988/// Instantiate a resource method builder
16989///
16990/// ```test_harness,no_run
16991/// # extern crate hyper;
16992/// # extern crate hyper_rustls;
16993/// # extern crate google_ml1 as ml1;
16994/// use ml1::api::GoogleCloudMlV1__ExplainRequest;
16995/// # async fn dox() {
16996/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16997///
16998/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16999/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17000/// #     .with_native_roots()
17001/// #     .unwrap()
17002/// #     .https_only()
17003/// #     .enable_http2()
17004/// #     .build();
17005///
17006/// # let executor = hyper_util::rt::TokioExecutor::new();
17007/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17008/// #     secret,
17009/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17010/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17011/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17012/// #     ),
17013/// # ).build().await.unwrap();
17014///
17015/// # let client = hyper_util::client::legacy::Client::builder(
17016/// #     hyper_util::rt::TokioExecutor::new()
17017/// # )
17018/// # .build(
17019/// #     hyper_rustls::HttpsConnectorBuilder::new()
17020/// #         .with_native_roots()
17021/// #         .unwrap()
17022/// #         .https_or_http()
17023/// #         .enable_http2()
17024/// #         .build()
17025/// # );
17026/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
17027/// // As the method needs a request, you would usually fill it with the desired information
17028/// // into the respective structure. Some of the parts shown here might not be applicable !
17029/// // Values shown here are possibly random and not representative !
17030/// let mut req = GoogleCloudMlV1__ExplainRequest::default();
17031///
17032/// // You can configure optional parameters by calling the respective setters at will, and
17033/// // execute the final call using `doit()`.
17034/// // Values shown here are possibly random and not representative !
17035/// let result = hub.projects().explain(req, "name")
17036///              .doit().await;
17037/// # }
17038/// ```
17039pub struct ProjectExplainCall<'a, C>
17040where
17041    C: 'a,
17042{
17043    hub: &'a CloudMachineLearningEngine<C>,
17044    _request: GoogleCloudMlV1__ExplainRequest,
17045    _name: String,
17046    _delegate: Option<&'a mut dyn common::Delegate>,
17047    _additional_params: HashMap<String, String>,
17048    _scopes: BTreeSet<String>,
17049}
17050
17051impl<'a, C> common::CallBuilder for ProjectExplainCall<'a, C> {}
17052
17053impl<'a, C> ProjectExplainCall<'a, C>
17054where
17055    C: common::Connector,
17056{
17057    /// Perform the operation you have build so far.
17058    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleApi__HttpBody)> {
17059        use std::borrow::Cow;
17060        use std::io::{Read, Seek};
17061
17062        use common::{url::Params, ToParts};
17063        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17064
17065        let mut dd = common::DefaultDelegate;
17066        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17067        dlg.begin(common::MethodInfo {
17068            id: "ml.projects.explain",
17069            http_method: hyper::Method::POST,
17070        });
17071
17072        for &field in ["alt", "name"].iter() {
17073            if self._additional_params.contains_key(field) {
17074                dlg.finished(false);
17075                return Err(common::Error::FieldClash(field));
17076            }
17077        }
17078
17079        let mut params = Params::with_capacity(4 + self._additional_params.len());
17080        params.push("name", self._name);
17081
17082        params.extend(self._additional_params.iter());
17083
17084        params.push("alt", "json");
17085        let mut url = self.hub._base_url.clone() + "v1/{+name}:explain";
17086        if self._scopes.is_empty() {
17087            self._scopes
17088                .insert(Scope::CloudPlatform.as_ref().to_string());
17089        }
17090
17091        #[allow(clippy::single_element_loop)]
17092        for &(find_this, param_name) in [("{+name}", "name")].iter() {
17093            url = params.uri_replacement(url, param_name, find_this, true);
17094        }
17095        {
17096            let to_remove = ["name"];
17097            params.remove_params(&to_remove);
17098        }
17099
17100        let url = params.parse_with_url(&url);
17101
17102        let mut json_mime_type = mime::APPLICATION_JSON;
17103        let mut request_value_reader = {
17104            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17105            common::remove_json_null_values(&mut value);
17106            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17107            serde_json::to_writer(&mut dst, &value).unwrap();
17108            dst
17109        };
17110        let request_size = request_value_reader
17111            .seek(std::io::SeekFrom::End(0))
17112            .unwrap();
17113        request_value_reader
17114            .seek(std::io::SeekFrom::Start(0))
17115            .unwrap();
17116
17117        loop {
17118            let token = match self
17119                .hub
17120                .auth
17121                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17122                .await
17123            {
17124                Ok(token) => token,
17125                Err(e) => match dlg.token(e) {
17126                    Ok(token) => token,
17127                    Err(e) => {
17128                        dlg.finished(false);
17129                        return Err(common::Error::MissingToken(e));
17130                    }
17131                },
17132            };
17133            request_value_reader
17134                .seek(std::io::SeekFrom::Start(0))
17135                .unwrap();
17136            let mut req_result = {
17137                let client = &self.hub.client;
17138                dlg.pre_request();
17139                let mut req_builder = hyper::Request::builder()
17140                    .method(hyper::Method::POST)
17141                    .uri(url.as_str())
17142                    .header(USER_AGENT, self.hub._user_agent.clone());
17143
17144                if let Some(token) = token.as_ref() {
17145                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17146                }
17147
17148                let request = req_builder
17149                    .header(CONTENT_TYPE, json_mime_type.to_string())
17150                    .header(CONTENT_LENGTH, request_size as u64)
17151                    .body(common::to_body(
17152                        request_value_reader.get_ref().clone().into(),
17153                    ));
17154
17155                client.request(request.unwrap()).await
17156            };
17157
17158            match req_result {
17159                Err(err) => {
17160                    if let common::Retry::After(d) = dlg.http_error(&err) {
17161                        sleep(d).await;
17162                        continue;
17163                    }
17164                    dlg.finished(false);
17165                    return Err(common::Error::HttpError(err));
17166                }
17167                Ok(res) => {
17168                    let (mut parts, body) = res.into_parts();
17169                    let mut body = common::Body::new(body);
17170                    if !parts.status.is_success() {
17171                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17172                        let error = serde_json::from_str(&common::to_string(&bytes));
17173                        let response = common::to_response(parts, bytes.into());
17174
17175                        if let common::Retry::After(d) =
17176                            dlg.http_failure(&response, error.as_ref().ok())
17177                        {
17178                            sleep(d).await;
17179                            continue;
17180                        }
17181
17182                        dlg.finished(false);
17183
17184                        return Err(match error {
17185                            Ok(value) => common::Error::BadRequest(value),
17186                            _ => common::Error::Failure(response),
17187                        });
17188                    }
17189                    let response = {
17190                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17191                        let encoded = common::to_string(&bytes);
17192                        match serde_json::from_str(&encoded) {
17193                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17194                            Err(error) => {
17195                                dlg.response_json_decode_error(&encoded, &error);
17196                                return Err(common::Error::JsonDecodeError(
17197                                    encoded.to_string(),
17198                                    error,
17199                                ));
17200                            }
17201                        }
17202                    };
17203
17204                    dlg.finished(true);
17205                    return Ok(response);
17206                }
17207            }
17208        }
17209    }
17210
17211    ///
17212    /// Sets the *request* property to the given value.
17213    ///
17214    /// Even though the property as already been set when instantiating this call,
17215    /// we provide this method for API completeness.
17216    pub fn request(
17217        mut self,
17218        new_value: GoogleCloudMlV1__ExplainRequest,
17219    ) -> ProjectExplainCall<'a, C> {
17220        self._request = new_value;
17221        self
17222    }
17223    /// Required. The resource name of a model or a version. Authorization: requires the `predict` permission on the specified resource.
17224    ///
17225    /// Sets the *name* path property to the given value.
17226    ///
17227    /// Even though the property as already been set when instantiating this call,
17228    /// we provide this method for API completeness.
17229    pub fn name(mut self, new_value: &str) -> ProjectExplainCall<'a, C> {
17230        self._name = new_value.to_string();
17231        self
17232    }
17233    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17234    /// while executing the actual API request.
17235    ///
17236    /// ````text
17237    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17238    /// ````
17239    ///
17240    /// Sets the *delegate* property to the given value.
17241    pub fn delegate(
17242        mut self,
17243        new_value: &'a mut dyn common::Delegate,
17244    ) -> ProjectExplainCall<'a, C> {
17245        self._delegate = Some(new_value);
17246        self
17247    }
17248
17249    /// Set any additional parameter of the query string used in the request.
17250    /// It should be used to set parameters which are not yet available through their own
17251    /// setters.
17252    ///
17253    /// Please note that this method must not be used to set any of the known parameters
17254    /// which have their own setter method. If done anyway, the request will fail.
17255    ///
17256    /// # Additional Parameters
17257    ///
17258    /// * *$.xgafv* (query-string) - V1 error format.
17259    /// * *access_token* (query-string) - OAuth access token.
17260    /// * *alt* (query-string) - Data format for response.
17261    /// * *callback* (query-string) - JSONP
17262    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17263    /// * *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.
17264    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17265    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17266    /// * *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.
17267    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17268    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17269    pub fn param<T>(mut self, name: T, value: T) -> ProjectExplainCall<'a, C>
17270    where
17271        T: AsRef<str>,
17272    {
17273        self._additional_params
17274            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17275        self
17276    }
17277
17278    /// Identifies the authorization scope for the method you are building.
17279    ///
17280    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17281    /// [`Scope::CloudPlatform`].
17282    ///
17283    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17284    /// tokens for more than one scope.
17285    ///
17286    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17287    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17288    /// sufficient, a read-write scope will do as well.
17289    pub fn add_scope<St>(mut self, scope: St) -> ProjectExplainCall<'a, C>
17290    where
17291        St: AsRef<str>,
17292    {
17293        self._scopes.insert(String::from(scope.as_ref()));
17294        self
17295    }
17296    /// Identifies the authorization scope(s) for the method you are building.
17297    ///
17298    /// See [`Self::add_scope()`] for details.
17299    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectExplainCall<'a, C>
17300    where
17301        I: IntoIterator<Item = St>,
17302        St: AsRef<str>,
17303    {
17304        self._scopes
17305            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17306        self
17307    }
17308
17309    /// Removes all scopes, and no default scope will be used either.
17310    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17311    /// for details).
17312    pub fn clear_scopes(mut self) -> ProjectExplainCall<'a, C> {
17313        self._scopes.clear();
17314        self
17315    }
17316}
17317
17318/// Get the service account information associated with your project. You need this information in order to grant the service account permissions for the Google Cloud Storage location where you put your model training code for training the model with Google Cloud Machine Learning.
17319///
17320/// A builder for the *getConfig* method supported by a *project* resource.
17321/// It is not used directly, but through a [`ProjectMethods`] instance.
17322///
17323/// # Example
17324///
17325/// Instantiate a resource method builder
17326///
17327/// ```test_harness,no_run
17328/// # extern crate hyper;
17329/// # extern crate hyper_rustls;
17330/// # extern crate google_ml1 as ml1;
17331/// # async fn dox() {
17332/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17333///
17334/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17335/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17336/// #     .with_native_roots()
17337/// #     .unwrap()
17338/// #     .https_only()
17339/// #     .enable_http2()
17340/// #     .build();
17341///
17342/// # let executor = hyper_util::rt::TokioExecutor::new();
17343/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17344/// #     secret,
17345/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17346/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17347/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17348/// #     ),
17349/// # ).build().await.unwrap();
17350///
17351/// # let client = hyper_util::client::legacy::Client::builder(
17352/// #     hyper_util::rt::TokioExecutor::new()
17353/// # )
17354/// # .build(
17355/// #     hyper_rustls::HttpsConnectorBuilder::new()
17356/// #         .with_native_roots()
17357/// #         .unwrap()
17358/// #         .https_or_http()
17359/// #         .enable_http2()
17360/// #         .build()
17361/// # );
17362/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
17363/// // You can configure optional parameters by calling the respective setters at will, and
17364/// // execute the final call using `doit()`.
17365/// // Values shown here are possibly random and not representative !
17366/// let result = hub.projects().get_config("name")
17367///              .doit().await;
17368/// # }
17369/// ```
17370pub struct ProjectGetConfigCall<'a, C>
17371where
17372    C: 'a,
17373{
17374    hub: &'a CloudMachineLearningEngine<C>,
17375    _name: String,
17376    _delegate: Option<&'a mut dyn common::Delegate>,
17377    _additional_params: HashMap<String, String>,
17378    _scopes: BTreeSet<String>,
17379}
17380
17381impl<'a, C> common::CallBuilder for ProjectGetConfigCall<'a, C> {}
17382
17383impl<'a, C> ProjectGetConfigCall<'a, C>
17384where
17385    C: common::Connector,
17386{
17387    /// Perform the operation you have build so far.
17388    pub async fn doit(
17389        mut self,
17390    ) -> common::Result<(common::Response, GoogleCloudMlV1__GetConfigResponse)> {
17391        use std::borrow::Cow;
17392        use std::io::{Read, Seek};
17393
17394        use common::{url::Params, ToParts};
17395        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17396
17397        let mut dd = common::DefaultDelegate;
17398        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17399        dlg.begin(common::MethodInfo {
17400            id: "ml.projects.getConfig",
17401            http_method: hyper::Method::GET,
17402        });
17403
17404        for &field in ["alt", "name"].iter() {
17405            if self._additional_params.contains_key(field) {
17406                dlg.finished(false);
17407                return Err(common::Error::FieldClash(field));
17408            }
17409        }
17410
17411        let mut params = Params::with_capacity(3 + self._additional_params.len());
17412        params.push("name", self._name);
17413
17414        params.extend(self._additional_params.iter());
17415
17416        params.push("alt", "json");
17417        let mut url = self.hub._base_url.clone() + "v1/{+name}:getConfig";
17418        if self._scopes.is_empty() {
17419            self._scopes
17420                .insert(Scope::CloudPlatform.as_ref().to_string());
17421        }
17422
17423        #[allow(clippy::single_element_loop)]
17424        for &(find_this, param_name) in [("{+name}", "name")].iter() {
17425            url = params.uri_replacement(url, param_name, find_this, true);
17426        }
17427        {
17428            let to_remove = ["name"];
17429            params.remove_params(&to_remove);
17430        }
17431
17432        let url = params.parse_with_url(&url);
17433
17434        loop {
17435            let token = match self
17436                .hub
17437                .auth
17438                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17439                .await
17440            {
17441                Ok(token) => token,
17442                Err(e) => match dlg.token(e) {
17443                    Ok(token) => token,
17444                    Err(e) => {
17445                        dlg.finished(false);
17446                        return Err(common::Error::MissingToken(e));
17447                    }
17448                },
17449            };
17450            let mut req_result = {
17451                let client = &self.hub.client;
17452                dlg.pre_request();
17453                let mut req_builder = hyper::Request::builder()
17454                    .method(hyper::Method::GET)
17455                    .uri(url.as_str())
17456                    .header(USER_AGENT, self.hub._user_agent.clone());
17457
17458                if let Some(token) = token.as_ref() {
17459                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17460                }
17461
17462                let request = req_builder
17463                    .header(CONTENT_LENGTH, 0_u64)
17464                    .body(common::to_body::<String>(None));
17465
17466                client.request(request.unwrap()).await
17467            };
17468
17469            match req_result {
17470                Err(err) => {
17471                    if let common::Retry::After(d) = dlg.http_error(&err) {
17472                        sleep(d).await;
17473                        continue;
17474                    }
17475                    dlg.finished(false);
17476                    return Err(common::Error::HttpError(err));
17477                }
17478                Ok(res) => {
17479                    let (mut parts, body) = res.into_parts();
17480                    let mut body = common::Body::new(body);
17481                    if !parts.status.is_success() {
17482                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17483                        let error = serde_json::from_str(&common::to_string(&bytes));
17484                        let response = common::to_response(parts, bytes.into());
17485
17486                        if let common::Retry::After(d) =
17487                            dlg.http_failure(&response, error.as_ref().ok())
17488                        {
17489                            sleep(d).await;
17490                            continue;
17491                        }
17492
17493                        dlg.finished(false);
17494
17495                        return Err(match error {
17496                            Ok(value) => common::Error::BadRequest(value),
17497                            _ => common::Error::Failure(response),
17498                        });
17499                    }
17500                    let response = {
17501                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17502                        let encoded = common::to_string(&bytes);
17503                        match serde_json::from_str(&encoded) {
17504                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17505                            Err(error) => {
17506                                dlg.response_json_decode_error(&encoded, &error);
17507                                return Err(common::Error::JsonDecodeError(
17508                                    encoded.to_string(),
17509                                    error,
17510                                ));
17511                            }
17512                        }
17513                    };
17514
17515                    dlg.finished(true);
17516                    return Ok(response);
17517                }
17518            }
17519        }
17520    }
17521
17522    /// Required. The project name.
17523    ///
17524    /// Sets the *name* path property to the given value.
17525    ///
17526    /// Even though the property as already been set when instantiating this call,
17527    /// we provide this method for API completeness.
17528    pub fn name(mut self, new_value: &str) -> ProjectGetConfigCall<'a, C> {
17529        self._name = new_value.to_string();
17530        self
17531    }
17532    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17533    /// while executing the actual API request.
17534    ///
17535    /// ````text
17536    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17537    /// ````
17538    ///
17539    /// Sets the *delegate* property to the given value.
17540    pub fn delegate(
17541        mut self,
17542        new_value: &'a mut dyn common::Delegate,
17543    ) -> ProjectGetConfigCall<'a, C> {
17544        self._delegate = Some(new_value);
17545        self
17546    }
17547
17548    /// Set any additional parameter of the query string used in the request.
17549    /// It should be used to set parameters which are not yet available through their own
17550    /// setters.
17551    ///
17552    /// Please note that this method must not be used to set any of the known parameters
17553    /// which have their own setter method. If done anyway, the request will fail.
17554    ///
17555    /// # Additional Parameters
17556    ///
17557    /// * *$.xgafv* (query-string) - V1 error format.
17558    /// * *access_token* (query-string) - OAuth access token.
17559    /// * *alt* (query-string) - Data format for response.
17560    /// * *callback* (query-string) - JSONP
17561    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17562    /// * *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.
17563    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17564    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17565    /// * *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.
17566    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17567    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17568    pub fn param<T>(mut self, name: T, value: T) -> ProjectGetConfigCall<'a, C>
17569    where
17570        T: AsRef<str>,
17571    {
17572        self._additional_params
17573            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17574        self
17575    }
17576
17577    /// Identifies the authorization scope for the method you are building.
17578    ///
17579    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17580    /// [`Scope::CloudPlatform`].
17581    ///
17582    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17583    /// tokens for more than one scope.
17584    ///
17585    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17586    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17587    /// sufficient, a read-write scope will do as well.
17588    pub fn add_scope<St>(mut self, scope: St) -> ProjectGetConfigCall<'a, C>
17589    where
17590        St: AsRef<str>,
17591    {
17592        self._scopes.insert(String::from(scope.as_ref()));
17593        self
17594    }
17595    /// Identifies the authorization scope(s) for the method you are building.
17596    ///
17597    /// See [`Self::add_scope()`] for details.
17598    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGetConfigCall<'a, C>
17599    where
17600        I: IntoIterator<Item = St>,
17601        St: AsRef<str>,
17602    {
17603        self._scopes
17604            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17605        self
17606    }
17607
17608    /// Removes all scopes, and no default scope will be used either.
17609    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17610    /// for details).
17611    pub fn clear_scopes(mut self) -> ProjectGetConfigCall<'a, C> {
17612        self._scopes.clear();
17613        self
17614    }
17615}
17616
17617/// Performs online prediction on the data in the request. {% dynamic include "/ai-platform/includes/___predict-request" %}
17618///
17619/// A builder for the *predict* method supported by a *project* resource.
17620/// It is not used directly, but through a [`ProjectMethods`] instance.
17621///
17622/// # Example
17623///
17624/// Instantiate a resource method builder
17625///
17626/// ```test_harness,no_run
17627/// # extern crate hyper;
17628/// # extern crate hyper_rustls;
17629/// # extern crate google_ml1 as ml1;
17630/// use ml1::api::GoogleCloudMlV1__PredictRequest;
17631/// # async fn dox() {
17632/// # use ml1::{CloudMachineLearningEngine, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17633///
17634/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17635/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17636/// #     .with_native_roots()
17637/// #     .unwrap()
17638/// #     .https_only()
17639/// #     .enable_http2()
17640/// #     .build();
17641///
17642/// # let executor = hyper_util::rt::TokioExecutor::new();
17643/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17644/// #     secret,
17645/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17646/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17647/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17648/// #     ),
17649/// # ).build().await.unwrap();
17650///
17651/// # let client = hyper_util::client::legacy::Client::builder(
17652/// #     hyper_util::rt::TokioExecutor::new()
17653/// # )
17654/// # .build(
17655/// #     hyper_rustls::HttpsConnectorBuilder::new()
17656/// #         .with_native_roots()
17657/// #         .unwrap()
17658/// #         .https_or_http()
17659/// #         .enable_http2()
17660/// #         .build()
17661/// # );
17662/// # let mut hub = CloudMachineLearningEngine::new(client, auth);
17663/// // As the method needs a request, you would usually fill it with the desired information
17664/// // into the respective structure. Some of the parts shown here might not be applicable !
17665/// // Values shown here are possibly random and not representative !
17666/// let mut req = GoogleCloudMlV1__PredictRequest::default();
17667///
17668/// // You can configure optional parameters by calling the respective setters at will, and
17669/// // execute the final call using `doit()`.
17670/// // Values shown here are possibly random and not representative !
17671/// let result = hub.projects().predict(req, "name")
17672///              .doit().await;
17673/// # }
17674/// ```
17675pub struct ProjectPredictCall<'a, C>
17676where
17677    C: 'a,
17678{
17679    hub: &'a CloudMachineLearningEngine<C>,
17680    _request: GoogleCloudMlV1__PredictRequest,
17681    _name: String,
17682    _delegate: Option<&'a mut dyn common::Delegate>,
17683    _additional_params: HashMap<String, String>,
17684    _scopes: BTreeSet<String>,
17685}
17686
17687impl<'a, C> common::CallBuilder for ProjectPredictCall<'a, C> {}
17688
17689impl<'a, C> ProjectPredictCall<'a, C>
17690where
17691    C: common::Connector,
17692{
17693    /// Perform the operation you have build so far.
17694    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleApi__HttpBody)> {
17695        use std::borrow::Cow;
17696        use std::io::{Read, Seek};
17697
17698        use common::{url::Params, ToParts};
17699        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17700
17701        let mut dd = common::DefaultDelegate;
17702        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17703        dlg.begin(common::MethodInfo {
17704            id: "ml.projects.predict",
17705            http_method: hyper::Method::POST,
17706        });
17707
17708        for &field in ["alt", "name"].iter() {
17709            if self._additional_params.contains_key(field) {
17710                dlg.finished(false);
17711                return Err(common::Error::FieldClash(field));
17712            }
17713        }
17714
17715        let mut params = Params::with_capacity(4 + self._additional_params.len());
17716        params.push("name", self._name);
17717
17718        params.extend(self._additional_params.iter());
17719
17720        params.push("alt", "json");
17721        let mut url = self.hub._base_url.clone() + "v1/{+name}:predict";
17722        if self._scopes.is_empty() {
17723            self._scopes
17724                .insert(Scope::CloudPlatform.as_ref().to_string());
17725        }
17726
17727        #[allow(clippy::single_element_loop)]
17728        for &(find_this, param_name) in [("{+name}", "name")].iter() {
17729            url = params.uri_replacement(url, param_name, find_this, true);
17730        }
17731        {
17732            let to_remove = ["name"];
17733            params.remove_params(&to_remove);
17734        }
17735
17736        let url = params.parse_with_url(&url);
17737
17738        let mut json_mime_type = mime::APPLICATION_JSON;
17739        let mut request_value_reader = {
17740            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17741            common::remove_json_null_values(&mut value);
17742            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17743            serde_json::to_writer(&mut dst, &value).unwrap();
17744            dst
17745        };
17746        let request_size = request_value_reader
17747            .seek(std::io::SeekFrom::End(0))
17748            .unwrap();
17749        request_value_reader
17750            .seek(std::io::SeekFrom::Start(0))
17751            .unwrap();
17752
17753        loop {
17754            let token = match self
17755                .hub
17756                .auth
17757                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17758                .await
17759            {
17760                Ok(token) => token,
17761                Err(e) => match dlg.token(e) {
17762                    Ok(token) => token,
17763                    Err(e) => {
17764                        dlg.finished(false);
17765                        return Err(common::Error::MissingToken(e));
17766                    }
17767                },
17768            };
17769            request_value_reader
17770                .seek(std::io::SeekFrom::Start(0))
17771                .unwrap();
17772            let mut req_result = {
17773                let client = &self.hub.client;
17774                dlg.pre_request();
17775                let mut req_builder = hyper::Request::builder()
17776                    .method(hyper::Method::POST)
17777                    .uri(url.as_str())
17778                    .header(USER_AGENT, self.hub._user_agent.clone());
17779
17780                if let Some(token) = token.as_ref() {
17781                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17782                }
17783
17784                let request = req_builder
17785                    .header(CONTENT_TYPE, json_mime_type.to_string())
17786                    .header(CONTENT_LENGTH, request_size as u64)
17787                    .body(common::to_body(
17788                        request_value_reader.get_ref().clone().into(),
17789                    ));
17790
17791                client.request(request.unwrap()).await
17792            };
17793
17794            match req_result {
17795                Err(err) => {
17796                    if let common::Retry::After(d) = dlg.http_error(&err) {
17797                        sleep(d).await;
17798                        continue;
17799                    }
17800                    dlg.finished(false);
17801                    return Err(common::Error::HttpError(err));
17802                }
17803                Ok(res) => {
17804                    let (mut parts, body) = res.into_parts();
17805                    let mut body = common::Body::new(body);
17806                    if !parts.status.is_success() {
17807                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17808                        let error = serde_json::from_str(&common::to_string(&bytes));
17809                        let response = common::to_response(parts, bytes.into());
17810
17811                        if let common::Retry::After(d) =
17812                            dlg.http_failure(&response, error.as_ref().ok())
17813                        {
17814                            sleep(d).await;
17815                            continue;
17816                        }
17817
17818                        dlg.finished(false);
17819
17820                        return Err(match error {
17821                            Ok(value) => common::Error::BadRequest(value),
17822                            _ => common::Error::Failure(response),
17823                        });
17824                    }
17825                    let response = {
17826                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17827                        let encoded = common::to_string(&bytes);
17828                        match serde_json::from_str(&encoded) {
17829                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17830                            Err(error) => {
17831                                dlg.response_json_decode_error(&encoded, &error);
17832                                return Err(common::Error::JsonDecodeError(
17833                                    encoded.to_string(),
17834                                    error,
17835                                ));
17836                            }
17837                        }
17838                    };
17839
17840                    dlg.finished(true);
17841                    return Ok(response);
17842                }
17843            }
17844        }
17845    }
17846
17847    ///
17848    /// Sets the *request* property to the given value.
17849    ///
17850    /// Even though the property as already been set when instantiating this call,
17851    /// we provide this method for API completeness.
17852    pub fn request(
17853        mut self,
17854        new_value: GoogleCloudMlV1__PredictRequest,
17855    ) -> ProjectPredictCall<'a, C> {
17856        self._request = new_value;
17857        self
17858    }
17859    /// Required. The resource name of a model or a version. Authorization: requires the `predict` permission on the specified resource.
17860    ///
17861    /// Sets the *name* path property to the given value.
17862    ///
17863    /// Even though the property as already been set when instantiating this call,
17864    /// we provide this method for API completeness.
17865    pub fn name(mut self, new_value: &str) -> ProjectPredictCall<'a, C> {
17866        self._name = new_value.to_string();
17867        self
17868    }
17869    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17870    /// while executing the actual API request.
17871    ///
17872    /// ````text
17873    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17874    /// ````
17875    ///
17876    /// Sets the *delegate* property to the given value.
17877    pub fn delegate(
17878        mut self,
17879        new_value: &'a mut dyn common::Delegate,
17880    ) -> ProjectPredictCall<'a, C> {
17881        self._delegate = Some(new_value);
17882        self
17883    }
17884
17885    /// Set any additional parameter of the query string used in the request.
17886    /// It should be used to set parameters which are not yet available through their own
17887    /// setters.
17888    ///
17889    /// Please note that this method must not be used to set any of the known parameters
17890    /// which have their own setter method. If done anyway, the request will fail.
17891    ///
17892    /// # Additional Parameters
17893    ///
17894    /// * *$.xgafv* (query-string) - V1 error format.
17895    /// * *access_token* (query-string) - OAuth access token.
17896    /// * *alt* (query-string) - Data format for response.
17897    /// * *callback* (query-string) - JSONP
17898    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17899    /// * *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.
17900    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17901    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17902    /// * *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.
17903    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17904    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17905    pub fn param<T>(mut self, name: T, value: T) -> ProjectPredictCall<'a, C>
17906    where
17907        T: AsRef<str>,
17908    {
17909        self._additional_params
17910            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17911        self
17912    }
17913
17914    /// Identifies the authorization scope for the method you are building.
17915    ///
17916    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17917    /// [`Scope::CloudPlatform`].
17918    ///
17919    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17920    /// tokens for more than one scope.
17921    ///
17922    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17923    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17924    /// sufficient, a read-write scope will do as well.
17925    pub fn add_scope<St>(mut self, scope: St) -> ProjectPredictCall<'a, C>
17926    where
17927        St: AsRef<str>,
17928    {
17929        self._scopes.insert(String::from(scope.as_ref()));
17930        self
17931    }
17932    /// Identifies the authorization scope(s) for the method you are building.
17933    ///
17934    /// See [`Self::add_scope()`] for details.
17935    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectPredictCall<'a, C>
17936    where
17937        I: IntoIterator<Item = St>,
17938        St: AsRef<str>,
17939    {
17940        self._scopes
17941            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17942        self
17943    }
17944
17945    /// Removes all scopes, and no default scope will be used either.
17946    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17947    /// for details).
17948    pub fn clear_scopes(mut self) -> ProjectPredictCall<'a, C> {
17949        self._scopes.clear();
17950        self
17951    }
17952}