google_notebooks1/
api.rs

1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16    /// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
17    CloudPlatform,
18}
19
20impl AsRef<str> for Scope {
21    fn as_ref(&self) -> &str {
22        match *self {
23            Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
24        }
25    }
26}
27
28#[allow(clippy::derivable_impls)]
29impl Default for Scope {
30    fn default() -> Scope {
31        Scope::CloudPlatform
32    }
33}
34
35// ########
36// HUB ###
37// ######
38
39/// Central instance to access all AIPlatformNotebooks related resource activities
40///
41/// # Examples
42///
43/// Instantiate a new hub
44///
45/// ```test_harness,no_run
46/// extern crate hyper;
47/// extern crate hyper_rustls;
48/// extern crate google_notebooks1 as notebooks1;
49/// use notebooks1::api::Runtime;
50/// use notebooks1::{Result, Error};
51/// # async fn dox() {
52/// use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
53///
54/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
55/// // `client_secret`, among other things.
56/// let secret: yup_oauth2::ApplicationSecret = Default::default();
57/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
58/// // unless you replace  `None` with the desired Flow.
59/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
60/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
61/// // retrieve them from storage.
62/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
63///     .with_native_roots()
64///     .unwrap()
65///     .https_only()
66///     .enable_http2()
67///     .build();
68///
69/// let executor = hyper_util::rt::TokioExecutor::new();
70/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
71///     secret,
72///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
73///     yup_oauth2::client::CustomHyperClientBuilder::from(
74///         hyper_util::client::legacy::Client::builder(executor).build(connector),
75///     ),
76/// ).build().await.unwrap();
77///
78/// let client = hyper_util::client::legacy::Client::builder(
79///     hyper_util::rt::TokioExecutor::new()
80/// )
81/// .build(
82///     hyper_rustls::HttpsConnectorBuilder::new()
83///         .with_native_roots()
84///         .unwrap()
85///         .https_or_http()
86///         .enable_http2()
87///         .build()
88/// );
89/// let mut hub = AIPlatformNotebooks::new(client, auth);
90/// // As the method needs a request, you would usually fill it with the desired information
91/// // into the respective structure. Some of the parts shown here might not be applicable !
92/// // Values shown here are possibly random and not representative !
93/// let mut req = Runtime::default();
94///
95/// // You can configure optional parameters by calling the respective setters at will, and
96/// // execute the final call using `doit()`.
97/// // Values shown here are possibly random and not representative !
98/// let result = hub.projects().locations_runtimes_create(req, "parent")
99///              .runtime_id("sed")
100///              .request_id("amet.")
101///              .doit().await;
102///
103/// match result {
104///     Err(e) => match e {
105///         // The Error enum provides details about what exactly happened.
106///         // You can also just use its `Debug`, `Display` or `Error` traits
107///          Error::HttpError(_)
108///         |Error::Io(_)
109///         |Error::MissingAPIKey
110///         |Error::MissingToken(_)
111///         |Error::Cancelled
112///         |Error::UploadSizeLimitExceeded(_, _)
113///         |Error::Failure(_)
114///         |Error::BadRequest(_)
115///         |Error::FieldClash(_)
116///         |Error::JsonDecodeError(_, _) => println!("{}", e),
117///     },
118///     Ok(res) => println!("Success: {:?}", res),
119/// }
120/// # }
121/// ```
122#[derive(Clone)]
123pub struct AIPlatformNotebooks<C> {
124    pub client: common::Client<C>,
125    pub auth: Box<dyn common::GetToken>,
126    _user_agent: String,
127    _base_url: String,
128    _root_url: String,
129}
130
131impl<C> common::Hub for AIPlatformNotebooks<C> {}
132
133impl<'a, C> AIPlatformNotebooks<C> {
134    pub fn new<A: 'static + common::GetToken>(
135        client: common::Client<C>,
136        auth: A,
137    ) -> AIPlatformNotebooks<C> {
138        AIPlatformNotebooks {
139            client,
140            auth: Box::new(auth),
141            _user_agent: "google-api-rust-client/7.0.0".to_string(),
142            _base_url: "https://notebooks.googleapis.com/".to_string(),
143            _root_url: "https://notebooks.googleapis.com/".to_string(),
144        }
145    }
146
147    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
148        ProjectMethods { hub: self }
149    }
150
151    /// Set the user-agent header field to use in all requests to the server.
152    /// It defaults to `google-api-rust-client/7.0.0`.
153    ///
154    /// Returns the previously set user-agent.
155    pub fn user_agent(&mut self, agent_name: String) -> String {
156        std::mem::replace(&mut self._user_agent, agent_name)
157    }
158
159    /// Set the base url to use in all requests to the server.
160    /// It defaults to `https://notebooks.googleapis.com/`.
161    ///
162    /// Returns the previously set base url.
163    pub fn base_url(&mut self, new_base_url: String) -> String {
164        std::mem::replace(&mut self._base_url, new_base_url)
165    }
166
167    /// Set the root url to use in all requests to the server.
168    /// It defaults to `https://notebooks.googleapis.com/`.
169    ///
170    /// Returns the previously set root url.
171    pub fn root_url(&mut self, new_root_url: String) -> String {
172        std::mem::replace(&mut self._root_url, new_root_url)
173    }
174}
175
176// ############
177// SCHEMAS ###
178// ##########
179/// Definition of a hardware accelerator. Note that not all combinations of `type` and `core_count` are valid. See [GPUs on Compute Engine](https://cloud.google.com/compute/docs/gpus/#gpus-list) to find a valid combination. TPUs are not supported.
180///
181/// This type is not used in any activity, and only used as *part* of another schema.
182///
183#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
184#[serde_with::serde_as]
185#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
186pub struct AcceleratorConfig {
187    /// Count of cores of this accelerator.
188    #[serde(rename = "coreCount")]
189    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
190    pub core_count: Option<i64>,
191    /// Type of this accelerator.
192    #[serde(rename = "type")]
193    pub type_: Option<String>,
194}
195
196impl common::Part for AcceleratorConfig {}
197
198/// Associates `members`, or principals, with a `role`.
199///
200/// This type is not used in any activity, and only used as *part* of another schema.
201///
202#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
203#[serde_with::serde_as]
204#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
205pub struct Binding {
206    /// 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).
207    pub condition: Option<Expr>,
208    /// 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`.
209    pub members: Option<Vec<String>>,
210    /// 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).
211    pub role: Option<String>,
212}
213
214impl common::Part for Binding {}
215
216/// Definition of the boot image used by the Runtime. Used to facilitate runtime upgradeability.
217///
218/// This type is not used in any activity, and only used as *part* of another schema.
219///
220#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
221#[serde_with::serde_as]
222#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
223pub struct BootImage {
224    _never_set: Option<bool>,
225}
226
227impl common::Part for BootImage {}
228
229/// The request message for Operations.CancelOperation.
230///
231/// # Activities
232///
233/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
234/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
235///
236/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (request)
237#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
238#[serde_with::serde_as]
239#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
240pub struct CancelOperationRequest {
241    _never_set: Option<bool>,
242}
243
244impl common::RequestValue for CancelOperationRequest {}
245
246/// Definition of a container image for starting a notebook instance with the environment installed in a container.
247///
248/// This type is not used in any activity, and only used as *part* of another schema.
249///
250#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
251#[serde_with::serde_as]
252#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
253pub struct ContainerImage {
254    /// Required. The path to the container image repository. For example: `gcr.io/{project_id}/{image_name}`
255    pub repository: Option<String>,
256    /// The tag of the container image. If not specified, this defaults to the latest tag.
257    pub tag: Option<String>,
258}
259
260impl common::Part for ContainerImage {}
261
262/// Parameters used in Dataproc JobType executions.
263///
264/// This type is not used in any activity, and only used as *part* of another schema.
265///
266#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
267#[serde_with::serde_as]
268#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
269pub struct DataprocParameters {
270    /// URI for cluster used to run Dataproc execution. Format: `projects/{PROJECT_ID}/regions/{REGION}/clusters/{CLUSTER_NAME}`
271    pub cluster: Option<String>,
272}
273
274impl common::Part for DataprocParameters {}
275
276/// Request for creating a notebook instance diagnostic file.
277///
278/// # Activities
279///
280/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
281/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
282///
283/// * [locations instances diagnose projects](ProjectLocationInstanceDiagnoseCall) (request)
284#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
285#[serde_with::serde_as]
286#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
287pub struct DiagnoseInstanceRequest {
288    /// Required. Defines flags that are used to run the diagnostic tool
289    #[serde(rename = "diagnosticConfig")]
290    pub diagnostic_config: Option<DiagnosticConfig>,
291    /// Optional. Maximum amount of time in minutes before the operation times out.
292    #[serde(rename = "timeoutMinutes")]
293    pub timeout_minutes: Option<i32>,
294}
295
296impl common::RequestValue for DiagnoseInstanceRequest {}
297
298/// Request for creating a notebook instance diagnostic file.
299///
300/// # Activities
301///
302/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
303/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
304///
305/// * [locations runtimes diagnose projects](ProjectLocationRuntimeDiagnoseCall) (request)
306#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
307#[serde_with::serde_as]
308#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
309pub struct DiagnoseRuntimeRequest {
310    /// Required. Defines flags that are used to run the diagnostic tool
311    #[serde(rename = "diagnosticConfig")]
312    pub diagnostic_config: Option<DiagnosticConfig>,
313    /// Optional. Maximum amount of time in minutes before the operation times out.
314    #[serde(rename = "timeoutMinutes")]
315    pub timeout_minutes: Option<i32>,
316}
317
318impl common::RequestValue for DiagnoseRuntimeRequest {}
319
320/// Defines flags that are used to run the diagnostic tool
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 DiagnosticConfig {
328    /// Optional. Enables flag to copy all `/home/jupyter` folder contents
329    #[serde(rename = "copyHomeFilesFlagEnabled")]
330    pub copy_home_files_flag_enabled: Option<bool>,
331    /// Required. User Cloud Storage bucket location (REQUIRED). Must be formatted with path prefix (`gs://$GCS_BUCKET`). Permissions: User Managed Notebooks: - storage.buckets.writer: Must be given to the project's service account attached to VM. Google Managed Notebooks: - storage.buckets.writer: Must be given to the project's service account or user credentials attached to VM depending on authentication mode. Cloud Storage bucket Log file will be written to `gs://$GCS_BUCKET/$RELATIVE_PATH/$VM_DATE_$TIME.tar.gz`
332    #[serde(rename = "gcsBucket")]
333    pub gcs_bucket: Option<String>,
334    /// Optional. Enables flag to capture packets from the instance for 30 seconds
335    #[serde(rename = "packetCaptureFlagEnabled")]
336    pub packet_capture_flag_enabled: Option<bool>,
337    /// Optional. Defines the relative storage path in the Cloud Storage bucket where the diagnostic logs will be written: Default path will be the root directory of the Cloud Storage bucket (`gs://$GCS_BUCKET/$DATE_$TIME.tar.gz`) Example of full path where Log file will be written: `gs://$GCS_BUCKET/$RELATIVE_PATH/`
338    #[serde(rename = "relativePath")]
339    pub relative_path: Option<String>,
340    /// Optional. Enables flag to repair service for instance
341    #[serde(rename = "repairFlagEnabled")]
342    pub repair_flag_enabled: Option<bool>,
343}
344
345impl common::Part for DiagnosticConfig {}
346
347/// An instance-attached disk resource.
348///
349/// This type is not used in any activity, and only used as *part* of another schema.
350///
351#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
352#[serde_with::serde_as]
353#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
354pub struct Disk {
355    /// Indicates whether the disk will be auto-deleted when the instance is deleted (but not when the disk is detached from the instance).
356    #[serde(rename = "autoDelete")]
357    pub auto_delete: Option<bool>,
358    /// Indicates that this is a boot disk. The virtual machine will use the first partition of the disk for its root filesystem.
359    pub boot: Option<bool>,
360    /// Indicates a unique device name of your choice that is reflected into the `/dev/disk/by-id/google-*` tree of a Linux operating system running within the instance. This name can be used to reference the device for mounting, resizing, and so on, from within the instance. If not specified, the server chooses a default device name to apply to this disk, in the form persistent-disk-x, where x is a number assigned by Google Compute Engine.This field is only applicable for persistent disks.
361    #[serde(rename = "deviceName")]
362    pub device_name: Option<String>,
363    /// Indicates the size of the disk in base-2 GB.
364    #[serde(rename = "diskSizeGb")]
365    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
366    pub disk_size_gb: Option<i64>,
367    /// Indicates a list of features to enable on the guest operating system. Applicable only for bootable images. Read Enabling guest operating system features to see a list of available options.
368    #[serde(rename = "guestOsFeatures")]
369    pub guest_os_features: Option<Vec<GuestOsFeature>>,
370    /// A zero-based index to this disk, where 0 is reserved for the boot disk. If you have many disks attached to an instance, each disk would have a unique index number.
371    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
372    pub index: Option<i64>,
373    /// Indicates the disk interface to use for attaching this disk, which is either SCSI or NVME. The default is SCSI. Persistent disks must always use SCSI and the request will fail if you attempt to attach a persistent disk in any other format than SCSI. Local SSDs can use either NVME or SCSI. For performance characteristics of SCSI over NVMe, see Local SSD performance. Valid values: * `NVME` * `SCSI`
374    pub interface: Option<String>,
375    /// Type of the resource. Always compute#attachedDisk for attached disks.
376    pub kind: Option<String>,
377    /// A list of publicly visible licenses. Reserved for Google's use. A License represents billing and aggregate usage data for public and marketplace images.
378    pub licenses: Option<Vec<String>>,
379    /// The mode in which to attach this disk, either `READ_WRITE` or `READ_ONLY`. If not specified, the default is to attach the disk in `READ_WRITE` mode. Valid values: * `READ_ONLY` * `READ_WRITE`
380    pub mode: Option<String>,
381    /// Indicates a valid partial or full URL to an existing Persistent Disk resource.
382    pub source: Option<String>,
383    /// Indicates the type of the disk, either `SCRATCH` or `PERSISTENT`. Valid values: * `PERSISTENT` * `SCRATCH`
384    #[serde(rename = "type")]
385    pub type_: Option<String>,
386}
387
388impl common::Part for Disk {}
389
390/// 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); }
391///
392/// # Activities
393///
394/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
395/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
396///
397/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (response)
398/// * [locations operations delete projects](ProjectLocationOperationDeleteCall) (response)
399#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
400#[serde_with::serde_as]
401#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
402pub struct Empty {
403    _never_set: Option<bool>,
404}
405
406impl common::ResponseResult for Empty {}
407
408/// Represents a custom encryption key configuration that can be applied to a resource. This will encrypt all disks in Virtual Machine.
409///
410/// This type is not used in any activity, and only used as *part* of another schema.
411///
412#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
413#[serde_with::serde_as]
414#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
415pub struct EncryptionConfig {
416    /// The Cloud KMS resource identifier of the customer-managed encryption key used to protect a resource, such as a disks. It has the following format: `projects/{PROJECT_ID}/locations/{REGION}/keyRings/{KEY_RING_NAME}/cryptoKeys/{KEY_NAME}`
417    #[serde(rename = "kmsKey")]
418    pub kms_key: Option<String>,
419}
420
421impl common::Part for EncryptionConfig {}
422
423/// Definition of a software environment that is used to start a notebook instance.
424///
425/// # Activities
426///
427/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
428/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
429///
430/// * [locations environments create projects](ProjectLocationEnvironmentCreateCall) (request)
431/// * [locations environments get projects](ProjectLocationEnvironmentGetCall) (response)
432#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
433#[serde_with::serde_as]
434#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
435pub struct Environment {
436    /// Use a container image to start the notebook instance.
437    #[serde(rename = "containerImage")]
438    pub container_image: Option<ContainerImage>,
439    /// Output only. The time at which this environment was created.
440    #[serde(rename = "createTime")]
441    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
442    /// A brief description of this environment.
443    pub description: Option<String>,
444    /// Display name of this environment for the UI.
445    #[serde(rename = "displayName")]
446    pub display_name: Option<String>,
447    /// Output only. Name of this environment. Format: `projects/{project_id}/locations/{location}/environments/{environment_id}`
448    pub name: Option<String>,
449    /// Path to a Bash script that automatically runs after a notebook instance fully boots up. The path must be a URL or Cloud Storage path. Example: `"gs://path-to-file/file-name"`
450    #[serde(rename = "postStartupScript")]
451    pub post_startup_script: Option<String>,
452    /// Use a Compute Engine VM image to start the notebook instance.
453    #[serde(rename = "vmImage")]
454    pub vm_image: Option<VmImage>,
455}
456
457impl common::RequestValue for Environment {}
458impl common::ResponseResult for Environment {}
459
460/// The definition of an Event for a managed / semi-managed notebook instance.
461///
462/// This type is not used in any activity, and only used as *part* of another schema.
463///
464#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
465#[serde_with::serde_as]
466#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
467pub struct Event {
468    /// Optional. Event details. This field is used to pass event information.
469    pub details: Option<HashMap<String, String>>,
470    /// Event report time.
471    #[serde(rename = "reportTime")]
472    pub report_time: Option<chrono::DateTime<chrono::offset::Utc>>,
473    /// Event type.
474    #[serde(rename = "type")]
475    pub type_: Option<String>,
476}
477
478impl common::Part for Event {}
479
480/// The definition of a single executed notebook.
481///
482/// # Activities
483///
484/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
485/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
486///
487/// * [locations executions create projects](ProjectLocationExecutionCreateCall) (request)
488/// * [locations executions get projects](ProjectLocationExecutionGetCall) (response)
489#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
490#[serde_with::serde_as]
491#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
492pub struct Execution {
493    /// Output only. Time the Execution was instantiated.
494    #[serde(rename = "createTime")]
495    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
496    /// A brief description of this execution.
497    pub description: Option<String>,
498    /// Output only. Name used for UI purposes. Name can only contain alphanumeric characters and underscores '_'.
499    #[serde(rename = "displayName")]
500    pub display_name: Option<String>,
501    /// execute metadata including name, hardware spec, region, labels, etc.
502    #[serde(rename = "executionTemplate")]
503    pub execution_template: Option<ExecutionTemplate>,
504    /// Output only. The URI of the external job used to execute the notebook.
505    #[serde(rename = "jobUri")]
506    pub job_uri: Option<String>,
507    /// Output only. The resource name of the execute. Format: `projects/{project_id}/locations/{location}/executions/{execution_id}`
508    pub name: Option<String>,
509    /// Output notebook file generated by this execution
510    #[serde(rename = "outputNotebookFile")]
511    pub output_notebook_file: Option<String>,
512    /// Output only. State of the underlying AI Platform job.
513    pub state: Option<String>,
514    /// Output only. Time the Execution was last updated.
515    #[serde(rename = "updateTime")]
516    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
517}
518
519impl common::RequestValue for Execution {}
520impl common::ResponseResult for Execution {}
521
522/// The description a notebook execution workload.
523///
524/// This type is not used in any activity, and only used as *part* of another schema.
525///
526#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
527#[serde_with::serde_as]
528#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
529pub struct ExecutionTemplate {
530    /// Configuration (count and accelerator type) for hardware running notebook execution.
531    #[serde(rename = "acceleratorConfig")]
532    pub accelerator_config: Option<SchedulerAcceleratorConfig>,
533    /// Container Image URI to a DLVM Example: 'gcr.io/deeplearning-platform-release/base-cu100' More examples can be found at: https://cloud.google.com/ai-platform/deep-learning-containers/docs/choosing-container
534    #[serde(rename = "containerImageUri")]
535    pub container_image_uri: Option<String>,
536    /// Parameters used in Dataproc JobType executions.
537    #[serde(rename = "dataprocParameters")]
538    pub dataproc_parameters: Option<DataprocParameters>,
539    /// Path to the notebook file to execute. Must be in a Google Cloud Storage bucket. Format: `gs://{bucket_name}/{folder}/{notebook_file_name}` Ex: `gs://notebook_user/scheduled_notebooks/sentiment_notebook.ipynb`
540    #[serde(rename = "inputNotebookFile")]
541    pub input_notebook_file: Option<String>,
542    /// The type of Job to be used on this execution.
543    #[serde(rename = "jobType")]
544    pub job_type: Option<String>,
545    /// Name of the kernel spec to use. This must be specified if the kernel spec name on the execution target does not match the name in the input notebook file.
546    #[serde(rename = "kernelSpec")]
547    pub kernel_spec: Option<String>,
548    /// Labels for execution. If execution is scheduled, a field included will be 'nbs-scheduled'. Otherwise, it is an immediate execution, and an included field will be 'nbs-immediate'. Use fields to efficiently index between various types of executions.
549    pub labels: Option<HashMap<String, String>>,
550    /// 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. The following types are supported: - `n1-standard-4` - `n1-standard-8` - `n1-standard-16` - `n1-standard-32` - `n1-standard-64` - `n1-standard-96` - `n1-highmem-2` - `n1-highmem-4` - `n1-highmem-8` - `n1-highmem-16` - `n1-highmem-32` - `n1-highmem-64` - `n1-highmem-96` - `n1-highcpu-16` - `n1-highcpu-32` - `n1-highcpu-64` - `n1-highcpu-96` Alternatively, you can use the following legacy machine types: - `standard` - `large_model` - `complex_model_s` - `complex_model_m` - `complex_model_l` - `standard_gpu` - `complex_model_m_gpu` - `complex_model_l_gpu` - `standard_p100` - `complex_model_m_p100` - `standard_v100` - `large_model_v100` - `complex_model_m_v100` - `complex_model_l_v100` 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 TPU](https://cloud.google.com/ai-platform/training/docs/using-tpus#configuring_a_custom_tpu_machine).
551    #[serde(rename = "masterType")]
552    pub master_type: Option<String>,
553    /// Path to the notebook folder to write to. Must be in a Google Cloud Storage bucket path. Format: `gs://{bucket_name}/{folder}` Ex: `gs://notebook_user/scheduled_notebooks`
554    #[serde(rename = "outputNotebookFolder")]
555    pub output_notebook_folder: Option<String>,
556    /// Parameters used within the 'input_notebook_file' notebook.
557    pub parameters: Option<String>,
558    /// Parameters to be overridden in the notebook during execution. Ref https://papermill.readthedocs.io/en/latest/usage-parameterize.html on how to specifying parameters in the input notebook and pass them here in an YAML file. Ex: `gs://notebook_user/scheduled_notebooks/sentiment_notebook_params.yaml`
559    #[serde(rename = "paramsYamlFile")]
560    pub params_yaml_file: Option<String>,
561    /// Required. Scale tier of the hardware used for notebook execution. DEPRECATED Will be discontinued. As right now only CUSTOM is supported.
562    #[serde(rename = "scaleTier")]
563    pub scale_tier: Option<String>,
564    /// The email address of a service account to use when running the execution. You must have the `iam.serviceAccounts.actAs` permission for the specified service account.
565    #[serde(rename = "serviceAccount")]
566    pub service_account: Option<String>,
567    /// The name of a Vertex AI [Tensorboard] resource to which this execution will upload Tensorboard logs. Format: `projects/{project}/locations/{location}/tensorboards/{tensorboard}`
568    pub tensorboard: Option<String>,
569    /// Parameters used in Vertex AI JobType executions.
570    #[serde(rename = "vertexAiParameters")]
571    pub vertex_ai_parameters: Option<VertexAIParameters>,
572}
573
574impl common::Part for ExecutionTemplate {}
575
576/// 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.
577///
578/// This type is not used in any activity, and only used as *part* of another schema.
579///
580#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
581#[serde_with::serde_as]
582#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
583pub struct Expr {
584    /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
585    pub description: Option<String>,
586    /// Textual representation of an expression in Common Expression Language syntax.
587    pub expression: Option<String>,
588    /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
589    pub location: Option<String>,
590    /// 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.
591    pub title: Option<String>,
592}
593
594impl common::Part for Expr {}
595
596/// Response for checking if a notebook instance is healthy.
597///
598/// # Activities
599///
600/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
601/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
602///
603/// * [locations instances get instance health projects](ProjectLocationInstanceGetInstanceHealthCall) (response)
604#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
605#[serde_with::serde_as]
606#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
607pub struct GetInstanceHealthResponse {
608    /// Output only. Additional information about instance health. Example: healthInfo": { "docker_proxy_agent_status": "1", "docker_status": "1", "jupyterlab_api_status": "-1", "jupyterlab_status": "-1", "updated": "2020-10-18 09:40:03.573409" }
609    #[serde(rename = "healthInfo")]
610    pub health_info: Option<HashMap<String, String>>,
611    /// Output only. Runtime health_state.
612    #[serde(rename = "healthState")]
613    pub health_state: Option<String>,
614}
615
616impl common::ResponseResult for GetInstanceHealthResponse {}
617
618/// Guest OS features for boot disk.
619///
620/// This type is not used in any activity, and only used as *part* of another schema.
621///
622#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
623#[serde_with::serde_as]
624#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
625pub struct GuestOsFeature {
626    /// The ID of a supported feature. Read Enabling guest operating system features to see a list of available options. Valid values: * `FEATURE_TYPE_UNSPECIFIED` * `MULTI_IP_SUBNET` * `SECURE_BOOT` * `UEFI_COMPATIBLE` * `VIRTIO_SCSI_MULTIQUEUE` * `WINDOWS`
627    #[serde(rename = "type")]
628    pub type_: Option<String>,
629}
630
631impl common::Part for GuestOsFeature {}
632
633/// The definition of a notebook instance.
634///
635/// # Activities
636///
637/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
638/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
639///
640/// * [locations instances create projects](ProjectLocationInstanceCreateCall) (request)
641/// * [locations instances get projects](ProjectLocationInstanceGetCall) (response)
642#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
643#[serde_with::serde_as]
644#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
645pub struct Instance {
646    /// The hardware accelerator used on this instance. If you use accelerators, make sure that your configuration has [enough vCPUs and memory to support the `machine_type` you have selected](https://cloud.google.com/compute/docs/gpus/#gpus-list).
647    #[serde(rename = "acceleratorConfig")]
648    pub accelerator_config: Option<AcceleratorConfig>,
649    /// Input only. The size of the boot disk in GB attached to this instance, up to a maximum of 64000 GB (64 TB). The minimum recommended value is 100 GB. If not specified, this defaults to 100.
650    #[serde(rename = "bootDiskSizeGb")]
651    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
652    pub boot_disk_size_gb: Option<i64>,
653    /// Input only. The type of the boot disk attached to this instance, defaults to standard persistent disk (`PD_STANDARD`).
654    #[serde(rename = "bootDiskType")]
655    pub boot_disk_type: Option<String>,
656    /// Optional. Flag to enable ip forwarding or not, default false/off. https://cloud.google.com/vpc/docs/using-routes#canipforward
657    #[serde(rename = "canIpForward")]
658    pub can_ip_forward: Option<bool>,
659    /// Use a container image to start the notebook instance.
660    #[serde(rename = "containerImage")]
661    pub container_image: Option<ContainerImage>,
662    /// Output only. Instance creation time.
663    #[serde(rename = "createTime")]
664    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
665    /// Output only. Email address of entity that sent original CreateInstance request.
666    pub creator: Option<String>,
667    /// Specify a custom Cloud Storage path where the GPU driver is stored. If not specified, we'll automatically choose from official GPU drivers.
668    #[serde(rename = "customGpuDriverPath")]
669    pub custom_gpu_driver_path: Option<String>,
670    /// Input only. The size of the data disk in GB attached to this instance, up to a maximum of 64000 GB (64 TB). You can choose the size of the data disk based on how big your notebooks and data are. If not specified, this defaults to 100.
671    #[serde(rename = "dataDiskSizeGb")]
672    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
673    pub data_disk_size_gb: Option<i64>,
674    /// Input only. The type of the data disk attached to this instance, defaults to standard persistent disk (`PD_STANDARD`).
675    #[serde(rename = "dataDiskType")]
676    pub data_disk_type: Option<String>,
677    /// Input only. Disk encryption method used on the boot and data disks, defaults to GMEK.
678    #[serde(rename = "diskEncryption")]
679    pub disk_encryption: Option<String>,
680    /// Output only. Attached disks to notebook instance.
681    pub disks: Option<Vec<Disk>>,
682    /// Whether the end user authorizes Google Cloud to install GPU driver on this instance. If this field is empty or set to false, the GPU driver won't be installed. Only applicable to instances with GPUs.
683    #[serde(rename = "installGpuDriver")]
684    pub install_gpu_driver: Option<bool>,
685    /// Output only. Checks how feasible a migration from UmN to WbI is.
686    #[serde(rename = "instanceMigrationEligibility")]
687    pub instance_migration_eligibility: Option<InstanceMigrationEligibility>,
688    /// Input only. The owner of this instance after creation. Format: `alias@example.com` Currently supports one owner only. If not specified, all of the service account users of your VM instance's service account can use the instance.
689    #[serde(rename = "instanceOwners")]
690    pub instance_owners: Option<Vec<String>>,
691    /// Input only. The KMS key used to encrypt the disks, only applicable if disk_encryption is CMEK. Format: `projects/{project_id}/locations/{location}/keyRings/{key_ring_id}/cryptoKeys/{key_id}` Learn more about [using your own encryption keys](https://cloud.google.com/kms/docs/quickstart).
692    #[serde(rename = "kmsKey")]
693    pub kms_key: Option<String>,
694    /// Labels to apply to this instance. These can be later modified by the setLabels method.
695    pub labels: Option<HashMap<String, String>>,
696    /// Required. The [Compute Engine machine type](https://cloud.google.com/compute/docs/machine-resource) of this instance.
697    #[serde(rename = "machineType")]
698    pub machine_type: Option<String>,
699    /// Custom metadata to apply to this instance. For example, to specify a Cloud Storage bucket for automatic backup, you can use the `gcs-data-bucket` metadata tag. Format: `"--metadata=gcs-data-bucket=BUCKET"`.
700    pub metadata: Option<HashMap<String, String>>,
701    /// Output only. Bool indicating whether this notebook has been migrated to a Workbench Instance
702    pub migrated: Option<bool>,
703    /// Output only. The name of this notebook instance. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
704    pub name: Option<String>,
705    /// The name of the VPC that this instance is in. Format: `projects/{project_id}/global/networks/{network_id}`
706    pub network: Option<String>,
707    /// Optional. The type of vNIC to be used on this interface. This may be gVNIC or VirtioNet.
708    #[serde(rename = "nicType")]
709    pub nic_type: Option<String>,
710    /// If true, the notebook instance will not register with the proxy.
711    #[serde(rename = "noProxyAccess")]
712    pub no_proxy_access: Option<bool>,
713    /// If true, no external IP will be assigned to this instance.
714    #[serde(rename = "noPublicIp")]
715    pub no_public_ip: Option<bool>,
716    /// Input only. If true, the data disk will not be auto deleted when deleting the instance.
717    #[serde(rename = "noRemoveDataDisk")]
718    pub no_remove_data_disk: Option<bool>,
719    /// Path to a Bash script that automatically runs after a notebook instance fully boots up. The path must be a URL or Cloud Storage path (`gs://path-to-file/file-name`).
720    #[serde(rename = "postStartupScript")]
721    pub post_startup_script: Option<String>,
722    /// Output only. The proxy endpoint that is used to access the Jupyter notebook.
723    #[serde(rename = "proxyUri")]
724    pub proxy_uri: Option<String>,
725    /// Optional. The optional reservation affinity. Setting this field will apply the specified [Zonal Compute Reservation](https://cloud.google.com/compute/docs/instances/reserving-zonal-resources) to this notebook instance.
726    #[serde(rename = "reservationAffinity")]
727    pub reservation_affinity: Option<ReservationAffinity>,
728    /// The service account on this instance, giving access to other Google Cloud services. You can use any service account within the same project, but you must have the service account user permission to use the instance. If not specified, the [Compute Engine default service account](https://cloud.google.com/compute/docs/access/service-accounts#default_service_account) is used.
729    #[serde(rename = "serviceAccount")]
730    pub service_account: Option<String>,
731    /// Optional. The URIs of service account scopes to be included in Compute Engine instances. If not specified, the following [scopes](https://cloud.google.com/compute/docs/access/service-accounts#accesscopesiam) are defined: - https://www.googleapis.com/auth/cloud-platform - https://www.googleapis.com/auth/userinfo.email If not using default scopes, you need at least: https://www.googleapis.com/auth/compute
732    #[serde(rename = "serviceAccountScopes")]
733    pub service_account_scopes: Option<Vec<String>>,
734    /// Optional. Shielded VM configuration. [Images using supported Shielded VM features](https://cloud.google.com/compute/docs/instances/modifying-shielded-vm).
735    #[serde(rename = "shieldedInstanceConfig")]
736    pub shielded_instance_config: Option<ShieldedInstanceConfig>,
737    /// Output only. The state of this instance.
738    pub state: Option<String>,
739    /// The name of the subnet that this instance is in. Format: `projects/{project_id}/regions/{region}/subnetworks/{subnetwork_id}`
740    pub subnet: Option<String>,
741    /// Optional. The Compute Engine network tags to add to runtime (see [Add network tags](https://cloud.google.com/vpc/docs/add-remove-network-tags)).
742    pub tags: Option<Vec<String>>,
743    /// Output only. Instance update time.
744    #[serde(rename = "updateTime")]
745    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
746    /// The upgrade history of this instance.
747    #[serde(rename = "upgradeHistory")]
748    pub upgrade_history: Option<Vec<UpgradeHistoryEntry>>,
749    /// Use a Compute Engine VM image to start the notebook instance.
750    #[serde(rename = "vmImage")]
751    pub vm_image: Option<VmImage>,
752}
753
754impl common::RequestValue for Instance {}
755impl common::ResponseResult for Instance {}
756
757/// Notebook instance configurations that can be updated.
758///
759/// This type is not used in any activity, and only used as *part* of another schema.
760///
761#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
762#[serde_with::serde_as]
763#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
764pub struct InstanceConfig {
765    /// Verifies core internal services are running.
766    #[serde(rename = "enableHealthMonitoring")]
767    pub enable_health_monitoring: Option<bool>,
768    /// Cron expression in UTC timezone, used to schedule instance auto upgrade. Please follow the [cron format](https://en.wikipedia.org/wiki/Cron).
769    #[serde(rename = "notebookUpgradeSchedule")]
770    pub notebook_upgrade_schedule: Option<String>,
771}
772
773impl common::Part for InstanceConfig {}
774
775/// InstanceMigrationEligibility represents the feasibility information of a migration from UmN to WbI.
776///
777/// This type is not used in any activity, and only used as *part* of another schema.
778///
779#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
780#[serde_with::serde_as]
781#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
782pub struct InstanceMigrationEligibility {
783    /// Output only. Certain configurations make the UmN ineligible for an automatic migration. A manual migration is required.
784    pub errors: Option<Vec<String>>,
785    /// Output only. Certain configurations will be defaulted during the migration.
786    pub warnings: Option<Vec<String>>,
787}
788
789impl common::Part for InstanceMigrationEligibility {}
790
791/// Response for checking if a notebook instance is upgradeable.
792///
793/// # Activities
794///
795/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
796/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
797///
798/// * [locations instances is upgradeable projects](ProjectLocationInstanceIsUpgradeableCall) (response)
799#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
800#[serde_with::serde_as]
801#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
802pub struct IsInstanceUpgradeableResponse {
803    /// The new image self link this instance will be upgraded to if calling the upgrade endpoint. This field will only be populated if field upgradeable is true.
804    #[serde(rename = "upgradeImage")]
805    pub upgrade_image: Option<String>,
806    /// Additional information about upgrade.
807    #[serde(rename = "upgradeInfo")]
808    pub upgrade_info: Option<String>,
809    /// The version this instance will be upgraded to if calling the upgrade endpoint. This field will only be populated if field upgradeable is true.
810    #[serde(rename = "upgradeVersion")]
811    pub upgrade_version: Option<String>,
812    /// If an instance is upgradeable.
813    pub upgradeable: Option<bool>,
814}
815
816impl common::ResponseResult for IsInstanceUpgradeableResponse {}
817
818/// Response for listing environments.
819///
820/// # Activities
821///
822/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
823/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
824///
825/// * [locations environments list projects](ProjectLocationEnvironmentListCall) (response)
826#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
827#[serde_with::serde_as]
828#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
829pub struct ListEnvironmentsResponse {
830    /// A list of returned environments.
831    pub environments: Option<Vec<Environment>>,
832    /// A page token that can be used to continue listing from the last result in the next list call.
833    #[serde(rename = "nextPageToken")]
834    pub next_page_token: Option<String>,
835    /// Locations that could not be reached.
836    pub unreachable: Option<Vec<String>>,
837}
838
839impl common::ResponseResult for ListEnvironmentsResponse {}
840
841/// Response for listing scheduled notebook executions
842///
843/// # Activities
844///
845/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
846/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
847///
848/// * [locations executions list projects](ProjectLocationExecutionListCall) (response)
849#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
850#[serde_with::serde_as]
851#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
852pub struct ListExecutionsResponse {
853    /// A list of returned instances.
854    pub executions: Option<Vec<Execution>>,
855    /// Page token that can be used to continue listing from the last result in the next list call.
856    #[serde(rename = "nextPageToken")]
857    pub next_page_token: Option<String>,
858    /// Executions IDs that could not be reached. For example: ['projects/{project_id}/location/{location}/executions/imagenet_test1', 'projects/{project_id}/location/{location}/executions/classifier_train1']
859    pub unreachable: Option<Vec<String>>,
860}
861
862impl common::ResponseResult for ListExecutionsResponse {}
863
864/// Response for listing notebook instances.
865///
866/// # Activities
867///
868/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
869/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
870///
871/// * [locations instances list projects](ProjectLocationInstanceListCall) (response)
872#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
873#[serde_with::serde_as]
874#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
875pub struct ListInstancesResponse {
876    /// A list of returned instances.
877    pub instances: Option<Vec<Instance>>,
878    /// Page token that can be used to continue listing from the last result in the next list call.
879    #[serde(rename = "nextPageToken")]
880    pub next_page_token: Option<String>,
881    /// Locations that could not be reached. For example, `['us-west1-a', 'us-central1-b']`. A ListInstancesResponse will only contain either instances or unreachables,
882    pub unreachable: Option<Vec<String>>,
883}
884
885impl common::ResponseResult for ListInstancesResponse {}
886
887/// The response message for Locations.ListLocations.
888///
889/// # Activities
890///
891/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
892/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
893///
894/// * [locations list projects](ProjectLocationListCall) (response)
895#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
896#[serde_with::serde_as]
897#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
898pub struct ListLocationsResponse {
899    /// A list of locations that matches the specified filter in the request.
900    pub locations: Option<Vec<Location>>,
901    /// The standard List next-page token.
902    #[serde(rename = "nextPageToken")]
903    pub next_page_token: Option<String>,
904}
905
906impl common::ResponseResult for ListLocationsResponse {}
907
908/// The response message for Operations.ListOperations.
909///
910/// # Activities
911///
912/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
913/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
914///
915/// * [locations operations list projects](ProjectLocationOperationListCall) (response)
916#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
917#[serde_with::serde_as]
918#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
919pub struct ListOperationsResponse {
920    /// The standard List next-page token.
921    #[serde(rename = "nextPageToken")]
922    pub next_page_token: Option<String>,
923    /// A list of operations that matches the specified filter in the request.
924    pub operations: Option<Vec<Operation>>,
925    /// Unordered list. Unreachable resources. Populated when the request sets `ListOperationsRequest.return_partial_success` and reads across collections. For example, when attempting to list all resources across all supported locations.
926    pub unreachable: Option<Vec<String>>,
927}
928
929impl common::ResponseResult for ListOperationsResponse {}
930
931/// Response for listing Managed Notebook Runtimes.
932///
933/// # Activities
934///
935/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
936/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
937///
938/// * [locations runtimes list projects](ProjectLocationRuntimeListCall) (response)
939#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
940#[serde_with::serde_as]
941#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
942pub struct ListRuntimesResponse {
943    /// Page token that can be used to continue listing from the last result in the next list call.
944    #[serde(rename = "nextPageToken")]
945    pub next_page_token: Option<String>,
946    /// A list of returned Runtimes.
947    pub runtimes: Option<Vec<Runtime>>,
948    /// Locations that could not be reached. For example, `['us-west1', 'us-central1']`. A ListRuntimesResponse will only contain either runtimes or unreachables,
949    pub unreachable: Option<Vec<String>>,
950}
951
952impl common::ResponseResult for ListRuntimesResponse {}
953
954/// Response for listing scheduled notebook job.
955///
956/// # Activities
957///
958/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
959/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
960///
961/// * [locations schedules list projects](ProjectLocationScheduleListCall) (response)
962#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
963#[serde_with::serde_as]
964#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
965pub struct ListSchedulesResponse {
966    /// Page token that can be used to continue listing from the last result in the next list call.
967    #[serde(rename = "nextPageToken")]
968    pub next_page_token: Option<String>,
969    /// A list of returned instances.
970    pub schedules: Option<Vec<Schedule>>,
971    /// Schedules that could not be reached. For example: ['projects/{project_id}/location/{location}/schedules/monthly_digest', 'projects/{project_id}/location/{location}/schedules/weekly_sentiment']
972    pub unreachable: Option<Vec<String>>,
973}
974
975impl common::ResponseResult for ListSchedulesResponse {}
976
977/// A Local attached disk resource.
978///
979/// This type is not used in any activity, and only used as *part* of another schema.
980///
981#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
982#[serde_with::serde_as]
983#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
984pub struct LocalDisk {
985    /// Optional. Output only. Specifies whether the disk will be auto-deleted when the instance is deleted (but not when the disk is detached from the instance).
986    #[serde(rename = "autoDelete")]
987    pub auto_delete: Option<bool>,
988    /// Optional. Output only. Indicates that this is a boot disk. The virtual machine will use the first partition of the disk for its root filesystem.
989    pub boot: Option<bool>,
990    /// Optional. Output only. Specifies a unique device name of your choice that is reflected into the `/dev/disk/by-id/google-*` tree of a Linux operating system running within the instance. This name can be used to reference the device for mounting, resizing, and so on, from within the instance. If not specified, the server chooses a default device name to apply to this disk, in the form persistent-disk-x, where x is a number assigned by Google Compute Engine. This field is only applicable for persistent disks.
991    #[serde(rename = "deviceName")]
992    pub device_name: Option<String>,
993    /// Output only. Indicates a list of features to enable on the guest operating system. Applicable only for bootable images. Read Enabling guest operating system features to see a list of available options.
994    #[serde(rename = "guestOsFeatures")]
995    pub guest_os_features: Option<Vec<RuntimeGuestOsFeature>>,
996    /// Output only. A zero-based index to this disk, where 0 is reserved for the boot disk. If you have many disks attached to an instance, each disk would have a unique index number.
997    pub index: Option<i32>,
998    /// Input only. Specifies the parameters for a new disk that will be created alongside the new instance. Use initialization parameters to create boot disks or local SSDs attached to the new instance. This property is mutually exclusive with the source property; you can only define one or the other, but not both.
999    #[serde(rename = "initializeParams")]
1000    pub initialize_params: Option<LocalDiskInitializeParams>,
1001    /// Specifies the disk interface to use for attaching this disk, which is either SCSI or NVME. The default is SCSI. Persistent disks must always use SCSI and the request will fail if you attempt to attach a persistent disk in any other format than SCSI. Local SSDs can use either NVME or SCSI. For performance characteristics of SCSI over NVMe, see Local SSD performance. Valid values: * `NVME` * `SCSI`
1002    pub interface: Option<String>,
1003    /// Output only. Type of the resource. Always compute#attachedDisk for attached disks.
1004    pub kind: Option<String>,
1005    /// Output only. Any valid publicly visible licenses.
1006    pub licenses: Option<Vec<String>>,
1007    /// The mode in which to attach this disk, either `READ_WRITE` or `READ_ONLY`. If not specified, the default is to attach the disk in `READ_WRITE` mode. Valid values: * `READ_ONLY` * `READ_WRITE`
1008    pub mode: Option<String>,
1009    /// Specifies a valid partial or full URL to an existing Persistent Disk resource.
1010    pub source: Option<String>,
1011    /// Specifies the type of the disk, either `SCRATCH` or `PERSISTENT`. If not specified, the default is `PERSISTENT`. Valid values: * `PERSISTENT` * `SCRATCH`
1012    #[serde(rename = "type")]
1013    pub type_: Option<String>,
1014}
1015
1016impl common::Part for LocalDisk {}
1017
1018/// Input only. Specifies the parameters for a new disk that will be created alongside the new instance. Use initialization parameters to create boot disks or local SSDs attached to the new runtime. This property is mutually exclusive with the source property; you can only define one or the other, but not both.
1019///
1020/// This type is not used in any activity, and only used as *part* of another schema.
1021///
1022#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1023#[serde_with::serde_as]
1024#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1025pub struct LocalDiskInitializeParams {
1026    /// Optional. Provide this property when creating the disk.
1027    pub description: Option<String>,
1028    /// Optional. Specifies the disk name. If not specified, the default is to use the name of the instance. If the disk with the instance name exists already in the given zone/region, a new name will be automatically generated.
1029    #[serde(rename = "diskName")]
1030    pub disk_name: Option<String>,
1031    /// Optional. Specifies the size of the disk in base-2 GB. If not specified, the disk will be the same size as the image (usually 10GB). If specified, the size must be equal to or larger than 10GB. Default 100 GB.
1032    #[serde(rename = "diskSizeGb")]
1033    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1034    pub disk_size_gb: Option<i64>,
1035    /// Input only. The type of the boot disk attached to this instance, defaults to standard persistent disk (`PD_STANDARD`).
1036    #[serde(rename = "diskType")]
1037    pub disk_type: Option<String>,
1038    /// Optional. Labels to apply to this disk. These can be later modified by the disks.setLabels method. This field is only applicable for persistent disks.
1039    pub labels: Option<HashMap<String, String>>,
1040}
1041
1042impl common::Part for LocalDiskInitializeParams {}
1043
1044/// A resource that represents a Google Cloud location.
1045///
1046/// # Activities
1047///
1048/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1049/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1050///
1051/// * [locations get projects](ProjectLocationGetCall) (response)
1052#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1053#[serde_with::serde_as]
1054#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1055pub struct Location {
1056    /// The friendly name for this location, typically a nearby city name. For example, "Tokyo".
1057    #[serde(rename = "displayName")]
1058    pub display_name: Option<String>,
1059    /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"}
1060    pub labels: Option<HashMap<String, String>>,
1061    /// The canonical id for this location. For example: `"us-east1"`.
1062    #[serde(rename = "locationId")]
1063    pub location_id: Option<String>,
1064    /// Service-specific metadata. For example the available capacity at the given location.
1065    pub metadata: Option<HashMap<String, serde_json::Value>>,
1066    /// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"`
1067    pub name: Option<String>,
1068}
1069
1070impl common::ResponseResult for Location {}
1071
1072/// Request for migrating a User-Managed Notebook to Workbench Instances.
1073///
1074/// # Activities
1075///
1076/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1077/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1078///
1079/// * [locations instances migrate projects](ProjectLocationInstanceMigrateCall) (request)
1080#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1081#[serde_with::serde_as]
1082#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1083pub struct MigrateInstanceRequest {
1084    /// Optional. Specifies the behavior of post startup script during migration.
1085    #[serde(rename = "postStartupScriptOption")]
1086    pub post_startup_script_option: Option<String>,
1087}
1088
1089impl common::RequestValue for MigrateInstanceRequest {}
1090
1091/// Request for migrating a Runtime to a Workbench Instance.
1092///
1093/// # Activities
1094///
1095/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1096/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1097///
1098/// * [locations runtimes migrate projects](ProjectLocationRuntimeMigrateCall) (request)
1099#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1100#[serde_with::serde_as]
1101#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1102pub struct MigrateRuntimeRequest {
1103    /// Optional. Name of the VPC that the new Instance is in. This is required if the Runtime uses google-managed network. If the Runtime uses customer-owned network, it will reuse the same VPC, and this field must be empty. Format: `projects/{project_id}/global/networks/{network_id}`
1104    pub network: Option<String>,
1105    /// Optional. Specifies the behavior of post startup script during migration.
1106    #[serde(rename = "postStartupScriptOption")]
1107    pub post_startup_script_option: Option<String>,
1108    /// Optional. Idempotent request UUID.
1109    #[serde(rename = "requestId")]
1110    pub request_id: Option<String>,
1111    /// Optional. The service account to be included in the Compute Engine instance of the new Workbench Instance when the Runtime uses "single user only" mode for permission. If not specified, the [Compute Engine default service account](https://cloud.google.com/compute/docs/access/service-accounts#default_service_account) is used. When the Runtime uses service account mode for permission, it will reuse the same service account, and this field must be empty.
1112    #[serde(rename = "serviceAccount")]
1113    pub service_account: Option<String>,
1114    /// Optional. Name of the subnet that the new Instance is in. This is required if the Runtime uses google-managed network. If the Runtime uses customer-owned network, it will reuse the same subnet, and this field must be empty. Format: `projects/{project_id}/regions/{region}/subnetworks/{subnetwork_id}`
1115    pub subnet: Option<String>,
1116}
1117
1118impl common::RequestValue for MigrateRuntimeRequest {}
1119
1120/// This resource represents a long-running operation that is the result of a network API call.
1121///
1122/// # Activities
1123///
1124/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1125/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1126///
1127/// * [locations environments create projects](ProjectLocationEnvironmentCreateCall) (response)
1128/// * [locations environments delete projects](ProjectLocationEnvironmentDeleteCall) (response)
1129/// * [locations executions create projects](ProjectLocationExecutionCreateCall) (response)
1130/// * [locations executions delete projects](ProjectLocationExecutionDeleteCall) (response)
1131/// * [locations instances create projects](ProjectLocationInstanceCreateCall) (response)
1132/// * [locations instances delete projects](ProjectLocationInstanceDeleteCall) (response)
1133/// * [locations instances diagnose projects](ProjectLocationInstanceDiagnoseCall) (response)
1134/// * [locations instances migrate projects](ProjectLocationInstanceMigrateCall) (response)
1135/// * [locations instances register projects](ProjectLocationInstanceRegisterCall) (response)
1136/// * [locations instances report projects](ProjectLocationInstanceReportCall) (response)
1137/// * [locations instances report event projects](ProjectLocationInstanceReportEventCall) (response)
1138/// * [locations instances reset projects](ProjectLocationInstanceResetCall) (response)
1139/// * [locations instances rollback projects](ProjectLocationInstanceRollbackCall) (response)
1140/// * [locations instances set accelerator projects](ProjectLocationInstanceSetAcceleratorCall) (response)
1141/// * [locations instances set labels projects](ProjectLocationInstanceSetLabelCall) (response)
1142/// * [locations instances set machine type projects](ProjectLocationInstanceSetMachineTypeCall) (response)
1143/// * [locations instances start projects](ProjectLocationInstanceStartCall) (response)
1144/// * [locations instances stop projects](ProjectLocationInstanceStopCall) (response)
1145/// * [locations instances update config projects](ProjectLocationInstanceUpdateConfigCall) (response)
1146/// * [locations instances update shielded instance config projects](ProjectLocationInstanceUpdateShieldedInstanceConfigCall) (response)
1147/// * [locations instances upgrade projects](ProjectLocationInstanceUpgradeCall) (response)
1148/// * [locations instances upgrade internal projects](ProjectLocationInstanceUpgradeInternalCall) (response)
1149/// * [locations operations get projects](ProjectLocationOperationGetCall) (response)
1150/// * [locations runtimes create projects](ProjectLocationRuntimeCreateCall) (response)
1151/// * [locations runtimes delete projects](ProjectLocationRuntimeDeleteCall) (response)
1152/// * [locations runtimes diagnose projects](ProjectLocationRuntimeDiagnoseCall) (response)
1153/// * [locations runtimes migrate projects](ProjectLocationRuntimeMigrateCall) (response)
1154/// * [locations runtimes patch projects](ProjectLocationRuntimePatchCall) (response)
1155/// * [locations runtimes report event projects](ProjectLocationRuntimeReportEventCall) (response)
1156/// * [locations runtimes reset projects](ProjectLocationRuntimeResetCall) (response)
1157/// * [locations runtimes start projects](ProjectLocationRuntimeStartCall) (response)
1158/// * [locations runtimes stop projects](ProjectLocationRuntimeStopCall) (response)
1159/// * [locations runtimes switch projects](ProjectLocationRuntimeSwitchCall) (response)
1160/// * [locations runtimes upgrade projects](ProjectLocationRuntimeUpgradeCall) (response)
1161/// * [locations schedules create projects](ProjectLocationScheduleCreateCall) (response)
1162/// * [locations schedules delete projects](ProjectLocationScheduleDeleteCall) (response)
1163/// * [locations schedules trigger projects](ProjectLocationScheduleTriggerCall) (response)
1164#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1165#[serde_with::serde_as]
1166#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1167pub struct Operation {
1168    /// 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.
1169    pub done: Option<bool>,
1170    /// The error result of the operation in case of failure or cancellation.
1171    pub error: Option<Status>,
1172    /// 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.
1173    pub metadata: Option<HashMap<String, serde_json::Value>>,
1174    /// 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}`.
1175    pub name: Option<String>,
1176    /// 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`.
1177    pub response: Option<HashMap<String, serde_json::Value>>,
1178}
1179
1180impl common::ResponseResult for Operation {}
1181
1182/// 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/).
1183///
1184/// # Activities
1185///
1186/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1187/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1188///
1189/// * [locations instances get iam policy projects](ProjectLocationInstanceGetIamPolicyCall) (response)
1190/// * [locations instances set iam policy projects](ProjectLocationInstanceSetIamPolicyCall) (response)
1191/// * [locations runtimes get iam policy projects](ProjectLocationRuntimeGetIamPolicyCall) (response)
1192/// * [locations runtimes set iam policy projects](ProjectLocationRuntimeSetIamPolicyCall) (response)
1193#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1194#[serde_with::serde_as]
1195#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1196pub struct Policy {
1197    /// 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`.
1198    pub bindings: Option<Vec<Binding>>,
1199    /// `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.
1200    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1201    pub etag: Option<Vec<u8>>,
1202    /// 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).
1203    pub version: Option<i32>,
1204}
1205
1206impl common::ResponseResult for Policy {}
1207
1208/// Request for getting a new access token.
1209///
1210/// # Activities
1211///
1212/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1213/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1214///
1215/// * [locations runtimes refresh runtime token internal projects](ProjectLocationRuntimeRefreshRuntimeTokenInternalCall) (request)
1216#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1217#[serde_with::serde_as]
1218#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1219pub struct RefreshRuntimeTokenInternalRequest {
1220    /// Required. The VM hardware token for authenticating the VM. https://cloud.google.com/compute/docs/instances/verifying-instance-identity
1221    #[serde(rename = "vmId")]
1222    pub vm_id: Option<String>,
1223}
1224
1225impl common::RequestValue for RefreshRuntimeTokenInternalRequest {}
1226
1227/// Response with a new access token.
1228///
1229/// # Activities
1230///
1231/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1232/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1233///
1234/// * [locations runtimes refresh runtime token internal projects](ProjectLocationRuntimeRefreshRuntimeTokenInternalCall) (response)
1235#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1236#[serde_with::serde_as]
1237#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1238pub struct RefreshRuntimeTokenInternalResponse {
1239    /// The OAuth 2.0 access token.
1240    #[serde(rename = "accessToken")]
1241    pub access_token: Option<String>,
1242    /// Output only. Token expiration time.
1243    #[serde(rename = "expireTime")]
1244    pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1245}
1246
1247impl common::ResponseResult for RefreshRuntimeTokenInternalResponse {}
1248
1249/// Request for registering a notebook instance.
1250///
1251/// # Activities
1252///
1253/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1254/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1255///
1256/// * [locations instances register projects](ProjectLocationInstanceRegisterCall) (request)
1257#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1258#[serde_with::serde_as]
1259#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1260pub struct RegisterInstanceRequest {
1261    /// Required. User defined unique ID of this instance. The `instance_id` must be 1 to 63 characters long and contain only lowercase letters, numeric characters, and dashes. The first character must be a lowercase letter and the last character cannot be a dash.
1262    #[serde(rename = "instanceId")]
1263    pub instance_id: Option<String>,
1264}
1265
1266impl common::RequestValue for RegisterInstanceRequest {}
1267
1268/// Request for reporting a Managed Notebook Event.
1269///
1270/// # Activities
1271///
1272/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1273/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1274///
1275/// * [locations instances report event projects](ProjectLocationInstanceReportEventCall) (request)
1276#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1277#[serde_with::serde_as]
1278#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1279pub struct ReportInstanceEventRequest {
1280    /// Required. The Event to be reported.
1281    pub event: Option<Event>,
1282    /// Required. The VM hardware token for authenticating the VM. https://cloud.google.com/compute/docs/instances/verifying-instance-identity
1283    #[serde(rename = "vmId")]
1284    pub vm_id: Option<String>,
1285}
1286
1287impl common::RequestValue for ReportInstanceEventRequest {}
1288
1289/// Request for notebook instances to report information to Notebooks API.
1290///
1291/// # Activities
1292///
1293/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1294/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1295///
1296/// * [locations instances report projects](ProjectLocationInstanceReportCall) (request)
1297#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1298#[serde_with::serde_as]
1299#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1300pub struct ReportInstanceInfoRequest {
1301    /// The metadata reported to Notebooks API. This will be merged to the instance metadata store
1302    pub metadata: Option<HashMap<String, String>>,
1303    /// Required. The VM hardware token for authenticating the VM. https://cloud.google.com/compute/docs/instances/verifying-instance-identity
1304    #[serde(rename = "vmId")]
1305    pub vm_id: Option<String>,
1306}
1307
1308impl common::RequestValue for ReportInstanceInfoRequest {}
1309
1310/// Request for reporting a Managed Notebook Event.
1311///
1312/// # Activities
1313///
1314/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1315/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1316///
1317/// * [locations runtimes report event projects](ProjectLocationRuntimeReportEventCall) (request)
1318#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1319#[serde_with::serde_as]
1320#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1321pub struct ReportRuntimeEventRequest {
1322    /// Required. The Event to be reported.
1323    pub event: Option<Event>,
1324    /// Required. The VM hardware token for authenticating the VM. https://cloud.google.com/compute/docs/instances/verifying-instance-identity
1325    #[serde(rename = "vmId")]
1326    pub vm_id: Option<String>,
1327}
1328
1329impl common::RequestValue for ReportRuntimeEventRequest {}
1330
1331/// Reservation Affinity for consuming Zonal reservation.
1332///
1333/// This type is not used in any activity, and only used as *part* of another schema.
1334///
1335#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1336#[serde_with::serde_as]
1337#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1338pub struct ReservationAffinity {
1339    /// Optional. Type of reservation to consume
1340    #[serde(rename = "consumeReservationType")]
1341    pub consume_reservation_type: Option<String>,
1342    /// Optional. Corresponds to the label key of reservation resource.
1343    pub key: Option<String>,
1344    /// Optional. Corresponds to the label values of reservation resource.
1345    pub values: Option<Vec<String>>,
1346}
1347
1348impl common::Part for ReservationAffinity {}
1349
1350/// Request for resetting a notebook instance
1351///
1352/// # Activities
1353///
1354/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1355/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1356///
1357/// * [locations instances reset projects](ProjectLocationInstanceResetCall) (request)
1358#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1359#[serde_with::serde_as]
1360#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1361pub struct ResetInstanceRequest {
1362    _never_set: Option<bool>,
1363}
1364
1365impl common::RequestValue for ResetInstanceRequest {}
1366
1367/// Request for resetting a Managed Notebook Runtime.
1368///
1369/// # Activities
1370///
1371/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1372/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1373///
1374/// * [locations runtimes reset projects](ProjectLocationRuntimeResetCall) (request)
1375#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1376#[serde_with::serde_as]
1377#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1378pub struct ResetRuntimeRequest {
1379    /// Idempotent request UUID.
1380    #[serde(rename = "requestId")]
1381    pub request_id: Option<String>,
1382}
1383
1384impl common::RequestValue for ResetRuntimeRequest {}
1385
1386/// Request for rollbacking a notebook instance
1387///
1388/// # Activities
1389///
1390/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1391/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1392///
1393/// * [locations instances rollback projects](ProjectLocationInstanceRollbackCall) (request)
1394#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1395#[serde_with::serde_as]
1396#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1397pub struct RollbackInstanceRequest {
1398    /// Required. The snapshot for rollback. Example: `projects/test-project/global/snapshots/krwlzipynril`.
1399    #[serde(rename = "targetSnapshot")]
1400    pub target_snapshot: Option<String>,
1401}
1402
1403impl common::RequestValue for RollbackInstanceRequest {}
1404
1405/// The definition of a Runtime for a managed notebook instance.
1406///
1407/// # Activities
1408///
1409/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1410/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1411///
1412/// * [locations runtimes create projects](ProjectLocationRuntimeCreateCall) (request)
1413/// * [locations runtimes get projects](ProjectLocationRuntimeGetCall) (response)
1414/// * [locations runtimes patch projects](ProjectLocationRuntimePatchCall) (request)
1415#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1416#[serde_with::serde_as]
1417#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1418pub struct Runtime {
1419    /// The config settings for accessing runtime.
1420    #[serde(rename = "accessConfig")]
1421    pub access_config: Option<RuntimeAccessConfig>,
1422    /// Output only. Runtime creation time.
1423    #[serde(rename = "createTime")]
1424    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1425    /// Output only. Runtime health_state.
1426    #[serde(rename = "healthState")]
1427    pub health_state: Option<String>,
1428    /// Optional. The labels to associate with this Managed Notebook or Runtime. Label **keys** must contain 1 to 63 characters, and must conform to [RFC 1035](https://www.ietf.org/rfc/rfc1035.txt). Label **values** may be empty, but, if present, must contain 1 to 63 characters, and must conform to [RFC 1035](https://www.ietf.org/rfc/rfc1035.txt). No more than 32 labels can be associated with a cluster.
1429    pub labels: Option<HashMap<String, String>>,
1430    /// Output only. Contains Runtime daemon metrics such as Service status and JupyterLab stats.
1431    pub metrics: Option<RuntimeMetrics>,
1432    /// Output only. Bool indicating whether this notebook has been migrated to a Workbench Instance
1433    pub migrated: Option<bool>,
1434    /// Output only. The resource name of the runtime. Format: `projects/{project}/locations/{location}/runtimes/{runtimeId}`
1435    pub name: Option<String>,
1436    /// Output only. Checks how feasible a migration from GmN to WbI is.
1437    #[serde(rename = "runtimeMigrationEligibility")]
1438    pub runtime_migration_eligibility: Option<RuntimeMigrationEligibility>,
1439    /// The config settings for software inside the runtime.
1440    #[serde(rename = "softwareConfig")]
1441    pub software_config: Option<RuntimeSoftwareConfig>,
1442    /// Output only. Runtime state.
1443    pub state: Option<String>,
1444    /// Output only. Runtime update time.
1445    #[serde(rename = "updateTime")]
1446    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1447    /// Use a Compute Engine VM image to start the managed notebook instance.
1448    #[serde(rename = "virtualMachine")]
1449    pub virtual_machine: Option<VirtualMachine>,
1450}
1451
1452impl common::RequestValue for Runtime {}
1453impl common::ResponseResult for Runtime {}
1454
1455/// Definition of the types of hardware accelerators that can be used. See [Compute Engine AcceleratorTypes](https://cloud.google.com/compute/docs/reference/beta/acceleratorTypes). Examples: * `nvidia-tesla-k80` * `nvidia-tesla-p100` * `nvidia-tesla-v100` * `nvidia-tesla-p4` * `nvidia-tesla-t4` * `nvidia-tesla-a100`
1456///
1457/// This type is not used in any activity, and only used as *part* of another schema.
1458///
1459#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1460#[serde_with::serde_as]
1461#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1462pub struct RuntimeAcceleratorConfig {
1463    /// Count of cores of this accelerator.
1464    #[serde(rename = "coreCount")]
1465    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1466    pub core_count: Option<i64>,
1467    /// Accelerator model.
1468    #[serde(rename = "type")]
1469    pub type_: Option<String>,
1470}
1471
1472impl common::Part for RuntimeAcceleratorConfig {}
1473
1474/// Specifies the login configuration for Runtime
1475///
1476/// This type is not used in any activity, and only used as *part* of another schema.
1477///
1478#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1479#[serde_with::serde_as]
1480#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1481pub struct RuntimeAccessConfig {
1482    /// The type of access mode this instance.
1483    #[serde(rename = "accessType")]
1484    pub access_type: Option<String>,
1485    /// Output only. The proxy endpoint that is used to access the runtime.
1486    #[serde(rename = "proxyUri")]
1487    pub proxy_uri: Option<String>,
1488    /// The owner of this runtime after creation. Format: `alias@example.com` Currently supports one owner only.
1489    #[serde(rename = "runtimeOwner")]
1490    pub runtime_owner: Option<String>,
1491}
1492
1493impl common::Part for RuntimeAccessConfig {}
1494
1495/// Optional. A list of features to enable on the guest operating system. Applicable only for bootable images. Read [Enabling guest operating system features](https://cloud.google.com/compute/docs/images/create-delete-deprecate-private-images#guest-os-features) to see a list of available options. Guest OS features for boot disk.
1496///
1497/// This type is not used in any activity, and only used as *part* of another schema.
1498///
1499#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1500#[serde_with::serde_as]
1501#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1502pub struct RuntimeGuestOsFeature {
1503    /// The ID of a supported feature. Read [Enabling guest operating system features](https://cloud.google.com/compute/docs/images/create-delete-deprecate-private-images#guest-os-features) to see a list of available options. Valid values: * `FEATURE_TYPE_UNSPECIFIED` * `MULTI_IP_SUBNET` * `SECURE_BOOT` * `UEFI_COMPATIBLE` * `VIRTIO_SCSI_MULTIQUEUE` * `WINDOWS`
1504    #[serde(rename = "type")]
1505    pub type_: Option<String>,
1506}
1507
1508impl common::Part for RuntimeGuestOsFeature {}
1509
1510/// Contains runtime daemon metrics, such as OS and kernels and sessions stats.
1511///
1512/// This type is not used in any activity, and only used as *part* of another schema.
1513///
1514#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1515#[serde_with::serde_as]
1516#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1517pub struct RuntimeMetrics {
1518    /// Output only. The system metrics.
1519    #[serde(rename = "systemMetrics")]
1520    pub system_metrics: Option<HashMap<String, String>>,
1521}
1522
1523impl common::Part for RuntimeMetrics {}
1524
1525/// RuntimeMigrationEligibility represents the feasibility information of a migration from GmN to WbI.
1526///
1527/// This type is not used in any activity, and only used as *part* of another schema.
1528///
1529#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1530#[serde_with::serde_as]
1531#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1532pub struct RuntimeMigrationEligibility {
1533    /// Output only. Certain configurations make the GmN ineligible for an automatic migration. A manual migration is required.
1534    pub errors: Option<Vec<String>>,
1535    /// Output only. Certain configurations will be defaulted during the migration.
1536    pub warnings: Option<Vec<String>>,
1537}
1538
1539impl common::Part for RuntimeMigrationEligibility {}
1540
1541/// A set of Shielded Instance options. See [Images using supported Shielded VM features](https://cloud.google.com/compute/docs/instances/modifying-shielded-vm). Not all combinations are valid.
1542///
1543/// This type is not used in any activity, and only used as *part* of another schema.
1544///
1545#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1546#[serde_with::serde_as]
1547#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1548pub struct RuntimeShieldedInstanceConfig {
1549    /// Defines whether the instance has integrity monitoring enabled. Enables monitoring and attestation of the boot integrity of the instance. The attestation is performed against the integrity policy baseline. This baseline is initially derived from the implicitly trusted boot image when the instance is created. Enabled by default.
1550    #[serde(rename = "enableIntegrityMonitoring")]
1551    pub enable_integrity_monitoring: Option<bool>,
1552    /// Defines whether the instance has Secure Boot enabled. Secure Boot helps ensure that the system only runs authentic software by verifying the digital signature of all boot components, and halting the boot process if signature verification fails. Disabled by default.
1553    #[serde(rename = "enableSecureBoot")]
1554    pub enable_secure_boot: Option<bool>,
1555    /// Defines whether the instance has the vTPM enabled. Enabled by default.
1556    #[serde(rename = "enableVtpm")]
1557    pub enable_vtpm: Option<bool>,
1558}
1559
1560impl common::Part for RuntimeShieldedInstanceConfig {}
1561
1562/// Specifies the selection and configuration of software inside the runtime. The properties to set on runtime. Properties keys are specified in `key:value` format, for example: * `idle_shutdown: true` * `idle_shutdown_timeout: 180` * `enable_health_monitoring: true`
1563///
1564/// This type is not used in any activity, and only used as *part* of another schema.
1565///
1566#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1567#[serde_with::serde_as]
1568#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1569pub struct RuntimeSoftwareConfig {
1570    /// Specify a custom Cloud Storage path where the GPU driver is stored. If not specified, we'll automatically choose from official GPU drivers.
1571    #[serde(rename = "customGpuDriverPath")]
1572    pub custom_gpu_driver_path: Option<String>,
1573    /// Bool indicating whether JupyterLab terminal will be available or not. Default: False
1574    #[serde(rename = "disableTerminal")]
1575    pub disable_terminal: Option<bool>,
1576    /// Verifies core internal services are running. Default: True
1577    #[serde(rename = "enableHealthMonitoring")]
1578    pub enable_health_monitoring: Option<bool>,
1579    /// Runtime will automatically shutdown after idle_shutdown_time. Default: True
1580    #[serde(rename = "idleShutdown")]
1581    pub idle_shutdown: Option<bool>,
1582    /// Time in minutes to wait before shutting down runtime. Default: 180 minutes
1583    #[serde(rename = "idleShutdownTimeout")]
1584    pub idle_shutdown_timeout: Option<i32>,
1585    /// Install Nvidia Driver automatically. Default: True
1586    #[serde(rename = "installGpuDriver")]
1587    pub install_gpu_driver: Option<bool>,
1588    /// Optional. Use a list of container images to use as Kernels in the notebook instance.
1589    pub kernels: Option<Vec<ContainerImage>>,
1590    /// Bool indicating whether mixer client should be disabled. Default: False
1591    #[serde(rename = "mixerDisabled")]
1592    pub mixer_disabled: Option<bool>,
1593    /// Cron expression in UTC timezone, used to schedule instance auto upgrade. Please follow the [cron format](https://en.wikipedia.org/wiki/Cron).
1594    #[serde(rename = "notebookUpgradeSchedule")]
1595    pub notebook_upgrade_schedule: Option<String>,
1596    /// Path to a Bash script that automatically runs after a notebook instance fully boots up. The path must be a URL or Cloud Storage path (`gs://path-to-file/file-name`).
1597    #[serde(rename = "postStartupScript")]
1598    pub post_startup_script: Option<String>,
1599    /// Behavior for the post startup script.
1600    #[serde(rename = "postStartupScriptBehavior")]
1601    pub post_startup_script_behavior: Option<String>,
1602    /// Output only. Bool indicating whether an newer image is available in an image family.
1603    pub upgradeable: Option<bool>,
1604    /// Output only. version of boot image such as M100, from release label of the image.
1605    pub version: Option<String>,
1606}
1607
1608impl common::Part for RuntimeSoftwareConfig {}
1609
1610/// The definition of a schedule.
1611///
1612/// # Activities
1613///
1614/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1615/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1616///
1617/// * [locations schedules create projects](ProjectLocationScheduleCreateCall) (request)
1618/// * [locations schedules get projects](ProjectLocationScheduleGetCall) (response)
1619#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1620#[serde_with::serde_as]
1621#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1622pub struct Schedule {
1623    /// Output only. Time the schedule was created.
1624    #[serde(rename = "createTime")]
1625    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1626    /// Cron-tab formatted schedule by which the job will execute. Format: minute, hour, day of month, month, day of week, e.g. `0 0 * * WED` = every Wednesday More examples: https://crontab.guru/examples.html
1627    #[serde(rename = "cronSchedule")]
1628    pub cron_schedule: Option<String>,
1629    /// A brief description of this environment.
1630    pub description: Option<String>,
1631    /// Output only. Display name used for UI purposes. Name can only contain alphanumeric characters, hyphens `-`, and underscores `_`.
1632    #[serde(rename = "displayName")]
1633    pub display_name: Option<String>,
1634    /// Notebook Execution Template corresponding to this schedule.
1635    #[serde(rename = "executionTemplate")]
1636    pub execution_template: Option<ExecutionTemplate>,
1637    /// Output only. The name of this schedule. Format: `projects/{project_id}/locations/{location}/schedules/{schedule_id}`
1638    pub name: Option<String>,
1639    /// Output only. The most recent execution names triggered from this schedule and their corresponding states.
1640    #[serde(rename = "recentExecutions")]
1641    pub recent_executions: Option<Vec<Execution>>,
1642    /// no description provided
1643    pub state: Option<String>,
1644    /// Timezone on which the cron_schedule. The value of this field must be a time zone name from the tz database. TZ Database: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones Note that some time zones include a provision for daylight savings time. The rules for daylight saving time are determined by the chosen tz. For UTC use the string "utc". If a time zone is not specified, the default will be in UTC (also known as GMT).
1645    #[serde(rename = "timeZone")]
1646    pub time_zone: Option<String>,
1647    /// Output only. Time the schedule was last updated.
1648    #[serde(rename = "updateTime")]
1649    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1650}
1651
1652impl common::RequestValue for Schedule {}
1653impl common::ResponseResult for Schedule {}
1654
1655/// Definition of a hardware accelerator. Note that not all combinations of `type` and `core_count` are valid. See [GPUs on Compute Engine](https://cloud.google.com/compute/docs/gpus) to find a valid combination. TPUs are not supported.
1656///
1657/// This type is not used in any activity, and only used as *part* of another schema.
1658///
1659#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1660#[serde_with::serde_as]
1661#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1662pub struct SchedulerAcceleratorConfig {
1663    /// Count of cores of this accelerator.
1664    #[serde(rename = "coreCount")]
1665    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1666    pub core_count: Option<i64>,
1667    /// Type of this accelerator.
1668    #[serde(rename = "type")]
1669    pub type_: Option<String>,
1670}
1671
1672impl common::Part for SchedulerAcceleratorConfig {}
1673
1674/// Request message for `SetIamPolicy` method.
1675///
1676/// # Activities
1677///
1678/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1679/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1680///
1681/// * [locations instances set iam policy projects](ProjectLocationInstanceSetIamPolicyCall) (request)
1682/// * [locations runtimes set iam policy projects](ProjectLocationRuntimeSetIamPolicyCall) (request)
1683#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1684#[serde_with::serde_as]
1685#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1686pub struct SetIamPolicyRequest {
1687    /// 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.
1688    pub policy: Option<Policy>,
1689}
1690
1691impl common::RequestValue for SetIamPolicyRequest {}
1692
1693/// Request for setting instance accelerator.
1694///
1695/// # Activities
1696///
1697/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1698/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1699///
1700/// * [locations instances set accelerator projects](ProjectLocationInstanceSetAcceleratorCall) (request)
1701#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1702#[serde_with::serde_as]
1703#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1704pub struct SetInstanceAcceleratorRequest {
1705    /// Required. Count of cores of this accelerator. Note that not all combinations of `type` and `core_count` are valid. See [GPUs on Compute Engine](https://cloud.google.com/compute/docs/gpus/#gpus-list) to find a valid combination. TPUs are not supported.
1706    #[serde(rename = "coreCount")]
1707    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1708    pub core_count: Option<i64>,
1709    /// Required. Type of this accelerator.
1710    #[serde(rename = "type")]
1711    pub type_: Option<String>,
1712}
1713
1714impl common::RequestValue for SetInstanceAcceleratorRequest {}
1715
1716/// Request for setting instance labels.
1717///
1718/// # Activities
1719///
1720/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1721/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1722///
1723/// * [locations instances set labels projects](ProjectLocationInstanceSetLabelCall) (request)
1724#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1725#[serde_with::serde_as]
1726#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1727pub struct SetInstanceLabelsRequest {
1728    /// Labels to apply to this instance. These can be later modified by the setLabels method
1729    pub labels: Option<HashMap<String, String>>,
1730}
1731
1732impl common::RequestValue for SetInstanceLabelsRequest {}
1733
1734/// Request for setting instance machine type.
1735///
1736/// # Activities
1737///
1738/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1739/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1740///
1741/// * [locations instances set machine type projects](ProjectLocationInstanceSetMachineTypeCall) (request)
1742#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1743#[serde_with::serde_as]
1744#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1745pub struct SetInstanceMachineTypeRequest {
1746    /// Required. The [Compute Engine machine type](https://cloud.google.com/compute/docs/machine-resource).
1747    #[serde(rename = "machineType")]
1748    pub machine_type: Option<String>,
1749}
1750
1751impl common::RequestValue for SetInstanceMachineTypeRequest {}
1752
1753/// A set of Shielded Instance options. See [Images using supported Shielded VM features](https://cloud.google.com/compute/docs/instances/modifying-shielded-vm). Not all combinations are valid.
1754///
1755/// This type is not used in any activity, and only used as *part* of another schema.
1756///
1757#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1758#[serde_with::serde_as]
1759#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1760pub struct ShieldedInstanceConfig {
1761    /// Defines whether the instance has integrity monitoring enabled. Enables monitoring and attestation of the boot integrity of the instance. The attestation is performed against the integrity policy baseline. This baseline is initially derived from the implicitly trusted boot image when the instance is created. Enabled by default.
1762    #[serde(rename = "enableIntegrityMonitoring")]
1763    pub enable_integrity_monitoring: Option<bool>,
1764    /// Defines whether the instance has Secure Boot enabled. Secure Boot helps ensure that the system only runs authentic software by verifying the digital signature of all boot components, and halting the boot process if signature verification fails. Disabled by default.
1765    #[serde(rename = "enableSecureBoot")]
1766    pub enable_secure_boot: Option<bool>,
1767    /// Defines whether the instance has the vTPM enabled. Enabled by default.
1768    #[serde(rename = "enableVtpm")]
1769    pub enable_vtpm: Option<bool>,
1770}
1771
1772impl common::Part for ShieldedInstanceConfig {}
1773
1774/// Request for starting a notebook instance
1775///
1776/// # Activities
1777///
1778/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1779/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1780///
1781/// * [locations instances start projects](ProjectLocationInstanceStartCall) (request)
1782#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1783#[serde_with::serde_as]
1784#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1785pub struct StartInstanceRequest {
1786    _never_set: Option<bool>,
1787}
1788
1789impl common::RequestValue for StartInstanceRequest {}
1790
1791/// Request for starting a Managed Notebook Runtime.
1792///
1793/// # Activities
1794///
1795/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1796/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1797///
1798/// * [locations runtimes start projects](ProjectLocationRuntimeStartCall) (request)
1799#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1800#[serde_with::serde_as]
1801#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1802pub struct StartRuntimeRequest {
1803    /// Idempotent request UUID.
1804    #[serde(rename = "requestId")]
1805    pub request_id: Option<String>,
1806}
1807
1808impl common::RequestValue for StartRuntimeRequest {}
1809
1810/// 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).
1811///
1812/// This type is not used in any activity, and only used as *part* of another schema.
1813///
1814#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1815#[serde_with::serde_as]
1816#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1817pub struct Status {
1818    /// The status code, which should be an enum value of google.rpc.Code.
1819    pub code: Option<i32>,
1820    /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
1821    pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
1822    /// 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.
1823    pub message: Option<String>,
1824}
1825
1826impl common::Part for Status {}
1827
1828/// Request for stopping a notebook instance
1829///
1830/// # Activities
1831///
1832/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1833/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1834///
1835/// * [locations instances stop projects](ProjectLocationInstanceStopCall) (request)
1836#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1837#[serde_with::serde_as]
1838#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1839pub struct StopInstanceRequest {
1840    _never_set: Option<bool>,
1841}
1842
1843impl common::RequestValue for StopInstanceRequest {}
1844
1845/// Request for stopping a Managed Notebook Runtime.
1846///
1847/// # Activities
1848///
1849/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1850/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1851///
1852/// * [locations runtimes stop projects](ProjectLocationRuntimeStopCall) (request)
1853#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1854#[serde_with::serde_as]
1855#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1856pub struct StopRuntimeRequest {
1857    /// Idempotent request UUID.
1858    #[serde(rename = "requestId")]
1859    pub request_id: Option<String>,
1860}
1861
1862impl common::RequestValue for StopRuntimeRequest {}
1863
1864/// Request for switching a Managed Notebook Runtime.
1865///
1866/// # Activities
1867///
1868/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1869/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1870///
1871/// * [locations runtimes switch projects](ProjectLocationRuntimeSwitchCall) (request)
1872#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1873#[serde_with::serde_as]
1874#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1875pub struct SwitchRuntimeRequest {
1876    /// accelerator config.
1877    #[serde(rename = "acceleratorConfig")]
1878    pub accelerator_config: Option<RuntimeAcceleratorConfig>,
1879    /// machine type.
1880    #[serde(rename = "machineType")]
1881    pub machine_type: Option<String>,
1882    /// Idempotent request UUID.
1883    #[serde(rename = "requestId")]
1884    pub request_id: Option<String>,
1885}
1886
1887impl common::RequestValue for SwitchRuntimeRequest {}
1888
1889/// Request message for `TestIamPermissions` method.
1890///
1891/// # Activities
1892///
1893/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1894/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1895///
1896/// * [locations instances test iam permissions projects](ProjectLocationInstanceTestIamPermissionCall) (request)
1897/// * [locations runtimes test iam permissions projects](ProjectLocationRuntimeTestIamPermissionCall) (request)
1898#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1899#[serde_with::serde_as]
1900#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1901pub struct TestIamPermissionsRequest {
1902    /// 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).
1903    pub permissions: Option<Vec<String>>,
1904}
1905
1906impl common::RequestValue for TestIamPermissionsRequest {}
1907
1908/// Response message for `TestIamPermissions` method.
1909///
1910/// # Activities
1911///
1912/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1913/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1914///
1915/// * [locations instances test iam permissions projects](ProjectLocationInstanceTestIamPermissionCall) (response)
1916/// * [locations runtimes test iam permissions projects](ProjectLocationRuntimeTestIamPermissionCall) (response)
1917#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1918#[serde_with::serde_as]
1919#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1920pub struct TestIamPermissionsResponse {
1921    /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed.
1922    pub permissions: Option<Vec<String>>,
1923}
1924
1925impl common::ResponseResult for TestIamPermissionsResponse {}
1926
1927/// Request for created scheduled notebooks
1928///
1929/// # Activities
1930///
1931/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1932/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1933///
1934/// * [locations schedules trigger projects](ProjectLocationScheduleTriggerCall) (request)
1935#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1936#[serde_with::serde_as]
1937#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1938pub struct TriggerScheduleRequest {
1939    _never_set: Option<bool>,
1940}
1941
1942impl common::RequestValue for TriggerScheduleRequest {}
1943
1944/// Request for updating instance configurations.
1945///
1946/// # Activities
1947///
1948/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1949/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1950///
1951/// * [locations instances update config projects](ProjectLocationInstanceUpdateConfigCall) (request)
1952#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1953#[serde_with::serde_as]
1954#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1955pub struct UpdateInstanceConfigRequest {
1956    /// The instance configurations to be updated.
1957    pub config: Option<InstanceConfig>,
1958}
1959
1960impl common::RequestValue for UpdateInstanceConfigRequest {}
1961
1962/// Request for adding/changing metadata items for an instance.
1963///
1964/// # Activities
1965///
1966/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1967/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1968///
1969/// * [locations instances update metadata items projects](ProjectLocationInstanceUpdateMetadataItemCall) (request)
1970#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1971#[serde_with::serde_as]
1972#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1973pub struct UpdateInstanceMetadataItemsRequest {
1974    /// Metadata items to add/update for the instance.
1975    pub items: Option<HashMap<String, String>>,
1976}
1977
1978impl common::RequestValue for UpdateInstanceMetadataItemsRequest {}
1979
1980/// Response for adding/changing metadata items for an instance.
1981///
1982/// # Activities
1983///
1984/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1985/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1986///
1987/// * [locations instances update metadata items projects](ProjectLocationInstanceUpdateMetadataItemCall) (response)
1988#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1989#[serde_with::serde_as]
1990#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1991pub struct UpdateInstanceMetadataItemsResponse {
1992    /// Map of items that were added/updated to/in the metadata.
1993    pub items: Option<HashMap<String, String>>,
1994}
1995
1996impl common::ResponseResult for UpdateInstanceMetadataItemsResponse {}
1997
1998/// Request for updating the Shielded Instance config for a notebook instance. You can only use this method on a stopped instance
1999///
2000/// # Activities
2001///
2002/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2003/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2004///
2005/// * [locations instances update shielded instance config projects](ProjectLocationInstanceUpdateShieldedInstanceConfigCall) (request)
2006#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2007#[serde_with::serde_as]
2008#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2009pub struct UpdateShieldedInstanceConfigRequest {
2010    /// ShieldedInstance configuration to be updated.
2011    #[serde(rename = "shieldedInstanceConfig")]
2012    pub shielded_instance_config: Option<ShieldedInstanceConfig>,
2013}
2014
2015impl common::RequestValue for UpdateShieldedInstanceConfigRequest {}
2016
2017/// The entry of VM image upgrade history.
2018///
2019/// This type is not used in any activity, and only used as *part* of another schema.
2020///
2021#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2022#[serde_with::serde_as]
2023#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2024pub struct UpgradeHistoryEntry {
2025    /// Action. Rolloback or Upgrade.
2026    pub action: Option<String>,
2027    /// The container image before this instance upgrade.
2028    #[serde(rename = "containerImage")]
2029    pub container_image: Option<String>,
2030    /// The time that this instance upgrade history entry is created.
2031    #[serde(rename = "createTime")]
2032    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2033    /// The framework of this notebook instance.
2034    pub framework: Option<String>,
2035    /// The snapshot of the boot disk of this notebook instance before upgrade.
2036    pub snapshot: Option<String>,
2037    /// The state of this instance upgrade history entry.
2038    pub state: Option<String>,
2039    /// Target VM Image. Format: `ainotebooks-vm/project/image-name/name`.
2040    #[serde(rename = "targetImage")]
2041    pub target_image: Option<String>,
2042    /// Target VM Version, like m63.
2043    #[serde(rename = "targetVersion")]
2044    pub target_version: Option<String>,
2045    /// The version of the notebook instance before this upgrade.
2046    pub version: Option<String>,
2047    /// The VM image before this instance upgrade.
2048    #[serde(rename = "vmImage")]
2049    pub vm_image: Option<String>,
2050}
2051
2052impl common::Part for UpgradeHistoryEntry {}
2053
2054/// Request for upgrading a notebook instance from within the VM
2055///
2056/// # Activities
2057///
2058/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2059/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2060///
2061/// * [locations instances upgrade internal projects](ProjectLocationInstanceUpgradeInternalCall) (request)
2062#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2063#[serde_with::serde_as]
2064#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2065pub struct UpgradeInstanceInternalRequest {
2066    /// Optional. The optional UpgradeType. Setting this field will search for additional compute images to upgrade this instance.
2067    #[serde(rename = "type")]
2068    pub type_: Option<String>,
2069    /// Required. The VM hardware token for authenticating the VM. https://cloud.google.com/compute/docs/instances/verifying-instance-identity
2070    #[serde(rename = "vmId")]
2071    pub vm_id: Option<String>,
2072}
2073
2074impl common::RequestValue for UpgradeInstanceInternalRequest {}
2075
2076/// Request for upgrading a notebook instance
2077///
2078/// # Activities
2079///
2080/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2081/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2082///
2083/// * [locations instances upgrade projects](ProjectLocationInstanceUpgradeCall) (request)
2084#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2085#[serde_with::serde_as]
2086#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2087pub struct UpgradeInstanceRequest {
2088    /// Optional. The optional UpgradeType. Setting this field will search for additional compute images to upgrade this instance.
2089    #[serde(rename = "type")]
2090    pub type_: Option<String>,
2091}
2092
2093impl common::RequestValue for UpgradeInstanceRequest {}
2094
2095/// Request for upgrading a Managed Notebook Runtime to the latest version. option (google.api.message_visibility).restriction = “TRUSTED_TESTER,SPECIAL_TESTER”;
2096///
2097/// # Activities
2098///
2099/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2100/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2101///
2102/// * [locations runtimes upgrade projects](ProjectLocationRuntimeUpgradeCall) (request)
2103#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2104#[serde_with::serde_as]
2105#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2106pub struct UpgradeRuntimeRequest {
2107    /// Idempotent request UUID.
2108    #[serde(rename = "requestId")]
2109    pub request_id: Option<String>,
2110}
2111
2112impl common::RequestValue for UpgradeRuntimeRequest {}
2113
2114/// Parameters used in Vertex AI JobType executions.
2115///
2116/// This type is not used in any activity, and only used as *part* of another schema.
2117///
2118#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2119#[serde_with::serde_as]
2120#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2121pub struct VertexAIParameters {
2122    /// Environment variables. At most 100 environment variables can be specified and unique. Example: `GCP_BUCKET=gs://my-bucket/samples/`
2123    pub env: Option<HashMap<String, String>>,
2124    /// The full name of the Compute Engine [network](https://cloud.google.com/compute/docs/networks-and-firewalls#networks) to which the Job should be peered. For example, `projects/12345/global/networks/myVPC`. [Format](https://cloud.google.com/compute/docs/reference/rest/v1/networks/insert) is of the form `projects/{project}/global/networks/{network}`. Where `{project}` is a project number, as in `12345`, and `{network}` is a network name. Private services access must already be configured for the network. If left unspecified, the job is not peered with any network.
2125    pub network: Option<String>,
2126}
2127
2128impl common::Part for VertexAIParameters {}
2129
2130/// Runtime using Virtual Machine for computing.
2131///
2132/// This type is not used in any activity, and only used as *part* of another schema.
2133///
2134#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2135#[serde_with::serde_as]
2136#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2137pub struct VirtualMachine {
2138    /// Output only. The unique identifier of the Managed Compute Engine instance.
2139    #[serde(rename = "instanceId")]
2140    pub instance_id: Option<String>,
2141    /// Output only. The user-friendly name of the Managed Compute Engine instance.
2142    #[serde(rename = "instanceName")]
2143    pub instance_name: Option<String>,
2144    /// Virtual Machine configuration settings.
2145    #[serde(rename = "virtualMachineConfig")]
2146    pub virtual_machine_config: Option<VirtualMachineConfig>,
2147}
2148
2149impl common::Part for VirtualMachine {}
2150
2151/// The config settings for virtual machine.
2152///
2153/// This type is not used in any activity, and only used as *part* of another schema.
2154///
2155#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2156#[serde_with::serde_as]
2157#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2158pub struct VirtualMachineConfig {
2159    /// Optional. The Compute Engine accelerator configuration for this runtime.
2160    #[serde(rename = "acceleratorConfig")]
2161    pub accelerator_config: Option<RuntimeAcceleratorConfig>,
2162    /// Optional. Boot image metadata used for runtime upgradeability.
2163    #[serde(rename = "bootImage")]
2164    pub boot_image: Option<BootImage>,
2165    /// Optional. Use a list of container images to use as Kernels in the notebook instance.
2166    #[serde(rename = "containerImages")]
2167    pub container_images: Option<Vec<ContainerImage>>,
2168    /// Required. Data disk option configuration settings.
2169    #[serde(rename = "dataDisk")]
2170    pub data_disk: Option<LocalDisk>,
2171    /// Optional. Encryption settings for virtual machine data disk.
2172    #[serde(rename = "encryptionConfig")]
2173    pub encryption_config: Option<EncryptionConfig>,
2174    /// Output only. The Compute Engine guest attributes. (see [Project and instance guest attributes](https://cloud.google.com/compute/docs/storing-retrieving-metadata#guest_attributes)).
2175    #[serde(rename = "guestAttributes")]
2176    pub guest_attributes: Option<HashMap<String, String>>,
2177    /// Optional. If true, runtime will only have internal IP addresses. By default, runtimes are not restricted to internal IP addresses, and will have ephemeral external IP addresses assigned to each vm. This `internal_ip_only` restriction can only be enabled for subnetwork enabled networks, and all dependencies must be configured to be accessible without external IP addresses.
2178    #[serde(rename = "internalIpOnly")]
2179    pub internal_ip_only: Option<bool>,
2180    /// Optional. The labels to associate with this runtime. Label **keys** must contain 1 to 63 characters, and must conform to [RFC 1035](https://www.ietf.org/rfc/rfc1035.txt). Label **values** may be empty, but, if present, must contain 1 to 63 characters, and must conform to [RFC 1035](https://www.ietf.org/rfc/rfc1035.txt). No more than 32 labels can be associated with a cluster.
2181    pub labels: Option<HashMap<String, String>>,
2182    /// Required. The Compute Engine machine type used for runtimes. Short name is valid. Examples: * `n1-standard-2` * `e2-standard-8`
2183    #[serde(rename = "machineType")]
2184    pub machine_type: Option<String>,
2185    /// Optional. The Compute Engine metadata entries to add to virtual machine. (see [Project and instance metadata](https://cloud.google.com/compute/docs/storing-retrieving-metadata#project_and_instance_metadata)).
2186    pub metadata: Option<HashMap<String, String>>,
2187    /// Optional. The Compute Engine network to be used for machine communications. Cannot be specified with subnetwork. If neither `network` nor `subnet` is specified, the "default" network of the project is used, if it exists. A full URL or partial URI. Examples: * `https://www.googleapis.com/compute/v1/projects/[project_id]/global/networks/default` * `projects/[project_id]/global/networks/default` Runtimes are managed resources inside Google Infrastructure. Runtimes support the following network configurations: * Google Managed Network (Network & subnet are empty) * Consumer Project VPC (network & subnet are required). Requires configuring Private Service Access. * Shared VPC (network & subnet are required). Requires configuring Private Service Access.
2188    pub network: Option<String>,
2189    /// Optional. The type of vNIC to be used on this interface. This may be gVNIC or VirtioNet.
2190    #[serde(rename = "nicType")]
2191    pub nic_type: Option<String>,
2192    /// Optional. Reserved IP Range name is used for VPC Peering. The subnetwork allocation will use the range *name* if it's assigned. Example: managed-notebooks-range-c PEERING_RANGE_NAME_3=managed-notebooks-range-c gcloud compute addresses create $PEERING_RANGE_NAME_3 \ --global \ --prefix-length=24 \ --description="Google Cloud Managed Notebooks Range 24 c" \ --network=$NETWORK \ --addresses=192.168.0.0 \ --purpose=VPC_PEERING Field value will be: `managed-notebooks-range-c`
2193    #[serde(rename = "reservedIpRange")]
2194    pub reserved_ip_range: Option<String>,
2195    /// Optional. Shielded VM Instance configuration settings.
2196    #[serde(rename = "shieldedInstanceConfig")]
2197    pub shielded_instance_config: Option<RuntimeShieldedInstanceConfig>,
2198    /// Optional. The Compute Engine subnetwork to be used for machine communications. Cannot be specified with network. A full URL or partial URI are valid. Examples: * `https://www.googleapis.com/compute/v1/projects/[project_id]/regions/us-east1/subnetworks/sub0` * `projects/[project_id]/regions/us-east1/subnetworks/sub0`
2199    pub subnet: Option<String>,
2200    /// Optional. The Compute Engine network tags to add to runtime (see [Add network tags](https://cloud.google.com/vpc/docs/add-remove-network-tags)).
2201    pub tags: Option<Vec<String>>,
2202    /// Output only. The zone where the virtual machine is located. If using regional request, the notebooks service will pick a location in the corresponding runtime region. On a get request, zone will always be present. Example: * `us-central1-b`
2203    pub zone: Option<String>,
2204}
2205
2206impl common::Part for VirtualMachineConfig {}
2207
2208/// Definition of a custom Compute Engine virtual machine image for starting a notebook instance with the environment installed directly on the VM.
2209///
2210/// This type is not used in any activity, and only used as *part* of another schema.
2211///
2212#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2213#[serde_with::serde_as]
2214#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2215pub struct VmImage {
2216    /// Use this VM image family to find the image; the newest image in this family will be used.
2217    #[serde(rename = "imageFamily")]
2218    pub image_family: Option<String>,
2219    /// Use VM image name to find the image.
2220    #[serde(rename = "imageName")]
2221    pub image_name: Option<String>,
2222    /// Required. The name of the Google Cloud project that this VM image belongs to. Format: `{project_id}`
2223    pub project: Option<String>,
2224}
2225
2226impl common::Part for VmImage {}
2227
2228// ###################
2229// MethodBuilders ###
2230// #################
2231
2232/// A builder providing access to all methods supported on *project* resources.
2233/// It is not used directly, but through the [`AIPlatformNotebooks`] hub.
2234///
2235/// # Example
2236///
2237/// Instantiate a resource builder
2238///
2239/// ```test_harness,no_run
2240/// extern crate hyper;
2241/// extern crate hyper_rustls;
2242/// extern crate google_notebooks1 as notebooks1;
2243///
2244/// # async fn dox() {
2245/// use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2246///
2247/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2248/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2249///     .with_native_roots()
2250///     .unwrap()
2251///     .https_only()
2252///     .enable_http2()
2253///     .build();
2254///
2255/// let executor = hyper_util::rt::TokioExecutor::new();
2256/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2257///     secret,
2258///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2259///     yup_oauth2::client::CustomHyperClientBuilder::from(
2260///         hyper_util::client::legacy::Client::builder(executor).build(connector),
2261///     ),
2262/// ).build().await.unwrap();
2263///
2264/// let client = hyper_util::client::legacy::Client::builder(
2265///     hyper_util::rt::TokioExecutor::new()
2266/// )
2267/// .build(
2268///     hyper_rustls::HttpsConnectorBuilder::new()
2269///         .with_native_roots()
2270///         .unwrap()
2271///         .https_or_http()
2272///         .enable_http2()
2273///         .build()
2274/// );
2275/// let mut hub = AIPlatformNotebooks::new(client, auth);
2276/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2277/// // like `locations_environments_create(...)`, `locations_environments_delete(...)`, `locations_environments_get(...)`, `locations_environments_list(...)`, `locations_executions_create(...)`, `locations_executions_delete(...)`, `locations_executions_get(...)`, `locations_executions_list(...)`, `locations_get(...)`, `locations_instances_create(...)`, `locations_instances_delete(...)`, `locations_instances_diagnose(...)`, `locations_instances_get(...)`, `locations_instances_get_iam_policy(...)`, `locations_instances_get_instance_health(...)`, `locations_instances_is_upgradeable(...)`, `locations_instances_list(...)`, `locations_instances_migrate(...)`, `locations_instances_register(...)`, `locations_instances_report(...)`, `locations_instances_report_event(...)`, `locations_instances_reset(...)`, `locations_instances_rollback(...)`, `locations_instances_set_accelerator(...)`, `locations_instances_set_iam_policy(...)`, `locations_instances_set_labels(...)`, `locations_instances_set_machine_type(...)`, `locations_instances_start(...)`, `locations_instances_stop(...)`, `locations_instances_test_iam_permissions(...)`, `locations_instances_update_config(...)`, `locations_instances_update_metadata_items(...)`, `locations_instances_update_shielded_instance_config(...)`, `locations_instances_upgrade(...)`, `locations_instances_upgrade_internal(...)`, `locations_list(...)`, `locations_operations_cancel(...)`, `locations_operations_delete(...)`, `locations_operations_get(...)`, `locations_operations_list(...)`, `locations_runtimes_create(...)`, `locations_runtimes_delete(...)`, `locations_runtimes_diagnose(...)`, `locations_runtimes_get(...)`, `locations_runtimes_get_iam_policy(...)`, `locations_runtimes_list(...)`, `locations_runtimes_migrate(...)`, `locations_runtimes_patch(...)`, `locations_runtimes_refresh_runtime_token_internal(...)`, `locations_runtimes_report_event(...)`, `locations_runtimes_reset(...)`, `locations_runtimes_set_iam_policy(...)`, `locations_runtimes_start(...)`, `locations_runtimes_stop(...)`, `locations_runtimes_switch(...)`, `locations_runtimes_test_iam_permissions(...)`, `locations_runtimes_upgrade(...)`, `locations_schedules_create(...)`, `locations_schedules_delete(...)`, `locations_schedules_get(...)`, `locations_schedules_list(...)` and `locations_schedules_trigger(...)`
2278/// // to build up your call.
2279/// let rb = hub.projects();
2280/// # }
2281/// ```
2282pub struct ProjectMethods<'a, C>
2283where
2284    C: 'a,
2285{
2286    hub: &'a AIPlatformNotebooks<C>,
2287}
2288
2289impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
2290
2291impl<'a, C> ProjectMethods<'a, C> {
2292    /// Create a builder to help you perform the following task:
2293    ///
2294    /// Creates a new Environment.
2295    ///
2296    /// # Arguments
2297    ///
2298    /// * `request` - No description provided.
2299    /// * `parent` - Required. Format: `projects/{project_id}/locations/{location}`
2300    pub fn locations_environments_create(
2301        &self,
2302        request: Environment,
2303        parent: &str,
2304    ) -> ProjectLocationEnvironmentCreateCall<'a, C> {
2305        ProjectLocationEnvironmentCreateCall {
2306            hub: self.hub,
2307            _request: request,
2308            _parent: parent.to_string(),
2309            _environment_id: Default::default(),
2310            _delegate: Default::default(),
2311            _additional_params: Default::default(),
2312            _scopes: Default::default(),
2313        }
2314    }
2315
2316    /// Create a builder to help you perform the following task:
2317    ///
2318    /// Deletes a single Environment.
2319    ///
2320    /// # Arguments
2321    ///
2322    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/environments/{environment_id}`
2323    pub fn locations_environments_delete(
2324        &self,
2325        name: &str,
2326    ) -> ProjectLocationEnvironmentDeleteCall<'a, C> {
2327        ProjectLocationEnvironmentDeleteCall {
2328            hub: self.hub,
2329            _name: name.to_string(),
2330            _delegate: Default::default(),
2331            _additional_params: Default::default(),
2332            _scopes: Default::default(),
2333        }
2334    }
2335
2336    /// Create a builder to help you perform the following task:
2337    ///
2338    /// Gets details of a single Environment.
2339    ///
2340    /// # Arguments
2341    ///
2342    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/environments/{environment_id}`
2343    pub fn locations_environments_get(
2344        &self,
2345        name: &str,
2346    ) -> ProjectLocationEnvironmentGetCall<'a, C> {
2347        ProjectLocationEnvironmentGetCall {
2348            hub: self.hub,
2349            _name: name.to_string(),
2350            _delegate: Default::default(),
2351            _additional_params: Default::default(),
2352            _scopes: Default::default(),
2353        }
2354    }
2355
2356    /// Create a builder to help you perform the following task:
2357    ///
2358    /// Lists environments in a project.
2359    ///
2360    /// # Arguments
2361    ///
2362    /// * `parent` - Required. Format: `projects/{project_id}/locations/{location}`
2363    pub fn locations_environments_list(
2364        &self,
2365        parent: &str,
2366    ) -> ProjectLocationEnvironmentListCall<'a, C> {
2367        ProjectLocationEnvironmentListCall {
2368            hub: self.hub,
2369            _parent: parent.to_string(),
2370            _page_token: Default::default(),
2371            _page_size: Default::default(),
2372            _delegate: Default::default(),
2373            _additional_params: Default::default(),
2374            _scopes: Default::default(),
2375        }
2376    }
2377
2378    /// Create a builder to help you perform the following task:
2379    ///
2380    /// Creates a new Execution in a given project and location.
2381    ///
2382    /// # Arguments
2383    ///
2384    /// * `request` - No description provided.
2385    /// * `parent` - Required. Format: `parent=projects/{project_id}/locations/{location}`
2386    pub fn locations_executions_create(
2387        &self,
2388        request: Execution,
2389        parent: &str,
2390    ) -> ProjectLocationExecutionCreateCall<'a, C> {
2391        ProjectLocationExecutionCreateCall {
2392            hub: self.hub,
2393            _request: request,
2394            _parent: parent.to_string(),
2395            _execution_id: Default::default(),
2396            _delegate: Default::default(),
2397            _additional_params: Default::default(),
2398            _scopes: Default::default(),
2399        }
2400    }
2401
2402    /// Create a builder to help you perform the following task:
2403    ///
2404    /// Deletes execution
2405    ///
2406    /// # Arguments
2407    ///
2408    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/executions/{execution_id}`
2409    pub fn locations_executions_delete(
2410        &self,
2411        name: &str,
2412    ) -> ProjectLocationExecutionDeleteCall<'a, C> {
2413        ProjectLocationExecutionDeleteCall {
2414            hub: self.hub,
2415            _name: name.to_string(),
2416            _delegate: Default::default(),
2417            _additional_params: Default::default(),
2418            _scopes: Default::default(),
2419        }
2420    }
2421
2422    /// Create a builder to help you perform the following task:
2423    ///
2424    /// Gets details of executions
2425    ///
2426    /// # Arguments
2427    ///
2428    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/executions/{execution_id}`
2429    pub fn locations_executions_get(&self, name: &str) -> ProjectLocationExecutionGetCall<'a, C> {
2430        ProjectLocationExecutionGetCall {
2431            hub: self.hub,
2432            _name: name.to_string(),
2433            _delegate: Default::default(),
2434            _additional_params: Default::default(),
2435            _scopes: Default::default(),
2436        }
2437    }
2438
2439    /// Create a builder to help you perform the following task:
2440    ///
2441    /// Lists executions in a given project and location
2442    ///
2443    /// # Arguments
2444    ///
2445    /// * `parent` - Required. Format: `parent=projects/{project_id}/locations/{location}`
2446    pub fn locations_executions_list(
2447        &self,
2448        parent: &str,
2449    ) -> ProjectLocationExecutionListCall<'a, C> {
2450        ProjectLocationExecutionListCall {
2451            hub: self.hub,
2452            _parent: parent.to_string(),
2453            _page_token: Default::default(),
2454            _page_size: Default::default(),
2455            _order_by: Default::default(),
2456            _filter: Default::default(),
2457            _delegate: Default::default(),
2458            _additional_params: Default::default(),
2459            _scopes: Default::default(),
2460        }
2461    }
2462
2463    /// Create a builder to help you perform the following task:
2464    ///
2465    /// Creates a new Instance in a given project and location.
2466    ///
2467    /// # Arguments
2468    ///
2469    /// * `request` - No description provided.
2470    /// * `parent` - Required. Format: `parent=projects/{project_id}/locations/{location}`
2471    pub fn locations_instances_create(
2472        &self,
2473        request: Instance,
2474        parent: &str,
2475    ) -> ProjectLocationInstanceCreateCall<'a, C> {
2476        ProjectLocationInstanceCreateCall {
2477            hub: self.hub,
2478            _request: request,
2479            _parent: parent.to_string(),
2480            _instance_id: Default::default(),
2481            _delegate: Default::default(),
2482            _additional_params: Default::default(),
2483            _scopes: Default::default(),
2484        }
2485    }
2486
2487    /// Create a builder to help you perform the following task:
2488    ///
2489    /// Deletes a single Instance.
2490    ///
2491    /// # Arguments
2492    ///
2493    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2494    pub fn locations_instances_delete(
2495        &self,
2496        name: &str,
2497    ) -> ProjectLocationInstanceDeleteCall<'a, C> {
2498        ProjectLocationInstanceDeleteCall {
2499            hub: self.hub,
2500            _name: name.to_string(),
2501            _delegate: Default::default(),
2502            _additional_params: Default::default(),
2503            _scopes: Default::default(),
2504        }
2505    }
2506
2507    /// Create a builder to help you perform the following task:
2508    ///
2509    /// Creates a Diagnostic File and runs Diagnostic Tool given an Instance.
2510    ///
2511    /// # Arguments
2512    ///
2513    /// * `request` - No description provided.
2514    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2515    pub fn locations_instances_diagnose(
2516        &self,
2517        request: DiagnoseInstanceRequest,
2518        name: &str,
2519    ) -> ProjectLocationInstanceDiagnoseCall<'a, C> {
2520        ProjectLocationInstanceDiagnoseCall {
2521            hub: self.hub,
2522            _request: request,
2523            _name: name.to_string(),
2524            _delegate: Default::default(),
2525            _additional_params: Default::default(),
2526            _scopes: Default::default(),
2527        }
2528    }
2529
2530    /// Create a builder to help you perform the following task:
2531    ///
2532    /// Gets details of a single Instance.
2533    ///
2534    /// # Arguments
2535    ///
2536    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2537    pub fn locations_instances_get(&self, name: &str) -> ProjectLocationInstanceGetCall<'a, C> {
2538        ProjectLocationInstanceGetCall {
2539            hub: self.hub,
2540            _name: name.to_string(),
2541            _delegate: Default::default(),
2542            _additional_params: Default::default(),
2543            _scopes: Default::default(),
2544        }
2545    }
2546
2547    /// Create a builder to help you perform the following task:
2548    ///
2549    /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
2550    ///
2551    /// # Arguments
2552    ///
2553    /// * `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.
2554    pub fn locations_instances_get_iam_policy(
2555        &self,
2556        resource: &str,
2557    ) -> ProjectLocationInstanceGetIamPolicyCall<'a, C> {
2558        ProjectLocationInstanceGetIamPolicyCall {
2559            hub: self.hub,
2560            _resource: resource.to_string(),
2561            _options_requested_policy_version: Default::default(),
2562            _delegate: Default::default(),
2563            _additional_params: Default::default(),
2564            _scopes: Default::default(),
2565        }
2566    }
2567
2568    /// Create a builder to help you perform the following task:
2569    ///
2570    /// Checks whether a notebook instance is healthy.
2571    ///
2572    /// # Arguments
2573    ///
2574    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2575    pub fn locations_instances_get_instance_health(
2576        &self,
2577        name: &str,
2578    ) -> ProjectLocationInstanceGetInstanceHealthCall<'a, C> {
2579        ProjectLocationInstanceGetInstanceHealthCall {
2580            hub: self.hub,
2581            _name: name.to_string(),
2582            _delegate: Default::default(),
2583            _additional_params: Default::default(),
2584            _scopes: Default::default(),
2585        }
2586    }
2587
2588    /// Create a builder to help you perform the following task:
2589    ///
2590    /// Checks whether a notebook instance is upgradable.
2591    ///
2592    /// # Arguments
2593    ///
2594    /// * `notebookInstance` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2595    pub fn locations_instances_is_upgradeable(
2596        &self,
2597        notebook_instance: &str,
2598    ) -> ProjectLocationInstanceIsUpgradeableCall<'a, C> {
2599        ProjectLocationInstanceIsUpgradeableCall {
2600            hub: self.hub,
2601            _notebook_instance: notebook_instance.to_string(),
2602            _type_: Default::default(),
2603            _delegate: Default::default(),
2604            _additional_params: Default::default(),
2605            _scopes: Default::default(),
2606        }
2607    }
2608
2609    /// Create a builder to help you perform the following task:
2610    ///
2611    /// Lists instances in a given project and location.
2612    ///
2613    /// # Arguments
2614    ///
2615    /// * `parent` - Required. Format: `parent=projects/{project_id}/locations/{location}`
2616    pub fn locations_instances_list(&self, parent: &str) -> ProjectLocationInstanceListCall<'a, C> {
2617        ProjectLocationInstanceListCall {
2618            hub: self.hub,
2619            _parent: parent.to_string(),
2620            _page_token: Default::default(),
2621            _page_size: Default::default(),
2622            _order_by: Default::default(),
2623            _filter: Default::default(),
2624            _delegate: Default::default(),
2625            _additional_params: Default::default(),
2626            _scopes: Default::default(),
2627        }
2628    }
2629
2630    /// Create a builder to help you perform the following task:
2631    ///
2632    /// Migrates an existing User-Managed Notebook to Workbench Instances.
2633    ///
2634    /// # Arguments
2635    ///
2636    /// * `request` - No description provided.
2637    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2638    pub fn locations_instances_migrate(
2639        &self,
2640        request: MigrateInstanceRequest,
2641        name: &str,
2642    ) -> ProjectLocationInstanceMigrateCall<'a, C> {
2643        ProjectLocationInstanceMigrateCall {
2644            hub: self.hub,
2645            _request: request,
2646            _name: name.to_string(),
2647            _delegate: Default::default(),
2648            _additional_params: Default::default(),
2649            _scopes: Default::default(),
2650        }
2651    }
2652
2653    /// Create a builder to help you perform the following task:
2654    ///
2655    /// Registers an existing legacy notebook instance to the Notebooks API server. Legacy instances are instances created with the legacy Compute Engine calls. They are not manageable by the Notebooks API out of the box. This call makes these instances manageable by the Notebooks API.
2656    ///
2657    /// # Arguments
2658    ///
2659    /// * `request` - No description provided.
2660    /// * `parent` - Required. Format: `parent=projects/{project_id}/locations/{location}`
2661    pub fn locations_instances_register(
2662        &self,
2663        request: RegisterInstanceRequest,
2664        parent: &str,
2665    ) -> ProjectLocationInstanceRegisterCall<'a, C> {
2666        ProjectLocationInstanceRegisterCall {
2667            hub: self.hub,
2668            _request: request,
2669            _parent: parent.to_string(),
2670            _delegate: Default::default(),
2671            _additional_params: Default::default(),
2672            _scopes: Default::default(),
2673        }
2674    }
2675
2676    /// Create a builder to help you perform the following task:
2677    ///
2678    /// Allows notebook instances to report their latest instance information to the Notebooks API server. The server will merge the reported information to the instance metadata store. Do not use this method directly.
2679    ///
2680    /// # Arguments
2681    ///
2682    /// * `request` - No description provided.
2683    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2684    pub fn locations_instances_report(
2685        &self,
2686        request: ReportInstanceInfoRequest,
2687        name: &str,
2688    ) -> ProjectLocationInstanceReportCall<'a, C> {
2689        ProjectLocationInstanceReportCall {
2690            hub: self.hub,
2691            _request: request,
2692            _name: name.to_string(),
2693            _delegate: Default::default(),
2694            _additional_params: Default::default(),
2695            _scopes: Default::default(),
2696        }
2697    }
2698
2699    /// Create a builder to help you perform the following task:
2700    ///
2701    /// Reports and processes an instance event.
2702    ///
2703    /// # Arguments
2704    ///
2705    /// * `request` - No description provided.
2706    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2707    pub fn locations_instances_report_event(
2708        &self,
2709        request: ReportInstanceEventRequest,
2710        name: &str,
2711    ) -> ProjectLocationInstanceReportEventCall<'a, C> {
2712        ProjectLocationInstanceReportEventCall {
2713            hub: self.hub,
2714            _request: request,
2715            _name: name.to_string(),
2716            _delegate: Default::default(),
2717            _additional_params: Default::default(),
2718            _scopes: Default::default(),
2719        }
2720    }
2721
2722    /// Create a builder to help you perform the following task:
2723    ///
2724    /// Resets a notebook instance.
2725    ///
2726    /// # Arguments
2727    ///
2728    /// * `request` - No description provided.
2729    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2730    pub fn locations_instances_reset(
2731        &self,
2732        request: ResetInstanceRequest,
2733        name: &str,
2734    ) -> ProjectLocationInstanceResetCall<'a, C> {
2735        ProjectLocationInstanceResetCall {
2736            hub: self.hub,
2737            _request: request,
2738            _name: name.to_string(),
2739            _delegate: Default::default(),
2740            _additional_params: Default::default(),
2741            _scopes: Default::default(),
2742        }
2743    }
2744
2745    /// Create a builder to help you perform the following task:
2746    ///
2747    /// Rollbacks a notebook instance to the previous version.
2748    ///
2749    /// # Arguments
2750    ///
2751    /// * `request` - No description provided.
2752    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2753    pub fn locations_instances_rollback(
2754        &self,
2755        request: RollbackInstanceRequest,
2756        name: &str,
2757    ) -> ProjectLocationInstanceRollbackCall<'a, C> {
2758        ProjectLocationInstanceRollbackCall {
2759            hub: self.hub,
2760            _request: request,
2761            _name: name.to_string(),
2762            _delegate: Default::default(),
2763            _additional_params: Default::default(),
2764            _scopes: Default::default(),
2765        }
2766    }
2767
2768    /// Create a builder to help you perform the following task:
2769    ///
2770    /// Updates the guest accelerators of a single Instance.
2771    ///
2772    /// # Arguments
2773    ///
2774    /// * `request` - No description provided.
2775    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2776    pub fn locations_instances_set_accelerator(
2777        &self,
2778        request: SetInstanceAcceleratorRequest,
2779        name: &str,
2780    ) -> ProjectLocationInstanceSetAcceleratorCall<'a, C> {
2781        ProjectLocationInstanceSetAcceleratorCall {
2782            hub: self.hub,
2783            _request: request,
2784            _name: name.to_string(),
2785            _delegate: Default::default(),
2786            _additional_params: Default::default(),
2787            _scopes: Default::default(),
2788        }
2789    }
2790
2791    /// Create a builder to help you perform the following task:
2792    ///
2793    /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
2794    ///
2795    /// # Arguments
2796    ///
2797    /// * `request` - No description provided.
2798    /// * `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.
2799    pub fn locations_instances_set_iam_policy(
2800        &self,
2801        request: SetIamPolicyRequest,
2802        resource: &str,
2803    ) -> ProjectLocationInstanceSetIamPolicyCall<'a, C> {
2804        ProjectLocationInstanceSetIamPolicyCall {
2805            hub: self.hub,
2806            _request: request,
2807            _resource: resource.to_string(),
2808            _delegate: Default::default(),
2809            _additional_params: Default::default(),
2810            _scopes: Default::default(),
2811        }
2812    }
2813
2814    /// Create a builder to help you perform the following task:
2815    ///
2816    /// Replaces all the labels of an Instance.
2817    ///
2818    /// # Arguments
2819    ///
2820    /// * `request` - No description provided.
2821    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2822    pub fn locations_instances_set_labels(
2823        &self,
2824        request: SetInstanceLabelsRequest,
2825        name: &str,
2826    ) -> ProjectLocationInstanceSetLabelCall<'a, C> {
2827        ProjectLocationInstanceSetLabelCall {
2828            hub: self.hub,
2829            _request: request,
2830            _name: name.to_string(),
2831            _delegate: Default::default(),
2832            _additional_params: Default::default(),
2833            _scopes: Default::default(),
2834        }
2835    }
2836
2837    /// Create a builder to help you perform the following task:
2838    ///
2839    /// Updates the machine type of a single Instance.
2840    ///
2841    /// # Arguments
2842    ///
2843    /// * `request` - No description provided.
2844    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2845    pub fn locations_instances_set_machine_type(
2846        &self,
2847        request: SetInstanceMachineTypeRequest,
2848        name: &str,
2849    ) -> ProjectLocationInstanceSetMachineTypeCall<'a, C> {
2850        ProjectLocationInstanceSetMachineTypeCall {
2851            hub: self.hub,
2852            _request: request,
2853            _name: name.to_string(),
2854            _delegate: Default::default(),
2855            _additional_params: Default::default(),
2856            _scopes: Default::default(),
2857        }
2858    }
2859
2860    /// Create a builder to help you perform the following task:
2861    ///
2862    /// Starts a notebook instance.
2863    ///
2864    /// # Arguments
2865    ///
2866    /// * `request` - No description provided.
2867    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2868    pub fn locations_instances_start(
2869        &self,
2870        request: StartInstanceRequest,
2871        name: &str,
2872    ) -> ProjectLocationInstanceStartCall<'a, C> {
2873        ProjectLocationInstanceStartCall {
2874            hub: self.hub,
2875            _request: request,
2876            _name: name.to_string(),
2877            _delegate: Default::default(),
2878            _additional_params: Default::default(),
2879            _scopes: Default::default(),
2880        }
2881    }
2882
2883    /// Create a builder to help you perform the following task:
2884    ///
2885    /// Stops a notebook instance.
2886    ///
2887    /// # Arguments
2888    ///
2889    /// * `request` - No description provided.
2890    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2891    pub fn locations_instances_stop(
2892        &self,
2893        request: StopInstanceRequest,
2894        name: &str,
2895    ) -> ProjectLocationInstanceStopCall<'a, C> {
2896        ProjectLocationInstanceStopCall {
2897            hub: self.hub,
2898            _request: request,
2899            _name: name.to_string(),
2900            _delegate: Default::default(),
2901            _additional_params: Default::default(),
2902            _scopes: Default::default(),
2903        }
2904    }
2905
2906    /// Create a builder to help you perform the following task:
2907    ///
2908    /// 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.
2909    ///
2910    /// # Arguments
2911    ///
2912    /// * `request` - No description provided.
2913    /// * `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.
2914    pub fn locations_instances_test_iam_permissions(
2915        &self,
2916        request: TestIamPermissionsRequest,
2917        resource: &str,
2918    ) -> ProjectLocationInstanceTestIamPermissionCall<'a, C> {
2919        ProjectLocationInstanceTestIamPermissionCall {
2920            hub: self.hub,
2921            _request: request,
2922            _resource: resource.to_string(),
2923            _delegate: Default::default(),
2924            _additional_params: Default::default(),
2925            _scopes: Default::default(),
2926        }
2927    }
2928
2929    /// Create a builder to help you perform the following task:
2930    ///
2931    /// Update Notebook Instance configurations.
2932    ///
2933    /// # Arguments
2934    ///
2935    /// * `request` - No description provided.
2936    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2937    pub fn locations_instances_update_config(
2938        &self,
2939        request: UpdateInstanceConfigRequest,
2940        name: &str,
2941    ) -> ProjectLocationInstanceUpdateConfigCall<'a, C> {
2942        ProjectLocationInstanceUpdateConfigCall {
2943            hub: self.hub,
2944            _request: request,
2945            _name: name.to_string(),
2946            _delegate: Default::default(),
2947            _additional_params: Default::default(),
2948            _scopes: Default::default(),
2949        }
2950    }
2951
2952    /// Create a builder to help you perform the following task:
2953    ///
2954    /// Add/update metadata items for an instance.
2955    ///
2956    /// # Arguments
2957    ///
2958    /// * `request` - No description provided.
2959    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2960    pub fn locations_instances_update_metadata_items(
2961        &self,
2962        request: UpdateInstanceMetadataItemsRequest,
2963        name: &str,
2964    ) -> ProjectLocationInstanceUpdateMetadataItemCall<'a, C> {
2965        ProjectLocationInstanceUpdateMetadataItemCall {
2966            hub: self.hub,
2967            _request: request,
2968            _name: name.to_string(),
2969            _delegate: Default::default(),
2970            _additional_params: Default::default(),
2971            _scopes: Default::default(),
2972        }
2973    }
2974
2975    /// Create a builder to help you perform the following task:
2976    ///
2977    /// Updates the Shielded instance configuration of a single Instance.
2978    ///
2979    /// # Arguments
2980    ///
2981    /// * `request` - No description provided.
2982    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2983    pub fn locations_instances_update_shielded_instance_config(
2984        &self,
2985        request: UpdateShieldedInstanceConfigRequest,
2986        name: &str,
2987    ) -> ProjectLocationInstanceUpdateShieldedInstanceConfigCall<'a, C> {
2988        ProjectLocationInstanceUpdateShieldedInstanceConfigCall {
2989            hub: self.hub,
2990            _request: request,
2991            _name: name.to_string(),
2992            _delegate: Default::default(),
2993            _additional_params: Default::default(),
2994            _scopes: Default::default(),
2995        }
2996    }
2997
2998    /// Create a builder to help you perform the following task:
2999    ///
3000    /// Upgrades a notebook instance to the latest version.
3001    ///
3002    /// # Arguments
3003    ///
3004    /// * `request` - No description provided.
3005    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
3006    pub fn locations_instances_upgrade(
3007        &self,
3008        request: UpgradeInstanceRequest,
3009        name: &str,
3010    ) -> ProjectLocationInstanceUpgradeCall<'a, C> {
3011        ProjectLocationInstanceUpgradeCall {
3012            hub: self.hub,
3013            _request: request,
3014            _name: name.to_string(),
3015            _delegate: Default::default(),
3016            _additional_params: Default::default(),
3017            _scopes: Default::default(),
3018        }
3019    }
3020
3021    /// Create a builder to help you perform the following task:
3022    ///
3023    /// Allows notebook instances to call this endpoint to upgrade themselves. Do not use this method directly.
3024    ///
3025    /// # Arguments
3026    ///
3027    /// * `request` - No description provided.
3028    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
3029    pub fn locations_instances_upgrade_internal(
3030        &self,
3031        request: UpgradeInstanceInternalRequest,
3032        name: &str,
3033    ) -> ProjectLocationInstanceUpgradeInternalCall<'a, C> {
3034        ProjectLocationInstanceUpgradeInternalCall {
3035            hub: self.hub,
3036            _request: request,
3037            _name: name.to_string(),
3038            _delegate: Default::default(),
3039            _additional_params: Default::default(),
3040            _scopes: Default::default(),
3041        }
3042    }
3043
3044    /// Create a builder to help you perform the following task:
3045    ///
3046    /// 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`.
3047    ///
3048    /// # Arguments
3049    ///
3050    /// * `request` - No description provided.
3051    /// * `name` - The name of the operation resource to be cancelled.
3052    pub fn locations_operations_cancel(
3053        &self,
3054        request: CancelOperationRequest,
3055        name: &str,
3056    ) -> ProjectLocationOperationCancelCall<'a, C> {
3057        ProjectLocationOperationCancelCall {
3058            hub: self.hub,
3059            _request: request,
3060            _name: name.to_string(),
3061            _delegate: Default::default(),
3062            _additional_params: Default::default(),
3063            _scopes: Default::default(),
3064        }
3065    }
3066
3067    /// Create a builder to help you perform the following task:
3068    ///
3069    /// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`.
3070    ///
3071    /// # Arguments
3072    ///
3073    /// * `name` - The name of the operation resource to be deleted.
3074    pub fn locations_operations_delete(
3075        &self,
3076        name: &str,
3077    ) -> ProjectLocationOperationDeleteCall<'a, C> {
3078        ProjectLocationOperationDeleteCall {
3079            hub: self.hub,
3080            _name: name.to_string(),
3081            _delegate: Default::default(),
3082            _additional_params: Default::default(),
3083            _scopes: Default::default(),
3084        }
3085    }
3086
3087    /// Create a builder to help you perform the following task:
3088    ///
3089    /// 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.
3090    ///
3091    /// # Arguments
3092    ///
3093    /// * `name` - The name of the operation resource.
3094    pub fn locations_operations_get(&self, name: &str) -> ProjectLocationOperationGetCall<'a, C> {
3095        ProjectLocationOperationGetCall {
3096            hub: self.hub,
3097            _name: name.to_string(),
3098            _delegate: Default::default(),
3099            _additional_params: Default::default(),
3100            _scopes: Default::default(),
3101        }
3102    }
3103
3104    /// Create a builder to help you perform the following task:
3105    ///
3106    /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
3107    ///
3108    /// # Arguments
3109    ///
3110    /// * `name` - The name of the operation's parent resource.
3111    pub fn locations_operations_list(&self, name: &str) -> ProjectLocationOperationListCall<'a, C> {
3112        ProjectLocationOperationListCall {
3113            hub: self.hub,
3114            _name: name.to_string(),
3115            _return_partial_success: Default::default(),
3116            _page_token: Default::default(),
3117            _page_size: Default::default(),
3118            _filter: Default::default(),
3119            _delegate: Default::default(),
3120            _additional_params: Default::default(),
3121            _scopes: Default::default(),
3122        }
3123    }
3124
3125    /// Create a builder to help you perform the following task:
3126    ///
3127    /// Creates a new Runtime in a given project and location.
3128    ///
3129    /// # Arguments
3130    ///
3131    /// * `request` - No description provided.
3132    /// * `parent` - Required. Format: `parent=projects/{project_id}/locations/{location}`
3133    pub fn locations_runtimes_create(
3134        &self,
3135        request: Runtime,
3136        parent: &str,
3137    ) -> ProjectLocationRuntimeCreateCall<'a, C> {
3138        ProjectLocationRuntimeCreateCall {
3139            hub: self.hub,
3140            _request: request,
3141            _parent: parent.to_string(),
3142            _runtime_id: Default::default(),
3143            _request_id: Default::default(),
3144            _delegate: Default::default(),
3145            _additional_params: Default::default(),
3146            _scopes: Default::default(),
3147        }
3148    }
3149
3150    /// Create a builder to help you perform the following task:
3151    ///
3152    /// Deletes a single Runtime.
3153    ///
3154    /// # Arguments
3155    ///
3156    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
3157    pub fn locations_runtimes_delete(&self, name: &str) -> ProjectLocationRuntimeDeleteCall<'a, C> {
3158        ProjectLocationRuntimeDeleteCall {
3159            hub: self.hub,
3160            _name: name.to_string(),
3161            _request_id: Default::default(),
3162            _delegate: Default::default(),
3163            _additional_params: Default::default(),
3164            _scopes: Default::default(),
3165        }
3166    }
3167
3168    /// Create a builder to help you perform the following task:
3169    ///
3170    /// Creates a Diagnostic File and runs Diagnostic Tool given a Runtime.
3171    ///
3172    /// # Arguments
3173    ///
3174    /// * `request` - No description provided.
3175    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtimes_id}`
3176    pub fn locations_runtimes_diagnose(
3177        &self,
3178        request: DiagnoseRuntimeRequest,
3179        name: &str,
3180    ) -> ProjectLocationRuntimeDiagnoseCall<'a, C> {
3181        ProjectLocationRuntimeDiagnoseCall {
3182            hub: self.hub,
3183            _request: request,
3184            _name: name.to_string(),
3185            _delegate: Default::default(),
3186            _additional_params: Default::default(),
3187            _scopes: Default::default(),
3188        }
3189    }
3190
3191    /// Create a builder to help you perform the following task:
3192    ///
3193    /// Gets details of a single Runtime. The location must be a regional endpoint rather than zonal.
3194    ///
3195    /// # Arguments
3196    ///
3197    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
3198    pub fn locations_runtimes_get(&self, name: &str) -> ProjectLocationRuntimeGetCall<'a, C> {
3199        ProjectLocationRuntimeGetCall {
3200            hub: self.hub,
3201            _name: name.to_string(),
3202            _delegate: Default::default(),
3203            _additional_params: Default::default(),
3204            _scopes: Default::default(),
3205        }
3206    }
3207
3208    /// Create a builder to help you perform the following task:
3209    ///
3210    /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
3211    ///
3212    /// # Arguments
3213    ///
3214    /// * `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.
3215    pub fn locations_runtimes_get_iam_policy(
3216        &self,
3217        resource: &str,
3218    ) -> ProjectLocationRuntimeGetIamPolicyCall<'a, C> {
3219        ProjectLocationRuntimeGetIamPolicyCall {
3220            hub: self.hub,
3221            _resource: resource.to_string(),
3222            _options_requested_policy_version: Default::default(),
3223            _delegate: Default::default(),
3224            _additional_params: Default::default(),
3225            _scopes: Default::default(),
3226        }
3227    }
3228
3229    /// Create a builder to help you perform the following task:
3230    ///
3231    /// Lists Runtimes in a given project and location.
3232    ///
3233    /// # Arguments
3234    ///
3235    /// * `parent` - Required. Format: `parent=projects/{project_id}/locations/{location}`
3236    pub fn locations_runtimes_list(&self, parent: &str) -> ProjectLocationRuntimeListCall<'a, C> {
3237        ProjectLocationRuntimeListCall {
3238            hub: self.hub,
3239            _parent: parent.to_string(),
3240            _page_token: Default::default(),
3241            _page_size: Default::default(),
3242            _order_by: Default::default(),
3243            _filter: Default::default(),
3244            _delegate: Default::default(),
3245            _additional_params: Default::default(),
3246            _scopes: Default::default(),
3247        }
3248    }
3249
3250    /// Create a builder to help you perform the following task:
3251    ///
3252    /// Migrate an existing Runtime to a new Workbench Instance.
3253    ///
3254    /// # Arguments
3255    ///
3256    /// * `request` - No description provided.
3257    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
3258    pub fn locations_runtimes_migrate(
3259        &self,
3260        request: MigrateRuntimeRequest,
3261        name: &str,
3262    ) -> ProjectLocationRuntimeMigrateCall<'a, C> {
3263        ProjectLocationRuntimeMigrateCall {
3264            hub: self.hub,
3265            _request: request,
3266            _name: name.to_string(),
3267            _delegate: Default::default(),
3268            _additional_params: Default::default(),
3269            _scopes: Default::default(),
3270        }
3271    }
3272
3273    /// Create a builder to help you perform the following task:
3274    ///
3275    /// Update Notebook Runtime configuration.
3276    ///
3277    /// # Arguments
3278    ///
3279    /// * `request` - No description provided.
3280    /// * `name` - Output only. The resource name of the runtime. Format: `projects/{project}/locations/{location}/runtimes/{runtimeId}`
3281    pub fn locations_runtimes_patch(
3282        &self,
3283        request: Runtime,
3284        name: &str,
3285    ) -> ProjectLocationRuntimePatchCall<'a, C> {
3286        ProjectLocationRuntimePatchCall {
3287            hub: self.hub,
3288            _request: request,
3289            _name: name.to_string(),
3290            _update_mask: Default::default(),
3291            _request_id: Default::default(),
3292            _delegate: Default::default(),
3293            _additional_params: Default::default(),
3294            _scopes: Default::default(),
3295        }
3296    }
3297
3298    /// Create a builder to help you perform the following task:
3299    ///
3300    /// Gets an access token for the consumer service account that the customer attached to the runtime. Only accessible from the tenant instance.
3301    ///
3302    /// # Arguments
3303    ///
3304    /// * `request` - No description provided.
3305    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
3306    pub fn locations_runtimes_refresh_runtime_token_internal(
3307        &self,
3308        request: RefreshRuntimeTokenInternalRequest,
3309        name: &str,
3310    ) -> ProjectLocationRuntimeRefreshRuntimeTokenInternalCall<'a, C> {
3311        ProjectLocationRuntimeRefreshRuntimeTokenInternalCall {
3312            hub: self.hub,
3313            _request: request,
3314            _name: name.to_string(),
3315            _delegate: Default::default(),
3316            _additional_params: Default::default(),
3317            _scopes: Default::default(),
3318        }
3319    }
3320
3321    /// Create a builder to help you perform the following task:
3322    ///
3323    /// Reports and processes a runtime event.
3324    ///
3325    /// # Arguments
3326    ///
3327    /// * `request` - No description provided.
3328    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
3329    pub fn locations_runtimes_report_event(
3330        &self,
3331        request: ReportRuntimeEventRequest,
3332        name: &str,
3333    ) -> ProjectLocationRuntimeReportEventCall<'a, C> {
3334        ProjectLocationRuntimeReportEventCall {
3335            hub: self.hub,
3336            _request: request,
3337            _name: name.to_string(),
3338            _delegate: Default::default(),
3339            _additional_params: Default::default(),
3340            _scopes: Default::default(),
3341        }
3342    }
3343
3344    /// Create a builder to help you perform the following task:
3345    ///
3346    /// Resets a Managed Notebook Runtime.
3347    ///
3348    /// # Arguments
3349    ///
3350    /// * `request` - No description provided.
3351    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
3352    pub fn locations_runtimes_reset(
3353        &self,
3354        request: ResetRuntimeRequest,
3355        name: &str,
3356    ) -> ProjectLocationRuntimeResetCall<'a, C> {
3357        ProjectLocationRuntimeResetCall {
3358            hub: self.hub,
3359            _request: request,
3360            _name: name.to_string(),
3361            _delegate: Default::default(),
3362            _additional_params: Default::default(),
3363            _scopes: Default::default(),
3364        }
3365    }
3366
3367    /// Create a builder to help you perform the following task:
3368    ///
3369    /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
3370    ///
3371    /// # Arguments
3372    ///
3373    /// * `request` - No description provided.
3374    /// * `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.
3375    pub fn locations_runtimes_set_iam_policy(
3376        &self,
3377        request: SetIamPolicyRequest,
3378        resource: &str,
3379    ) -> ProjectLocationRuntimeSetIamPolicyCall<'a, C> {
3380        ProjectLocationRuntimeSetIamPolicyCall {
3381            hub: self.hub,
3382            _request: request,
3383            _resource: resource.to_string(),
3384            _delegate: Default::default(),
3385            _additional_params: Default::default(),
3386            _scopes: Default::default(),
3387        }
3388    }
3389
3390    /// Create a builder to help you perform the following task:
3391    ///
3392    /// Starts a Managed Notebook Runtime. Perform "Start" on GPU instances; "Resume" on CPU instances See: https://cloud.google.com/compute/docs/instances/stop-start-instance https://cloud.google.com/compute/docs/instances/suspend-resume-instance
3393    ///
3394    /// # Arguments
3395    ///
3396    /// * `request` - No description provided.
3397    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
3398    pub fn locations_runtimes_start(
3399        &self,
3400        request: StartRuntimeRequest,
3401        name: &str,
3402    ) -> ProjectLocationRuntimeStartCall<'a, C> {
3403        ProjectLocationRuntimeStartCall {
3404            hub: self.hub,
3405            _request: request,
3406            _name: name.to_string(),
3407            _delegate: Default::default(),
3408            _additional_params: Default::default(),
3409            _scopes: Default::default(),
3410        }
3411    }
3412
3413    /// Create a builder to help you perform the following task:
3414    ///
3415    /// Stops a Managed Notebook Runtime. Perform "Stop" on GPU instances; "Suspend" on CPU instances See: https://cloud.google.com/compute/docs/instances/stop-start-instance https://cloud.google.com/compute/docs/instances/suspend-resume-instance
3416    ///
3417    /// # Arguments
3418    ///
3419    /// * `request` - No description provided.
3420    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
3421    pub fn locations_runtimes_stop(
3422        &self,
3423        request: StopRuntimeRequest,
3424        name: &str,
3425    ) -> ProjectLocationRuntimeStopCall<'a, C> {
3426        ProjectLocationRuntimeStopCall {
3427            hub: self.hub,
3428            _request: request,
3429            _name: name.to_string(),
3430            _delegate: Default::default(),
3431            _additional_params: Default::default(),
3432            _scopes: Default::default(),
3433        }
3434    }
3435
3436    /// Create a builder to help you perform the following task:
3437    ///
3438    /// Switch a Managed Notebook Runtime.
3439    ///
3440    /// # Arguments
3441    ///
3442    /// * `request` - No description provided.
3443    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
3444    pub fn locations_runtimes_switch(
3445        &self,
3446        request: SwitchRuntimeRequest,
3447        name: &str,
3448    ) -> ProjectLocationRuntimeSwitchCall<'a, C> {
3449        ProjectLocationRuntimeSwitchCall {
3450            hub: self.hub,
3451            _request: request,
3452            _name: name.to_string(),
3453            _delegate: Default::default(),
3454            _additional_params: Default::default(),
3455            _scopes: Default::default(),
3456        }
3457    }
3458
3459    /// Create a builder to help you perform the following task:
3460    ///
3461    /// 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.
3462    ///
3463    /// # Arguments
3464    ///
3465    /// * `request` - No description provided.
3466    /// * `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.
3467    pub fn locations_runtimes_test_iam_permissions(
3468        &self,
3469        request: TestIamPermissionsRequest,
3470        resource: &str,
3471    ) -> ProjectLocationRuntimeTestIamPermissionCall<'a, C> {
3472        ProjectLocationRuntimeTestIamPermissionCall {
3473            hub: self.hub,
3474            _request: request,
3475            _resource: resource.to_string(),
3476            _delegate: Default::default(),
3477            _additional_params: Default::default(),
3478            _scopes: Default::default(),
3479        }
3480    }
3481
3482    /// Create a builder to help you perform the following task:
3483    ///
3484    /// Upgrades a Managed Notebook Runtime to the latest version.
3485    ///
3486    /// # Arguments
3487    ///
3488    /// * `request` - No description provided.
3489    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
3490    pub fn locations_runtimes_upgrade(
3491        &self,
3492        request: UpgradeRuntimeRequest,
3493        name: &str,
3494    ) -> ProjectLocationRuntimeUpgradeCall<'a, C> {
3495        ProjectLocationRuntimeUpgradeCall {
3496            hub: self.hub,
3497            _request: request,
3498            _name: name.to_string(),
3499            _delegate: Default::default(),
3500            _additional_params: Default::default(),
3501            _scopes: Default::default(),
3502        }
3503    }
3504
3505    /// Create a builder to help you perform the following task:
3506    ///
3507    /// Creates a new Scheduled Notebook in a given project and location.
3508    ///
3509    /// # Arguments
3510    ///
3511    /// * `request` - No description provided.
3512    /// * `parent` - Required. Format: `parent=projects/{project_id}/locations/{location}`
3513    pub fn locations_schedules_create(
3514        &self,
3515        request: Schedule,
3516        parent: &str,
3517    ) -> ProjectLocationScheduleCreateCall<'a, C> {
3518        ProjectLocationScheduleCreateCall {
3519            hub: self.hub,
3520            _request: request,
3521            _parent: parent.to_string(),
3522            _schedule_id: Default::default(),
3523            _delegate: Default::default(),
3524            _additional_params: Default::default(),
3525            _scopes: Default::default(),
3526        }
3527    }
3528
3529    /// Create a builder to help you perform the following task:
3530    ///
3531    /// Deletes schedule and all underlying jobs
3532    ///
3533    /// # Arguments
3534    ///
3535    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/schedules/{schedule_id}`
3536    pub fn locations_schedules_delete(
3537        &self,
3538        name: &str,
3539    ) -> ProjectLocationScheduleDeleteCall<'a, C> {
3540        ProjectLocationScheduleDeleteCall {
3541            hub: self.hub,
3542            _name: name.to_string(),
3543            _delegate: Default::default(),
3544            _additional_params: Default::default(),
3545            _scopes: Default::default(),
3546        }
3547    }
3548
3549    /// Create a builder to help you perform the following task:
3550    ///
3551    /// Gets details of schedule
3552    ///
3553    /// # Arguments
3554    ///
3555    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/schedules/{schedule_id}`
3556    pub fn locations_schedules_get(&self, name: &str) -> ProjectLocationScheduleGetCall<'a, C> {
3557        ProjectLocationScheduleGetCall {
3558            hub: self.hub,
3559            _name: name.to_string(),
3560            _delegate: Default::default(),
3561            _additional_params: Default::default(),
3562            _scopes: Default::default(),
3563        }
3564    }
3565
3566    /// Create a builder to help you perform the following task:
3567    ///
3568    /// Lists schedules in a given project and location.
3569    ///
3570    /// # Arguments
3571    ///
3572    /// * `parent` - Required. Format: `parent=projects/{project_id}/locations/{location}`
3573    pub fn locations_schedules_list(&self, parent: &str) -> ProjectLocationScheduleListCall<'a, C> {
3574        ProjectLocationScheduleListCall {
3575            hub: self.hub,
3576            _parent: parent.to_string(),
3577            _page_token: Default::default(),
3578            _page_size: Default::default(),
3579            _order_by: Default::default(),
3580            _filter: Default::default(),
3581            _delegate: Default::default(),
3582            _additional_params: Default::default(),
3583            _scopes: Default::default(),
3584        }
3585    }
3586
3587    /// Create a builder to help you perform the following task:
3588    ///
3589    /// Triggers execution of an existing schedule.
3590    ///
3591    /// # Arguments
3592    ///
3593    /// * `request` - No description provided.
3594    /// * `name` - Required. Format: `parent=projects/{project_id}/locations/{location}/schedules/{schedule_id}`
3595    pub fn locations_schedules_trigger(
3596        &self,
3597        request: TriggerScheduleRequest,
3598        name: &str,
3599    ) -> ProjectLocationScheduleTriggerCall<'a, C> {
3600        ProjectLocationScheduleTriggerCall {
3601            hub: self.hub,
3602            _request: request,
3603            _name: name.to_string(),
3604            _delegate: Default::default(),
3605            _additional_params: Default::default(),
3606            _scopes: Default::default(),
3607        }
3608    }
3609
3610    /// Create a builder to help you perform the following task:
3611    ///
3612    /// Gets information about a location.
3613    ///
3614    /// # Arguments
3615    ///
3616    /// * `name` - Resource name for the location.
3617    pub fn locations_get(&self, name: &str) -> ProjectLocationGetCall<'a, C> {
3618        ProjectLocationGetCall {
3619            hub: self.hub,
3620            _name: name.to_string(),
3621            _delegate: Default::default(),
3622            _additional_params: Default::default(),
3623            _scopes: Default::default(),
3624        }
3625    }
3626
3627    /// Create a builder to help you perform the following task:
3628    ///
3629    /// Lists information about the supported locations for this service.
3630    ///
3631    /// # Arguments
3632    ///
3633    /// * `name` - The resource that owns the locations collection, if applicable.
3634    pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C> {
3635        ProjectLocationListCall {
3636            hub: self.hub,
3637            _name: name.to_string(),
3638            _page_token: Default::default(),
3639            _page_size: Default::default(),
3640            _filter: Default::default(),
3641            _extra_location_types: Default::default(),
3642            _delegate: Default::default(),
3643            _additional_params: Default::default(),
3644            _scopes: Default::default(),
3645        }
3646    }
3647}
3648
3649// ###################
3650// CallBuilders   ###
3651// #################
3652
3653/// Creates a new Environment.
3654///
3655/// A builder for the *locations.environments.create* method supported by a *project* resource.
3656/// It is not used directly, but through a [`ProjectMethods`] instance.
3657///
3658/// # Example
3659///
3660/// Instantiate a resource method builder
3661///
3662/// ```test_harness,no_run
3663/// # extern crate hyper;
3664/// # extern crate hyper_rustls;
3665/// # extern crate google_notebooks1 as notebooks1;
3666/// use notebooks1::api::Environment;
3667/// # async fn dox() {
3668/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3669///
3670/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3671/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3672/// #     .with_native_roots()
3673/// #     .unwrap()
3674/// #     .https_only()
3675/// #     .enable_http2()
3676/// #     .build();
3677///
3678/// # let executor = hyper_util::rt::TokioExecutor::new();
3679/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3680/// #     secret,
3681/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3682/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3683/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3684/// #     ),
3685/// # ).build().await.unwrap();
3686///
3687/// # let client = hyper_util::client::legacy::Client::builder(
3688/// #     hyper_util::rt::TokioExecutor::new()
3689/// # )
3690/// # .build(
3691/// #     hyper_rustls::HttpsConnectorBuilder::new()
3692/// #         .with_native_roots()
3693/// #         .unwrap()
3694/// #         .https_or_http()
3695/// #         .enable_http2()
3696/// #         .build()
3697/// # );
3698/// # let mut hub = AIPlatformNotebooks::new(client, auth);
3699/// // As the method needs a request, you would usually fill it with the desired information
3700/// // into the respective structure. Some of the parts shown here might not be applicable !
3701/// // Values shown here are possibly random and not representative !
3702/// let mut req = Environment::default();
3703///
3704/// // You can configure optional parameters by calling the respective setters at will, and
3705/// // execute the final call using `doit()`.
3706/// // Values shown here are possibly random and not representative !
3707/// let result = hub.projects().locations_environments_create(req, "parent")
3708///              .environment_id("amet.")
3709///              .doit().await;
3710/// # }
3711/// ```
3712pub struct ProjectLocationEnvironmentCreateCall<'a, C>
3713where
3714    C: 'a,
3715{
3716    hub: &'a AIPlatformNotebooks<C>,
3717    _request: Environment,
3718    _parent: String,
3719    _environment_id: Option<String>,
3720    _delegate: Option<&'a mut dyn common::Delegate>,
3721    _additional_params: HashMap<String, String>,
3722    _scopes: BTreeSet<String>,
3723}
3724
3725impl<'a, C> common::CallBuilder for ProjectLocationEnvironmentCreateCall<'a, C> {}
3726
3727impl<'a, C> ProjectLocationEnvironmentCreateCall<'a, C>
3728where
3729    C: common::Connector,
3730{
3731    /// Perform the operation you have build so far.
3732    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3733        use std::borrow::Cow;
3734        use std::io::{Read, Seek};
3735
3736        use common::{url::Params, ToParts};
3737        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3738
3739        let mut dd = common::DefaultDelegate;
3740        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3741        dlg.begin(common::MethodInfo {
3742            id: "notebooks.projects.locations.environments.create",
3743            http_method: hyper::Method::POST,
3744        });
3745
3746        for &field in ["alt", "parent", "environmentId"].iter() {
3747            if self._additional_params.contains_key(field) {
3748                dlg.finished(false);
3749                return Err(common::Error::FieldClash(field));
3750            }
3751        }
3752
3753        let mut params = Params::with_capacity(5 + self._additional_params.len());
3754        params.push("parent", self._parent);
3755        if let Some(value) = self._environment_id.as_ref() {
3756            params.push("environmentId", value);
3757        }
3758
3759        params.extend(self._additional_params.iter());
3760
3761        params.push("alt", "json");
3762        let mut url = self.hub._base_url.clone() + "v1/{+parent}/environments";
3763        if self._scopes.is_empty() {
3764            self._scopes
3765                .insert(Scope::CloudPlatform.as_ref().to_string());
3766        }
3767
3768        #[allow(clippy::single_element_loop)]
3769        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3770            url = params.uri_replacement(url, param_name, find_this, true);
3771        }
3772        {
3773            let to_remove = ["parent"];
3774            params.remove_params(&to_remove);
3775        }
3776
3777        let url = params.parse_with_url(&url);
3778
3779        let mut json_mime_type = mime::APPLICATION_JSON;
3780        let mut request_value_reader = {
3781            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3782            common::remove_json_null_values(&mut value);
3783            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3784            serde_json::to_writer(&mut dst, &value).unwrap();
3785            dst
3786        };
3787        let request_size = request_value_reader
3788            .seek(std::io::SeekFrom::End(0))
3789            .unwrap();
3790        request_value_reader
3791            .seek(std::io::SeekFrom::Start(0))
3792            .unwrap();
3793
3794        loop {
3795            let token = match self
3796                .hub
3797                .auth
3798                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3799                .await
3800            {
3801                Ok(token) => token,
3802                Err(e) => match dlg.token(e) {
3803                    Ok(token) => token,
3804                    Err(e) => {
3805                        dlg.finished(false);
3806                        return Err(common::Error::MissingToken(e));
3807                    }
3808                },
3809            };
3810            request_value_reader
3811                .seek(std::io::SeekFrom::Start(0))
3812                .unwrap();
3813            let mut req_result = {
3814                let client = &self.hub.client;
3815                dlg.pre_request();
3816                let mut req_builder = hyper::Request::builder()
3817                    .method(hyper::Method::POST)
3818                    .uri(url.as_str())
3819                    .header(USER_AGENT, self.hub._user_agent.clone());
3820
3821                if let Some(token) = token.as_ref() {
3822                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3823                }
3824
3825                let request = req_builder
3826                    .header(CONTENT_TYPE, json_mime_type.to_string())
3827                    .header(CONTENT_LENGTH, request_size as u64)
3828                    .body(common::to_body(
3829                        request_value_reader.get_ref().clone().into(),
3830                    ));
3831
3832                client.request(request.unwrap()).await
3833            };
3834
3835            match req_result {
3836                Err(err) => {
3837                    if let common::Retry::After(d) = dlg.http_error(&err) {
3838                        sleep(d).await;
3839                        continue;
3840                    }
3841                    dlg.finished(false);
3842                    return Err(common::Error::HttpError(err));
3843                }
3844                Ok(res) => {
3845                    let (mut parts, body) = res.into_parts();
3846                    let mut body = common::Body::new(body);
3847                    if !parts.status.is_success() {
3848                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3849                        let error = serde_json::from_str(&common::to_string(&bytes));
3850                        let response = common::to_response(parts, bytes.into());
3851
3852                        if let common::Retry::After(d) =
3853                            dlg.http_failure(&response, error.as_ref().ok())
3854                        {
3855                            sleep(d).await;
3856                            continue;
3857                        }
3858
3859                        dlg.finished(false);
3860
3861                        return Err(match error {
3862                            Ok(value) => common::Error::BadRequest(value),
3863                            _ => common::Error::Failure(response),
3864                        });
3865                    }
3866                    let response = {
3867                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3868                        let encoded = common::to_string(&bytes);
3869                        match serde_json::from_str(&encoded) {
3870                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3871                            Err(error) => {
3872                                dlg.response_json_decode_error(&encoded, &error);
3873                                return Err(common::Error::JsonDecodeError(
3874                                    encoded.to_string(),
3875                                    error,
3876                                ));
3877                            }
3878                        }
3879                    };
3880
3881                    dlg.finished(true);
3882                    return Ok(response);
3883                }
3884            }
3885        }
3886    }
3887
3888    ///
3889    /// Sets the *request* property to the given value.
3890    ///
3891    /// Even though the property as already been set when instantiating this call,
3892    /// we provide this method for API completeness.
3893    pub fn request(
3894        mut self,
3895        new_value: Environment,
3896    ) -> ProjectLocationEnvironmentCreateCall<'a, C> {
3897        self._request = new_value;
3898        self
3899    }
3900    /// Required. Format: `projects/{project_id}/locations/{location}`
3901    ///
3902    /// Sets the *parent* path property to the given value.
3903    ///
3904    /// Even though the property as already been set when instantiating this call,
3905    /// we provide this method for API completeness.
3906    pub fn parent(mut self, new_value: &str) -> ProjectLocationEnvironmentCreateCall<'a, C> {
3907        self._parent = new_value.to_string();
3908        self
3909    }
3910    /// Required. User-defined unique ID of this environment. The `environment_id` must be 1 to 63 characters long and contain only lowercase letters, numeric characters, and dashes. The first character must be a lowercase letter and the last character cannot be a dash.
3911    ///
3912    /// Sets the *environment id* query property to the given value.
3913    pub fn environment_id(
3914        mut self,
3915        new_value: &str,
3916    ) -> ProjectLocationEnvironmentCreateCall<'a, C> {
3917        self._environment_id = Some(new_value.to_string());
3918        self
3919    }
3920    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3921    /// while executing the actual API request.
3922    ///
3923    /// ````text
3924    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3925    /// ````
3926    ///
3927    /// Sets the *delegate* property to the given value.
3928    pub fn delegate(
3929        mut self,
3930        new_value: &'a mut dyn common::Delegate,
3931    ) -> ProjectLocationEnvironmentCreateCall<'a, C> {
3932        self._delegate = Some(new_value);
3933        self
3934    }
3935
3936    /// Set any additional parameter of the query string used in the request.
3937    /// It should be used to set parameters which are not yet available through their own
3938    /// setters.
3939    ///
3940    /// Please note that this method must not be used to set any of the known parameters
3941    /// which have their own setter method. If done anyway, the request will fail.
3942    ///
3943    /// # Additional Parameters
3944    ///
3945    /// * *$.xgafv* (query-string) - V1 error format.
3946    /// * *access_token* (query-string) - OAuth access token.
3947    /// * *alt* (query-string) - Data format for response.
3948    /// * *callback* (query-string) - JSONP
3949    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3950    /// * *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.
3951    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3952    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3953    /// * *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.
3954    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3955    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3956    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEnvironmentCreateCall<'a, C>
3957    where
3958        T: AsRef<str>,
3959    {
3960        self._additional_params
3961            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3962        self
3963    }
3964
3965    /// Identifies the authorization scope for the method you are building.
3966    ///
3967    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3968    /// [`Scope::CloudPlatform`].
3969    ///
3970    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3971    /// tokens for more than one scope.
3972    ///
3973    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3974    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3975    /// sufficient, a read-write scope will do as well.
3976    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEnvironmentCreateCall<'a, C>
3977    where
3978        St: AsRef<str>,
3979    {
3980        self._scopes.insert(String::from(scope.as_ref()));
3981        self
3982    }
3983    /// Identifies the authorization scope(s) for the method you are building.
3984    ///
3985    /// See [`Self::add_scope()`] for details.
3986    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEnvironmentCreateCall<'a, C>
3987    where
3988        I: IntoIterator<Item = St>,
3989        St: AsRef<str>,
3990    {
3991        self._scopes
3992            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3993        self
3994    }
3995
3996    /// Removes all scopes, and no default scope will be used either.
3997    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3998    /// for details).
3999    pub fn clear_scopes(mut self) -> ProjectLocationEnvironmentCreateCall<'a, C> {
4000        self._scopes.clear();
4001        self
4002    }
4003}
4004
4005/// Deletes a single Environment.
4006///
4007/// A builder for the *locations.environments.delete* method supported by a *project* resource.
4008/// It is not used directly, but through a [`ProjectMethods`] instance.
4009///
4010/// # Example
4011///
4012/// Instantiate a resource method builder
4013///
4014/// ```test_harness,no_run
4015/// # extern crate hyper;
4016/// # extern crate hyper_rustls;
4017/// # extern crate google_notebooks1 as notebooks1;
4018/// # async fn dox() {
4019/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4020///
4021/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4022/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4023/// #     .with_native_roots()
4024/// #     .unwrap()
4025/// #     .https_only()
4026/// #     .enable_http2()
4027/// #     .build();
4028///
4029/// # let executor = hyper_util::rt::TokioExecutor::new();
4030/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4031/// #     secret,
4032/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4033/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4034/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4035/// #     ),
4036/// # ).build().await.unwrap();
4037///
4038/// # let client = hyper_util::client::legacy::Client::builder(
4039/// #     hyper_util::rt::TokioExecutor::new()
4040/// # )
4041/// # .build(
4042/// #     hyper_rustls::HttpsConnectorBuilder::new()
4043/// #         .with_native_roots()
4044/// #         .unwrap()
4045/// #         .https_or_http()
4046/// #         .enable_http2()
4047/// #         .build()
4048/// # );
4049/// # let mut hub = AIPlatformNotebooks::new(client, auth);
4050/// // You can configure optional parameters by calling the respective setters at will, and
4051/// // execute the final call using `doit()`.
4052/// // Values shown here are possibly random and not representative !
4053/// let result = hub.projects().locations_environments_delete("name")
4054///              .doit().await;
4055/// # }
4056/// ```
4057pub struct ProjectLocationEnvironmentDeleteCall<'a, C>
4058where
4059    C: 'a,
4060{
4061    hub: &'a AIPlatformNotebooks<C>,
4062    _name: String,
4063    _delegate: Option<&'a mut dyn common::Delegate>,
4064    _additional_params: HashMap<String, String>,
4065    _scopes: BTreeSet<String>,
4066}
4067
4068impl<'a, C> common::CallBuilder for ProjectLocationEnvironmentDeleteCall<'a, C> {}
4069
4070impl<'a, C> ProjectLocationEnvironmentDeleteCall<'a, C>
4071where
4072    C: common::Connector,
4073{
4074    /// Perform the operation you have build so far.
4075    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4076        use std::borrow::Cow;
4077        use std::io::{Read, Seek};
4078
4079        use common::{url::Params, ToParts};
4080        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4081
4082        let mut dd = common::DefaultDelegate;
4083        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4084        dlg.begin(common::MethodInfo {
4085            id: "notebooks.projects.locations.environments.delete",
4086            http_method: hyper::Method::DELETE,
4087        });
4088
4089        for &field in ["alt", "name"].iter() {
4090            if self._additional_params.contains_key(field) {
4091                dlg.finished(false);
4092                return Err(common::Error::FieldClash(field));
4093            }
4094        }
4095
4096        let mut params = Params::with_capacity(3 + self._additional_params.len());
4097        params.push("name", self._name);
4098
4099        params.extend(self._additional_params.iter());
4100
4101        params.push("alt", "json");
4102        let mut url = self.hub._base_url.clone() + "v1/{+name}";
4103        if self._scopes.is_empty() {
4104            self._scopes
4105                .insert(Scope::CloudPlatform.as_ref().to_string());
4106        }
4107
4108        #[allow(clippy::single_element_loop)]
4109        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4110            url = params.uri_replacement(url, param_name, find_this, true);
4111        }
4112        {
4113            let to_remove = ["name"];
4114            params.remove_params(&to_remove);
4115        }
4116
4117        let url = params.parse_with_url(&url);
4118
4119        loop {
4120            let token = match self
4121                .hub
4122                .auth
4123                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4124                .await
4125            {
4126                Ok(token) => token,
4127                Err(e) => match dlg.token(e) {
4128                    Ok(token) => token,
4129                    Err(e) => {
4130                        dlg.finished(false);
4131                        return Err(common::Error::MissingToken(e));
4132                    }
4133                },
4134            };
4135            let mut req_result = {
4136                let client = &self.hub.client;
4137                dlg.pre_request();
4138                let mut req_builder = hyper::Request::builder()
4139                    .method(hyper::Method::DELETE)
4140                    .uri(url.as_str())
4141                    .header(USER_AGENT, self.hub._user_agent.clone());
4142
4143                if let Some(token) = token.as_ref() {
4144                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4145                }
4146
4147                let request = req_builder
4148                    .header(CONTENT_LENGTH, 0_u64)
4149                    .body(common::to_body::<String>(None));
4150
4151                client.request(request.unwrap()).await
4152            };
4153
4154            match req_result {
4155                Err(err) => {
4156                    if let common::Retry::After(d) = dlg.http_error(&err) {
4157                        sleep(d).await;
4158                        continue;
4159                    }
4160                    dlg.finished(false);
4161                    return Err(common::Error::HttpError(err));
4162                }
4163                Ok(res) => {
4164                    let (mut parts, body) = res.into_parts();
4165                    let mut body = common::Body::new(body);
4166                    if !parts.status.is_success() {
4167                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4168                        let error = serde_json::from_str(&common::to_string(&bytes));
4169                        let response = common::to_response(parts, bytes.into());
4170
4171                        if let common::Retry::After(d) =
4172                            dlg.http_failure(&response, error.as_ref().ok())
4173                        {
4174                            sleep(d).await;
4175                            continue;
4176                        }
4177
4178                        dlg.finished(false);
4179
4180                        return Err(match error {
4181                            Ok(value) => common::Error::BadRequest(value),
4182                            _ => common::Error::Failure(response),
4183                        });
4184                    }
4185                    let response = {
4186                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4187                        let encoded = common::to_string(&bytes);
4188                        match serde_json::from_str(&encoded) {
4189                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4190                            Err(error) => {
4191                                dlg.response_json_decode_error(&encoded, &error);
4192                                return Err(common::Error::JsonDecodeError(
4193                                    encoded.to_string(),
4194                                    error,
4195                                ));
4196                            }
4197                        }
4198                    };
4199
4200                    dlg.finished(true);
4201                    return Ok(response);
4202                }
4203            }
4204        }
4205    }
4206
4207    /// Required. Format: `projects/{project_id}/locations/{location}/environments/{environment_id}`
4208    ///
4209    /// Sets the *name* path property to the given value.
4210    ///
4211    /// Even though the property as already been set when instantiating this call,
4212    /// we provide this method for API completeness.
4213    pub fn name(mut self, new_value: &str) -> ProjectLocationEnvironmentDeleteCall<'a, C> {
4214        self._name = new_value.to_string();
4215        self
4216    }
4217    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4218    /// while executing the actual API request.
4219    ///
4220    /// ````text
4221    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4222    /// ````
4223    ///
4224    /// Sets the *delegate* property to the given value.
4225    pub fn delegate(
4226        mut self,
4227        new_value: &'a mut dyn common::Delegate,
4228    ) -> ProjectLocationEnvironmentDeleteCall<'a, C> {
4229        self._delegate = Some(new_value);
4230        self
4231    }
4232
4233    /// Set any additional parameter of the query string used in the request.
4234    /// It should be used to set parameters which are not yet available through their own
4235    /// setters.
4236    ///
4237    /// Please note that this method must not be used to set any of the known parameters
4238    /// which have their own setter method. If done anyway, the request will fail.
4239    ///
4240    /// # Additional Parameters
4241    ///
4242    /// * *$.xgafv* (query-string) - V1 error format.
4243    /// * *access_token* (query-string) - OAuth access token.
4244    /// * *alt* (query-string) - Data format for response.
4245    /// * *callback* (query-string) - JSONP
4246    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4247    /// * *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.
4248    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4249    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4250    /// * *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.
4251    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4252    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4253    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEnvironmentDeleteCall<'a, C>
4254    where
4255        T: AsRef<str>,
4256    {
4257        self._additional_params
4258            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4259        self
4260    }
4261
4262    /// Identifies the authorization scope for the method you are building.
4263    ///
4264    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4265    /// [`Scope::CloudPlatform`].
4266    ///
4267    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4268    /// tokens for more than one scope.
4269    ///
4270    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4271    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4272    /// sufficient, a read-write scope will do as well.
4273    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEnvironmentDeleteCall<'a, C>
4274    where
4275        St: AsRef<str>,
4276    {
4277        self._scopes.insert(String::from(scope.as_ref()));
4278        self
4279    }
4280    /// Identifies the authorization scope(s) for the method you are building.
4281    ///
4282    /// See [`Self::add_scope()`] for details.
4283    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEnvironmentDeleteCall<'a, C>
4284    where
4285        I: IntoIterator<Item = St>,
4286        St: AsRef<str>,
4287    {
4288        self._scopes
4289            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4290        self
4291    }
4292
4293    /// Removes all scopes, and no default scope will be used either.
4294    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4295    /// for details).
4296    pub fn clear_scopes(mut self) -> ProjectLocationEnvironmentDeleteCall<'a, C> {
4297        self._scopes.clear();
4298        self
4299    }
4300}
4301
4302/// Gets details of a single Environment.
4303///
4304/// A builder for the *locations.environments.get* method supported by a *project* resource.
4305/// It is not used directly, but through a [`ProjectMethods`] instance.
4306///
4307/// # Example
4308///
4309/// Instantiate a resource method builder
4310///
4311/// ```test_harness,no_run
4312/// # extern crate hyper;
4313/// # extern crate hyper_rustls;
4314/// # extern crate google_notebooks1 as notebooks1;
4315/// # async fn dox() {
4316/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4317///
4318/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4319/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4320/// #     .with_native_roots()
4321/// #     .unwrap()
4322/// #     .https_only()
4323/// #     .enable_http2()
4324/// #     .build();
4325///
4326/// # let executor = hyper_util::rt::TokioExecutor::new();
4327/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4328/// #     secret,
4329/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4330/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4331/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4332/// #     ),
4333/// # ).build().await.unwrap();
4334///
4335/// # let client = hyper_util::client::legacy::Client::builder(
4336/// #     hyper_util::rt::TokioExecutor::new()
4337/// # )
4338/// # .build(
4339/// #     hyper_rustls::HttpsConnectorBuilder::new()
4340/// #         .with_native_roots()
4341/// #         .unwrap()
4342/// #         .https_or_http()
4343/// #         .enable_http2()
4344/// #         .build()
4345/// # );
4346/// # let mut hub = AIPlatformNotebooks::new(client, auth);
4347/// // You can configure optional parameters by calling the respective setters at will, and
4348/// // execute the final call using `doit()`.
4349/// // Values shown here are possibly random and not representative !
4350/// let result = hub.projects().locations_environments_get("name")
4351///              .doit().await;
4352/// # }
4353/// ```
4354pub struct ProjectLocationEnvironmentGetCall<'a, C>
4355where
4356    C: 'a,
4357{
4358    hub: &'a AIPlatformNotebooks<C>,
4359    _name: String,
4360    _delegate: Option<&'a mut dyn common::Delegate>,
4361    _additional_params: HashMap<String, String>,
4362    _scopes: BTreeSet<String>,
4363}
4364
4365impl<'a, C> common::CallBuilder for ProjectLocationEnvironmentGetCall<'a, C> {}
4366
4367impl<'a, C> ProjectLocationEnvironmentGetCall<'a, C>
4368where
4369    C: common::Connector,
4370{
4371    /// Perform the operation you have build so far.
4372    pub async fn doit(mut self) -> common::Result<(common::Response, Environment)> {
4373        use std::borrow::Cow;
4374        use std::io::{Read, Seek};
4375
4376        use common::{url::Params, ToParts};
4377        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4378
4379        let mut dd = common::DefaultDelegate;
4380        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4381        dlg.begin(common::MethodInfo {
4382            id: "notebooks.projects.locations.environments.get",
4383            http_method: hyper::Method::GET,
4384        });
4385
4386        for &field in ["alt", "name"].iter() {
4387            if self._additional_params.contains_key(field) {
4388                dlg.finished(false);
4389                return Err(common::Error::FieldClash(field));
4390            }
4391        }
4392
4393        let mut params = Params::with_capacity(3 + self._additional_params.len());
4394        params.push("name", self._name);
4395
4396        params.extend(self._additional_params.iter());
4397
4398        params.push("alt", "json");
4399        let mut url = self.hub._base_url.clone() + "v1/{+name}";
4400        if self._scopes.is_empty() {
4401            self._scopes
4402                .insert(Scope::CloudPlatform.as_ref().to_string());
4403        }
4404
4405        #[allow(clippy::single_element_loop)]
4406        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4407            url = params.uri_replacement(url, param_name, find_this, true);
4408        }
4409        {
4410            let to_remove = ["name"];
4411            params.remove_params(&to_remove);
4412        }
4413
4414        let url = params.parse_with_url(&url);
4415
4416        loop {
4417            let token = match self
4418                .hub
4419                .auth
4420                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4421                .await
4422            {
4423                Ok(token) => token,
4424                Err(e) => match dlg.token(e) {
4425                    Ok(token) => token,
4426                    Err(e) => {
4427                        dlg.finished(false);
4428                        return Err(common::Error::MissingToken(e));
4429                    }
4430                },
4431            };
4432            let mut req_result = {
4433                let client = &self.hub.client;
4434                dlg.pre_request();
4435                let mut req_builder = hyper::Request::builder()
4436                    .method(hyper::Method::GET)
4437                    .uri(url.as_str())
4438                    .header(USER_AGENT, self.hub._user_agent.clone());
4439
4440                if let Some(token) = token.as_ref() {
4441                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4442                }
4443
4444                let request = req_builder
4445                    .header(CONTENT_LENGTH, 0_u64)
4446                    .body(common::to_body::<String>(None));
4447
4448                client.request(request.unwrap()).await
4449            };
4450
4451            match req_result {
4452                Err(err) => {
4453                    if let common::Retry::After(d) = dlg.http_error(&err) {
4454                        sleep(d).await;
4455                        continue;
4456                    }
4457                    dlg.finished(false);
4458                    return Err(common::Error::HttpError(err));
4459                }
4460                Ok(res) => {
4461                    let (mut parts, body) = res.into_parts();
4462                    let mut body = common::Body::new(body);
4463                    if !parts.status.is_success() {
4464                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4465                        let error = serde_json::from_str(&common::to_string(&bytes));
4466                        let response = common::to_response(parts, bytes.into());
4467
4468                        if let common::Retry::After(d) =
4469                            dlg.http_failure(&response, error.as_ref().ok())
4470                        {
4471                            sleep(d).await;
4472                            continue;
4473                        }
4474
4475                        dlg.finished(false);
4476
4477                        return Err(match error {
4478                            Ok(value) => common::Error::BadRequest(value),
4479                            _ => common::Error::Failure(response),
4480                        });
4481                    }
4482                    let response = {
4483                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4484                        let encoded = common::to_string(&bytes);
4485                        match serde_json::from_str(&encoded) {
4486                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4487                            Err(error) => {
4488                                dlg.response_json_decode_error(&encoded, &error);
4489                                return Err(common::Error::JsonDecodeError(
4490                                    encoded.to_string(),
4491                                    error,
4492                                ));
4493                            }
4494                        }
4495                    };
4496
4497                    dlg.finished(true);
4498                    return Ok(response);
4499                }
4500            }
4501        }
4502    }
4503
4504    /// Required. Format: `projects/{project_id}/locations/{location}/environments/{environment_id}`
4505    ///
4506    /// Sets the *name* path property to the given value.
4507    ///
4508    /// Even though the property as already been set when instantiating this call,
4509    /// we provide this method for API completeness.
4510    pub fn name(mut self, new_value: &str) -> ProjectLocationEnvironmentGetCall<'a, C> {
4511        self._name = new_value.to_string();
4512        self
4513    }
4514    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4515    /// while executing the actual API request.
4516    ///
4517    /// ````text
4518    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4519    /// ````
4520    ///
4521    /// Sets the *delegate* property to the given value.
4522    pub fn delegate(
4523        mut self,
4524        new_value: &'a mut dyn common::Delegate,
4525    ) -> ProjectLocationEnvironmentGetCall<'a, C> {
4526        self._delegate = Some(new_value);
4527        self
4528    }
4529
4530    /// Set any additional parameter of the query string used in the request.
4531    /// It should be used to set parameters which are not yet available through their own
4532    /// setters.
4533    ///
4534    /// Please note that this method must not be used to set any of the known parameters
4535    /// which have their own setter method. If done anyway, the request will fail.
4536    ///
4537    /// # Additional Parameters
4538    ///
4539    /// * *$.xgafv* (query-string) - V1 error format.
4540    /// * *access_token* (query-string) - OAuth access token.
4541    /// * *alt* (query-string) - Data format for response.
4542    /// * *callback* (query-string) - JSONP
4543    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4544    /// * *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.
4545    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4546    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4547    /// * *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.
4548    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4549    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4550    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEnvironmentGetCall<'a, C>
4551    where
4552        T: AsRef<str>,
4553    {
4554        self._additional_params
4555            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4556        self
4557    }
4558
4559    /// Identifies the authorization scope for the method you are building.
4560    ///
4561    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4562    /// [`Scope::CloudPlatform`].
4563    ///
4564    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4565    /// tokens for more than one scope.
4566    ///
4567    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4568    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4569    /// sufficient, a read-write scope will do as well.
4570    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEnvironmentGetCall<'a, C>
4571    where
4572        St: AsRef<str>,
4573    {
4574        self._scopes.insert(String::from(scope.as_ref()));
4575        self
4576    }
4577    /// Identifies the authorization scope(s) for the method you are building.
4578    ///
4579    /// See [`Self::add_scope()`] for details.
4580    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEnvironmentGetCall<'a, C>
4581    where
4582        I: IntoIterator<Item = St>,
4583        St: AsRef<str>,
4584    {
4585        self._scopes
4586            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4587        self
4588    }
4589
4590    /// Removes all scopes, and no default scope will be used either.
4591    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4592    /// for details).
4593    pub fn clear_scopes(mut self) -> ProjectLocationEnvironmentGetCall<'a, C> {
4594        self._scopes.clear();
4595        self
4596    }
4597}
4598
4599/// Lists environments in a project.
4600///
4601/// A builder for the *locations.environments.list* method supported by a *project* resource.
4602/// It is not used directly, but through a [`ProjectMethods`] instance.
4603///
4604/// # Example
4605///
4606/// Instantiate a resource method builder
4607///
4608/// ```test_harness,no_run
4609/// # extern crate hyper;
4610/// # extern crate hyper_rustls;
4611/// # extern crate google_notebooks1 as notebooks1;
4612/// # async fn dox() {
4613/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4614///
4615/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4616/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4617/// #     .with_native_roots()
4618/// #     .unwrap()
4619/// #     .https_only()
4620/// #     .enable_http2()
4621/// #     .build();
4622///
4623/// # let executor = hyper_util::rt::TokioExecutor::new();
4624/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4625/// #     secret,
4626/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4627/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4628/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4629/// #     ),
4630/// # ).build().await.unwrap();
4631///
4632/// # let client = hyper_util::client::legacy::Client::builder(
4633/// #     hyper_util::rt::TokioExecutor::new()
4634/// # )
4635/// # .build(
4636/// #     hyper_rustls::HttpsConnectorBuilder::new()
4637/// #         .with_native_roots()
4638/// #         .unwrap()
4639/// #         .https_or_http()
4640/// #         .enable_http2()
4641/// #         .build()
4642/// # );
4643/// # let mut hub = AIPlatformNotebooks::new(client, auth);
4644/// // You can configure optional parameters by calling the respective setters at will, and
4645/// // execute the final call using `doit()`.
4646/// // Values shown here are possibly random and not representative !
4647/// let result = hub.projects().locations_environments_list("parent")
4648///              .page_token("Lorem")
4649///              .page_size(-12)
4650///              .doit().await;
4651/// # }
4652/// ```
4653pub struct ProjectLocationEnvironmentListCall<'a, C>
4654where
4655    C: 'a,
4656{
4657    hub: &'a AIPlatformNotebooks<C>,
4658    _parent: String,
4659    _page_token: Option<String>,
4660    _page_size: Option<i32>,
4661    _delegate: Option<&'a mut dyn common::Delegate>,
4662    _additional_params: HashMap<String, String>,
4663    _scopes: BTreeSet<String>,
4664}
4665
4666impl<'a, C> common::CallBuilder for ProjectLocationEnvironmentListCall<'a, C> {}
4667
4668impl<'a, C> ProjectLocationEnvironmentListCall<'a, C>
4669where
4670    C: common::Connector,
4671{
4672    /// Perform the operation you have build so far.
4673    pub async fn doit(mut self) -> common::Result<(common::Response, ListEnvironmentsResponse)> {
4674        use std::borrow::Cow;
4675        use std::io::{Read, Seek};
4676
4677        use common::{url::Params, ToParts};
4678        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4679
4680        let mut dd = common::DefaultDelegate;
4681        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4682        dlg.begin(common::MethodInfo {
4683            id: "notebooks.projects.locations.environments.list",
4684            http_method: hyper::Method::GET,
4685        });
4686
4687        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
4688            if self._additional_params.contains_key(field) {
4689                dlg.finished(false);
4690                return Err(common::Error::FieldClash(field));
4691            }
4692        }
4693
4694        let mut params = Params::with_capacity(5 + self._additional_params.len());
4695        params.push("parent", self._parent);
4696        if let Some(value) = self._page_token.as_ref() {
4697            params.push("pageToken", value);
4698        }
4699        if let Some(value) = self._page_size.as_ref() {
4700            params.push("pageSize", value.to_string());
4701        }
4702
4703        params.extend(self._additional_params.iter());
4704
4705        params.push("alt", "json");
4706        let mut url = self.hub._base_url.clone() + "v1/{+parent}/environments";
4707        if self._scopes.is_empty() {
4708            self._scopes
4709                .insert(Scope::CloudPlatform.as_ref().to_string());
4710        }
4711
4712        #[allow(clippy::single_element_loop)]
4713        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4714            url = params.uri_replacement(url, param_name, find_this, true);
4715        }
4716        {
4717            let to_remove = ["parent"];
4718            params.remove_params(&to_remove);
4719        }
4720
4721        let url = params.parse_with_url(&url);
4722
4723        loop {
4724            let token = match self
4725                .hub
4726                .auth
4727                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4728                .await
4729            {
4730                Ok(token) => token,
4731                Err(e) => match dlg.token(e) {
4732                    Ok(token) => token,
4733                    Err(e) => {
4734                        dlg.finished(false);
4735                        return Err(common::Error::MissingToken(e));
4736                    }
4737                },
4738            };
4739            let mut req_result = {
4740                let client = &self.hub.client;
4741                dlg.pre_request();
4742                let mut req_builder = hyper::Request::builder()
4743                    .method(hyper::Method::GET)
4744                    .uri(url.as_str())
4745                    .header(USER_AGENT, self.hub._user_agent.clone());
4746
4747                if let Some(token) = token.as_ref() {
4748                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4749                }
4750
4751                let request = req_builder
4752                    .header(CONTENT_LENGTH, 0_u64)
4753                    .body(common::to_body::<String>(None));
4754
4755                client.request(request.unwrap()).await
4756            };
4757
4758            match req_result {
4759                Err(err) => {
4760                    if let common::Retry::After(d) = dlg.http_error(&err) {
4761                        sleep(d).await;
4762                        continue;
4763                    }
4764                    dlg.finished(false);
4765                    return Err(common::Error::HttpError(err));
4766                }
4767                Ok(res) => {
4768                    let (mut parts, body) = res.into_parts();
4769                    let mut body = common::Body::new(body);
4770                    if !parts.status.is_success() {
4771                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4772                        let error = serde_json::from_str(&common::to_string(&bytes));
4773                        let response = common::to_response(parts, bytes.into());
4774
4775                        if let common::Retry::After(d) =
4776                            dlg.http_failure(&response, error.as_ref().ok())
4777                        {
4778                            sleep(d).await;
4779                            continue;
4780                        }
4781
4782                        dlg.finished(false);
4783
4784                        return Err(match error {
4785                            Ok(value) => common::Error::BadRequest(value),
4786                            _ => common::Error::Failure(response),
4787                        });
4788                    }
4789                    let response = {
4790                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4791                        let encoded = common::to_string(&bytes);
4792                        match serde_json::from_str(&encoded) {
4793                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4794                            Err(error) => {
4795                                dlg.response_json_decode_error(&encoded, &error);
4796                                return Err(common::Error::JsonDecodeError(
4797                                    encoded.to_string(),
4798                                    error,
4799                                ));
4800                            }
4801                        }
4802                    };
4803
4804                    dlg.finished(true);
4805                    return Ok(response);
4806                }
4807            }
4808        }
4809    }
4810
4811    /// Required. Format: `projects/{project_id}/locations/{location}`
4812    ///
4813    /// Sets the *parent* path property to the given value.
4814    ///
4815    /// Even though the property as already been set when instantiating this call,
4816    /// we provide this method for API completeness.
4817    pub fn parent(mut self, new_value: &str) -> ProjectLocationEnvironmentListCall<'a, C> {
4818        self._parent = new_value.to_string();
4819        self
4820    }
4821    /// A previous returned page token that can be used to continue listing from the last result.
4822    ///
4823    /// Sets the *page token* query property to the given value.
4824    pub fn page_token(mut self, new_value: &str) -> ProjectLocationEnvironmentListCall<'a, C> {
4825        self._page_token = Some(new_value.to_string());
4826        self
4827    }
4828    /// Maximum return size of the list call.
4829    ///
4830    /// Sets the *page size* query property to the given value.
4831    pub fn page_size(mut self, new_value: i32) -> ProjectLocationEnvironmentListCall<'a, C> {
4832        self._page_size = Some(new_value);
4833        self
4834    }
4835    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4836    /// while executing the actual API request.
4837    ///
4838    /// ````text
4839    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4840    /// ````
4841    ///
4842    /// Sets the *delegate* property to the given value.
4843    pub fn delegate(
4844        mut self,
4845        new_value: &'a mut dyn common::Delegate,
4846    ) -> ProjectLocationEnvironmentListCall<'a, C> {
4847        self._delegate = Some(new_value);
4848        self
4849    }
4850
4851    /// Set any additional parameter of the query string used in the request.
4852    /// It should be used to set parameters which are not yet available through their own
4853    /// setters.
4854    ///
4855    /// Please note that this method must not be used to set any of the known parameters
4856    /// which have their own setter method. If done anyway, the request will fail.
4857    ///
4858    /// # Additional Parameters
4859    ///
4860    /// * *$.xgafv* (query-string) - V1 error format.
4861    /// * *access_token* (query-string) - OAuth access token.
4862    /// * *alt* (query-string) - Data format for response.
4863    /// * *callback* (query-string) - JSONP
4864    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4865    /// * *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.
4866    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4867    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4868    /// * *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.
4869    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4870    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4871    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEnvironmentListCall<'a, C>
4872    where
4873        T: AsRef<str>,
4874    {
4875        self._additional_params
4876            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4877        self
4878    }
4879
4880    /// Identifies the authorization scope for the method you are building.
4881    ///
4882    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4883    /// [`Scope::CloudPlatform`].
4884    ///
4885    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4886    /// tokens for more than one scope.
4887    ///
4888    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4889    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4890    /// sufficient, a read-write scope will do as well.
4891    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEnvironmentListCall<'a, C>
4892    where
4893        St: AsRef<str>,
4894    {
4895        self._scopes.insert(String::from(scope.as_ref()));
4896        self
4897    }
4898    /// Identifies the authorization scope(s) for the method you are building.
4899    ///
4900    /// See [`Self::add_scope()`] for details.
4901    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEnvironmentListCall<'a, C>
4902    where
4903        I: IntoIterator<Item = St>,
4904        St: AsRef<str>,
4905    {
4906        self._scopes
4907            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4908        self
4909    }
4910
4911    /// Removes all scopes, and no default scope will be used either.
4912    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4913    /// for details).
4914    pub fn clear_scopes(mut self) -> ProjectLocationEnvironmentListCall<'a, C> {
4915        self._scopes.clear();
4916        self
4917    }
4918}
4919
4920/// Creates a new Execution in a given project and location.
4921///
4922/// A builder for the *locations.executions.create* method supported by a *project* resource.
4923/// It is not used directly, but through a [`ProjectMethods`] instance.
4924///
4925/// # Example
4926///
4927/// Instantiate a resource method builder
4928///
4929/// ```test_harness,no_run
4930/// # extern crate hyper;
4931/// # extern crate hyper_rustls;
4932/// # extern crate google_notebooks1 as notebooks1;
4933/// use notebooks1::api::Execution;
4934/// # async fn dox() {
4935/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4936///
4937/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4938/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4939/// #     .with_native_roots()
4940/// #     .unwrap()
4941/// #     .https_only()
4942/// #     .enable_http2()
4943/// #     .build();
4944///
4945/// # let executor = hyper_util::rt::TokioExecutor::new();
4946/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4947/// #     secret,
4948/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4949/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4950/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4951/// #     ),
4952/// # ).build().await.unwrap();
4953///
4954/// # let client = hyper_util::client::legacy::Client::builder(
4955/// #     hyper_util::rt::TokioExecutor::new()
4956/// # )
4957/// # .build(
4958/// #     hyper_rustls::HttpsConnectorBuilder::new()
4959/// #         .with_native_roots()
4960/// #         .unwrap()
4961/// #         .https_or_http()
4962/// #         .enable_http2()
4963/// #         .build()
4964/// # );
4965/// # let mut hub = AIPlatformNotebooks::new(client, auth);
4966/// // As the method needs a request, you would usually fill it with the desired information
4967/// // into the respective structure. Some of the parts shown here might not be applicable !
4968/// // Values shown here are possibly random and not representative !
4969/// let mut req = Execution::default();
4970///
4971/// // You can configure optional parameters by calling the respective setters at will, and
4972/// // execute the final call using `doit()`.
4973/// // Values shown here are possibly random and not representative !
4974/// let result = hub.projects().locations_executions_create(req, "parent")
4975///              .execution_id("dolor")
4976///              .doit().await;
4977/// # }
4978/// ```
4979pub struct ProjectLocationExecutionCreateCall<'a, C>
4980where
4981    C: 'a,
4982{
4983    hub: &'a AIPlatformNotebooks<C>,
4984    _request: Execution,
4985    _parent: String,
4986    _execution_id: Option<String>,
4987    _delegate: Option<&'a mut dyn common::Delegate>,
4988    _additional_params: HashMap<String, String>,
4989    _scopes: BTreeSet<String>,
4990}
4991
4992impl<'a, C> common::CallBuilder for ProjectLocationExecutionCreateCall<'a, C> {}
4993
4994impl<'a, C> ProjectLocationExecutionCreateCall<'a, C>
4995where
4996    C: common::Connector,
4997{
4998    /// Perform the operation you have build so far.
4999    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5000        use std::borrow::Cow;
5001        use std::io::{Read, Seek};
5002
5003        use common::{url::Params, ToParts};
5004        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5005
5006        let mut dd = common::DefaultDelegate;
5007        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5008        dlg.begin(common::MethodInfo {
5009            id: "notebooks.projects.locations.executions.create",
5010            http_method: hyper::Method::POST,
5011        });
5012
5013        for &field in ["alt", "parent", "executionId"].iter() {
5014            if self._additional_params.contains_key(field) {
5015                dlg.finished(false);
5016                return Err(common::Error::FieldClash(field));
5017            }
5018        }
5019
5020        let mut params = Params::with_capacity(5 + self._additional_params.len());
5021        params.push("parent", self._parent);
5022        if let Some(value) = self._execution_id.as_ref() {
5023            params.push("executionId", value);
5024        }
5025
5026        params.extend(self._additional_params.iter());
5027
5028        params.push("alt", "json");
5029        let mut url = self.hub._base_url.clone() + "v1/{+parent}/executions";
5030        if self._scopes.is_empty() {
5031            self._scopes
5032                .insert(Scope::CloudPlatform.as_ref().to_string());
5033        }
5034
5035        #[allow(clippy::single_element_loop)]
5036        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5037            url = params.uri_replacement(url, param_name, find_this, true);
5038        }
5039        {
5040            let to_remove = ["parent"];
5041            params.remove_params(&to_remove);
5042        }
5043
5044        let url = params.parse_with_url(&url);
5045
5046        let mut json_mime_type = mime::APPLICATION_JSON;
5047        let mut request_value_reader = {
5048            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5049            common::remove_json_null_values(&mut value);
5050            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5051            serde_json::to_writer(&mut dst, &value).unwrap();
5052            dst
5053        };
5054        let request_size = request_value_reader
5055            .seek(std::io::SeekFrom::End(0))
5056            .unwrap();
5057        request_value_reader
5058            .seek(std::io::SeekFrom::Start(0))
5059            .unwrap();
5060
5061        loop {
5062            let token = match self
5063                .hub
5064                .auth
5065                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5066                .await
5067            {
5068                Ok(token) => token,
5069                Err(e) => match dlg.token(e) {
5070                    Ok(token) => token,
5071                    Err(e) => {
5072                        dlg.finished(false);
5073                        return Err(common::Error::MissingToken(e));
5074                    }
5075                },
5076            };
5077            request_value_reader
5078                .seek(std::io::SeekFrom::Start(0))
5079                .unwrap();
5080            let mut req_result = {
5081                let client = &self.hub.client;
5082                dlg.pre_request();
5083                let mut req_builder = hyper::Request::builder()
5084                    .method(hyper::Method::POST)
5085                    .uri(url.as_str())
5086                    .header(USER_AGENT, self.hub._user_agent.clone());
5087
5088                if let Some(token) = token.as_ref() {
5089                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5090                }
5091
5092                let request = req_builder
5093                    .header(CONTENT_TYPE, json_mime_type.to_string())
5094                    .header(CONTENT_LENGTH, request_size as u64)
5095                    .body(common::to_body(
5096                        request_value_reader.get_ref().clone().into(),
5097                    ));
5098
5099                client.request(request.unwrap()).await
5100            };
5101
5102            match req_result {
5103                Err(err) => {
5104                    if let common::Retry::After(d) = dlg.http_error(&err) {
5105                        sleep(d).await;
5106                        continue;
5107                    }
5108                    dlg.finished(false);
5109                    return Err(common::Error::HttpError(err));
5110                }
5111                Ok(res) => {
5112                    let (mut parts, body) = res.into_parts();
5113                    let mut body = common::Body::new(body);
5114                    if !parts.status.is_success() {
5115                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5116                        let error = serde_json::from_str(&common::to_string(&bytes));
5117                        let response = common::to_response(parts, bytes.into());
5118
5119                        if let common::Retry::After(d) =
5120                            dlg.http_failure(&response, error.as_ref().ok())
5121                        {
5122                            sleep(d).await;
5123                            continue;
5124                        }
5125
5126                        dlg.finished(false);
5127
5128                        return Err(match error {
5129                            Ok(value) => common::Error::BadRequest(value),
5130                            _ => common::Error::Failure(response),
5131                        });
5132                    }
5133                    let response = {
5134                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5135                        let encoded = common::to_string(&bytes);
5136                        match serde_json::from_str(&encoded) {
5137                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5138                            Err(error) => {
5139                                dlg.response_json_decode_error(&encoded, &error);
5140                                return Err(common::Error::JsonDecodeError(
5141                                    encoded.to_string(),
5142                                    error,
5143                                ));
5144                            }
5145                        }
5146                    };
5147
5148                    dlg.finished(true);
5149                    return Ok(response);
5150                }
5151            }
5152        }
5153    }
5154
5155    ///
5156    /// Sets the *request* property to the given value.
5157    ///
5158    /// Even though the property as already been set when instantiating this call,
5159    /// we provide this method for API completeness.
5160    pub fn request(mut self, new_value: Execution) -> ProjectLocationExecutionCreateCall<'a, C> {
5161        self._request = new_value;
5162        self
5163    }
5164    /// Required. Format: `parent=projects/{project_id}/locations/{location}`
5165    ///
5166    /// Sets the *parent* path property to the given value.
5167    ///
5168    /// Even though the property as already been set when instantiating this call,
5169    /// we provide this method for API completeness.
5170    pub fn parent(mut self, new_value: &str) -> ProjectLocationExecutionCreateCall<'a, C> {
5171        self._parent = new_value.to_string();
5172        self
5173    }
5174    /// Required. User-defined unique ID of this execution.
5175    ///
5176    /// Sets the *execution id* query property to the given value.
5177    pub fn execution_id(mut self, new_value: &str) -> ProjectLocationExecutionCreateCall<'a, C> {
5178        self._execution_id = Some(new_value.to_string());
5179        self
5180    }
5181    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5182    /// while executing the actual API request.
5183    ///
5184    /// ````text
5185    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5186    /// ````
5187    ///
5188    /// Sets the *delegate* property to the given value.
5189    pub fn delegate(
5190        mut self,
5191        new_value: &'a mut dyn common::Delegate,
5192    ) -> ProjectLocationExecutionCreateCall<'a, C> {
5193        self._delegate = Some(new_value);
5194        self
5195    }
5196
5197    /// Set any additional parameter of the query string used in the request.
5198    /// It should be used to set parameters which are not yet available through their own
5199    /// setters.
5200    ///
5201    /// Please note that this method must not be used to set any of the known parameters
5202    /// which have their own setter method. If done anyway, the request will fail.
5203    ///
5204    /// # Additional Parameters
5205    ///
5206    /// * *$.xgafv* (query-string) - V1 error format.
5207    /// * *access_token* (query-string) - OAuth access token.
5208    /// * *alt* (query-string) - Data format for response.
5209    /// * *callback* (query-string) - JSONP
5210    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5211    /// * *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.
5212    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5213    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5214    /// * *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.
5215    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5216    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5217    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationExecutionCreateCall<'a, C>
5218    where
5219        T: AsRef<str>,
5220    {
5221        self._additional_params
5222            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5223        self
5224    }
5225
5226    /// Identifies the authorization scope for the method you are building.
5227    ///
5228    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5229    /// [`Scope::CloudPlatform`].
5230    ///
5231    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5232    /// tokens for more than one scope.
5233    ///
5234    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5235    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5236    /// sufficient, a read-write scope will do as well.
5237    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationExecutionCreateCall<'a, C>
5238    where
5239        St: AsRef<str>,
5240    {
5241        self._scopes.insert(String::from(scope.as_ref()));
5242        self
5243    }
5244    /// Identifies the authorization scope(s) for the method you are building.
5245    ///
5246    /// See [`Self::add_scope()`] for details.
5247    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationExecutionCreateCall<'a, C>
5248    where
5249        I: IntoIterator<Item = St>,
5250        St: AsRef<str>,
5251    {
5252        self._scopes
5253            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5254        self
5255    }
5256
5257    /// Removes all scopes, and no default scope will be used either.
5258    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5259    /// for details).
5260    pub fn clear_scopes(mut self) -> ProjectLocationExecutionCreateCall<'a, C> {
5261        self._scopes.clear();
5262        self
5263    }
5264}
5265
5266/// Deletes execution
5267///
5268/// A builder for the *locations.executions.delete* method supported by a *project* resource.
5269/// It is not used directly, but through a [`ProjectMethods`] instance.
5270///
5271/// # Example
5272///
5273/// Instantiate a resource method builder
5274///
5275/// ```test_harness,no_run
5276/// # extern crate hyper;
5277/// # extern crate hyper_rustls;
5278/// # extern crate google_notebooks1 as notebooks1;
5279/// # async fn dox() {
5280/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5281///
5282/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5283/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5284/// #     .with_native_roots()
5285/// #     .unwrap()
5286/// #     .https_only()
5287/// #     .enable_http2()
5288/// #     .build();
5289///
5290/// # let executor = hyper_util::rt::TokioExecutor::new();
5291/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5292/// #     secret,
5293/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5294/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5295/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5296/// #     ),
5297/// # ).build().await.unwrap();
5298///
5299/// # let client = hyper_util::client::legacy::Client::builder(
5300/// #     hyper_util::rt::TokioExecutor::new()
5301/// # )
5302/// # .build(
5303/// #     hyper_rustls::HttpsConnectorBuilder::new()
5304/// #         .with_native_roots()
5305/// #         .unwrap()
5306/// #         .https_or_http()
5307/// #         .enable_http2()
5308/// #         .build()
5309/// # );
5310/// # let mut hub = AIPlatformNotebooks::new(client, auth);
5311/// // You can configure optional parameters by calling the respective setters at will, and
5312/// // execute the final call using `doit()`.
5313/// // Values shown here are possibly random and not representative !
5314/// let result = hub.projects().locations_executions_delete("name")
5315///              .doit().await;
5316/// # }
5317/// ```
5318pub struct ProjectLocationExecutionDeleteCall<'a, C>
5319where
5320    C: 'a,
5321{
5322    hub: &'a AIPlatformNotebooks<C>,
5323    _name: String,
5324    _delegate: Option<&'a mut dyn common::Delegate>,
5325    _additional_params: HashMap<String, String>,
5326    _scopes: BTreeSet<String>,
5327}
5328
5329impl<'a, C> common::CallBuilder for ProjectLocationExecutionDeleteCall<'a, C> {}
5330
5331impl<'a, C> ProjectLocationExecutionDeleteCall<'a, C>
5332where
5333    C: common::Connector,
5334{
5335    /// Perform the operation you have build so far.
5336    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5337        use std::borrow::Cow;
5338        use std::io::{Read, Seek};
5339
5340        use common::{url::Params, ToParts};
5341        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5342
5343        let mut dd = common::DefaultDelegate;
5344        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5345        dlg.begin(common::MethodInfo {
5346            id: "notebooks.projects.locations.executions.delete",
5347            http_method: hyper::Method::DELETE,
5348        });
5349
5350        for &field in ["alt", "name"].iter() {
5351            if self._additional_params.contains_key(field) {
5352                dlg.finished(false);
5353                return Err(common::Error::FieldClash(field));
5354            }
5355        }
5356
5357        let mut params = Params::with_capacity(3 + self._additional_params.len());
5358        params.push("name", self._name);
5359
5360        params.extend(self._additional_params.iter());
5361
5362        params.push("alt", "json");
5363        let mut url = self.hub._base_url.clone() + "v1/{+name}";
5364        if self._scopes.is_empty() {
5365            self._scopes
5366                .insert(Scope::CloudPlatform.as_ref().to_string());
5367        }
5368
5369        #[allow(clippy::single_element_loop)]
5370        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5371            url = params.uri_replacement(url, param_name, find_this, true);
5372        }
5373        {
5374            let to_remove = ["name"];
5375            params.remove_params(&to_remove);
5376        }
5377
5378        let url = params.parse_with_url(&url);
5379
5380        loop {
5381            let token = match self
5382                .hub
5383                .auth
5384                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5385                .await
5386            {
5387                Ok(token) => token,
5388                Err(e) => match dlg.token(e) {
5389                    Ok(token) => token,
5390                    Err(e) => {
5391                        dlg.finished(false);
5392                        return Err(common::Error::MissingToken(e));
5393                    }
5394                },
5395            };
5396            let mut req_result = {
5397                let client = &self.hub.client;
5398                dlg.pre_request();
5399                let mut req_builder = hyper::Request::builder()
5400                    .method(hyper::Method::DELETE)
5401                    .uri(url.as_str())
5402                    .header(USER_AGENT, self.hub._user_agent.clone());
5403
5404                if let Some(token) = token.as_ref() {
5405                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5406                }
5407
5408                let request = req_builder
5409                    .header(CONTENT_LENGTH, 0_u64)
5410                    .body(common::to_body::<String>(None));
5411
5412                client.request(request.unwrap()).await
5413            };
5414
5415            match req_result {
5416                Err(err) => {
5417                    if let common::Retry::After(d) = dlg.http_error(&err) {
5418                        sleep(d).await;
5419                        continue;
5420                    }
5421                    dlg.finished(false);
5422                    return Err(common::Error::HttpError(err));
5423                }
5424                Ok(res) => {
5425                    let (mut parts, body) = res.into_parts();
5426                    let mut body = common::Body::new(body);
5427                    if !parts.status.is_success() {
5428                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5429                        let error = serde_json::from_str(&common::to_string(&bytes));
5430                        let response = common::to_response(parts, bytes.into());
5431
5432                        if let common::Retry::After(d) =
5433                            dlg.http_failure(&response, error.as_ref().ok())
5434                        {
5435                            sleep(d).await;
5436                            continue;
5437                        }
5438
5439                        dlg.finished(false);
5440
5441                        return Err(match error {
5442                            Ok(value) => common::Error::BadRequest(value),
5443                            _ => common::Error::Failure(response),
5444                        });
5445                    }
5446                    let response = {
5447                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5448                        let encoded = common::to_string(&bytes);
5449                        match serde_json::from_str(&encoded) {
5450                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5451                            Err(error) => {
5452                                dlg.response_json_decode_error(&encoded, &error);
5453                                return Err(common::Error::JsonDecodeError(
5454                                    encoded.to_string(),
5455                                    error,
5456                                ));
5457                            }
5458                        }
5459                    };
5460
5461                    dlg.finished(true);
5462                    return Ok(response);
5463                }
5464            }
5465        }
5466    }
5467
5468    /// Required. Format: `projects/{project_id}/locations/{location}/executions/{execution_id}`
5469    ///
5470    /// Sets the *name* path property to the given value.
5471    ///
5472    /// Even though the property as already been set when instantiating this call,
5473    /// we provide this method for API completeness.
5474    pub fn name(mut self, new_value: &str) -> ProjectLocationExecutionDeleteCall<'a, C> {
5475        self._name = new_value.to_string();
5476        self
5477    }
5478    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5479    /// while executing the actual API request.
5480    ///
5481    /// ````text
5482    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5483    /// ````
5484    ///
5485    /// Sets the *delegate* property to the given value.
5486    pub fn delegate(
5487        mut self,
5488        new_value: &'a mut dyn common::Delegate,
5489    ) -> ProjectLocationExecutionDeleteCall<'a, C> {
5490        self._delegate = Some(new_value);
5491        self
5492    }
5493
5494    /// Set any additional parameter of the query string used in the request.
5495    /// It should be used to set parameters which are not yet available through their own
5496    /// setters.
5497    ///
5498    /// Please note that this method must not be used to set any of the known parameters
5499    /// which have their own setter method. If done anyway, the request will fail.
5500    ///
5501    /// # Additional Parameters
5502    ///
5503    /// * *$.xgafv* (query-string) - V1 error format.
5504    /// * *access_token* (query-string) - OAuth access token.
5505    /// * *alt* (query-string) - Data format for response.
5506    /// * *callback* (query-string) - JSONP
5507    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5508    /// * *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.
5509    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5510    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5511    /// * *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.
5512    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5513    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5514    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationExecutionDeleteCall<'a, C>
5515    where
5516        T: AsRef<str>,
5517    {
5518        self._additional_params
5519            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5520        self
5521    }
5522
5523    /// Identifies the authorization scope for the method you are building.
5524    ///
5525    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5526    /// [`Scope::CloudPlatform`].
5527    ///
5528    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5529    /// tokens for more than one scope.
5530    ///
5531    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5532    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5533    /// sufficient, a read-write scope will do as well.
5534    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationExecutionDeleteCall<'a, C>
5535    where
5536        St: AsRef<str>,
5537    {
5538        self._scopes.insert(String::from(scope.as_ref()));
5539        self
5540    }
5541    /// Identifies the authorization scope(s) for the method you are building.
5542    ///
5543    /// See [`Self::add_scope()`] for details.
5544    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationExecutionDeleteCall<'a, C>
5545    where
5546        I: IntoIterator<Item = St>,
5547        St: AsRef<str>,
5548    {
5549        self._scopes
5550            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5551        self
5552    }
5553
5554    /// Removes all scopes, and no default scope will be used either.
5555    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5556    /// for details).
5557    pub fn clear_scopes(mut self) -> ProjectLocationExecutionDeleteCall<'a, C> {
5558        self._scopes.clear();
5559        self
5560    }
5561}
5562
5563/// Gets details of executions
5564///
5565/// A builder for the *locations.executions.get* method supported by a *project* resource.
5566/// It is not used directly, but through a [`ProjectMethods`] instance.
5567///
5568/// # Example
5569///
5570/// Instantiate a resource method builder
5571///
5572/// ```test_harness,no_run
5573/// # extern crate hyper;
5574/// # extern crate hyper_rustls;
5575/// # extern crate google_notebooks1 as notebooks1;
5576/// # async fn dox() {
5577/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5578///
5579/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5580/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5581/// #     .with_native_roots()
5582/// #     .unwrap()
5583/// #     .https_only()
5584/// #     .enable_http2()
5585/// #     .build();
5586///
5587/// # let executor = hyper_util::rt::TokioExecutor::new();
5588/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5589/// #     secret,
5590/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5591/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5592/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5593/// #     ),
5594/// # ).build().await.unwrap();
5595///
5596/// # let client = hyper_util::client::legacy::Client::builder(
5597/// #     hyper_util::rt::TokioExecutor::new()
5598/// # )
5599/// # .build(
5600/// #     hyper_rustls::HttpsConnectorBuilder::new()
5601/// #         .with_native_roots()
5602/// #         .unwrap()
5603/// #         .https_or_http()
5604/// #         .enable_http2()
5605/// #         .build()
5606/// # );
5607/// # let mut hub = AIPlatformNotebooks::new(client, auth);
5608/// // You can configure optional parameters by calling the respective setters at will, and
5609/// // execute the final call using `doit()`.
5610/// // Values shown here are possibly random and not representative !
5611/// let result = hub.projects().locations_executions_get("name")
5612///              .doit().await;
5613/// # }
5614/// ```
5615pub struct ProjectLocationExecutionGetCall<'a, C>
5616where
5617    C: 'a,
5618{
5619    hub: &'a AIPlatformNotebooks<C>,
5620    _name: String,
5621    _delegate: Option<&'a mut dyn common::Delegate>,
5622    _additional_params: HashMap<String, String>,
5623    _scopes: BTreeSet<String>,
5624}
5625
5626impl<'a, C> common::CallBuilder for ProjectLocationExecutionGetCall<'a, C> {}
5627
5628impl<'a, C> ProjectLocationExecutionGetCall<'a, C>
5629where
5630    C: common::Connector,
5631{
5632    /// Perform the operation you have build so far.
5633    pub async fn doit(mut self) -> common::Result<(common::Response, Execution)> {
5634        use std::borrow::Cow;
5635        use std::io::{Read, Seek};
5636
5637        use common::{url::Params, ToParts};
5638        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5639
5640        let mut dd = common::DefaultDelegate;
5641        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5642        dlg.begin(common::MethodInfo {
5643            id: "notebooks.projects.locations.executions.get",
5644            http_method: hyper::Method::GET,
5645        });
5646
5647        for &field in ["alt", "name"].iter() {
5648            if self._additional_params.contains_key(field) {
5649                dlg.finished(false);
5650                return Err(common::Error::FieldClash(field));
5651            }
5652        }
5653
5654        let mut params = Params::with_capacity(3 + self._additional_params.len());
5655        params.push("name", self._name);
5656
5657        params.extend(self._additional_params.iter());
5658
5659        params.push("alt", "json");
5660        let mut url = self.hub._base_url.clone() + "v1/{+name}";
5661        if self._scopes.is_empty() {
5662            self._scopes
5663                .insert(Scope::CloudPlatform.as_ref().to_string());
5664        }
5665
5666        #[allow(clippy::single_element_loop)]
5667        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5668            url = params.uri_replacement(url, param_name, find_this, true);
5669        }
5670        {
5671            let to_remove = ["name"];
5672            params.remove_params(&to_remove);
5673        }
5674
5675        let url = params.parse_with_url(&url);
5676
5677        loop {
5678            let token = match self
5679                .hub
5680                .auth
5681                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5682                .await
5683            {
5684                Ok(token) => token,
5685                Err(e) => match dlg.token(e) {
5686                    Ok(token) => token,
5687                    Err(e) => {
5688                        dlg.finished(false);
5689                        return Err(common::Error::MissingToken(e));
5690                    }
5691                },
5692            };
5693            let mut req_result = {
5694                let client = &self.hub.client;
5695                dlg.pre_request();
5696                let mut req_builder = hyper::Request::builder()
5697                    .method(hyper::Method::GET)
5698                    .uri(url.as_str())
5699                    .header(USER_AGENT, self.hub._user_agent.clone());
5700
5701                if let Some(token) = token.as_ref() {
5702                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5703                }
5704
5705                let request = req_builder
5706                    .header(CONTENT_LENGTH, 0_u64)
5707                    .body(common::to_body::<String>(None));
5708
5709                client.request(request.unwrap()).await
5710            };
5711
5712            match req_result {
5713                Err(err) => {
5714                    if let common::Retry::After(d) = dlg.http_error(&err) {
5715                        sleep(d).await;
5716                        continue;
5717                    }
5718                    dlg.finished(false);
5719                    return Err(common::Error::HttpError(err));
5720                }
5721                Ok(res) => {
5722                    let (mut parts, body) = res.into_parts();
5723                    let mut body = common::Body::new(body);
5724                    if !parts.status.is_success() {
5725                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5726                        let error = serde_json::from_str(&common::to_string(&bytes));
5727                        let response = common::to_response(parts, bytes.into());
5728
5729                        if let common::Retry::After(d) =
5730                            dlg.http_failure(&response, error.as_ref().ok())
5731                        {
5732                            sleep(d).await;
5733                            continue;
5734                        }
5735
5736                        dlg.finished(false);
5737
5738                        return Err(match error {
5739                            Ok(value) => common::Error::BadRequest(value),
5740                            _ => common::Error::Failure(response),
5741                        });
5742                    }
5743                    let response = {
5744                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5745                        let encoded = common::to_string(&bytes);
5746                        match serde_json::from_str(&encoded) {
5747                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5748                            Err(error) => {
5749                                dlg.response_json_decode_error(&encoded, &error);
5750                                return Err(common::Error::JsonDecodeError(
5751                                    encoded.to_string(),
5752                                    error,
5753                                ));
5754                            }
5755                        }
5756                    };
5757
5758                    dlg.finished(true);
5759                    return Ok(response);
5760                }
5761            }
5762        }
5763    }
5764
5765    /// Required. Format: `projects/{project_id}/locations/{location}/executions/{execution_id}`
5766    ///
5767    /// Sets the *name* path property to the given value.
5768    ///
5769    /// Even though the property as already been set when instantiating this call,
5770    /// we provide this method for API completeness.
5771    pub fn name(mut self, new_value: &str) -> ProjectLocationExecutionGetCall<'a, C> {
5772        self._name = new_value.to_string();
5773        self
5774    }
5775    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5776    /// while executing the actual API request.
5777    ///
5778    /// ````text
5779    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5780    /// ````
5781    ///
5782    /// Sets the *delegate* property to the given value.
5783    pub fn delegate(
5784        mut self,
5785        new_value: &'a mut dyn common::Delegate,
5786    ) -> ProjectLocationExecutionGetCall<'a, C> {
5787        self._delegate = Some(new_value);
5788        self
5789    }
5790
5791    /// Set any additional parameter of the query string used in the request.
5792    /// It should be used to set parameters which are not yet available through their own
5793    /// setters.
5794    ///
5795    /// Please note that this method must not be used to set any of the known parameters
5796    /// which have their own setter method. If done anyway, the request will fail.
5797    ///
5798    /// # Additional Parameters
5799    ///
5800    /// * *$.xgafv* (query-string) - V1 error format.
5801    /// * *access_token* (query-string) - OAuth access token.
5802    /// * *alt* (query-string) - Data format for response.
5803    /// * *callback* (query-string) - JSONP
5804    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5805    /// * *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.
5806    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5807    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5808    /// * *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.
5809    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5810    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5811    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationExecutionGetCall<'a, C>
5812    where
5813        T: AsRef<str>,
5814    {
5815        self._additional_params
5816            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5817        self
5818    }
5819
5820    /// Identifies the authorization scope for the method you are building.
5821    ///
5822    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5823    /// [`Scope::CloudPlatform`].
5824    ///
5825    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5826    /// tokens for more than one scope.
5827    ///
5828    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5829    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5830    /// sufficient, a read-write scope will do as well.
5831    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationExecutionGetCall<'a, C>
5832    where
5833        St: AsRef<str>,
5834    {
5835        self._scopes.insert(String::from(scope.as_ref()));
5836        self
5837    }
5838    /// Identifies the authorization scope(s) for the method you are building.
5839    ///
5840    /// See [`Self::add_scope()`] for details.
5841    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationExecutionGetCall<'a, C>
5842    where
5843        I: IntoIterator<Item = St>,
5844        St: AsRef<str>,
5845    {
5846        self._scopes
5847            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5848        self
5849    }
5850
5851    /// Removes all scopes, and no default scope will be used either.
5852    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5853    /// for details).
5854    pub fn clear_scopes(mut self) -> ProjectLocationExecutionGetCall<'a, C> {
5855        self._scopes.clear();
5856        self
5857    }
5858}
5859
5860/// Lists executions in a given project and location
5861///
5862/// A builder for the *locations.executions.list* method supported by a *project* resource.
5863/// It is not used directly, but through a [`ProjectMethods`] instance.
5864///
5865/// # Example
5866///
5867/// Instantiate a resource method builder
5868///
5869/// ```test_harness,no_run
5870/// # extern crate hyper;
5871/// # extern crate hyper_rustls;
5872/// # extern crate google_notebooks1 as notebooks1;
5873/// # async fn dox() {
5874/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5875///
5876/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5877/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5878/// #     .with_native_roots()
5879/// #     .unwrap()
5880/// #     .https_only()
5881/// #     .enable_http2()
5882/// #     .build();
5883///
5884/// # let executor = hyper_util::rt::TokioExecutor::new();
5885/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5886/// #     secret,
5887/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5888/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5889/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5890/// #     ),
5891/// # ).build().await.unwrap();
5892///
5893/// # let client = hyper_util::client::legacy::Client::builder(
5894/// #     hyper_util::rt::TokioExecutor::new()
5895/// # )
5896/// # .build(
5897/// #     hyper_rustls::HttpsConnectorBuilder::new()
5898/// #         .with_native_roots()
5899/// #         .unwrap()
5900/// #         .https_or_http()
5901/// #         .enable_http2()
5902/// #         .build()
5903/// # );
5904/// # let mut hub = AIPlatformNotebooks::new(client, auth);
5905/// // You can configure optional parameters by calling the respective setters at will, and
5906/// // execute the final call using `doit()`.
5907/// // Values shown here are possibly random and not representative !
5908/// let result = hub.projects().locations_executions_list("parent")
5909///              .page_token("amet")
5910///              .page_size(-20)
5911///              .order_by("ipsum")
5912///              .filter("sed")
5913///              .doit().await;
5914/// # }
5915/// ```
5916pub struct ProjectLocationExecutionListCall<'a, C>
5917where
5918    C: 'a,
5919{
5920    hub: &'a AIPlatformNotebooks<C>,
5921    _parent: String,
5922    _page_token: Option<String>,
5923    _page_size: Option<i32>,
5924    _order_by: Option<String>,
5925    _filter: Option<String>,
5926    _delegate: Option<&'a mut dyn common::Delegate>,
5927    _additional_params: HashMap<String, String>,
5928    _scopes: BTreeSet<String>,
5929}
5930
5931impl<'a, C> common::CallBuilder for ProjectLocationExecutionListCall<'a, C> {}
5932
5933impl<'a, C> ProjectLocationExecutionListCall<'a, C>
5934where
5935    C: common::Connector,
5936{
5937    /// Perform the operation you have build so far.
5938    pub async fn doit(mut self) -> common::Result<(common::Response, ListExecutionsResponse)> {
5939        use std::borrow::Cow;
5940        use std::io::{Read, Seek};
5941
5942        use common::{url::Params, ToParts};
5943        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5944
5945        let mut dd = common::DefaultDelegate;
5946        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5947        dlg.begin(common::MethodInfo {
5948            id: "notebooks.projects.locations.executions.list",
5949            http_method: hyper::Method::GET,
5950        });
5951
5952        for &field in [
5953            "alt",
5954            "parent",
5955            "pageToken",
5956            "pageSize",
5957            "orderBy",
5958            "filter",
5959        ]
5960        .iter()
5961        {
5962            if self._additional_params.contains_key(field) {
5963                dlg.finished(false);
5964                return Err(common::Error::FieldClash(field));
5965            }
5966        }
5967
5968        let mut params = Params::with_capacity(7 + self._additional_params.len());
5969        params.push("parent", self._parent);
5970        if let Some(value) = self._page_token.as_ref() {
5971            params.push("pageToken", value);
5972        }
5973        if let Some(value) = self._page_size.as_ref() {
5974            params.push("pageSize", value.to_string());
5975        }
5976        if let Some(value) = self._order_by.as_ref() {
5977            params.push("orderBy", value);
5978        }
5979        if let Some(value) = self._filter.as_ref() {
5980            params.push("filter", value);
5981        }
5982
5983        params.extend(self._additional_params.iter());
5984
5985        params.push("alt", "json");
5986        let mut url = self.hub._base_url.clone() + "v1/{+parent}/executions";
5987        if self._scopes.is_empty() {
5988            self._scopes
5989                .insert(Scope::CloudPlatform.as_ref().to_string());
5990        }
5991
5992        #[allow(clippy::single_element_loop)]
5993        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5994            url = params.uri_replacement(url, param_name, find_this, true);
5995        }
5996        {
5997            let to_remove = ["parent"];
5998            params.remove_params(&to_remove);
5999        }
6000
6001        let url = params.parse_with_url(&url);
6002
6003        loop {
6004            let token = match self
6005                .hub
6006                .auth
6007                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6008                .await
6009            {
6010                Ok(token) => token,
6011                Err(e) => match dlg.token(e) {
6012                    Ok(token) => token,
6013                    Err(e) => {
6014                        dlg.finished(false);
6015                        return Err(common::Error::MissingToken(e));
6016                    }
6017                },
6018            };
6019            let mut req_result = {
6020                let client = &self.hub.client;
6021                dlg.pre_request();
6022                let mut req_builder = hyper::Request::builder()
6023                    .method(hyper::Method::GET)
6024                    .uri(url.as_str())
6025                    .header(USER_AGENT, self.hub._user_agent.clone());
6026
6027                if let Some(token) = token.as_ref() {
6028                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6029                }
6030
6031                let request = req_builder
6032                    .header(CONTENT_LENGTH, 0_u64)
6033                    .body(common::to_body::<String>(None));
6034
6035                client.request(request.unwrap()).await
6036            };
6037
6038            match req_result {
6039                Err(err) => {
6040                    if let common::Retry::After(d) = dlg.http_error(&err) {
6041                        sleep(d).await;
6042                        continue;
6043                    }
6044                    dlg.finished(false);
6045                    return Err(common::Error::HttpError(err));
6046                }
6047                Ok(res) => {
6048                    let (mut parts, body) = res.into_parts();
6049                    let mut body = common::Body::new(body);
6050                    if !parts.status.is_success() {
6051                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6052                        let error = serde_json::from_str(&common::to_string(&bytes));
6053                        let response = common::to_response(parts, bytes.into());
6054
6055                        if let common::Retry::After(d) =
6056                            dlg.http_failure(&response, error.as_ref().ok())
6057                        {
6058                            sleep(d).await;
6059                            continue;
6060                        }
6061
6062                        dlg.finished(false);
6063
6064                        return Err(match error {
6065                            Ok(value) => common::Error::BadRequest(value),
6066                            _ => common::Error::Failure(response),
6067                        });
6068                    }
6069                    let response = {
6070                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6071                        let encoded = common::to_string(&bytes);
6072                        match serde_json::from_str(&encoded) {
6073                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6074                            Err(error) => {
6075                                dlg.response_json_decode_error(&encoded, &error);
6076                                return Err(common::Error::JsonDecodeError(
6077                                    encoded.to_string(),
6078                                    error,
6079                                ));
6080                            }
6081                        }
6082                    };
6083
6084                    dlg.finished(true);
6085                    return Ok(response);
6086                }
6087            }
6088        }
6089    }
6090
6091    /// Required. Format: `parent=projects/{project_id}/locations/{location}`
6092    ///
6093    /// Sets the *parent* path property to the given value.
6094    ///
6095    /// Even though the property as already been set when instantiating this call,
6096    /// we provide this method for API completeness.
6097    pub fn parent(mut self, new_value: &str) -> ProjectLocationExecutionListCall<'a, C> {
6098        self._parent = new_value.to_string();
6099        self
6100    }
6101    /// A previous returned page token that can be used to continue listing from the last result.
6102    ///
6103    /// Sets the *page token* query property to the given value.
6104    pub fn page_token(mut self, new_value: &str) -> ProjectLocationExecutionListCall<'a, C> {
6105        self._page_token = Some(new_value.to_string());
6106        self
6107    }
6108    /// Maximum return size of the list call.
6109    ///
6110    /// Sets the *page size* query property to the given value.
6111    pub fn page_size(mut self, new_value: i32) -> ProjectLocationExecutionListCall<'a, C> {
6112        self._page_size = Some(new_value);
6113        self
6114    }
6115    /// Sort by field.
6116    ///
6117    /// Sets the *order by* query property to the given value.
6118    pub fn order_by(mut self, new_value: &str) -> ProjectLocationExecutionListCall<'a, C> {
6119        self._order_by = Some(new_value.to_string());
6120        self
6121    }
6122    /// Filter applied to resulting executions. Currently only supports filtering executions by a specified `schedule_id`. Format: `schedule_id=`
6123    ///
6124    /// Sets the *filter* query property to the given value.
6125    pub fn filter(mut self, new_value: &str) -> ProjectLocationExecutionListCall<'a, C> {
6126        self._filter = Some(new_value.to_string());
6127        self
6128    }
6129    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6130    /// while executing the actual API request.
6131    ///
6132    /// ````text
6133    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6134    /// ````
6135    ///
6136    /// Sets the *delegate* property to the given value.
6137    pub fn delegate(
6138        mut self,
6139        new_value: &'a mut dyn common::Delegate,
6140    ) -> ProjectLocationExecutionListCall<'a, C> {
6141        self._delegate = Some(new_value);
6142        self
6143    }
6144
6145    /// Set any additional parameter of the query string used in the request.
6146    /// It should be used to set parameters which are not yet available through their own
6147    /// setters.
6148    ///
6149    /// Please note that this method must not be used to set any of the known parameters
6150    /// which have their own setter method. If done anyway, the request will fail.
6151    ///
6152    /// # Additional Parameters
6153    ///
6154    /// * *$.xgafv* (query-string) - V1 error format.
6155    /// * *access_token* (query-string) - OAuth access token.
6156    /// * *alt* (query-string) - Data format for response.
6157    /// * *callback* (query-string) - JSONP
6158    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6159    /// * *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.
6160    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6161    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6162    /// * *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.
6163    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6164    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6165    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationExecutionListCall<'a, C>
6166    where
6167        T: AsRef<str>,
6168    {
6169        self._additional_params
6170            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6171        self
6172    }
6173
6174    /// Identifies the authorization scope for the method you are building.
6175    ///
6176    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6177    /// [`Scope::CloudPlatform`].
6178    ///
6179    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6180    /// tokens for more than one scope.
6181    ///
6182    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6183    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6184    /// sufficient, a read-write scope will do as well.
6185    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationExecutionListCall<'a, C>
6186    where
6187        St: AsRef<str>,
6188    {
6189        self._scopes.insert(String::from(scope.as_ref()));
6190        self
6191    }
6192    /// Identifies the authorization scope(s) for the method you are building.
6193    ///
6194    /// See [`Self::add_scope()`] for details.
6195    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationExecutionListCall<'a, C>
6196    where
6197        I: IntoIterator<Item = St>,
6198        St: AsRef<str>,
6199    {
6200        self._scopes
6201            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6202        self
6203    }
6204
6205    /// Removes all scopes, and no default scope will be used either.
6206    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6207    /// for details).
6208    pub fn clear_scopes(mut self) -> ProjectLocationExecutionListCall<'a, C> {
6209        self._scopes.clear();
6210        self
6211    }
6212}
6213
6214/// Creates a new Instance in a given project and location.
6215///
6216/// A builder for the *locations.instances.create* method supported by a *project* resource.
6217/// It is not used directly, but through a [`ProjectMethods`] instance.
6218///
6219/// # Example
6220///
6221/// Instantiate a resource method builder
6222///
6223/// ```test_harness,no_run
6224/// # extern crate hyper;
6225/// # extern crate hyper_rustls;
6226/// # extern crate google_notebooks1 as notebooks1;
6227/// use notebooks1::api::Instance;
6228/// # async fn dox() {
6229/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6230///
6231/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6232/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6233/// #     .with_native_roots()
6234/// #     .unwrap()
6235/// #     .https_only()
6236/// #     .enable_http2()
6237/// #     .build();
6238///
6239/// # let executor = hyper_util::rt::TokioExecutor::new();
6240/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6241/// #     secret,
6242/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6243/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6244/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6245/// #     ),
6246/// # ).build().await.unwrap();
6247///
6248/// # let client = hyper_util::client::legacy::Client::builder(
6249/// #     hyper_util::rt::TokioExecutor::new()
6250/// # )
6251/// # .build(
6252/// #     hyper_rustls::HttpsConnectorBuilder::new()
6253/// #         .with_native_roots()
6254/// #         .unwrap()
6255/// #         .https_or_http()
6256/// #         .enable_http2()
6257/// #         .build()
6258/// # );
6259/// # let mut hub = AIPlatformNotebooks::new(client, auth);
6260/// // As the method needs a request, you would usually fill it with the desired information
6261/// // into the respective structure. Some of the parts shown here might not be applicable !
6262/// // Values shown here are possibly random and not representative !
6263/// let mut req = Instance::default();
6264///
6265/// // You can configure optional parameters by calling the respective setters at will, and
6266/// // execute the final call using `doit()`.
6267/// // Values shown here are possibly random and not representative !
6268/// let result = hub.projects().locations_instances_create(req, "parent")
6269///              .instance_id("gubergren")
6270///              .doit().await;
6271/// # }
6272/// ```
6273pub struct ProjectLocationInstanceCreateCall<'a, C>
6274where
6275    C: 'a,
6276{
6277    hub: &'a AIPlatformNotebooks<C>,
6278    _request: Instance,
6279    _parent: String,
6280    _instance_id: Option<String>,
6281    _delegate: Option<&'a mut dyn common::Delegate>,
6282    _additional_params: HashMap<String, String>,
6283    _scopes: BTreeSet<String>,
6284}
6285
6286impl<'a, C> common::CallBuilder for ProjectLocationInstanceCreateCall<'a, C> {}
6287
6288impl<'a, C> ProjectLocationInstanceCreateCall<'a, C>
6289where
6290    C: common::Connector,
6291{
6292    /// Perform the operation you have build so far.
6293    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6294        use std::borrow::Cow;
6295        use std::io::{Read, Seek};
6296
6297        use common::{url::Params, ToParts};
6298        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6299
6300        let mut dd = common::DefaultDelegate;
6301        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6302        dlg.begin(common::MethodInfo {
6303            id: "notebooks.projects.locations.instances.create",
6304            http_method: hyper::Method::POST,
6305        });
6306
6307        for &field in ["alt", "parent", "instanceId"].iter() {
6308            if self._additional_params.contains_key(field) {
6309                dlg.finished(false);
6310                return Err(common::Error::FieldClash(field));
6311            }
6312        }
6313
6314        let mut params = Params::with_capacity(5 + self._additional_params.len());
6315        params.push("parent", self._parent);
6316        if let Some(value) = self._instance_id.as_ref() {
6317            params.push("instanceId", value);
6318        }
6319
6320        params.extend(self._additional_params.iter());
6321
6322        params.push("alt", "json");
6323        let mut url = self.hub._base_url.clone() + "v1/{+parent}/instances";
6324        if self._scopes.is_empty() {
6325            self._scopes
6326                .insert(Scope::CloudPlatform.as_ref().to_string());
6327        }
6328
6329        #[allow(clippy::single_element_loop)]
6330        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6331            url = params.uri_replacement(url, param_name, find_this, true);
6332        }
6333        {
6334            let to_remove = ["parent"];
6335            params.remove_params(&to_remove);
6336        }
6337
6338        let url = params.parse_with_url(&url);
6339
6340        let mut json_mime_type = mime::APPLICATION_JSON;
6341        let mut request_value_reader = {
6342            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6343            common::remove_json_null_values(&mut value);
6344            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6345            serde_json::to_writer(&mut dst, &value).unwrap();
6346            dst
6347        };
6348        let request_size = request_value_reader
6349            .seek(std::io::SeekFrom::End(0))
6350            .unwrap();
6351        request_value_reader
6352            .seek(std::io::SeekFrom::Start(0))
6353            .unwrap();
6354
6355        loop {
6356            let token = match self
6357                .hub
6358                .auth
6359                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6360                .await
6361            {
6362                Ok(token) => token,
6363                Err(e) => match dlg.token(e) {
6364                    Ok(token) => token,
6365                    Err(e) => {
6366                        dlg.finished(false);
6367                        return Err(common::Error::MissingToken(e));
6368                    }
6369                },
6370            };
6371            request_value_reader
6372                .seek(std::io::SeekFrom::Start(0))
6373                .unwrap();
6374            let mut req_result = {
6375                let client = &self.hub.client;
6376                dlg.pre_request();
6377                let mut req_builder = hyper::Request::builder()
6378                    .method(hyper::Method::POST)
6379                    .uri(url.as_str())
6380                    .header(USER_AGENT, self.hub._user_agent.clone());
6381
6382                if let Some(token) = token.as_ref() {
6383                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6384                }
6385
6386                let request = req_builder
6387                    .header(CONTENT_TYPE, json_mime_type.to_string())
6388                    .header(CONTENT_LENGTH, request_size as u64)
6389                    .body(common::to_body(
6390                        request_value_reader.get_ref().clone().into(),
6391                    ));
6392
6393                client.request(request.unwrap()).await
6394            };
6395
6396            match req_result {
6397                Err(err) => {
6398                    if let common::Retry::After(d) = dlg.http_error(&err) {
6399                        sleep(d).await;
6400                        continue;
6401                    }
6402                    dlg.finished(false);
6403                    return Err(common::Error::HttpError(err));
6404                }
6405                Ok(res) => {
6406                    let (mut parts, body) = res.into_parts();
6407                    let mut body = common::Body::new(body);
6408                    if !parts.status.is_success() {
6409                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6410                        let error = serde_json::from_str(&common::to_string(&bytes));
6411                        let response = common::to_response(parts, bytes.into());
6412
6413                        if let common::Retry::After(d) =
6414                            dlg.http_failure(&response, error.as_ref().ok())
6415                        {
6416                            sleep(d).await;
6417                            continue;
6418                        }
6419
6420                        dlg.finished(false);
6421
6422                        return Err(match error {
6423                            Ok(value) => common::Error::BadRequest(value),
6424                            _ => common::Error::Failure(response),
6425                        });
6426                    }
6427                    let response = {
6428                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6429                        let encoded = common::to_string(&bytes);
6430                        match serde_json::from_str(&encoded) {
6431                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6432                            Err(error) => {
6433                                dlg.response_json_decode_error(&encoded, &error);
6434                                return Err(common::Error::JsonDecodeError(
6435                                    encoded.to_string(),
6436                                    error,
6437                                ));
6438                            }
6439                        }
6440                    };
6441
6442                    dlg.finished(true);
6443                    return Ok(response);
6444                }
6445            }
6446        }
6447    }
6448
6449    ///
6450    /// Sets the *request* property to the given value.
6451    ///
6452    /// Even though the property as already been set when instantiating this call,
6453    /// we provide this method for API completeness.
6454    pub fn request(mut self, new_value: Instance) -> ProjectLocationInstanceCreateCall<'a, C> {
6455        self._request = new_value;
6456        self
6457    }
6458    /// Required. Format: `parent=projects/{project_id}/locations/{location}`
6459    ///
6460    /// Sets the *parent* path property to the given value.
6461    ///
6462    /// Even though the property as already been set when instantiating this call,
6463    /// we provide this method for API completeness.
6464    pub fn parent(mut self, new_value: &str) -> ProjectLocationInstanceCreateCall<'a, C> {
6465        self._parent = new_value.to_string();
6466        self
6467    }
6468    /// Required. User-defined unique ID of this instance.
6469    ///
6470    /// Sets the *instance id* query property to the given value.
6471    pub fn instance_id(mut self, new_value: &str) -> ProjectLocationInstanceCreateCall<'a, C> {
6472        self._instance_id = Some(new_value.to_string());
6473        self
6474    }
6475    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6476    /// while executing the actual API request.
6477    ///
6478    /// ````text
6479    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6480    /// ````
6481    ///
6482    /// Sets the *delegate* property to the given value.
6483    pub fn delegate(
6484        mut self,
6485        new_value: &'a mut dyn common::Delegate,
6486    ) -> ProjectLocationInstanceCreateCall<'a, C> {
6487        self._delegate = Some(new_value);
6488        self
6489    }
6490
6491    /// Set any additional parameter of the query string used in the request.
6492    /// It should be used to set parameters which are not yet available through their own
6493    /// setters.
6494    ///
6495    /// Please note that this method must not be used to set any of the known parameters
6496    /// which have their own setter method. If done anyway, the request will fail.
6497    ///
6498    /// # Additional Parameters
6499    ///
6500    /// * *$.xgafv* (query-string) - V1 error format.
6501    /// * *access_token* (query-string) - OAuth access token.
6502    /// * *alt* (query-string) - Data format for response.
6503    /// * *callback* (query-string) - JSONP
6504    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6505    /// * *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.
6506    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6507    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6508    /// * *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.
6509    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6510    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6511    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceCreateCall<'a, C>
6512    where
6513        T: AsRef<str>,
6514    {
6515        self._additional_params
6516            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6517        self
6518    }
6519
6520    /// Identifies the authorization scope for the method you are building.
6521    ///
6522    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6523    /// [`Scope::CloudPlatform`].
6524    ///
6525    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6526    /// tokens for more than one scope.
6527    ///
6528    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6529    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6530    /// sufficient, a read-write scope will do as well.
6531    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceCreateCall<'a, C>
6532    where
6533        St: AsRef<str>,
6534    {
6535        self._scopes.insert(String::from(scope.as_ref()));
6536        self
6537    }
6538    /// Identifies the authorization scope(s) for the method you are building.
6539    ///
6540    /// See [`Self::add_scope()`] for details.
6541    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceCreateCall<'a, C>
6542    where
6543        I: IntoIterator<Item = St>,
6544        St: AsRef<str>,
6545    {
6546        self._scopes
6547            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6548        self
6549    }
6550
6551    /// Removes all scopes, and no default scope will be used either.
6552    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6553    /// for details).
6554    pub fn clear_scopes(mut self) -> ProjectLocationInstanceCreateCall<'a, C> {
6555        self._scopes.clear();
6556        self
6557    }
6558}
6559
6560/// Deletes a single Instance.
6561///
6562/// A builder for the *locations.instances.delete* method supported by a *project* resource.
6563/// It is not used directly, but through a [`ProjectMethods`] instance.
6564///
6565/// # Example
6566///
6567/// Instantiate a resource method builder
6568///
6569/// ```test_harness,no_run
6570/// # extern crate hyper;
6571/// # extern crate hyper_rustls;
6572/// # extern crate google_notebooks1 as notebooks1;
6573/// # async fn dox() {
6574/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6575///
6576/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6577/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6578/// #     .with_native_roots()
6579/// #     .unwrap()
6580/// #     .https_only()
6581/// #     .enable_http2()
6582/// #     .build();
6583///
6584/// # let executor = hyper_util::rt::TokioExecutor::new();
6585/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6586/// #     secret,
6587/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6588/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6589/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6590/// #     ),
6591/// # ).build().await.unwrap();
6592///
6593/// # let client = hyper_util::client::legacy::Client::builder(
6594/// #     hyper_util::rt::TokioExecutor::new()
6595/// # )
6596/// # .build(
6597/// #     hyper_rustls::HttpsConnectorBuilder::new()
6598/// #         .with_native_roots()
6599/// #         .unwrap()
6600/// #         .https_or_http()
6601/// #         .enable_http2()
6602/// #         .build()
6603/// # );
6604/// # let mut hub = AIPlatformNotebooks::new(client, auth);
6605/// // You can configure optional parameters by calling the respective setters at will, and
6606/// // execute the final call using `doit()`.
6607/// // Values shown here are possibly random and not representative !
6608/// let result = hub.projects().locations_instances_delete("name")
6609///              .doit().await;
6610/// # }
6611/// ```
6612pub struct ProjectLocationInstanceDeleteCall<'a, C>
6613where
6614    C: 'a,
6615{
6616    hub: &'a AIPlatformNotebooks<C>,
6617    _name: String,
6618    _delegate: Option<&'a mut dyn common::Delegate>,
6619    _additional_params: HashMap<String, String>,
6620    _scopes: BTreeSet<String>,
6621}
6622
6623impl<'a, C> common::CallBuilder for ProjectLocationInstanceDeleteCall<'a, C> {}
6624
6625impl<'a, C> ProjectLocationInstanceDeleteCall<'a, C>
6626where
6627    C: common::Connector,
6628{
6629    /// Perform the operation you have build so far.
6630    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6631        use std::borrow::Cow;
6632        use std::io::{Read, Seek};
6633
6634        use common::{url::Params, ToParts};
6635        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6636
6637        let mut dd = common::DefaultDelegate;
6638        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6639        dlg.begin(common::MethodInfo {
6640            id: "notebooks.projects.locations.instances.delete",
6641            http_method: hyper::Method::DELETE,
6642        });
6643
6644        for &field in ["alt", "name"].iter() {
6645            if self._additional_params.contains_key(field) {
6646                dlg.finished(false);
6647                return Err(common::Error::FieldClash(field));
6648            }
6649        }
6650
6651        let mut params = Params::with_capacity(3 + self._additional_params.len());
6652        params.push("name", self._name);
6653
6654        params.extend(self._additional_params.iter());
6655
6656        params.push("alt", "json");
6657        let mut url = self.hub._base_url.clone() + "v1/{+name}";
6658        if self._scopes.is_empty() {
6659            self._scopes
6660                .insert(Scope::CloudPlatform.as_ref().to_string());
6661        }
6662
6663        #[allow(clippy::single_element_loop)]
6664        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6665            url = params.uri_replacement(url, param_name, find_this, true);
6666        }
6667        {
6668            let to_remove = ["name"];
6669            params.remove_params(&to_remove);
6670        }
6671
6672        let url = params.parse_with_url(&url);
6673
6674        loop {
6675            let token = match self
6676                .hub
6677                .auth
6678                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6679                .await
6680            {
6681                Ok(token) => token,
6682                Err(e) => match dlg.token(e) {
6683                    Ok(token) => token,
6684                    Err(e) => {
6685                        dlg.finished(false);
6686                        return Err(common::Error::MissingToken(e));
6687                    }
6688                },
6689            };
6690            let mut req_result = {
6691                let client = &self.hub.client;
6692                dlg.pre_request();
6693                let mut req_builder = hyper::Request::builder()
6694                    .method(hyper::Method::DELETE)
6695                    .uri(url.as_str())
6696                    .header(USER_AGENT, self.hub._user_agent.clone());
6697
6698                if let Some(token) = token.as_ref() {
6699                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6700                }
6701
6702                let request = req_builder
6703                    .header(CONTENT_LENGTH, 0_u64)
6704                    .body(common::to_body::<String>(None));
6705
6706                client.request(request.unwrap()).await
6707            };
6708
6709            match req_result {
6710                Err(err) => {
6711                    if let common::Retry::After(d) = dlg.http_error(&err) {
6712                        sleep(d).await;
6713                        continue;
6714                    }
6715                    dlg.finished(false);
6716                    return Err(common::Error::HttpError(err));
6717                }
6718                Ok(res) => {
6719                    let (mut parts, body) = res.into_parts();
6720                    let mut body = common::Body::new(body);
6721                    if !parts.status.is_success() {
6722                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6723                        let error = serde_json::from_str(&common::to_string(&bytes));
6724                        let response = common::to_response(parts, bytes.into());
6725
6726                        if let common::Retry::After(d) =
6727                            dlg.http_failure(&response, error.as_ref().ok())
6728                        {
6729                            sleep(d).await;
6730                            continue;
6731                        }
6732
6733                        dlg.finished(false);
6734
6735                        return Err(match error {
6736                            Ok(value) => common::Error::BadRequest(value),
6737                            _ => common::Error::Failure(response),
6738                        });
6739                    }
6740                    let response = {
6741                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6742                        let encoded = common::to_string(&bytes);
6743                        match serde_json::from_str(&encoded) {
6744                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6745                            Err(error) => {
6746                                dlg.response_json_decode_error(&encoded, &error);
6747                                return Err(common::Error::JsonDecodeError(
6748                                    encoded.to_string(),
6749                                    error,
6750                                ));
6751                            }
6752                        }
6753                    };
6754
6755                    dlg.finished(true);
6756                    return Ok(response);
6757                }
6758            }
6759        }
6760    }
6761
6762    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
6763    ///
6764    /// Sets the *name* path property to the given value.
6765    ///
6766    /// Even though the property as already been set when instantiating this call,
6767    /// we provide this method for API completeness.
6768    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceDeleteCall<'a, C> {
6769        self._name = new_value.to_string();
6770        self
6771    }
6772    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6773    /// while executing the actual API request.
6774    ///
6775    /// ````text
6776    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6777    /// ````
6778    ///
6779    /// Sets the *delegate* property to the given value.
6780    pub fn delegate(
6781        mut self,
6782        new_value: &'a mut dyn common::Delegate,
6783    ) -> ProjectLocationInstanceDeleteCall<'a, C> {
6784        self._delegate = Some(new_value);
6785        self
6786    }
6787
6788    /// Set any additional parameter of the query string used in the request.
6789    /// It should be used to set parameters which are not yet available through their own
6790    /// setters.
6791    ///
6792    /// Please note that this method must not be used to set any of the known parameters
6793    /// which have their own setter method. If done anyway, the request will fail.
6794    ///
6795    /// # Additional Parameters
6796    ///
6797    /// * *$.xgafv* (query-string) - V1 error format.
6798    /// * *access_token* (query-string) - OAuth access token.
6799    /// * *alt* (query-string) - Data format for response.
6800    /// * *callback* (query-string) - JSONP
6801    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6802    /// * *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.
6803    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6804    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6805    /// * *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.
6806    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6807    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6808    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceDeleteCall<'a, C>
6809    where
6810        T: AsRef<str>,
6811    {
6812        self._additional_params
6813            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6814        self
6815    }
6816
6817    /// Identifies the authorization scope for the method you are building.
6818    ///
6819    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6820    /// [`Scope::CloudPlatform`].
6821    ///
6822    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6823    /// tokens for more than one scope.
6824    ///
6825    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6826    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6827    /// sufficient, a read-write scope will do as well.
6828    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceDeleteCall<'a, C>
6829    where
6830        St: AsRef<str>,
6831    {
6832        self._scopes.insert(String::from(scope.as_ref()));
6833        self
6834    }
6835    /// Identifies the authorization scope(s) for the method you are building.
6836    ///
6837    /// See [`Self::add_scope()`] for details.
6838    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceDeleteCall<'a, C>
6839    where
6840        I: IntoIterator<Item = St>,
6841        St: AsRef<str>,
6842    {
6843        self._scopes
6844            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6845        self
6846    }
6847
6848    /// Removes all scopes, and no default scope will be used either.
6849    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6850    /// for details).
6851    pub fn clear_scopes(mut self) -> ProjectLocationInstanceDeleteCall<'a, C> {
6852        self._scopes.clear();
6853        self
6854    }
6855}
6856
6857/// Creates a Diagnostic File and runs Diagnostic Tool given an Instance.
6858///
6859/// A builder for the *locations.instances.diagnose* method supported by a *project* resource.
6860/// It is not used directly, but through a [`ProjectMethods`] instance.
6861///
6862/// # Example
6863///
6864/// Instantiate a resource method builder
6865///
6866/// ```test_harness,no_run
6867/// # extern crate hyper;
6868/// # extern crate hyper_rustls;
6869/// # extern crate google_notebooks1 as notebooks1;
6870/// use notebooks1::api::DiagnoseInstanceRequest;
6871/// # async fn dox() {
6872/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6873///
6874/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6875/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6876/// #     .with_native_roots()
6877/// #     .unwrap()
6878/// #     .https_only()
6879/// #     .enable_http2()
6880/// #     .build();
6881///
6882/// # let executor = hyper_util::rt::TokioExecutor::new();
6883/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6884/// #     secret,
6885/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6886/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6887/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6888/// #     ),
6889/// # ).build().await.unwrap();
6890///
6891/// # let client = hyper_util::client::legacy::Client::builder(
6892/// #     hyper_util::rt::TokioExecutor::new()
6893/// # )
6894/// # .build(
6895/// #     hyper_rustls::HttpsConnectorBuilder::new()
6896/// #         .with_native_roots()
6897/// #         .unwrap()
6898/// #         .https_or_http()
6899/// #         .enable_http2()
6900/// #         .build()
6901/// # );
6902/// # let mut hub = AIPlatformNotebooks::new(client, auth);
6903/// // As the method needs a request, you would usually fill it with the desired information
6904/// // into the respective structure. Some of the parts shown here might not be applicable !
6905/// // Values shown here are possibly random and not representative !
6906/// let mut req = DiagnoseInstanceRequest::default();
6907///
6908/// // You can configure optional parameters by calling the respective setters at will, and
6909/// // execute the final call using `doit()`.
6910/// // Values shown here are possibly random and not representative !
6911/// let result = hub.projects().locations_instances_diagnose(req, "name")
6912///              .doit().await;
6913/// # }
6914/// ```
6915pub struct ProjectLocationInstanceDiagnoseCall<'a, C>
6916where
6917    C: 'a,
6918{
6919    hub: &'a AIPlatformNotebooks<C>,
6920    _request: DiagnoseInstanceRequest,
6921    _name: String,
6922    _delegate: Option<&'a mut dyn common::Delegate>,
6923    _additional_params: HashMap<String, String>,
6924    _scopes: BTreeSet<String>,
6925}
6926
6927impl<'a, C> common::CallBuilder for ProjectLocationInstanceDiagnoseCall<'a, C> {}
6928
6929impl<'a, C> ProjectLocationInstanceDiagnoseCall<'a, C>
6930where
6931    C: common::Connector,
6932{
6933    /// Perform the operation you have build so far.
6934    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6935        use std::borrow::Cow;
6936        use std::io::{Read, Seek};
6937
6938        use common::{url::Params, ToParts};
6939        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6940
6941        let mut dd = common::DefaultDelegate;
6942        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6943        dlg.begin(common::MethodInfo {
6944            id: "notebooks.projects.locations.instances.diagnose",
6945            http_method: hyper::Method::POST,
6946        });
6947
6948        for &field in ["alt", "name"].iter() {
6949            if self._additional_params.contains_key(field) {
6950                dlg.finished(false);
6951                return Err(common::Error::FieldClash(field));
6952            }
6953        }
6954
6955        let mut params = Params::with_capacity(4 + self._additional_params.len());
6956        params.push("name", self._name);
6957
6958        params.extend(self._additional_params.iter());
6959
6960        params.push("alt", "json");
6961        let mut url = self.hub._base_url.clone() + "v1/{+name}:diagnose";
6962        if self._scopes.is_empty() {
6963            self._scopes
6964                .insert(Scope::CloudPlatform.as_ref().to_string());
6965        }
6966
6967        #[allow(clippy::single_element_loop)]
6968        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6969            url = params.uri_replacement(url, param_name, find_this, true);
6970        }
6971        {
6972            let to_remove = ["name"];
6973            params.remove_params(&to_remove);
6974        }
6975
6976        let url = params.parse_with_url(&url);
6977
6978        let mut json_mime_type = mime::APPLICATION_JSON;
6979        let mut request_value_reader = {
6980            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6981            common::remove_json_null_values(&mut value);
6982            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6983            serde_json::to_writer(&mut dst, &value).unwrap();
6984            dst
6985        };
6986        let request_size = request_value_reader
6987            .seek(std::io::SeekFrom::End(0))
6988            .unwrap();
6989        request_value_reader
6990            .seek(std::io::SeekFrom::Start(0))
6991            .unwrap();
6992
6993        loop {
6994            let token = match self
6995                .hub
6996                .auth
6997                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6998                .await
6999            {
7000                Ok(token) => token,
7001                Err(e) => match dlg.token(e) {
7002                    Ok(token) => token,
7003                    Err(e) => {
7004                        dlg.finished(false);
7005                        return Err(common::Error::MissingToken(e));
7006                    }
7007                },
7008            };
7009            request_value_reader
7010                .seek(std::io::SeekFrom::Start(0))
7011                .unwrap();
7012            let mut req_result = {
7013                let client = &self.hub.client;
7014                dlg.pre_request();
7015                let mut req_builder = hyper::Request::builder()
7016                    .method(hyper::Method::POST)
7017                    .uri(url.as_str())
7018                    .header(USER_AGENT, self.hub._user_agent.clone());
7019
7020                if let Some(token) = token.as_ref() {
7021                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7022                }
7023
7024                let request = req_builder
7025                    .header(CONTENT_TYPE, json_mime_type.to_string())
7026                    .header(CONTENT_LENGTH, request_size as u64)
7027                    .body(common::to_body(
7028                        request_value_reader.get_ref().clone().into(),
7029                    ));
7030
7031                client.request(request.unwrap()).await
7032            };
7033
7034            match req_result {
7035                Err(err) => {
7036                    if let common::Retry::After(d) = dlg.http_error(&err) {
7037                        sleep(d).await;
7038                        continue;
7039                    }
7040                    dlg.finished(false);
7041                    return Err(common::Error::HttpError(err));
7042                }
7043                Ok(res) => {
7044                    let (mut parts, body) = res.into_parts();
7045                    let mut body = common::Body::new(body);
7046                    if !parts.status.is_success() {
7047                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7048                        let error = serde_json::from_str(&common::to_string(&bytes));
7049                        let response = common::to_response(parts, bytes.into());
7050
7051                        if let common::Retry::After(d) =
7052                            dlg.http_failure(&response, error.as_ref().ok())
7053                        {
7054                            sleep(d).await;
7055                            continue;
7056                        }
7057
7058                        dlg.finished(false);
7059
7060                        return Err(match error {
7061                            Ok(value) => common::Error::BadRequest(value),
7062                            _ => common::Error::Failure(response),
7063                        });
7064                    }
7065                    let response = {
7066                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7067                        let encoded = common::to_string(&bytes);
7068                        match serde_json::from_str(&encoded) {
7069                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7070                            Err(error) => {
7071                                dlg.response_json_decode_error(&encoded, &error);
7072                                return Err(common::Error::JsonDecodeError(
7073                                    encoded.to_string(),
7074                                    error,
7075                                ));
7076                            }
7077                        }
7078                    };
7079
7080                    dlg.finished(true);
7081                    return Ok(response);
7082                }
7083            }
7084        }
7085    }
7086
7087    ///
7088    /// Sets the *request* property to the given value.
7089    ///
7090    /// Even though the property as already been set when instantiating this call,
7091    /// we provide this method for API completeness.
7092    pub fn request(
7093        mut self,
7094        new_value: DiagnoseInstanceRequest,
7095    ) -> ProjectLocationInstanceDiagnoseCall<'a, C> {
7096        self._request = new_value;
7097        self
7098    }
7099    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
7100    ///
7101    /// Sets the *name* path property to the given value.
7102    ///
7103    /// Even though the property as already been set when instantiating this call,
7104    /// we provide this method for API completeness.
7105    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceDiagnoseCall<'a, C> {
7106        self._name = new_value.to_string();
7107        self
7108    }
7109    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7110    /// while executing the actual API request.
7111    ///
7112    /// ````text
7113    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7114    /// ````
7115    ///
7116    /// Sets the *delegate* property to the given value.
7117    pub fn delegate(
7118        mut self,
7119        new_value: &'a mut dyn common::Delegate,
7120    ) -> ProjectLocationInstanceDiagnoseCall<'a, C> {
7121        self._delegate = Some(new_value);
7122        self
7123    }
7124
7125    /// Set any additional parameter of the query string used in the request.
7126    /// It should be used to set parameters which are not yet available through their own
7127    /// setters.
7128    ///
7129    /// Please note that this method must not be used to set any of the known parameters
7130    /// which have their own setter method. If done anyway, the request will fail.
7131    ///
7132    /// # Additional Parameters
7133    ///
7134    /// * *$.xgafv* (query-string) - V1 error format.
7135    /// * *access_token* (query-string) - OAuth access token.
7136    /// * *alt* (query-string) - Data format for response.
7137    /// * *callback* (query-string) - JSONP
7138    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7139    /// * *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.
7140    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7141    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7142    /// * *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.
7143    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7144    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7145    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceDiagnoseCall<'a, C>
7146    where
7147        T: AsRef<str>,
7148    {
7149        self._additional_params
7150            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7151        self
7152    }
7153
7154    /// Identifies the authorization scope for the method you are building.
7155    ///
7156    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7157    /// [`Scope::CloudPlatform`].
7158    ///
7159    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7160    /// tokens for more than one scope.
7161    ///
7162    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7163    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7164    /// sufficient, a read-write scope will do as well.
7165    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceDiagnoseCall<'a, C>
7166    where
7167        St: AsRef<str>,
7168    {
7169        self._scopes.insert(String::from(scope.as_ref()));
7170        self
7171    }
7172    /// Identifies the authorization scope(s) for the method you are building.
7173    ///
7174    /// See [`Self::add_scope()`] for details.
7175    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceDiagnoseCall<'a, C>
7176    where
7177        I: IntoIterator<Item = St>,
7178        St: AsRef<str>,
7179    {
7180        self._scopes
7181            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7182        self
7183    }
7184
7185    /// Removes all scopes, and no default scope will be used either.
7186    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7187    /// for details).
7188    pub fn clear_scopes(mut self) -> ProjectLocationInstanceDiagnoseCall<'a, C> {
7189        self._scopes.clear();
7190        self
7191    }
7192}
7193
7194/// Gets details of a single Instance.
7195///
7196/// A builder for the *locations.instances.get* method supported by a *project* resource.
7197/// It is not used directly, but through a [`ProjectMethods`] instance.
7198///
7199/// # Example
7200///
7201/// Instantiate a resource method builder
7202///
7203/// ```test_harness,no_run
7204/// # extern crate hyper;
7205/// # extern crate hyper_rustls;
7206/// # extern crate google_notebooks1 as notebooks1;
7207/// # async fn dox() {
7208/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7209///
7210/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7211/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7212/// #     .with_native_roots()
7213/// #     .unwrap()
7214/// #     .https_only()
7215/// #     .enable_http2()
7216/// #     .build();
7217///
7218/// # let executor = hyper_util::rt::TokioExecutor::new();
7219/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7220/// #     secret,
7221/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7222/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7223/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7224/// #     ),
7225/// # ).build().await.unwrap();
7226///
7227/// # let client = hyper_util::client::legacy::Client::builder(
7228/// #     hyper_util::rt::TokioExecutor::new()
7229/// # )
7230/// # .build(
7231/// #     hyper_rustls::HttpsConnectorBuilder::new()
7232/// #         .with_native_roots()
7233/// #         .unwrap()
7234/// #         .https_or_http()
7235/// #         .enable_http2()
7236/// #         .build()
7237/// # );
7238/// # let mut hub = AIPlatformNotebooks::new(client, auth);
7239/// // You can configure optional parameters by calling the respective setters at will, and
7240/// // execute the final call using `doit()`.
7241/// // Values shown here are possibly random and not representative !
7242/// let result = hub.projects().locations_instances_get("name")
7243///              .doit().await;
7244/// # }
7245/// ```
7246pub struct ProjectLocationInstanceGetCall<'a, C>
7247where
7248    C: 'a,
7249{
7250    hub: &'a AIPlatformNotebooks<C>,
7251    _name: String,
7252    _delegate: Option<&'a mut dyn common::Delegate>,
7253    _additional_params: HashMap<String, String>,
7254    _scopes: BTreeSet<String>,
7255}
7256
7257impl<'a, C> common::CallBuilder for ProjectLocationInstanceGetCall<'a, C> {}
7258
7259impl<'a, C> ProjectLocationInstanceGetCall<'a, C>
7260where
7261    C: common::Connector,
7262{
7263    /// Perform the operation you have build so far.
7264    pub async fn doit(mut self) -> common::Result<(common::Response, Instance)> {
7265        use std::borrow::Cow;
7266        use std::io::{Read, Seek};
7267
7268        use common::{url::Params, ToParts};
7269        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7270
7271        let mut dd = common::DefaultDelegate;
7272        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7273        dlg.begin(common::MethodInfo {
7274            id: "notebooks.projects.locations.instances.get",
7275            http_method: hyper::Method::GET,
7276        });
7277
7278        for &field in ["alt", "name"].iter() {
7279            if self._additional_params.contains_key(field) {
7280                dlg.finished(false);
7281                return Err(common::Error::FieldClash(field));
7282            }
7283        }
7284
7285        let mut params = Params::with_capacity(3 + self._additional_params.len());
7286        params.push("name", self._name);
7287
7288        params.extend(self._additional_params.iter());
7289
7290        params.push("alt", "json");
7291        let mut url = self.hub._base_url.clone() + "v1/{+name}";
7292        if self._scopes.is_empty() {
7293            self._scopes
7294                .insert(Scope::CloudPlatform.as_ref().to_string());
7295        }
7296
7297        #[allow(clippy::single_element_loop)]
7298        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7299            url = params.uri_replacement(url, param_name, find_this, true);
7300        }
7301        {
7302            let to_remove = ["name"];
7303            params.remove_params(&to_remove);
7304        }
7305
7306        let url = params.parse_with_url(&url);
7307
7308        loop {
7309            let token = match self
7310                .hub
7311                .auth
7312                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7313                .await
7314            {
7315                Ok(token) => token,
7316                Err(e) => match dlg.token(e) {
7317                    Ok(token) => token,
7318                    Err(e) => {
7319                        dlg.finished(false);
7320                        return Err(common::Error::MissingToken(e));
7321                    }
7322                },
7323            };
7324            let mut req_result = {
7325                let client = &self.hub.client;
7326                dlg.pre_request();
7327                let mut req_builder = hyper::Request::builder()
7328                    .method(hyper::Method::GET)
7329                    .uri(url.as_str())
7330                    .header(USER_AGENT, self.hub._user_agent.clone());
7331
7332                if let Some(token) = token.as_ref() {
7333                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7334                }
7335
7336                let request = req_builder
7337                    .header(CONTENT_LENGTH, 0_u64)
7338                    .body(common::to_body::<String>(None));
7339
7340                client.request(request.unwrap()).await
7341            };
7342
7343            match req_result {
7344                Err(err) => {
7345                    if let common::Retry::After(d) = dlg.http_error(&err) {
7346                        sleep(d).await;
7347                        continue;
7348                    }
7349                    dlg.finished(false);
7350                    return Err(common::Error::HttpError(err));
7351                }
7352                Ok(res) => {
7353                    let (mut parts, body) = res.into_parts();
7354                    let mut body = common::Body::new(body);
7355                    if !parts.status.is_success() {
7356                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7357                        let error = serde_json::from_str(&common::to_string(&bytes));
7358                        let response = common::to_response(parts, bytes.into());
7359
7360                        if let common::Retry::After(d) =
7361                            dlg.http_failure(&response, error.as_ref().ok())
7362                        {
7363                            sleep(d).await;
7364                            continue;
7365                        }
7366
7367                        dlg.finished(false);
7368
7369                        return Err(match error {
7370                            Ok(value) => common::Error::BadRequest(value),
7371                            _ => common::Error::Failure(response),
7372                        });
7373                    }
7374                    let response = {
7375                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7376                        let encoded = common::to_string(&bytes);
7377                        match serde_json::from_str(&encoded) {
7378                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7379                            Err(error) => {
7380                                dlg.response_json_decode_error(&encoded, &error);
7381                                return Err(common::Error::JsonDecodeError(
7382                                    encoded.to_string(),
7383                                    error,
7384                                ));
7385                            }
7386                        }
7387                    };
7388
7389                    dlg.finished(true);
7390                    return Ok(response);
7391                }
7392            }
7393        }
7394    }
7395
7396    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
7397    ///
7398    /// Sets the *name* path property to the given value.
7399    ///
7400    /// Even though the property as already been set when instantiating this call,
7401    /// we provide this method for API completeness.
7402    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceGetCall<'a, C> {
7403        self._name = new_value.to_string();
7404        self
7405    }
7406    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7407    /// while executing the actual API request.
7408    ///
7409    /// ````text
7410    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7411    /// ````
7412    ///
7413    /// Sets the *delegate* property to the given value.
7414    pub fn delegate(
7415        mut self,
7416        new_value: &'a mut dyn common::Delegate,
7417    ) -> ProjectLocationInstanceGetCall<'a, C> {
7418        self._delegate = Some(new_value);
7419        self
7420    }
7421
7422    /// Set any additional parameter of the query string used in the request.
7423    /// It should be used to set parameters which are not yet available through their own
7424    /// setters.
7425    ///
7426    /// Please note that this method must not be used to set any of the known parameters
7427    /// which have their own setter method. If done anyway, the request will fail.
7428    ///
7429    /// # Additional Parameters
7430    ///
7431    /// * *$.xgafv* (query-string) - V1 error format.
7432    /// * *access_token* (query-string) - OAuth access token.
7433    /// * *alt* (query-string) - Data format for response.
7434    /// * *callback* (query-string) - JSONP
7435    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7436    /// * *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.
7437    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7438    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7439    /// * *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.
7440    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7441    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7442    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceGetCall<'a, C>
7443    where
7444        T: AsRef<str>,
7445    {
7446        self._additional_params
7447            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7448        self
7449    }
7450
7451    /// Identifies the authorization scope for the method you are building.
7452    ///
7453    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7454    /// [`Scope::CloudPlatform`].
7455    ///
7456    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7457    /// tokens for more than one scope.
7458    ///
7459    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7460    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7461    /// sufficient, a read-write scope will do as well.
7462    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceGetCall<'a, C>
7463    where
7464        St: AsRef<str>,
7465    {
7466        self._scopes.insert(String::from(scope.as_ref()));
7467        self
7468    }
7469    /// Identifies the authorization scope(s) for the method you are building.
7470    ///
7471    /// See [`Self::add_scope()`] for details.
7472    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceGetCall<'a, C>
7473    where
7474        I: IntoIterator<Item = St>,
7475        St: AsRef<str>,
7476    {
7477        self._scopes
7478            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7479        self
7480    }
7481
7482    /// Removes all scopes, and no default scope will be used either.
7483    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7484    /// for details).
7485    pub fn clear_scopes(mut self) -> ProjectLocationInstanceGetCall<'a, C> {
7486        self._scopes.clear();
7487        self
7488    }
7489}
7490
7491/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
7492///
7493/// A builder for the *locations.instances.getIamPolicy* method supported by a *project* resource.
7494/// It is not used directly, but through a [`ProjectMethods`] instance.
7495///
7496/// # Example
7497///
7498/// Instantiate a resource method builder
7499///
7500/// ```test_harness,no_run
7501/// # extern crate hyper;
7502/// # extern crate hyper_rustls;
7503/// # extern crate google_notebooks1 as notebooks1;
7504/// # async fn dox() {
7505/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7506///
7507/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7508/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7509/// #     .with_native_roots()
7510/// #     .unwrap()
7511/// #     .https_only()
7512/// #     .enable_http2()
7513/// #     .build();
7514///
7515/// # let executor = hyper_util::rt::TokioExecutor::new();
7516/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7517/// #     secret,
7518/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7519/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7520/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7521/// #     ),
7522/// # ).build().await.unwrap();
7523///
7524/// # let client = hyper_util::client::legacy::Client::builder(
7525/// #     hyper_util::rt::TokioExecutor::new()
7526/// # )
7527/// # .build(
7528/// #     hyper_rustls::HttpsConnectorBuilder::new()
7529/// #         .with_native_roots()
7530/// #         .unwrap()
7531/// #         .https_or_http()
7532/// #         .enable_http2()
7533/// #         .build()
7534/// # );
7535/// # let mut hub = AIPlatformNotebooks::new(client, auth);
7536/// // You can configure optional parameters by calling the respective setters at will, and
7537/// // execute the final call using `doit()`.
7538/// // Values shown here are possibly random and not representative !
7539/// let result = hub.projects().locations_instances_get_iam_policy("resource")
7540///              .options_requested_policy_version(-7)
7541///              .doit().await;
7542/// # }
7543/// ```
7544pub struct ProjectLocationInstanceGetIamPolicyCall<'a, C>
7545where
7546    C: 'a,
7547{
7548    hub: &'a AIPlatformNotebooks<C>,
7549    _resource: String,
7550    _options_requested_policy_version: Option<i32>,
7551    _delegate: Option<&'a mut dyn common::Delegate>,
7552    _additional_params: HashMap<String, String>,
7553    _scopes: BTreeSet<String>,
7554}
7555
7556impl<'a, C> common::CallBuilder for ProjectLocationInstanceGetIamPolicyCall<'a, C> {}
7557
7558impl<'a, C> ProjectLocationInstanceGetIamPolicyCall<'a, C>
7559where
7560    C: common::Connector,
7561{
7562    /// Perform the operation you have build so far.
7563    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
7564        use std::borrow::Cow;
7565        use std::io::{Read, Seek};
7566
7567        use common::{url::Params, ToParts};
7568        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7569
7570        let mut dd = common::DefaultDelegate;
7571        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7572        dlg.begin(common::MethodInfo {
7573            id: "notebooks.projects.locations.instances.getIamPolicy",
7574            http_method: hyper::Method::GET,
7575        });
7576
7577        for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
7578            if self._additional_params.contains_key(field) {
7579                dlg.finished(false);
7580                return Err(common::Error::FieldClash(field));
7581            }
7582        }
7583
7584        let mut params = Params::with_capacity(4 + self._additional_params.len());
7585        params.push("resource", self._resource);
7586        if let Some(value) = self._options_requested_policy_version.as_ref() {
7587            params.push("options.requestedPolicyVersion", value.to_string());
7588        }
7589
7590        params.extend(self._additional_params.iter());
7591
7592        params.push("alt", "json");
7593        let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
7594        if self._scopes.is_empty() {
7595            self._scopes
7596                .insert(Scope::CloudPlatform.as_ref().to_string());
7597        }
7598
7599        #[allow(clippy::single_element_loop)]
7600        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
7601            url = params.uri_replacement(url, param_name, find_this, true);
7602        }
7603        {
7604            let to_remove = ["resource"];
7605            params.remove_params(&to_remove);
7606        }
7607
7608        let url = params.parse_with_url(&url);
7609
7610        loop {
7611            let token = match self
7612                .hub
7613                .auth
7614                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7615                .await
7616            {
7617                Ok(token) => token,
7618                Err(e) => match dlg.token(e) {
7619                    Ok(token) => token,
7620                    Err(e) => {
7621                        dlg.finished(false);
7622                        return Err(common::Error::MissingToken(e));
7623                    }
7624                },
7625            };
7626            let mut req_result = {
7627                let client = &self.hub.client;
7628                dlg.pre_request();
7629                let mut req_builder = hyper::Request::builder()
7630                    .method(hyper::Method::GET)
7631                    .uri(url.as_str())
7632                    .header(USER_AGENT, self.hub._user_agent.clone());
7633
7634                if let Some(token) = token.as_ref() {
7635                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7636                }
7637
7638                let request = req_builder
7639                    .header(CONTENT_LENGTH, 0_u64)
7640                    .body(common::to_body::<String>(None));
7641
7642                client.request(request.unwrap()).await
7643            };
7644
7645            match req_result {
7646                Err(err) => {
7647                    if let common::Retry::After(d) = dlg.http_error(&err) {
7648                        sleep(d).await;
7649                        continue;
7650                    }
7651                    dlg.finished(false);
7652                    return Err(common::Error::HttpError(err));
7653                }
7654                Ok(res) => {
7655                    let (mut parts, body) = res.into_parts();
7656                    let mut body = common::Body::new(body);
7657                    if !parts.status.is_success() {
7658                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7659                        let error = serde_json::from_str(&common::to_string(&bytes));
7660                        let response = common::to_response(parts, bytes.into());
7661
7662                        if let common::Retry::After(d) =
7663                            dlg.http_failure(&response, error.as_ref().ok())
7664                        {
7665                            sleep(d).await;
7666                            continue;
7667                        }
7668
7669                        dlg.finished(false);
7670
7671                        return Err(match error {
7672                            Ok(value) => common::Error::BadRequest(value),
7673                            _ => common::Error::Failure(response),
7674                        });
7675                    }
7676                    let response = {
7677                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7678                        let encoded = common::to_string(&bytes);
7679                        match serde_json::from_str(&encoded) {
7680                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7681                            Err(error) => {
7682                                dlg.response_json_decode_error(&encoded, &error);
7683                                return Err(common::Error::JsonDecodeError(
7684                                    encoded.to_string(),
7685                                    error,
7686                                ));
7687                            }
7688                        }
7689                    };
7690
7691                    dlg.finished(true);
7692                    return Ok(response);
7693                }
7694            }
7695        }
7696    }
7697
7698    /// 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.
7699    ///
7700    /// Sets the *resource* path property to the given value.
7701    ///
7702    /// Even though the property as already been set when instantiating this call,
7703    /// we provide this method for API completeness.
7704    pub fn resource(mut self, new_value: &str) -> ProjectLocationInstanceGetIamPolicyCall<'a, C> {
7705        self._resource = new_value.to_string();
7706        self
7707    }
7708    /// 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).
7709    ///
7710    /// Sets the *options.requested policy version* query property to the given value.
7711    pub fn options_requested_policy_version(
7712        mut self,
7713        new_value: i32,
7714    ) -> ProjectLocationInstanceGetIamPolicyCall<'a, C> {
7715        self._options_requested_policy_version = Some(new_value);
7716        self
7717    }
7718    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7719    /// while executing the actual API request.
7720    ///
7721    /// ````text
7722    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7723    /// ````
7724    ///
7725    /// Sets the *delegate* property to the given value.
7726    pub fn delegate(
7727        mut self,
7728        new_value: &'a mut dyn common::Delegate,
7729    ) -> ProjectLocationInstanceGetIamPolicyCall<'a, C> {
7730        self._delegate = Some(new_value);
7731        self
7732    }
7733
7734    /// Set any additional parameter of the query string used in the request.
7735    /// It should be used to set parameters which are not yet available through their own
7736    /// setters.
7737    ///
7738    /// Please note that this method must not be used to set any of the known parameters
7739    /// which have their own setter method. If done anyway, the request will fail.
7740    ///
7741    /// # Additional Parameters
7742    ///
7743    /// * *$.xgafv* (query-string) - V1 error format.
7744    /// * *access_token* (query-string) - OAuth access token.
7745    /// * *alt* (query-string) - Data format for response.
7746    /// * *callback* (query-string) - JSONP
7747    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7748    /// * *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.
7749    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7750    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7751    /// * *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.
7752    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7753    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7754    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceGetIamPolicyCall<'a, C>
7755    where
7756        T: AsRef<str>,
7757    {
7758        self._additional_params
7759            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7760        self
7761    }
7762
7763    /// Identifies the authorization scope for the method you are building.
7764    ///
7765    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7766    /// [`Scope::CloudPlatform`].
7767    ///
7768    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7769    /// tokens for more than one scope.
7770    ///
7771    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7772    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7773    /// sufficient, a read-write scope will do as well.
7774    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceGetIamPolicyCall<'a, C>
7775    where
7776        St: AsRef<str>,
7777    {
7778        self._scopes.insert(String::from(scope.as_ref()));
7779        self
7780    }
7781    /// Identifies the authorization scope(s) for the method you are building.
7782    ///
7783    /// See [`Self::add_scope()`] for details.
7784    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceGetIamPolicyCall<'a, C>
7785    where
7786        I: IntoIterator<Item = St>,
7787        St: AsRef<str>,
7788    {
7789        self._scopes
7790            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7791        self
7792    }
7793
7794    /// Removes all scopes, and no default scope will be used either.
7795    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7796    /// for details).
7797    pub fn clear_scopes(mut self) -> ProjectLocationInstanceGetIamPolicyCall<'a, C> {
7798        self._scopes.clear();
7799        self
7800    }
7801}
7802
7803/// Checks whether a notebook instance is healthy.
7804///
7805/// A builder for the *locations.instances.getInstanceHealth* method supported by a *project* resource.
7806/// It is not used directly, but through a [`ProjectMethods`] instance.
7807///
7808/// # Example
7809///
7810/// Instantiate a resource method builder
7811///
7812/// ```test_harness,no_run
7813/// # extern crate hyper;
7814/// # extern crate hyper_rustls;
7815/// # extern crate google_notebooks1 as notebooks1;
7816/// # async fn dox() {
7817/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7818///
7819/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7820/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7821/// #     .with_native_roots()
7822/// #     .unwrap()
7823/// #     .https_only()
7824/// #     .enable_http2()
7825/// #     .build();
7826///
7827/// # let executor = hyper_util::rt::TokioExecutor::new();
7828/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7829/// #     secret,
7830/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7831/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7832/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7833/// #     ),
7834/// # ).build().await.unwrap();
7835///
7836/// # let client = hyper_util::client::legacy::Client::builder(
7837/// #     hyper_util::rt::TokioExecutor::new()
7838/// # )
7839/// # .build(
7840/// #     hyper_rustls::HttpsConnectorBuilder::new()
7841/// #         .with_native_roots()
7842/// #         .unwrap()
7843/// #         .https_or_http()
7844/// #         .enable_http2()
7845/// #         .build()
7846/// # );
7847/// # let mut hub = AIPlatformNotebooks::new(client, auth);
7848/// // You can configure optional parameters by calling the respective setters at will, and
7849/// // execute the final call using `doit()`.
7850/// // Values shown here are possibly random and not representative !
7851/// let result = hub.projects().locations_instances_get_instance_health("name")
7852///              .doit().await;
7853/// # }
7854/// ```
7855pub struct ProjectLocationInstanceGetInstanceHealthCall<'a, C>
7856where
7857    C: 'a,
7858{
7859    hub: &'a AIPlatformNotebooks<C>,
7860    _name: String,
7861    _delegate: Option<&'a mut dyn common::Delegate>,
7862    _additional_params: HashMap<String, String>,
7863    _scopes: BTreeSet<String>,
7864}
7865
7866impl<'a, C> common::CallBuilder for ProjectLocationInstanceGetInstanceHealthCall<'a, C> {}
7867
7868impl<'a, C> ProjectLocationInstanceGetInstanceHealthCall<'a, C>
7869where
7870    C: common::Connector,
7871{
7872    /// Perform the operation you have build so far.
7873    pub async fn doit(mut self) -> common::Result<(common::Response, GetInstanceHealthResponse)> {
7874        use std::borrow::Cow;
7875        use std::io::{Read, Seek};
7876
7877        use common::{url::Params, ToParts};
7878        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7879
7880        let mut dd = common::DefaultDelegate;
7881        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7882        dlg.begin(common::MethodInfo {
7883            id: "notebooks.projects.locations.instances.getInstanceHealth",
7884            http_method: hyper::Method::GET,
7885        });
7886
7887        for &field in ["alt", "name"].iter() {
7888            if self._additional_params.contains_key(field) {
7889                dlg.finished(false);
7890                return Err(common::Error::FieldClash(field));
7891            }
7892        }
7893
7894        let mut params = Params::with_capacity(3 + self._additional_params.len());
7895        params.push("name", self._name);
7896
7897        params.extend(self._additional_params.iter());
7898
7899        params.push("alt", "json");
7900        let mut url = self.hub._base_url.clone() + "v1/{+name}:getInstanceHealth";
7901        if self._scopes.is_empty() {
7902            self._scopes
7903                .insert(Scope::CloudPlatform.as_ref().to_string());
7904        }
7905
7906        #[allow(clippy::single_element_loop)]
7907        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7908            url = params.uri_replacement(url, param_name, find_this, true);
7909        }
7910        {
7911            let to_remove = ["name"];
7912            params.remove_params(&to_remove);
7913        }
7914
7915        let url = params.parse_with_url(&url);
7916
7917        loop {
7918            let token = match self
7919                .hub
7920                .auth
7921                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7922                .await
7923            {
7924                Ok(token) => token,
7925                Err(e) => match dlg.token(e) {
7926                    Ok(token) => token,
7927                    Err(e) => {
7928                        dlg.finished(false);
7929                        return Err(common::Error::MissingToken(e));
7930                    }
7931                },
7932            };
7933            let mut req_result = {
7934                let client = &self.hub.client;
7935                dlg.pre_request();
7936                let mut req_builder = hyper::Request::builder()
7937                    .method(hyper::Method::GET)
7938                    .uri(url.as_str())
7939                    .header(USER_AGENT, self.hub._user_agent.clone());
7940
7941                if let Some(token) = token.as_ref() {
7942                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7943                }
7944
7945                let request = req_builder
7946                    .header(CONTENT_LENGTH, 0_u64)
7947                    .body(common::to_body::<String>(None));
7948
7949                client.request(request.unwrap()).await
7950            };
7951
7952            match req_result {
7953                Err(err) => {
7954                    if let common::Retry::After(d) = dlg.http_error(&err) {
7955                        sleep(d).await;
7956                        continue;
7957                    }
7958                    dlg.finished(false);
7959                    return Err(common::Error::HttpError(err));
7960                }
7961                Ok(res) => {
7962                    let (mut parts, body) = res.into_parts();
7963                    let mut body = common::Body::new(body);
7964                    if !parts.status.is_success() {
7965                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7966                        let error = serde_json::from_str(&common::to_string(&bytes));
7967                        let response = common::to_response(parts, bytes.into());
7968
7969                        if let common::Retry::After(d) =
7970                            dlg.http_failure(&response, error.as_ref().ok())
7971                        {
7972                            sleep(d).await;
7973                            continue;
7974                        }
7975
7976                        dlg.finished(false);
7977
7978                        return Err(match error {
7979                            Ok(value) => common::Error::BadRequest(value),
7980                            _ => common::Error::Failure(response),
7981                        });
7982                    }
7983                    let response = {
7984                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7985                        let encoded = common::to_string(&bytes);
7986                        match serde_json::from_str(&encoded) {
7987                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7988                            Err(error) => {
7989                                dlg.response_json_decode_error(&encoded, &error);
7990                                return Err(common::Error::JsonDecodeError(
7991                                    encoded.to_string(),
7992                                    error,
7993                                ));
7994                            }
7995                        }
7996                    };
7997
7998                    dlg.finished(true);
7999                    return Ok(response);
8000                }
8001            }
8002        }
8003    }
8004
8005    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
8006    ///
8007    /// Sets the *name* path property to the given value.
8008    ///
8009    /// Even though the property as already been set when instantiating this call,
8010    /// we provide this method for API completeness.
8011    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceGetInstanceHealthCall<'a, C> {
8012        self._name = new_value.to_string();
8013        self
8014    }
8015    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8016    /// while executing the actual API request.
8017    ///
8018    /// ````text
8019    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8020    /// ````
8021    ///
8022    /// Sets the *delegate* property to the given value.
8023    pub fn delegate(
8024        mut self,
8025        new_value: &'a mut dyn common::Delegate,
8026    ) -> ProjectLocationInstanceGetInstanceHealthCall<'a, C> {
8027        self._delegate = Some(new_value);
8028        self
8029    }
8030
8031    /// Set any additional parameter of the query string used in the request.
8032    /// It should be used to set parameters which are not yet available through their own
8033    /// setters.
8034    ///
8035    /// Please note that this method must not be used to set any of the known parameters
8036    /// which have their own setter method. If done anyway, the request will fail.
8037    ///
8038    /// # Additional Parameters
8039    ///
8040    /// * *$.xgafv* (query-string) - V1 error format.
8041    /// * *access_token* (query-string) - OAuth access token.
8042    /// * *alt* (query-string) - Data format for response.
8043    /// * *callback* (query-string) - JSONP
8044    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8045    /// * *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.
8046    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8047    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8048    /// * *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.
8049    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8050    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8051    pub fn param<T>(
8052        mut self,
8053        name: T,
8054        value: T,
8055    ) -> ProjectLocationInstanceGetInstanceHealthCall<'a, C>
8056    where
8057        T: AsRef<str>,
8058    {
8059        self._additional_params
8060            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8061        self
8062    }
8063
8064    /// Identifies the authorization scope for the method you are building.
8065    ///
8066    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8067    /// [`Scope::CloudPlatform`].
8068    ///
8069    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8070    /// tokens for more than one scope.
8071    ///
8072    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8073    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8074    /// sufficient, a read-write scope will do as well.
8075    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceGetInstanceHealthCall<'a, C>
8076    where
8077        St: AsRef<str>,
8078    {
8079        self._scopes.insert(String::from(scope.as_ref()));
8080        self
8081    }
8082    /// Identifies the authorization scope(s) for the method you are building.
8083    ///
8084    /// See [`Self::add_scope()`] for details.
8085    pub fn add_scopes<I, St>(
8086        mut self,
8087        scopes: I,
8088    ) -> ProjectLocationInstanceGetInstanceHealthCall<'a, C>
8089    where
8090        I: IntoIterator<Item = St>,
8091        St: AsRef<str>,
8092    {
8093        self._scopes
8094            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8095        self
8096    }
8097
8098    /// Removes all scopes, and no default scope will be used either.
8099    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8100    /// for details).
8101    pub fn clear_scopes(mut self) -> ProjectLocationInstanceGetInstanceHealthCall<'a, C> {
8102        self._scopes.clear();
8103        self
8104    }
8105}
8106
8107/// Checks whether a notebook instance is upgradable.
8108///
8109/// A builder for the *locations.instances.isUpgradeable* method supported by a *project* resource.
8110/// It is not used directly, but through a [`ProjectMethods`] instance.
8111///
8112/// # Example
8113///
8114/// Instantiate a resource method builder
8115///
8116/// ```test_harness,no_run
8117/// # extern crate hyper;
8118/// # extern crate hyper_rustls;
8119/// # extern crate google_notebooks1 as notebooks1;
8120/// # async fn dox() {
8121/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8122///
8123/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8124/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8125/// #     .with_native_roots()
8126/// #     .unwrap()
8127/// #     .https_only()
8128/// #     .enable_http2()
8129/// #     .build();
8130///
8131/// # let executor = hyper_util::rt::TokioExecutor::new();
8132/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8133/// #     secret,
8134/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8135/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8136/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8137/// #     ),
8138/// # ).build().await.unwrap();
8139///
8140/// # let client = hyper_util::client::legacy::Client::builder(
8141/// #     hyper_util::rt::TokioExecutor::new()
8142/// # )
8143/// # .build(
8144/// #     hyper_rustls::HttpsConnectorBuilder::new()
8145/// #         .with_native_roots()
8146/// #         .unwrap()
8147/// #         .https_or_http()
8148/// #         .enable_http2()
8149/// #         .build()
8150/// # );
8151/// # let mut hub = AIPlatformNotebooks::new(client, auth);
8152/// // You can configure optional parameters by calling the respective setters at will, and
8153/// // execute the final call using `doit()`.
8154/// // Values shown here are possibly random and not representative !
8155/// let result = hub.projects().locations_instances_is_upgradeable("notebookInstance")
8156///              .type_("dolor")
8157///              .doit().await;
8158/// # }
8159/// ```
8160pub struct ProjectLocationInstanceIsUpgradeableCall<'a, C>
8161where
8162    C: 'a,
8163{
8164    hub: &'a AIPlatformNotebooks<C>,
8165    _notebook_instance: String,
8166    _type_: Option<String>,
8167    _delegate: Option<&'a mut dyn common::Delegate>,
8168    _additional_params: HashMap<String, String>,
8169    _scopes: BTreeSet<String>,
8170}
8171
8172impl<'a, C> common::CallBuilder for ProjectLocationInstanceIsUpgradeableCall<'a, C> {}
8173
8174impl<'a, C> ProjectLocationInstanceIsUpgradeableCall<'a, C>
8175where
8176    C: common::Connector,
8177{
8178    /// Perform the operation you have build so far.
8179    pub async fn doit(
8180        mut self,
8181    ) -> common::Result<(common::Response, IsInstanceUpgradeableResponse)> {
8182        use std::borrow::Cow;
8183        use std::io::{Read, Seek};
8184
8185        use common::{url::Params, ToParts};
8186        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8187
8188        let mut dd = common::DefaultDelegate;
8189        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8190        dlg.begin(common::MethodInfo {
8191            id: "notebooks.projects.locations.instances.isUpgradeable",
8192            http_method: hyper::Method::GET,
8193        });
8194
8195        for &field in ["alt", "notebookInstance", "type"].iter() {
8196            if self._additional_params.contains_key(field) {
8197                dlg.finished(false);
8198                return Err(common::Error::FieldClash(field));
8199            }
8200        }
8201
8202        let mut params = Params::with_capacity(4 + self._additional_params.len());
8203        params.push("notebookInstance", self._notebook_instance);
8204        if let Some(value) = self._type_.as_ref() {
8205            params.push("type", value);
8206        }
8207
8208        params.extend(self._additional_params.iter());
8209
8210        params.push("alt", "json");
8211        let mut url = self.hub._base_url.clone() + "v1/{+notebookInstance}:isUpgradeable";
8212        if self._scopes.is_empty() {
8213            self._scopes
8214                .insert(Scope::CloudPlatform.as_ref().to_string());
8215        }
8216
8217        #[allow(clippy::single_element_loop)]
8218        for &(find_this, param_name) in [("{+notebookInstance}", "notebookInstance")].iter() {
8219            url = params.uri_replacement(url, param_name, find_this, true);
8220        }
8221        {
8222            let to_remove = ["notebookInstance"];
8223            params.remove_params(&to_remove);
8224        }
8225
8226        let url = params.parse_with_url(&url);
8227
8228        loop {
8229            let token = match self
8230                .hub
8231                .auth
8232                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8233                .await
8234            {
8235                Ok(token) => token,
8236                Err(e) => match dlg.token(e) {
8237                    Ok(token) => token,
8238                    Err(e) => {
8239                        dlg.finished(false);
8240                        return Err(common::Error::MissingToken(e));
8241                    }
8242                },
8243            };
8244            let mut req_result = {
8245                let client = &self.hub.client;
8246                dlg.pre_request();
8247                let mut req_builder = hyper::Request::builder()
8248                    .method(hyper::Method::GET)
8249                    .uri(url.as_str())
8250                    .header(USER_AGENT, self.hub._user_agent.clone());
8251
8252                if let Some(token) = token.as_ref() {
8253                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8254                }
8255
8256                let request = req_builder
8257                    .header(CONTENT_LENGTH, 0_u64)
8258                    .body(common::to_body::<String>(None));
8259
8260                client.request(request.unwrap()).await
8261            };
8262
8263            match req_result {
8264                Err(err) => {
8265                    if let common::Retry::After(d) = dlg.http_error(&err) {
8266                        sleep(d).await;
8267                        continue;
8268                    }
8269                    dlg.finished(false);
8270                    return Err(common::Error::HttpError(err));
8271                }
8272                Ok(res) => {
8273                    let (mut parts, body) = res.into_parts();
8274                    let mut body = common::Body::new(body);
8275                    if !parts.status.is_success() {
8276                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8277                        let error = serde_json::from_str(&common::to_string(&bytes));
8278                        let response = common::to_response(parts, bytes.into());
8279
8280                        if let common::Retry::After(d) =
8281                            dlg.http_failure(&response, error.as_ref().ok())
8282                        {
8283                            sleep(d).await;
8284                            continue;
8285                        }
8286
8287                        dlg.finished(false);
8288
8289                        return Err(match error {
8290                            Ok(value) => common::Error::BadRequest(value),
8291                            _ => common::Error::Failure(response),
8292                        });
8293                    }
8294                    let response = {
8295                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8296                        let encoded = common::to_string(&bytes);
8297                        match serde_json::from_str(&encoded) {
8298                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8299                            Err(error) => {
8300                                dlg.response_json_decode_error(&encoded, &error);
8301                                return Err(common::Error::JsonDecodeError(
8302                                    encoded.to_string(),
8303                                    error,
8304                                ));
8305                            }
8306                        }
8307                    };
8308
8309                    dlg.finished(true);
8310                    return Ok(response);
8311                }
8312            }
8313        }
8314    }
8315
8316    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
8317    ///
8318    /// Sets the *notebook instance* path property to the given value.
8319    ///
8320    /// Even though the property as already been set when instantiating this call,
8321    /// we provide this method for API completeness.
8322    pub fn notebook_instance(
8323        mut self,
8324        new_value: &str,
8325    ) -> ProjectLocationInstanceIsUpgradeableCall<'a, C> {
8326        self._notebook_instance = new_value.to_string();
8327        self
8328    }
8329    /// Optional. The optional UpgradeType. Setting this field will search for additional compute images to upgrade this instance.
8330    ///
8331    /// Sets the *type* query property to the given value.
8332    pub fn type_(mut self, new_value: &str) -> ProjectLocationInstanceIsUpgradeableCall<'a, C> {
8333        self._type_ = Some(new_value.to_string());
8334        self
8335    }
8336    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8337    /// while executing the actual API request.
8338    ///
8339    /// ````text
8340    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8341    /// ````
8342    ///
8343    /// Sets the *delegate* property to the given value.
8344    pub fn delegate(
8345        mut self,
8346        new_value: &'a mut dyn common::Delegate,
8347    ) -> ProjectLocationInstanceIsUpgradeableCall<'a, C> {
8348        self._delegate = Some(new_value);
8349        self
8350    }
8351
8352    /// Set any additional parameter of the query string used in the request.
8353    /// It should be used to set parameters which are not yet available through their own
8354    /// setters.
8355    ///
8356    /// Please note that this method must not be used to set any of the known parameters
8357    /// which have their own setter method. If done anyway, the request will fail.
8358    ///
8359    /// # Additional Parameters
8360    ///
8361    /// * *$.xgafv* (query-string) - V1 error format.
8362    /// * *access_token* (query-string) - OAuth access token.
8363    /// * *alt* (query-string) - Data format for response.
8364    /// * *callback* (query-string) - JSONP
8365    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8366    /// * *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.
8367    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8368    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8369    /// * *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.
8370    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8371    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8372    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceIsUpgradeableCall<'a, C>
8373    where
8374        T: AsRef<str>,
8375    {
8376        self._additional_params
8377            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8378        self
8379    }
8380
8381    /// Identifies the authorization scope for the method you are building.
8382    ///
8383    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8384    /// [`Scope::CloudPlatform`].
8385    ///
8386    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8387    /// tokens for more than one scope.
8388    ///
8389    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8390    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8391    /// sufficient, a read-write scope will do as well.
8392    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceIsUpgradeableCall<'a, C>
8393    where
8394        St: AsRef<str>,
8395    {
8396        self._scopes.insert(String::from(scope.as_ref()));
8397        self
8398    }
8399    /// Identifies the authorization scope(s) for the method you are building.
8400    ///
8401    /// See [`Self::add_scope()`] for details.
8402    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceIsUpgradeableCall<'a, C>
8403    where
8404        I: IntoIterator<Item = St>,
8405        St: AsRef<str>,
8406    {
8407        self._scopes
8408            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8409        self
8410    }
8411
8412    /// Removes all scopes, and no default scope will be used either.
8413    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8414    /// for details).
8415    pub fn clear_scopes(mut self) -> ProjectLocationInstanceIsUpgradeableCall<'a, C> {
8416        self._scopes.clear();
8417        self
8418    }
8419}
8420
8421/// Lists instances in a given project and location.
8422///
8423/// A builder for the *locations.instances.list* method supported by a *project* resource.
8424/// It is not used directly, but through a [`ProjectMethods`] instance.
8425///
8426/// # Example
8427///
8428/// Instantiate a resource method builder
8429///
8430/// ```test_harness,no_run
8431/// # extern crate hyper;
8432/// # extern crate hyper_rustls;
8433/// # extern crate google_notebooks1 as notebooks1;
8434/// # async fn dox() {
8435/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8436///
8437/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8438/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8439/// #     .with_native_roots()
8440/// #     .unwrap()
8441/// #     .https_only()
8442/// #     .enable_http2()
8443/// #     .build();
8444///
8445/// # let executor = hyper_util::rt::TokioExecutor::new();
8446/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8447/// #     secret,
8448/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8449/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8450/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8451/// #     ),
8452/// # ).build().await.unwrap();
8453///
8454/// # let client = hyper_util::client::legacy::Client::builder(
8455/// #     hyper_util::rt::TokioExecutor::new()
8456/// # )
8457/// # .build(
8458/// #     hyper_rustls::HttpsConnectorBuilder::new()
8459/// #         .with_native_roots()
8460/// #         .unwrap()
8461/// #         .https_or_http()
8462/// #         .enable_http2()
8463/// #         .build()
8464/// # );
8465/// # let mut hub = AIPlatformNotebooks::new(client, auth);
8466/// // You can configure optional parameters by calling the respective setters at will, and
8467/// // execute the final call using `doit()`.
8468/// // Values shown here are possibly random and not representative !
8469/// let result = hub.projects().locations_instances_list("parent")
8470///              .page_token("eos")
8471///              .page_size(-86)
8472///              .order_by("sed")
8473///              .filter("duo")
8474///              .doit().await;
8475/// # }
8476/// ```
8477pub struct ProjectLocationInstanceListCall<'a, C>
8478where
8479    C: 'a,
8480{
8481    hub: &'a AIPlatformNotebooks<C>,
8482    _parent: String,
8483    _page_token: Option<String>,
8484    _page_size: Option<i32>,
8485    _order_by: Option<String>,
8486    _filter: Option<String>,
8487    _delegate: Option<&'a mut dyn common::Delegate>,
8488    _additional_params: HashMap<String, String>,
8489    _scopes: BTreeSet<String>,
8490}
8491
8492impl<'a, C> common::CallBuilder for ProjectLocationInstanceListCall<'a, C> {}
8493
8494impl<'a, C> ProjectLocationInstanceListCall<'a, C>
8495where
8496    C: common::Connector,
8497{
8498    /// Perform the operation you have build so far.
8499    pub async fn doit(mut self) -> common::Result<(common::Response, ListInstancesResponse)> {
8500        use std::borrow::Cow;
8501        use std::io::{Read, Seek};
8502
8503        use common::{url::Params, ToParts};
8504        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8505
8506        let mut dd = common::DefaultDelegate;
8507        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8508        dlg.begin(common::MethodInfo {
8509            id: "notebooks.projects.locations.instances.list",
8510            http_method: hyper::Method::GET,
8511        });
8512
8513        for &field in [
8514            "alt",
8515            "parent",
8516            "pageToken",
8517            "pageSize",
8518            "orderBy",
8519            "filter",
8520        ]
8521        .iter()
8522        {
8523            if self._additional_params.contains_key(field) {
8524                dlg.finished(false);
8525                return Err(common::Error::FieldClash(field));
8526            }
8527        }
8528
8529        let mut params = Params::with_capacity(7 + self._additional_params.len());
8530        params.push("parent", self._parent);
8531        if let Some(value) = self._page_token.as_ref() {
8532            params.push("pageToken", value);
8533        }
8534        if let Some(value) = self._page_size.as_ref() {
8535            params.push("pageSize", value.to_string());
8536        }
8537        if let Some(value) = self._order_by.as_ref() {
8538            params.push("orderBy", value);
8539        }
8540        if let Some(value) = self._filter.as_ref() {
8541            params.push("filter", value);
8542        }
8543
8544        params.extend(self._additional_params.iter());
8545
8546        params.push("alt", "json");
8547        let mut url = self.hub._base_url.clone() + "v1/{+parent}/instances";
8548        if self._scopes.is_empty() {
8549            self._scopes
8550                .insert(Scope::CloudPlatform.as_ref().to_string());
8551        }
8552
8553        #[allow(clippy::single_element_loop)]
8554        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8555            url = params.uri_replacement(url, param_name, find_this, true);
8556        }
8557        {
8558            let to_remove = ["parent"];
8559            params.remove_params(&to_remove);
8560        }
8561
8562        let url = params.parse_with_url(&url);
8563
8564        loop {
8565            let token = match self
8566                .hub
8567                .auth
8568                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8569                .await
8570            {
8571                Ok(token) => token,
8572                Err(e) => match dlg.token(e) {
8573                    Ok(token) => token,
8574                    Err(e) => {
8575                        dlg.finished(false);
8576                        return Err(common::Error::MissingToken(e));
8577                    }
8578                },
8579            };
8580            let mut req_result = {
8581                let client = &self.hub.client;
8582                dlg.pre_request();
8583                let mut req_builder = hyper::Request::builder()
8584                    .method(hyper::Method::GET)
8585                    .uri(url.as_str())
8586                    .header(USER_AGENT, self.hub._user_agent.clone());
8587
8588                if let Some(token) = token.as_ref() {
8589                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8590                }
8591
8592                let request = req_builder
8593                    .header(CONTENT_LENGTH, 0_u64)
8594                    .body(common::to_body::<String>(None));
8595
8596                client.request(request.unwrap()).await
8597            };
8598
8599            match req_result {
8600                Err(err) => {
8601                    if let common::Retry::After(d) = dlg.http_error(&err) {
8602                        sleep(d).await;
8603                        continue;
8604                    }
8605                    dlg.finished(false);
8606                    return Err(common::Error::HttpError(err));
8607                }
8608                Ok(res) => {
8609                    let (mut parts, body) = res.into_parts();
8610                    let mut body = common::Body::new(body);
8611                    if !parts.status.is_success() {
8612                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8613                        let error = serde_json::from_str(&common::to_string(&bytes));
8614                        let response = common::to_response(parts, bytes.into());
8615
8616                        if let common::Retry::After(d) =
8617                            dlg.http_failure(&response, error.as_ref().ok())
8618                        {
8619                            sleep(d).await;
8620                            continue;
8621                        }
8622
8623                        dlg.finished(false);
8624
8625                        return Err(match error {
8626                            Ok(value) => common::Error::BadRequest(value),
8627                            _ => common::Error::Failure(response),
8628                        });
8629                    }
8630                    let response = {
8631                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8632                        let encoded = common::to_string(&bytes);
8633                        match serde_json::from_str(&encoded) {
8634                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8635                            Err(error) => {
8636                                dlg.response_json_decode_error(&encoded, &error);
8637                                return Err(common::Error::JsonDecodeError(
8638                                    encoded.to_string(),
8639                                    error,
8640                                ));
8641                            }
8642                        }
8643                    };
8644
8645                    dlg.finished(true);
8646                    return Ok(response);
8647                }
8648            }
8649        }
8650    }
8651
8652    /// Required. Format: `parent=projects/{project_id}/locations/{location}`
8653    ///
8654    /// Sets the *parent* path property to the given value.
8655    ///
8656    /// Even though the property as already been set when instantiating this call,
8657    /// we provide this method for API completeness.
8658    pub fn parent(mut self, new_value: &str) -> ProjectLocationInstanceListCall<'a, C> {
8659        self._parent = new_value.to_string();
8660        self
8661    }
8662    /// A previous returned page token that can be used to continue listing from the last result.
8663    ///
8664    /// Sets the *page token* query property to the given value.
8665    pub fn page_token(mut self, new_value: &str) -> ProjectLocationInstanceListCall<'a, C> {
8666        self._page_token = Some(new_value.to_string());
8667        self
8668    }
8669    /// Maximum return size of the list call.
8670    ///
8671    /// Sets the *page size* query property to the given value.
8672    pub fn page_size(mut self, new_value: i32) -> ProjectLocationInstanceListCall<'a, C> {
8673        self._page_size = Some(new_value);
8674        self
8675    }
8676    /// Optional. Sort results. Supported values are "name", "name desc" or "" (unsorted).
8677    ///
8678    /// Sets the *order by* query property to the given value.
8679    pub fn order_by(mut self, new_value: &str) -> ProjectLocationInstanceListCall<'a, C> {
8680        self._order_by = Some(new_value.to_string());
8681        self
8682    }
8683    /// Optional. List filter.
8684    ///
8685    /// Sets the *filter* query property to the given value.
8686    pub fn filter(mut self, new_value: &str) -> ProjectLocationInstanceListCall<'a, C> {
8687        self._filter = Some(new_value.to_string());
8688        self
8689    }
8690    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8691    /// while executing the actual API request.
8692    ///
8693    /// ````text
8694    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8695    /// ````
8696    ///
8697    /// Sets the *delegate* property to the given value.
8698    pub fn delegate(
8699        mut self,
8700        new_value: &'a mut dyn common::Delegate,
8701    ) -> ProjectLocationInstanceListCall<'a, C> {
8702        self._delegate = Some(new_value);
8703        self
8704    }
8705
8706    /// Set any additional parameter of the query string used in the request.
8707    /// It should be used to set parameters which are not yet available through their own
8708    /// setters.
8709    ///
8710    /// Please note that this method must not be used to set any of the known parameters
8711    /// which have their own setter method. If done anyway, the request will fail.
8712    ///
8713    /// # Additional Parameters
8714    ///
8715    /// * *$.xgafv* (query-string) - V1 error format.
8716    /// * *access_token* (query-string) - OAuth access token.
8717    /// * *alt* (query-string) - Data format for response.
8718    /// * *callback* (query-string) - JSONP
8719    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8720    /// * *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.
8721    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8722    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8723    /// * *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.
8724    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8725    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8726    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceListCall<'a, C>
8727    where
8728        T: AsRef<str>,
8729    {
8730        self._additional_params
8731            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8732        self
8733    }
8734
8735    /// Identifies the authorization scope for the method you are building.
8736    ///
8737    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8738    /// [`Scope::CloudPlatform`].
8739    ///
8740    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8741    /// tokens for more than one scope.
8742    ///
8743    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8744    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8745    /// sufficient, a read-write scope will do as well.
8746    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceListCall<'a, C>
8747    where
8748        St: AsRef<str>,
8749    {
8750        self._scopes.insert(String::from(scope.as_ref()));
8751        self
8752    }
8753    /// Identifies the authorization scope(s) for the method you are building.
8754    ///
8755    /// See [`Self::add_scope()`] for details.
8756    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceListCall<'a, C>
8757    where
8758        I: IntoIterator<Item = St>,
8759        St: AsRef<str>,
8760    {
8761        self._scopes
8762            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8763        self
8764    }
8765
8766    /// Removes all scopes, and no default scope will be used either.
8767    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8768    /// for details).
8769    pub fn clear_scopes(mut self) -> ProjectLocationInstanceListCall<'a, C> {
8770        self._scopes.clear();
8771        self
8772    }
8773}
8774
8775/// Migrates an existing User-Managed Notebook to Workbench Instances.
8776///
8777/// A builder for the *locations.instances.migrate* method supported by a *project* resource.
8778/// It is not used directly, but through a [`ProjectMethods`] instance.
8779///
8780/// # Example
8781///
8782/// Instantiate a resource method builder
8783///
8784/// ```test_harness,no_run
8785/// # extern crate hyper;
8786/// # extern crate hyper_rustls;
8787/// # extern crate google_notebooks1 as notebooks1;
8788/// use notebooks1::api::MigrateInstanceRequest;
8789/// # async fn dox() {
8790/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8791///
8792/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8793/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8794/// #     .with_native_roots()
8795/// #     .unwrap()
8796/// #     .https_only()
8797/// #     .enable_http2()
8798/// #     .build();
8799///
8800/// # let executor = hyper_util::rt::TokioExecutor::new();
8801/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8802/// #     secret,
8803/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8804/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8805/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8806/// #     ),
8807/// # ).build().await.unwrap();
8808///
8809/// # let client = hyper_util::client::legacy::Client::builder(
8810/// #     hyper_util::rt::TokioExecutor::new()
8811/// # )
8812/// # .build(
8813/// #     hyper_rustls::HttpsConnectorBuilder::new()
8814/// #         .with_native_roots()
8815/// #         .unwrap()
8816/// #         .https_or_http()
8817/// #         .enable_http2()
8818/// #         .build()
8819/// # );
8820/// # let mut hub = AIPlatformNotebooks::new(client, auth);
8821/// // As the method needs a request, you would usually fill it with the desired information
8822/// // into the respective structure. Some of the parts shown here might not be applicable !
8823/// // Values shown here are possibly random and not representative !
8824/// let mut req = MigrateInstanceRequest::default();
8825///
8826/// // You can configure optional parameters by calling the respective setters at will, and
8827/// // execute the final call using `doit()`.
8828/// // Values shown here are possibly random and not representative !
8829/// let result = hub.projects().locations_instances_migrate(req, "name")
8830///              .doit().await;
8831/// # }
8832/// ```
8833pub struct ProjectLocationInstanceMigrateCall<'a, C>
8834where
8835    C: 'a,
8836{
8837    hub: &'a AIPlatformNotebooks<C>,
8838    _request: MigrateInstanceRequest,
8839    _name: String,
8840    _delegate: Option<&'a mut dyn common::Delegate>,
8841    _additional_params: HashMap<String, String>,
8842    _scopes: BTreeSet<String>,
8843}
8844
8845impl<'a, C> common::CallBuilder for ProjectLocationInstanceMigrateCall<'a, C> {}
8846
8847impl<'a, C> ProjectLocationInstanceMigrateCall<'a, C>
8848where
8849    C: common::Connector,
8850{
8851    /// Perform the operation you have build so far.
8852    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
8853        use std::borrow::Cow;
8854        use std::io::{Read, Seek};
8855
8856        use common::{url::Params, ToParts};
8857        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8858
8859        let mut dd = common::DefaultDelegate;
8860        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8861        dlg.begin(common::MethodInfo {
8862            id: "notebooks.projects.locations.instances.migrate",
8863            http_method: hyper::Method::POST,
8864        });
8865
8866        for &field in ["alt", "name"].iter() {
8867            if self._additional_params.contains_key(field) {
8868                dlg.finished(false);
8869                return Err(common::Error::FieldClash(field));
8870            }
8871        }
8872
8873        let mut params = Params::with_capacity(4 + self._additional_params.len());
8874        params.push("name", self._name);
8875
8876        params.extend(self._additional_params.iter());
8877
8878        params.push("alt", "json");
8879        let mut url = self.hub._base_url.clone() + "v1/{+name}:migrate";
8880        if self._scopes.is_empty() {
8881            self._scopes
8882                .insert(Scope::CloudPlatform.as_ref().to_string());
8883        }
8884
8885        #[allow(clippy::single_element_loop)]
8886        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8887            url = params.uri_replacement(url, param_name, find_this, true);
8888        }
8889        {
8890            let to_remove = ["name"];
8891            params.remove_params(&to_remove);
8892        }
8893
8894        let url = params.parse_with_url(&url);
8895
8896        let mut json_mime_type = mime::APPLICATION_JSON;
8897        let mut request_value_reader = {
8898            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8899            common::remove_json_null_values(&mut value);
8900            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8901            serde_json::to_writer(&mut dst, &value).unwrap();
8902            dst
8903        };
8904        let request_size = request_value_reader
8905            .seek(std::io::SeekFrom::End(0))
8906            .unwrap();
8907        request_value_reader
8908            .seek(std::io::SeekFrom::Start(0))
8909            .unwrap();
8910
8911        loop {
8912            let token = match self
8913                .hub
8914                .auth
8915                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8916                .await
8917            {
8918                Ok(token) => token,
8919                Err(e) => match dlg.token(e) {
8920                    Ok(token) => token,
8921                    Err(e) => {
8922                        dlg.finished(false);
8923                        return Err(common::Error::MissingToken(e));
8924                    }
8925                },
8926            };
8927            request_value_reader
8928                .seek(std::io::SeekFrom::Start(0))
8929                .unwrap();
8930            let mut req_result = {
8931                let client = &self.hub.client;
8932                dlg.pre_request();
8933                let mut req_builder = hyper::Request::builder()
8934                    .method(hyper::Method::POST)
8935                    .uri(url.as_str())
8936                    .header(USER_AGENT, self.hub._user_agent.clone());
8937
8938                if let Some(token) = token.as_ref() {
8939                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8940                }
8941
8942                let request = req_builder
8943                    .header(CONTENT_TYPE, json_mime_type.to_string())
8944                    .header(CONTENT_LENGTH, request_size as u64)
8945                    .body(common::to_body(
8946                        request_value_reader.get_ref().clone().into(),
8947                    ));
8948
8949                client.request(request.unwrap()).await
8950            };
8951
8952            match req_result {
8953                Err(err) => {
8954                    if let common::Retry::After(d) = dlg.http_error(&err) {
8955                        sleep(d).await;
8956                        continue;
8957                    }
8958                    dlg.finished(false);
8959                    return Err(common::Error::HttpError(err));
8960                }
8961                Ok(res) => {
8962                    let (mut parts, body) = res.into_parts();
8963                    let mut body = common::Body::new(body);
8964                    if !parts.status.is_success() {
8965                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8966                        let error = serde_json::from_str(&common::to_string(&bytes));
8967                        let response = common::to_response(parts, bytes.into());
8968
8969                        if let common::Retry::After(d) =
8970                            dlg.http_failure(&response, error.as_ref().ok())
8971                        {
8972                            sleep(d).await;
8973                            continue;
8974                        }
8975
8976                        dlg.finished(false);
8977
8978                        return Err(match error {
8979                            Ok(value) => common::Error::BadRequest(value),
8980                            _ => common::Error::Failure(response),
8981                        });
8982                    }
8983                    let response = {
8984                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8985                        let encoded = common::to_string(&bytes);
8986                        match serde_json::from_str(&encoded) {
8987                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8988                            Err(error) => {
8989                                dlg.response_json_decode_error(&encoded, &error);
8990                                return Err(common::Error::JsonDecodeError(
8991                                    encoded.to_string(),
8992                                    error,
8993                                ));
8994                            }
8995                        }
8996                    };
8997
8998                    dlg.finished(true);
8999                    return Ok(response);
9000                }
9001            }
9002        }
9003    }
9004
9005    ///
9006    /// Sets the *request* property to the given value.
9007    ///
9008    /// Even though the property as already been set when instantiating this call,
9009    /// we provide this method for API completeness.
9010    pub fn request(
9011        mut self,
9012        new_value: MigrateInstanceRequest,
9013    ) -> ProjectLocationInstanceMigrateCall<'a, C> {
9014        self._request = new_value;
9015        self
9016    }
9017    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
9018    ///
9019    /// Sets the *name* path property to the given value.
9020    ///
9021    /// Even though the property as already been set when instantiating this call,
9022    /// we provide this method for API completeness.
9023    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceMigrateCall<'a, C> {
9024        self._name = new_value.to_string();
9025        self
9026    }
9027    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9028    /// while executing the actual API request.
9029    ///
9030    /// ````text
9031    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9032    /// ````
9033    ///
9034    /// Sets the *delegate* property to the given value.
9035    pub fn delegate(
9036        mut self,
9037        new_value: &'a mut dyn common::Delegate,
9038    ) -> ProjectLocationInstanceMigrateCall<'a, C> {
9039        self._delegate = Some(new_value);
9040        self
9041    }
9042
9043    /// Set any additional parameter of the query string used in the request.
9044    /// It should be used to set parameters which are not yet available through their own
9045    /// setters.
9046    ///
9047    /// Please note that this method must not be used to set any of the known parameters
9048    /// which have their own setter method. If done anyway, the request will fail.
9049    ///
9050    /// # Additional Parameters
9051    ///
9052    /// * *$.xgafv* (query-string) - V1 error format.
9053    /// * *access_token* (query-string) - OAuth access token.
9054    /// * *alt* (query-string) - Data format for response.
9055    /// * *callback* (query-string) - JSONP
9056    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9057    /// * *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.
9058    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9059    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9060    /// * *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.
9061    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9062    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9063    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceMigrateCall<'a, C>
9064    where
9065        T: AsRef<str>,
9066    {
9067        self._additional_params
9068            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9069        self
9070    }
9071
9072    /// Identifies the authorization scope for the method you are building.
9073    ///
9074    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9075    /// [`Scope::CloudPlatform`].
9076    ///
9077    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9078    /// tokens for more than one scope.
9079    ///
9080    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9081    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9082    /// sufficient, a read-write scope will do as well.
9083    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceMigrateCall<'a, C>
9084    where
9085        St: AsRef<str>,
9086    {
9087        self._scopes.insert(String::from(scope.as_ref()));
9088        self
9089    }
9090    /// Identifies the authorization scope(s) for the method you are building.
9091    ///
9092    /// See [`Self::add_scope()`] for details.
9093    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceMigrateCall<'a, C>
9094    where
9095        I: IntoIterator<Item = St>,
9096        St: AsRef<str>,
9097    {
9098        self._scopes
9099            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9100        self
9101    }
9102
9103    /// Removes all scopes, and no default scope will be used either.
9104    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9105    /// for details).
9106    pub fn clear_scopes(mut self) -> ProjectLocationInstanceMigrateCall<'a, C> {
9107        self._scopes.clear();
9108        self
9109    }
9110}
9111
9112/// Registers an existing legacy notebook instance to the Notebooks API server. Legacy instances are instances created with the legacy Compute Engine calls. They are not manageable by the Notebooks API out of the box. This call makes these instances manageable by the Notebooks API.
9113///
9114/// A builder for the *locations.instances.register* method supported by a *project* resource.
9115/// It is not used directly, but through a [`ProjectMethods`] instance.
9116///
9117/// # Example
9118///
9119/// Instantiate a resource method builder
9120///
9121/// ```test_harness,no_run
9122/// # extern crate hyper;
9123/// # extern crate hyper_rustls;
9124/// # extern crate google_notebooks1 as notebooks1;
9125/// use notebooks1::api::RegisterInstanceRequest;
9126/// # async fn dox() {
9127/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9128///
9129/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9130/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9131/// #     .with_native_roots()
9132/// #     .unwrap()
9133/// #     .https_only()
9134/// #     .enable_http2()
9135/// #     .build();
9136///
9137/// # let executor = hyper_util::rt::TokioExecutor::new();
9138/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9139/// #     secret,
9140/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9141/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9142/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9143/// #     ),
9144/// # ).build().await.unwrap();
9145///
9146/// # let client = hyper_util::client::legacy::Client::builder(
9147/// #     hyper_util::rt::TokioExecutor::new()
9148/// # )
9149/// # .build(
9150/// #     hyper_rustls::HttpsConnectorBuilder::new()
9151/// #         .with_native_roots()
9152/// #         .unwrap()
9153/// #         .https_or_http()
9154/// #         .enable_http2()
9155/// #         .build()
9156/// # );
9157/// # let mut hub = AIPlatformNotebooks::new(client, auth);
9158/// // As the method needs a request, you would usually fill it with the desired information
9159/// // into the respective structure. Some of the parts shown here might not be applicable !
9160/// // Values shown here are possibly random and not representative !
9161/// let mut req = RegisterInstanceRequest::default();
9162///
9163/// // You can configure optional parameters by calling the respective setters at will, and
9164/// // execute the final call using `doit()`.
9165/// // Values shown here are possibly random and not representative !
9166/// let result = hub.projects().locations_instances_register(req, "parent")
9167///              .doit().await;
9168/// # }
9169/// ```
9170pub struct ProjectLocationInstanceRegisterCall<'a, C>
9171where
9172    C: 'a,
9173{
9174    hub: &'a AIPlatformNotebooks<C>,
9175    _request: RegisterInstanceRequest,
9176    _parent: String,
9177    _delegate: Option<&'a mut dyn common::Delegate>,
9178    _additional_params: HashMap<String, String>,
9179    _scopes: BTreeSet<String>,
9180}
9181
9182impl<'a, C> common::CallBuilder for ProjectLocationInstanceRegisterCall<'a, C> {}
9183
9184impl<'a, C> ProjectLocationInstanceRegisterCall<'a, C>
9185where
9186    C: common::Connector,
9187{
9188    /// Perform the operation you have build so far.
9189    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
9190        use std::borrow::Cow;
9191        use std::io::{Read, Seek};
9192
9193        use common::{url::Params, ToParts};
9194        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9195
9196        let mut dd = common::DefaultDelegate;
9197        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9198        dlg.begin(common::MethodInfo {
9199            id: "notebooks.projects.locations.instances.register",
9200            http_method: hyper::Method::POST,
9201        });
9202
9203        for &field in ["alt", "parent"].iter() {
9204            if self._additional_params.contains_key(field) {
9205                dlg.finished(false);
9206                return Err(common::Error::FieldClash(field));
9207            }
9208        }
9209
9210        let mut params = Params::with_capacity(4 + self._additional_params.len());
9211        params.push("parent", self._parent);
9212
9213        params.extend(self._additional_params.iter());
9214
9215        params.push("alt", "json");
9216        let mut url = self.hub._base_url.clone() + "v1/{+parent}/instances:register";
9217        if self._scopes.is_empty() {
9218            self._scopes
9219                .insert(Scope::CloudPlatform.as_ref().to_string());
9220        }
9221
9222        #[allow(clippy::single_element_loop)]
9223        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9224            url = params.uri_replacement(url, param_name, find_this, true);
9225        }
9226        {
9227            let to_remove = ["parent"];
9228            params.remove_params(&to_remove);
9229        }
9230
9231        let url = params.parse_with_url(&url);
9232
9233        let mut json_mime_type = mime::APPLICATION_JSON;
9234        let mut request_value_reader = {
9235            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9236            common::remove_json_null_values(&mut value);
9237            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9238            serde_json::to_writer(&mut dst, &value).unwrap();
9239            dst
9240        };
9241        let request_size = request_value_reader
9242            .seek(std::io::SeekFrom::End(0))
9243            .unwrap();
9244        request_value_reader
9245            .seek(std::io::SeekFrom::Start(0))
9246            .unwrap();
9247
9248        loop {
9249            let token = match self
9250                .hub
9251                .auth
9252                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9253                .await
9254            {
9255                Ok(token) => token,
9256                Err(e) => match dlg.token(e) {
9257                    Ok(token) => token,
9258                    Err(e) => {
9259                        dlg.finished(false);
9260                        return Err(common::Error::MissingToken(e));
9261                    }
9262                },
9263            };
9264            request_value_reader
9265                .seek(std::io::SeekFrom::Start(0))
9266                .unwrap();
9267            let mut req_result = {
9268                let client = &self.hub.client;
9269                dlg.pre_request();
9270                let mut req_builder = hyper::Request::builder()
9271                    .method(hyper::Method::POST)
9272                    .uri(url.as_str())
9273                    .header(USER_AGENT, self.hub._user_agent.clone());
9274
9275                if let Some(token) = token.as_ref() {
9276                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9277                }
9278
9279                let request = req_builder
9280                    .header(CONTENT_TYPE, json_mime_type.to_string())
9281                    .header(CONTENT_LENGTH, request_size as u64)
9282                    .body(common::to_body(
9283                        request_value_reader.get_ref().clone().into(),
9284                    ));
9285
9286                client.request(request.unwrap()).await
9287            };
9288
9289            match req_result {
9290                Err(err) => {
9291                    if let common::Retry::After(d) = dlg.http_error(&err) {
9292                        sleep(d).await;
9293                        continue;
9294                    }
9295                    dlg.finished(false);
9296                    return Err(common::Error::HttpError(err));
9297                }
9298                Ok(res) => {
9299                    let (mut parts, body) = res.into_parts();
9300                    let mut body = common::Body::new(body);
9301                    if !parts.status.is_success() {
9302                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9303                        let error = serde_json::from_str(&common::to_string(&bytes));
9304                        let response = common::to_response(parts, bytes.into());
9305
9306                        if let common::Retry::After(d) =
9307                            dlg.http_failure(&response, error.as_ref().ok())
9308                        {
9309                            sleep(d).await;
9310                            continue;
9311                        }
9312
9313                        dlg.finished(false);
9314
9315                        return Err(match error {
9316                            Ok(value) => common::Error::BadRequest(value),
9317                            _ => common::Error::Failure(response),
9318                        });
9319                    }
9320                    let response = {
9321                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9322                        let encoded = common::to_string(&bytes);
9323                        match serde_json::from_str(&encoded) {
9324                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9325                            Err(error) => {
9326                                dlg.response_json_decode_error(&encoded, &error);
9327                                return Err(common::Error::JsonDecodeError(
9328                                    encoded.to_string(),
9329                                    error,
9330                                ));
9331                            }
9332                        }
9333                    };
9334
9335                    dlg.finished(true);
9336                    return Ok(response);
9337                }
9338            }
9339        }
9340    }
9341
9342    ///
9343    /// Sets the *request* property to the given value.
9344    ///
9345    /// Even though the property as already been set when instantiating this call,
9346    /// we provide this method for API completeness.
9347    pub fn request(
9348        mut self,
9349        new_value: RegisterInstanceRequest,
9350    ) -> ProjectLocationInstanceRegisterCall<'a, C> {
9351        self._request = new_value;
9352        self
9353    }
9354    /// Required. Format: `parent=projects/{project_id}/locations/{location}`
9355    ///
9356    /// Sets the *parent* path property to the given value.
9357    ///
9358    /// Even though the property as already been set when instantiating this call,
9359    /// we provide this method for API completeness.
9360    pub fn parent(mut self, new_value: &str) -> ProjectLocationInstanceRegisterCall<'a, C> {
9361        self._parent = new_value.to_string();
9362        self
9363    }
9364    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9365    /// while executing the actual API request.
9366    ///
9367    /// ````text
9368    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9369    /// ````
9370    ///
9371    /// Sets the *delegate* property to the given value.
9372    pub fn delegate(
9373        mut self,
9374        new_value: &'a mut dyn common::Delegate,
9375    ) -> ProjectLocationInstanceRegisterCall<'a, C> {
9376        self._delegate = Some(new_value);
9377        self
9378    }
9379
9380    /// Set any additional parameter of the query string used in the request.
9381    /// It should be used to set parameters which are not yet available through their own
9382    /// setters.
9383    ///
9384    /// Please note that this method must not be used to set any of the known parameters
9385    /// which have their own setter method. If done anyway, the request will fail.
9386    ///
9387    /// # Additional Parameters
9388    ///
9389    /// * *$.xgafv* (query-string) - V1 error format.
9390    /// * *access_token* (query-string) - OAuth access token.
9391    /// * *alt* (query-string) - Data format for response.
9392    /// * *callback* (query-string) - JSONP
9393    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9394    /// * *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.
9395    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9396    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9397    /// * *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.
9398    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9399    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9400    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceRegisterCall<'a, C>
9401    where
9402        T: AsRef<str>,
9403    {
9404        self._additional_params
9405            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9406        self
9407    }
9408
9409    /// Identifies the authorization scope for the method you are building.
9410    ///
9411    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9412    /// [`Scope::CloudPlatform`].
9413    ///
9414    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9415    /// tokens for more than one scope.
9416    ///
9417    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9418    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9419    /// sufficient, a read-write scope will do as well.
9420    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceRegisterCall<'a, C>
9421    where
9422        St: AsRef<str>,
9423    {
9424        self._scopes.insert(String::from(scope.as_ref()));
9425        self
9426    }
9427    /// Identifies the authorization scope(s) for the method you are building.
9428    ///
9429    /// See [`Self::add_scope()`] for details.
9430    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceRegisterCall<'a, C>
9431    where
9432        I: IntoIterator<Item = St>,
9433        St: AsRef<str>,
9434    {
9435        self._scopes
9436            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9437        self
9438    }
9439
9440    /// Removes all scopes, and no default scope will be used either.
9441    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9442    /// for details).
9443    pub fn clear_scopes(mut self) -> ProjectLocationInstanceRegisterCall<'a, C> {
9444        self._scopes.clear();
9445        self
9446    }
9447}
9448
9449/// Allows notebook instances to report their latest instance information to the Notebooks API server. The server will merge the reported information to the instance metadata store. Do not use this method directly.
9450///
9451/// A builder for the *locations.instances.report* method supported by a *project* resource.
9452/// It is not used directly, but through a [`ProjectMethods`] instance.
9453///
9454/// # Example
9455///
9456/// Instantiate a resource method builder
9457///
9458/// ```test_harness,no_run
9459/// # extern crate hyper;
9460/// # extern crate hyper_rustls;
9461/// # extern crate google_notebooks1 as notebooks1;
9462/// use notebooks1::api::ReportInstanceInfoRequest;
9463/// # async fn dox() {
9464/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9465///
9466/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9467/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9468/// #     .with_native_roots()
9469/// #     .unwrap()
9470/// #     .https_only()
9471/// #     .enable_http2()
9472/// #     .build();
9473///
9474/// # let executor = hyper_util::rt::TokioExecutor::new();
9475/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9476/// #     secret,
9477/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9478/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9479/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9480/// #     ),
9481/// # ).build().await.unwrap();
9482///
9483/// # let client = hyper_util::client::legacy::Client::builder(
9484/// #     hyper_util::rt::TokioExecutor::new()
9485/// # )
9486/// # .build(
9487/// #     hyper_rustls::HttpsConnectorBuilder::new()
9488/// #         .with_native_roots()
9489/// #         .unwrap()
9490/// #         .https_or_http()
9491/// #         .enable_http2()
9492/// #         .build()
9493/// # );
9494/// # let mut hub = AIPlatformNotebooks::new(client, auth);
9495/// // As the method needs a request, you would usually fill it with the desired information
9496/// // into the respective structure. Some of the parts shown here might not be applicable !
9497/// // Values shown here are possibly random and not representative !
9498/// let mut req = ReportInstanceInfoRequest::default();
9499///
9500/// // You can configure optional parameters by calling the respective setters at will, and
9501/// // execute the final call using `doit()`.
9502/// // Values shown here are possibly random and not representative !
9503/// let result = hub.projects().locations_instances_report(req, "name")
9504///              .doit().await;
9505/// # }
9506/// ```
9507pub struct ProjectLocationInstanceReportCall<'a, C>
9508where
9509    C: 'a,
9510{
9511    hub: &'a AIPlatformNotebooks<C>,
9512    _request: ReportInstanceInfoRequest,
9513    _name: String,
9514    _delegate: Option<&'a mut dyn common::Delegate>,
9515    _additional_params: HashMap<String, String>,
9516    _scopes: BTreeSet<String>,
9517}
9518
9519impl<'a, C> common::CallBuilder for ProjectLocationInstanceReportCall<'a, C> {}
9520
9521impl<'a, C> ProjectLocationInstanceReportCall<'a, C>
9522where
9523    C: common::Connector,
9524{
9525    /// Perform the operation you have build so far.
9526    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
9527        use std::borrow::Cow;
9528        use std::io::{Read, Seek};
9529
9530        use common::{url::Params, ToParts};
9531        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9532
9533        let mut dd = common::DefaultDelegate;
9534        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9535        dlg.begin(common::MethodInfo {
9536            id: "notebooks.projects.locations.instances.report",
9537            http_method: hyper::Method::POST,
9538        });
9539
9540        for &field in ["alt", "name"].iter() {
9541            if self._additional_params.contains_key(field) {
9542                dlg.finished(false);
9543                return Err(common::Error::FieldClash(field));
9544            }
9545        }
9546
9547        let mut params = Params::with_capacity(4 + self._additional_params.len());
9548        params.push("name", self._name);
9549
9550        params.extend(self._additional_params.iter());
9551
9552        params.push("alt", "json");
9553        let mut url = self.hub._base_url.clone() + "v1/{+name}:report";
9554        if self._scopes.is_empty() {
9555            self._scopes
9556                .insert(Scope::CloudPlatform.as_ref().to_string());
9557        }
9558
9559        #[allow(clippy::single_element_loop)]
9560        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9561            url = params.uri_replacement(url, param_name, find_this, true);
9562        }
9563        {
9564            let to_remove = ["name"];
9565            params.remove_params(&to_remove);
9566        }
9567
9568        let url = params.parse_with_url(&url);
9569
9570        let mut json_mime_type = mime::APPLICATION_JSON;
9571        let mut request_value_reader = {
9572            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9573            common::remove_json_null_values(&mut value);
9574            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9575            serde_json::to_writer(&mut dst, &value).unwrap();
9576            dst
9577        };
9578        let request_size = request_value_reader
9579            .seek(std::io::SeekFrom::End(0))
9580            .unwrap();
9581        request_value_reader
9582            .seek(std::io::SeekFrom::Start(0))
9583            .unwrap();
9584
9585        loop {
9586            let token = match self
9587                .hub
9588                .auth
9589                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9590                .await
9591            {
9592                Ok(token) => token,
9593                Err(e) => match dlg.token(e) {
9594                    Ok(token) => token,
9595                    Err(e) => {
9596                        dlg.finished(false);
9597                        return Err(common::Error::MissingToken(e));
9598                    }
9599                },
9600            };
9601            request_value_reader
9602                .seek(std::io::SeekFrom::Start(0))
9603                .unwrap();
9604            let mut req_result = {
9605                let client = &self.hub.client;
9606                dlg.pre_request();
9607                let mut req_builder = hyper::Request::builder()
9608                    .method(hyper::Method::POST)
9609                    .uri(url.as_str())
9610                    .header(USER_AGENT, self.hub._user_agent.clone());
9611
9612                if let Some(token) = token.as_ref() {
9613                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9614                }
9615
9616                let request = req_builder
9617                    .header(CONTENT_TYPE, json_mime_type.to_string())
9618                    .header(CONTENT_LENGTH, request_size as u64)
9619                    .body(common::to_body(
9620                        request_value_reader.get_ref().clone().into(),
9621                    ));
9622
9623                client.request(request.unwrap()).await
9624            };
9625
9626            match req_result {
9627                Err(err) => {
9628                    if let common::Retry::After(d) = dlg.http_error(&err) {
9629                        sleep(d).await;
9630                        continue;
9631                    }
9632                    dlg.finished(false);
9633                    return Err(common::Error::HttpError(err));
9634                }
9635                Ok(res) => {
9636                    let (mut parts, body) = res.into_parts();
9637                    let mut body = common::Body::new(body);
9638                    if !parts.status.is_success() {
9639                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9640                        let error = serde_json::from_str(&common::to_string(&bytes));
9641                        let response = common::to_response(parts, bytes.into());
9642
9643                        if let common::Retry::After(d) =
9644                            dlg.http_failure(&response, error.as_ref().ok())
9645                        {
9646                            sleep(d).await;
9647                            continue;
9648                        }
9649
9650                        dlg.finished(false);
9651
9652                        return Err(match error {
9653                            Ok(value) => common::Error::BadRequest(value),
9654                            _ => common::Error::Failure(response),
9655                        });
9656                    }
9657                    let response = {
9658                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9659                        let encoded = common::to_string(&bytes);
9660                        match serde_json::from_str(&encoded) {
9661                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9662                            Err(error) => {
9663                                dlg.response_json_decode_error(&encoded, &error);
9664                                return Err(common::Error::JsonDecodeError(
9665                                    encoded.to_string(),
9666                                    error,
9667                                ));
9668                            }
9669                        }
9670                    };
9671
9672                    dlg.finished(true);
9673                    return Ok(response);
9674                }
9675            }
9676        }
9677    }
9678
9679    ///
9680    /// Sets the *request* property to the given value.
9681    ///
9682    /// Even though the property as already been set when instantiating this call,
9683    /// we provide this method for API completeness.
9684    pub fn request(
9685        mut self,
9686        new_value: ReportInstanceInfoRequest,
9687    ) -> ProjectLocationInstanceReportCall<'a, C> {
9688        self._request = new_value;
9689        self
9690    }
9691    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
9692    ///
9693    /// Sets the *name* path property to the given value.
9694    ///
9695    /// Even though the property as already been set when instantiating this call,
9696    /// we provide this method for API completeness.
9697    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceReportCall<'a, C> {
9698        self._name = new_value.to_string();
9699        self
9700    }
9701    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9702    /// while executing the actual API request.
9703    ///
9704    /// ````text
9705    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9706    /// ````
9707    ///
9708    /// Sets the *delegate* property to the given value.
9709    pub fn delegate(
9710        mut self,
9711        new_value: &'a mut dyn common::Delegate,
9712    ) -> ProjectLocationInstanceReportCall<'a, C> {
9713        self._delegate = Some(new_value);
9714        self
9715    }
9716
9717    /// Set any additional parameter of the query string used in the request.
9718    /// It should be used to set parameters which are not yet available through their own
9719    /// setters.
9720    ///
9721    /// Please note that this method must not be used to set any of the known parameters
9722    /// which have their own setter method. If done anyway, the request will fail.
9723    ///
9724    /// # Additional Parameters
9725    ///
9726    /// * *$.xgafv* (query-string) - V1 error format.
9727    /// * *access_token* (query-string) - OAuth access token.
9728    /// * *alt* (query-string) - Data format for response.
9729    /// * *callback* (query-string) - JSONP
9730    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9731    /// * *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.
9732    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9733    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9734    /// * *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.
9735    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9736    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9737    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceReportCall<'a, C>
9738    where
9739        T: AsRef<str>,
9740    {
9741        self._additional_params
9742            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9743        self
9744    }
9745
9746    /// Identifies the authorization scope for the method you are building.
9747    ///
9748    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9749    /// [`Scope::CloudPlatform`].
9750    ///
9751    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9752    /// tokens for more than one scope.
9753    ///
9754    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9755    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9756    /// sufficient, a read-write scope will do as well.
9757    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceReportCall<'a, C>
9758    where
9759        St: AsRef<str>,
9760    {
9761        self._scopes.insert(String::from(scope.as_ref()));
9762        self
9763    }
9764    /// Identifies the authorization scope(s) for the method you are building.
9765    ///
9766    /// See [`Self::add_scope()`] for details.
9767    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceReportCall<'a, C>
9768    where
9769        I: IntoIterator<Item = St>,
9770        St: AsRef<str>,
9771    {
9772        self._scopes
9773            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9774        self
9775    }
9776
9777    /// Removes all scopes, and no default scope will be used either.
9778    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9779    /// for details).
9780    pub fn clear_scopes(mut self) -> ProjectLocationInstanceReportCall<'a, C> {
9781        self._scopes.clear();
9782        self
9783    }
9784}
9785
9786/// Reports and processes an instance event.
9787///
9788/// A builder for the *locations.instances.reportEvent* method supported by a *project* resource.
9789/// It is not used directly, but through a [`ProjectMethods`] instance.
9790///
9791/// # Example
9792///
9793/// Instantiate a resource method builder
9794///
9795/// ```test_harness,no_run
9796/// # extern crate hyper;
9797/// # extern crate hyper_rustls;
9798/// # extern crate google_notebooks1 as notebooks1;
9799/// use notebooks1::api::ReportInstanceEventRequest;
9800/// # async fn dox() {
9801/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9802///
9803/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9804/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9805/// #     .with_native_roots()
9806/// #     .unwrap()
9807/// #     .https_only()
9808/// #     .enable_http2()
9809/// #     .build();
9810///
9811/// # let executor = hyper_util::rt::TokioExecutor::new();
9812/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9813/// #     secret,
9814/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9815/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9816/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9817/// #     ),
9818/// # ).build().await.unwrap();
9819///
9820/// # let client = hyper_util::client::legacy::Client::builder(
9821/// #     hyper_util::rt::TokioExecutor::new()
9822/// # )
9823/// # .build(
9824/// #     hyper_rustls::HttpsConnectorBuilder::new()
9825/// #         .with_native_roots()
9826/// #         .unwrap()
9827/// #         .https_or_http()
9828/// #         .enable_http2()
9829/// #         .build()
9830/// # );
9831/// # let mut hub = AIPlatformNotebooks::new(client, auth);
9832/// // As the method needs a request, you would usually fill it with the desired information
9833/// // into the respective structure. Some of the parts shown here might not be applicable !
9834/// // Values shown here are possibly random and not representative !
9835/// let mut req = ReportInstanceEventRequest::default();
9836///
9837/// // You can configure optional parameters by calling the respective setters at will, and
9838/// // execute the final call using `doit()`.
9839/// // Values shown here are possibly random and not representative !
9840/// let result = hub.projects().locations_instances_report_event(req, "name")
9841///              .doit().await;
9842/// # }
9843/// ```
9844pub struct ProjectLocationInstanceReportEventCall<'a, C>
9845where
9846    C: 'a,
9847{
9848    hub: &'a AIPlatformNotebooks<C>,
9849    _request: ReportInstanceEventRequest,
9850    _name: String,
9851    _delegate: Option<&'a mut dyn common::Delegate>,
9852    _additional_params: HashMap<String, String>,
9853    _scopes: BTreeSet<String>,
9854}
9855
9856impl<'a, C> common::CallBuilder for ProjectLocationInstanceReportEventCall<'a, C> {}
9857
9858impl<'a, C> ProjectLocationInstanceReportEventCall<'a, C>
9859where
9860    C: common::Connector,
9861{
9862    /// Perform the operation you have build so far.
9863    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
9864        use std::borrow::Cow;
9865        use std::io::{Read, Seek};
9866
9867        use common::{url::Params, ToParts};
9868        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9869
9870        let mut dd = common::DefaultDelegate;
9871        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9872        dlg.begin(common::MethodInfo {
9873            id: "notebooks.projects.locations.instances.reportEvent",
9874            http_method: hyper::Method::POST,
9875        });
9876
9877        for &field in ["alt", "name"].iter() {
9878            if self._additional_params.contains_key(field) {
9879                dlg.finished(false);
9880                return Err(common::Error::FieldClash(field));
9881            }
9882        }
9883
9884        let mut params = Params::with_capacity(4 + self._additional_params.len());
9885        params.push("name", self._name);
9886
9887        params.extend(self._additional_params.iter());
9888
9889        params.push("alt", "json");
9890        let mut url = self.hub._base_url.clone() + "v1/{+name}:reportEvent";
9891        if self._scopes.is_empty() {
9892            self._scopes
9893                .insert(Scope::CloudPlatform.as_ref().to_string());
9894        }
9895
9896        #[allow(clippy::single_element_loop)]
9897        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9898            url = params.uri_replacement(url, param_name, find_this, true);
9899        }
9900        {
9901            let to_remove = ["name"];
9902            params.remove_params(&to_remove);
9903        }
9904
9905        let url = params.parse_with_url(&url);
9906
9907        let mut json_mime_type = mime::APPLICATION_JSON;
9908        let mut request_value_reader = {
9909            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9910            common::remove_json_null_values(&mut value);
9911            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9912            serde_json::to_writer(&mut dst, &value).unwrap();
9913            dst
9914        };
9915        let request_size = request_value_reader
9916            .seek(std::io::SeekFrom::End(0))
9917            .unwrap();
9918        request_value_reader
9919            .seek(std::io::SeekFrom::Start(0))
9920            .unwrap();
9921
9922        loop {
9923            let token = match self
9924                .hub
9925                .auth
9926                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9927                .await
9928            {
9929                Ok(token) => token,
9930                Err(e) => match dlg.token(e) {
9931                    Ok(token) => token,
9932                    Err(e) => {
9933                        dlg.finished(false);
9934                        return Err(common::Error::MissingToken(e));
9935                    }
9936                },
9937            };
9938            request_value_reader
9939                .seek(std::io::SeekFrom::Start(0))
9940                .unwrap();
9941            let mut req_result = {
9942                let client = &self.hub.client;
9943                dlg.pre_request();
9944                let mut req_builder = hyper::Request::builder()
9945                    .method(hyper::Method::POST)
9946                    .uri(url.as_str())
9947                    .header(USER_AGENT, self.hub._user_agent.clone());
9948
9949                if let Some(token) = token.as_ref() {
9950                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9951                }
9952
9953                let request = req_builder
9954                    .header(CONTENT_TYPE, json_mime_type.to_string())
9955                    .header(CONTENT_LENGTH, request_size as u64)
9956                    .body(common::to_body(
9957                        request_value_reader.get_ref().clone().into(),
9958                    ));
9959
9960                client.request(request.unwrap()).await
9961            };
9962
9963            match req_result {
9964                Err(err) => {
9965                    if let common::Retry::After(d) = dlg.http_error(&err) {
9966                        sleep(d).await;
9967                        continue;
9968                    }
9969                    dlg.finished(false);
9970                    return Err(common::Error::HttpError(err));
9971                }
9972                Ok(res) => {
9973                    let (mut parts, body) = res.into_parts();
9974                    let mut body = common::Body::new(body);
9975                    if !parts.status.is_success() {
9976                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9977                        let error = serde_json::from_str(&common::to_string(&bytes));
9978                        let response = common::to_response(parts, bytes.into());
9979
9980                        if let common::Retry::After(d) =
9981                            dlg.http_failure(&response, error.as_ref().ok())
9982                        {
9983                            sleep(d).await;
9984                            continue;
9985                        }
9986
9987                        dlg.finished(false);
9988
9989                        return Err(match error {
9990                            Ok(value) => common::Error::BadRequest(value),
9991                            _ => common::Error::Failure(response),
9992                        });
9993                    }
9994                    let response = {
9995                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9996                        let encoded = common::to_string(&bytes);
9997                        match serde_json::from_str(&encoded) {
9998                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9999                            Err(error) => {
10000                                dlg.response_json_decode_error(&encoded, &error);
10001                                return Err(common::Error::JsonDecodeError(
10002                                    encoded.to_string(),
10003                                    error,
10004                                ));
10005                            }
10006                        }
10007                    };
10008
10009                    dlg.finished(true);
10010                    return Ok(response);
10011                }
10012            }
10013        }
10014    }
10015
10016    ///
10017    /// Sets the *request* property to the given value.
10018    ///
10019    /// Even though the property as already been set when instantiating this call,
10020    /// we provide this method for API completeness.
10021    pub fn request(
10022        mut self,
10023        new_value: ReportInstanceEventRequest,
10024    ) -> ProjectLocationInstanceReportEventCall<'a, C> {
10025        self._request = new_value;
10026        self
10027    }
10028    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
10029    ///
10030    /// Sets the *name* path property to the given value.
10031    ///
10032    /// Even though the property as already been set when instantiating this call,
10033    /// we provide this method for API completeness.
10034    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceReportEventCall<'a, C> {
10035        self._name = new_value.to_string();
10036        self
10037    }
10038    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10039    /// while executing the actual API request.
10040    ///
10041    /// ````text
10042    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10043    /// ````
10044    ///
10045    /// Sets the *delegate* property to the given value.
10046    pub fn delegate(
10047        mut self,
10048        new_value: &'a mut dyn common::Delegate,
10049    ) -> ProjectLocationInstanceReportEventCall<'a, C> {
10050        self._delegate = Some(new_value);
10051        self
10052    }
10053
10054    /// Set any additional parameter of the query string used in the request.
10055    /// It should be used to set parameters which are not yet available through their own
10056    /// setters.
10057    ///
10058    /// Please note that this method must not be used to set any of the known parameters
10059    /// which have their own setter method. If done anyway, the request will fail.
10060    ///
10061    /// # Additional Parameters
10062    ///
10063    /// * *$.xgafv* (query-string) - V1 error format.
10064    /// * *access_token* (query-string) - OAuth access token.
10065    /// * *alt* (query-string) - Data format for response.
10066    /// * *callback* (query-string) - JSONP
10067    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10068    /// * *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.
10069    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10070    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10071    /// * *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.
10072    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10073    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10074    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceReportEventCall<'a, C>
10075    where
10076        T: AsRef<str>,
10077    {
10078        self._additional_params
10079            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10080        self
10081    }
10082
10083    /// Identifies the authorization scope for the method you are building.
10084    ///
10085    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10086    /// [`Scope::CloudPlatform`].
10087    ///
10088    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10089    /// tokens for more than one scope.
10090    ///
10091    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10092    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10093    /// sufficient, a read-write scope will do as well.
10094    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceReportEventCall<'a, C>
10095    where
10096        St: AsRef<str>,
10097    {
10098        self._scopes.insert(String::from(scope.as_ref()));
10099        self
10100    }
10101    /// Identifies the authorization scope(s) for the method you are building.
10102    ///
10103    /// See [`Self::add_scope()`] for details.
10104    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceReportEventCall<'a, C>
10105    where
10106        I: IntoIterator<Item = St>,
10107        St: AsRef<str>,
10108    {
10109        self._scopes
10110            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10111        self
10112    }
10113
10114    /// Removes all scopes, and no default scope will be used either.
10115    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10116    /// for details).
10117    pub fn clear_scopes(mut self) -> ProjectLocationInstanceReportEventCall<'a, C> {
10118        self._scopes.clear();
10119        self
10120    }
10121}
10122
10123/// Resets a notebook instance.
10124///
10125/// A builder for the *locations.instances.reset* method supported by a *project* resource.
10126/// It is not used directly, but through a [`ProjectMethods`] instance.
10127///
10128/// # Example
10129///
10130/// Instantiate a resource method builder
10131///
10132/// ```test_harness,no_run
10133/// # extern crate hyper;
10134/// # extern crate hyper_rustls;
10135/// # extern crate google_notebooks1 as notebooks1;
10136/// use notebooks1::api::ResetInstanceRequest;
10137/// # async fn dox() {
10138/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10139///
10140/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10141/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10142/// #     .with_native_roots()
10143/// #     .unwrap()
10144/// #     .https_only()
10145/// #     .enable_http2()
10146/// #     .build();
10147///
10148/// # let executor = hyper_util::rt::TokioExecutor::new();
10149/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10150/// #     secret,
10151/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10152/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10153/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10154/// #     ),
10155/// # ).build().await.unwrap();
10156///
10157/// # let client = hyper_util::client::legacy::Client::builder(
10158/// #     hyper_util::rt::TokioExecutor::new()
10159/// # )
10160/// # .build(
10161/// #     hyper_rustls::HttpsConnectorBuilder::new()
10162/// #         .with_native_roots()
10163/// #         .unwrap()
10164/// #         .https_or_http()
10165/// #         .enable_http2()
10166/// #         .build()
10167/// # );
10168/// # let mut hub = AIPlatformNotebooks::new(client, auth);
10169/// // As the method needs a request, you would usually fill it with the desired information
10170/// // into the respective structure. Some of the parts shown here might not be applicable !
10171/// // Values shown here are possibly random and not representative !
10172/// let mut req = ResetInstanceRequest::default();
10173///
10174/// // You can configure optional parameters by calling the respective setters at will, and
10175/// // execute the final call using `doit()`.
10176/// // Values shown here are possibly random and not representative !
10177/// let result = hub.projects().locations_instances_reset(req, "name")
10178///              .doit().await;
10179/// # }
10180/// ```
10181pub struct ProjectLocationInstanceResetCall<'a, C>
10182where
10183    C: 'a,
10184{
10185    hub: &'a AIPlatformNotebooks<C>,
10186    _request: ResetInstanceRequest,
10187    _name: String,
10188    _delegate: Option<&'a mut dyn common::Delegate>,
10189    _additional_params: HashMap<String, String>,
10190    _scopes: BTreeSet<String>,
10191}
10192
10193impl<'a, C> common::CallBuilder for ProjectLocationInstanceResetCall<'a, C> {}
10194
10195impl<'a, C> ProjectLocationInstanceResetCall<'a, C>
10196where
10197    C: common::Connector,
10198{
10199    /// Perform the operation you have build so far.
10200    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
10201        use std::borrow::Cow;
10202        use std::io::{Read, Seek};
10203
10204        use common::{url::Params, ToParts};
10205        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10206
10207        let mut dd = common::DefaultDelegate;
10208        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10209        dlg.begin(common::MethodInfo {
10210            id: "notebooks.projects.locations.instances.reset",
10211            http_method: hyper::Method::POST,
10212        });
10213
10214        for &field in ["alt", "name"].iter() {
10215            if self._additional_params.contains_key(field) {
10216                dlg.finished(false);
10217                return Err(common::Error::FieldClash(field));
10218            }
10219        }
10220
10221        let mut params = Params::with_capacity(4 + self._additional_params.len());
10222        params.push("name", self._name);
10223
10224        params.extend(self._additional_params.iter());
10225
10226        params.push("alt", "json");
10227        let mut url = self.hub._base_url.clone() + "v1/{+name}:reset";
10228        if self._scopes.is_empty() {
10229            self._scopes
10230                .insert(Scope::CloudPlatform.as_ref().to_string());
10231        }
10232
10233        #[allow(clippy::single_element_loop)]
10234        for &(find_this, param_name) in [("{+name}", "name")].iter() {
10235            url = params.uri_replacement(url, param_name, find_this, true);
10236        }
10237        {
10238            let to_remove = ["name"];
10239            params.remove_params(&to_remove);
10240        }
10241
10242        let url = params.parse_with_url(&url);
10243
10244        let mut json_mime_type = mime::APPLICATION_JSON;
10245        let mut request_value_reader = {
10246            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10247            common::remove_json_null_values(&mut value);
10248            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10249            serde_json::to_writer(&mut dst, &value).unwrap();
10250            dst
10251        };
10252        let request_size = request_value_reader
10253            .seek(std::io::SeekFrom::End(0))
10254            .unwrap();
10255        request_value_reader
10256            .seek(std::io::SeekFrom::Start(0))
10257            .unwrap();
10258
10259        loop {
10260            let token = match self
10261                .hub
10262                .auth
10263                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10264                .await
10265            {
10266                Ok(token) => token,
10267                Err(e) => match dlg.token(e) {
10268                    Ok(token) => token,
10269                    Err(e) => {
10270                        dlg.finished(false);
10271                        return Err(common::Error::MissingToken(e));
10272                    }
10273                },
10274            };
10275            request_value_reader
10276                .seek(std::io::SeekFrom::Start(0))
10277                .unwrap();
10278            let mut req_result = {
10279                let client = &self.hub.client;
10280                dlg.pre_request();
10281                let mut req_builder = hyper::Request::builder()
10282                    .method(hyper::Method::POST)
10283                    .uri(url.as_str())
10284                    .header(USER_AGENT, self.hub._user_agent.clone());
10285
10286                if let Some(token) = token.as_ref() {
10287                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10288                }
10289
10290                let request = req_builder
10291                    .header(CONTENT_TYPE, json_mime_type.to_string())
10292                    .header(CONTENT_LENGTH, request_size as u64)
10293                    .body(common::to_body(
10294                        request_value_reader.get_ref().clone().into(),
10295                    ));
10296
10297                client.request(request.unwrap()).await
10298            };
10299
10300            match req_result {
10301                Err(err) => {
10302                    if let common::Retry::After(d) = dlg.http_error(&err) {
10303                        sleep(d).await;
10304                        continue;
10305                    }
10306                    dlg.finished(false);
10307                    return Err(common::Error::HttpError(err));
10308                }
10309                Ok(res) => {
10310                    let (mut parts, body) = res.into_parts();
10311                    let mut body = common::Body::new(body);
10312                    if !parts.status.is_success() {
10313                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10314                        let error = serde_json::from_str(&common::to_string(&bytes));
10315                        let response = common::to_response(parts, bytes.into());
10316
10317                        if let common::Retry::After(d) =
10318                            dlg.http_failure(&response, error.as_ref().ok())
10319                        {
10320                            sleep(d).await;
10321                            continue;
10322                        }
10323
10324                        dlg.finished(false);
10325
10326                        return Err(match error {
10327                            Ok(value) => common::Error::BadRequest(value),
10328                            _ => common::Error::Failure(response),
10329                        });
10330                    }
10331                    let response = {
10332                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10333                        let encoded = common::to_string(&bytes);
10334                        match serde_json::from_str(&encoded) {
10335                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10336                            Err(error) => {
10337                                dlg.response_json_decode_error(&encoded, &error);
10338                                return Err(common::Error::JsonDecodeError(
10339                                    encoded.to_string(),
10340                                    error,
10341                                ));
10342                            }
10343                        }
10344                    };
10345
10346                    dlg.finished(true);
10347                    return Ok(response);
10348                }
10349            }
10350        }
10351    }
10352
10353    ///
10354    /// Sets the *request* property to the given value.
10355    ///
10356    /// Even though the property as already been set when instantiating this call,
10357    /// we provide this method for API completeness.
10358    pub fn request(
10359        mut self,
10360        new_value: ResetInstanceRequest,
10361    ) -> ProjectLocationInstanceResetCall<'a, C> {
10362        self._request = new_value;
10363        self
10364    }
10365    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
10366    ///
10367    /// Sets the *name* path property to the given value.
10368    ///
10369    /// Even though the property as already been set when instantiating this call,
10370    /// we provide this method for API completeness.
10371    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceResetCall<'a, C> {
10372        self._name = new_value.to_string();
10373        self
10374    }
10375    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10376    /// while executing the actual API request.
10377    ///
10378    /// ````text
10379    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10380    /// ````
10381    ///
10382    /// Sets the *delegate* property to the given value.
10383    pub fn delegate(
10384        mut self,
10385        new_value: &'a mut dyn common::Delegate,
10386    ) -> ProjectLocationInstanceResetCall<'a, C> {
10387        self._delegate = Some(new_value);
10388        self
10389    }
10390
10391    /// Set any additional parameter of the query string used in the request.
10392    /// It should be used to set parameters which are not yet available through their own
10393    /// setters.
10394    ///
10395    /// Please note that this method must not be used to set any of the known parameters
10396    /// which have their own setter method. If done anyway, the request will fail.
10397    ///
10398    /// # Additional Parameters
10399    ///
10400    /// * *$.xgafv* (query-string) - V1 error format.
10401    /// * *access_token* (query-string) - OAuth access token.
10402    /// * *alt* (query-string) - Data format for response.
10403    /// * *callback* (query-string) - JSONP
10404    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10405    /// * *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.
10406    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10407    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10408    /// * *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.
10409    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10410    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10411    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceResetCall<'a, C>
10412    where
10413        T: AsRef<str>,
10414    {
10415        self._additional_params
10416            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10417        self
10418    }
10419
10420    /// Identifies the authorization scope for the method you are building.
10421    ///
10422    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10423    /// [`Scope::CloudPlatform`].
10424    ///
10425    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10426    /// tokens for more than one scope.
10427    ///
10428    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10429    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10430    /// sufficient, a read-write scope will do as well.
10431    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceResetCall<'a, C>
10432    where
10433        St: AsRef<str>,
10434    {
10435        self._scopes.insert(String::from(scope.as_ref()));
10436        self
10437    }
10438    /// Identifies the authorization scope(s) for the method you are building.
10439    ///
10440    /// See [`Self::add_scope()`] for details.
10441    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceResetCall<'a, C>
10442    where
10443        I: IntoIterator<Item = St>,
10444        St: AsRef<str>,
10445    {
10446        self._scopes
10447            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10448        self
10449    }
10450
10451    /// Removes all scopes, and no default scope will be used either.
10452    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10453    /// for details).
10454    pub fn clear_scopes(mut self) -> ProjectLocationInstanceResetCall<'a, C> {
10455        self._scopes.clear();
10456        self
10457    }
10458}
10459
10460/// Rollbacks a notebook instance to the previous version.
10461///
10462/// A builder for the *locations.instances.rollback* method supported by a *project* resource.
10463/// It is not used directly, but through a [`ProjectMethods`] instance.
10464///
10465/// # Example
10466///
10467/// Instantiate a resource method builder
10468///
10469/// ```test_harness,no_run
10470/// # extern crate hyper;
10471/// # extern crate hyper_rustls;
10472/// # extern crate google_notebooks1 as notebooks1;
10473/// use notebooks1::api::RollbackInstanceRequest;
10474/// # async fn dox() {
10475/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10476///
10477/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10478/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10479/// #     .with_native_roots()
10480/// #     .unwrap()
10481/// #     .https_only()
10482/// #     .enable_http2()
10483/// #     .build();
10484///
10485/// # let executor = hyper_util::rt::TokioExecutor::new();
10486/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10487/// #     secret,
10488/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10489/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10490/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10491/// #     ),
10492/// # ).build().await.unwrap();
10493///
10494/// # let client = hyper_util::client::legacy::Client::builder(
10495/// #     hyper_util::rt::TokioExecutor::new()
10496/// # )
10497/// # .build(
10498/// #     hyper_rustls::HttpsConnectorBuilder::new()
10499/// #         .with_native_roots()
10500/// #         .unwrap()
10501/// #         .https_or_http()
10502/// #         .enable_http2()
10503/// #         .build()
10504/// # );
10505/// # let mut hub = AIPlatformNotebooks::new(client, auth);
10506/// // As the method needs a request, you would usually fill it with the desired information
10507/// // into the respective structure. Some of the parts shown here might not be applicable !
10508/// // Values shown here are possibly random and not representative !
10509/// let mut req = RollbackInstanceRequest::default();
10510///
10511/// // You can configure optional parameters by calling the respective setters at will, and
10512/// // execute the final call using `doit()`.
10513/// // Values shown here are possibly random and not representative !
10514/// let result = hub.projects().locations_instances_rollback(req, "name")
10515///              .doit().await;
10516/// # }
10517/// ```
10518pub struct ProjectLocationInstanceRollbackCall<'a, C>
10519where
10520    C: 'a,
10521{
10522    hub: &'a AIPlatformNotebooks<C>,
10523    _request: RollbackInstanceRequest,
10524    _name: String,
10525    _delegate: Option<&'a mut dyn common::Delegate>,
10526    _additional_params: HashMap<String, String>,
10527    _scopes: BTreeSet<String>,
10528}
10529
10530impl<'a, C> common::CallBuilder for ProjectLocationInstanceRollbackCall<'a, C> {}
10531
10532impl<'a, C> ProjectLocationInstanceRollbackCall<'a, C>
10533where
10534    C: common::Connector,
10535{
10536    /// Perform the operation you have build so far.
10537    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
10538        use std::borrow::Cow;
10539        use std::io::{Read, Seek};
10540
10541        use common::{url::Params, ToParts};
10542        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10543
10544        let mut dd = common::DefaultDelegate;
10545        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10546        dlg.begin(common::MethodInfo {
10547            id: "notebooks.projects.locations.instances.rollback",
10548            http_method: hyper::Method::POST,
10549        });
10550
10551        for &field in ["alt", "name"].iter() {
10552            if self._additional_params.contains_key(field) {
10553                dlg.finished(false);
10554                return Err(common::Error::FieldClash(field));
10555            }
10556        }
10557
10558        let mut params = Params::with_capacity(4 + self._additional_params.len());
10559        params.push("name", self._name);
10560
10561        params.extend(self._additional_params.iter());
10562
10563        params.push("alt", "json");
10564        let mut url = self.hub._base_url.clone() + "v1/{+name}:rollback";
10565        if self._scopes.is_empty() {
10566            self._scopes
10567                .insert(Scope::CloudPlatform.as_ref().to_string());
10568        }
10569
10570        #[allow(clippy::single_element_loop)]
10571        for &(find_this, param_name) in [("{+name}", "name")].iter() {
10572            url = params.uri_replacement(url, param_name, find_this, true);
10573        }
10574        {
10575            let to_remove = ["name"];
10576            params.remove_params(&to_remove);
10577        }
10578
10579        let url = params.parse_with_url(&url);
10580
10581        let mut json_mime_type = mime::APPLICATION_JSON;
10582        let mut request_value_reader = {
10583            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10584            common::remove_json_null_values(&mut value);
10585            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10586            serde_json::to_writer(&mut dst, &value).unwrap();
10587            dst
10588        };
10589        let request_size = request_value_reader
10590            .seek(std::io::SeekFrom::End(0))
10591            .unwrap();
10592        request_value_reader
10593            .seek(std::io::SeekFrom::Start(0))
10594            .unwrap();
10595
10596        loop {
10597            let token = match self
10598                .hub
10599                .auth
10600                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10601                .await
10602            {
10603                Ok(token) => token,
10604                Err(e) => match dlg.token(e) {
10605                    Ok(token) => token,
10606                    Err(e) => {
10607                        dlg.finished(false);
10608                        return Err(common::Error::MissingToken(e));
10609                    }
10610                },
10611            };
10612            request_value_reader
10613                .seek(std::io::SeekFrom::Start(0))
10614                .unwrap();
10615            let mut req_result = {
10616                let client = &self.hub.client;
10617                dlg.pre_request();
10618                let mut req_builder = hyper::Request::builder()
10619                    .method(hyper::Method::POST)
10620                    .uri(url.as_str())
10621                    .header(USER_AGENT, self.hub._user_agent.clone());
10622
10623                if let Some(token) = token.as_ref() {
10624                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10625                }
10626
10627                let request = req_builder
10628                    .header(CONTENT_TYPE, json_mime_type.to_string())
10629                    .header(CONTENT_LENGTH, request_size as u64)
10630                    .body(common::to_body(
10631                        request_value_reader.get_ref().clone().into(),
10632                    ));
10633
10634                client.request(request.unwrap()).await
10635            };
10636
10637            match req_result {
10638                Err(err) => {
10639                    if let common::Retry::After(d) = dlg.http_error(&err) {
10640                        sleep(d).await;
10641                        continue;
10642                    }
10643                    dlg.finished(false);
10644                    return Err(common::Error::HttpError(err));
10645                }
10646                Ok(res) => {
10647                    let (mut parts, body) = res.into_parts();
10648                    let mut body = common::Body::new(body);
10649                    if !parts.status.is_success() {
10650                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10651                        let error = serde_json::from_str(&common::to_string(&bytes));
10652                        let response = common::to_response(parts, bytes.into());
10653
10654                        if let common::Retry::After(d) =
10655                            dlg.http_failure(&response, error.as_ref().ok())
10656                        {
10657                            sleep(d).await;
10658                            continue;
10659                        }
10660
10661                        dlg.finished(false);
10662
10663                        return Err(match error {
10664                            Ok(value) => common::Error::BadRequest(value),
10665                            _ => common::Error::Failure(response),
10666                        });
10667                    }
10668                    let response = {
10669                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10670                        let encoded = common::to_string(&bytes);
10671                        match serde_json::from_str(&encoded) {
10672                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10673                            Err(error) => {
10674                                dlg.response_json_decode_error(&encoded, &error);
10675                                return Err(common::Error::JsonDecodeError(
10676                                    encoded.to_string(),
10677                                    error,
10678                                ));
10679                            }
10680                        }
10681                    };
10682
10683                    dlg.finished(true);
10684                    return Ok(response);
10685                }
10686            }
10687        }
10688    }
10689
10690    ///
10691    /// Sets the *request* property to the given value.
10692    ///
10693    /// Even though the property as already been set when instantiating this call,
10694    /// we provide this method for API completeness.
10695    pub fn request(
10696        mut self,
10697        new_value: RollbackInstanceRequest,
10698    ) -> ProjectLocationInstanceRollbackCall<'a, C> {
10699        self._request = new_value;
10700        self
10701    }
10702    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
10703    ///
10704    /// Sets the *name* path property to the given value.
10705    ///
10706    /// Even though the property as already been set when instantiating this call,
10707    /// we provide this method for API completeness.
10708    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceRollbackCall<'a, C> {
10709        self._name = new_value.to_string();
10710        self
10711    }
10712    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10713    /// while executing the actual API request.
10714    ///
10715    /// ````text
10716    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10717    /// ````
10718    ///
10719    /// Sets the *delegate* property to the given value.
10720    pub fn delegate(
10721        mut self,
10722        new_value: &'a mut dyn common::Delegate,
10723    ) -> ProjectLocationInstanceRollbackCall<'a, C> {
10724        self._delegate = Some(new_value);
10725        self
10726    }
10727
10728    /// Set any additional parameter of the query string used in the request.
10729    /// It should be used to set parameters which are not yet available through their own
10730    /// setters.
10731    ///
10732    /// Please note that this method must not be used to set any of the known parameters
10733    /// which have their own setter method. If done anyway, the request will fail.
10734    ///
10735    /// # Additional Parameters
10736    ///
10737    /// * *$.xgafv* (query-string) - V1 error format.
10738    /// * *access_token* (query-string) - OAuth access token.
10739    /// * *alt* (query-string) - Data format for response.
10740    /// * *callback* (query-string) - JSONP
10741    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10742    /// * *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.
10743    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10744    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10745    /// * *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.
10746    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10747    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10748    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceRollbackCall<'a, C>
10749    where
10750        T: AsRef<str>,
10751    {
10752        self._additional_params
10753            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10754        self
10755    }
10756
10757    /// Identifies the authorization scope for the method you are building.
10758    ///
10759    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10760    /// [`Scope::CloudPlatform`].
10761    ///
10762    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10763    /// tokens for more than one scope.
10764    ///
10765    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10766    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10767    /// sufficient, a read-write scope will do as well.
10768    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceRollbackCall<'a, C>
10769    where
10770        St: AsRef<str>,
10771    {
10772        self._scopes.insert(String::from(scope.as_ref()));
10773        self
10774    }
10775    /// Identifies the authorization scope(s) for the method you are building.
10776    ///
10777    /// See [`Self::add_scope()`] for details.
10778    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceRollbackCall<'a, C>
10779    where
10780        I: IntoIterator<Item = St>,
10781        St: AsRef<str>,
10782    {
10783        self._scopes
10784            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10785        self
10786    }
10787
10788    /// Removes all scopes, and no default scope will be used either.
10789    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10790    /// for details).
10791    pub fn clear_scopes(mut self) -> ProjectLocationInstanceRollbackCall<'a, C> {
10792        self._scopes.clear();
10793        self
10794    }
10795}
10796
10797/// Updates the guest accelerators of a single Instance.
10798///
10799/// A builder for the *locations.instances.setAccelerator* method supported by a *project* resource.
10800/// It is not used directly, but through a [`ProjectMethods`] instance.
10801///
10802/// # Example
10803///
10804/// Instantiate a resource method builder
10805///
10806/// ```test_harness,no_run
10807/// # extern crate hyper;
10808/// # extern crate hyper_rustls;
10809/// # extern crate google_notebooks1 as notebooks1;
10810/// use notebooks1::api::SetInstanceAcceleratorRequest;
10811/// # async fn dox() {
10812/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10813///
10814/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10815/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10816/// #     .with_native_roots()
10817/// #     .unwrap()
10818/// #     .https_only()
10819/// #     .enable_http2()
10820/// #     .build();
10821///
10822/// # let executor = hyper_util::rt::TokioExecutor::new();
10823/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10824/// #     secret,
10825/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10826/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10827/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10828/// #     ),
10829/// # ).build().await.unwrap();
10830///
10831/// # let client = hyper_util::client::legacy::Client::builder(
10832/// #     hyper_util::rt::TokioExecutor::new()
10833/// # )
10834/// # .build(
10835/// #     hyper_rustls::HttpsConnectorBuilder::new()
10836/// #         .with_native_roots()
10837/// #         .unwrap()
10838/// #         .https_or_http()
10839/// #         .enable_http2()
10840/// #         .build()
10841/// # );
10842/// # let mut hub = AIPlatformNotebooks::new(client, auth);
10843/// // As the method needs a request, you would usually fill it with the desired information
10844/// // into the respective structure. Some of the parts shown here might not be applicable !
10845/// // Values shown here are possibly random and not representative !
10846/// let mut req = SetInstanceAcceleratorRequest::default();
10847///
10848/// // You can configure optional parameters by calling the respective setters at will, and
10849/// // execute the final call using `doit()`.
10850/// // Values shown here are possibly random and not representative !
10851/// let result = hub.projects().locations_instances_set_accelerator(req, "name")
10852///              .doit().await;
10853/// # }
10854/// ```
10855pub struct ProjectLocationInstanceSetAcceleratorCall<'a, C>
10856where
10857    C: 'a,
10858{
10859    hub: &'a AIPlatformNotebooks<C>,
10860    _request: SetInstanceAcceleratorRequest,
10861    _name: String,
10862    _delegate: Option<&'a mut dyn common::Delegate>,
10863    _additional_params: HashMap<String, String>,
10864    _scopes: BTreeSet<String>,
10865}
10866
10867impl<'a, C> common::CallBuilder for ProjectLocationInstanceSetAcceleratorCall<'a, C> {}
10868
10869impl<'a, C> ProjectLocationInstanceSetAcceleratorCall<'a, C>
10870where
10871    C: common::Connector,
10872{
10873    /// Perform the operation you have build so far.
10874    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
10875        use std::borrow::Cow;
10876        use std::io::{Read, Seek};
10877
10878        use common::{url::Params, ToParts};
10879        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10880
10881        let mut dd = common::DefaultDelegate;
10882        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10883        dlg.begin(common::MethodInfo {
10884            id: "notebooks.projects.locations.instances.setAccelerator",
10885            http_method: hyper::Method::PATCH,
10886        });
10887
10888        for &field in ["alt", "name"].iter() {
10889            if self._additional_params.contains_key(field) {
10890                dlg.finished(false);
10891                return Err(common::Error::FieldClash(field));
10892            }
10893        }
10894
10895        let mut params = Params::with_capacity(4 + self._additional_params.len());
10896        params.push("name", self._name);
10897
10898        params.extend(self._additional_params.iter());
10899
10900        params.push("alt", "json");
10901        let mut url = self.hub._base_url.clone() + "v1/{+name}:setAccelerator";
10902        if self._scopes.is_empty() {
10903            self._scopes
10904                .insert(Scope::CloudPlatform.as_ref().to_string());
10905        }
10906
10907        #[allow(clippy::single_element_loop)]
10908        for &(find_this, param_name) in [("{+name}", "name")].iter() {
10909            url = params.uri_replacement(url, param_name, find_this, true);
10910        }
10911        {
10912            let to_remove = ["name"];
10913            params.remove_params(&to_remove);
10914        }
10915
10916        let url = params.parse_with_url(&url);
10917
10918        let mut json_mime_type = mime::APPLICATION_JSON;
10919        let mut request_value_reader = {
10920            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10921            common::remove_json_null_values(&mut value);
10922            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10923            serde_json::to_writer(&mut dst, &value).unwrap();
10924            dst
10925        };
10926        let request_size = request_value_reader
10927            .seek(std::io::SeekFrom::End(0))
10928            .unwrap();
10929        request_value_reader
10930            .seek(std::io::SeekFrom::Start(0))
10931            .unwrap();
10932
10933        loop {
10934            let token = match self
10935                .hub
10936                .auth
10937                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10938                .await
10939            {
10940                Ok(token) => token,
10941                Err(e) => match dlg.token(e) {
10942                    Ok(token) => token,
10943                    Err(e) => {
10944                        dlg.finished(false);
10945                        return Err(common::Error::MissingToken(e));
10946                    }
10947                },
10948            };
10949            request_value_reader
10950                .seek(std::io::SeekFrom::Start(0))
10951                .unwrap();
10952            let mut req_result = {
10953                let client = &self.hub.client;
10954                dlg.pre_request();
10955                let mut req_builder = hyper::Request::builder()
10956                    .method(hyper::Method::PATCH)
10957                    .uri(url.as_str())
10958                    .header(USER_AGENT, self.hub._user_agent.clone());
10959
10960                if let Some(token) = token.as_ref() {
10961                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10962                }
10963
10964                let request = req_builder
10965                    .header(CONTENT_TYPE, json_mime_type.to_string())
10966                    .header(CONTENT_LENGTH, request_size as u64)
10967                    .body(common::to_body(
10968                        request_value_reader.get_ref().clone().into(),
10969                    ));
10970
10971                client.request(request.unwrap()).await
10972            };
10973
10974            match req_result {
10975                Err(err) => {
10976                    if let common::Retry::After(d) = dlg.http_error(&err) {
10977                        sleep(d).await;
10978                        continue;
10979                    }
10980                    dlg.finished(false);
10981                    return Err(common::Error::HttpError(err));
10982                }
10983                Ok(res) => {
10984                    let (mut parts, body) = res.into_parts();
10985                    let mut body = common::Body::new(body);
10986                    if !parts.status.is_success() {
10987                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10988                        let error = serde_json::from_str(&common::to_string(&bytes));
10989                        let response = common::to_response(parts, bytes.into());
10990
10991                        if let common::Retry::After(d) =
10992                            dlg.http_failure(&response, error.as_ref().ok())
10993                        {
10994                            sleep(d).await;
10995                            continue;
10996                        }
10997
10998                        dlg.finished(false);
10999
11000                        return Err(match error {
11001                            Ok(value) => common::Error::BadRequest(value),
11002                            _ => common::Error::Failure(response),
11003                        });
11004                    }
11005                    let response = {
11006                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11007                        let encoded = common::to_string(&bytes);
11008                        match serde_json::from_str(&encoded) {
11009                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11010                            Err(error) => {
11011                                dlg.response_json_decode_error(&encoded, &error);
11012                                return Err(common::Error::JsonDecodeError(
11013                                    encoded.to_string(),
11014                                    error,
11015                                ));
11016                            }
11017                        }
11018                    };
11019
11020                    dlg.finished(true);
11021                    return Ok(response);
11022                }
11023            }
11024        }
11025    }
11026
11027    ///
11028    /// Sets the *request* property to the given value.
11029    ///
11030    /// Even though the property as already been set when instantiating this call,
11031    /// we provide this method for API completeness.
11032    pub fn request(
11033        mut self,
11034        new_value: SetInstanceAcceleratorRequest,
11035    ) -> ProjectLocationInstanceSetAcceleratorCall<'a, C> {
11036        self._request = new_value;
11037        self
11038    }
11039    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
11040    ///
11041    /// Sets the *name* path property to the given value.
11042    ///
11043    /// Even though the property as already been set when instantiating this call,
11044    /// we provide this method for API completeness.
11045    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceSetAcceleratorCall<'a, C> {
11046        self._name = new_value.to_string();
11047        self
11048    }
11049    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11050    /// while executing the actual API request.
11051    ///
11052    /// ````text
11053    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11054    /// ````
11055    ///
11056    /// Sets the *delegate* property to the given value.
11057    pub fn delegate(
11058        mut self,
11059        new_value: &'a mut dyn common::Delegate,
11060    ) -> ProjectLocationInstanceSetAcceleratorCall<'a, C> {
11061        self._delegate = Some(new_value);
11062        self
11063    }
11064
11065    /// Set any additional parameter of the query string used in the request.
11066    /// It should be used to set parameters which are not yet available through their own
11067    /// setters.
11068    ///
11069    /// Please note that this method must not be used to set any of the known parameters
11070    /// which have their own setter method. If done anyway, the request will fail.
11071    ///
11072    /// # Additional Parameters
11073    ///
11074    /// * *$.xgafv* (query-string) - V1 error format.
11075    /// * *access_token* (query-string) - OAuth access token.
11076    /// * *alt* (query-string) - Data format for response.
11077    /// * *callback* (query-string) - JSONP
11078    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11079    /// * *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.
11080    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11081    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11082    /// * *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.
11083    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11084    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11085    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceSetAcceleratorCall<'a, C>
11086    where
11087        T: AsRef<str>,
11088    {
11089        self._additional_params
11090            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11091        self
11092    }
11093
11094    /// Identifies the authorization scope for the method you are building.
11095    ///
11096    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11097    /// [`Scope::CloudPlatform`].
11098    ///
11099    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11100    /// tokens for more than one scope.
11101    ///
11102    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11103    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11104    /// sufficient, a read-write scope will do as well.
11105    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceSetAcceleratorCall<'a, C>
11106    where
11107        St: AsRef<str>,
11108    {
11109        self._scopes.insert(String::from(scope.as_ref()));
11110        self
11111    }
11112    /// Identifies the authorization scope(s) for the method you are building.
11113    ///
11114    /// See [`Self::add_scope()`] for details.
11115    pub fn add_scopes<I, St>(
11116        mut self,
11117        scopes: I,
11118    ) -> ProjectLocationInstanceSetAcceleratorCall<'a, C>
11119    where
11120        I: IntoIterator<Item = St>,
11121        St: AsRef<str>,
11122    {
11123        self._scopes
11124            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11125        self
11126    }
11127
11128    /// Removes all scopes, and no default scope will be used either.
11129    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11130    /// for details).
11131    pub fn clear_scopes(mut self) -> ProjectLocationInstanceSetAcceleratorCall<'a, C> {
11132        self._scopes.clear();
11133        self
11134    }
11135}
11136
11137/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
11138///
11139/// A builder for the *locations.instances.setIamPolicy* method supported by a *project* resource.
11140/// It is not used directly, but through a [`ProjectMethods`] instance.
11141///
11142/// # Example
11143///
11144/// Instantiate a resource method builder
11145///
11146/// ```test_harness,no_run
11147/// # extern crate hyper;
11148/// # extern crate hyper_rustls;
11149/// # extern crate google_notebooks1 as notebooks1;
11150/// use notebooks1::api::SetIamPolicyRequest;
11151/// # async fn dox() {
11152/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11153///
11154/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11155/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11156/// #     .with_native_roots()
11157/// #     .unwrap()
11158/// #     .https_only()
11159/// #     .enable_http2()
11160/// #     .build();
11161///
11162/// # let executor = hyper_util::rt::TokioExecutor::new();
11163/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11164/// #     secret,
11165/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11166/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11167/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11168/// #     ),
11169/// # ).build().await.unwrap();
11170///
11171/// # let client = hyper_util::client::legacy::Client::builder(
11172/// #     hyper_util::rt::TokioExecutor::new()
11173/// # )
11174/// # .build(
11175/// #     hyper_rustls::HttpsConnectorBuilder::new()
11176/// #         .with_native_roots()
11177/// #         .unwrap()
11178/// #         .https_or_http()
11179/// #         .enable_http2()
11180/// #         .build()
11181/// # );
11182/// # let mut hub = AIPlatformNotebooks::new(client, auth);
11183/// // As the method needs a request, you would usually fill it with the desired information
11184/// // into the respective structure. Some of the parts shown here might not be applicable !
11185/// // Values shown here are possibly random and not representative !
11186/// let mut req = SetIamPolicyRequest::default();
11187///
11188/// // You can configure optional parameters by calling the respective setters at will, and
11189/// // execute the final call using `doit()`.
11190/// // Values shown here are possibly random and not representative !
11191/// let result = hub.projects().locations_instances_set_iam_policy(req, "resource")
11192///              .doit().await;
11193/// # }
11194/// ```
11195pub struct ProjectLocationInstanceSetIamPolicyCall<'a, C>
11196where
11197    C: 'a,
11198{
11199    hub: &'a AIPlatformNotebooks<C>,
11200    _request: SetIamPolicyRequest,
11201    _resource: String,
11202    _delegate: Option<&'a mut dyn common::Delegate>,
11203    _additional_params: HashMap<String, String>,
11204    _scopes: BTreeSet<String>,
11205}
11206
11207impl<'a, C> common::CallBuilder for ProjectLocationInstanceSetIamPolicyCall<'a, C> {}
11208
11209impl<'a, C> ProjectLocationInstanceSetIamPolicyCall<'a, C>
11210where
11211    C: common::Connector,
11212{
11213    /// Perform the operation you have build so far.
11214    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
11215        use std::borrow::Cow;
11216        use std::io::{Read, Seek};
11217
11218        use common::{url::Params, ToParts};
11219        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11220
11221        let mut dd = common::DefaultDelegate;
11222        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11223        dlg.begin(common::MethodInfo {
11224            id: "notebooks.projects.locations.instances.setIamPolicy",
11225            http_method: hyper::Method::POST,
11226        });
11227
11228        for &field in ["alt", "resource"].iter() {
11229            if self._additional_params.contains_key(field) {
11230                dlg.finished(false);
11231                return Err(common::Error::FieldClash(field));
11232            }
11233        }
11234
11235        let mut params = Params::with_capacity(4 + self._additional_params.len());
11236        params.push("resource", self._resource);
11237
11238        params.extend(self._additional_params.iter());
11239
11240        params.push("alt", "json");
11241        let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
11242        if self._scopes.is_empty() {
11243            self._scopes
11244                .insert(Scope::CloudPlatform.as_ref().to_string());
11245        }
11246
11247        #[allow(clippy::single_element_loop)]
11248        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
11249            url = params.uri_replacement(url, param_name, find_this, true);
11250        }
11251        {
11252            let to_remove = ["resource"];
11253            params.remove_params(&to_remove);
11254        }
11255
11256        let url = params.parse_with_url(&url);
11257
11258        let mut json_mime_type = mime::APPLICATION_JSON;
11259        let mut request_value_reader = {
11260            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11261            common::remove_json_null_values(&mut value);
11262            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11263            serde_json::to_writer(&mut dst, &value).unwrap();
11264            dst
11265        };
11266        let request_size = request_value_reader
11267            .seek(std::io::SeekFrom::End(0))
11268            .unwrap();
11269        request_value_reader
11270            .seek(std::io::SeekFrom::Start(0))
11271            .unwrap();
11272
11273        loop {
11274            let token = match self
11275                .hub
11276                .auth
11277                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11278                .await
11279            {
11280                Ok(token) => token,
11281                Err(e) => match dlg.token(e) {
11282                    Ok(token) => token,
11283                    Err(e) => {
11284                        dlg.finished(false);
11285                        return Err(common::Error::MissingToken(e));
11286                    }
11287                },
11288            };
11289            request_value_reader
11290                .seek(std::io::SeekFrom::Start(0))
11291                .unwrap();
11292            let mut req_result = {
11293                let client = &self.hub.client;
11294                dlg.pre_request();
11295                let mut req_builder = hyper::Request::builder()
11296                    .method(hyper::Method::POST)
11297                    .uri(url.as_str())
11298                    .header(USER_AGENT, self.hub._user_agent.clone());
11299
11300                if let Some(token) = token.as_ref() {
11301                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11302                }
11303
11304                let request = req_builder
11305                    .header(CONTENT_TYPE, json_mime_type.to_string())
11306                    .header(CONTENT_LENGTH, request_size as u64)
11307                    .body(common::to_body(
11308                        request_value_reader.get_ref().clone().into(),
11309                    ));
11310
11311                client.request(request.unwrap()).await
11312            };
11313
11314            match req_result {
11315                Err(err) => {
11316                    if let common::Retry::After(d) = dlg.http_error(&err) {
11317                        sleep(d).await;
11318                        continue;
11319                    }
11320                    dlg.finished(false);
11321                    return Err(common::Error::HttpError(err));
11322                }
11323                Ok(res) => {
11324                    let (mut parts, body) = res.into_parts();
11325                    let mut body = common::Body::new(body);
11326                    if !parts.status.is_success() {
11327                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11328                        let error = serde_json::from_str(&common::to_string(&bytes));
11329                        let response = common::to_response(parts, bytes.into());
11330
11331                        if let common::Retry::After(d) =
11332                            dlg.http_failure(&response, error.as_ref().ok())
11333                        {
11334                            sleep(d).await;
11335                            continue;
11336                        }
11337
11338                        dlg.finished(false);
11339
11340                        return Err(match error {
11341                            Ok(value) => common::Error::BadRequest(value),
11342                            _ => common::Error::Failure(response),
11343                        });
11344                    }
11345                    let response = {
11346                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11347                        let encoded = common::to_string(&bytes);
11348                        match serde_json::from_str(&encoded) {
11349                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11350                            Err(error) => {
11351                                dlg.response_json_decode_error(&encoded, &error);
11352                                return Err(common::Error::JsonDecodeError(
11353                                    encoded.to_string(),
11354                                    error,
11355                                ));
11356                            }
11357                        }
11358                    };
11359
11360                    dlg.finished(true);
11361                    return Ok(response);
11362                }
11363            }
11364        }
11365    }
11366
11367    ///
11368    /// Sets the *request* property to the given value.
11369    ///
11370    /// Even though the property as already been set when instantiating this call,
11371    /// we provide this method for API completeness.
11372    pub fn request(
11373        mut self,
11374        new_value: SetIamPolicyRequest,
11375    ) -> ProjectLocationInstanceSetIamPolicyCall<'a, C> {
11376        self._request = new_value;
11377        self
11378    }
11379    /// 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.
11380    ///
11381    /// Sets the *resource* 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 resource(mut self, new_value: &str) -> ProjectLocationInstanceSetIamPolicyCall<'a, C> {
11386        self._resource = new_value.to_string();
11387        self
11388    }
11389    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11390    /// while executing the actual API request.
11391    ///
11392    /// ````text
11393    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11394    /// ````
11395    ///
11396    /// Sets the *delegate* property to the given value.
11397    pub fn delegate(
11398        mut self,
11399        new_value: &'a mut dyn common::Delegate,
11400    ) -> ProjectLocationInstanceSetIamPolicyCall<'a, C> {
11401        self._delegate = Some(new_value);
11402        self
11403    }
11404
11405    /// Set any additional parameter of the query string used in the request.
11406    /// It should be used to set parameters which are not yet available through their own
11407    /// setters.
11408    ///
11409    /// Please note that this method must not be used to set any of the known parameters
11410    /// which have their own setter method. If done anyway, the request will fail.
11411    ///
11412    /// # Additional Parameters
11413    ///
11414    /// * *$.xgafv* (query-string) - V1 error format.
11415    /// * *access_token* (query-string) - OAuth access token.
11416    /// * *alt* (query-string) - Data format for response.
11417    /// * *callback* (query-string) - JSONP
11418    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11419    /// * *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.
11420    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11421    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11422    /// * *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.
11423    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11424    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11425    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceSetIamPolicyCall<'a, C>
11426    where
11427        T: AsRef<str>,
11428    {
11429        self._additional_params
11430            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11431        self
11432    }
11433
11434    /// Identifies the authorization scope for the method you are building.
11435    ///
11436    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11437    /// [`Scope::CloudPlatform`].
11438    ///
11439    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11440    /// tokens for more than one scope.
11441    ///
11442    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11443    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11444    /// sufficient, a read-write scope will do as well.
11445    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceSetIamPolicyCall<'a, C>
11446    where
11447        St: AsRef<str>,
11448    {
11449        self._scopes.insert(String::from(scope.as_ref()));
11450        self
11451    }
11452    /// Identifies the authorization scope(s) for the method you are building.
11453    ///
11454    /// See [`Self::add_scope()`] for details.
11455    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceSetIamPolicyCall<'a, C>
11456    where
11457        I: IntoIterator<Item = St>,
11458        St: AsRef<str>,
11459    {
11460        self._scopes
11461            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11462        self
11463    }
11464
11465    /// Removes all scopes, and no default scope will be used either.
11466    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11467    /// for details).
11468    pub fn clear_scopes(mut self) -> ProjectLocationInstanceSetIamPolicyCall<'a, C> {
11469        self._scopes.clear();
11470        self
11471    }
11472}
11473
11474/// Replaces all the labels of an Instance.
11475///
11476/// A builder for the *locations.instances.setLabels* method supported by a *project* resource.
11477/// It is not used directly, but through a [`ProjectMethods`] instance.
11478///
11479/// # Example
11480///
11481/// Instantiate a resource method builder
11482///
11483/// ```test_harness,no_run
11484/// # extern crate hyper;
11485/// # extern crate hyper_rustls;
11486/// # extern crate google_notebooks1 as notebooks1;
11487/// use notebooks1::api::SetInstanceLabelsRequest;
11488/// # async fn dox() {
11489/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11490///
11491/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11492/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11493/// #     .with_native_roots()
11494/// #     .unwrap()
11495/// #     .https_only()
11496/// #     .enable_http2()
11497/// #     .build();
11498///
11499/// # let executor = hyper_util::rt::TokioExecutor::new();
11500/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11501/// #     secret,
11502/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11503/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11504/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11505/// #     ),
11506/// # ).build().await.unwrap();
11507///
11508/// # let client = hyper_util::client::legacy::Client::builder(
11509/// #     hyper_util::rt::TokioExecutor::new()
11510/// # )
11511/// # .build(
11512/// #     hyper_rustls::HttpsConnectorBuilder::new()
11513/// #         .with_native_roots()
11514/// #         .unwrap()
11515/// #         .https_or_http()
11516/// #         .enable_http2()
11517/// #         .build()
11518/// # );
11519/// # let mut hub = AIPlatformNotebooks::new(client, auth);
11520/// // As the method needs a request, you would usually fill it with the desired information
11521/// // into the respective structure. Some of the parts shown here might not be applicable !
11522/// // Values shown here are possibly random and not representative !
11523/// let mut req = SetInstanceLabelsRequest::default();
11524///
11525/// // You can configure optional parameters by calling the respective setters at will, and
11526/// // execute the final call using `doit()`.
11527/// // Values shown here are possibly random and not representative !
11528/// let result = hub.projects().locations_instances_set_labels(req, "name")
11529///              .doit().await;
11530/// # }
11531/// ```
11532pub struct ProjectLocationInstanceSetLabelCall<'a, C>
11533where
11534    C: 'a,
11535{
11536    hub: &'a AIPlatformNotebooks<C>,
11537    _request: SetInstanceLabelsRequest,
11538    _name: String,
11539    _delegate: Option<&'a mut dyn common::Delegate>,
11540    _additional_params: HashMap<String, String>,
11541    _scopes: BTreeSet<String>,
11542}
11543
11544impl<'a, C> common::CallBuilder for ProjectLocationInstanceSetLabelCall<'a, C> {}
11545
11546impl<'a, C> ProjectLocationInstanceSetLabelCall<'a, C>
11547where
11548    C: common::Connector,
11549{
11550    /// Perform the operation you have build so far.
11551    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
11552        use std::borrow::Cow;
11553        use std::io::{Read, Seek};
11554
11555        use common::{url::Params, ToParts};
11556        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11557
11558        let mut dd = common::DefaultDelegate;
11559        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11560        dlg.begin(common::MethodInfo {
11561            id: "notebooks.projects.locations.instances.setLabels",
11562            http_method: hyper::Method::PATCH,
11563        });
11564
11565        for &field in ["alt", "name"].iter() {
11566            if self._additional_params.contains_key(field) {
11567                dlg.finished(false);
11568                return Err(common::Error::FieldClash(field));
11569            }
11570        }
11571
11572        let mut params = Params::with_capacity(4 + self._additional_params.len());
11573        params.push("name", self._name);
11574
11575        params.extend(self._additional_params.iter());
11576
11577        params.push("alt", "json");
11578        let mut url = self.hub._base_url.clone() + "v1/{+name}:setLabels";
11579        if self._scopes.is_empty() {
11580            self._scopes
11581                .insert(Scope::CloudPlatform.as_ref().to_string());
11582        }
11583
11584        #[allow(clippy::single_element_loop)]
11585        for &(find_this, param_name) in [("{+name}", "name")].iter() {
11586            url = params.uri_replacement(url, param_name, find_this, true);
11587        }
11588        {
11589            let to_remove = ["name"];
11590            params.remove_params(&to_remove);
11591        }
11592
11593        let url = params.parse_with_url(&url);
11594
11595        let mut json_mime_type = mime::APPLICATION_JSON;
11596        let mut request_value_reader = {
11597            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11598            common::remove_json_null_values(&mut value);
11599            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11600            serde_json::to_writer(&mut dst, &value).unwrap();
11601            dst
11602        };
11603        let request_size = request_value_reader
11604            .seek(std::io::SeekFrom::End(0))
11605            .unwrap();
11606        request_value_reader
11607            .seek(std::io::SeekFrom::Start(0))
11608            .unwrap();
11609
11610        loop {
11611            let token = match self
11612                .hub
11613                .auth
11614                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11615                .await
11616            {
11617                Ok(token) => token,
11618                Err(e) => match dlg.token(e) {
11619                    Ok(token) => token,
11620                    Err(e) => {
11621                        dlg.finished(false);
11622                        return Err(common::Error::MissingToken(e));
11623                    }
11624                },
11625            };
11626            request_value_reader
11627                .seek(std::io::SeekFrom::Start(0))
11628                .unwrap();
11629            let mut req_result = {
11630                let client = &self.hub.client;
11631                dlg.pre_request();
11632                let mut req_builder = hyper::Request::builder()
11633                    .method(hyper::Method::PATCH)
11634                    .uri(url.as_str())
11635                    .header(USER_AGENT, self.hub._user_agent.clone());
11636
11637                if let Some(token) = token.as_ref() {
11638                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11639                }
11640
11641                let request = req_builder
11642                    .header(CONTENT_TYPE, json_mime_type.to_string())
11643                    .header(CONTENT_LENGTH, request_size as u64)
11644                    .body(common::to_body(
11645                        request_value_reader.get_ref().clone().into(),
11646                    ));
11647
11648                client.request(request.unwrap()).await
11649            };
11650
11651            match req_result {
11652                Err(err) => {
11653                    if let common::Retry::After(d) = dlg.http_error(&err) {
11654                        sleep(d).await;
11655                        continue;
11656                    }
11657                    dlg.finished(false);
11658                    return Err(common::Error::HttpError(err));
11659                }
11660                Ok(res) => {
11661                    let (mut parts, body) = res.into_parts();
11662                    let mut body = common::Body::new(body);
11663                    if !parts.status.is_success() {
11664                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11665                        let error = serde_json::from_str(&common::to_string(&bytes));
11666                        let response = common::to_response(parts, bytes.into());
11667
11668                        if let common::Retry::After(d) =
11669                            dlg.http_failure(&response, error.as_ref().ok())
11670                        {
11671                            sleep(d).await;
11672                            continue;
11673                        }
11674
11675                        dlg.finished(false);
11676
11677                        return Err(match error {
11678                            Ok(value) => common::Error::BadRequest(value),
11679                            _ => common::Error::Failure(response),
11680                        });
11681                    }
11682                    let response = {
11683                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11684                        let encoded = common::to_string(&bytes);
11685                        match serde_json::from_str(&encoded) {
11686                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11687                            Err(error) => {
11688                                dlg.response_json_decode_error(&encoded, &error);
11689                                return Err(common::Error::JsonDecodeError(
11690                                    encoded.to_string(),
11691                                    error,
11692                                ));
11693                            }
11694                        }
11695                    };
11696
11697                    dlg.finished(true);
11698                    return Ok(response);
11699                }
11700            }
11701        }
11702    }
11703
11704    ///
11705    /// Sets the *request* property to the given value.
11706    ///
11707    /// Even though the property as already been set when instantiating this call,
11708    /// we provide this method for API completeness.
11709    pub fn request(
11710        mut self,
11711        new_value: SetInstanceLabelsRequest,
11712    ) -> ProjectLocationInstanceSetLabelCall<'a, C> {
11713        self._request = new_value;
11714        self
11715    }
11716    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
11717    ///
11718    /// Sets the *name* path property to the given value.
11719    ///
11720    /// Even though the property as already been set when instantiating this call,
11721    /// we provide this method for API completeness.
11722    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceSetLabelCall<'a, C> {
11723        self._name = new_value.to_string();
11724        self
11725    }
11726    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11727    /// while executing the actual API request.
11728    ///
11729    /// ````text
11730    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11731    /// ````
11732    ///
11733    /// Sets the *delegate* property to the given value.
11734    pub fn delegate(
11735        mut self,
11736        new_value: &'a mut dyn common::Delegate,
11737    ) -> ProjectLocationInstanceSetLabelCall<'a, C> {
11738        self._delegate = Some(new_value);
11739        self
11740    }
11741
11742    /// Set any additional parameter of the query string used in the request.
11743    /// It should be used to set parameters which are not yet available through their own
11744    /// setters.
11745    ///
11746    /// Please note that this method must not be used to set any of the known parameters
11747    /// which have their own setter method. If done anyway, the request will fail.
11748    ///
11749    /// # Additional Parameters
11750    ///
11751    /// * *$.xgafv* (query-string) - V1 error format.
11752    /// * *access_token* (query-string) - OAuth access token.
11753    /// * *alt* (query-string) - Data format for response.
11754    /// * *callback* (query-string) - JSONP
11755    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11756    /// * *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.
11757    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11758    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11759    /// * *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.
11760    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11761    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11762    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceSetLabelCall<'a, C>
11763    where
11764        T: AsRef<str>,
11765    {
11766        self._additional_params
11767            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11768        self
11769    }
11770
11771    /// Identifies the authorization scope for the method you are building.
11772    ///
11773    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11774    /// [`Scope::CloudPlatform`].
11775    ///
11776    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11777    /// tokens for more than one scope.
11778    ///
11779    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11780    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11781    /// sufficient, a read-write scope will do as well.
11782    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceSetLabelCall<'a, C>
11783    where
11784        St: AsRef<str>,
11785    {
11786        self._scopes.insert(String::from(scope.as_ref()));
11787        self
11788    }
11789    /// Identifies the authorization scope(s) for the method you are building.
11790    ///
11791    /// See [`Self::add_scope()`] for details.
11792    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceSetLabelCall<'a, C>
11793    where
11794        I: IntoIterator<Item = St>,
11795        St: AsRef<str>,
11796    {
11797        self._scopes
11798            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11799        self
11800    }
11801
11802    /// Removes all scopes, and no default scope will be used either.
11803    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11804    /// for details).
11805    pub fn clear_scopes(mut self) -> ProjectLocationInstanceSetLabelCall<'a, C> {
11806        self._scopes.clear();
11807        self
11808    }
11809}
11810
11811/// Updates the machine type of a single Instance.
11812///
11813/// A builder for the *locations.instances.setMachineType* method supported by a *project* resource.
11814/// It is not used directly, but through a [`ProjectMethods`] instance.
11815///
11816/// # Example
11817///
11818/// Instantiate a resource method builder
11819///
11820/// ```test_harness,no_run
11821/// # extern crate hyper;
11822/// # extern crate hyper_rustls;
11823/// # extern crate google_notebooks1 as notebooks1;
11824/// use notebooks1::api::SetInstanceMachineTypeRequest;
11825/// # async fn dox() {
11826/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11827///
11828/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11829/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11830/// #     .with_native_roots()
11831/// #     .unwrap()
11832/// #     .https_only()
11833/// #     .enable_http2()
11834/// #     .build();
11835///
11836/// # let executor = hyper_util::rt::TokioExecutor::new();
11837/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11838/// #     secret,
11839/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11840/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11841/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11842/// #     ),
11843/// # ).build().await.unwrap();
11844///
11845/// # let client = hyper_util::client::legacy::Client::builder(
11846/// #     hyper_util::rt::TokioExecutor::new()
11847/// # )
11848/// # .build(
11849/// #     hyper_rustls::HttpsConnectorBuilder::new()
11850/// #         .with_native_roots()
11851/// #         .unwrap()
11852/// #         .https_or_http()
11853/// #         .enable_http2()
11854/// #         .build()
11855/// # );
11856/// # let mut hub = AIPlatformNotebooks::new(client, auth);
11857/// // As the method needs a request, you would usually fill it with the desired information
11858/// // into the respective structure. Some of the parts shown here might not be applicable !
11859/// // Values shown here are possibly random and not representative !
11860/// let mut req = SetInstanceMachineTypeRequest::default();
11861///
11862/// // You can configure optional parameters by calling the respective setters at will, and
11863/// // execute the final call using `doit()`.
11864/// // Values shown here are possibly random and not representative !
11865/// let result = hub.projects().locations_instances_set_machine_type(req, "name")
11866///              .doit().await;
11867/// # }
11868/// ```
11869pub struct ProjectLocationInstanceSetMachineTypeCall<'a, C>
11870where
11871    C: 'a,
11872{
11873    hub: &'a AIPlatformNotebooks<C>,
11874    _request: SetInstanceMachineTypeRequest,
11875    _name: String,
11876    _delegate: Option<&'a mut dyn common::Delegate>,
11877    _additional_params: HashMap<String, String>,
11878    _scopes: BTreeSet<String>,
11879}
11880
11881impl<'a, C> common::CallBuilder for ProjectLocationInstanceSetMachineTypeCall<'a, C> {}
11882
11883impl<'a, C> ProjectLocationInstanceSetMachineTypeCall<'a, C>
11884where
11885    C: common::Connector,
11886{
11887    /// Perform the operation you have build so far.
11888    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
11889        use std::borrow::Cow;
11890        use std::io::{Read, Seek};
11891
11892        use common::{url::Params, ToParts};
11893        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11894
11895        let mut dd = common::DefaultDelegate;
11896        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11897        dlg.begin(common::MethodInfo {
11898            id: "notebooks.projects.locations.instances.setMachineType",
11899            http_method: hyper::Method::PATCH,
11900        });
11901
11902        for &field in ["alt", "name"].iter() {
11903            if self._additional_params.contains_key(field) {
11904                dlg.finished(false);
11905                return Err(common::Error::FieldClash(field));
11906            }
11907        }
11908
11909        let mut params = Params::with_capacity(4 + self._additional_params.len());
11910        params.push("name", self._name);
11911
11912        params.extend(self._additional_params.iter());
11913
11914        params.push("alt", "json");
11915        let mut url = self.hub._base_url.clone() + "v1/{+name}:setMachineType";
11916        if self._scopes.is_empty() {
11917            self._scopes
11918                .insert(Scope::CloudPlatform.as_ref().to_string());
11919        }
11920
11921        #[allow(clippy::single_element_loop)]
11922        for &(find_this, param_name) in [("{+name}", "name")].iter() {
11923            url = params.uri_replacement(url, param_name, find_this, true);
11924        }
11925        {
11926            let to_remove = ["name"];
11927            params.remove_params(&to_remove);
11928        }
11929
11930        let url = params.parse_with_url(&url);
11931
11932        let mut json_mime_type = mime::APPLICATION_JSON;
11933        let mut request_value_reader = {
11934            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11935            common::remove_json_null_values(&mut value);
11936            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11937            serde_json::to_writer(&mut dst, &value).unwrap();
11938            dst
11939        };
11940        let request_size = request_value_reader
11941            .seek(std::io::SeekFrom::End(0))
11942            .unwrap();
11943        request_value_reader
11944            .seek(std::io::SeekFrom::Start(0))
11945            .unwrap();
11946
11947        loop {
11948            let token = match self
11949                .hub
11950                .auth
11951                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11952                .await
11953            {
11954                Ok(token) => token,
11955                Err(e) => match dlg.token(e) {
11956                    Ok(token) => token,
11957                    Err(e) => {
11958                        dlg.finished(false);
11959                        return Err(common::Error::MissingToken(e));
11960                    }
11961                },
11962            };
11963            request_value_reader
11964                .seek(std::io::SeekFrom::Start(0))
11965                .unwrap();
11966            let mut req_result = {
11967                let client = &self.hub.client;
11968                dlg.pre_request();
11969                let mut req_builder = hyper::Request::builder()
11970                    .method(hyper::Method::PATCH)
11971                    .uri(url.as_str())
11972                    .header(USER_AGENT, self.hub._user_agent.clone());
11973
11974                if let Some(token) = token.as_ref() {
11975                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11976                }
11977
11978                let request = req_builder
11979                    .header(CONTENT_TYPE, json_mime_type.to_string())
11980                    .header(CONTENT_LENGTH, request_size as u64)
11981                    .body(common::to_body(
11982                        request_value_reader.get_ref().clone().into(),
11983                    ));
11984
11985                client.request(request.unwrap()).await
11986            };
11987
11988            match req_result {
11989                Err(err) => {
11990                    if let common::Retry::After(d) = dlg.http_error(&err) {
11991                        sleep(d).await;
11992                        continue;
11993                    }
11994                    dlg.finished(false);
11995                    return Err(common::Error::HttpError(err));
11996                }
11997                Ok(res) => {
11998                    let (mut parts, body) = res.into_parts();
11999                    let mut body = common::Body::new(body);
12000                    if !parts.status.is_success() {
12001                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12002                        let error = serde_json::from_str(&common::to_string(&bytes));
12003                        let response = common::to_response(parts, bytes.into());
12004
12005                        if let common::Retry::After(d) =
12006                            dlg.http_failure(&response, error.as_ref().ok())
12007                        {
12008                            sleep(d).await;
12009                            continue;
12010                        }
12011
12012                        dlg.finished(false);
12013
12014                        return Err(match error {
12015                            Ok(value) => common::Error::BadRequest(value),
12016                            _ => common::Error::Failure(response),
12017                        });
12018                    }
12019                    let response = {
12020                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12021                        let encoded = common::to_string(&bytes);
12022                        match serde_json::from_str(&encoded) {
12023                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12024                            Err(error) => {
12025                                dlg.response_json_decode_error(&encoded, &error);
12026                                return Err(common::Error::JsonDecodeError(
12027                                    encoded.to_string(),
12028                                    error,
12029                                ));
12030                            }
12031                        }
12032                    };
12033
12034                    dlg.finished(true);
12035                    return Ok(response);
12036                }
12037            }
12038        }
12039    }
12040
12041    ///
12042    /// Sets the *request* property to the given value.
12043    ///
12044    /// Even though the property as already been set when instantiating this call,
12045    /// we provide this method for API completeness.
12046    pub fn request(
12047        mut self,
12048        new_value: SetInstanceMachineTypeRequest,
12049    ) -> ProjectLocationInstanceSetMachineTypeCall<'a, C> {
12050        self._request = new_value;
12051        self
12052    }
12053    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
12054    ///
12055    /// Sets the *name* path property to the given value.
12056    ///
12057    /// Even though the property as already been set when instantiating this call,
12058    /// we provide this method for API completeness.
12059    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceSetMachineTypeCall<'a, C> {
12060        self._name = new_value.to_string();
12061        self
12062    }
12063    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12064    /// while executing the actual API request.
12065    ///
12066    /// ````text
12067    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12068    /// ````
12069    ///
12070    /// Sets the *delegate* property to the given value.
12071    pub fn delegate(
12072        mut self,
12073        new_value: &'a mut dyn common::Delegate,
12074    ) -> ProjectLocationInstanceSetMachineTypeCall<'a, C> {
12075        self._delegate = Some(new_value);
12076        self
12077    }
12078
12079    /// Set any additional parameter of the query string used in the request.
12080    /// It should be used to set parameters which are not yet available through their own
12081    /// setters.
12082    ///
12083    /// Please note that this method must not be used to set any of the known parameters
12084    /// which have their own setter method. If done anyway, the request will fail.
12085    ///
12086    /// # Additional Parameters
12087    ///
12088    /// * *$.xgafv* (query-string) - V1 error format.
12089    /// * *access_token* (query-string) - OAuth access token.
12090    /// * *alt* (query-string) - Data format for response.
12091    /// * *callback* (query-string) - JSONP
12092    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12093    /// * *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.
12094    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12095    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12096    /// * *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.
12097    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12098    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12099    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceSetMachineTypeCall<'a, C>
12100    where
12101        T: AsRef<str>,
12102    {
12103        self._additional_params
12104            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12105        self
12106    }
12107
12108    /// Identifies the authorization scope for the method you are building.
12109    ///
12110    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12111    /// [`Scope::CloudPlatform`].
12112    ///
12113    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12114    /// tokens for more than one scope.
12115    ///
12116    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12117    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12118    /// sufficient, a read-write scope will do as well.
12119    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceSetMachineTypeCall<'a, C>
12120    where
12121        St: AsRef<str>,
12122    {
12123        self._scopes.insert(String::from(scope.as_ref()));
12124        self
12125    }
12126    /// Identifies the authorization scope(s) for the method you are building.
12127    ///
12128    /// See [`Self::add_scope()`] for details.
12129    pub fn add_scopes<I, St>(
12130        mut self,
12131        scopes: I,
12132    ) -> ProjectLocationInstanceSetMachineTypeCall<'a, C>
12133    where
12134        I: IntoIterator<Item = St>,
12135        St: AsRef<str>,
12136    {
12137        self._scopes
12138            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12139        self
12140    }
12141
12142    /// Removes all scopes, and no default scope will be used either.
12143    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12144    /// for details).
12145    pub fn clear_scopes(mut self) -> ProjectLocationInstanceSetMachineTypeCall<'a, C> {
12146        self._scopes.clear();
12147        self
12148    }
12149}
12150
12151/// Starts a notebook instance.
12152///
12153/// A builder for the *locations.instances.start* method supported by a *project* resource.
12154/// It is not used directly, but through a [`ProjectMethods`] instance.
12155///
12156/// # Example
12157///
12158/// Instantiate a resource method builder
12159///
12160/// ```test_harness,no_run
12161/// # extern crate hyper;
12162/// # extern crate hyper_rustls;
12163/// # extern crate google_notebooks1 as notebooks1;
12164/// use notebooks1::api::StartInstanceRequest;
12165/// # async fn dox() {
12166/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12167///
12168/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12169/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12170/// #     .with_native_roots()
12171/// #     .unwrap()
12172/// #     .https_only()
12173/// #     .enable_http2()
12174/// #     .build();
12175///
12176/// # let executor = hyper_util::rt::TokioExecutor::new();
12177/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12178/// #     secret,
12179/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12180/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12181/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12182/// #     ),
12183/// # ).build().await.unwrap();
12184///
12185/// # let client = hyper_util::client::legacy::Client::builder(
12186/// #     hyper_util::rt::TokioExecutor::new()
12187/// # )
12188/// # .build(
12189/// #     hyper_rustls::HttpsConnectorBuilder::new()
12190/// #         .with_native_roots()
12191/// #         .unwrap()
12192/// #         .https_or_http()
12193/// #         .enable_http2()
12194/// #         .build()
12195/// # );
12196/// # let mut hub = AIPlatformNotebooks::new(client, auth);
12197/// // As the method needs a request, you would usually fill it with the desired information
12198/// // into the respective structure. Some of the parts shown here might not be applicable !
12199/// // Values shown here are possibly random and not representative !
12200/// let mut req = StartInstanceRequest::default();
12201///
12202/// // You can configure optional parameters by calling the respective setters at will, and
12203/// // execute the final call using `doit()`.
12204/// // Values shown here are possibly random and not representative !
12205/// let result = hub.projects().locations_instances_start(req, "name")
12206///              .doit().await;
12207/// # }
12208/// ```
12209pub struct ProjectLocationInstanceStartCall<'a, C>
12210where
12211    C: 'a,
12212{
12213    hub: &'a AIPlatformNotebooks<C>,
12214    _request: StartInstanceRequest,
12215    _name: String,
12216    _delegate: Option<&'a mut dyn common::Delegate>,
12217    _additional_params: HashMap<String, String>,
12218    _scopes: BTreeSet<String>,
12219}
12220
12221impl<'a, C> common::CallBuilder for ProjectLocationInstanceStartCall<'a, C> {}
12222
12223impl<'a, C> ProjectLocationInstanceStartCall<'a, C>
12224where
12225    C: common::Connector,
12226{
12227    /// Perform the operation you have build so far.
12228    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
12229        use std::borrow::Cow;
12230        use std::io::{Read, Seek};
12231
12232        use common::{url::Params, ToParts};
12233        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12234
12235        let mut dd = common::DefaultDelegate;
12236        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12237        dlg.begin(common::MethodInfo {
12238            id: "notebooks.projects.locations.instances.start",
12239            http_method: hyper::Method::POST,
12240        });
12241
12242        for &field in ["alt", "name"].iter() {
12243            if self._additional_params.contains_key(field) {
12244                dlg.finished(false);
12245                return Err(common::Error::FieldClash(field));
12246            }
12247        }
12248
12249        let mut params = Params::with_capacity(4 + self._additional_params.len());
12250        params.push("name", self._name);
12251
12252        params.extend(self._additional_params.iter());
12253
12254        params.push("alt", "json");
12255        let mut url = self.hub._base_url.clone() + "v1/{+name}:start";
12256        if self._scopes.is_empty() {
12257            self._scopes
12258                .insert(Scope::CloudPlatform.as_ref().to_string());
12259        }
12260
12261        #[allow(clippy::single_element_loop)]
12262        for &(find_this, param_name) in [("{+name}", "name")].iter() {
12263            url = params.uri_replacement(url, param_name, find_this, true);
12264        }
12265        {
12266            let to_remove = ["name"];
12267            params.remove_params(&to_remove);
12268        }
12269
12270        let url = params.parse_with_url(&url);
12271
12272        let mut json_mime_type = mime::APPLICATION_JSON;
12273        let mut request_value_reader = {
12274            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12275            common::remove_json_null_values(&mut value);
12276            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12277            serde_json::to_writer(&mut dst, &value).unwrap();
12278            dst
12279        };
12280        let request_size = request_value_reader
12281            .seek(std::io::SeekFrom::End(0))
12282            .unwrap();
12283        request_value_reader
12284            .seek(std::io::SeekFrom::Start(0))
12285            .unwrap();
12286
12287        loop {
12288            let token = match self
12289                .hub
12290                .auth
12291                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12292                .await
12293            {
12294                Ok(token) => token,
12295                Err(e) => match dlg.token(e) {
12296                    Ok(token) => token,
12297                    Err(e) => {
12298                        dlg.finished(false);
12299                        return Err(common::Error::MissingToken(e));
12300                    }
12301                },
12302            };
12303            request_value_reader
12304                .seek(std::io::SeekFrom::Start(0))
12305                .unwrap();
12306            let mut req_result = {
12307                let client = &self.hub.client;
12308                dlg.pre_request();
12309                let mut req_builder = hyper::Request::builder()
12310                    .method(hyper::Method::POST)
12311                    .uri(url.as_str())
12312                    .header(USER_AGENT, self.hub._user_agent.clone());
12313
12314                if let Some(token) = token.as_ref() {
12315                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12316                }
12317
12318                let request = req_builder
12319                    .header(CONTENT_TYPE, json_mime_type.to_string())
12320                    .header(CONTENT_LENGTH, request_size as u64)
12321                    .body(common::to_body(
12322                        request_value_reader.get_ref().clone().into(),
12323                    ));
12324
12325                client.request(request.unwrap()).await
12326            };
12327
12328            match req_result {
12329                Err(err) => {
12330                    if let common::Retry::After(d) = dlg.http_error(&err) {
12331                        sleep(d).await;
12332                        continue;
12333                    }
12334                    dlg.finished(false);
12335                    return Err(common::Error::HttpError(err));
12336                }
12337                Ok(res) => {
12338                    let (mut parts, body) = res.into_parts();
12339                    let mut body = common::Body::new(body);
12340                    if !parts.status.is_success() {
12341                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12342                        let error = serde_json::from_str(&common::to_string(&bytes));
12343                        let response = common::to_response(parts, bytes.into());
12344
12345                        if let common::Retry::After(d) =
12346                            dlg.http_failure(&response, error.as_ref().ok())
12347                        {
12348                            sleep(d).await;
12349                            continue;
12350                        }
12351
12352                        dlg.finished(false);
12353
12354                        return Err(match error {
12355                            Ok(value) => common::Error::BadRequest(value),
12356                            _ => common::Error::Failure(response),
12357                        });
12358                    }
12359                    let response = {
12360                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12361                        let encoded = common::to_string(&bytes);
12362                        match serde_json::from_str(&encoded) {
12363                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12364                            Err(error) => {
12365                                dlg.response_json_decode_error(&encoded, &error);
12366                                return Err(common::Error::JsonDecodeError(
12367                                    encoded.to_string(),
12368                                    error,
12369                                ));
12370                            }
12371                        }
12372                    };
12373
12374                    dlg.finished(true);
12375                    return Ok(response);
12376                }
12377            }
12378        }
12379    }
12380
12381    ///
12382    /// Sets the *request* property to the given value.
12383    ///
12384    /// Even though the property as already been set when instantiating this call,
12385    /// we provide this method for API completeness.
12386    pub fn request(
12387        mut self,
12388        new_value: StartInstanceRequest,
12389    ) -> ProjectLocationInstanceStartCall<'a, C> {
12390        self._request = new_value;
12391        self
12392    }
12393    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
12394    ///
12395    /// Sets the *name* path property to the given value.
12396    ///
12397    /// Even though the property as already been set when instantiating this call,
12398    /// we provide this method for API completeness.
12399    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceStartCall<'a, C> {
12400        self._name = new_value.to_string();
12401        self
12402    }
12403    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12404    /// while executing the actual API request.
12405    ///
12406    /// ````text
12407    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12408    /// ````
12409    ///
12410    /// Sets the *delegate* property to the given value.
12411    pub fn delegate(
12412        mut self,
12413        new_value: &'a mut dyn common::Delegate,
12414    ) -> ProjectLocationInstanceStartCall<'a, C> {
12415        self._delegate = Some(new_value);
12416        self
12417    }
12418
12419    /// Set any additional parameter of the query string used in the request.
12420    /// It should be used to set parameters which are not yet available through their own
12421    /// setters.
12422    ///
12423    /// Please note that this method must not be used to set any of the known parameters
12424    /// which have their own setter method. If done anyway, the request will fail.
12425    ///
12426    /// # Additional Parameters
12427    ///
12428    /// * *$.xgafv* (query-string) - V1 error format.
12429    /// * *access_token* (query-string) - OAuth access token.
12430    /// * *alt* (query-string) - Data format for response.
12431    /// * *callback* (query-string) - JSONP
12432    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12433    /// * *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.
12434    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12435    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12436    /// * *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.
12437    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12438    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12439    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceStartCall<'a, C>
12440    where
12441        T: AsRef<str>,
12442    {
12443        self._additional_params
12444            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12445        self
12446    }
12447
12448    /// Identifies the authorization scope for the method you are building.
12449    ///
12450    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12451    /// [`Scope::CloudPlatform`].
12452    ///
12453    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12454    /// tokens for more than one scope.
12455    ///
12456    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12457    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12458    /// sufficient, a read-write scope will do as well.
12459    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceStartCall<'a, C>
12460    where
12461        St: AsRef<str>,
12462    {
12463        self._scopes.insert(String::from(scope.as_ref()));
12464        self
12465    }
12466    /// Identifies the authorization scope(s) for the method you are building.
12467    ///
12468    /// See [`Self::add_scope()`] for details.
12469    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceStartCall<'a, C>
12470    where
12471        I: IntoIterator<Item = St>,
12472        St: AsRef<str>,
12473    {
12474        self._scopes
12475            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12476        self
12477    }
12478
12479    /// Removes all scopes, and no default scope will be used either.
12480    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12481    /// for details).
12482    pub fn clear_scopes(mut self) -> ProjectLocationInstanceStartCall<'a, C> {
12483        self._scopes.clear();
12484        self
12485    }
12486}
12487
12488/// Stops a notebook instance.
12489///
12490/// A builder for the *locations.instances.stop* method supported by a *project* resource.
12491/// It is not used directly, but through a [`ProjectMethods`] instance.
12492///
12493/// # Example
12494///
12495/// Instantiate a resource method builder
12496///
12497/// ```test_harness,no_run
12498/// # extern crate hyper;
12499/// # extern crate hyper_rustls;
12500/// # extern crate google_notebooks1 as notebooks1;
12501/// use notebooks1::api::StopInstanceRequest;
12502/// # async fn dox() {
12503/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12504///
12505/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12506/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12507/// #     .with_native_roots()
12508/// #     .unwrap()
12509/// #     .https_only()
12510/// #     .enable_http2()
12511/// #     .build();
12512///
12513/// # let executor = hyper_util::rt::TokioExecutor::new();
12514/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12515/// #     secret,
12516/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12517/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12518/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12519/// #     ),
12520/// # ).build().await.unwrap();
12521///
12522/// # let client = hyper_util::client::legacy::Client::builder(
12523/// #     hyper_util::rt::TokioExecutor::new()
12524/// # )
12525/// # .build(
12526/// #     hyper_rustls::HttpsConnectorBuilder::new()
12527/// #         .with_native_roots()
12528/// #         .unwrap()
12529/// #         .https_or_http()
12530/// #         .enable_http2()
12531/// #         .build()
12532/// # );
12533/// # let mut hub = AIPlatformNotebooks::new(client, auth);
12534/// // As the method needs a request, you would usually fill it with the desired information
12535/// // into the respective structure. Some of the parts shown here might not be applicable !
12536/// // Values shown here are possibly random and not representative !
12537/// let mut req = StopInstanceRequest::default();
12538///
12539/// // You can configure optional parameters by calling the respective setters at will, and
12540/// // execute the final call using `doit()`.
12541/// // Values shown here are possibly random and not representative !
12542/// let result = hub.projects().locations_instances_stop(req, "name")
12543///              .doit().await;
12544/// # }
12545/// ```
12546pub struct ProjectLocationInstanceStopCall<'a, C>
12547where
12548    C: 'a,
12549{
12550    hub: &'a AIPlatformNotebooks<C>,
12551    _request: StopInstanceRequest,
12552    _name: String,
12553    _delegate: Option<&'a mut dyn common::Delegate>,
12554    _additional_params: HashMap<String, String>,
12555    _scopes: BTreeSet<String>,
12556}
12557
12558impl<'a, C> common::CallBuilder for ProjectLocationInstanceStopCall<'a, C> {}
12559
12560impl<'a, C> ProjectLocationInstanceStopCall<'a, C>
12561where
12562    C: common::Connector,
12563{
12564    /// Perform the operation you have build so far.
12565    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
12566        use std::borrow::Cow;
12567        use std::io::{Read, Seek};
12568
12569        use common::{url::Params, ToParts};
12570        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12571
12572        let mut dd = common::DefaultDelegate;
12573        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12574        dlg.begin(common::MethodInfo {
12575            id: "notebooks.projects.locations.instances.stop",
12576            http_method: hyper::Method::POST,
12577        });
12578
12579        for &field in ["alt", "name"].iter() {
12580            if self._additional_params.contains_key(field) {
12581                dlg.finished(false);
12582                return Err(common::Error::FieldClash(field));
12583            }
12584        }
12585
12586        let mut params = Params::with_capacity(4 + self._additional_params.len());
12587        params.push("name", self._name);
12588
12589        params.extend(self._additional_params.iter());
12590
12591        params.push("alt", "json");
12592        let mut url = self.hub._base_url.clone() + "v1/{+name}:stop";
12593        if self._scopes.is_empty() {
12594            self._scopes
12595                .insert(Scope::CloudPlatform.as_ref().to_string());
12596        }
12597
12598        #[allow(clippy::single_element_loop)]
12599        for &(find_this, param_name) in [("{+name}", "name")].iter() {
12600            url = params.uri_replacement(url, param_name, find_this, true);
12601        }
12602        {
12603            let to_remove = ["name"];
12604            params.remove_params(&to_remove);
12605        }
12606
12607        let url = params.parse_with_url(&url);
12608
12609        let mut json_mime_type = mime::APPLICATION_JSON;
12610        let mut request_value_reader = {
12611            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12612            common::remove_json_null_values(&mut value);
12613            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12614            serde_json::to_writer(&mut dst, &value).unwrap();
12615            dst
12616        };
12617        let request_size = request_value_reader
12618            .seek(std::io::SeekFrom::End(0))
12619            .unwrap();
12620        request_value_reader
12621            .seek(std::io::SeekFrom::Start(0))
12622            .unwrap();
12623
12624        loop {
12625            let token = match self
12626                .hub
12627                .auth
12628                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12629                .await
12630            {
12631                Ok(token) => token,
12632                Err(e) => match dlg.token(e) {
12633                    Ok(token) => token,
12634                    Err(e) => {
12635                        dlg.finished(false);
12636                        return Err(common::Error::MissingToken(e));
12637                    }
12638                },
12639            };
12640            request_value_reader
12641                .seek(std::io::SeekFrom::Start(0))
12642                .unwrap();
12643            let mut req_result = {
12644                let client = &self.hub.client;
12645                dlg.pre_request();
12646                let mut req_builder = hyper::Request::builder()
12647                    .method(hyper::Method::POST)
12648                    .uri(url.as_str())
12649                    .header(USER_AGENT, self.hub._user_agent.clone());
12650
12651                if let Some(token) = token.as_ref() {
12652                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12653                }
12654
12655                let request = req_builder
12656                    .header(CONTENT_TYPE, json_mime_type.to_string())
12657                    .header(CONTENT_LENGTH, request_size as u64)
12658                    .body(common::to_body(
12659                        request_value_reader.get_ref().clone().into(),
12660                    ));
12661
12662                client.request(request.unwrap()).await
12663            };
12664
12665            match req_result {
12666                Err(err) => {
12667                    if let common::Retry::After(d) = dlg.http_error(&err) {
12668                        sleep(d).await;
12669                        continue;
12670                    }
12671                    dlg.finished(false);
12672                    return Err(common::Error::HttpError(err));
12673                }
12674                Ok(res) => {
12675                    let (mut parts, body) = res.into_parts();
12676                    let mut body = common::Body::new(body);
12677                    if !parts.status.is_success() {
12678                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12679                        let error = serde_json::from_str(&common::to_string(&bytes));
12680                        let response = common::to_response(parts, bytes.into());
12681
12682                        if let common::Retry::After(d) =
12683                            dlg.http_failure(&response, error.as_ref().ok())
12684                        {
12685                            sleep(d).await;
12686                            continue;
12687                        }
12688
12689                        dlg.finished(false);
12690
12691                        return Err(match error {
12692                            Ok(value) => common::Error::BadRequest(value),
12693                            _ => common::Error::Failure(response),
12694                        });
12695                    }
12696                    let response = {
12697                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12698                        let encoded = common::to_string(&bytes);
12699                        match serde_json::from_str(&encoded) {
12700                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12701                            Err(error) => {
12702                                dlg.response_json_decode_error(&encoded, &error);
12703                                return Err(common::Error::JsonDecodeError(
12704                                    encoded.to_string(),
12705                                    error,
12706                                ));
12707                            }
12708                        }
12709                    };
12710
12711                    dlg.finished(true);
12712                    return Ok(response);
12713                }
12714            }
12715        }
12716    }
12717
12718    ///
12719    /// Sets the *request* property to the given value.
12720    ///
12721    /// Even though the property as already been set when instantiating this call,
12722    /// we provide this method for API completeness.
12723    pub fn request(
12724        mut self,
12725        new_value: StopInstanceRequest,
12726    ) -> ProjectLocationInstanceStopCall<'a, C> {
12727        self._request = new_value;
12728        self
12729    }
12730    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
12731    ///
12732    /// Sets the *name* path property to the given value.
12733    ///
12734    /// Even though the property as already been set when instantiating this call,
12735    /// we provide this method for API completeness.
12736    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceStopCall<'a, C> {
12737        self._name = new_value.to_string();
12738        self
12739    }
12740    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12741    /// while executing the actual API request.
12742    ///
12743    /// ````text
12744    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12745    /// ````
12746    ///
12747    /// Sets the *delegate* property to the given value.
12748    pub fn delegate(
12749        mut self,
12750        new_value: &'a mut dyn common::Delegate,
12751    ) -> ProjectLocationInstanceStopCall<'a, C> {
12752        self._delegate = Some(new_value);
12753        self
12754    }
12755
12756    /// Set any additional parameter of the query string used in the request.
12757    /// It should be used to set parameters which are not yet available through their own
12758    /// setters.
12759    ///
12760    /// Please note that this method must not be used to set any of the known parameters
12761    /// which have their own setter method. If done anyway, the request will fail.
12762    ///
12763    /// # Additional Parameters
12764    ///
12765    /// * *$.xgafv* (query-string) - V1 error format.
12766    /// * *access_token* (query-string) - OAuth access token.
12767    /// * *alt* (query-string) - Data format for response.
12768    /// * *callback* (query-string) - JSONP
12769    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12770    /// * *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.
12771    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12772    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12773    /// * *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.
12774    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12775    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12776    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceStopCall<'a, C>
12777    where
12778        T: AsRef<str>,
12779    {
12780        self._additional_params
12781            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12782        self
12783    }
12784
12785    /// Identifies the authorization scope for the method you are building.
12786    ///
12787    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12788    /// [`Scope::CloudPlatform`].
12789    ///
12790    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12791    /// tokens for more than one scope.
12792    ///
12793    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12794    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12795    /// sufficient, a read-write scope will do as well.
12796    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceStopCall<'a, C>
12797    where
12798        St: AsRef<str>,
12799    {
12800        self._scopes.insert(String::from(scope.as_ref()));
12801        self
12802    }
12803    /// Identifies the authorization scope(s) for the method you are building.
12804    ///
12805    /// See [`Self::add_scope()`] for details.
12806    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceStopCall<'a, C>
12807    where
12808        I: IntoIterator<Item = St>,
12809        St: AsRef<str>,
12810    {
12811        self._scopes
12812            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12813        self
12814    }
12815
12816    /// Removes all scopes, and no default scope will be used either.
12817    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12818    /// for details).
12819    pub fn clear_scopes(mut self) -> ProjectLocationInstanceStopCall<'a, C> {
12820        self._scopes.clear();
12821        self
12822    }
12823}
12824
12825/// 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.
12826///
12827/// A builder for the *locations.instances.testIamPermissions* method supported by a *project* resource.
12828/// It is not used directly, but through a [`ProjectMethods`] instance.
12829///
12830/// # Example
12831///
12832/// Instantiate a resource method builder
12833///
12834/// ```test_harness,no_run
12835/// # extern crate hyper;
12836/// # extern crate hyper_rustls;
12837/// # extern crate google_notebooks1 as notebooks1;
12838/// use notebooks1::api::TestIamPermissionsRequest;
12839/// # async fn dox() {
12840/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12841///
12842/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12843/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12844/// #     .with_native_roots()
12845/// #     .unwrap()
12846/// #     .https_only()
12847/// #     .enable_http2()
12848/// #     .build();
12849///
12850/// # let executor = hyper_util::rt::TokioExecutor::new();
12851/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12852/// #     secret,
12853/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12854/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12855/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12856/// #     ),
12857/// # ).build().await.unwrap();
12858///
12859/// # let client = hyper_util::client::legacy::Client::builder(
12860/// #     hyper_util::rt::TokioExecutor::new()
12861/// # )
12862/// # .build(
12863/// #     hyper_rustls::HttpsConnectorBuilder::new()
12864/// #         .with_native_roots()
12865/// #         .unwrap()
12866/// #         .https_or_http()
12867/// #         .enable_http2()
12868/// #         .build()
12869/// # );
12870/// # let mut hub = AIPlatformNotebooks::new(client, auth);
12871/// // As the method needs a request, you would usually fill it with the desired information
12872/// // into the respective structure. Some of the parts shown here might not be applicable !
12873/// // Values shown here are possibly random and not representative !
12874/// let mut req = TestIamPermissionsRequest::default();
12875///
12876/// // You can configure optional parameters by calling the respective setters at will, and
12877/// // execute the final call using `doit()`.
12878/// // Values shown here are possibly random and not representative !
12879/// let result = hub.projects().locations_instances_test_iam_permissions(req, "resource")
12880///              .doit().await;
12881/// # }
12882/// ```
12883pub struct ProjectLocationInstanceTestIamPermissionCall<'a, C>
12884where
12885    C: 'a,
12886{
12887    hub: &'a AIPlatformNotebooks<C>,
12888    _request: TestIamPermissionsRequest,
12889    _resource: String,
12890    _delegate: Option<&'a mut dyn common::Delegate>,
12891    _additional_params: HashMap<String, String>,
12892    _scopes: BTreeSet<String>,
12893}
12894
12895impl<'a, C> common::CallBuilder for ProjectLocationInstanceTestIamPermissionCall<'a, C> {}
12896
12897impl<'a, C> ProjectLocationInstanceTestIamPermissionCall<'a, C>
12898where
12899    C: common::Connector,
12900{
12901    /// Perform the operation you have build so far.
12902    pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
12903        use std::borrow::Cow;
12904        use std::io::{Read, Seek};
12905
12906        use common::{url::Params, ToParts};
12907        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12908
12909        let mut dd = common::DefaultDelegate;
12910        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12911        dlg.begin(common::MethodInfo {
12912            id: "notebooks.projects.locations.instances.testIamPermissions",
12913            http_method: hyper::Method::POST,
12914        });
12915
12916        for &field in ["alt", "resource"].iter() {
12917            if self._additional_params.contains_key(field) {
12918                dlg.finished(false);
12919                return Err(common::Error::FieldClash(field));
12920            }
12921        }
12922
12923        let mut params = Params::with_capacity(4 + self._additional_params.len());
12924        params.push("resource", self._resource);
12925
12926        params.extend(self._additional_params.iter());
12927
12928        params.push("alt", "json");
12929        let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
12930        if self._scopes.is_empty() {
12931            self._scopes
12932                .insert(Scope::CloudPlatform.as_ref().to_string());
12933        }
12934
12935        #[allow(clippy::single_element_loop)]
12936        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
12937            url = params.uri_replacement(url, param_name, find_this, true);
12938        }
12939        {
12940            let to_remove = ["resource"];
12941            params.remove_params(&to_remove);
12942        }
12943
12944        let url = params.parse_with_url(&url);
12945
12946        let mut json_mime_type = mime::APPLICATION_JSON;
12947        let mut request_value_reader = {
12948            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12949            common::remove_json_null_values(&mut value);
12950            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12951            serde_json::to_writer(&mut dst, &value).unwrap();
12952            dst
12953        };
12954        let request_size = request_value_reader
12955            .seek(std::io::SeekFrom::End(0))
12956            .unwrap();
12957        request_value_reader
12958            .seek(std::io::SeekFrom::Start(0))
12959            .unwrap();
12960
12961        loop {
12962            let token = match self
12963                .hub
12964                .auth
12965                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12966                .await
12967            {
12968                Ok(token) => token,
12969                Err(e) => match dlg.token(e) {
12970                    Ok(token) => token,
12971                    Err(e) => {
12972                        dlg.finished(false);
12973                        return Err(common::Error::MissingToken(e));
12974                    }
12975                },
12976            };
12977            request_value_reader
12978                .seek(std::io::SeekFrom::Start(0))
12979                .unwrap();
12980            let mut req_result = {
12981                let client = &self.hub.client;
12982                dlg.pre_request();
12983                let mut req_builder = hyper::Request::builder()
12984                    .method(hyper::Method::POST)
12985                    .uri(url.as_str())
12986                    .header(USER_AGENT, self.hub._user_agent.clone());
12987
12988                if let Some(token) = token.as_ref() {
12989                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12990                }
12991
12992                let request = req_builder
12993                    .header(CONTENT_TYPE, json_mime_type.to_string())
12994                    .header(CONTENT_LENGTH, request_size as u64)
12995                    .body(common::to_body(
12996                        request_value_reader.get_ref().clone().into(),
12997                    ));
12998
12999                client.request(request.unwrap()).await
13000            };
13001
13002            match req_result {
13003                Err(err) => {
13004                    if let common::Retry::After(d) = dlg.http_error(&err) {
13005                        sleep(d).await;
13006                        continue;
13007                    }
13008                    dlg.finished(false);
13009                    return Err(common::Error::HttpError(err));
13010                }
13011                Ok(res) => {
13012                    let (mut parts, body) = res.into_parts();
13013                    let mut body = common::Body::new(body);
13014                    if !parts.status.is_success() {
13015                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13016                        let error = serde_json::from_str(&common::to_string(&bytes));
13017                        let response = common::to_response(parts, bytes.into());
13018
13019                        if let common::Retry::After(d) =
13020                            dlg.http_failure(&response, error.as_ref().ok())
13021                        {
13022                            sleep(d).await;
13023                            continue;
13024                        }
13025
13026                        dlg.finished(false);
13027
13028                        return Err(match error {
13029                            Ok(value) => common::Error::BadRequest(value),
13030                            _ => common::Error::Failure(response),
13031                        });
13032                    }
13033                    let response = {
13034                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13035                        let encoded = common::to_string(&bytes);
13036                        match serde_json::from_str(&encoded) {
13037                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13038                            Err(error) => {
13039                                dlg.response_json_decode_error(&encoded, &error);
13040                                return Err(common::Error::JsonDecodeError(
13041                                    encoded.to_string(),
13042                                    error,
13043                                ));
13044                            }
13045                        }
13046                    };
13047
13048                    dlg.finished(true);
13049                    return Ok(response);
13050                }
13051            }
13052        }
13053    }
13054
13055    ///
13056    /// Sets the *request* property to the given value.
13057    ///
13058    /// Even though the property as already been set when instantiating this call,
13059    /// we provide this method for API completeness.
13060    pub fn request(
13061        mut self,
13062        new_value: TestIamPermissionsRequest,
13063    ) -> ProjectLocationInstanceTestIamPermissionCall<'a, C> {
13064        self._request = new_value;
13065        self
13066    }
13067    /// 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.
13068    ///
13069    /// Sets the *resource* path property to the given value.
13070    ///
13071    /// Even though the property as already been set when instantiating this call,
13072    /// we provide this method for API completeness.
13073    pub fn resource(
13074        mut self,
13075        new_value: &str,
13076    ) -> ProjectLocationInstanceTestIamPermissionCall<'a, C> {
13077        self._resource = new_value.to_string();
13078        self
13079    }
13080    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13081    /// while executing the actual API request.
13082    ///
13083    /// ````text
13084    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13085    /// ````
13086    ///
13087    /// Sets the *delegate* property to the given value.
13088    pub fn delegate(
13089        mut self,
13090        new_value: &'a mut dyn common::Delegate,
13091    ) -> ProjectLocationInstanceTestIamPermissionCall<'a, C> {
13092        self._delegate = Some(new_value);
13093        self
13094    }
13095
13096    /// Set any additional parameter of the query string used in the request.
13097    /// It should be used to set parameters which are not yet available through their own
13098    /// setters.
13099    ///
13100    /// Please note that this method must not be used to set any of the known parameters
13101    /// which have their own setter method. If done anyway, the request will fail.
13102    ///
13103    /// # Additional Parameters
13104    ///
13105    /// * *$.xgafv* (query-string) - V1 error format.
13106    /// * *access_token* (query-string) - OAuth access token.
13107    /// * *alt* (query-string) - Data format for response.
13108    /// * *callback* (query-string) - JSONP
13109    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13110    /// * *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.
13111    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13112    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13113    /// * *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.
13114    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13115    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13116    pub fn param<T>(
13117        mut self,
13118        name: T,
13119        value: T,
13120    ) -> ProjectLocationInstanceTestIamPermissionCall<'a, C>
13121    where
13122        T: AsRef<str>,
13123    {
13124        self._additional_params
13125            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13126        self
13127    }
13128
13129    /// Identifies the authorization scope for the method you are building.
13130    ///
13131    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13132    /// [`Scope::CloudPlatform`].
13133    ///
13134    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13135    /// tokens for more than one scope.
13136    ///
13137    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13138    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13139    /// sufficient, a read-write scope will do as well.
13140    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceTestIamPermissionCall<'a, C>
13141    where
13142        St: AsRef<str>,
13143    {
13144        self._scopes.insert(String::from(scope.as_ref()));
13145        self
13146    }
13147    /// Identifies the authorization scope(s) for the method you are building.
13148    ///
13149    /// See [`Self::add_scope()`] for details.
13150    pub fn add_scopes<I, St>(
13151        mut self,
13152        scopes: I,
13153    ) -> ProjectLocationInstanceTestIamPermissionCall<'a, C>
13154    where
13155        I: IntoIterator<Item = St>,
13156        St: AsRef<str>,
13157    {
13158        self._scopes
13159            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13160        self
13161    }
13162
13163    /// Removes all scopes, and no default scope will be used either.
13164    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13165    /// for details).
13166    pub fn clear_scopes(mut self) -> ProjectLocationInstanceTestIamPermissionCall<'a, C> {
13167        self._scopes.clear();
13168        self
13169    }
13170}
13171
13172/// Update Notebook Instance configurations.
13173///
13174/// A builder for the *locations.instances.updateConfig* method supported by a *project* resource.
13175/// It is not used directly, but through a [`ProjectMethods`] instance.
13176///
13177/// # Example
13178///
13179/// Instantiate a resource method builder
13180///
13181/// ```test_harness,no_run
13182/// # extern crate hyper;
13183/// # extern crate hyper_rustls;
13184/// # extern crate google_notebooks1 as notebooks1;
13185/// use notebooks1::api::UpdateInstanceConfigRequest;
13186/// # async fn dox() {
13187/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13188///
13189/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13190/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13191/// #     .with_native_roots()
13192/// #     .unwrap()
13193/// #     .https_only()
13194/// #     .enable_http2()
13195/// #     .build();
13196///
13197/// # let executor = hyper_util::rt::TokioExecutor::new();
13198/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13199/// #     secret,
13200/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13201/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13202/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13203/// #     ),
13204/// # ).build().await.unwrap();
13205///
13206/// # let client = hyper_util::client::legacy::Client::builder(
13207/// #     hyper_util::rt::TokioExecutor::new()
13208/// # )
13209/// # .build(
13210/// #     hyper_rustls::HttpsConnectorBuilder::new()
13211/// #         .with_native_roots()
13212/// #         .unwrap()
13213/// #         .https_or_http()
13214/// #         .enable_http2()
13215/// #         .build()
13216/// # );
13217/// # let mut hub = AIPlatformNotebooks::new(client, auth);
13218/// // As the method needs a request, you would usually fill it with the desired information
13219/// // into the respective structure. Some of the parts shown here might not be applicable !
13220/// // Values shown here are possibly random and not representative !
13221/// let mut req = UpdateInstanceConfigRequest::default();
13222///
13223/// // You can configure optional parameters by calling the respective setters at will, and
13224/// // execute the final call using `doit()`.
13225/// // Values shown here are possibly random and not representative !
13226/// let result = hub.projects().locations_instances_update_config(req, "name")
13227///              .doit().await;
13228/// # }
13229/// ```
13230pub struct ProjectLocationInstanceUpdateConfigCall<'a, C>
13231where
13232    C: 'a,
13233{
13234    hub: &'a AIPlatformNotebooks<C>,
13235    _request: UpdateInstanceConfigRequest,
13236    _name: String,
13237    _delegate: Option<&'a mut dyn common::Delegate>,
13238    _additional_params: HashMap<String, String>,
13239    _scopes: BTreeSet<String>,
13240}
13241
13242impl<'a, C> common::CallBuilder for ProjectLocationInstanceUpdateConfigCall<'a, C> {}
13243
13244impl<'a, C> ProjectLocationInstanceUpdateConfigCall<'a, C>
13245where
13246    C: common::Connector,
13247{
13248    /// Perform the operation you have build so far.
13249    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
13250        use std::borrow::Cow;
13251        use std::io::{Read, Seek};
13252
13253        use common::{url::Params, ToParts};
13254        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13255
13256        let mut dd = common::DefaultDelegate;
13257        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13258        dlg.begin(common::MethodInfo {
13259            id: "notebooks.projects.locations.instances.updateConfig",
13260            http_method: hyper::Method::PATCH,
13261        });
13262
13263        for &field in ["alt", "name"].iter() {
13264            if self._additional_params.contains_key(field) {
13265                dlg.finished(false);
13266                return Err(common::Error::FieldClash(field));
13267            }
13268        }
13269
13270        let mut params = Params::with_capacity(4 + self._additional_params.len());
13271        params.push("name", self._name);
13272
13273        params.extend(self._additional_params.iter());
13274
13275        params.push("alt", "json");
13276        let mut url = self.hub._base_url.clone() + "v1/{+name}:updateConfig";
13277        if self._scopes.is_empty() {
13278            self._scopes
13279                .insert(Scope::CloudPlatform.as_ref().to_string());
13280        }
13281
13282        #[allow(clippy::single_element_loop)]
13283        for &(find_this, param_name) in [("{+name}", "name")].iter() {
13284            url = params.uri_replacement(url, param_name, find_this, true);
13285        }
13286        {
13287            let to_remove = ["name"];
13288            params.remove_params(&to_remove);
13289        }
13290
13291        let url = params.parse_with_url(&url);
13292
13293        let mut json_mime_type = mime::APPLICATION_JSON;
13294        let mut request_value_reader = {
13295            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13296            common::remove_json_null_values(&mut value);
13297            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13298            serde_json::to_writer(&mut dst, &value).unwrap();
13299            dst
13300        };
13301        let request_size = request_value_reader
13302            .seek(std::io::SeekFrom::End(0))
13303            .unwrap();
13304        request_value_reader
13305            .seek(std::io::SeekFrom::Start(0))
13306            .unwrap();
13307
13308        loop {
13309            let token = match self
13310                .hub
13311                .auth
13312                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13313                .await
13314            {
13315                Ok(token) => token,
13316                Err(e) => match dlg.token(e) {
13317                    Ok(token) => token,
13318                    Err(e) => {
13319                        dlg.finished(false);
13320                        return Err(common::Error::MissingToken(e));
13321                    }
13322                },
13323            };
13324            request_value_reader
13325                .seek(std::io::SeekFrom::Start(0))
13326                .unwrap();
13327            let mut req_result = {
13328                let client = &self.hub.client;
13329                dlg.pre_request();
13330                let mut req_builder = hyper::Request::builder()
13331                    .method(hyper::Method::PATCH)
13332                    .uri(url.as_str())
13333                    .header(USER_AGENT, self.hub._user_agent.clone());
13334
13335                if let Some(token) = token.as_ref() {
13336                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13337                }
13338
13339                let request = req_builder
13340                    .header(CONTENT_TYPE, json_mime_type.to_string())
13341                    .header(CONTENT_LENGTH, request_size as u64)
13342                    .body(common::to_body(
13343                        request_value_reader.get_ref().clone().into(),
13344                    ));
13345
13346                client.request(request.unwrap()).await
13347            };
13348
13349            match req_result {
13350                Err(err) => {
13351                    if let common::Retry::After(d) = dlg.http_error(&err) {
13352                        sleep(d).await;
13353                        continue;
13354                    }
13355                    dlg.finished(false);
13356                    return Err(common::Error::HttpError(err));
13357                }
13358                Ok(res) => {
13359                    let (mut parts, body) = res.into_parts();
13360                    let mut body = common::Body::new(body);
13361                    if !parts.status.is_success() {
13362                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13363                        let error = serde_json::from_str(&common::to_string(&bytes));
13364                        let response = common::to_response(parts, bytes.into());
13365
13366                        if let common::Retry::After(d) =
13367                            dlg.http_failure(&response, error.as_ref().ok())
13368                        {
13369                            sleep(d).await;
13370                            continue;
13371                        }
13372
13373                        dlg.finished(false);
13374
13375                        return Err(match error {
13376                            Ok(value) => common::Error::BadRequest(value),
13377                            _ => common::Error::Failure(response),
13378                        });
13379                    }
13380                    let response = {
13381                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13382                        let encoded = common::to_string(&bytes);
13383                        match serde_json::from_str(&encoded) {
13384                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13385                            Err(error) => {
13386                                dlg.response_json_decode_error(&encoded, &error);
13387                                return Err(common::Error::JsonDecodeError(
13388                                    encoded.to_string(),
13389                                    error,
13390                                ));
13391                            }
13392                        }
13393                    };
13394
13395                    dlg.finished(true);
13396                    return Ok(response);
13397                }
13398            }
13399        }
13400    }
13401
13402    ///
13403    /// Sets the *request* property to the given value.
13404    ///
13405    /// Even though the property as already been set when instantiating this call,
13406    /// we provide this method for API completeness.
13407    pub fn request(
13408        mut self,
13409        new_value: UpdateInstanceConfigRequest,
13410    ) -> ProjectLocationInstanceUpdateConfigCall<'a, C> {
13411        self._request = new_value;
13412        self
13413    }
13414    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
13415    ///
13416    /// Sets the *name* path property to the given value.
13417    ///
13418    /// Even though the property as already been set when instantiating this call,
13419    /// we provide this method for API completeness.
13420    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceUpdateConfigCall<'a, C> {
13421        self._name = new_value.to_string();
13422        self
13423    }
13424    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13425    /// while executing the actual API request.
13426    ///
13427    /// ````text
13428    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13429    /// ````
13430    ///
13431    /// Sets the *delegate* property to the given value.
13432    pub fn delegate(
13433        mut self,
13434        new_value: &'a mut dyn common::Delegate,
13435    ) -> ProjectLocationInstanceUpdateConfigCall<'a, C> {
13436        self._delegate = Some(new_value);
13437        self
13438    }
13439
13440    /// Set any additional parameter of the query string used in the request.
13441    /// It should be used to set parameters which are not yet available through their own
13442    /// setters.
13443    ///
13444    /// Please note that this method must not be used to set any of the known parameters
13445    /// which have their own setter method. If done anyway, the request will fail.
13446    ///
13447    /// # Additional Parameters
13448    ///
13449    /// * *$.xgafv* (query-string) - V1 error format.
13450    /// * *access_token* (query-string) - OAuth access token.
13451    /// * *alt* (query-string) - Data format for response.
13452    /// * *callback* (query-string) - JSONP
13453    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13454    /// * *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.
13455    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13456    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13457    /// * *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.
13458    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13459    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13460    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceUpdateConfigCall<'a, C>
13461    where
13462        T: AsRef<str>,
13463    {
13464        self._additional_params
13465            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13466        self
13467    }
13468
13469    /// Identifies the authorization scope for the method you are building.
13470    ///
13471    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13472    /// [`Scope::CloudPlatform`].
13473    ///
13474    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13475    /// tokens for more than one scope.
13476    ///
13477    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13478    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13479    /// sufficient, a read-write scope will do as well.
13480    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceUpdateConfigCall<'a, C>
13481    where
13482        St: AsRef<str>,
13483    {
13484        self._scopes.insert(String::from(scope.as_ref()));
13485        self
13486    }
13487    /// Identifies the authorization scope(s) for the method you are building.
13488    ///
13489    /// See [`Self::add_scope()`] for details.
13490    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceUpdateConfigCall<'a, C>
13491    where
13492        I: IntoIterator<Item = St>,
13493        St: AsRef<str>,
13494    {
13495        self._scopes
13496            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13497        self
13498    }
13499
13500    /// Removes all scopes, and no default scope will be used either.
13501    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13502    /// for details).
13503    pub fn clear_scopes(mut self) -> ProjectLocationInstanceUpdateConfigCall<'a, C> {
13504        self._scopes.clear();
13505        self
13506    }
13507}
13508
13509/// Add/update metadata items for an instance.
13510///
13511/// A builder for the *locations.instances.updateMetadataItems* method supported by a *project* resource.
13512/// It is not used directly, but through a [`ProjectMethods`] instance.
13513///
13514/// # Example
13515///
13516/// Instantiate a resource method builder
13517///
13518/// ```test_harness,no_run
13519/// # extern crate hyper;
13520/// # extern crate hyper_rustls;
13521/// # extern crate google_notebooks1 as notebooks1;
13522/// use notebooks1::api::UpdateInstanceMetadataItemsRequest;
13523/// # async fn dox() {
13524/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13525///
13526/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13527/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13528/// #     .with_native_roots()
13529/// #     .unwrap()
13530/// #     .https_only()
13531/// #     .enable_http2()
13532/// #     .build();
13533///
13534/// # let executor = hyper_util::rt::TokioExecutor::new();
13535/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13536/// #     secret,
13537/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13538/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13539/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13540/// #     ),
13541/// # ).build().await.unwrap();
13542///
13543/// # let client = hyper_util::client::legacy::Client::builder(
13544/// #     hyper_util::rt::TokioExecutor::new()
13545/// # )
13546/// # .build(
13547/// #     hyper_rustls::HttpsConnectorBuilder::new()
13548/// #         .with_native_roots()
13549/// #         .unwrap()
13550/// #         .https_or_http()
13551/// #         .enable_http2()
13552/// #         .build()
13553/// # );
13554/// # let mut hub = AIPlatformNotebooks::new(client, auth);
13555/// // As the method needs a request, you would usually fill it with the desired information
13556/// // into the respective structure. Some of the parts shown here might not be applicable !
13557/// // Values shown here are possibly random and not representative !
13558/// let mut req = UpdateInstanceMetadataItemsRequest::default();
13559///
13560/// // You can configure optional parameters by calling the respective setters at will, and
13561/// // execute the final call using `doit()`.
13562/// // Values shown here are possibly random and not representative !
13563/// let result = hub.projects().locations_instances_update_metadata_items(req, "name")
13564///              .doit().await;
13565/// # }
13566/// ```
13567pub struct ProjectLocationInstanceUpdateMetadataItemCall<'a, C>
13568where
13569    C: 'a,
13570{
13571    hub: &'a AIPlatformNotebooks<C>,
13572    _request: UpdateInstanceMetadataItemsRequest,
13573    _name: String,
13574    _delegate: Option<&'a mut dyn common::Delegate>,
13575    _additional_params: HashMap<String, String>,
13576    _scopes: BTreeSet<String>,
13577}
13578
13579impl<'a, C> common::CallBuilder for ProjectLocationInstanceUpdateMetadataItemCall<'a, C> {}
13580
13581impl<'a, C> ProjectLocationInstanceUpdateMetadataItemCall<'a, C>
13582where
13583    C: common::Connector,
13584{
13585    /// Perform the operation you have build so far.
13586    pub async fn doit(
13587        mut self,
13588    ) -> common::Result<(common::Response, UpdateInstanceMetadataItemsResponse)> {
13589        use std::borrow::Cow;
13590        use std::io::{Read, Seek};
13591
13592        use common::{url::Params, ToParts};
13593        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13594
13595        let mut dd = common::DefaultDelegate;
13596        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13597        dlg.begin(common::MethodInfo {
13598            id: "notebooks.projects.locations.instances.updateMetadataItems",
13599            http_method: hyper::Method::PATCH,
13600        });
13601
13602        for &field in ["alt", "name"].iter() {
13603            if self._additional_params.contains_key(field) {
13604                dlg.finished(false);
13605                return Err(common::Error::FieldClash(field));
13606            }
13607        }
13608
13609        let mut params = Params::with_capacity(4 + self._additional_params.len());
13610        params.push("name", self._name);
13611
13612        params.extend(self._additional_params.iter());
13613
13614        params.push("alt", "json");
13615        let mut url = self.hub._base_url.clone() + "v1/{+name}:updateMetadataItems";
13616        if self._scopes.is_empty() {
13617            self._scopes
13618                .insert(Scope::CloudPlatform.as_ref().to_string());
13619        }
13620
13621        #[allow(clippy::single_element_loop)]
13622        for &(find_this, param_name) in [("{+name}", "name")].iter() {
13623            url = params.uri_replacement(url, param_name, find_this, true);
13624        }
13625        {
13626            let to_remove = ["name"];
13627            params.remove_params(&to_remove);
13628        }
13629
13630        let url = params.parse_with_url(&url);
13631
13632        let mut json_mime_type = mime::APPLICATION_JSON;
13633        let mut request_value_reader = {
13634            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13635            common::remove_json_null_values(&mut value);
13636            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13637            serde_json::to_writer(&mut dst, &value).unwrap();
13638            dst
13639        };
13640        let request_size = request_value_reader
13641            .seek(std::io::SeekFrom::End(0))
13642            .unwrap();
13643        request_value_reader
13644            .seek(std::io::SeekFrom::Start(0))
13645            .unwrap();
13646
13647        loop {
13648            let token = match self
13649                .hub
13650                .auth
13651                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13652                .await
13653            {
13654                Ok(token) => token,
13655                Err(e) => match dlg.token(e) {
13656                    Ok(token) => token,
13657                    Err(e) => {
13658                        dlg.finished(false);
13659                        return Err(common::Error::MissingToken(e));
13660                    }
13661                },
13662            };
13663            request_value_reader
13664                .seek(std::io::SeekFrom::Start(0))
13665                .unwrap();
13666            let mut req_result = {
13667                let client = &self.hub.client;
13668                dlg.pre_request();
13669                let mut req_builder = hyper::Request::builder()
13670                    .method(hyper::Method::PATCH)
13671                    .uri(url.as_str())
13672                    .header(USER_AGENT, self.hub._user_agent.clone());
13673
13674                if let Some(token) = token.as_ref() {
13675                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13676                }
13677
13678                let request = req_builder
13679                    .header(CONTENT_TYPE, json_mime_type.to_string())
13680                    .header(CONTENT_LENGTH, request_size as u64)
13681                    .body(common::to_body(
13682                        request_value_reader.get_ref().clone().into(),
13683                    ));
13684
13685                client.request(request.unwrap()).await
13686            };
13687
13688            match req_result {
13689                Err(err) => {
13690                    if let common::Retry::After(d) = dlg.http_error(&err) {
13691                        sleep(d).await;
13692                        continue;
13693                    }
13694                    dlg.finished(false);
13695                    return Err(common::Error::HttpError(err));
13696                }
13697                Ok(res) => {
13698                    let (mut parts, body) = res.into_parts();
13699                    let mut body = common::Body::new(body);
13700                    if !parts.status.is_success() {
13701                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13702                        let error = serde_json::from_str(&common::to_string(&bytes));
13703                        let response = common::to_response(parts, bytes.into());
13704
13705                        if let common::Retry::After(d) =
13706                            dlg.http_failure(&response, error.as_ref().ok())
13707                        {
13708                            sleep(d).await;
13709                            continue;
13710                        }
13711
13712                        dlg.finished(false);
13713
13714                        return Err(match error {
13715                            Ok(value) => common::Error::BadRequest(value),
13716                            _ => common::Error::Failure(response),
13717                        });
13718                    }
13719                    let response = {
13720                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13721                        let encoded = common::to_string(&bytes);
13722                        match serde_json::from_str(&encoded) {
13723                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13724                            Err(error) => {
13725                                dlg.response_json_decode_error(&encoded, &error);
13726                                return Err(common::Error::JsonDecodeError(
13727                                    encoded.to_string(),
13728                                    error,
13729                                ));
13730                            }
13731                        }
13732                    };
13733
13734                    dlg.finished(true);
13735                    return Ok(response);
13736                }
13737            }
13738        }
13739    }
13740
13741    ///
13742    /// Sets the *request* property to the given value.
13743    ///
13744    /// Even though the property as already been set when instantiating this call,
13745    /// we provide this method for API completeness.
13746    pub fn request(
13747        mut self,
13748        new_value: UpdateInstanceMetadataItemsRequest,
13749    ) -> ProjectLocationInstanceUpdateMetadataItemCall<'a, C> {
13750        self._request = new_value;
13751        self
13752    }
13753    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
13754    ///
13755    /// Sets the *name* path property to the given value.
13756    ///
13757    /// Even though the property as already been set when instantiating this call,
13758    /// we provide this method for API completeness.
13759    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceUpdateMetadataItemCall<'a, C> {
13760        self._name = new_value.to_string();
13761        self
13762    }
13763    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13764    /// while executing the actual API request.
13765    ///
13766    /// ````text
13767    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13768    /// ````
13769    ///
13770    /// Sets the *delegate* property to the given value.
13771    pub fn delegate(
13772        mut self,
13773        new_value: &'a mut dyn common::Delegate,
13774    ) -> ProjectLocationInstanceUpdateMetadataItemCall<'a, C> {
13775        self._delegate = Some(new_value);
13776        self
13777    }
13778
13779    /// Set any additional parameter of the query string used in the request.
13780    /// It should be used to set parameters which are not yet available through their own
13781    /// setters.
13782    ///
13783    /// Please note that this method must not be used to set any of the known parameters
13784    /// which have their own setter method. If done anyway, the request will fail.
13785    ///
13786    /// # Additional Parameters
13787    ///
13788    /// * *$.xgafv* (query-string) - V1 error format.
13789    /// * *access_token* (query-string) - OAuth access token.
13790    /// * *alt* (query-string) - Data format for response.
13791    /// * *callback* (query-string) - JSONP
13792    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13793    /// * *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.
13794    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13795    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13796    /// * *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.
13797    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13798    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13799    pub fn param<T>(
13800        mut self,
13801        name: T,
13802        value: T,
13803    ) -> ProjectLocationInstanceUpdateMetadataItemCall<'a, C>
13804    where
13805        T: AsRef<str>,
13806    {
13807        self._additional_params
13808            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13809        self
13810    }
13811
13812    /// Identifies the authorization scope for the method you are building.
13813    ///
13814    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13815    /// [`Scope::CloudPlatform`].
13816    ///
13817    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13818    /// tokens for more than one scope.
13819    ///
13820    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13821    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13822    /// sufficient, a read-write scope will do as well.
13823    pub fn add_scope<St>(
13824        mut self,
13825        scope: St,
13826    ) -> ProjectLocationInstanceUpdateMetadataItemCall<'a, C>
13827    where
13828        St: AsRef<str>,
13829    {
13830        self._scopes.insert(String::from(scope.as_ref()));
13831        self
13832    }
13833    /// Identifies the authorization scope(s) for the method you are building.
13834    ///
13835    /// See [`Self::add_scope()`] for details.
13836    pub fn add_scopes<I, St>(
13837        mut self,
13838        scopes: I,
13839    ) -> ProjectLocationInstanceUpdateMetadataItemCall<'a, C>
13840    where
13841        I: IntoIterator<Item = St>,
13842        St: AsRef<str>,
13843    {
13844        self._scopes
13845            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13846        self
13847    }
13848
13849    /// Removes all scopes, and no default scope will be used either.
13850    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13851    /// for details).
13852    pub fn clear_scopes(mut self) -> ProjectLocationInstanceUpdateMetadataItemCall<'a, C> {
13853        self._scopes.clear();
13854        self
13855    }
13856}
13857
13858/// Updates the Shielded instance configuration of a single Instance.
13859///
13860/// A builder for the *locations.instances.updateShieldedInstanceConfig* method supported by a *project* resource.
13861/// It is not used directly, but through a [`ProjectMethods`] instance.
13862///
13863/// # Example
13864///
13865/// Instantiate a resource method builder
13866///
13867/// ```test_harness,no_run
13868/// # extern crate hyper;
13869/// # extern crate hyper_rustls;
13870/// # extern crate google_notebooks1 as notebooks1;
13871/// use notebooks1::api::UpdateShieldedInstanceConfigRequest;
13872/// # async fn dox() {
13873/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13874///
13875/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13876/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13877/// #     .with_native_roots()
13878/// #     .unwrap()
13879/// #     .https_only()
13880/// #     .enable_http2()
13881/// #     .build();
13882///
13883/// # let executor = hyper_util::rt::TokioExecutor::new();
13884/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13885/// #     secret,
13886/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13887/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13888/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13889/// #     ),
13890/// # ).build().await.unwrap();
13891///
13892/// # let client = hyper_util::client::legacy::Client::builder(
13893/// #     hyper_util::rt::TokioExecutor::new()
13894/// # )
13895/// # .build(
13896/// #     hyper_rustls::HttpsConnectorBuilder::new()
13897/// #         .with_native_roots()
13898/// #         .unwrap()
13899/// #         .https_or_http()
13900/// #         .enable_http2()
13901/// #         .build()
13902/// # );
13903/// # let mut hub = AIPlatformNotebooks::new(client, auth);
13904/// // As the method needs a request, you would usually fill it with the desired information
13905/// // into the respective structure. Some of the parts shown here might not be applicable !
13906/// // Values shown here are possibly random and not representative !
13907/// let mut req = UpdateShieldedInstanceConfigRequest::default();
13908///
13909/// // You can configure optional parameters by calling the respective setters at will, and
13910/// // execute the final call using `doit()`.
13911/// // Values shown here are possibly random and not representative !
13912/// let result = hub.projects().locations_instances_update_shielded_instance_config(req, "name")
13913///              .doit().await;
13914/// # }
13915/// ```
13916pub struct ProjectLocationInstanceUpdateShieldedInstanceConfigCall<'a, C>
13917where
13918    C: 'a,
13919{
13920    hub: &'a AIPlatformNotebooks<C>,
13921    _request: UpdateShieldedInstanceConfigRequest,
13922    _name: String,
13923    _delegate: Option<&'a mut dyn common::Delegate>,
13924    _additional_params: HashMap<String, String>,
13925    _scopes: BTreeSet<String>,
13926}
13927
13928impl<'a, C> common::CallBuilder for ProjectLocationInstanceUpdateShieldedInstanceConfigCall<'a, C> {}
13929
13930impl<'a, C> ProjectLocationInstanceUpdateShieldedInstanceConfigCall<'a, C>
13931where
13932    C: common::Connector,
13933{
13934    /// Perform the operation you have build so far.
13935    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
13936        use std::borrow::Cow;
13937        use std::io::{Read, Seek};
13938
13939        use common::{url::Params, ToParts};
13940        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13941
13942        let mut dd = common::DefaultDelegate;
13943        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13944        dlg.begin(common::MethodInfo {
13945            id: "notebooks.projects.locations.instances.updateShieldedInstanceConfig",
13946            http_method: hyper::Method::PATCH,
13947        });
13948
13949        for &field in ["alt", "name"].iter() {
13950            if self._additional_params.contains_key(field) {
13951                dlg.finished(false);
13952                return Err(common::Error::FieldClash(field));
13953            }
13954        }
13955
13956        let mut params = Params::with_capacity(4 + self._additional_params.len());
13957        params.push("name", self._name);
13958
13959        params.extend(self._additional_params.iter());
13960
13961        params.push("alt", "json");
13962        let mut url = self.hub._base_url.clone() + "v1/{+name}:updateShieldedInstanceConfig";
13963        if self._scopes.is_empty() {
13964            self._scopes
13965                .insert(Scope::CloudPlatform.as_ref().to_string());
13966        }
13967
13968        #[allow(clippy::single_element_loop)]
13969        for &(find_this, param_name) in [("{+name}", "name")].iter() {
13970            url = params.uri_replacement(url, param_name, find_this, true);
13971        }
13972        {
13973            let to_remove = ["name"];
13974            params.remove_params(&to_remove);
13975        }
13976
13977        let url = params.parse_with_url(&url);
13978
13979        let mut json_mime_type = mime::APPLICATION_JSON;
13980        let mut request_value_reader = {
13981            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13982            common::remove_json_null_values(&mut value);
13983            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13984            serde_json::to_writer(&mut dst, &value).unwrap();
13985            dst
13986        };
13987        let request_size = request_value_reader
13988            .seek(std::io::SeekFrom::End(0))
13989            .unwrap();
13990        request_value_reader
13991            .seek(std::io::SeekFrom::Start(0))
13992            .unwrap();
13993
13994        loop {
13995            let token = match self
13996                .hub
13997                .auth
13998                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13999                .await
14000            {
14001                Ok(token) => token,
14002                Err(e) => match dlg.token(e) {
14003                    Ok(token) => token,
14004                    Err(e) => {
14005                        dlg.finished(false);
14006                        return Err(common::Error::MissingToken(e));
14007                    }
14008                },
14009            };
14010            request_value_reader
14011                .seek(std::io::SeekFrom::Start(0))
14012                .unwrap();
14013            let mut req_result = {
14014                let client = &self.hub.client;
14015                dlg.pre_request();
14016                let mut req_builder = hyper::Request::builder()
14017                    .method(hyper::Method::PATCH)
14018                    .uri(url.as_str())
14019                    .header(USER_AGENT, self.hub._user_agent.clone());
14020
14021                if let Some(token) = token.as_ref() {
14022                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14023                }
14024
14025                let request = req_builder
14026                    .header(CONTENT_TYPE, json_mime_type.to_string())
14027                    .header(CONTENT_LENGTH, request_size as u64)
14028                    .body(common::to_body(
14029                        request_value_reader.get_ref().clone().into(),
14030                    ));
14031
14032                client.request(request.unwrap()).await
14033            };
14034
14035            match req_result {
14036                Err(err) => {
14037                    if let common::Retry::After(d) = dlg.http_error(&err) {
14038                        sleep(d).await;
14039                        continue;
14040                    }
14041                    dlg.finished(false);
14042                    return Err(common::Error::HttpError(err));
14043                }
14044                Ok(res) => {
14045                    let (mut parts, body) = res.into_parts();
14046                    let mut body = common::Body::new(body);
14047                    if !parts.status.is_success() {
14048                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14049                        let error = serde_json::from_str(&common::to_string(&bytes));
14050                        let response = common::to_response(parts, bytes.into());
14051
14052                        if let common::Retry::After(d) =
14053                            dlg.http_failure(&response, error.as_ref().ok())
14054                        {
14055                            sleep(d).await;
14056                            continue;
14057                        }
14058
14059                        dlg.finished(false);
14060
14061                        return Err(match error {
14062                            Ok(value) => common::Error::BadRequest(value),
14063                            _ => common::Error::Failure(response),
14064                        });
14065                    }
14066                    let response = {
14067                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14068                        let encoded = common::to_string(&bytes);
14069                        match serde_json::from_str(&encoded) {
14070                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14071                            Err(error) => {
14072                                dlg.response_json_decode_error(&encoded, &error);
14073                                return Err(common::Error::JsonDecodeError(
14074                                    encoded.to_string(),
14075                                    error,
14076                                ));
14077                            }
14078                        }
14079                    };
14080
14081                    dlg.finished(true);
14082                    return Ok(response);
14083                }
14084            }
14085        }
14086    }
14087
14088    ///
14089    /// Sets the *request* property to the given value.
14090    ///
14091    /// Even though the property as already been set when instantiating this call,
14092    /// we provide this method for API completeness.
14093    pub fn request(
14094        mut self,
14095        new_value: UpdateShieldedInstanceConfigRequest,
14096    ) -> ProjectLocationInstanceUpdateShieldedInstanceConfigCall<'a, C> {
14097        self._request = new_value;
14098        self
14099    }
14100    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
14101    ///
14102    /// Sets the *name* path property to the given value.
14103    ///
14104    /// Even though the property as already been set when instantiating this call,
14105    /// we provide this method for API completeness.
14106    pub fn name(
14107        mut self,
14108        new_value: &str,
14109    ) -> ProjectLocationInstanceUpdateShieldedInstanceConfigCall<'a, C> {
14110        self._name = new_value.to_string();
14111        self
14112    }
14113    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14114    /// while executing the actual API request.
14115    ///
14116    /// ````text
14117    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14118    /// ````
14119    ///
14120    /// Sets the *delegate* property to the given value.
14121    pub fn delegate(
14122        mut self,
14123        new_value: &'a mut dyn common::Delegate,
14124    ) -> ProjectLocationInstanceUpdateShieldedInstanceConfigCall<'a, C> {
14125        self._delegate = Some(new_value);
14126        self
14127    }
14128
14129    /// Set any additional parameter of the query string used in the request.
14130    /// It should be used to set parameters which are not yet available through their own
14131    /// setters.
14132    ///
14133    /// Please note that this method must not be used to set any of the known parameters
14134    /// which have their own setter method. If done anyway, the request will fail.
14135    ///
14136    /// # Additional Parameters
14137    ///
14138    /// * *$.xgafv* (query-string) - V1 error format.
14139    /// * *access_token* (query-string) - OAuth access token.
14140    /// * *alt* (query-string) - Data format for response.
14141    /// * *callback* (query-string) - JSONP
14142    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14143    /// * *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.
14144    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14145    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14146    /// * *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.
14147    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14148    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14149    pub fn param<T>(
14150        mut self,
14151        name: T,
14152        value: T,
14153    ) -> ProjectLocationInstanceUpdateShieldedInstanceConfigCall<'a, C>
14154    where
14155        T: AsRef<str>,
14156    {
14157        self._additional_params
14158            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14159        self
14160    }
14161
14162    /// Identifies the authorization scope for the method you are building.
14163    ///
14164    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14165    /// [`Scope::CloudPlatform`].
14166    ///
14167    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14168    /// tokens for more than one scope.
14169    ///
14170    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14171    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14172    /// sufficient, a read-write scope will do as well.
14173    pub fn add_scope<St>(
14174        mut self,
14175        scope: St,
14176    ) -> ProjectLocationInstanceUpdateShieldedInstanceConfigCall<'a, C>
14177    where
14178        St: AsRef<str>,
14179    {
14180        self._scopes.insert(String::from(scope.as_ref()));
14181        self
14182    }
14183    /// Identifies the authorization scope(s) for the method you are building.
14184    ///
14185    /// See [`Self::add_scope()`] for details.
14186    pub fn add_scopes<I, St>(
14187        mut self,
14188        scopes: I,
14189    ) -> ProjectLocationInstanceUpdateShieldedInstanceConfigCall<'a, C>
14190    where
14191        I: IntoIterator<Item = St>,
14192        St: AsRef<str>,
14193    {
14194        self._scopes
14195            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14196        self
14197    }
14198
14199    /// Removes all scopes, and no default scope will be used either.
14200    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14201    /// for details).
14202    pub fn clear_scopes(
14203        mut self,
14204    ) -> ProjectLocationInstanceUpdateShieldedInstanceConfigCall<'a, C> {
14205        self._scopes.clear();
14206        self
14207    }
14208}
14209
14210/// Upgrades a notebook instance to the latest version.
14211///
14212/// A builder for the *locations.instances.upgrade* method supported by a *project* resource.
14213/// It is not used directly, but through a [`ProjectMethods`] instance.
14214///
14215/// # Example
14216///
14217/// Instantiate a resource method builder
14218///
14219/// ```test_harness,no_run
14220/// # extern crate hyper;
14221/// # extern crate hyper_rustls;
14222/// # extern crate google_notebooks1 as notebooks1;
14223/// use notebooks1::api::UpgradeInstanceRequest;
14224/// # async fn dox() {
14225/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14226///
14227/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14228/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14229/// #     .with_native_roots()
14230/// #     .unwrap()
14231/// #     .https_only()
14232/// #     .enable_http2()
14233/// #     .build();
14234///
14235/// # let executor = hyper_util::rt::TokioExecutor::new();
14236/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14237/// #     secret,
14238/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14239/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14240/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14241/// #     ),
14242/// # ).build().await.unwrap();
14243///
14244/// # let client = hyper_util::client::legacy::Client::builder(
14245/// #     hyper_util::rt::TokioExecutor::new()
14246/// # )
14247/// # .build(
14248/// #     hyper_rustls::HttpsConnectorBuilder::new()
14249/// #         .with_native_roots()
14250/// #         .unwrap()
14251/// #         .https_or_http()
14252/// #         .enable_http2()
14253/// #         .build()
14254/// # );
14255/// # let mut hub = AIPlatformNotebooks::new(client, auth);
14256/// // As the method needs a request, you would usually fill it with the desired information
14257/// // into the respective structure. Some of the parts shown here might not be applicable !
14258/// // Values shown here are possibly random and not representative !
14259/// let mut req = UpgradeInstanceRequest::default();
14260///
14261/// // You can configure optional parameters by calling the respective setters at will, and
14262/// // execute the final call using `doit()`.
14263/// // Values shown here are possibly random and not representative !
14264/// let result = hub.projects().locations_instances_upgrade(req, "name")
14265///              .doit().await;
14266/// # }
14267/// ```
14268pub struct ProjectLocationInstanceUpgradeCall<'a, C>
14269where
14270    C: 'a,
14271{
14272    hub: &'a AIPlatformNotebooks<C>,
14273    _request: UpgradeInstanceRequest,
14274    _name: String,
14275    _delegate: Option<&'a mut dyn common::Delegate>,
14276    _additional_params: HashMap<String, String>,
14277    _scopes: BTreeSet<String>,
14278}
14279
14280impl<'a, C> common::CallBuilder for ProjectLocationInstanceUpgradeCall<'a, C> {}
14281
14282impl<'a, C> ProjectLocationInstanceUpgradeCall<'a, C>
14283where
14284    C: common::Connector,
14285{
14286    /// Perform the operation you have build so far.
14287    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
14288        use std::borrow::Cow;
14289        use std::io::{Read, Seek};
14290
14291        use common::{url::Params, ToParts};
14292        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14293
14294        let mut dd = common::DefaultDelegate;
14295        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14296        dlg.begin(common::MethodInfo {
14297            id: "notebooks.projects.locations.instances.upgrade",
14298            http_method: hyper::Method::POST,
14299        });
14300
14301        for &field in ["alt", "name"].iter() {
14302            if self._additional_params.contains_key(field) {
14303                dlg.finished(false);
14304                return Err(common::Error::FieldClash(field));
14305            }
14306        }
14307
14308        let mut params = Params::with_capacity(4 + self._additional_params.len());
14309        params.push("name", self._name);
14310
14311        params.extend(self._additional_params.iter());
14312
14313        params.push("alt", "json");
14314        let mut url = self.hub._base_url.clone() + "v1/{+name}:upgrade";
14315        if self._scopes.is_empty() {
14316            self._scopes
14317                .insert(Scope::CloudPlatform.as_ref().to_string());
14318        }
14319
14320        #[allow(clippy::single_element_loop)]
14321        for &(find_this, param_name) in [("{+name}", "name")].iter() {
14322            url = params.uri_replacement(url, param_name, find_this, true);
14323        }
14324        {
14325            let to_remove = ["name"];
14326            params.remove_params(&to_remove);
14327        }
14328
14329        let url = params.parse_with_url(&url);
14330
14331        let mut json_mime_type = mime::APPLICATION_JSON;
14332        let mut request_value_reader = {
14333            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14334            common::remove_json_null_values(&mut value);
14335            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14336            serde_json::to_writer(&mut dst, &value).unwrap();
14337            dst
14338        };
14339        let request_size = request_value_reader
14340            .seek(std::io::SeekFrom::End(0))
14341            .unwrap();
14342        request_value_reader
14343            .seek(std::io::SeekFrom::Start(0))
14344            .unwrap();
14345
14346        loop {
14347            let token = match self
14348                .hub
14349                .auth
14350                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14351                .await
14352            {
14353                Ok(token) => token,
14354                Err(e) => match dlg.token(e) {
14355                    Ok(token) => token,
14356                    Err(e) => {
14357                        dlg.finished(false);
14358                        return Err(common::Error::MissingToken(e));
14359                    }
14360                },
14361            };
14362            request_value_reader
14363                .seek(std::io::SeekFrom::Start(0))
14364                .unwrap();
14365            let mut req_result = {
14366                let client = &self.hub.client;
14367                dlg.pre_request();
14368                let mut req_builder = hyper::Request::builder()
14369                    .method(hyper::Method::POST)
14370                    .uri(url.as_str())
14371                    .header(USER_AGENT, self.hub._user_agent.clone());
14372
14373                if let Some(token) = token.as_ref() {
14374                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14375                }
14376
14377                let request = req_builder
14378                    .header(CONTENT_TYPE, json_mime_type.to_string())
14379                    .header(CONTENT_LENGTH, request_size as u64)
14380                    .body(common::to_body(
14381                        request_value_reader.get_ref().clone().into(),
14382                    ));
14383
14384                client.request(request.unwrap()).await
14385            };
14386
14387            match req_result {
14388                Err(err) => {
14389                    if let common::Retry::After(d) = dlg.http_error(&err) {
14390                        sleep(d).await;
14391                        continue;
14392                    }
14393                    dlg.finished(false);
14394                    return Err(common::Error::HttpError(err));
14395                }
14396                Ok(res) => {
14397                    let (mut parts, body) = res.into_parts();
14398                    let mut body = common::Body::new(body);
14399                    if !parts.status.is_success() {
14400                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14401                        let error = serde_json::from_str(&common::to_string(&bytes));
14402                        let response = common::to_response(parts, bytes.into());
14403
14404                        if let common::Retry::After(d) =
14405                            dlg.http_failure(&response, error.as_ref().ok())
14406                        {
14407                            sleep(d).await;
14408                            continue;
14409                        }
14410
14411                        dlg.finished(false);
14412
14413                        return Err(match error {
14414                            Ok(value) => common::Error::BadRequest(value),
14415                            _ => common::Error::Failure(response),
14416                        });
14417                    }
14418                    let response = {
14419                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14420                        let encoded = common::to_string(&bytes);
14421                        match serde_json::from_str(&encoded) {
14422                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14423                            Err(error) => {
14424                                dlg.response_json_decode_error(&encoded, &error);
14425                                return Err(common::Error::JsonDecodeError(
14426                                    encoded.to_string(),
14427                                    error,
14428                                ));
14429                            }
14430                        }
14431                    };
14432
14433                    dlg.finished(true);
14434                    return Ok(response);
14435                }
14436            }
14437        }
14438    }
14439
14440    ///
14441    /// Sets the *request* property to the given value.
14442    ///
14443    /// Even though the property as already been set when instantiating this call,
14444    /// we provide this method for API completeness.
14445    pub fn request(
14446        mut self,
14447        new_value: UpgradeInstanceRequest,
14448    ) -> ProjectLocationInstanceUpgradeCall<'a, C> {
14449        self._request = new_value;
14450        self
14451    }
14452    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
14453    ///
14454    /// Sets the *name* path property to the given value.
14455    ///
14456    /// Even though the property as already been set when instantiating this call,
14457    /// we provide this method for API completeness.
14458    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceUpgradeCall<'a, C> {
14459        self._name = new_value.to_string();
14460        self
14461    }
14462    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14463    /// while executing the actual API request.
14464    ///
14465    /// ````text
14466    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14467    /// ````
14468    ///
14469    /// Sets the *delegate* property to the given value.
14470    pub fn delegate(
14471        mut self,
14472        new_value: &'a mut dyn common::Delegate,
14473    ) -> ProjectLocationInstanceUpgradeCall<'a, C> {
14474        self._delegate = Some(new_value);
14475        self
14476    }
14477
14478    /// Set any additional parameter of the query string used in the request.
14479    /// It should be used to set parameters which are not yet available through their own
14480    /// setters.
14481    ///
14482    /// Please note that this method must not be used to set any of the known parameters
14483    /// which have their own setter method. If done anyway, the request will fail.
14484    ///
14485    /// # Additional Parameters
14486    ///
14487    /// * *$.xgafv* (query-string) - V1 error format.
14488    /// * *access_token* (query-string) - OAuth access token.
14489    /// * *alt* (query-string) - Data format for response.
14490    /// * *callback* (query-string) - JSONP
14491    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14492    /// * *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.
14493    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14494    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14495    /// * *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.
14496    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14497    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14498    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceUpgradeCall<'a, C>
14499    where
14500        T: AsRef<str>,
14501    {
14502        self._additional_params
14503            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14504        self
14505    }
14506
14507    /// Identifies the authorization scope for the method you are building.
14508    ///
14509    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14510    /// [`Scope::CloudPlatform`].
14511    ///
14512    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14513    /// tokens for more than one scope.
14514    ///
14515    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14516    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14517    /// sufficient, a read-write scope will do as well.
14518    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceUpgradeCall<'a, C>
14519    where
14520        St: AsRef<str>,
14521    {
14522        self._scopes.insert(String::from(scope.as_ref()));
14523        self
14524    }
14525    /// Identifies the authorization scope(s) for the method you are building.
14526    ///
14527    /// See [`Self::add_scope()`] for details.
14528    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceUpgradeCall<'a, C>
14529    where
14530        I: IntoIterator<Item = St>,
14531        St: AsRef<str>,
14532    {
14533        self._scopes
14534            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14535        self
14536    }
14537
14538    /// Removes all scopes, and no default scope will be used either.
14539    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14540    /// for details).
14541    pub fn clear_scopes(mut self) -> ProjectLocationInstanceUpgradeCall<'a, C> {
14542        self._scopes.clear();
14543        self
14544    }
14545}
14546
14547/// Allows notebook instances to call this endpoint to upgrade themselves. Do not use this method directly.
14548///
14549/// A builder for the *locations.instances.upgradeInternal* method supported by a *project* resource.
14550/// It is not used directly, but through a [`ProjectMethods`] instance.
14551///
14552/// # Example
14553///
14554/// Instantiate a resource method builder
14555///
14556/// ```test_harness,no_run
14557/// # extern crate hyper;
14558/// # extern crate hyper_rustls;
14559/// # extern crate google_notebooks1 as notebooks1;
14560/// use notebooks1::api::UpgradeInstanceInternalRequest;
14561/// # async fn dox() {
14562/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14563///
14564/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14565/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14566/// #     .with_native_roots()
14567/// #     .unwrap()
14568/// #     .https_only()
14569/// #     .enable_http2()
14570/// #     .build();
14571///
14572/// # let executor = hyper_util::rt::TokioExecutor::new();
14573/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14574/// #     secret,
14575/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14576/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14577/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14578/// #     ),
14579/// # ).build().await.unwrap();
14580///
14581/// # let client = hyper_util::client::legacy::Client::builder(
14582/// #     hyper_util::rt::TokioExecutor::new()
14583/// # )
14584/// # .build(
14585/// #     hyper_rustls::HttpsConnectorBuilder::new()
14586/// #         .with_native_roots()
14587/// #         .unwrap()
14588/// #         .https_or_http()
14589/// #         .enable_http2()
14590/// #         .build()
14591/// # );
14592/// # let mut hub = AIPlatformNotebooks::new(client, auth);
14593/// // As the method needs a request, you would usually fill it with the desired information
14594/// // into the respective structure. Some of the parts shown here might not be applicable !
14595/// // Values shown here are possibly random and not representative !
14596/// let mut req = UpgradeInstanceInternalRequest::default();
14597///
14598/// // You can configure optional parameters by calling the respective setters at will, and
14599/// // execute the final call using `doit()`.
14600/// // Values shown here are possibly random and not representative !
14601/// let result = hub.projects().locations_instances_upgrade_internal(req, "name")
14602///              .doit().await;
14603/// # }
14604/// ```
14605pub struct ProjectLocationInstanceUpgradeInternalCall<'a, C>
14606where
14607    C: 'a,
14608{
14609    hub: &'a AIPlatformNotebooks<C>,
14610    _request: UpgradeInstanceInternalRequest,
14611    _name: String,
14612    _delegate: Option<&'a mut dyn common::Delegate>,
14613    _additional_params: HashMap<String, String>,
14614    _scopes: BTreeSet<String>,
14615}
14616
14617impl<'a, C> common::CallBuilder for ProjectLocationInstanceUpgradeInternalCall<'a, C> {}
14618
14619impl<'a, C> ProjectLocationInstanceUpgradeInternalCall<'a, C>
14620where
14621    C: common::Connector,
14622{
14623    /// Perform the operation you have build so far.
14624    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
14625        use std::borrow::Cow;
14626        use std::io::{Read, Seek};
14627
14628        use common::{url::Params, ToParts};
14629        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14630
14631        let mut dd = common::DefaultDelegate;
14632        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14633        dlg.begin(common::MethodInfo {
14634            id: "notebooks.projects.locations.instances.upgradeInternal",
14635            http_method: hyper::Method::POST,
14636        });
14637
14638        for &field in ["alt", "name"].iter() {
14639            if self._additional_params.contains_key(field) {
14640                dlg.finished(false);
14641                return Err(common::Error::FieldClash(field));
14642            }
14643        }
14644
14645        let mut params = Params::with_capacity(4 + self._additional_params.len());
14646        params.push("name", self._name);
14647
14648        params.extend(self._additional_params.iter());
14649
14650        params.push("alt", "json");
14651        let mut url = self.hub._base_url.clone() + "v1/{+name}:upgradeInternal";
14652        if self._scopes.is_empty() {
14653            self._scopes
14654                .insert(Scope::CloudPlatform.as_ref().to_string());
14655        }
14656
14657        #[allow(clippy::single_element_loop)]
14658        for &(find_this, param_name) in [("{+name}", "name")].iter() {
14659            url = params.uri_replacement(url, param_name, find_this, true);
14660        }
14661        {
14662            let to_remove = ["name"];
14663            params.remove_params(&to_remove);
14664        }
14665
14666        let url = params.parse_with_url(&url);
14667
14668        let mut json_mime_type = mime::APPLICATION_JSON;
14669        let mut request_value_reader = {
14670            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14671            common::remove_json_null_values(&mut value);
14672            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14673            serde_json::to_writer(&mut dst, &value).unwrap();
14674            dst
14675        };
14676        let request_size = request_value_reader
14677            .seek(std::io::SeekFrom::End(0))
14678            .unwrap();
14679        request_value_reader
14680            .seek(std::io::SeekFrom::Start(0))
14681            .unwrap();
14682
14683        loop {
14684            let token = match self
14685                .hub
14686                .auth
14687                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14688                .await
14689            {
14690                Ok(token) => token,
14691                Err(e) => match dlg.token(e) {
14692                    Ok(token) => token,
14693                    Err(e) => {
14694                        dlg.finished(false);
14695                        return Err(common::Error::MissingToken(e));
14696                    }
14697                },
14698            };
14699            request_value_reader
14700                .seek(std::io::SeekFrom::Start(0))
14701                .unwrap();
14702            let mut req_result = {
14703                let client = &self.hub.client;
14704                dlg.pre_request();
14705                let mut req_builder = hyper::Request::builder()
14706                    .method(hyper::Method::POST)
14707                    .uri(url.as_str())
14708                    .header(USER_AGENT, self.hub._user_agent.clone());
14709
14710                if let Some(token) = token.as_ref() {
14711                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14712                }
14713
14714                let request = req_builder
14715                    .header(CONTENT_TYPE, json_mime_type.to_string())
14716                    .header(CONTENT_LENGTH, request_size as u64)
14717                    .body(common::to_body(
14718                        request_value_reader.get_ref().clone().into(),
14719                    ));
14720
14721                client.request(request.unwrap()).await
14722            };
14723
14724            match req_result {
14725                Err(err) => {
14726                    if let common::Retry::After(d) = dlg.http_error(&err) {
14727                        sleep(d).await;
14728                        continue;
14729                    }
14730                    dlg.finished(false);
14731                    return Err(common::Error::HttpError(err));
14732                }
14733                Ok(res) => {
14734                    let (mut parts, body) = res.into_parts();
14735                    let mut body = common::Body::new(body);
14736                    if !parts.status.is_success() {
14737                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14738                        let error = serde_json::from_str(&common::to_string(&bytes));
14739                        let response = common::to_response(parts, bytes.into());
14740
14741                        if let common::Retry::After(d) =
14742                            dlg.http_failure(&response, error.as_ref().ok())
14743                        {
14744                            sleep(d).await;
14745                            continue;
14746                        }
14747
14748                        dlg.finished(false);
14749
14750                        return Err(match error {
14751                            Ok(value) => common::Error::BadRequest(value),
14752                            _ => common::Error::Failure(response),
14753                        });
14754                    }
14755                    let response = {
14756                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14757                        let encoded = common::to_string(&bytes);
14758                        match serde_json::from_str(&encoded) {
14759                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14760                            Err(error) => {
14761                                dlg.response_json_decode_error(&encoded, &error);
14762                                return Err(common::Error::JsonDecodeError(
14763                                    encoded.to_string(),
14764                                    error,
14765                                ));
14766                            }
14767                        }
14768                    };
14769
14770                    dlg.finished(true);
14771                    return Ok(response);
14772                }
14773            }
14774        }
14775    }
14776
14777    ///
14778    /// Sets the *request* property to the given value.
14779    ///
14780    /// Even though the property as already been set when instantiating this call,
14781    /// we provide this method for API completeness.
14782    pub fn request(
14783        mut self,
14784        new_value: UpgradeInstanceInternalRequest,
14785    ) -> ProjectLocationInstanceUpgradeInternalCall<'a, C> {
14786        self._request = new_value;
14787        self
14788    }
14789    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
14790    ///
14791    /// Sets the *name* path property to the given value.
14792    ///
14793    /// Even though the property as already been set when instantiating this call,
14794    /// we provide this method for API completeness.
14795    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceUpgradeInternalCall<'a, C> {
14796        self._name = new_value.to_string();
14797        self
14798    }
14799    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14800    /// while executing the actual API request.
14801    ///
14802    /// ````text
14803    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14804    /// ````
14805    ///
14806    /// Sets the *delegate* property to the given value.
14807    pub fn delegate(
14808        mut self,
14809        new_value: &'a mut dyn common::Delegate,
14810    ) -> ProjectLocationInstanceUpgradeInternalCall<'a, C> {
14811        self._delegate = Some(new_value);
14812        self
14813    }
14814
14815    /// Set any additional parameter of the query string used in the request.
14816    /// It should be used to set parameters which are not yet available through their own
14817    /// setters.
14818    ///
14819    /// Please note that this method must not be used to set any of the known parameters
14820    /// which have their own setter method. If done anyway, the request will fail.
14821    ///
14822    /// # Additional Parameters
14823    ///
14824    /// * *$.xgafv* (query-string) - V1 error format.
14825    /// * *access_token* (query-string) - OAuth access token.
14826    /// * *alt* (query-string) - Data format for response.
14827    /// * *callback* (query-string) - JSONP
14828    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14829    /// * *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.
14830    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14831    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14832    /// * *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.
14833    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14834    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14835    pub fn param<T>(
14836        mut self,
14837        name: T,
14838        value: T,
14839    ) -> ProjectLocationInstanceUpgradeInternalCall<'a, C>
14840    where
14841        T: AsRef<str>,
14842    {
14843        self._additional_params
14844            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14845        self
14846    }
14847
14848    /// Identifies the authorization scope for the method you are building.
14849    ///
14850    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14851    /// [`Scope::CloudPlatform`].
14852    ///
14853    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14854    /// tokens for more than one scope.
14855    ///
14856    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14857    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14858    /// sufficient, a read-write scope will do as well.
14859    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceUpgradeInternalCall<'a, C>
14860    where
14861        St: AsRef<str>,
14862    {
14863        self._scopes.insert(String::from(scope.as_ref()));
14864        self
14865    }
14866    /// Identifies the authorization scope(s) for the method you are building.
14867    ///
14868    /// See [`Self::add_scope()`] for details.
14869    pub fn add_scopes<I, St>(
14870        mut self,
14871        scopes: I,
14872    ) -> ProjectLocationInstanceUpgradeInternalCall<'a, C>
14873    where
14874        I: IntoIterator<Item = St>,
14875        St: AsRef<str>,
14876    {
14877        self._scopes
14878            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14879        self
14880    }
14881
14882    /// Removes all scopes, and no default scope will be used either.
14883    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14884    /// for details).
14885    pub fn clear_scopes(mut self) -> ProjectLocationInstanceUpgradeInternalCall<'a, C> {
14886        self._scopes.clear();
14887        self
14888    }
14889}
14890
14891/// 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`.
14892///
14893/// A builder for the *locations.operations.cancel* method supported by a *project* resource.
14894/// It is not used directly, but through a [`ProjectMethods`] instance.
14895///
14896/// # Example
14897///
14898/// Instantiate a resource method builder
14899///
14900/// ```test_harness,no_run
14901/// # extern crate hyper;
14902/// # extern crate hyper_rustls;
14903/// # extern crate google_notebooks1 as notebooks1;
14904/// use notebooks1::api::CancelOperationRequest;
14905/// # async fn dox() {
14906/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14907///
14908/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14909/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14910/// #     .with_native_roots()
14911/// #     .unwrap()
14912/// #     .https_only()
14913/// #     .enable_http2()
14914/// #     .build();
14915///
14916/// # let executor = hyper_util::rt::TokioExecutor::new();
14917/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14918/// #     secret,
14919/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14920/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14921/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14922/// #     ),
14923/// # ).build().await.unwrap();
14924///
14925/// # let client = hyper_util::client::legacy::Client::builder(
14926/// #     hyper_util::rt::TokioExecutor::new()
14927/// # )
14928/// # .build(
14929/// #     hyper_rustls::HttpsConnectorBuilder::new()
14930/// #         .with_native_roots()
14931/// #         .unwrap()
14932/// #         .https_or_http()
14933/// #         .enable_http2()
14934/// #         .build()
14935/// # );
14936/// # let mut hub = AIPlatformNotebooks::new(client, auth);
14937/// // As the method needs a request, you would usually fill it with the desired information
14938/// // into the respective structure. Some of the parts shown here might not be applicable !
14939/// // Values shown here are possibly random and not representative !
14940/// let mut req = CancelOperationRequest::default();
14941///
14942/// // You can configure optional parameters by calling the respective setters at will, and
14943/// // execute the final call using `doit()`.
14944/// // Values shown here are possibly random and not representative !
14945/// let result = hub.projects().locations_operations_cancel(req, "name")
14946///              .doit().await;
14947/// # }
14948/// ```
14949pub struct ProjectLocationOperationCancelCall<'a, C>
14950where
14951    C: 'a,
14952{
14953    hub: &'a AIPlatformNotebooks<C>,
14954    _request: CancelOperationRequest,
14955    _name: String,
14956    _delegate: Option<&'a mut dyn common::Delegate>,
14957    _additional_params: HashMap<String, String>,
14958    _scopes: BTreeSet<String>,
14959}
14960
14961impl<'a, C> common::CallBuilder for ProjectLocationOperationCancelCall<'a, C> {}
14962
14963impl<'a, C> ProjectLocationOperationCancelCall<'a, C>
14964where
14965    C: common::Connector,
14966{
14967    /// Perform the operation you have build so far.
14968    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
14969        use std::borrow::Cow;
14970        use std::io::{Read, Seek};
14971
14972        use common::{url::Params, ToParts};
14973        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14974
14975        let mut dd = common::DefaultDelegate;
14976        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14977        dlg.begin(common::MethodInfo {
14978            id: "notebooks.projects.locations.operations.cancel",
14979            http_method: hyper::Method::POST,
14980        });
14981
14982        for &field in ["alt", "name"].iter() {
14983            if self._additional_params.contains_key(field) {
14984                dlg.finished(false);
14985                return Err(common::Error::FieldClash(field));
14986            }
14987        }
14988
14989        let mut params = Params::with_capacity(4 + self._additional_params.len());
14990        params.push("name", self._name);
14991
14992        params.extend(self._additional_params.iter());
14993
14994        params.push("alt", "json");
14995        let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
14996        if self._scopes.is_empty() {
14997            self._scopes
14998                .insert(Scope::CloudPlatform.as_ref().to_string());
14999        }
15000
15001        #[allow(clippy::single_element_loop)]
15002        for &(find_this, param_name) in [("{+name}", "name")].iter() {
15003            url = params.uri_replacement(url, param_name, find_this, true);
15004        }
15005        {
15006            let to_remove = ["name"];
15007            params.remove_params(&to_remove);
15008        }
15009
15010        let url = params.parse_with_url(&url);
15011
15012        let mut json_mime_type = mime::APPLICATION_JSON;
15013        let mut request_value_reader = {
15014            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15015            common::remove_json_null_values(&mut value);
15016            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15017            serde_json::to_writer(&mut dst, &value).unwrap();
15018            dst
15019        };
15020        let request_size = request_value_reader
15021            .seek(std::io::SeekFrom::End(0))
15022            .unwrap();
15023        request_value_reader
15024            .seek(std::io::SeekFrom::Start(0))
15025            .unwrap();
15026
15027        loop {
15028            let token = match self
15029                .hub
15030                .auth
15031                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15032                .await
15033            {
15034                Ok(token) => token,
15035                Err(e) => match dlg.token(e) {
15036                    Ok(token) => token,
15037                    Err(e) => {
15038                        dlg.finished(false);
15039                        return Err(common::Error::MissingToken(e));
15040                    }
15041                },
15042            };
15043            request_value_reader
15044                .seek(std::io::SeekFrom::Start(0))
15045                .unwrap();
15046            let mut req_result = {
15047                let client = &self.hub.client;
15048                dlg.pre_request();
15049                let mut req_builder = hyper::Request::builder()
15050                    .method(hyper::Method::POST)
15051                    .uri(url.as_str())
15052                    .header(USER_AGENT, self.hub._user_agent.clone());
15053
15054                if let Some(token) = token.as_ref() {
15055                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15056                }
15057
15058                let request = req_builder
15059                    .header(CONTENT_TYPE, json_mime_type.to_string())
15060                    .header(CONTENT_LENGTH, request_size as u64)
15061                    .body(common::to_body(
15062                        request_value_reader.get_ref().clone().into(),
15063                    ));
15064
15065                client.request(request.unwrap()).await
15066            };
15067
15068            match req_result {
15069                Err(err) => {
15070                    if let common::Retry::After(d) = dlg.http_error(&err) {
15071                        sleep(d).await;
15072                        continue;
15073                    }
15074                    dlg.finished(false);
15075                    return Err(common::Error::HttpError(err));
15076                }
15077                Ok(res) => {
15078                    let (mut parts, body) = res.into_parts();
15079                    let mut body = common::Body::new(body);
15080                    if !parts.status.is_success() {
15081                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15082                        let error = serde_json::from_str(&common::to_string(&bytes));
15083                        let response = common::to_response(parts, bytes.into());
15084
15085                        if let common::Retry::After(d) =
15086                            dlg.http_failure(&response, error.as_ref().ok())
15087                        {
15088                            sleep(d).await;
15089                            continue;
15090                        }
15091
15092                        dlg.finished(false);
15093
15094                        return Err(match error {
15095                            Ok(value) => common::Error::BadRequest(value),
15096                            _ => common::Error::Failure(response),
15097                        });
15098                    }
15099                    let response = {
15100                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15101                        let encoded = common::to_string(&bytes);
15102                        match serde_json::from_str(&encoded) {
15103                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15104                            Err(error) => {
15105                                dlg.response_json_decode_error(&encoded, &error);
15106                                return Err(common::Error::JsonDecodeError(
15107                                    encoded.to_string(),
15108                                    error,
15109                                ));
15110                            }
15111                        }
15112                    };
15113
15114                    dlg.finished(true);
15115                    return Ok(response);
15116                }
15117            }
15118        }
15119    }
15120
15121    ///
15122    /// Sets the *request* property to the given value.
15123    ///
15124    /// Even though the property as already been set when instantiating this call,
15125    /// we provide this method for API completeness.
15126    pub fn request(
15127        mut self,
15128        new_value: CancelOperationRequest,
15129    ) -> ProjectLocationOperationCancelCall<'a, C> {
15130        self._request = new_value;
15131        self
15132    }
15133    /// The name of the operation resource to be cancelled.
15134    ///
15135    /// Sets the *name* path property to the given value.
15136    ///
15137    /// Even though the property as already been set when instantiating this call,
15138    /// we provide this method for API completeness.
15139    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationCancelCall<'a, C> {
15140        self._name = new_value.to_string();
15141        self
15142    }
15143    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15144    /// while executing the actual API request.
15145    ///
15146    /// ````text
15147    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15148    /// ````
15149    ///
15150    /// Sets the *delegate* property to the given value.
15151    pub fn delegate(
15152        mut self,
15153        new_value: &'a mut dyn common::Delegate,
15154    ) -> ProjectLocationOperationCancelCall<'a, C> {
15155        self._delegate = Some(new_value);
15156        self
15157    }
15158
15159    /// Set any additional parameter of the query string used in the request.
15160    /// It should be used to set parameters which are not yet available through their own
15161    /// setters.
15162    ///
15163    /// Please note that this method must not be used to set any of the known parameters
15164    /// which have their own setter method. If done anyway, the request will fail.
15165    ///
15166    /// # Additional Parameters
15167    ///
15168    /// * *$.xgafv* (query-string) - V1 error format.
15169    /// * *access_token* (query-string) - OAuth access token.
15170    /// * *alt* (query-string) - Data format for response.
15171    /// * *callback* (query-string) - JSONP
15172    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15173    /// * *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.
15174    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15175    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15176    /// * *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.
15177    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15178    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15179    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationCancelCall<'a, C>
15180    where
15181        T: AsRef<str>,
15182    {
15183        self._additional_params
15184            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15185        self
15186    }
15187
15188    /// Identifies the authorization scope for the method you are building.
15189    ///
15190    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15191    /// [`Scope::CloudPlatform`].
15192    ///
15193    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15194    /// tokens for more than one scope.
15195    ///
15196    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15197    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15198    /// sufficient, a read-write scope will do as well.
15199    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationCancelCall<'a, C>
15200    where
15201        St: AsRef<str>,
15202    {
15203        self._scopes.insert(String::from(scope.as_ref()));
15204        self
15205    }
15206    /// Identifies the authorization scope(s) for the method you are building.
15207    ///
15208    /// See [`Self::add_scope()`] for details.
15209    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationCancelCall<'a, C>
15210    where
15211        I: IntoIterator<Item = St>,
15212        St: AsRef<str>,
15213    {
15214        self._scopes
15215            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15216        self
15217    }
15218
15219    /// Removes all scopes, and no default scope will be used either.
15220    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15221    /// for details).
15222    pub fn clear_scopes(mut self) -> ProjectLocationOperationCancelCall<'a, C> {
15223        self._scopes.clear();
15224        self
15225    }
15226}
15227
15228/// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`.
15229///
15230/// A builder for the *locations.operations.delete* method supported by a *project* resource.
15231/// It is not used directly, but through a [`ProjectMethods`] instance.
15232///
15233/// # Example
15234///
15235/// Instantiate a resource method builder
15236///
15237/// ```test_harness,no_run
15238/// # extern crate hyper;
15239/// # extern crate hyper_rustls;
15240/// # extern crate google_notebooks1 as notebooks1;
15241/// # async fn dox() {
15242/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15243///
15244/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15245/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15246/// #     .with_native_roots()
15247/// #     .unwrap()
15248/// #     .https_only()
15249/// #     .enable_http2()
15250/// #     .build();
15251///
15252/// # let executor = hyper_util::rt::TokioExecutor::new();
15253/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15254/// #     secret,
15255/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15256/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15257/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15258/// #     ),
15259/// # ).build().await.unwrap();
15260///
15261/// # let client = hyper_util::client::legacy::Client::builder(
15262/// #     hyper_util::rt::TokioExecutor::new()
15263/// # )
15264/// # .build(
15265/// #     hyper_rustls::HttpsConnectorBuilder::new()
15266/// #         .with_native_roots()
15267/// #         .unwrap()
15268/// #         .https_or_http()
15269/// #         .enable_http2()
15270/// #         .build()
15271/// # );
15272/// # let mut hub = AIPlatformNotebooks::new(client, auth);
15273/// // You can configure optional parameters by calling the respective setters at will, and
15274/// // execute the final call using `doit()`.
15275/// // Values shown here are possibly random and not representative !
15276/// let result = hub.projects().locations_operations_delete("name")
15277///              .doit().await;
15278/// # }
15279/// ```
15280pub struct ProjectLocationOperationDeleteCall<'a, C>
15281where
15282    C: 'a,
15283{
15284    hub: &'a AIPlatformNotebooks<C>,
15285    _name: String,
15286    _delegate: Option<&'a mut dyn common::Delegate>,
15287    _additional_params: HashMap<String, String>,
15288    _scopes: BTreeSet<String>,
15289}
15290
15291impl<'a, C> common::CallBuilder for ProjectLocationOperationDeleteCall<'a, C> {}
15292
15293impl<'a, C> ProjectLocationOperationDeleteCall<'a, C>
15294where
15295    C: common::Connector,
15296{
15297    /// Perform the operation you have build so far.
15298    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
15299        use std::borrow::Cow;
15300        use std::io::{Read, Seek};
15301
15302        use common::{url::Params, ToParts};
15303        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15304
15305        let mut dd = common::DefaultDelegate;
15306        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15307        dlg.begin(common::MethodInfo {
15308            id: "notebooks.projects.locations.operations.delete",
15309            http_method: hyper::Method::DELETE,
15310        });
15311
15312        for &field in ["alt", "name"].iter() {
15313            if self._additional_params.contains_key(field) {
15314                dlg.finished(false);
15315                return Err(common::Error::FieldClash(field));
15316            }
15317        }
15318
15319        let mut params = Params::with_capacity(3 + self._additional_params.len());
15320        params.push("name", self._name);
15321
15322        params.extend(self._additional_params.iter());
15323
15324        params.push("alt", "json");
15325        let mut url = self.hub._base_url.clone() + "v1/{+name}";
15326        if self._scopes.is_empty() {
15327            self._scopes
15328                .insert(Scope::CloudPlatform.as_ref().to_string());
15329        }
15330
15331        #[allow(clippy::single_element_loop)]
15332        for &(find_this, param_name) in [("{+name}", "name")].iter() {
15333            url = params.uri_replacement(url, param_name, find_this, true);
15334        }
15335        {
15336            let to_remove = ["name"];
15337            params.remove_params(&to_remove);
15338        }
15339
15340        let url = params.parse_with_url(&url);
15341
15342        loop {
15343            let token = match self
15344                .hub
15345                .auth
15346                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15347                .await
15348            {
15349                Ok(token) => token,
15350                Err(e) => match dlg.token(e) {
15351                    Ok(token) => token,
15352                    Err(e) => {
15353                        dlg.finished(false);
15354                        return Err(common::Error::MissingToken(e));
15355                    }
15356                },
15357            };
15358            let mut req_result = {
15359                let client = &self.hub.client;
15360                dlg.pre_request();
15361                let mut req_builder = hyper::Request::builder()
15362                    .method(hyper::Method::DELETE)
15363                    .uri(url.as_str())
15364                    .header(USER_AGENT, self.hub._user_agent.clone());
15365
15366                if let Some(token) = token.as_ref() {
15367                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15368                }
15369
15370                let request = req_builder
15371                    .header(CONTENT_LENGTH, 0_u64)
15372                    .body(common::to_body::<String>(None));
15373
15374                client.request(request.unwrap()).await
15375            };
15376
15377            match req_result {
15378                Err(err) => {
15379                    if let common::Retry::After(d) = dlg.http_error(&err) {
15380                        sleep(d).await;
15381                        continue;
15382                    }
15383                    dlg.finished(false);
15384                    return Err(common::Error::HttpError(err));
15385                }
15386                Ok(res) => {
15387                    let (mut parts, body) = res.into_parts();
15388                    let mut body = common::Body::new(body);
15389                    if !parts.status.is_success() {
15390                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15391                        let error = serde_json::from_str(&common::to_string(&bytes));
15392                        let response = common::to_response(parts, bytes.into());
15393
15394                        if let common::Retry::After(d) =
15395                            dlg.http_failure(&response, error.as_ref().ok())
15396                        {
15397                            sleep(d).await;
15398                            continue;
15399                        }
15400
15401                        dlg.finished(false);
15402
15403                        return Err(match error {
15404                            Ok(value) => common::Error::BadRequest(value),
15405                            _ => common::Error::Failure(response),
15406                        });
15407                    }
15408                    let response = {
15409                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15410                        let encoded = common::to_string(&bytes);
15411                        match serde_json::from_str(&encoded) {
15412                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15413                            Err(error) => {
15414                                dlg.response_json_decode_error(&encoded, &error);
15415                                return Err(common::Error::JsonDecodeError(
15416                                    encoded.to_string(),
15417                                    error,
15418                                ));
15419                            }
15420                        }
15421                    };
15422
15423                    dlg.finished(true);
15424                    return Ok(response);
15425                }
15426            }
15427        }
15428    }
15429
15430    /// The name of the operation resource to be deleted.
15431    ///
15432    /// Sets the *name* path property to the given value.
15433    ///
15434    /// Even though the property as already been set when instantiating this call,
15435    /// we provide this method for API completeness.
15436    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationDeleteCall<'a, C> {
15437        self._name = new_value.to_string();
15438        self
15439    }
15440    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15441    /// while executing the actual API request.
15442    ///
15443    /// ````text
15444    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15445    /// ````
15446    ///
15447    /// Sets the *delegate* property to the given value.
15448    pub fn delegate(
15449        mut self,
15450        new_value: &'a mut dyn common::Delegate,
15451    ) -> ProjectLocationOperationDeleteCall<'a, C> {
15452        self._delegate = Some(new_value);
15453        self
15454    }
15455
15456    /// Set any additional parameter of the query string used in the request.
15457    /// It should be used to set parameters which are not yet available through their own
15458    /// setters.
15459    ///
15460    /// Please note that this method must not be used to set any of the known parameters
15461    /// which have their own setter method. If done anyway, the request will fail.
15462    ///
15463    /// # Additional Parameters
15464    ///
15465    /// * *$.xgafv* (query-string) - V1 error format.
15466    /// * *access_token* (query-string) - OAuth access token.
15467    /// * *alt* (query-string) - Data format for response.
15468    /// * *callback* (query-string) - JSONP
15469    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15470    /// * *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.
15471    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15472    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15473    /// * *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.
15474    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15475    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15476    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationDeleteCall<'a, C>
15477    where
15478        T: AsRef<str>,
15479    {
15480        self._additional_params
15481            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15482        self
15483    }
15484
15485    /// Identifies the authorization scope for the method you are building.
15486    ///
15487    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15488    /// [`Scope::CloudPlatform`].
15489    ///
15490    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15491    /// tokens for more than one scope.
15492    ///
15493    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15494    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15495    /// sufficient, a read-write scope will do as well.
15496    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationDeleteCall<'a, C>
15497    where
15498        St: AsRef<str>,
15499    {
15500        self._scopes.insert(String::from(scope.as_ref()));
15501        self
15502    }
15503    /// Identifies the authorization scope(s) for the method you are building.
15504    ///
15505    /// See [`Self::add_scope()`] for details.
15506    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationDeleteCall<'a, C>
15507    where
15508        I: IntoIterator<Item = St>,
15509        St: AsRef<str>,
15510    {
15511        self._scopes
15512            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15513        self
15514    }
15515
15516    /// Removes all scopes, and no default scope will be used either.
15517    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15518    /// for details).
15519    pub fn clear_scopes(mut self) -> ProjectLocationOperationDeleteCall<'a, C> {
15520        self._scopes.clear();
15521        self
15522    }
15523}
15524
15525/// 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.
15526///
15527/// A builder for the *locations.operations.get* method supported by a *project* resource.
15528/// It is not used directly, but through a [`ProjectMethods`] instance.
15529///
15530/// # Example
15531///
15532/// Instantiate a resource method builder
15533///
15534/// ```test_harness,no_run
15535/// # extern crate hyper;
15536/// # extern crate hyper_rustls;
15537/// # extern crate google_notebooks1 as notebooks1;
15538/// # async fn dox() {
15539/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15540///
15541/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15542/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15543/// #     .with_native_roots()
15544/// #     .unwrap()
15545/// #     .https_only()
15546/// #     .enable_http2()
15547/// #     .build();
15548///
15549/// # let executor = hyper_util::rt::TokioExecutor::new();
15550/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15551/// #     secret,
15552/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15553/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15554/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15555/// #     ),
15556/// # ).build().await.unwrap();
15557///
15558/// # let client = hyper_util::client::legacy::Client::builder(
15559/// #     hyper_util::rt::TokioExecutor::new()
15560/// # )
15561/// # .build(
15562/// #     hyper_rustls::HttpsConnectorBuilder::new()
15563/// #         .with_native_roots()
15564/// #         .unwrap()
15565/// #         .https_or_http()
15566/// #         .enable_http2()
15567/// #         .build()
15568/// # );
15569/// # let mut hub = AIPlatformNotebooks::new(client, auth);
15570/// // You can configure optional parameters by calling the respective setters at will, and
15571/// // execute the final call using `doit()`.
15572/// // Values shown here are possibly random and not representative !
15573/// let result = hub.projects().locations_operations_get("name")
15574///              .doit().await;
15575/// # }
15576/// ```
15577pub struct ProjectLocationOperationGetCall<'a, C>
15578where
15579    C: 'a,
15580{
15581    hub: &'a AIPlatformNotebooks<C>,
15582    _name: String,
15583    _delegate: Option<&'a mut dyn common::Delegate>,
15584    _additional_params: HashMap<String, String>,
15585    _scopes: BTreeSet<String>,
15586}
15587
15588impl<'a, C> common::CallBuilder for ProjectLocationOperationGetCall<'a, C> {}
15589
15590impl<'a, C> ProjectLocationOperationGetCall<'a, C>
15591where
15592    C: common::Connector,
15593{
15594    /// Perform the operation you have build so far.
15595    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
15596        use std::borrow::Cow;
15597        use std::io::{Read, Seek};
15598
15599        use common::{url::Params, ToParts};
15600        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15601
15602        let mut dd = common::DefaultDelegate;
15603        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15604        dlg.begin(common::MethodInfo {
15605            id: "notebooks.projects.locations.operations.get",
15606            http_method: hyper::Method::GET,
15607        });
15608
15609        for &field in ["alt", "name"].iter() {
15610            if self._additional_params.contains_key(field) {
15611                dlg.finished(false);
15612                return Err(common::Error::FieldClash(field));
15613            }
15614        }
15615
15616        let mut params = Params::with_capacity(3 + self._additional_params.len());
15617        params.push("name", self._name);
15618
15619        params.extend(self._additional_params.iter());
15620
15621        params.push("alt", "json");
15622        let mut url = self.hub._base_url.clone() + "v1/{+name}";
15623        if self._scopes.is_empty() {
15624            self._scopes
15625                .insert(Scope::CloudPlatform.as_ref().to_string());
15626        }
15627
15628        #[allow(clippy::single_element_loop)]
15629        for &(find_this, param_name) in [("{+name}", "name")].iter() {
15630            url = params.uri_replacement(url, param_name, find_this, true);
15631        }
15632        {
15633            let to_remove = ["name"];
15634            params.remove_params(&to_remove);
15635        }
15636
15637        let url = params.parse_with_url(&url);
15638
15639        loop {
15640            let token = match self
15641                .hub
15642                .auth
15643                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15644                .await
15645            {
15646                Ok(token) => token,
15647                Err(e) => match dlg.token(e) {
15648                    Ok(token) => token,
15649                    Err(e) => {
15650                        dlg.finished(false);
15651                        return Err(common::Error::MissingToken(e));
15652                    }
15653                },
15654            };
15655            let mut req_result = {
15656                let client = &self.hub.client;
15657                dlg.pre_request();
15658                let mut req_builder = hyper::Request::builder()
15659                    .method(hyper::Method::GET)
15660                    .uri(url.as_str())
15661                    .header(USER_AGENT, self.hub._user_agent.clone());
15662
15663                if let Some(token) = token.as_ref() {
15664                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15665                }
15666
15667                let request = req_builder
15668                    .header(CONTENT_LENGTH, 0_u64)
15669                    .body(common::to_body::<String>(None));
15670
15671                client.request(request.unwrap()).await
15672            };
15673
15674            match req_result {
15675                Err(err) => {
15676                    if let common::Retry::After(d) = dlg.http_error(&err) {
15677                        sleep(d).await;
15678                        continue;
15679                    }
15680                    dlg.finished(false);
15681                    return Err(common::Error::HttpError(err));
15682                }
15683                Ok(res) => {
15684                    let (mut parts, body) = res.into_parts();
15685                    let mut body = common::Body::new(body);
15686                    if !parts.status.is_success() {
15687                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15688                        let error = serde_json::from_str(&common::to_string(&bytes));
15689                        let response = common::to_response(parts, bytes.into());
15690
15691                        if let common::Retry::After(d) =
15692                            dlg.http_failure(&response, error.as_ref().ok())
15693                        {
15694                            sleep(d).await;
15695                            continue;
15696                        }
15697
15698                        dlg.finished(false);
15699
15700                        return Err(match error {
15701                            Ok(value) => common::Error::BadRequest(value),
15702                            _ => common::Error::Failure(response),
15703                        });
15704                    }
15705                    let response = {
15706                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15707                        let encoded = common::to_string(&bytes);
15708                        match serde_json::from_str(&encoded) {
15709                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15710                            Err(error) => {
15711                                dlg.response_json_decode_error(&encoded, &error);
15712                                return Err(common::Error::JsonDecodeError(
15713                                    encoded.to_string(),
15714                                    error,
15715                                ));
15716                            }
15717                        }
15718                    };
15719
15720                    dlg.finished(true);
15721                    return Ok(response);
15722                }
15723            }
15724        }
15725    }
15726
15727    /// The name of the operation resource.
15728    ///
15729    /// Sets the *name* path property to the given value.
15730    ///
15731    /// Even though the property as already been set when instantiating this call,
15732    /// we provide this method for API completeness.
15733    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationGetCall<'a, C> {
15734        self._name = new_value.to_string();
15735        self
15736    }
15737    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15738    /// while executing the actual API request.
15739    ///
15740    /// ````text
15741    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15742    /// ````
15743    ///
15744    /// Sets the *delegate* property to the given value.
15745    pub fn delegate(
15746        mut self,
15747        new_value: &'a mut dyn common::Delegate,
15748    ) -> ProjectLocationOperationGetCall<'a, C> {
15749        self._delegate = Some(new_value);
15750        self
15751    }
15752
15753    /// Set any additional parameter of the query string used in the request.
15754    /// It should be used to set parameters which are not yet available through their own
15755    /// setters.
15756    ///
15757    /// Please note that this method must not be used to set any of the known parameters
15758    /// which have their own setter method. If done anyway, the request will fail.
15759    ///
15760    /// # Additional Parameters
15761    ///
15762    /// * *$.xgafv* (query-string) - V1 error format.
15763    /// * *access_token* (query-string) - OAuth access token.
15764    /// * *alt* (query-string) - Data format for response.
15765    /// * *callback* (query-string) - JSONP
15766    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15767    /// * *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.
15768    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15769    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15770    /// * *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.
15771    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15772    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15773    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationGetCall<'a, C>
15774    where
15775        T: AsRef<str>,
15776    {
15777        self._additional_params
15778            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15779        self
15780    }
15781
15782    /// Identifies the authorization scope for the method you are building.
15783    ///
15784    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15785    /// [`Scope::CloudPlatform`].
15786    ///
15787    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15788    /// tokens for more than one scope.
15789    ///
15790    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15791    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15792    /// sufficient, a read-write scope will do as well.
15793    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationGetCall<'a, C>
15794    where
15795        St: AsRef<str>,
15796    {
15797        self._scopes.insert(String::from(scope.as_ref()));
15798        self
15799    }
15800    /// Identifies the authorization scope(s) for the method you are building.
15801    ///
15802    /// See [`Self::add_scope()`] for details.
15803    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationGetCall<'a, C>
15804    where
15805        I: IntoIterator<Item = St>,
15806        St: AsRef<str>,
15807    {
15808        self._scopes
15809            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15810        self
15811    }
15812
15813    /// Removes all scopes, and no default scope will be used either.
15814    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15815    /// for details).
15816    pub fn clear_scopes(mut self) -> ProjectLocationOperationGetCall<'a, C> {
15817        self._scopes.clear();
15818        self
15819    }
15820}
15821
15822/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
15823///
15824/// A builder for the *locations.operations.list* method supported by a *project* resource.
15825/// It is not used directly, but through a [`ProjectMethods`] instance.
15826///
15827/// # Example
15828///
15829/// Instantiate a resource method builder
15830///
15831/// ```test_harness,no_run
15832/// # extern crate hyper;
15833/// # extern crate hyper_rustls;
15834/// # extern crate google_notebooks1 as notebooks1;
15835/// # async fn dox() {
15836/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15837///
15838/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15839/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15840/// #     .with_native_roots()
15841/// #     .unwrap()
15842/// #     .https_only()
15843/// #     .enable_http2()
15844/// #     .build();
15845///
15846/// # let executor = hyper_util::rt::TokioExecutor::new();
15847/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15848/// #     secret,
15849/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15850/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15851/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15852/// #     ),
15853/// # ).build().await.unwrap();
15854///
15855/// # let client = hyper_util::client::legacy::Client::builder(
15856/// #     hyper_util::rt::TokioExecutor::new()
15857/// # )
15858/// # .build(
15859/// #     hyper_rustls::HttpsConnectorBuilder::new()
15860/// #         .with_native_roots()
15861/// #         .unwrap()
15862/// #         .https_or_http()
15863/// #         .enable_http2()
15864/// #         .build()
15865/// # );
15866/// # let mut hub = AIPlatformNotebooks::new(client, auth);
15867/// // You can configure optional parameters by calling the respective setters at will, and
15868/// // execute the final call using `doit()`.
15869/// // Values shown here are possibly random and not representative !
15870/// let result = hub.projects().locations_operations_list("name")
15871///              .return_partial_success(false)
15872///              .page_token("duo")
15873///              .page_size(-76)
15874///              .filter("vero")
15875///              .doit().await;
15876/// # }
15877/// ```
15878pub struct ProjectLocationOperationListCall<'a, C>
15879where
15880    C: 'a,
15881{
15882    hub: &'a AIPlatformNotebooks<C>,
15883    _name: String,
15884    _return_partial_success: Option<bool>,
15885    _page_token: Option<String>,
15886    _page_size: Option<i32>,
15887    _filter: Option<String>,
15888    _delegate: Option<&'a mut dyn common::Delegate>,
15889    _additional_params: HashMap<String, String>,
15890    _scopes: BTreeSet<String>,
15891}
15892
15893impl<'a, C> common::CallBuilder for ProjectLocationOperationListCall<'a, C> {}
15894
15895impl<'a, C> ProjectLocationOperationListCall<'a, C>
15896where
15897    C: common::Connector,
15898{
15899    /// Perform the operation you have build so far.
15900    pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
15901        use std::borrow::Cow;
15902        use std::io::{Read, Seek};
15903
15904        use common::{url::Params, ToParts};
15905        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15906
15907        let mut dd = common::DefaultDelegate;
15908        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15909        dlg.begin(common::MethodInfo {
15910            id: "notebooks.projects.locations.operations.list",
15911            http_method: hyper::Method::GET,
15912        });
15913
15914        for &field in [
15915            "alt",
15916            "name",
15917            "returnPartialSuccess",
15918            "pageToken",
15919            "pageSize",
15920            "filter",
15921        ]
15922        .iter()
15923        {
15924            if self._additional_params.contains_key(field) {
15925                dlg.finished(false);
15926                return Err(common::Error::FieldClash(field));
15927            }
15928        }
15929
15930        let mut params = Params::with_capacity(7 + self._additional_params.len());
15931        params.push("name", self._name);
15932        if let Some(value) = self._return_partial_success.as_ref() {
15933            params.push("returnPartialSuccess", value.to_string());
15934        }
15935        if let Some(value) = self._page_token.as_ref() {
15936            params.push("pageToken", value);
15937        }
15938        if let Some(value) = self._page_size.as_ref() {
15939            params.push("pageSize", value.to_string());
15940        }
15941        if let Some(value) = self._filter.as_ref() {
15942            params.push("filter", value);
15943        }
15944
15945        params.extend(self._additional_params.iter());
15946
15947        params.push("alt", "json");
15948        let mut url = self.hub._base_url.clone() + "v1/{+name}/operations";
15949        if self._scopes.is_empty() {
15950            self._scopes
15951                .insert(Scope::CloudPlatform.as_ref().to_string());
15952        }
15953
15954        #[allow(clippy::single_element_loop)]
15955        for &(find_this, param_name) in [("{+name}", "name")].iter() {
15956            url = params.uri_replacement(url, param_name, find_this, true);
15957        }
15958        {
15959            let to_remove = ["name"];
15960            params.remove_params(&to_remove);
15961        }
15962
15963        let url = params.parse_with_url(&url);
15964
15965        loop {
15966            let token = match self
15967                .hub
15968                .auth
15969                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15970                .await
15971            {
15972                Ok(token) => token,
15973                Err(e) => match dlg.token(e) {
15974                    Ok(token) => token,
15975                    Err(e) => {
15976                        dlg.finished(false);
15977                        return Err(common::Error::MissingToken(e));
15978                    }
15979                },
15980            };
15981            let mut req_result = {
15982                let client = &self.hub.client;
15983                dlg.pre_request();
15984                let mut req_builder = hyper::Request::builder()
15985                    .method(hyper::Method::GET)
15986                    .uri(url.as_str())
15987                    .header(USER_AGENT, self.hub._user_agent.clone());
15988
15989                if let Some(token) = token.as_ref() {
15990                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15991                }
15992
15993                let request = req_builder
15994                    .header(CONTENT_LENGTH, 0_u64)
15995                    .body(common::to_body::<String>(None));
15996
15997                client.request(request.unwrap()).await
15998            };
15999
16000            match req_result {
16001                Err(err) => {
16002                    if let common::Retry::After(d) = dlg.http_error(&err) {
16003                        sleep(d).await;
16004                        continue;
16005                    }
16006                    dlg.finished(false);
16007                    return Err(common::Error::HttpError(err));
16008                }
16009                Ok(res) => {
16010                    let (mut parts, body) = res.into_parts();
16011                    let mut body = common::Body::new(body);
16012                    if !parts.status.is_success() {
16013                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16014                        let error = serde_json::from_str(&common::to_string(&bytes));
16015                        let response = common::to_response(parts, bytes.into());
16016
16017                        if let common::Retry::After(d) =
16018                            dlg.http_failure(&response, error.as_ref().ok())
16019                        {
16020                            sleep(d).await;
16021                            continue;
16022                        }
16023
16024                        dlg.finished(false);
16025
16026                        return Err(match error {
16027                            Ok(value) => common::Error::BadRequest(value),
16028                            _ => common::Error::Failure(response),
16029                        });
16030                    }
16031                    let response = {
16032                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16033                        let encoded = common::to_string(&bytes);
16034                        match serde_json::from_str(&encoded) {
16035                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16036                            Err(error) => {
16037                                dlg.response_json_decode_error(&encoded, &error);
16038                                return Err(common::Error::JsonDecodeError(
16039                                    encoded.to_string(),
16040                                    error,
16041                                ));
16042                            }
16043                        }
16044                    };
16045
16046                    dlg.finished(true);
16047                    return Ok(response);
16048                }
16049            }
16050        }
16051    }
16052
16053    /// The name of the operation's parent resource.
16054    ///
16055    /// Sets the *name* path property to the given value.
16056    ///
16057    /// Even though the property as already been set when instantiating this call,
16058    /// we provide this method for API completeness.
16059    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
16060        self._name = new_value.to_string();
16061        self
16062    }
16063    /// When set to `true`, operations that are reachable are returned as normal, and those that are unreachable are returned in the ListOperationsResponse.unreachable field. This can only be `true` when reading across collections. For example, when `parent` is set to `"projects/example/locations/-"`. This field is not supported by default and will result in an `UNIMPLEMENTED` error if set unless explicitly documented otherwise in service or product specific documentation.
16064    ///
16065    /// Sets the *return partial success* query property to the given value.
16066    pub fn return_partial_success(
16067        mut self,
16068        new_value: bool,
16069    ) -> ProjectLocationOperationListCall<'a, C> {
16070        self._return_partial_success = Some(new_value);
16071        self
16072    }
16073    /// The standard list page token.
16074    ///
16075    /// Sets the *page token* query property to the given value.
16076    pub fn page_token(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
16077        self._page_token = Some(new_value.to_string());
16078        self
16079    }
16080    /// The standard list page size.
16081    ///
16082    /// Sets the *page size* query property to the given value.
16083    pub fn page_size(mut self, new_value: i32) -> ProjectLocationOperationListCall<'a, C> {
16084        self._page_size = Some(new_value);
16085        self
16086    }
16087    /// The standard list filter.
16088    ///
16089    /// Sets the *filter* query property to the given value.
16090    pub fn filter(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
16091        self._filter = Some(new_value.to_string());
16092        self
16093    }
16094    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16095    /// while executing the actual API request.
16096    ///
16097    /// ````text
16098    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16099    /// ````
16100    ///
16101    /// Sets the *delegate* property to the given value.
16102    pub fn delegate(
16103        mut self,
16104        new_value: &'a mut dyn common::Delegate,
16105    ) -> ProjectLocationOperationListCall<'a, C> {
16106        self._delegate = Some(new_value);
16107        self
16108    }
16109
16110    /// Set any additional parameter of the query string used in the request.
16111    /// It should be used to set parameters which are not yet available through their own
16112    /// setters.
16113    ///
16114    /// Please note that this method must not be used to set any of the known parameters
16115    /// which have their own setter method. If done anyway, the request will fail.
16116    ///
16117    /// # Additional Parameters
16118    ///
16119    /// * *$.xgafv* (query-string) - V1 error format.
16120    /// * *access_token* (query-string) - OAuth access token.
16121    /// * *alt* (query-string) - Data format for response.
16122    /// * *callback* (query-string) - JSONP
16123    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16124    /// * *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.
16125    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16126    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16127    /// * *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.
16128    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16129    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16130    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationListCall<'a, C>
16131    where
16132        T: AsRef<str>,
16133    {
16134        self._additional_params
16135            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16136        self
16137    }
16138
16139    /// Identifies the authorization scope for the method you are building.
16140    ///
16141    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16142    /// [`Scope::CloudPlatform`].
16143    ///
16144    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16145    /// tokens for more than one scope.
16146    ///
16147    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16148    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16149    /// sufficient, a read-write scope will do as well.
16150    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationListCall<'a, C>
16151    where
16152        St: AsRef<str>,
16153    {
16154        self._scopes.insert(String::from(scope.as_ref()));
16155        self
16156    }
16157    /// Identifies the authorization scope(s) for the method you are building.
16158    ///
16159    /// See [`Self::add_scope()`] for details.
16160    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationListCall<'a, C>
16161    where
16162        I: IntoIterator<Item = St>,
16163        St: AsRef<str>,
16164    {
16165        self._scopes
16166            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16167        self
16168    }
16169
16170    /// Removes all scopes, and no default scope will be used either.
16171    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16172    /// for details).
16173    pub fn clear_scopes(mut self) -> ProjectLocationOperationListCall<'a, C> {
16174        self._scopes.clear();
16175        self
16176    }
16177}
16178
16179/// Creates a new Runtime in a given project and location.
16180///
16181/// A builder for the *locations.runtimes.create* method supported by a *project* resource.
16182/// It is not used directly, but through a [`ProjectMethods`] instance.
16183///
16184/// # Example
16185///
16186/// Instantiate a resource method builder
16187///
16188/// ```test_harness,no_run
16189/// # extern crate hyper;
16190/// # extern crate hyper_rustls;
16191/// # extern crate google_notebooks1 as notebooks1;
16192/// use notebooks1::api::Runtime;
16193/// # async fn dox() {
16194/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16195///
16196/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16197/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16198/// #     .with_native_roots()
16199/// #     .unwrap()
16200/// #     .https_only()
16201/// #     .enable_http2()
16202/// #     .build();
16203///
16204/// # let executor = hyper_util::rt::TokioExecutor::new();
16205/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16206/// #     secret,
16207/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16208/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16209/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16210/// #     ),
16211/// # ).build().await.unwrap();
16212///
16213/// # let client = hyper_util::client::legacy::Client::builder(
16214/// #     hyper_util::rt::TokioExecutor::new()
16215/// # )
16216/// # .build(
16217/// #     hyper_rustls::HttpsConnectorBuilder::new()
16218/// #         .with_native_roots()
16219/// #         .unwrap()
16220/// #         .https_or_http()
16221/// #         .enable_http2()
16222/// #         .build()
16223/// # );
16224/// # let mut hub = AIPlatformNotebooks::new(client, auth);
16225/// // As the method needs a request, you would usually fill it with the desired information
16226/// // into the respective structure. Some of the parts shown here might not be applicable !
16227/// // Values shown here are possibly random and not representative !
16228/// let mut req = Runtime::default();
16229///
16230/// // You can configure optional parameters by calling the respective setters at will, and
16231/// // execute the final call using `doit()`.
16232/// // Values shown here are possibly random and not representative !
16233/// let result = hub.projects().locations_runtimes_create(req, "parent")
16234///              .runtime_id("Stet")
16235///              .request_id("vero")
16236///              .doit().await;
16237/// # }
16238/// ```
16239pub struct ProjectLocationRuntimeCreateCall<'a, C>
16240where
16241    C: 'a,
16242{
16243    hub: &'a AIPlatformNotebooks<C>,
16244    _request: Runtime,
16245    _parent: String,
16246    _runtime_id: Option<String>,
16247    _request_id: Option<String>,
16248    _delegate: Option<&'a mut dyn common::Delegate>,
16249    _additional_params: HashMap<String, String>,
16250    _scopes: BTreeSet<String>,
16251}
16252
16253impl<'a, C> common::CallBuilder for ProjectLocationRuntimeCreateCall<'a, C> {}
16254
16255impl<'a, C> ProjectLocationRuntimeCreateCall<'a, C>
16256where
16257    C: common::Connector,
16258{
16259    /// Perform the operation you have build so far.
16260    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
16261        use std::borrow::Cow;
16262        use std::io::{Read, Seek};
16263
16264        use common::{url::Params, ToParts};
16265        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16266
16267        let mut dd = common::DefaultDelegate;
16268        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16269        dlg.begin(common::MethodInfo {
16270            id: "notebooks.projects.locations.runtimes.create",
16271            http_method: hyper::Method::POST,
16272        });
16273
16274        for &field in ["alt", "parent", "runtimeId", "requestId"].iter() {
16275            if self._additional_params.contains_key(field) {
16276                dlg.finished(false);
16277                return Err(common::Error::FieldClash(field));
16278            }
16279        }
16280
16281        let mut params = Params::with_capacity(6 + self._additional_params.len());
16282        params.push("parent", self._parent);
16283        if let Some(value) = self._runtime_id.as_ref() {
16284            params.push("runtimeId", value);
16285        }
16286        if let Some(value) = self._request_id.as_ref() {
16287            params.push("requestId", value);
16288        }
16289
16290        params.extend(self._additional_params.iter());
16291
16292        params.push("alt", "json");
16293        let mut url = self.hub._base_url.clone() + "v1/{+parent}/runtimes";
16294        if self._scopes.is_empty() {
16295            self._scopes
16296                .insert(Scope::CloudPlatform.as_ref().to_string());
16297        }
16298
16299        #[allow(clippy::single_element_loop)]
16300        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
16301            url = params.uri_replacement(url, param_name, find_this, true);
16302        }
16303        {
16304            let to_remove = ["parent"];
16305            params.remove_params(&to_remove);
16306        }
16307
16308        let url = params.parse_with_url(&url);
16309
16310        let mut json_mime_type = mime::APPLICATION_JSON;
16311        let mut request_value_reader = {
16312            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16313            common::remove_json_null_values(&mut value);
16314            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16315            serde_json::to_writer(&mut dst, &value).unwrap();
16316            dst
16317        };
16318        let request_size = request_value_reader
16319            .seek(std::io::SeekFrom::End(0))
16320            .unwrap();
16321        request_value_reader
16322            .seek(std::io::SeekFrom::Start(0))
16323            .unwrap();
16324
16325        loop {
16326            let token = match self
16327                .hub
16328                .auth
16329                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16330                .await
16331            {
16332                Ok(token) => token,
16333                Err(e) => match dlg.token(e) {
16334                    Ok(token) => token,
16335                    Err(e) => {
16336                        dlg.finished(false);
16337                        return Err(common::Error::MissingToken(e));
16338                    }
16339                },
16340            };
16341            request_value_reader
16342                .seek(std::io::SeekFrom::Start(0))
16343                .unwrap();
16344            let mut req_result = {
16345                let client = &self.hub.client;
16346                dlg.pre_request();
16347                let mut req_builder = hyper::Request::builder()
16348                    .method(hyper::Method::POST)
16349                    .uri(url.as_str())
16350                    .header(USER_AGENT, self.hub._user_agent.clone());
16351
16352                if let Some(token) = token.as_ref() {
16353                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16354                }
16355
16356                let request = req_builder
16357                    .header(CONTENT_TYPE, json_mime_type.to_string())
16358                    .header(CONTENT_LENGTH, request_size as u64)
16359                    .body(common::to_body(
16360                        request_value_reader.get_ref().clone().into(),
16361                    ));
16362
16363                client.request(request.unwrap()).await
16364            };
16365
16366            match req_result {
16367                Err(err) => {
16368                    if let common::Retry::After(d) = dlg.http_error(&err) {
16369                        sleep(d).await;
16370                        continue;
16371                    }
16372                    dlg.finished(false);
16373                    return Err(common::Error::HttpError(err));
16374                }
16375                Ok(res) => {
16376                    let (mut parts, body) = res.into_parts();
16377                    let mut body = common::Body::new(body);
16378                    if !parts.status.is_success() {
16379                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16380                        let error = serde_json::from_str(&common::to_string(&bytes));
16381                        let response = common::to_response(parts, bytes.into());
16382
16383                        if let common::Retry::After(d) =
16384                            dlg.http_failure(&response, error.as_ref().ok())
16385                        {
16386                            sleep(d).await;
16387                            continue;
16388                        }
16389
16390                        dlg.finished(false);
16391
16392                        return Err(match error {
16393                            Ok(value) => common::Error::BadRequest(value),
16394                            _ => common::Error::Failure(response),
16395                        });
16396                    }
16397                    let response = {
16398                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16399                        let encoded = common::to_string(&bytes);
16400                        match serde_json::from_str(&encoded) {
16401                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16402                            Err(error) => {
16403                                dlg.response_json_decode_error(&encoded, &error);
16404                                return Err(common::Error::JsonDecodeError(
16405                                    encoded.to_string(),
16406                                    error,
16407                                ));
16408                            }
16409                        }
16410                    };
16411
16412                    dlg.finished(true);
16413                    return Ok(response);
16414                }
16415            }
16416        }
16417    }
16418
16419    ///
16420    /// Sets the *request* property to the given value.
16421    ///
16422    /// Even though the property as already been set when instantiating this call,
16423    /// we provide this method for API completeness.
16424    pub fn request(mut self, new_value: Runtime) -> ProjectLocationRuntimeCreateCall<'a, C> {
16425        self._request = new_value;
16426        self
16427    }
16428    /// Required. Format: `parent=projects/{project_id}/locations/{location}`
16429    ///
16430    /// Sets the *parent* path property to the given value.
16431    ///
16432    /// Even though the property as already been set when instantiating this call,
16433    /// we provide this method for API completeness.
16434    pub fn parent(mut self, new_value: &str) -> ProjectLocationRuntimeCreateCall<'a, C> {
16435        self._parent = new_value.to_string();
16436        self
16437    }
16438    /// Required. User-defined unique ID of this Runtime.
16439    ///
16440    /// Sets the *runtime id* query property to the given value.
16441    pub fn runtime_id(mut self, new_value: &str) -> ProjectLocationRuntimeCreateCall<'a, C> {
16442        self._runtime_id = Some(new_value.to_string());
16443        self
16444    }
16445    /// Idempotent request UUID.
16446    ///
16447    /// Sets the *request id* query property to the given value.
16448    pub fn request_id(mut self, new_value: &str) -> ProjectLocationRuntimeCreateCall<'a, C> {
16449        self._request_id = Some(new_value.to_string());
16450        self
16451    }
16452    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16453    /// while executing the actual API request.
16454    ///
16455    /// ````text
16456    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16457    /// ````
16458    ///
16459    /// Sets the *delegate* property to the given value.
16460    pub fn delegate(
16461        mut self,
16462        new_value: &'a mut dyn common::Delegate,
16463    ) -> ProjectLocationRuntimeCreateCall<'a, C> {
16464        self._delegate = Some(new_value);
16465        self
16466    }
16467
16468    /// Set any additional parameter of the query string used in the request.
16469    /// It should be used to set parameters which are not yet available through their own
16470    /// setters.
16471    ///
16472    /// Please note that this method must not be used to set any of the known parameters
16473    /// which have their own setter method. If done anyway, the request will fail.
16474    ///
16475    /// # Additional Parameters
16476    ///
16477    /// * *$.xgafv* (query-string) - V1 error format.
16478    /// * *access_token* (query-string) - OAuth access token.
16479    /// * *alt* (query-string) - Data format for response.
16480    /// * *callback* (query-string) - JSONP
16481    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16482    /// * *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.
16483    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16484    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16485    /// * *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.
16486    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16487    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16488    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRuntimeCreateCall<'a, C>
16489    where
16490        T: AsRef<str>,
16491    {
16492        self._additional_params
16493            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16494        self
16495    }
16496
16497    /// Identifies the authorization scope for the method you are building.
16498    ///
16499    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16500    /// [`Scope::CloudPlatform`].
16501    ///
16502    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16503    /// tokens for more than one scope.
16504    ///
16505    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16506    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16507    /// sufficient, a read-write scope will do as well.
16508    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRuntimeCreateCall<'a, C>
16509    where
16510        St: AsRef<str>,
16511    {
16512        self._scopes.insert(String::from(scope.as_ref()));
16513        self
16514    }
16515    /// Identifies the authorization scope(s) for the method you are building.
16516    ///
16517    /// See [`Self::add_scope()`] for details.
16518    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRuntimeCreateCall<'a, C>
16519    where
16520        I: IntoIterator<Item = St>,
16521        St: AsRef<str>,
16522    {
16523        self._scopes
16524            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16525        self
16526    }
16527
16528    /// Removes all scopes, and no default scope will be used either.
16529    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16530    /// for details).
16531    pub fn clear_scopes(mut self) -> ProjectLocationRuntimeCreateCall<'a, C> {
16532        self._scopes.clear();
16533        self
16534    }
16535}
16536
16537/// Deletes a single Runtime.
16538///
16539/// A builder for the *locations.runtimes.delete* method supported by a *project* resource.
16540/// It is not used directly, but through a [`ProjectMethods`] instance.
16541///
16542/// # Example
16543///
16544/// Instantiate a resource method builder
16545///
16546/// ```test_harness,no_run
16547/// # extern crate hyper;
16548/// # extern crate hyper_rustls;
16549/// # extern crate google_notebooks1 as notebooks1;
16550/// # async fn dox() {
16551/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16552///
16553/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16554/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16555/// #     .with_native_roots()
16556/// #     .unwrap()
16557/// #     .https_only()
16558/// #     .enable_http2()
16559/// #     .build();
16560///
16561/// # let executor = hyper_util::rt::TokioExecutor::new();
16562/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16563/// #     secret,
16564/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16565/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16566/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16567/// #     ),
16568/// # ).build().await.unwrap();
16569///
16570/// # let client = hyper_util::client::legacy::Client::builder(
16571/// #     hyper_util::rt::TokioExecutor::new()
16572/// # )
16573/// # .build(
16574/// #     hyper_rustls::HttpsConnectorBuilder::new()
16575/// #         .with_native_roots()
16576/// #         .unwrap()
16577/// #         .https_or_http()
16578/// #         .enable_http2()
16579/// #         .build()
16580/// # );
16581/// # let mut hub = AIPlatformNotebooks::new(client, auth);
16582/// // You can configure optional parameters by calling the respective setters at will, and
16583/// // execute the final call using `doit()`.
16584/// // Values shown here are possibly random and not representative !
16585/// let result = hub.projects().locations_runtimes_delete("name")
16586///              .request_id("Lorem")
16587///              .doit().await;
16588/// # }
16589/// ```
16590pub struct ProjectLocationRuntimeDeleteCall<'a, C>
16591where
16592    C: 'a,
16593{
16594    hub: &'a AIPlatformNotebooks<C>,
16595    _name: String,
16596    _request_id: Option<String>,
16597    _delegate: Option<&'a mut dyn common::Delegate>,
16598    _additional_params: HashMap<String, String>,
16599    _scopes: BTreeSet<String>,
16600}
16601
16602impl<'a, C> common::CallBuilder for ProjectLocationRuntimeDeleteCall<'a, C> {}
16603
16604impl<'a, C> ProjectLocationRuntimeDeleteCall<'a, C>
16605where
16606    C: common::Connector,
16607{
16608    /// Perform the operation you have build so far.
16609    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
16610        use std::borrow::Cow;
16611        use std::io::{Read, Seek};
16612
16613        use common::{url::Params, ToParts};
16614        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16615
16616        let mut dd = common::DefaultDelegate;
16617        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16618        dlg.begin(common::MethodInfo {
16619            id: "notebooks.projects.locations.runtimes.delete",
16620            http_method: hyper::Method::DELETE,
16621        });
16622
16623        for &field in ["alt", "name", "requestId"].iter() {
16624            if self._additional_params.contains_key(field) {
16625                dlg.finished(false);
16626                return Err(common::Error::FieldClash(field));
16627            }
16628        }
16629
16630        let mut params = Params::with_capacity(4 + self._additional_params.len());
16631        params.push("name", self._name);
16632        if let Some(value) = self._request_id.as_ref() {
16633            params.push("requestId", value);
16634        }
16635
16636        params.extend(self._additional_params.iter());
16637
16638        params.push("alt", "json");
16639        let mut url = self.hub._base_url.clone() + "v1/{+name}";
16640        if self._scopes.is_empty() {
16641            self._scopes
16642                .insert(Scope::CloudPlatform.as_ref().to_string());
16643        }
16644
16645        #[allow(clippy::single_element_loop)]
16646        for &(find_this, param_name) in [("{+name}", "name")].iter() {
16647            url = params.uri_replacement(url, param_name, find_this, true);
16648        }
16649        {
16650            let to_remove = ["name"];
16651            params.remove_params(&to_remove);
16652        }
16653
16654        let url = params.parse_with_url(&url);
16655
16656        loop {
16657            let token = match self
16658                .hub
16659                .auth
16660                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16661                .await
16662            {
16663                Ok(token) => token,
16664                Err(e) => match dlg.token(e) {
16665                    Ok(token) => token,
16666                    Err(e) => {
16667                        dlg.finished(false);
16668                        return Err(common::Error::MissingToken(e));
16669                    }
16670                },
16671            };
16672            let mut req_result = {
16673                let client = &self.hub.client;
16674                dlg.pre_request();
16675                let mut req_builder = hyper::Request::builder()
16676                    .method(hyper::Method::DELETE)
16677                    .uri(url.as_str())
16678                    .header(USER_AGENT, self.hub._user_agent.clone());
16679
16680                if let Some(token) = token.as_ref() {
16681                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16682                }
16683
16684                let request = req_builder
16685                    .header(CONTENT_LENGTH, 0_u64)
16686                    .body(common::to_body::<String>(None));
16687
16688                client.request(request.unwrap()).await
16689            };
16690
16691            match req_result {
16692                Err(err) => {
16693                    if let common::Retry::After(d) = dlg.http_error(&err) {
16694                        sleep(d).await;
16695                        continue;
16696                    }
16697                    dlg.finished(false);
16698                    return Err(common::Error::HttpError(err));
16699                }
16700                Ok(res) => {
16701                    let (mut parts, body) = res.into_parts();
16702                    let mut body = common::Body::new(body);
16703                    if !parts.status.is_success() {
16704                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16705                        let error = serde_json::from_str(&common::to_string(&bytes));
16706                        let response = common::to_response(parts, bytes.into());
16707
16708                        if let common::Retry::After(d) =
16709                            dlg.http_failure(&response, error.as_ref().ok())
16710                        {
16711                            sleep(d).await;
16712                            continue;
16713                        }
16714
16715                        dlg.finished(false);
16716
16717                        return Err(match error {
16718                            Ok(value) => common::Error::BadRequest(value),
16719                            _ => common::Error::Failure(response),
16720                        });
16721                    }
16722                    let response = {
16723                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16724                        let encoded = common::to_string(&bytes);
16725                        match serde_json::from_str(&encoded) {
16726                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16727                            Err(error) => {
16728                                dlg.response_json_decode_error(&encoded, &error);
16729                                return Err(common::Error::JsonDecodeError(
16730                                    encoded.to_string(),
16731                                    error,
16732                                ));
16733                            }
16734                        }
16735                    };
16736
16737                    dlg.finished(true);
16738                    return Ok(response);
16739                }
16740            }
16741        }
16742    }
16743
16744    /// Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
16745    ///
16746    /// Sets the *name* path property to the given value.
16747    ///
16748    /// Even though the property as already been set when instantiating this call,
16749    /// we provide this method for API completeness.
16750    pub fn name(mut self, new_value: &str) -> ProjectLocationRuntimeDeleteCall<'a, C> {
16751        self._name = new_value.to_string();
16752        self
16753    }
16754    /// Idempotent request UUID.
16755    ///
16756    /// Sets the *request id* query property to the given value.
16757    pub fn request_id(mut self, new_value: &str) -> ProjectLocationRuntimeDeleteCall<'a, C> {
16758        self._request_id = Some(new_value.to_string());
16759        self
16760    }
16761    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16762    /// while executing the actual API request.
16763    ///
16764    /// ````text
16765    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16766    /// ````
16767    ///
16768    /// Sets the *delegate* property to the given value.
16769    pub fn delegate(
16770        mut self,
16771        new_value: &'a mut dyn common::Delegate,
16772    ) -> ProjectLocationRuntimeDeleteCall<'a, C> {
16773        self._delegate = Some(new_value);
16774        self
16775    }
16776
16777    /// Set any additional parameter of the query string used in the request.
16778    /// It should be used to set parameters which are not yet available through their own
16779    /// setters.
16780    ///
16781    /// Please note that this method must not be used to set any of the known parameters
16782    /// which have their own setter method. If done anyway, the request will fail.
16783    ///
16784    /// # Additional Parameters
16785    ///
16786    /// * *$.xgafv* (query-string) - V1 error format.
16787    /// * *access_token* (query-string) - OAuth access token.
16788    /// * *alt* (query-string) - Data format for response.
16789    /// * *callback* (query-string) - JSONP
16790    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16791    /// * *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.
16792    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16793    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16794    /// * *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.
16795    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16796    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16797    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRuntimeDeleteCall<'a, C>
16798    where
16799        T: AsRef<str>,
16800    {
16801        self._additional_params
16802            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16803        self
16804    }
16805
16806    /// Identifies the authorization scope for the method you are building.
16807    ///
16808    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16809    /// [`Scope::CloudPlatform`].
16810    ///
16811    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16812    /// tokens for more than one scope.
16813    ///
16814    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16815    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16816    /// sufficient, a read-write scope will do as well.
16817    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRuntimeDeleteCall<'a, C>
16818    where
16819        St: AsRef<str>,
16820    {
16821        self._scopes.insert(String::from(scope.as_ref()));
16822        self
16823    }
16824    /// Identifies the authorization scope(s) for the method you are building.
16825    ///
16826    /// See [`Self::add_scope()`] for details.
16827    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRuntimeDeleteCall<'a, C>
16828    where
16829        I: IntoIterator<Item = St>,
16830        St: AsRef<str>,
16831    {
16832        self._scopes
16833            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16834        self
16835    }
16836
16837    /// Removes all scopes, and no default scope will be used either.
16838    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16839    /// for details).
16840    pub fn clear_scopes(mut self) -> ProjectLocationRuntimeDeleteCall<'a, C> {
16841        self._scopes.clear();
16842        self
16843    }
16844}
16845
16846/// Creates a Diagnostic File and runs Diagnostic Tool given a Runtime.
16847///
16848/// A builder for the *locations.runtimes.diagnose* method supported by a *project* resource.
16849/// It is not used directly, but through a [`ProjectMethods`] instance.
16850///
16851/// # Example
16852///
16853/// Instantiate a resource method builder
16854///
16855/// ```test_harness,no_run
16856/// # extern crate hyper;
16857/// # extern crate hyper_rustls;
16858/// # extern crate google_notebooks1 as notebooks1;
16859/// use notebooks1::api::DiagnoseRuntimeRequest;
16860/// # async fn dox() {
16861/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16862///
16863/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16864/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16865/// #     .with_native_roots()
16866/// #     .unwrap()
16867/// #     .https_only()
16868/// #     .enable_http2()
16869/// #     .build();
16870///
16871/// # let executor = hyper_util::rt::TokioExecutor::new();
16872/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16873/// #     secret,
16874/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16875/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16876/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16877/// #     ),
16878/// # ).build().await.unwrap();
16879///
16880/// # let client = hyper_util::client::legacy::Client::builder(
16881/// #     hyper_util::rt::TokioExecutor::new()
16882/// # )
16883/// # .build(
16884/// #     hyper_rustls::HttpsConnectorBuilder::new()
16885/// #         .with_native_roots()
16886/// #         .unwrap()
16887/// #         .https_or_http()
16888/// #         .enable_http2()
16889/// #         .build()
16890/// # );
16891/// # let mut hub = AIPlatformNotebooks::new(client, auth);
16892/// // As the method needs a request, you would usually fill it with the desired information
16893/// // into the respective structure. Some of the parts shown here might not be applicable !
16894/// // Values shown here are possibly random and not representative !
16895/// let mut req = DiagnoseRuntimeRequest::default();
16896///
16897/// // You can configure optional parameters by calling the respective setters at will, and
16898/// // execute the final call using `doit()`.
16899/// // Values shown here are possibly random and not representative !
16900/// let result = hub.projects().locations_runtimes_diagnose(req, "name")
16901///              .doit().await;
16902/// # }
16903/// ```
16904pub struct ProjectLocationRuntimeDiagnoseCall<'a, C>
16905where
16906    C: 'a,
16907{
16908    hub: &'a AIPlatformNotebooks<C>,
16909    _request: DiagnoseRuntimeRequest,
16910    _name: String,
16911    _delegate: Option<&'a mut dyn common::Delegate>,
16912    _additional_params: HashMap<String, String>,
16913    _scopes: BTreeSet<String>,
16914}
16915
16916impl<'a, C> common::CallBuilder for ProjectLocationRuntimeDiagnoseCall<'a, C> {}
16917
16918impl<'a, C> ProjectLocationRuntimeDiagnoseCall<'a, C>
16919where
16920    C: common::Connector,
16921{
16922    /// Perform the operation you have build so far.
16923    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
16924        use std::borrow::Cow;
16925        use std::io::{Read, Seek};
16926
16927        use common::{url::Params, ToParts};
16928        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16929
16930        let mut dd = common::DefaultDelegate;
16931        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16932        dlg.begin(common::MethodInfo {
16933            id: "notebooks.projects.locations.runtimes.diagnose",
16934            http_method: hyper::Method::POST,
16935        });
16936
16937        for &field in ["alt", "name"].iter() {
16938            if self._additional_params.contains_key(field) {
16939                dlg.finished(false);
16940                return Err(common::Error::FieldClash(field));
16941            }
16942        }
16943
16944        let mut params = Params::with_capacity(4 + self._additional_params.len());
16945        params.push("name", self._name);
16946
16947        params.extend(self._additional_params.iter());
16948
16949        params.push("alt", "json");
16950        let mut url = self.hub._base_url.clone() + "v1/{+name}:diagnose";
16951        if self._scopes.is_empty() {
16952            self._scopes
16953                .insert(Scope::CloudPlatform.as_ref().to_string());
16954        }
16955
16956        #[allow(clippy::single_element_loop)]
16957        for &(find_this, param_name) in [("{+name}", "name")].iter() {
16958            url = params.uri_replacement(url, param_name, find_this, true);
16959        }
16960        {
16961            let to_remove = ["name"];
16962            params.remove_params(&to_remove);
16963        }
16964
16965        let url = params.parse_with_url(&url);
16966
16967        let mut json_mime_type = mime::APPLICATION_JSON;
16968        let mut request_value_reader = {
16969            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16970            common::remove_json_null_values(&mut value);
16971            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16972            serde_json::to_writer(&mut dst, &value).unwrap();
16973            dst
16974        };
16975        let request_size = request_value_reader
16976            .seek(std::io::SeekFrom::End(0))
16977            .unwrap();
16978        request_value_reader
16979            .seek(std::io::SeekFrom::Start(0))
16980            .unwrap();
16981
16982        loop {
16983            let token = match self
16984                .hub
16985                .auth
16986                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16987                .await
16988            {
16989                Ok(token) => token,
16990                Err(e) => match dlg.token(e) {
16991                    Ok(token) => token,
16992                    Err(e) => {
16993                        dlg.finished(false);
16994                        return Err(common::Error::MissingToken(e));
16995                    }
16996                },
16997            };
16998            request_value_reader
16999                .seek(std::io::SeekFrom::Start(0))
17000                .unwrap();
17001            let mut req_result = {
17002                let client = &self.hub.client;
17003                dlg.pre_request();
17004                let mut req_builder = hyper::Request::builder()
17005                    .method(hyper::Method::POST)
17006                    .uri(url.as_str())
17007                    .header(USER_AGENT, self.hub._user_agent.clone());
17008
17009                if let Some(token) = token.as_ref() {
17010                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17011                }
17012
17013                let request = req_builder
17014                    .header(CONTENT_TYPE, json_mime_type.to_string())
17015                    .header(CONTENT_LENGTH, request_size as u64)
17016                    .body(common::to_body(
17017                        request_value_reader.get_ref().clone().into(),
17018                    ));
17019
17020                client.request(request.unwrap()).await
17021            };
17022
17023            match req_result {
17024                Err(err) => {
17025                    if let common::Retry::After(d) = dlg.http_error(&err) {
17026                        sleep(d).await;
17027                        continue;
17028                    }
17029                    dlg.finished(false);
17030                    return Err(common::Error::HttpError(err));
17031                }
17032                Ok(res) => {
17033                    let (mut parts, body) = res.into_parts();
17034                    let mut body = common::Body::new(body);
17035                    if !parts.status.is_success() {
17036                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17037                        let error = serde_json::from_str(&common::to_string(&bytes));
17038                        let response = common::to_response(parts, bytes.into());
17039
17040                        if let common::Retry::After(d) =
17041                            dlg.http_failure(&response, error.as_ref().ok())
17042                        {
17043                            sleep(d).await;
17044                            continue;
17045                        }
17046
17047                        dlg.finished(false);
17048
17049                        return Err(match error {
17050                            Ok(value) => common::Error::BadRequest(value),
17051                            _ => common::Error::Failure(response),
17052                        });
17053                    }
17054                    let response = {
17055                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17056                        let encoded = common::to_string(&bytes);
17057                        match serde_json::from_str(&encoded) {
17058                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17059                            Err(error) => {
17060                                dlg.response_json_decode_error(&encoded, &error);
17061                                return Err(common::Error::JsonDecodeError(
17062                                    encoded.to_string(),
17063                                    error,
17064                                ));
17065                            }
17066                        }
17067                    };
17068
17069                    dlg.finished(true);
17070                    return Ok(response);
17071                }
17072            }
17073        }
17074    }
17075
17076    ///
17077    /// Sets the *request* property to the given value.
17078    ///
17079    /// Even though the property as already been set when instantiating this call,
17080    /// we provide this method for API completeness.
17081    pub fn request(
17082        mut self,
17083        new_value: DiagnoseRuntimeRequest,
17084    ) -> ProjectLocationRuntimeDiagnoseCall<'a, C> {
17085        self._request = new_value;
17086        self
17087    }
17088    /// Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtimes_id}`
17089    ///
17090    /// Sets the *name* path property to the given value.
17091    ///
17092    /// Even though the property as already been set when instantiating this call,
17093    /// we provide this method for API completeness.
17094    pub fn name(mut self, new_value: &str) -> ProjectLocationRuntimeDiagnoseCall<'a, C> {
17095        self._name = new_value.to_string();
17096        self
17097    }
17098    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17099    /// while executing the actual API request.
17100    ///
17101    /// ````text
17102    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17103    /// ````
17104    ///
17105    /// Sets the *delegate* property to the given value.
17106    pub fn delegate(
17107        mut self,
17108        new_value: &'a mut dyn common::Delegate,
17109    ) -> ProjectLocationRuntimeDiagnoseCall<'a, C> {
17110        self._delegate = Some(new_value);
17111        self
17112    }
17113
17114    /// Set any additional parameter of the query string used in the request.
17115    /// It should be used to set parameters which are not yet available through their own
17116    /// setters.
17117    ///
17118    /// Please note that this method must not be used to set any of the known parameters
17119    /// which have their own setter method. If done anyway, the request will fail.
17120    ///
17121    /// # Additional Parameters
17122    ///
17123    /// * *$.xgafv* (query-string) - V1 error format.
17124    /// * *access_token* (query-string) - OAuth access token.
17125    /// * *alt* (query-string) - Data format for response.
17126    /// * *callback* (query-string) - JSONP
17127    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17128    /// * *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.
17129    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17130    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17131    /// * *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.
17132    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17133    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17134    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRuntimeDiagnoseCall<'a, C>
17135    where
17136        T: AsRef<str>,
17137    {
17138        self._additional_params
17139            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17140        self
17141    }
17142
17143    /// Identifies the authorization scope for the method you are building.
17144    ///
17145    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17146    /// [`Scope::CloudPlatform`].
17147    ///
17148    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17149    /// tokens for more than one scope.
17150    ///
17151    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17152    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17153    /// sufficient, a read-write scope will do as well.
17154    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRuntimeDiagnoseCall<'a, C>
17155    where
17156        St: AsRef<str>,
17157    {
17158        self._scopes.insert(String::from(scope.as_ref()));
17159        self
17160    }
17161    /// Identifies the authorization scope(s) for the method you are building.
17162    ///
17163    /// See [`Self::add_scope()`] for details.
17164    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRuntimeDiagnoseCall<'a, C>
17165    where
17166        I: IntoIterator<Item = St>,
17167        St: AsRef<str>,
17168    {
17169        self._scopes
17170            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17171        self
17172    }
17173
17174    /// Removes all scopes, and no default scope will be used either.
17175    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17176    /// for details).
17177    pub fn clear_scopes(mut self) -> ProjectLocationRuntimeDiagnoseCall<'a, C> {
17178        self._scopes.clear();
17179        self
17180    }
17181}
17182
17183/// Gets details of a single Runtime. The location must be a regional endpoint rather than zonal.
17184///
17185/// A builder for the *locations.runtimes.get* method supported by a *project* resource.
17186/// It is not used directly, but through a [`ProjectMethods`] instance.
17187///
17188/// # Example
17189///
17190/// Instantiate a resource method builder
17191///
17192/// ```test_harness,no_run
17193/// # extern crate hyper;
17194/// # extern crate hyper_rustls;
17195/// # extern crate google_notebooks1 as notebooks1;
17196/// # async fn dox() {
17197/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17198///
17199/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17200/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17201/// #     .with_native_roots()
17202/// #     .unwrap()
17203/// #     .https_only()
17204/// #     .enable_http2()
17205/// #     .build();
17206///
17207/// # let executor = hyper_util::rt::TokioExecutor::new();
17208/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17209/// #     secret,
17210/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17211/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17212/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17213/// #     ),
17214/// # ).build().await.unwrap();
17215///
17216/// # let client = hyper_util::client::legacy::Client::builder(
17217/// #     hyper_util::rt::TokioExecutor::new()
17218/// # )
17219/// # .build(
17220/// #     hyper_rustls::HttpsConnectorBuilder::new()
17221/// #         .with_native_roots()
17222/// #         .unwrap()
17223/// #         .https_or_http()
17224/// #         .enable_http2()
17225/// #         .build()
17226/// # );
17227/// # let mut hub = AIPlatformNotebooks::new(client, auth);
17228/// // You can configure optional parameters by calling the respective setters at will, and
17229/// // execute the final call using `doit()`.
17230/// // Values shown here are possibly random and not representative !
17231/// let result = hub.projects().locations_runtimes_get("name")
17232///              .doit().await;
17233/// # }
17234/// ```
17235pub struct ProjectLocationRuntimeGetCall<'a, C>
17236where
17237    C: 'a,
17238{
17239    hub: &'a AIPlatformNotebooks<C>,
17240    _name: String,
17241    _delegate: Option<&'a mut dyn common::Delegate>,
17242    _additional_params: HashMap<String, String>,
17243    _scopes: BTreeSet<String>,
17244}
17245
17246impl<'a, C> common::CallBuilder for ProjectLocationRuntimeGetCall<'a, C> {}
17247
17248impl<'a, C> ProjectLocationRuntimeGetCall<'a, C>
17249where
17250    C: common::Connector,
17251{
17252    /// Perform the operation you have build so far.
17253    pub async fn doit(mut self) -> common::Result<(common::Response, Runtime)> {
17254        use std::borrow::Cow;
17255        use std::io::{Read, Seek};
17256
17257        use common::{url::Params, ToParts};
17258        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17259
17260        let mut dd = common::DefaultDelegate;
17261        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17262        dlg.begin(common::MethodInfo {
17263            id: "notebooks.projects.locations.runtimes.get",
17264            http_method: hyper::Method::GET,
17265        });
17266
17267        for &field in ["alt", "name"].iter() {
17268            if self._additional_params.contains_key(field) {
17269                dlg.finished(false);
17270                return Err(common::Error::FieldClash(field));
17271            }
17272        }
17273
17274        let mut params = Params::with_capacity(3 + self._additional_params.len());
17275        params.push("name", self._name);
17276
17277        params.extend(self._additional_params.iter());
17278
17279        params.push("alt", "json");
17280        let mut url = self.hub._base_url.clone() + "v1/{+name}";
17281        if self._scopes.is_empty() {
17282            self._scopes
17283                .insert(Scope::CloudPlatform.as_ref().to_string());
17284        }
17285
17286        #[allow(clippy::single_element_loop)]
17287        for &(find_this, param_name) in [("{+name}", "name")].iter() {
17288            url = params.uri_replacement(url, param_name, find_this, true);
17289        }
17290        {
17291            let to_remove = ["name"];
17292            params.remove_params(&to_remove);
17293        }
17294
17295        let url = params.parse_with_url(&url);
17296
17297        loop {
17298            let token = match self
17299                .hub
17300                .auth
17301                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17302                .await
17303            {
17304                Ok(token) => token,
17305                Err(e) => match dlg.token(e) {
17306                    Ok(token) => token,
17307                    Err(e) => {
17308                        dlg.finished(false);
17309                        return Err(common::Error::MissingToken(e));
17310                    }
17311                },
17312            };
17313            let mut req_result = {
17314                let client = &self.hub.client;
17315                dlg.pre_request();
17316                let mut req_builder = hyper::Request::builder()
17317                    .method(hyper::Method::GET)
17318                    .uri(url.as_str())
17319                    .header(USER_AGENT, self.hub._user_agent.clone());
17320
17321                if let Some(token) = token.as_ref() {
17322                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17323                }
17324
17325                let request = req_builder
17326                    .header(CONTENT_LENGTH, 0_u64)
17327                    .body(common::to_body::<String>(None));
17328
17329                client.request(request.unwrap()).await
17330            };
17331
17332            match req_result {
17333                Err(err) => {
17334                    if let common::Retry::After(d) = dlg.http_error(&err) {
17335                        sleep(d).await;
17336                        continue;
17337                    }
17338                    dlg.finished(false);
17339                    return Err(common::Error::HttpError(err));
17340                }
17341                Ok(res) => {
17342                    let (mut parts, body) = res.into_parts();
17343                    let mut body = common::Body::new(body);
17344                    if !parts.status.is_success() {
17345                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17346                        let error = serde_json::from_str(&common::to_string(&bytes));
17347                        let response = common::to_response(parts, bytes.into());
17348
17349                        if let common::Retry::After(d) =
17350                            dlg.http_failure(&response, error.as_ref().ok())
17351                        {
17352                            sleep(d).await;
17353                            continue;
17354                        }
17355
17356                        dlg.finished(false);
17357
17358                        return Err(match error {
17359                            Ok(value) => common::Error::BadRequest(value),
17360                            _ => common::Error::Failure(response),
17361                        });
17362                    }
17363                    let response = {
17364                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17365                        let encoded = common::to_string(&bytes);
17366                        match serde_json::from_str(&encoded) {
17367                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17368                            Err(error) => {
17369                                dlg.response_json_decode_error(&encoded, &error);
17370                                return Err(common::Error::JsonDecodeError(
17371                                    encoded.to_string(),
17372                                    error,
17373                                ));
17374                            }
17375                        }
17376                    };
17377
17378                    dlg.finished(true);
17379                    return Ok(response);
17380                }
17381            }
17382        }
17383    }
17384
17385    /// Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
17386    ///
17387    /// Sets the *name* path property to the given value.
17388    ///
17389    /// Even though the property as already been set when instantiating this call,
17390    /// we provide this method for API completeness.
17391    pub fn name(mut self, new_value: &str) -> ProjectLocationRuntimeGetCall<'a, C> {
17392        self._name = new_value.to_string();
17393        self
17394    }
17395    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17396    /// while executing the actual API request.
17397    ///
17398    /// ````text
17399    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17400    /// ````
17401    ///
17402    /// Sets the *delegate* property to the given value.
17403    pub fn delegate(
17404        mut self,
17405        new_value: &'a mut dyn common::Delegate,
17406    ) -> ProjectLocationRuntimeGetCall<'a, C> {
17407        self._delegate = Some(new_value);
17408        self
17409    }
17410
17411    /// Set any additional parameter of the query string used in the request.
17412    /// It should be used to set parameters which are not yet available through their own
17413    /// setters.
17414    ///
17415    /// Please note that this method must not be used to set any of the known parameters
17416    /// which have their own setter method. If done anyway, the request will fail.
17417    ///
17418    /// # Additional Parameters
17419    ///
17420    /// * *$.xgafv* (query-string) - V1 error format.
17421    /// * *access_token* (query-string) - OAuth access token.
17422    /// * *alt* (query-string) - Data format for response.
17423    /// * *callback* (query-string) - JSONP
17424    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17425    /// * *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.
17426    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17427    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17428    /// * *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.
17429    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17430    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17431    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRuntimeGetCall<'a, C>
17432    where
17433        T: AsRef<str>,
17434    {
17435        self._additional_params
17436            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17437        self
17438    }
17439
17440    /// Identifies the authorization scope for the method you are building.
17441    ///
17442    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17443    /// [`Scope::CloudPlatform`].
17444    ///
17445    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17446    /// tokens for more than one scope.
17447    ///
17448    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17449    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17450    /// sufficient, a read-write scope will do as well.
17451    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRuntimeGetCall<'a, C>
17452    where
17453        St: AsRef<str>,
17454    {
17455        self._scopes.insert(String::from(scope.as_ref()));
17456        self
17457    }
17458    /// Identifies the authorization scope(s) for the method you are building.
17459    ///
17460    /// See [`Self::add_scope()`] for details.
17461    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRuntimeGetCall<'a, C>
17462    where
17463        I: IntoIterator<Item = St>,
17464        St: AsRef<str>,
17465    {
17466        self._scopes
17467            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17468        self
17469    }
17470
17471    /// Removes all scopes, and no default scope will be used either.
17472    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17473    /// for details).
17474    pub fn clear_scopes(mut self) -> ProjectLocationRuntimeGetCall<'a, C> {
17475        self._scopes.clear();
17476        self
17477    }
17478}
17479
17480/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
17481///
17482/// A builder for the *locations.runtimes.getIamPolicy* method supported by a *project* resource.
17483/// It is not used directly, but through a [`ProjectMethods`] instance.
17484///
17485/// # Example
17486///
17487/// Instantiate a resource method builder
17488///
17489/// ```test_harness,no_run
17490/// # extern crate hyper;
17491/// # extern crate hyper_rustls;
17492/// # extern crate google_notebooks1 as notebooks1;
17493/// # async fn dox() {
17494/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17495///
17496/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17497/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17498/// #     .with_native_roots()
17499/// #     .unwrap()
17500/// #     .https_only()
17501/// #     .enable_http2()
17502/// #     .build();
17503///
17504/// # let executor = hyper_util::rt::TokioExecutor::new();
17505/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17506/// #     secret,
17507/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17508/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17509/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17510/// #     ),
17511/// # ).build().await.unwrap();
17512///
17513/// # let client = hyper_util::client::legacy::Client::builder(
17514/// #     hyper_util::rt::TokioExecutor::new()
17515/// # )
17516/// # .build(
17517/// #     hyper_rustls::HttpsConnectorBuilder::new()
17518/// #         .with_native_roots()
17519/// #         .unwrap()
17520/// #         .https_or_http()
17521/// #         .enable_http2()
17522/// #         .build()
17523/// # );
17524/// # let mut hub = AIPlatformNotebooks::new(client, auth);
17525/// // You can configure optional parameters by calling the respective setters at will, and
17526/// // execute the final call using `doit()`.
17527/// // Values shown here are possibly random and not representative !
17528/// let result = hub.projects().locations_runtimes_get_iam_policy("resource")
17529///              .options_requested_policy_version(-23)
17530///              .doit().await;
17531/// # }
17532/// ```
17533pub struct ProjectLocationRuntimeGetIamPolicyCall<'a, C>
17534where
17535    C: 'a,
17536{
17537    hub: &'a AIPlatformNotebooks<C>,
17538    _resource: String,
17539    _options_requested_policy_version: Option<i32>,
17540    _delegate: Option<&'a mut dyn common::Delegate>,
17541    _additional_params: HashMap<String, String>,
17542    _scopes: BTreeSet<String>,
17543}
17544
17545impl<'a, C> common::CallBuilder for ProjectLocationRuntimeGetIamPolicyCall<'a, C> {}
17546
17547impl<'a, C> ProjectLocationRuntimeGetIamPolicyCall<'a, C>
17548where
17549    C: common::Connector,
17550{
17551    /// Perform the operation you have build so far.
17552    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
17553        use std::borrow::Cow;
17554        use std::io::{Read, Seek};
17555
17556        use common::{url::Params, ToParts};
17557        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17558
17559        let mut dd = common::DefaultDelegate;
17560        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17561        dlg.begin(common::MethodInfo {
17562            id: "notebooks.projects.locations.runtimes.getIamPolicy",
17563            http_method: hyper::Method::GET,
17564        });
17565
17566        for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
17567            if self._additional_params.contains_key(field) {
17568                dlg.finished(false);
17569                return Err(common::Error::FieldClash(field));
17570            }
17571        }
17572
17573        let mut params = Params::with_capacity(4 + self._additional_params.len());
17574        params.push("resource", self._resource);
17575        if let Some(value) = self._options_requested_policy_version.as_ref() {
17576            params.push("options.requestedPolicyVersion", value.to_string());
17577        }
17578
17579        params.extend(self._additional_params.iter());
17580
17581        params.push("alt", "json");
17582        let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
17583        if self._scopes.is_empty() {
17584            self._scopes
17585                .insert(Scope::CloudPlatform.as_ref().to_string());
17586        }
17587
17588        #[allow(clippy::single_element_loop)]
17589        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
17590            url = params.uri_replacement(url, param_name, find_this, true);
17591        }
17592        {
17593            let to_remove = ["resource"];
17594            params.remove_params(&to_remove);
17595        }
17596
17597        let url = params.parse_with_url(&url);
17598
17599        loop {
17600            let token = match self
17601                .hub
17602                .auth
17603                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17604                .await
17605            {
17606                Ok(token) => token,
17607                Err(e) => match dlg.token(e) {
17608                    Ok(token) => token,
17609                    Err(e) => {
17610                        dlg.finished(false);
17611                        return Err(common::Error::MissingToken(e));
17612                    }
17613                },
17614            };
17615            let mut req_result = {
17616                let client = &self.hub.client;
17617                dlg.pre_request();
17618                let mut req_builder = hyper::Request::builder()
17619                    .method(hyper::Method::GET)
17620                    .uri(url.as_str())
17621                    .header(USER_AGENT, self.hub._user_agent.clone());
17622
17623                if let Some(token) = token.as_ref() {
17624                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17625                }
17626
17627                let request = req_builder
17628                    .header(CONTENT_LENGTH, 0_u64)
17629                    .body(common::to_body::<String>(None));
17630
17631                client.request(request.unwrap()).await
17632            };
17633
17634            match req_result {
17635                Err(err) => {
17636                    if let common::Retry::After(d) = dlg.http_error(&err) {
17637                        sleep(d).await;
17638                        continue;
17639                    }
17640                    dlg.finished(false);
17641                    return Err(common::Error::HttpError(err));
17642                }
17643                Ok(res) => {
17644                    let (mut parts, body) = res.into_parts();
17645                    let mut body = common::Body::new(body);
17646                    if !parts.status.is_success() {
17647                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17648                        let error = serde_json::from_str(&common::to_string(&bytes));
17649                        let response = common::to_response(parts, bytes.into());
17650
17651                        if let common::Retry::After(d) =
17652                            dlg.http_failure(&response, error.as_ref().ok())
17653                        {
17654                            sleep(d).await;
17655                            continue;
17656                        }
17657
17658                        dlg.finished(false);
17659
17660                        return Err(match error {
17661                            Ok(value) => common::Error::BadRequest(value),
17662                            _ => common::Error::Failure(response),
17663                        });
17664                    }
17665                    let response = {
17666                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17667                        let encoded = common::to_string(&bytes);
17668                        match serde_json::from_str(&encoded) {
17669                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17670                            Err(error) => {
17671                                dlg.response_json_decode_error(&encoded, &error);
17672                                return Err(common::Error::JsonDecodeError(
17673                                    encoded.to_string(),
17674                                    error,
17675                                ));
17676                            }
17677                        }
17678                    };
17679
17680                    dlg.finished(true);
17681                    return Ok(response);
17682                }
17683            }
17684        }
17685    }
17686
17687    /// 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.
17688    ///
17689    /// Sets the *resource* path property to the given value.
17690    ///
17691    /// Even though the property as already been set when instantiating this call,
17692    /// we provide this method for API completeness.
17693    pub fn resource(mut self, new_value: &str) -> ProjectLocationRuntimeGetIamPolicyCall<'a, C> {
17694        self._resource = new_value.to_string();
17695        self
17696    }
17697    /// 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).
17698    ///
17699    /// Sets the *options.requested policy version* query property to the given value.
17700    pub fn options_requested_policy_version(
17701        mut self,
17702        new_value: i32,
17703    ) -> ProjectLocationRuntimeGetIamPolicyCall<'a, C> {
17704        self._options_requested_policy_version = Some(new_value);
17705        self
17706    }
17707    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17708    /// while executing the actual API request.
17709    ///
17710    /// ````text
17711    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17712    /// ````
17713    ///
17714    /// Sets the *delegate* property to the given value.
17715    pub fn delegate(
17716        mut self,
17717        new_value: &'a mut dyn common::Delegate,
17718    ) -> ProjectLocationRuntimeGetIamPolicyCall<'a, C> {
17719        self._delegate = Some(new_value);
17720        self
17721    }
17722
17723    /// Set any additional parameter of the query string used in the request.
17724    /// It should be used to set parameters which are not yet available through their own
17725    /// setters.
17726    ///
17727    /// Please note that this method must not be used to set any of the known parameters
17728    /// which have their own setter method. If done anyway, the request will fail.
17729    ///
17730    /// # Additional Parameters
17731    ///
17732    /// * *$.xgafv* (query-string) - V1 error format.
17733    /// * *access_token* (query-string) - OAuth access token.
17734    /// * *alt* (query-string) - Data format for response.
17735    /// * *callback* (query-string) - JSONP
17736    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17737    /// * *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.
17738    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17739    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17740    /// * *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.
17741    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17742    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17743    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRuntimeGetIamPolicyCall<'a, C>
17744    where
17745        T: AsRef<str>,
17746    {
17747        self._additional_params
17748            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17749        self
17750    }
17751
17752    /// Identifies the authorization scope for the method you are building.
17753    ///
17754    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17755    /// [`Scope::CloudPlatform`].
17756    ///
17757    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17758    /// tokens for more than one scope.
17759    ///
17760    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17761    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17762    /// sufficient, a read-write scope will do as well.
17763    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRuntimeGetIamPolicyCall<'a, C>
17764    where
17765        St: AsRef<str>,
17766    {
17767        self._scopes.insert(String::from(scope.as_ref()));
17768        self
17769    }
17770    /// Identifies the authorization scope(s) for the method you are building.
17771    ///
17772    /// See [`Self::add_scope()`] for details.
17773    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRuntimeGetIamPolicyCall<'a, C>
17774    where
17775        I: IntoIterator<Item = St>,
17776        St: AsRef<str>,
17777    {
17778        self._scopes
17779            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17780        self
17781    }
17782
17783    /// Removes all scopes, and no default scope will be used either.
17784    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17785    /// for details).
17786    pub fn clear_scopes(mut self) -> ProjectLocationRuntimeGetIamPolicyCall<'a, C> {
17787        self._scopes.clear();
17788        self
17789    }
17790}
17791
17792/// Lists Runtimes in a given project and location.
17793///
17794/// A builder for the *locations.runtimes.list* method supported by a *project* resource.
17795/// It is not used directly, but through a [`ProjectMethods`] instance.
17796///
17797/// # Example
17798///
17799/// Instantiate a resource method builder
17800///
17801/// ```test_harness,no_run
17802/// # extern crate hyper;
17803/// # extern crate hyper_rustls;
17804/// # extern crate google_notebooks1 as notebooks1;
17805/// # async fn dox() {
17806/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17807///
17808/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17809/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17810/// #     .with_native_roots()
17811/// #     .unwrap()
17812/// #     .https_only()
17813/// #     .enable_http2()
17814/// #     .build();
17815///
17816/// # let executor = hyper_util::rt::TokioExecutor::new();
17817/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17818/// #     secret,
17819/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17820/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17821/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17822/// #     ),
17823/// # ).build().await.unwrap();
17824///
17825/// # let client = hyper_util::client::legacy::Client::builder(
17826/// #     hyper_util::rt::TokioExecutor::new()
17827/// # )
17828/// # .build(
17829/// #     hyper_rustls::HttpsConnectorBuilder::new()
17830/// #         .with_native_roots()
17831/// #         .unwrap()
17832/// #         .https_or_http()
17833/// #         .enable_http2()
17834/// #         .build()
17835/// # );
17836/// # let mut hub = AIPlatformNotebooks::new(client, auth);
17837/// // You can configure optional parameters by calling the respective setters at will, and
17838/// // execute the final call using `doit()`.
17839/// // Values shown here are possibly random and not representative !
17840/// let result = hub.projects().locations_runtimes_list("parent")
17841///              .page_token("consetetur")
17842///              .page_size(-28)
17843///              .order_by("et")
17844///              .filter("erat")
17845///              .doit().await;
17846/// # }
17847/// ```
17848pub struct ProjectLocationRuntimeListCall<'a, C>
17849where
17850    C: 'a,
17851{
17852    hub: &'a AIPlatformNotebooks<C>,
17853    _parent: String,
17854    _page_token: Option<String>,
17855    _page_size: Option<i32>,
17856    _order_by: Option<String>,
17857    _filter: Option<String>,
17858    _delegate: Option<&'a mut dyn common::Delegate>,
17859    _additional_params: HashMap<String, String>,
17860    _scopes: BTreeSet<String>,
17861}
17862
17863impl<'a, C> common::CallBuilder for ProjectLocationRuntimeListCall<'a, C> {}
17864
17865impl<'a, C> ProjectLocationRuntimeListCall<'a, C>
17866where
17867    C: common::Connector,
17868{
17869    /// Perform the operation you have build so far.
17870    pub async fn doit(mut self) -> common::Result<(common::Response, ListRuntimesResponse)> {
17871        use std::borrow::Cow;
17872        use std::io::{Read, Seek};
17873
17874        use common::{url::Params, ToParts};
17875        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17876
17877        let mut dd = common::DefaultDelegate;
17878        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17879        dlg.begin(common::MethodInfo {
17880            id: "notebooks.projects.locations.runtimes.list",
17881            http_method: hyper::Method::GET,
17882        });
17883
17884        for &field in [
17885            "alt",
17886            "parent",
17887            "pageToken",
17888            "pageSize",
17889            "orderBy",
17890            "filter",
17891        ]
17892        .iter()
17893        {
17894            if self._additional_params.contains_key(field) {
17895                dlg.finished(false);
17896                return Err(common::Error::FieldClash(field));
17897            }
17898        }
17899
17900        let mut params = Params::with_capacity(7 + self._additional_params.len());
17901        params.push("parent", self._parent);
17902        if let Some(value) = self._page_token.as_ref() {
17903            params.push("pageToken", value);
17904        }
17905        if let Some(value) = self._page_size.as_ref() {
17906            params.push("pageSize", value.to_string());
17907        }
17908        if let Some(value) = self._order_by.as_ref() {
17909            params.push("orderBy", value);
17910        }
17911        if let Some(value) = self._filter.as_ref() {
17912            params.push("filter", value);
17913        }
17914
17915        params.extend(self._additional_params.iter());
17916
17917        params.push("alt", "json");
17918        let mut url = self.hub._base_url.clone() + "v1/{+parent}/runtimes";
17919        if self._scopes.is_empty() {
17920            self._scopes
17921                .insert(Scope::CloudPlatform.as_ref().to_string());
17922        }
17923
17924        #[allow(clippy::single_element_loop)]
17925        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
17926            url = params.uri_replacement(url, param_name, find_this, true);
17927        }
17928        {
17929            let to_remove = ["parent"];
17930            params.remove_params(&to_remove);
17931        }
17932
17933        let url = params.parse_with_url(&url);
17934
17935        loop {
17936            let token = match self
17937                .hub
17938                .auth
17939                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17940                .await
17941            {
17942                Ok(token) => token,
17943                Err(e) => match dlg.token(e) {
17944                    Ok(token) => token,
17945                    Err(e) => {
17946                        dlg.finished(false);
17947                        return Err(common::Error::MissingToken(e));
17948                    }
17949                },
17950            };
17951            let mut req_result = {
17952                let client = &self.hub.client;
17953                dlg.pre_request();
17954                let mut req_builder = hyper::Request::builder()
17955                    .method(hyper::Method::GET)
17956                    .uri(url.as_str())
17957                    .header(USER_AGENT, self.hub._user_agent.clone());
17958
17959                if let Some(token) = token.as_ref() {
17960                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17961                }
17962
17963                let request = req_builder
17964                    .header(CONTENT_LENGTH, 0_u64)
17965                    .body(common::to_body::<String>(None));
17966
17967                client.request(request.unwrap()).await
17968            };
17969
17970            match req_result {
17971                Err(err) => {
17972                    if let common::Retry::After(d) = dlg.http_error(&err) {
17973                        sleep(d).await;
17974                        continue;
17975                    }
17976                    dlg.finished(false);
17977                    return Err(common::Error::HttpError(err));
17978                }
17979                Ok(res) => {
17980                    let (mut parts, body) = res.into_parts();
17981                    let mut body = common::Body::new(body);
17982                    if !parts.status.is_success() {
17983                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17984                        let error = serde_json::from_str(&common::to_string(&bytes));
17985                        let response = common::to_response(parts, bytes.into());
17986
17987                        if let common::Retry::After(d) =
17988                            dlg.http_failure(&response, error.as_ref().ok())
17989                        {
17990                            sleep(d).await;
17991                            continue;
17992                        }
17993
17994                        dlg.finished(false);
17995
17996                        return Err(match error {
17997                            Ok(value) => common::Error::BadRequest(value),
17998                            _ => common::Error::Failure(response),
17999                        });
18000                    }
18001                    let response = {
18002                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18003                        let encoded = common::to_string(&bytes);
18004                        match serde_json::from_str(&encoded) {
18005                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18006                            Err(error) => {
18007                                dlg.response_json_decode_error(&encoded, &error);
18008                                return Err(common::Error::JsonDecodeError(
18009                                    encoded.to_string(),
18010                                    error,
18011                                ));
18012                            }
18013                        }
18014                    };
18015
18016                    dlg.finished(true);
18017                    return Ok(response);
18018                }
18019            }
18020        }
18021    }
18022
18023    /// Required. Format: `parent=projects/{project_id}/locations/{location}`
18024    ///
18025    /// Sets the *parent* path property to the given value.
18026    ///
18027    /// Even though the property as already been set when instantiating this call,
18028    /// we provide this method for API completeness.
18029    pub fn parent(mut self, new_value: &str) -> ProjectLocationRuntimeListCall<'a, C> {
18030        self._parent = new_value.to_string();
18031        self
18032    }
18033    /// A previous returned page token that can be used to continue listing from the last result.
18034    ///
18035    /// Sets the *page token* query property to the given value.
18036    pub fn page_token(mut self, new_value: &str) -> ProjectLocationRuntimeListCall<'a, C> {
18037        self._page_token = Some(new_value.to_string());
18038        self
18039    }
18040    /// Maximum return size of the list call.
18041    ///
18042    /// Sets the *page size* query property to the given value.
18043    pub fn page_size(mut self, new_value: i32) -> ProjectLocationRuntimeListCall<'a, C> {
18044        self._page_size = Some(new_value);
18045        self
18046    }
18047    /// Optional. Sort results. Supported values are "name", "name desc" or "" (unsorted).
18048    ///
18049    /// Sets the *order by* query property to the given value.
18050    pub fn order_by(mut self, new_value: &str) -> ProjectLocationRuntimeListCall<'a, C> {
18051        self._order_by = Some(new_value.to_string());
18052        self
18053    }
18054    /// Optional. List filter.
18055    ///
18056    /// Sets the *filter* query property to the given value.
18057    pub fn filter(mut self, new_value: &str) -> ProjectLocationRuntimeListCall<'a, C> {
18058        self._filter = Some(new_value.to_string());
18059        self
18060    }
18061    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18062    /// while executing the actual API request.
18063    ///
18064    /// ````text
18065    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18066    /// ````
18067    ///
18068    /// Sets the *delegate* property to the given value.
18069    pub fn delegate(
18070        mut self,
18071        new_value: &'a mut dyn common::Delegate,
18072    ) -> ProjectLocationRuntimeListCall<'a, C> {
18073        self._delegate = Some(new_value);
18074        self
18075    }
18076
18077    /// Set any additional parameter of the query string used in the request.
18078    /// It should be used to set parameters which are not yet available through their own
18079    /// setters.
18080    ///
18081    /// Please note that this method must not be used to set any of the known parameters
18082    /// which have their own setter method. If done anyway, the request will fail.
18083    ///
18084    /// # Additional Parameters
18085    ///
18086    /// * *$.xgafv* (query-string) - V1 error format.
18087    /// * *access_token* (query-string) - OAuth access token.
18088    /// * *alt* (query-string) - Data format for response.
18089    /// * *callback* (query-string) - JSONP
18090    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18091    /// * *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.
18092    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18093    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18094    /// * *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.
18095    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18096    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18097    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRuntimeListCall<'a, C>
18098    where
18099        T: AsRef<str>,
18100    {
18101        self._additional_params
18102            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18103        self
18104    }
18105
18106    /// Identifies the authorization scope for the method you are building.
18107    ///
18108    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18109    /// [`Scope::CloudPlatform`].
18110    ///
18111    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18112    /// tokens for more than one scope.
18113    ///
18114    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18115    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18116    /// sufficient, a read-write scope will do as well.
18117    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRuntimeListCall<'a, C>
18118    where
18119        St: AsRef<str>,
18120    {
18121        self._scopes.insert(String::from(scope.as_ref()));
18122        self
18123    }
18124    /// Identifies the authorization scope(s) for the method you are building.
18125    ///
18126    /// See [`Self::add_scope()`] for details.
18127    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRuntimeListCall<'a, C>
18128    where
18129        I: IntoIterator<Item = St>,
18130        St: AsRef<str>,
18131    {
18132        self._scopes
18133            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18134        self
18135    }
18136
18137    /// Removes all scopes, and no default scope will be used either.
18138    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18139    /// for details).
18140    pub fn clear_scopes(mut self) -> ProjectLocationRuntimeListCall<'a, C> {
18141        self._scopes.clear();
18142        self
18143    }
18144}
18145
18146/// Migrate an existing Runtime to a new Workbench Instance.
18147///
18148/// A builder for the *locations.runtimes.migrate* method supported by a *project* resource.
18149/// It is not used directly, but through a [`ProjectMethods`] instance.
18150///
18151/// # Example
18152///
18153/// Instantiate a resource method builder
18154///
18155/// ```test_harness,no_run
18156/// # extern crate hyper;
18157/// # extern crate hyper_rustls;
18158/// # extern crate google_notebooks1 as notebooks1;
18159/// use notebooks1::api::MigrateRuntimeRequest;
18160/// # async fn dox() {
18161/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18162///
18163/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18164/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18165/// #     .with_native_roots()
18166/// #     .unwrap()
18167/// #     .https_only()
18168/// #     .enable_http2()
18169/// #     .build();
18170///
18171/// # let executor = hyper_util::rt::TokioExecutor::new();
18172/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18173/// #     secret,
18174/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18175/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
18176/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
18177/// #     ),
18178/// # ).build().await.unwrap();
18179///
18180/// # let client = hyper_util::client::legacy::Client::builder(
18181/// #     hyper_util::rt::TokioExecutor::new()
18182/// # )
18183/// # .build(
18184/// #     hyper_rustls::HttpsConnectorBuilder::new()
18185/// #         .with_native_roots()
18186/// #         .unwrap()
18187/// #         .https_or_http()
18188/// #         .enable_http2()
18189/// #         .build()
18190/// # );
18191/// # let mut hub = AIPlatformNotebooks::new(client, auth);
18192/// // As the method needs a request, you would usually fill it with the desired information
18193/// // into the respective structure. Some of the parts shown here might not be applicable !
18194/// // Values shown here are possibly random and not representative !
18195/// let mut req = MigrateRuntimeRequest::default();
18196///
18197/// // You can configure optional parameters by calling the respective setters at will, and
18198/// // execute the final call using `doit()`.
18199/// // Values shown here are possibly random and not representative !
18200/// let result = hub.projects().locations_runtimes_migrate(req, "name")
18201///              .doit().await;
18202/// # }
18203/// ```
18204pub struct ProjectLocationRuntimeMigrateCall<'a, C>
18205where
18206    C: 'a,
18207{
18208    hub: &'a AIPlatformNotebooks<C>,
18209    _request: MigrateRuntimeRequest,
18210    _name: String,
18211    _delegate: Option<&'a mut dyn common::Delegate>,
18212    _additional_params: HashMap<String, String>,
18213    _scopes: BTreeSet<String>,
18214}
18215
18216impl<'a, C> common::CallBuilder for ProjectLocationRuntimeMigrateCall<'a, C> {}
18217
18218impl<'a, C> ProjectLocationRuntimeMigrateCall<'a, C>
18219where
18220    C: common::Connector,
18221{
18222    /// Perform the operation you have build so far.
18223    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
18224        use std::borrow::Cow;
18225        use std::io::{Read, Seek};
18226
18227        use common::{url::Params, ToParts};
18228        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18229
18230        let mut dd = common::DefaultDelegate;
18231        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18232        dlg.begin(common::MethodInfo {
18233            id: "notebooks.projects.locations.runtimes.migrate",
18234            http_method: hyper::Method::POST,
18235        });
18236
18237        for &field in ["alt", "name"].iter() {
18238            if self._additional_params.contains_key(field) {
18239                dlg.finished(false);
18240                return Err(common::Error::FieldClash(field));
18241            }
18242        }
18243
18244        let mut params = Params::with_capacity(4 + self._additional_params.len());
18245        params.push("name", self._name);
18246
18247        params.extend(self._additional_params.iter());
18248
18249        params.push("alt", "json");
18250        let mut url = self.hub._base_url.clone() + "v1/{+name}:migrate";
18251        if self._scopes.is_empty() {
18252            self._scopes
18253                .insert(Scope::CloudPlatform.as_ref().to_string());
18254        }
18255
18256        #[allow(clippy::single_element_loop)]
18257        for &(find_this, param_name) in [("{+name}", "name")].iter() {
18258            url = params.uri_replacement(url, param_name, find_this, true);
18259        }
18260        {
18261            let to_remove = ["name"];
18262            params.remove_params(&to_remove);
18263        }
18264
18265        let url = params.parse_with_url(&url);
18266
18267        let mut json_mime_type = mime::APPLICATION_JSON;
18268        let mut request_value_reader = {
18269            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18270            common::remove_json_null_values(&mut value);
18271            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18272            serde_json::to_writer(&mut dst, &value).unwrap();
18273            dst
18274        };
18275        let request_size = request_value_reader
18276            .seek(std::io::SeekFrom::End(0))
18277            .unwrap();
18278        request_value_reader
18279            .seek(std::io::SeekFrom::Start(0))
18280            .unwrap();
18281
18282        loop {
18283            let token = match self
18284                .hub
18285                .auth
18286                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18287                .await
18288            {
18289                Ok(token) => token,
18290                Err(e) => match dlg.token(e) {
18291                    Ok(token) => token,
18292                    Err(e) => {
18293                        dlg.finished(false);
18294                        return Err(common::Error::MissingToken(e));
18295                    }
18296                },
18297            };
18298            request_value_reader
18299                .seek(std::io::SeekFrom::Start(0))
18300                .unwrap();
18301            let mut req_result = {
18302                let client = &self.hub.client;
18303                dlg.pre_request();
18304                let mut req_builder = hyper::Request::builder()
18305                    .method(hyper::Method::POST)
18306                    .uri(url.as_str())
18307                    .header(USER_AGENT, self.hub._user_agent.clone());
18308
18309                if let Some(token) = token.as_ref() {
18310                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18311                }
18312
18313                let request = req_builder
18314                    .header(CONTENT_TYPE, json_mime_type.to_string())
18315                    .header(CONTENT_LENGTH, request_size as u64)
18316                    .body(common::to_body(
18317                        request_value_reader.get_ref().clone().into(),
18318                    ));
18319
18320                client.request(request.unwrap()).await
18321            };
18322
18323            match req_result {
18324                Err(err) => {
18325                    if let common::Retry::After(d) = dlg.http_error(&err) {
18326                        sleep(d).await;
18327                        continue;
18328                    }
18329                    dlg.finished(false);
18330                    return Err(common::Error::HttpError(err));
18331                }
18332                Ok(res) => {
18333                    let (mut parts, body) = res.into_parts();
18334                    let mut body = common::Body::new(body);
18335                    if !parts.status.is_success() {
18336                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18337                        let error = serde_json::from_str(&common::to_string(&bytes));
18338                        let response = common::to_response(parts, bytes.into());
18339
18340                        if let common::Retry::After(d) =
18341                            dlg.http_failure(&response, error.as_ref().ok())
18342                        {
18343                            sleep(d).await;
18344                            continue;
18345                        }
18346
18347                        dlg.finished(false);
18348
18349                        return Err(match error {
18350                            Ok(value) => common::Error::BadRequest(value),
18351                            _ => common::Error::Failure(response),
18352                        });
18353                    }
18354                    let response = {
18355                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18356                        let encoded = common::to_string(&bytes);
18357                        match serde_json::from_str(&encoded) {
18358                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18359                            Err(error) => {
18360                                dlg.response_json_decode_error(&encoded, &error);
18361                                return Err(common::Error::JsonDecodeError(
18362                                    encoded.to_string(),
18363                                    error,
18364                                ));
18365                            }
18366                        }
18367                    };
18368
18369                    dlg.finished(true);
18370                    return Ok(response);
18371                }
18372            }
18373        }
18374    }
18375
18376    ///
18377    /// Sets the *request* property to the given value.
18378    ///
18379    /// Even though the property as already been set when instantiating this call,
18380    /// we provide this method for API completeness.
18381    pub fn request(
18382        mut self,
18383        new_value: MigrateRuntimeRequest,
18384    ) -> ProjectLocationRuntimeMigrateCall<'a, C> {
18385        self._request = new_value;
18386        self
18387    }
18388    /// Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
18389    ///
18390    /// Sets the *name* path property to the given value.
18391    ///
18392    /// Even though the property as already been set when instantiating this call,
18393    /// we provide this method for API completeness.
18394    pub fn name(mut self, new_value: &str) -> ProjectLocationRuntimeMigrateCall<'a, C> {
18395        self._name = new_value.to_string();
18396        self
18397    }
18398    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18399    /// while executing the actual API request.
18400    ///
18401    /// ````text
18402    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18403    /// ````
18404    ///
18405    /// Sets the *delegate* property to the given value.
18406    pub fn delegate(
18407        mut self,
18408        new_value: &'a mut dyn common::Delegate,
18409    ) -> ProjectLocationRuntimeMigrateCall<'a, C> {
18410        self._delegate = Some(new_value);
18411        self
18412    }
18413
18414    /// Set any additional parameter of the query string used in the request.
18415    /// It should be used to set parameters which are not yet available through their own
18416    /// setters.
18417    ///
18418    /// Please note that this method must not be used to set any of the known parameters
18419    /// which have their own setter method. If done anyway, the request will fail.
18420    ///
18421    /// # Additional Parameters
18422    ///
18423    /// * *$.xgafv* (query-string) - V1 error format.
18424    /// * *access_token* (query-string) - OAuth access token.
18425    /// * *alt* (query-string) - Data format for response.
18426    /// * *callback* (query-string) - JSONP
18427    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18428    /// * *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.
18429    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18430    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18431    /// * *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.
18432    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18433    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18434    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRuntimeMigrateCall<'a, C>
18435    where
18436        T: AsRef<str>,
18437    {
18438        self._additional_params
18439            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18440        self
18441    }
18442
18443    /// Identifies the authorization scope for the method you are building.
18444    ///
18445    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18446    /// [`Scope::CloudPlatform`].
18447    ///
18448    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18449    /// tokens for more than one scope.
18450    ///
18451    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18452    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18453    /// sufficient, a read-write scope will do as well.
18454    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRuntimeMigrateCall<'a, C>
18455    where
18456        St: AsRef<str>,
18457    {
18458        self._scopes.insert(String::from(scope.as_ref()));
18459        self
18460    }
18461    /// Identifies the authorization scope(s) for the method you are building.
18462    ///
18463    /// See [`Self::add_scope()`] for details.
18464    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRuntimeMigrateCall<'a, C>
18465    where
18466        I: IntoIterator<Item = St>,
18467        St: AsRef<str>,
18468    {
18469        self._scopes
18470            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18471        self
18472    }
18473
18474    /// Removes all scopes, and no default scope will be used either.
18475    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18476    /// for details).
18477    pub fn clear_scopes(mut self) -> ProjectLocationRuntimeMigrateCall<'a, C> {
18478        self._scopes.clear();
18479        self
18480    }
18481}
18482
18483/// Update Notebook Runtime configuration.
18484///
18485/// A builder for the *locations.runtimes.patch* method supported by a *project* resource.
18486/// It is not used directly, but through a [`ProjectMethods`] instance.
18487///
18488/// # Example
18489///
18490/// Instantiate a resource method builder
18491///
18492/// ```test_harness,no_run
18493/// # extern crate hyper;
18494/// # extern crate hyper_rustls;
18495/// # extern crate google_notebooks1 as notebooks1;
18496/// use notebooks1::api::Runtime;
18497/// # async fn dox() {
18498/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18499///
18500/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18501/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18502/// #     .with_native_roots()
18503/// #     .unwrap()
18504/// #     .https_only()
18505/// #     .enable_http2()
18506/// #     .build();
18507///
18508/// # let executor = hyper_util::rt::TokioExecutor::new();
18509/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18510/// #     secret,
18511/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18512/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
18513/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
18514/// #     ),
18515/// # ).build().await.unwrap();
18516///
18517/// # let client = hyper_util::client::legacy::Client::builder(
18518/// #     hyper_util::rt::TokioExecutor::new()
18519/// # )
18520/// # .build(
18521/// #     hyper_rustls::HttpsConnectorBuilder::new()
18522/// #         .with_native_roots()
18523/// #         .unwrap()
18524/// #         .https_or_http()
18525/// #         .enable_http2()
18526/// #         .build()
18527/// # );
18528/// # let mut hub = AIPlatformNotebooks::new(client, auth);
18529/// // As the method needs a request, you would usually fill it with the desired information
18530/// // into the respective structure. Some of the parts shown here might not be applicable !
18531/// // Values shown here are possibly random and not representative !
18532/// let mut req = Runtime::default();
18533///
18534/// // You can configure optional parameters by calling the respective setters at will, and
18535/// // execute the final call using `doit()`.
18536/// // Values shown here are possibly random and not representative !
18537/// let result = hub.projects().locations_runtimes_patch(req, "name")
18538///              .update_mask(FieldMask::new::<&str>(&[]))
18539///              .request_id("sed")
18540///              .doit().await;
18541/// # }
18542/// ```
18543pub struct ProjectLocationRuntimePatchCall<'a, C>
18544where
18545    C: 'a,
18546{
18547    hub: &'a AIPlatformNotebooks<C>,
18548    _request: Runtime,
18549    _name: String,
18550    _update_mask: Option<common::FieldMask>,
18551    _request_id: Option<String>,
18552    _delegate: Option<&'a mut dyn common::Delegate>,
18553    _additional_params: HashMap<String, String>,
18554    _scopes: BTreeSet<String>,
18555}
18556
18557impl<'a, C> common::CallBuilder for ProjectLocationRuntimePatchCall<'a, C> {}
18558
18559impl<'a, C> ProjectLocationRuntimePatchCall<'a, C>
18560where
18561    C: common::Connector,
18562{
18563    /// Perform the operation you have build so far.
18564    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
18565        use std::borrow::Cow;
18566        use std::io::{Read, Seek};
18567
18568        use common::{url::Params, ToParts};
18569        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18570
18571        let mut dd = common::DefaultDelegate;
18572        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18573        dlg.begin(common::MethodInfo {
18574            id: "notebooks.projects.locations.runtimes.patch",
18575            http_method: hyper::Method::PATCH,
18576        });
18577
18578        for &field in ["alt", "name", "updateMask", "requestId"].iter() {
18579            if self._additional_params.contains_key(field) {
18580                dlg.finished(false);
18581                return Err(common::Error::FieldClash(field));
18582            }
18583        }
18584
18585        let mut params = Params::with_capacity(6 + self._additional_params.len());
18586        params.push("name", self._name);
18587        if let Some(value) = self._update_mask.as_ref() {
18588            params.push("updateMask", value.to_string());
18589        }
18590        if let Some(value) = self._request_id.as_ref() {
18591            params.push("requestId", value);
18592        }
18593
18594        params.extend(self._additional_params.iter());
18595
18596        params.push("alt", "json");
18597        let mut url = self.hub._base_url.clone() + "v1/{+name}";
18598        if self._scopes.is_empty() {
18599            self._scopes
18600                .insert(Scope::CloudPlatform.as_ref().to_string());
18601        }
18602
18603        #[allow(clippy::single_element_loop)]
18604        for &(find_this, param_name) in [("{+name}", "name")].iter() {
18605            url = params.uri_replacement(url, param_name, find_this, true);
18606        }
18607        {
18608            let to_remove = ["name"];
18609            params.remove_params(&to_remove);
18610        }
18611
18612        let url = params.parse_with_url(&url);
18613
18614        let mut json_mime_type = mime::APPLICATION_JSON;
18615        let mut request_value_reader = {
18616            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18617            common::remove_json_null_values(&mut value);
18618            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18619            serde_json::to_writer(&mut dst, &value).unwrap();
18620            dst
18621        };
18622        let request_size = request_value_reader
18623            .seek(std::io::SeekFrom::End(0))
18624            .unwrap();
18625        request_value_reader
18626            .seek(std::io::SeekFrom::Start(0))
18627            .unwrap();
18628
18629        loop {
18630            let token = match self
18631                .hub
18632                .auth
18633                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18634                .await
18635            {
18636                Ok(token) => token,
18637                Err(e) => match dlg.token(e) {
18638                    Ok(token) => token,
18639                    Err(e) => {
18640                        dlg.finished(false);
18641                        return Err(common::Error::MissingToken(e));
18642                    }
18643                },
18644            };
18645            request_value_reader
18646                .seek(std::io::SeekFrom::Start(0))
18647                .unwrap();
18648            let mut req_result = {
18649                let client = &self.hub.client;
18650                dlg.pre_request();
18651                let mut req_builder = hyper::Request::builder()
18652                    .method(hyper::Method::PATCH)
18653                    .uri(url.as_str())
18654                    .header(USER_AGENT, self.hub._user_agent.clone());
18655
18656                if let Some(token) = token.as_ref() {
18657                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18658                }
18659
18660                let request = req_builder
18661                    .header(CONTENT_TYPE, json_mime_type.to_string())
18662                    .header(CONTENT_LENGTH, request_size as u64)
18663                    .body(common::to_body(
18664                        request_value_reader.get_ref().clone().into(),
18665                    ));
18666
18667                client.request(request.unwrap()).await
18668            };
18669
18670            match req_result {
18671                Err(err) => {
18672                    if let common::Retry::After(d) = dlg.http_error(&err) {
18673                        sleep(d).await;
18674                        continue;
18675                    }
18676                    dlg.finished(false);
18677                    return Err(common::Error::HttpError(err));
18678                }
18679                Ok(res) => {
18680                    let (mut parts, body) = res.into_parts();
18681                    let mut body = common::Body::new(body);
18682                    if !parts.status.is_success() {
18683                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18684                        let error = serde_json::from_str(&common::to_string(&bytes));
18685                        let response = common::to_response(parts, bytes.into());
18686
18687                        if let common::Retry::After(d) =
18688                            dlg.http_failure(&response, error.as_ref().ok())
18689                        {
18690                            sleep(d).await;
18691                            continue;
18692                        }
18693
18694                        dlg.finished(false);
18695
18696                        return Err(match error {
18697                            Ok(value) => common::Error::BadRequest(value),
18698                            _ => common::Error::Failure(response),
18699                        });
18700                    }
18701                    let response = {
18702                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18703                        let encoded = common::to_string(&bytes);
18704                        match serde_json::from_str(&encoded) {
18705                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18706                            Err(error) => {
18707                                dlg.response_json_decode_error(&encoded, &error);
18708                                return Err(common::Error::JsonDecodeError(
18709                                    encoded.to_string(),
18710                                    error,
18711                                ));
18712                            }
18713                        }
18714                    };
18715
18716                    dlg.finished(true);
18717                    return Ok(response);
18718                }
18719            }
18720        }
18721    }
18722
18723    ///
18724    /// Sets the *request* property to the given value.
18725    ///
18726    /// Even though the property as already been set when instantiating this call,
18727    /// we provide this method for API completeness.
18728    pub fn request(mut self, new_value: Runtime) -> ProjectLocationRuntimePatchCall<'a, C> {
18729        self._request = new_value;
18730        self
18731    }
18732    /// Output only. The resource name of the runtime. Format: `projects/{project}/locations/{location}/runtimes/{runtimeId}`
18733    ///
18734    /// Sets the *name* path property to the given value.
18735    ///
18736    /// Even though the property as already been set when instantiating this call,
18737    /// we provide this method for API completeness.
18738    pub fn name(mut self, new_value: &str) -> ProjectLocationRuntimePatchCall<'a, C> {
18739        self._name = new_value.to_string();
18740        self
18741    }
18742    /// Required. Specifies the path, relative to `Runtime`, of the field to update. For example, to change the software configuration kernels, the `update_mask` parameter would be specified as `software_config.kernels`, and the `PATCH` request body would specify the new value, as follows: { "software_config":{ "kernels": [{ 'repository': 'gcr.io/deeplearning-platform-release/pytorch-gpu', 'tag': 'latest' }], } } Currently, only the following fields can be updated: - `software_config.kernels` - `software_config.post_startup_script` - `software_config.custom_gpu_driver_path` - `software_config.idle_shutdown` - `software_config.idle_shutdown_timeout` - `software_config.disable_terminal` - `labels`
18743    ///
18744    /// Sets the *update mask* query property to the given value.
18745    pub fn update_mask(
18746        mut self,
18747        new_value: common::FieldMask,
18748    ) -> ProjectLocationRuntimePatchCall<'a, C> {
18749        self._update_mask = Some(new_value);
18750        self
18751    }
18752    /// Idempotent request UUID.
18753    ///
18754    /// Sets the *request id* query property to the given value.
18755    pub fn request_id(mut self, new_value: &str) -> ProjectLocationRuntimePatchCall<'a, C> {
18756        self._request_id = Some(new_value.to_string());
18757        self
18758    }
18759    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18760    /// while executing the actual API request.
18761    ///
18762    /// ````text
18763    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18764    /// ````
18765    ///
18766    /// Sets the *delegate* property to the given value.
18767    pub fn delegate(
18768        mut self,
18769        new_value: &'a mut dyn common::Delegate,
18770    ) -> ProjectLocationRuntimePatchCall<'a, C> {
18771        self._delegate = Some(new_value);
18772        self
18773    }
18774
18775    /// Set any additional parameter of the query string used in the request.
18776    /// It should be used to set parameters which are not yet available through their own
18777    /// setters.
18778    ///
18779    /// Please note that this method must not be used to set any of the known parameters
18780    /// which have their own setter method. If done anyway, the request will fail.
18781    ///
18782    /// # Additional Parameters
18783    ///
18784    /// * *$.xgafv* (query-string) - V1 error format.
18785    /// * *access_token* (query-string) - OAuth access token.
18786    /// * *alt* (query-string) - Data format for response.
18787    /// * *callback* (query-string) - JSONP
18788    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18789    /// * *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.
18790    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18791    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18792    /// * *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.
18793    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18794    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18795    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRuntimePatchCall<'a, C>
18796    where
18797        T: AsRef<str>,
18798    {
18799        self._additional_params
18800            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18801        self
18802    }
18803
18804    /// Identifies the authorization scope for the method you are building.
18805    ///
18806    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18807    /// [`Scope::CloudPlatform`].
18808    ///
18809    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18810    /// tokens for more than one scope.
18811    ///
18812    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18813    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18814    /// sufficient, a read-write scope will do as well.
18815    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRuntimePatchCall<'a, C>
18816    where
18817        St: AsRef<str>,
18818    {
18819        self._scopes.insert(String::from(scope.as_ref()));
18820        self
18821    }
18822    /// Identifies the authorization scope(s) for the method you are building.
18823    ///
18824    /// See [`Self::add_scope()`] for details.
18825    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRuntimePatchCall<'a, C>
18826    where
18827        I: IntoIterator<Item = St>,
18828        St: AsRef<str>,
18829    {
18830        self._scopes
18831            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18832        self
18833    }
18834
18835    /// Removes all scopes, and no default scope will be used either.
18836    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18837    /// for details).
18838    pub fn clear_scopes(mut self) -> ProjectLocationRuntimePatchCall<'a, C> {
18839        self._scopes.clear();
18840        self
18841    }
18842}
18843
18844/// Gets an access token for the consumer service account that the customer attached to the runtime. Only accessible from the tenant instance.
18845///
18846/// A builder for the *locations.runtimes.refreshRuntimeTokenInternal* method supported by a *project* resource.
18847/// It is not used directly, but through a [`ProjectMethods`] instance.
18848///
18849/// # Example
18850///
18851/// Instantiate a resource method builder
18852///
18853/// ```test_harness,no_run
18854/// # extern crate hyper;
18855/// # extern crate hyper_rustls;
18856/// # extern crate google_notebooks1 as notebooks1;
18857/// use notebooks1::api::RefreshRuntimeTokenInternalRequest;
18858/// # async fn dox() {
18859/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18860///
18861/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18862/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18863/// #     .with_native_roots()
18864/// #     .unwrap()
18865/// #     .https_only()
18866/// #     .enable_http2()
18867/// #     .build();
18868///
18869/// # let executor = hyper_util::rt::TokioExecutor::new();
18870/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18871/// #     secret,
18872/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18873/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
18874/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
18875/// #     ),
18876/// # ).build().await.unwrap();
18877///
18878/// # let client = hyper_util::client::legacy::Client::builder(
18879/// #     hyper_util::rt::TokioExecutor::new()
18880/// # )
18881/// # .build(
18882/// #     hyper_rustls::HttpsConnectorBuilder::new()
18883/// #         .with_native_roots()
18884/// #         .unwrap()
18885/// #         .https_or_http()
18886/// #         .enable_http2()
18887/// #         .build()
18888/// # );
18889/// # let mut hub = AIPlatformNotebooks::new(client, auth);
18890/// // As the method needs a request, you would usually fill it with the desired information
18891/// // into the respective structure. Some of the parts shown here might not be applicable !
18892/// // Values shown here are possibly random and not representative !
18893/// let mut req = RefreshRuntimeTokenInternalRequest::default();
18894///
18895/// // You can configure optional parameters by calling the respective setters at will, and
18896/// // execute the final call using `doit()`.
18897/// // Values shown here are possibly random and not representative !
18898/// let result = hub.projects().locations_runtimes_refresh_runtime_token_internal(req, "name")
18899///              .doit().await;
18900/// # }
18901/// ```
18902pub struct ProjectLocationRuntimeRefreshRuntimeTokenInternalCall<'a, C>
18903where
18904    C: 'a,
18905{
18906    hub: &'a AIPlatformNotebooks<C>,
18907    _request: RefreshRuntimeTokenInternalRequest,
18908    _name: String,
18909    _delegate: Option<&'a mut dyn common::Delegate>,
18910    _additional_params: HashMap<String, String>,
18911    _scopes: BTreeSet<String>,
18912}
18913
18914impl<'a, C> common::CallBuilder for ProjectLocationRuntimeRefreshRuntimeTokenInternalCall<'a, C> {}
18915
18916impl<'a, C> ProjectLocationRuntimeRefreshRuntimeTokenInternalCall<'a, C>
18917where
18918    C: common::Connector,
18919{
18920    /// Perform the operation you have build so far.
18921    pub async fn doit(
18922        mut self,
18923    ) -> common::Result<(common::Response, RefreshRuntimeTokenInternalResponse)> {
18924        use std::borrow::Cow;
18925        use std::io::{Read, Seek};
18926
18927        use common::{url::Params, ToParts};
18928        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18929
18930        let mut dd = common::DefaultDelegate;
18931        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18932        dlg.begin(common::MethodInfo {
18933            id: "notebooks.projects.locations.runtimes.refreshRuntimeTokenInternal",
18934            http_method: hyper::Method::POST,
18935        });
18936
18937        for &field in ["alt", "name"].iter() {
18938            if self._additional_params.contains_key(field) {
18939                dlg.finished(false);
18940                return Err(common::Error::FieldClash(field));
18941            }
18942        }
18943
18944        let mut params = Params::with_capacity(4 + self._additional_params.len());
18945        params.push("name", self._name);
18946
18947        params.extend(self._additional_params.iter());
18948
18949        params.push("alt", "json");
18950        let mut url = self.hub._base_url.clone() + "v1/{+name}:refreshRuntimeTokenInternal";
18951        if self._scopes.is_empty() {
18952            self._scopes
18953                .insert(Scope::CloudPlatform.as_ref().to_string());
18954        }
18955
18956        #[allow(clippy::single_element_loop)]
18957        for &(find_this, param_name) in [("{+name}", "name")].iter() {
18958            url = params.uri_replacement(url, param_name, find_this, true);
18959        }
18960        {
18961            let to_remove = ["name"];
18962            params.remove_params(&to_remove);
18963        }
18964
18965        let url = params.parse_with_url(&url);
18966
18967        let mut json_mime_type = mime::APPLICATION_JSON;
18968        let mut request_value_reader = {
18969            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18970            common::remove_json_null_values(&mut value);
18971            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18972            serde_json::to_writer(&mut dst, &value).unwrap();
18973            dst
18974        };
18975        let request_size = request_value_reader
18976            .seek(std::io::SeekFrom::End(0))
18977            .unwrap();
18978        request_value_reader
18979            .seek(std::io::SeekFrom::Start(0))
18980            .unwrap();
18981
18982        loop {
18983            let token = match self
18984                .hub
18985                .auth
18986                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18987                .await
18988            {
18989                Ok(token) => token,
18990                Err(e) => match dlg.token(e) {
18991                    Ok(token) => token,
18992                    Err(e) => {
18993                        dlg.finished(false);
18994                        return Err(common::Error::MissingToken(e));
18995                    }
18996                },
18997            };
18998            request_value_reader
18999                .seek(std::io::SeekFrom::Start(0))
19000                .unwrap();
19001            let mut req_result = {
19002                let client = &self.hub.client;
19003                dlg.pre_request();
19004                let mut req_builder = hyper::Request::builder()
19005                    .method(hyper::Method::POST)
19006                    .uri(url.as_str())
19007                    .header(USER_AGENT, self.hub._user_agent.clone());
19008
19009                if let Some(token) = token.as_ref() {
19010                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19011                }
19012
19013                let request = req_builder
19014                    .header(CONTENT_TYPE, json_mime_type.to_string())
19015                    .header(CONTENT_LENGTH, request_size as u64)
19016                    .body(common::to_body(
19017                        request_value_reader.get_ref().clone().into(),
19018                    ));
19019
19020                client.request(request.unwrap()).await
19021            };
19022
19023            match req_result {
19024                Err(err) => {
19025                    if let common::Retry::After(d) = dlg.http_error(&err) {
19026                        sleep(d).await;
19027                        continue;
19028                    }
19029                    dlg.finished(false);
19030                    return Err(common::Error::HttpError(err));
19031                }
19032                Ok(res) => {
19033                    let (mut parts, body) = res.into_parts();
19034                    let mut body = common::Body::new(body);
19035                    if !parts.status.is_success() {
19036                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19037                        let error = serde_json::from_str(&common::to_string(&bytes));
19038                        let response = common::to_response(parts, bytes.into());
19039
19040                        if let common::Retry::After(d) =
19041                            dlg.http_failure(&response, error.as_ref().ok())
19042                        {
19043                            sleep(d).await;
19044                            continue;
19045                        }
19046
19047                        dlg.finished(false);
19048
19049                        return Err(match error {
19050                            Ok(value) => common::Error::BadRequest(value),
19051                            _ => common::Error::Failure(response),
19052                        });
19053                    }
19054                    let response = {
19055                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19056                        let encoded = common::to_string(&bytes);
19057                        match serde_json::from_str(&encoded) {
19058                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19059                            Err(error) => {
19060                                dlg.response_json_decode_error(&encoded, &error);
19061                                return Err(common::Error::JsonDecodeError(
19062                                    encoded.to_string(),
19063                                    error,
19064                                ));
19065                            }
19066                        }
19067                    };
19068
19069                    dlg.finished(true);
19070                    return Ok(response);
19071                }
19072            }
19073        }
19074    }
19075
19076    ///
19077    /// Sets the *request* property to the given value.
19078    ///
19079    /// Even though the property as already been set when instantiating this call,
19080    /// we provide this method for API completeness.
19081    pub fn request(
19082        mut self,
19083        new_value: RefreshRuntimeTokenInternalRequest,
19084    ) -> ProjectLocationRuntimeRefreshRuntimeTokenInternalCall<'a, C> {
19085        self._request = new_value;
19086        self
19087    }
19088    /// Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
19089    ///
19090    /// Sets the *name* path property to the given value.
19091    ///
19092    /// Even though the property as already been set when instantiating this call,
19093    /// we provide this method for API completeness.
19094    pub fn name(
19095        mut self,
19096        new_value: &str,
19097    ) -> ProjectLocationRuntimeRefreshRuntimeTokenInternalCall<'a, C> {
19098        self._name = new_value.to_string();
19099        self
19100    }
19101    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19102    /// while executing the actual API request.
19103    ///
19104    /// ````text
19105    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19106    /// ````
19107    ///
19108    /// Sets the *delegate* property to the given value.
19109    pub fn delegate(
19110        mut self,
19111        new_value: &'a mut dyn common::Delegate,
19112    ) -> ProjectLocationRuntimeRefreshRuntimeTokenInternalCall<'a, C> {
19113        self._delegate = Some(new_value);
19114        self
19115    }
19116
19117    /// Set any additional parameter of the query string used in the request.
19118    /// It should be used to set parameters which are not yet available through their own
19119    /// setters.
19120    ///
19121    /// Please note that this method must not be used to set any of the known parameters
19122    /// which have their own setter method. If done anyway, the request will fail.
19123    ///
19124    /// # Additional Parameters
19125    ///
19126    /// * *$.xgafv* (query-string) - V1 error format.
19127    /// * *access_token* (query-string) - OAuth access token.
19128    /// * *alt* (query-string) - Data format for response.
19129    /// * *callback* (query-string) - JSONP
19130    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19131    /// * *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.
19132    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19133    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19134    /// * *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.
19135    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19136    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19137    pub fn param<T>(
19138        mut self,
19139        name: T,
19140        value: T,
19141    ) -> ProjectLocationRuntimeRefreshRuntimeTokenInternalCall<'a, C>
19142    where
19143        T: AsRef<str>,
19144    {
19145        self._additional_params
19146            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19147        self
19148    }
19149
19150    /// Identifies the authorization scope for the method you are building.
19151    ///
19152    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19153    /// [`Scope::CloudPlatform`].
19154    ///
19155    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19156    /// tokens for more than one scope.
19157    ///
19158    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19159    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19160    /// sufficient, a read-write scope will do as well.
19161    pub fn add_scope<St>(
19162        mut self,
19163        scope: St,
19164    ) -> ProjectLocationRuntimeRefreshRuntimeTokenInternalCall<'a, C>
19165    where
19166        St: AsRef<str>,
19167    {
19168        self._scopes.insert(String::from(scope.as_ref()));
19169        self
19170    }
19171    /// Identifies the authorization scope(s) for the method you are building.
19172    ///
19173    /// See [`Self::add_scope()`] for details.
19174    pub fn add_scopes<I, St>(
19175        mut self,
19176        scopes: I,
19177    ) -> ProjectLocationRuntimeRefreshRuntimeTokenInternalCall<'a, C>
19178    where
19179        I: IntoIterator<Item = St>,
19180        St: AsRef<str>,
19181    {
19182        self._scopes
19183            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19184        self
19185    }
19186
19187    /// Removes all scopes, and no default scope will be used either.
19188    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19189    /// for details).
19190    pub fn clear_scopes(mut self) -> ProjectLocationRuntimeRefreshRuntimeTokenInternalCall<'a, C> {
19191        self._scopes.clear();
19192        self
19193    }
19194}
19195
19196/// Reports and processes a runtime event.
19197///
19198/// A builder for the *locations.runtimes.reportEvent* method supported by a *project* resource.
19199/// It is not used directly, but through a [`ProjectMethods`] instance.
19200///
19201/// # Example
19202///
19203/// Instantiate a resource method builder
19204///
19205/// ```test_harness,no_run
19206/// # extern crate hyper;
19207/// # extern crate hyper_rustls;
19208/// # extern crate google_notebooks1 as notebooks1;
19209/// use notebooks1::api::ReportRuntimeEventRequest;
19210/// # async fn dox() {
19211/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19212///
19213/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19214/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19215/// #     .with_native_roots()
19216/// #     .unwrap()
19217/// #     .https_only()
19218/// #     .enable_http2()
19219/// #     .build();
19220///
19221/// # let executor = hyper_util::rt::TokioExecutor::new();
19222/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19223/// #     secret,
19224/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19225/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
19226/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
19227/// #     ),
19228/// # ).build().await.unwrap();
19229///
19230/// # let client = hyper_util::client::legacy::Client::builder(
19231/// #     hyper_util::rt::TokioExecutor::new()
19232/// # )
19233/// # .build(
19234/// #     hyper_rustls::HttpsConnectorBuilder::new()
19235/// #         .with_native_roots()
19236/// #         .unwrap()
19237/// #         .https_or_http()
19238/// #         .enable_http2()
19239/// #         .build()
19240/// # );
19241/// # let mut hub = AIPlatformNotebooks::new(client, auth);
19242/// // As the method needs a request, you would usually fill it with the desired information
19243/// // into the respective structure. Some of the parts shown here might not be applicable !
19244/// // Values shown here are possibly random and not representative !
19245/// let mut req = ReportRuntimeEventRequest::default();
19246///
19247/// // You can configure optional parameters by calling the respective setters at will, and
19248/// // execute the final call using `doit()`.
19249/// // Values shown here are possibly random and not representative !
19250/// let result = hub.projects().locations_runtimes_report_event(req, "name")
19251///              .doit().await;
19252/// # }
19253/// ```
19254pub struct ProjectLocationRuntimeReportEventCall<'a, C>
19255where
19256    C: 'a,
19257{
19258    hub: &'a AIPlatformNotebooks<C>,
19259    _request: ReportRuntimeEventRequest,
19260    _name: String,
19261    _delegate: Option<&'a mut dyn common::Delegate>,
19262    _additional_params: HashMap<String, String>,
19263    _scopes: BTreeSet<String>,
19264}
19265
19266impl<'a, C> common::CallBuilder for ProjectLocationRuntimeReportEventCall<'a, C> {}
19267
19268impl<'a, C> ProjectLocationRuntimeReportEventCall<'a, C>
19269where
19270    C: common::Connector,
19271{
19272    /// Perform the operation you have build so far.
19273    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
19274        use std::borrow::Cow;
19275        use std::io::{Read, Seek};
19276
19277        use common::{url::Params, ToParts};
19278        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19279
19280        let mut dd = common::DefaultDelegate;
19281        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19282        dlg.begin(common::MethodInfo {
19283            id: "notebooks.projects.locations.runtimes.reportEvent",
19284            http_method: hyper::Method::POST,
19285        });
19286
19287        for &field in ["alt", "name"].iter() {
19288            if self._additional_params.contains_key(field) {
19289                dlg.finished(false);
19290                return Err(common::Error::FieldClash(field));
19291            }
19292        }
19293
19294        let mut params = Params::with_capacity(4 + self._additional_params.len());
19295        params.push("name", self._name);
19296
19297        params.extend(self._additional_params.iter());
19298
19299        params.push("alt", "json");
19300        let mut url = self.hub._base_url.clone() + "v1/{+name}:reportEvent";
19301        if self._scopes.is_empty() {
19302            self._scopes
19303                .insert(Scope::CloudPlatform.as_ref().to_string());
19304        }
19305
19306        #[allow(clippy::single_element_loop)]
19307        for &(find_this, param_name) in [("{+name}", "name")].iter() {
19308            url = params.uri_replacement(url, param_name, find_this, true);
19309        }
19310        {
19311            let to_remove = ["name"];
19312            params.remove_params(&to_remove);
19313        }
19314
19315        let url = params.parse_with_url(&url);
19316
19317        let mut json_mime_type = mime::APPLICATION_JSON;
19318        let mut request_value_reader = {
19319            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19320            common::remove_json_null_values(&mut value);
19321            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19322            serde_json::to_writer(&mut dst, &value).unwrap();
19323            dst
19324        };
19325        let request_size = request_value_reader
19326            .seek(std::io::SeekFrom::End(0))
19327            .unwrap();
19328        request_value_reader
19329            .seek(std::io::SeekFrom::Start(0))
19330            .unwrap();
19331
19332        loop {
19333            let token = match self
19334                .hub
19335                .auth
19336                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19337                .await
19338            {
19339                Ok(token) => token,
19340                Err(e) => match dlg.token(e) {
19341                    Ok(token) => token,
19342                    Err(e) => {
19343                        dlg.finished(false);
19344                        return Err(common::Error::MissingToken(e));
19345                    }
19346                },
19347            };
19348            request_value_reader
19349                .seek(std::io::SeekFrom::Start(0))
19350                .unwrap();
19351            let mut req_result = {
19352                let client = &self.hub.client;
19353                dlg.pre_request();
19354                let mut req_builder = hyper::Request::builder()
19355                    .method(hyper::Method::POST)
19356                    .uri(url.as_str())
19357                    .header(USER_AGENT, self.hub._user_agent.clone());
19358
19359                if let Some(token) = token.as_ref() {
19360                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19361                }
19362
19363                let request = req_builder
19364                    .header(CONTENT_TYPE, json_mime_type.to_string())
19365                    .header(CONTENT_LENGTH, request_size as u64)
19366                    .body(common::to_body(
19367                        request_value_reader.get_ref().clone().into(),
19368                    ));
19369
19370                client.request(request.unwrap()).await
19371            };
19372
19373            match req_result {
19374                Err(err) => {
19375                    if let common::Retry::After(d) = dlg.http_error(&err) {
19376                        sleep(d).await;
19377                        continue;
19378                    }
19379                    dlg.finished(false);
19380                    return Err(common::Error::HttpError(err));
19381                }
19382                Ok(res) => {
19383                    let (mut parts, body) = res.into_parts();
19384                    let mut body = common::Body::new(body);
19385                    if !parts.status.is_success() {
19386                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19387                        let error = serde_json::from_str(&common::to_string(&bytes));
19388                        let response = common::to_response(parts, bytes.into());
19389
19390                        if let common::Retry::After(d) =
19391                            dlg.http_failure(&response, error.as_ref().ok())
19392                        {
19393                            sleep(d).await;
19394                            continue;
19395                        }
19396
19397                        dlg.finished(false);
19398
19399                        return Err(match error {
19400                            Ok(value) => common::Error::BadRequest(value),
19401                            _ => common::Error::Failure(response),
19402                        });
19403                    }
19404                    let response = {
19405                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19406                        let encoded = common::to_string(&bytes);
19407                        match serde_json::from_str(&encoded) {
19408                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19409                            Err(error) => {
19410                                dlg.response_json_decode_error(&encoded, &error);
19411                                return Err(common::Error::JsonDecodeError(
19412                                    encoded.to_string(),
19413                                    error,
19414                                ));
19415                            }
19416                        }
19417                    };
19418
19419                    dlg.finished(true);
19420                    return Ok(response);
19421                }
19422            }
19423        }
19424    }
19425
19426    ///
19427    /// Sets the *request* property to the given value.
19428    ///
19429    /// Even though the property as already been set when instantiating this call,
19430    /// we provide this method for API completeness.
19431    pub fn request(
19432        mut self,
19433        new_value: ReportRuntimeEventRequest,
19434    ) -> ProjectLocationRuntimeReportEventCall<'a, C> {
19435        self._request = new_value;
19436        self
19437    }
19438    /// Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
19439    ///
19440    /// Sets the *name* path property to the given value.
19441    ///
19442    /// Even though the property as already been set when instantiating this call,
19443    /// we provide this method for API completeness.
19444    pub fn name(mut self, new_value: &str) -> ProjectLocationRuntimeReportEventCall<'a, C> {
19445        self._name = new_value.to_string();
19446        self
19447    }
19448    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19449    /// while executing the actual API request.
19450    ///
19451    /// ````text
19452    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19453    /// ````
19454    ///
19455    /// Sets the *delegate* property to the given value.
19456    pub fn delegate(
19457        mut self,
19458        new_value: &'a mut dyn common::Delegate,
19459    ) -> ProjectLocationRuntimeReportEventCall<'a, C> {
19460        self._delegate = Some(new_value);
19461        self
19462    }
19463
19464    /// Set any additional parameter of the query string used in the request.
19465    /// It should be used to set parameters which are not yet available through their own
19466    /// setters.
19467    ///
19468    /// Please note that this method must not be used to set any of the known parameters
19469    /// which have their own setter method. If done anyway, the request will fail.
19470    ///
19471    /// # Additional Parameters
19472    ///
19473    /// * *$.xgafv* (query-string) - V1 error format.
19474    /// * *access_token* (query-string) - OAuth access token.
19475    /// * *alt* (query-string) - Data format for response.
19476    /// * *callback* (query-string) - JSONP
19477    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19478    /// * *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.
19479    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19480    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19481    /// * *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.
19482    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19483    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19484    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRuntimeReportEventCall<'a, C>
19485    where
19486        T: AsRef<str>,
19487    {
19488        self._additional_params
19489            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19490        self
19491    }
19492
19493    /// Identifies the authorization scope for the method you are building.
19494    ///
19495    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19496    /// [`Scope::CloudPlatform`].
19497    ///
19498    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19499    /// tokens for more than one scope.
19500    ///
19501    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19502    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19503    /// sufficient, a read-write scope will do as well.
19504    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRuntimeReportEventCall<'a, C>
19505    where
19506        St: AsRef<str>,
19507    {
19508        self._scopes.insert(String::from(scope.as_ref()));
19509        self
19510    }
19511    /// Identifies the authorization scope(s) for the method you are building.
19512    ///
19513    /// See [`Self::add_scope()`] for details.
19514    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRuntimeReportEventCall<'a, C>
19515    where
19516        I: IntoIterator<Item = St>,
19517        St: AsRef<str>,
19518    {
19519        self._scopes
19520            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19521        self
19522    }
19523
19524    /// Removes all scopes, and no default scope will be used either.
19525    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19526    /// for details).
19527    pub fn clear_scopes(mut self) -> ProjectLocationRuntimeReportEventCall<'a, C> {
19528        self._scopes.clear();
19529        self
19530    }
19531}
19532
19533/// Resets a Managed Notebook Runtime.
19534///
19535/// A builder for the *locations.runtimes.reset* method supported by a *project* resource.
19536/// It is not used directly, but through a [`ProjectMethods`] instance.
19537///
19538/// # Example
19539///
19540/// Instantiate a resource method builder
19541///
19542/// ```test_harness,no_run
19543/// # extern crate hyper;
19544/// # extern crate hyper_rustls;
19545/// # extern crate google_notebooks1 as notebooks1;
19546/// use notebooks1::api::ResetRuntimeRequest;
19547/// # async fn dox() {
19548/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19549///
19550/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19551/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19552/// #     .with_native_roots()
19553/// #     .unwrap()
19554/// #     .https_only()
19555/// #     .enable_http2()
19556/// #     .build();
19557///
19558/// # let executor = hyper_util::rt::TokioExecutor::new();
19559/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19560/// #     secret,
19561/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19562/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
19563/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
19564/// #     ),
19565/// # ).build().await.unwrap();
19566///
19567/// # let client = hyper_util::client::legacy::Client::builder(
19568/// #     hyper_util::rt::TokioExecutor::new()
19569/// # )
19570/// # .build(
19571/// #     hyper_rustls::HttpsConnectorBuilder::new()
19572/// #         .with_native_roots()
19573/// #         .unwrap()
19574/// #         .https_or_http()
19575/// #         .enable_http2()
19576/// #         .build()
19577/// # );
19578/// # let mut hub = AIPlatformNotebooks::new(client, auth);
19579/// // As the method needs a request, you would usually fill it with the desired information
19580/// // into the respective structure. Some of the parts shown here might not be applicable !
19581/// // Values shown here are possibly random and not representative !
19582/// let mut req = ResetRuntimeRequest::default();
19583///
19584/// // You can configure optional parameters by calling the respective setters at will, and
19585/// // execute the final call using `doit()`.
19586/// // Values shown here are possibly random and not representative !
19587/// let result = hub.projects().locations_runtimes_reset(req, "name")
19588///              .doit().await;
19589/// # }
19590/// ```
19591pub struct ProjectLocationRuntimeResetCall<'a, C>
19592where
19593    C: 'a,
19594{
19595    hub: &'a AIPlatformNotebooks<C>,
19596    _request: ResetRuntimeRequest,
19597    _name: String,
19598    _delegate: Option<&'a mut dyn common::Delegate>,
19599    _additional_params: HashMap<String, String>,
19600    _scopes: BTreeSet<String>,
19601}
19602
19603impl<'a, C> common::CallBuilder for ProjectLocationRuntimeResetCall<'a, C> {}
19604
19605impl<'a, C> ProjectLocationRuntimeResetCall<'a, C>
19606where
19607    C: common::Connector,
19608{
19609    /// Perform the operation you have build so far.
19610    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
19611        use std::borrow::Cow;
19612        use std::io::{Read, Seek};
19613
19614        use common::{url::Params, ToParts};
19615        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19616
19617        let mut dd = common::DefaultDelegate;
19618        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19619        dlg.begin(common::MethodInfo {
19620            id: "notebooks.projects.locations.runtimes.reset",
19621            http_method: hyper::Method::POST,
19622        });
19623
19624        for &field in ["alt", "name"].iter() {
19625            if self._additional_params.contains_key(field) {
19626                dlg.finished(false);
19627                return Err(common::Error::FieldClash(field));
19628            }
19629        }
19630
19631        let mut params = Params::with_capacity(4 + self._additional_params.len());
19632        params.push("name", self._name);
19633
19634        params.extend(self._additional_params.iter());
19635
19636        params.push("alt", "json");
19637        let mut url = self.hub._base_url.clone() + "v1/{+name}:reset";
19638        if self._scopes.is_empty() {
19639            self._scopes
19640                .insert(Scope::CloudPlatform.as_ref().to_string());
19641        }
19642
19643        #[allow(clippy::single_element_loop)]
19644        for &(find_this, param_name) in [("{+name}", "name")].iter() {
19645            url = params.uri_replacement(url, param_name, find_this, true);
19646        }
19647        {
19648            let to_remove = ["name"];
19649            params.remove_params(&to_remove);
19650        }
19651
19652        let url = params.parse_with_url(&url);
19653
19654        let mut json_mime_type = mime::APPLICATION_JSON;
19655        let mut request_value_reader = {
19656            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19657            common::remove_json_null_values(&mut value);
19658            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19659            serde_json::to_writer(&mut dst, &value).unwrap();
19660            dst
19661        };
19662        let request_size = request_value_reader
19663            .seek(std::io::SeekFrom::End(0))
19664            .unwrap();
19665        request_value_reader
19666            .seek(std::io::SeekFrom::Start(0))
19667            .unwrap();
19668
19669        loop {
19670            let token = match self
19671                .hub
19672                .auth
19673                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19674                .await
19675            {
19676                Ok(token) => token,
19677                Err(e) => match dlg.token(e) {
19678                    Ok(token) => token,
19679                    Err(e) => {
19680                        dlg.finished(false);
19681                        return Err(common::Error::MissingToken(e));
19682                    }
19683                },
19684            };
19685            request_value_reader
19686                .seek(std::io::SeekFrom::Start(0))
19687                .unwrap();
19688            let mut req_result = {
19689                let client = &self.hub.client;
19690                dlg.pre_request();
19691                let mut req_builder = hyper::Request::builder()
19692                    .method(hyper::Method::POST)
19693                    .uri(url.as_str())
19694                    .header(USER_AGENT, self.hub._user_agent.clone());
19695
19696                if let Some(token) = token.as_ref() {
19697                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19698                }
19699
19700                let request = req_builder
19701                    .header(CONTENT_TYPE, json_mime_type.to_string())
19702                    .header(CONTENT_LENGTH, request_size as u64)
19703                    .body(common::to_body(
19704                        request_value_reader.get_ref().clone().into(),
19705                    ));
19706
19707                client.request(request.unwrap()).await
19708            };
19709
19710            match req_result {
19711                Err(err) => {
19712                    if let common::Retry::After(d) = dlg.http_error(&err) {
19713                        sleep(d).await;
19714                        continue;
19715                    }
19716                    dlg.finished(false);
19717                    return Err(common::Error::HttpError(err));
19718                }
19719                Ok(res) => {
19720                    let (mut parts, body) = res.into_parts();
19721                    let mut body = common::Body::new(body);
19722                    if !parts.status.is_success() {
19723                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19724                        let error = serde_json::from_str(&common::to_string(&bytes));
19725                        let response = common::to_response(parts, bytes.into());
19726
19727                        if let common::Retry::After(d) =
19728                            dlg.http_failure(&response, error.as_ref().ok())
19729                        {
19730                            sleep(d).await;
19731                            continue;
19732                        }
19733
19734                        dlg.finished(false);
19735
19736                        return Err(match error {
19737                            Ok(value) => common::Error::BadRequest(value),
19738                            _ => common::Error::Failure(response),
19739                        });
19740                    }
19741                    let response = {
19742                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19743                        let encoded = common::to_string(&bytes);
19744                        match serde_json::from_str(&encoded) {
19745                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19746                            Err(error) => {
19747                                dlg.response_json_decode_error(&encoded, &error);
19748                                return Err(common::Error::JsonDecodeError(
19749                                    encoded.to_string(),
19750                                    error,
19751                                ));
19752                            }
19753                        }
19754                    };
19755
19756                    dlg.finished(true);
19757                    return Ok(response);
19758                }
19759            }
19760        }
19761    }
19762
19763    ///
19764    /// Sets the *request* property to the given value.
19765    ///
19766    /// Even though the property as already been set when instantiating this call,
19767    /// we provide this method for API completeness.
19768    pub fn request(
19769        mut self,
19770        new_value: ResetRuntimeRequest,
19771    ) -> ProjectLocationRuntimeResetCall<'a, C> {
19772        self._request = new_value;
19773        self
19774    }
19775    /// Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
19776    ///
19777    /// Sets the *name* path property to the given value.
19778    ///
19779    /// Even though the property as already been set when instantiating this call,
19780    /// we provide this method for API completeness.
19781    pub fn name(mut self, new_value: &str) -> ProjectLocationRuntimeResetCall<'a, C> {
19782        self._name = new_value.to_string();
19783        self
19784    }
19785    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19786    /// while executing the actual API request.
19787    ///
19788    /// ````text
19789    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19790    /// ````
19791    ///
19792    /// Sets the *delegate* property to the given value.
19793    pub fn delegate(
19794        mut self,
19795        new_value: &'a mut dyn common::Delegate,
19796    ) -> ProjectLocationRuntimeResetCall<'a, C> {
19797        self._delegate = Some(new_value);
19798        self
19799    }
19800
19801    /// Set any additional parameter of the query string used in the request.
19802    /// It should be used to set parameters which are not yet available through their own
19803    /// setters.
19804    ///
19805    /// Please note that this method must not be used to set any of the known parameters
19806    /// which have their own setter method. If done anyway, the request will fail.
19807    ///
19808    /// # Additional Parameters
19809    ///
19810    /// * *$.xgafv* (query-string) - V1 error format.
19811    /// * *access_token* (query-string) - OAuth access token.
19812    /// * *alt* (query-string) - Data format for response.
19813    /// * *callback* (query-string) - JSONP
19814    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19815    /// * *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.
19816    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19817    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19818    /// * *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.
19819    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19820    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19821    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRuntimeResetCall<'a, C>
19822    where
19823        T: AsRef<str>,
19824    {
19825        self._additional_params
19826            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19827        self
19828    }
19829
19830    /// Identifies the authorization scope for the method you are building.
19831    ///
19832    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19833    /// [`Scope::CloudPlatform`].
19834    ///
19835    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19836    /// tokens for more than one scope.
19837    ///
19838    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19839    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19840    /// sufficient, a read-write scope will do as well.
19841    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRuntimeResetCall<'a, C>
19842    where
19843        St: AsRef<str>,
19844    {
19845        self._scopes.insert(String::from(scope.as_ref()));
19846        self
19847    }
19848    /// Identifies the authorization scope(s) for the method you are building.
19849    ///
19850    /// See [`Self::add_scope()`] for details.
19851    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRuntimeResetCall<'a, C>
19852    where
19853        I: IntoIterator<Item = St>,
19854        St: AsRef<str>,
19855    {
19856        self._scopes
19857            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19858        self
19859    }
19860
19861    /// Removes all scopes, and no default scope will be used either.
19862    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19863    /// for details).
19864    pub fn clear_scopes(mut self) -> ProjectLocationRuntimeResetCall<'a, C> {
19865        self._scopes.clear();
19866        self
19867    }
19868}
19869
19870/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
19871///
19872/// A builder for the *locations.runtimes.setIamPolicy* method supported by a *project* resource.
19873/// It is not used directly, but through a [`ProjectMethods`] instance.
19874///
19875/// # Example
19876///
19877/// Instantiate a resource method builder
19878///
19879/// ```test_harness,no_run
19880/// # extern crate hyper;
19881/// # extern crate hyper_rustls;
19882/// # extern crate google_notebooks1 as notebooks1;
19883/// use notebooks1::api::SetIamPolicyRequest;
19884/// # async fn dox() {
19885/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19886///
19887/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19888/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19889/// #     .with_native_roots()
19890/// #     .unwrap()
19891/// #     .https_only()
19892/// #     .enable_http2()
19893/// #     .build();
19894///
19895/// # let executor = hyper_util::rt::TokioExecutor::new();
19896/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19897/// #     secret,
19898/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19899/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
19900/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
19901/// #     ),
19902/// # ).build().await.unwrap();
19903///
19904/// # let client = hyper_util::client::legacy::Client::builder(
19905/// #     hyper_util::rt::TokioExecutor::new()
19906/// # )
19907/// # .build(
19908/// #     hyper_rustls::HttpsConnectorBuilder::new()
19909/// #         .with_native_roots()
19910/// #         .unwrap()
19911/// #         .https_or_http()
19912/// #         .enable_http2()
19913/// #         .build()
19914/// # );
19915/// # let mut hub = AIPlatformNotebooks::new(client, auth);
19916/// // As the method needs a request, you would usually fill it with the desired information
19917/// // into the respective structure. Some of the parts shown here might not be applicable !
19918/// // Values shown here are possibly random and not representative !
19919/// let mut req = SetIamPolicyRequest::default();
19920///
19921/// // You can configure optional parameters by calling the respective setters at will, and
19922/// // execute the final call using `doit()`.
19923/// // Values shown here are possibly random and not representative !
19924/// let result = hub.projects().locations_runtimes_set_iam_policy(req, "resource")
19925///              .doit().await;
19926/// # }
19927/// ```
19928pub struct ProjectLocationRuntimeSetIamPolicyCall<'a, C>
19929where
19930    C: 'a,
19931{
19932    hub: &'a AIPlatformNotebooks<C>,
19933    _request: SetIamPolicyRequest,
19934    _resource: String,
19935    _delegate: Option<&'a mut dyn common::Delegate>,
19936    _additional_params: HashMap<String, String>,
19937    _scopes: BTreeSet<String>,
19938}
19939
19940impl<'a, C> common::CallBuilder for ProjectLocationRuntimeSetIamPolicyCall<'a, C> {}
19941
19942impl<'a, C> ProjectLocationRuntimeSetIamPolicyCall<'a, C>
19943where
19944    C: common::Connector,
19945{
19946    /// Perform the operation you have build so far.
19947    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
19948        use std::borrow::Cow;
19949        use std::io::{Read, Seek};
19950
19951        use common::{url::Params, ToParts};
19952        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19953
19954        let mut dd = common::DefaultDelegate;
19955        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19956        dlg.begin(common::MethodInfo {
19957            id: "notebooks.projects.locations.runtimes.setIamPolicy",
19958            http_method: hyper::Method::POST,
19959        });
19960
19961        for &field in ["alt", "resource"].iter() {
19962            if self._additional_params.contains_key(field) {
19963                dlg.finished(false);
19964                return Err(common::Error::FieldClash(field));
19965            }
19966        }
19967
19968        let mut params = Params::with_capacity(4 + self._additional_params.len());
19969        params.push("resource", self._resource);
19970
19971        params.extend(self._additional_params.iter());
19972
19973        params.push("alt", "json");
19974        let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
19975        if self._scopes.is_empty() {
19976            self._scopes
19977                .insert(Scope::CloudPlatform.as_ref().to_string());
19978        }
19979
19980        #[allow(clippy::single_element_loop)]
19981        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
19982            url = params.uri_replacement(url, param_name, find_this, true);
19983        }
19984        {
19985            let to_remove = ["resource"];
19986            params.remove_params(&to_remove);
19987        }
19988
19989        let url = params.parse_with_url(&url);
19990
19991        let mut json_mime_type = mime::APPLICATION_JSON;
19992        let mut request_value_reader = {
19993            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19994            common::remove_json_null_values(&mut value);
19995            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19996            serde_json::to_writer(&mut dst, &value).unwrap();
19997            dst
19998        };
19999        let request_size = request_value_reader
20000            .seek(std::io::SeekFrom::End(0))
20001            .unwrap();
20002        request_value_reader
20003            .seek(std::io::SeekFrom::Start(0))
20004            .unwrap();
20005
20006        loop {
20007            let token = match self
20008                .hub
20009                .auth
20010                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20011                .await
20012            {
20013                Ok(token) => token,
20014                Err(e) => match dlg.token(e) {
20015                    Ok(token) => token,
20016                    Err(e) => {
20017                        dlg.finished(false);
20018                        return Err(common::Error::MissingToken(e));
20019                    }
20020                },
20021            };
20022            request_value_reader
20023                .seek(std::io::SeekFrom::Start(0))
20024                .unwrap();
20025            let mut req_result = {
20026                let client = &self.hub.client;
20027                dlg.pre_request();
20028                let mut req_builder = hyper::Request::builder()
20029                    .method(hyper::Method::POST)
20030                    .uri(url.as_str())
20031                    .header(USER_AGENT, self.hub._user_agent.clone());
20032
20033                if let Some(token) = token.as_ref() {
20034                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20035                }
20036
20037                let request = req_builder
20038                    .header(CONTENT_TYPE, json_mime_type.to_string())
20039                    .header(CONTENT_LENGTH, request_size as u64)
20040                    .body(common::to_body(
20041                        request_value_reader.get_ref().clone().into(),
20042                    ));
20043
20044                client.request(request.unwrap()).await
20045            };
20046
20047            match req_result {
20048                Err(err) => {
20049                    if let common::Retry::After(d) = dlg.http_error(&err) {
20050                        sleep(d).await;
20051                        continue;
20052                    }
20053                    dlg.finished(false);
20054                    return Err(common::Error::HttpError(err));
20055                }
20056                Ok(res) => {
20057                    let (mut parts, body) = res.into_parts();
20058                    let mut body = common::Body::new(body);
20059                    if !parts.status.is_success() {
20060                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20061                        let error = serde_json::from_str(&common::to_string(&bytes));
20062                        let response = common::to_response(parts, bytes.into());
20063
20064                        if let common::Retry::After(d) =
20065                            dlg.http_failure(&response, error.as_ref().ok())
20066                        {
20067                            sleep(d).await;
20068                            continue;
20069                        }
20070
20071                        dlg.finished(false);
20072
20073                        return Err(match error {
20074                            Ok(value) => common::Error::BadRequest(value),
20075                            _ => common::Error::Failure(response),
20076                        });
20077                    }
20078                    let response = {
20079                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20080                        let encoded = common::to_string(&bytes);
20081                        match serde_json::from_str(&encoded) {
20082                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20083                            Err(error) => {
20084                                dlg.response_json_decode_error(&encoded, &error);
20085                                return Err(common::Error::JsonDecodeError(
20086                                    encoded.to_string(),
20087                                    error,
20088                                ));
20089                            }
20090                        }
20091                    };
20092
20093                    dlg.finished(true);
20094                    return Ok(response);
20095                }
20096            }
20097        }
20098    }
20099
20100    ///
20101    /// Sets the *request* property to the given value.
20102    ///
20103    /// Even though the property as already been set when instantiating this call,
20104    /// we provide this method for API completeness.
20105    pub fn request(
20106        mut self,
20107        new_value: SetIamPolicyRequest,
20108    ) -> ProjectLocationRuntimeSetIamPolicyCall<'a, C> {
20109        self._request = new_value;
20110        self
20111    }
20112    /// 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.
20113    ///
20114    /// Sets the *resource* path property to the given value.
20115    ///
20116    /// Even though the property as already been set when instantiating this call,
20117    /// we provide this method for API completeness.
20118    pub fn resource(mut self, new_value: &str) -> ProjectLocationRuntimeSetIamPolicyCall<'a, C> {
20119        self._resource = new_value.to_string();
20120        self
20121    }
20122    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20123    /// while executing the actual API request.
20124    ///
20125    /// ````text
20126    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20127    /// ````
20128    ///
20129    /// Sets the *delegate* property to the given value.
20130    pub fn delegate(
20131        mut self,
20132        new_value: &'a mut dyn common::Delegate,
20133    ) -> ProjectLocationRuntimeSetIamPolicyCall<'a, C> {
20134        self._delegate = Some(new_value);
20135        self
20136    }
20137
20138    /// Set any additional parameter of the query string used in the request.
20139    /// It should be used to set parameters which are not yet available through their own
20140    /// setters.
20141    ///
20142    /// Please note that this method must not be used to set any of the known parameters
20143    /// which have their own setter method. If done anyway, the request will fail.
20144    ///
20145    /// # Additional Parameters
20146    ///
20147    /// * *$.xgafv* (query-string) - V1 error format.
20148    /// * *access_token* (query-string) - OAuth access token.
20149    /// * *alt* (query-string) - Data format for response.
20150    /// * *callback* (query-string) - JSONP
20151    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20152    /// * *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.
20153    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20154    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20155    /// * *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.
20156    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20157    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20158    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRuntimeSetIamPolicyCall<'a, C>
20159    where
20160        T: AsRef<str>,
20161    {
20162        self._additional_params
20163            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20164        self
20165    }
20166
20167    /// Identifies the authorization scope for the method you are building.
20168    ///
20169    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20170    /// [`Scope::CloudPlatform`].
20171    ///
20172    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20173    /// tokens for more than one scope.
20174    ///
20175    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20176    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20177    /// sufficient, a read-write scope will do as well.
20178    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRuntimeSetIamPolicyCall<'a, C>
20179    where
20180        St: AsRef<str>,
20181    {
20182        self._scopes.insert(String::from(scope.as_ref()));
20183        self
20184    }
20185    /// Identifies the authorization scope(s) for the method you are building.
20186    ///
20187    /// See [`Self::add_scope()`] for details.
20188    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRuntimeSetIamPolicyCall<'a, C>
20189    where
20190        I: IntoIterator<Item = St>,
20191        St: AsRef<str>,
20192    {
20193        self._scopes
20194            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20195        self
20196    }
20197
20198    /// Removes all scopes, and no default scope will be used either.
20199    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20200    /// for details).
20201    pub fn clear_scopes(mut self) -> ProjectLocationRuntimeSetIamPolicyCall<'a, C> {
20202        self._scopes.clear();
20203        self
20204    }
20205}
20206
20207/// Starts a Managed Notebook Runtime. Perform "Start" on GPU instances; "Resume" on CPU instances See: https://cloud.google.com/compute/docs/instances/stop-start-instance https://cloud.google.com/compute/docs/instances/suspend-resume-instance
20208///
20209/// A builder for the *locations.runtimes.start* method supported by a *project* resource.
20210/// It is not used directly, but through a [`ProjectMethods`] instance.
20211///
20212/// # Example
20213///
20214/// Instantiate a resource method builder
20215///
20216/// ```test_harness,no_run
20217/// # extern crate hyper;
20218/// # extern crate hyper_rustls;
20219/// # extern crate google_notebooks1 as notebooks1;
20220/// use notebooks1::api::StartRuntimeRequest;
20221/// # async fn dox() {
20222/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20223///
20224/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20225/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20226/// #     .with_native_roots()
20227/// #     .unwrap()
20228/// #     .https_only()
20229/// #     .enable_http2()
20230/// #     .build();
20231///
20232/// # let executor = hyper_util::rt::TokioExecutor::new();
20233/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20234/// #     secret,
20235/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20236/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
20237/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
20238/// #     ),
20239/// # ).build().await.unwrap();
20240///
20241/// # let client = hyper_util::client::legacy::Client::builder(
20242/// #     hyper_util::rt::TokioExecutor::new()
20243/// # )
20244/// # .build(
20245/// #     hyper_rustls::HttpsConnectorBuilder::new()
20246/// #         .with_native_roots()
20247/// #         .unwrap()
20248/// #         .https_or_http()
20249/// #         .enable_http2()
20250/// #         .build()
20251/// # );
20252/// # let mut hub = AIPlatformNotebooks::new(client, auth);
20253/// // As the method needs a request, you would usually fill it with the desired information
20254/// // into the respective structure. Some of the parts shown here might not be applicable !
20255/// // Values shown here are possibly random and not representative !
20256/// let mut req = StartRuntimeRequest::default();
20257///
20258/// // You can configure optional parameters by calling the respective setters at will, and
20259/// // execute the final call using `doit()`.
20260/// // Values shown here are possibly random and not representative !
20261/// let result = hub.projects().locations_runtimes_start(req, "name")
20262///              .doit().await;
20263/// # }
20264/// ```
20265pub struct ProjectLocationRuntimeStartCall<'a, C>
20266where
20267    C: 'a,
20268{
20269    hub: &'a AIPlatformNotebooks<C>,
20270    _request: StartRuntimeRequest,
20271    _name: String,
20272    _delegate: Option<&'a mut dyn common::Delegate>,
20273    _additional_params: HashMap<String, String>,
20274    _scopes: BTreeSet<String>,
20275}
20276
20277impl<'a, C> common::CallBuilder for ProjectLocationRuntimeStartCall<'a, C> {}
20278
20279impl<'a, C> ProjectLocationRuntimeStartCall<'a, C>
20280where
20281    C: common::Connector,
20282{
20283    /// Perform the operation you have build so far.
20284    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
20285        use std::borrow::Cow;
20286        use std::io::{Read, Seek};
20287
20288        use common::{url::Params, ToParts};
20289        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20290
20291        let mut dd = common::DefaultDelegate;
20292        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20293        dlg.begin(common::MethodInfo {
20294            id: "notebooks.projects.locations.runtimes.start",
20295            http_method: hyper::Method::POST,
20296        });
20297
20298        for &field in ["alt", "name"].iter() {
20299            if self._additional_params.contains_key(field) {
20300                dlg.finished(false);
20301                return Err(common::Error::FieldClash(field));
20302            }
20303        }
20304
20305        let mut params = Params::with_capacity(4 + self._additional_params.len());
20306        params.push("name", self._name);
20307
20308        params.extend(self._additional_params.iter());
20309
20310        params.push("alt", "json");
20311        let mut url = self.hub._base_url.clone() + "v1/{+name}:start";
20312        if self._scopes.is_empty() {
20313            self._scopes
20314                .insert(Scope::CloudPlatform.as_ref().to_string());
20315        }
20316
20317        #[allow(clippy::single_element_loop)]
20318        for &(find_this, param_name) in [("{+name}", "name")].iter() {
20319            url = params.uri_replacement(url, param_name, find_this, true);
20320        }
20321        {
20322            let to_remove = ["name"];
20323            params.remove_params(&to_remove);
20324        }
20325
20326        let url = params.parse_with_url(&url);
20327
20328        let mut json_mime_type = mime::APPLICATION_JSON;
20329        let mut request_value_reader = {
20330            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20331            common::remove_json_null_values(&mut value);
20332            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20333            serde_json::to_writer(&mut dst, &value).unwrap();
20334            dst
20335        };
20336        let request_size = request_value_reader
20337            .seek(std::io::SeekFrom::End(0))
20338            .unwrap();
20339        request_value_reader
20340            .seek(std::io::SeekFrom::Start(0))
20341            .unwrap();
20342
20343        loop {
20344            let token = match self
20345                .hub
20346                .auth
20347                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20348                .await
20349            {
20350                Ok(token) => token,
20351                Err(e) => match dlg.token(e) {
20352                    Ok(token) => token,
20353                    Err(e) => {
20354                        dlg.finished(false);
20355                        return Err(common::Error::MissingToken(e));
20356                    }
20357                },
20358            };
20359            request_value_reader
20360                .seek(std::io::SeekFrom::Start(0))
20361                .unwrap();
20362            let mut req_result = {
20363                let client = &self.hub.client;
20364                dlg.pre_request();
20365                let mut req_builder = hyper::Request::builder()
20366                    .method(hyper::Method::POST)
20367                    .uri(url.as_str())
20368                    .header(USER_AGENT, self.hub._user_agent.clone());
20369
20370                if let Some(token) = token.as_ref() {
20371                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20372                }
20373
20374                let request = req_builder
20375                    .header(CONTENT_TYPE, json_mime_type.to_string())
20376                    .header(CONTENT_LENGTH, request_size as u64)
20377                    .body(common::to_body(
20378                        request_value_reader.get_ref().clone().into(),
20379                    ));
20380
20381                client.request(request.unwrap()).await
20382            };
20383
20384            match req_result {
20385                Err(err) => {
20386                    if let common::Retry::After(d) = dlg.http_error(&err) {
20387                        sleep(d).await;
20388                        continue;
20389                    }
20390                    dlg.finished(false);
20391                    return Err(common::Error::HttpError(err));
20392                }
20393                Ok(res) => {
20394                    let (mut parts, body) = res.into_parts();
20395                    let mut body = common::Body::new(body);
20396                    if !parts.status.is_success() {
20397                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20398                        let error = serde_json::from_str(&common::to_string(&bytes));
20399                        let response = common::to_response(parts, bytes.into());
20400
20401                        if let common::Retry::After(d) =
20402                            dlg.http_failure(&response, error.as_ref().ok())
20403                        {
20404                            sleep(d).await;
20405                            continue;
20406                        }
20407
20408                        dlg.finished(false);
20409
20410                        return Err(match error {
20411                            Ok(value) => common::Error::BadRequest(value),
20412                            _ => common::Error::Failure(response),
20413                        });
20414                    }
20415                    let response = {
20416                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20417                        let encoded = common::to_string(&bytes);
20418                        match serde_json::from_str(&encoded) {
20419                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20420                            Err(error) => {
20421                                dlg.response_json_decode_error(&encoded, &error);
20422                                return Err(common::Error::JsonDecodeError(
20423                                    encoded.to_string(),
20424                                    error,
20425                                ));
20426                            }
20427                        }
20428                    };
20429
20430                    dlg.finished(true);
20431                    return Ok(response);
20432                }
20433            }
20434        }
20435    }
20436
20437    ///
20438    /// Sets the *request* property to the given value.
20439    ///
20440    /// Even though the property as already been set when instantiating this call,
20441    /// we provide this method for API completeness.
20442    pub fn request(
20443        mut self,
20444        new_value: StartRuntimeRequest,
20445    ) -> ProjectLocationRuntimeStartCall<'a, C> {
20446        self._request = new_value;
20447        self
20448    }
20449    /// Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
20450    ///
20451    /// Sets the *name* path property to the given value.
20452    ///
20453    /// Even though the property as already been set when instantiating this call,
20454    /// we provide this method for API completeness.
20455    pub fn name(mut self, new_value: &str) -> ProjectLocationRuntimeStartCall<'a, C> {
20456        self._name = new_value.to_string();
20457        self
20458    }
20459    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20460    /// while executing the actual API request.
20461    ///
20462    /// ````text
20463    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20464    /// ````
20465    ///
20466    /// Sets the *delegate* property to the given value.
20467    pub fn delegate(
20468        mut self,
20469        new_value: &'a mut dyn common::Delegate,
20470    ) -> ProjectLocationRuntimeStartCall<'a, C> {
20471        self._delegate = Some(new_value);
20472        self
20473    }
20474
20475    /// Set any additional parameter of the query string used in the request.
20476    /// It should be used to set parameters which are not yet available through their own
20477    /// setters.
20478    ///
20479    /// Please note that this method must not be used to set any of the known parameters
20480    /// which have their own setter method. If done anyway, the request will fail.
20481    ///
20482    /// # Additional Parameters
20483    ///
20484    /// * *$.xgafv* (query-string) - V1 error format.
20485    /// * *access_token* (query-string) - OAuth access token.
20486    /// * *alt* (query-string) - Data format for response.
20487    /// * *callback* (query-string) - JSONP
20488    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20489    /// * *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.
20490    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20491    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20492    /// * *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.
20493    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20494    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20495    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRuntimeStartCall<'a, C>
20496    where
20497        T: AsRef<str>,
20498    {
20499        self._additional_params
20500            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20501        self
20502    }
20503
20504    /// Identifies the authorization scope for the method you are building.
20505    ///
20506    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20507    /// [`Scope::CloudPlatform`].
20508    ///
20509    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20510    /// tokens for more than one scope.
20511    ///
20512    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20513    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20514    /// sufficient, a read-write scope will do as well.
20515    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRuntimeStartCall<'a, C>
20516    where
20517        St: AsRef<str>,
20518    {
20519        self._scopes.insert(String::from(scope.as_ref()));
20520        self
20521    }
20522    /// Identifies the authorization scope(s) for the method you are building.
20523    ///
20524    /// See [`Self::add_scope()`] for details.
20525    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRuntimeStartCall<'a, C>
20526    where
20527        I: IntoIterator<Item = St>,
20528        St: AsRef<str>,
20529    {
20530        self._scopes
20531            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20532        self
20533    }
20534
20535    /// Removes all scopes, and no default scope will be used either.
20536    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20537    /// for details).
20538    pub fn clear_scopes(mut self) -> ProjectLocationRuntimeStartCall<'a, C> {
20539        self._scopes.clear();
20540        self
20541    }
20542}
20543
20544/// Stops a Managed Notebook Runtime. Perform "Stop" on GPU instances; "Suspend" on CPU instances See: https://cloud.google.com/compute/docs/instances/stop-start-instance https://cloud.google.com/compute/docs/instances/suspend-resume-instance
20545///
20546/// A builder for the *locations.runtimes.stop* method supported by a *project* resource.
20547/// It is not used directly, but through a [`ProjectMethods`] instance.
20548///
20549/// # Example
20550///
20551/// Instantiate a resource method builder
20552///
20553/// ```test_harness,no_run
20554/// # extern crate hyper;
20555/// # extern crate hyper_rustls;
20556/// # extern crate google_notebooks1 as notebooks1;
20557/// use notebooks1::api::StopRuntimeRequest;
20558/// # async fn dox() {
20559/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20560///
20561/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20562/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20563/// #     .with_native_roots()
20564/// #     .unwrap()
20565/// #     .https_only()
20566/// #     .enable_http2()
20567/// #     .build();
20568///
20569/// # let executor = hyper_util::rt::TokioExecutor::new();
20570/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20571/// #     secret,
20572/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20573/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
20574/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
20575/// #     ),
20576/// # ).build().await.unwrap();
20577///
20578/// # let client = hyper_util::client::legacy::Client::builder(
20579/// #     hyper_util::rt::TokioExecutor::new()
20580/// # )
20581/// # .build(
20582/// #     hyper_rustls::HttpsConnectorBuilder::new()
20583/// #         .with_native_roots()
20584/// #         .unwrap()
20585/// #         .https_or_http()
20586/// #         .enable_http2()
20587/// #         .build()
20588/// # );
20589/// # let mut hub = AIPlatformNotebooks::new(client, auth);
20590/// // As the method needs a request, you would usually fill it with the desired information
20591/// // into the respective structure. Some of the parts shown here might not be applicable !
20592/// // Values shown here are possibly random and not representative !
20593/// let mut req = StopRuntimeRequest::default();
20594///
20595/// // You can configure optional parameters by calling the respective setters at will, and
20596/// // execute the final call using `doit()`.
20597/// // Values shown here are possibly random and not representative !
20598/// let result = hub.projects().locations_runtimes_stop(req, "name")
20599///              .doit().await;
20600/// # }
20601/// ```
20602pub struct ProjectLocationRuntimeStopCall<'a, C>
20603where
20604    C: 'a,
20605{
20606    hub: &'a AIPlatformNotebooks<C>,
20607    _request: StopRuntimeRequest,
20608    _name: String,
20609    _delegate: Option<&'a mut dyn common::Delegate>,
20610    _additional_params: HashMap<String, String>,
20611    _scopes: BTreeSet<String>,
20612}
20613
20614impl<'a, C> common::CallBuilder for ProjectLocationRuntimeStopCall<'a, C> {}
20615
20616impl<'a, C> ProjectLocationRuntimeStopCall<'a, C>
20617where
20618    C: common::Connector,
20619{
20620    /// Perform the operation you have build so far.
20621    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
20622        use std::borrow::Cow;
20623        use std::io::{Read, Seek};
20624
20625        use common::{url::Params, ToParts};
20626        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20627
20628        let mut dd = common::DefaultDelegate;
20629        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20630        dlg.begin(common::MethodInfo {
20631            id: "notebooks.projects.locations.runtimes.stop",
20632            http_method: hyper::Method::POST,
20633        });
20634
20635        for &field in ["alt", "name"].iter() {
20636            if self._additional_params.contains_key(field) {
20637                dlg.finished(false);
20638                return Err(common::Error::FieldClash(field));
20639            }
20640        }
20641
20642        let mut params = Params::with_capacity(4 + self._additional_params.len());
20643        params.push("name", self._name);
20644
20645        params.extend(self._additional_params.iter());
20646
20647        params.push("alt", "json");
20648        let mut url = self.hub._base_url.clone() + "v1/{+name}:stop";
20649        if self._scopes.is_empty() {
20650            self._scopes
20651                .insert(Scope::CloudPlatform.as_ref().to_string());
20652        }
20653
20654        #[allow(clippy::single_element_loop)]
20655        for &(find_this, param_name) in [("{+name}", "name")].iter() {
20656            url = params.uri_replacement(url, param_name, find_this, true);
20657        }
20658        {
20659            let to_remove = ["name"];
20660            params.remove_params(&to_remove);
20661        }
20662
20663        let url = params.parse_with_url(&url);
20664
20665        let mut json_mime_type = mime::APPLICATION_JSON;
20666        let mut request_value_reader = {
20667            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20668            common::remove_json_null_values(&mut value);
20669            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20670            serde_json::to_writer(&mut dst, &value).unwrap();
20671            dst
20672        };
20673        let request_size = request_value_reader
20674            .seek(std::io::SeekFrom::End(0))
20675            .unwrap();
20676        request_value_reader
20677            .seek(std::io::SeekFrom::Start(0))
20678            .unwrap();
20679
20680        loop {
20681            let token = match self
20682                .hub
20683                .auth
20684                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20685                .await
20686            {
20687                Ok(token) => token,
20688                Err(e) => match dlg.token(e) {
20689                    Ok(token) => token,
20690                    Err(e) => {
20691                        dlg.finished(false);
20692                        return Err(common::Error::MissingToken(e));
20693                    }
20694                },
20695            };
20696            request_value_reader
20697                .seek(std::io::SeekFrom::Start(0))
20698                .unwrap();
20699            let mut req_result = {
20700                let client = &self.hub.client;
20701                dlg.pre_request();
20702                let mut req_builder = hyper::Request::builder()
20703                    .method(hyper::Method::POST)
20704                    .uri(url.as_str())
20705                    .header(USER_AGENT, self.hub._user_agent.clone());
20706
20707                if let Some(token) = token.as_ref() {
20708                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20709                }
20710
20711                let request = req_builder
20712                    .header(CONTENT_TYPE, json_mime_type.to_string())
20713                    .header(CONTENT_LENGTH, request_size as u64)
20714                    .body(common::to_body(
20715                        request_value_reader.get_ref().clone().into(),
20716                    ));
20717
20718                client.request(request.unwrap()).await
20719            };
20720
20721            match req_result {
20722                Err(err) => {
20723                    if let common::Retry::After(d) = dlg.http_error(&err) {
20724                        sleep(d).await;
20725                        continue;
20726                    }
20727                    dlg.finished(false);
20728                    return Err(common::Error::HttpError(err));
20729                }
20730                Ok(res) => {
20731                    let (mut parts, body) = res.into_parts();
20732                    let mut body = common::Body::new(body);
20733                    if !parts.status.is_success() {
20734                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20735                        let error = serde_json::from_str(&common::to_string(&bytes));
20736                        let response = common::to_response(parts, bytes.into());
20737
20738                        if let common::Retry::After(d) =
20739                            dlg.http_failure(&response, error.as_ref().ok())
20740                        {
20741                            sleep(d).await;
20742                            continue;
20743                        }
20744
20745                        dlg.finished(false);
20746
20747                        return Err(match error {
20748                            Ok(value) => common::Error::BadRequest(value),
20749                            _ => common::Error::Failure(response),
20750                        });
20751                    }
20752                    let response = {
20753                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20754                        let encoded = common::to_string(&bytes);
20755                        match serde_json::from_str(&encoded) {
20756                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20757                            Err(error) => {
20758                                dlg.response_json_decode_error(&encoded, &error);
20759                                return Err(common::Error::JsonDecodeError(
20760                                    encoded.to_string(),
20761                                    error,
20762                                ));
20763                            }
20764                        }
20765                    };
20766
20767                    dlg.finished(true);
20768                    return Ok(response);
20769                }
20770            }
20771        }
20772    }
20773
20774    ///
20775    /// Sets the *request* property to the given value.
20776    ///
20777    /// Even though the property as already been set when instantiating this call,
20778    /// we provide this method for API completeness.
20779    pub fn request(
20780        mut self,
20781        new_value: StopRuntimeRequest,
20782    ) -> ProjectLocationRuntimeStopCall<'a, C> {
20783        self._request = new_value;
20784        self
20785    }
20786    /// Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
20787    ///
20788    /// Sets the *name* path property to the given value.
20789    ///
20790    /// Even though the property as already been set when instantiating this call,
20791    /// we provide this method for API completeness.
20792    pub fn name(mut self, new_value: &str) -> ProjectLocationRuntimeStopCall<'a, C> {
20793        self._name = new_value.to_string();
20794        self
20795    }
20796    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20797    /// while executing the actual API request.
20798    ///
20799    /// ````text
20800    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20801    /// ````
20802    ///
20803    /// Sets the *delegate* property to the given value.
20804    pub fn delegate(
20805        mut self,
20806        new_value: &'a mut dyn common::Delegate,
20807    ) -> ProjectLocationRuntimeStopCall<'a, C> {
20808        self._delegate = Some(new_value);
20809        self
20810    }
20811
20812    /// Set any additional parameter of the query string used in the request.
20813    /// It should be used to set parameters which are not yet available through their own
20814    /// setters.
20815    ///
20816    /// Please note that this method must not be used to set any of the known parameters
20817    /// which have their own setter method. If done anyway, the request will fail.
20818    ///
20819    /// # Additional Parameters
20820    ///
20821    /// * *$.xgafv* (query-string) - V1 error format.
20822    /// * *access_token* (query-string) - OAuth access token.
20823    /// * *alt* (query-string) - Data format for response.
20824    /// * *callback* (query-string) - JSONP
20825    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20826    /// * *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.
20827    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20828    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20829    /// * *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.
20830    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20831    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20832    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRuntimeStopCall<'a, C>
20833    where
20834        T: AsRef<str>,
20835    {
20836        self._additional_params
20837            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20838        self
20839    }
20840
20841    /// Identifies the authorization scope for the method you are building.
20842    ///
20843    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20844    /// [`Scope::CloudPlatform`].
20845    ///
20846    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20847    /// tokens for more than one scope.
20848    ///
20849    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20850    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20851    /// sufficient, a read-write scope will do as well.
20852    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRuntimeStopCall<'a, C>
20853    where
20854        St: AsRef<str>,
20855    {
20856        self._scopes.insert(String::from(scope.as_ref()));
20857        self
20858    }
20859    /// Identifies the authorization scope(s) for the method you are building.
20860    ///
20861    /// See [`Self::add_scope()`] for details.
20862    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRuntimeStopCall<'a, C>
20863    where
20864        I: IntoIterator<Item = St>,
20865        St: AsRef<str>,
20866    {
20867        self._scopes
20868            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20869        self
20870    }
20871
20872    /// Removes all scopes, and no default scope will be used either.
20873    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20874    /// for details).
20875    pub fn clear_scopes(mut self) -> ProjectLocationRuntimeStopCall<'a, C> {
20876        self._scopes.clear();
20877        self
20878    }
20879}
20880
20881/// Switch a Managed Notebook Runtime.
20882///
20883/// A builder for the *locations.runtimes.switch* method supported by a *project* resource.
20884/// It is not used directly, but through a [`ProjectMethods`] instance.
20885///
20886/// # Example
20887///
20888/// Instantiate a resource method builder
20889///
20890/// ```test_harness,no_run
20891/// # extern crate hyper;
20892/// # extern crate hyper_rustls;
20893/// # extern crate google_notebooks1 as notebooks1;
20894/// use notebooks1::api::SwitchRuntimeRequest;
20895/// # async fn dox() {
20896/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20897///
20898/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20899/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20900/// #     .with_native_roots()
20901/// #     .unwrap()
20902/// #     .https_only()
20903/// #     .enable_http2()
20904/// #     .build();
20905///
20906/// # let executor = hyper_util::rt::TokioExecutor::new();
20907/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20908/// #     secret,
20909/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20910/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
20911/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
20912/// #     ),
20913/// # ).build().await.unwrap();
20914///
20915/// # let client = hyper_util::client::legacy::Client::builder(
20916/// #     hyper_util::rt::TokioExecutor::new()
20917/// # )
20918/// # .build(
20919/// #     hyper_rustls::HttpsConnectorBuilder::new()
20920/// #         .with_native_roots()
20921/// #         .unwrap()
20922/// #         .https_or_http()
20923/// #         .enable_http2()
20924/// #         .build()
20925/// # );
20926/// # let mut hub = AIPlatformNotebooks::new(client, auth);
20927/// // As the method needs a request, you would usually fill it with the desired information
20928/// // into the respective structure. Some of the parts shown here might not be applicable !
20929/// // Values shown here are possibly random and not representative !
20930/// let mut req = SwitchRuntimeRequest::default();
20931///
20932/// // You can configure optional parameters by calling the respective setters at will, and
20933/// // execute the final call using `doit()`.
20934/// // Values shown here are possibly random and not representative !
20935/// let result = hub.projects().locations_runtimes_switch(req, "name")
20936///              .doit().await;
20937/// # }
20938/// ```
20939pub struct ProjectLocationRuntimeSwitchCall<'a, C>
20940where
20941    C: 'a,
20942{
20943    hub: &'a AIPlatformNotebooks<C>,
20944    _request: SwitchRuntimeRequest,
20945    _name: String,
20946    _delegate: Option<&'a mut dyn common::Delegate>,
20947    _additional_params: HashMap<String, String>,
20948    _scopes: BTreeSet<String>,
20949}
20950
20951impl<'a, C> common::CallBuilder for ProjectLocationRuntimeSwitchCall<'a, C> {}
20952
20953impl<'a, C> ProjectLocationRuntimeSwitchCall<'a, C>
20954where
20955    C: common::Connector,
20956{
20957    /// Perform the operation you have build so far.
20958    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
20959        use std::borrow::Cow;
20960        use std::io::{Read, Seek};
20961
20962        use common::{url::Params, ToParts};
20963        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20964
20965        let mut dd = common::DefaultDelegate;
20966        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20967        dlg.begin(common::MethodInfo {
20968            id: "notebooks.projects.locations.runtimes.switch",
20969            http_method: hyper::Method::POST,
20970        });
20971
20972        for &field in ["alt", "name"].iter() {
20973            if self._additional_params.contains_key(field) {
20974                dlg.finished(false);
20975                return Err(common::Error::FieldClash(field));
20976            }
20977        }
20978
20979        let mut params = Params::with_capacity(4 + self._additional_params.len());
20980        params.push("name", self._name);
20981
20982        params.extend(self._additional_params.iter());
20983
20984        params.push("alt", "json");
20985        let mut url = self.hub._base_url.clone() + "v1/{+name}:switch";
20986        if self._scopes.is_empty() {
20987            self._scopes
20988                .insert(Scope::CloudPlatform.as_ref().to_string());
20989        }
20990
20991        #[allow(clippy::single_element_loop)]
20992        for &(find_this, param_name) in [("{+name}", "name")].iter() {
20993            url = params.uri_replacement(url, param_name, find_this, true);
20994        }
20995        {
20996            let to_remove = ["name"];
20997            params.remove_params(&to_remove);
20998        }
20999
21000        let url = params.parse_with_url(&url);
21001
21002        let mut json_mime_type = mime::APPLICATION_JSON;
21003        let mut request_value_reader = {
21004            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21005            common::remove_json_null_values(&mut value);
21006            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21007            serde_json::to_writer(&mut dst, &value).unwrap();
21008            dst
21009        };
21010        let request_size = request_value_reader
21011            .seek(std::io::SeekFrom::End(0))
21012            .unwrap();
21013        request_value_reader
21014            .seek(std::io::SeekFrom::Start(0))
21015            .unwrap();
21016
21017        loop {
21018            let token = match self
21019                .hub
21020                .auth
21021                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21022                .await
21023            {
21024                Ok(token) => token,
21025                Err(e) => match dlg.token(e) {
21026                    Ok(token) => token,
21027                    Err(e) => {
21028                        dlg.finished(false);
21029                        return Err(common::Error::MissingToken(e));
21030                    }
21031                },
21032            };
21033            request_value_reader
21034                .seek(std::io::SeekFrom::Start(0))
21035                .unwrap();
21036            let mut req_result = {
21037                let client = &self.hub.client;
21038                dlg.pre_request();
21039                let mut req_builder = hyper::Request::builder()
21040                    .method(hyper::Method::POST)
21041                    .uri(url.as_str())
21042                    .header(USER_AGENT, self.hub._user_agent.clone());
21043
21044                if let Some(token) = token.as_ref() {
21045                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21046                }
21047
21048                let request = req_builder
21049                    .header(CONTENT_TYPE, json_mime_type.to_string())
21050                    .header(CONTENT_LENGTH, request_size as u64)
21051                    .body(common::to_body(
21052                        request_value_reader.get_ref().clone().into(),
21053                    ));
21054
21055                client.request(request.unwrap()).await
21056            };
21057
21058            match req_result {
21059                Err(err) => {
21060                    if let common::Retry::After(d) = dlg.http_error(&err) {
21061                        sleep(d).await;
21062                        continue;
21063                    }
21064                    dlg.finished(false);
21065                    return Err(common::Error::HttpError(err));
21066                }
21067                Ok(res) => {
21068                    let (mut parts, body) = res.into_parts();
21069                    let mut body = common::Body::new(body);
21070                    if !parts.status.is_success() {
21071                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21072                        let error = serde_json::from_str(&common::to_string(&bytes));
21073                        let response = common::to_response(parts, bytes.into());
21074
21075                        if let common::Retry::After(d) =
21076                            dlg.http_failure(&response, error.as_ref().ok())
21077                        {
21078                            sleep(d).await;
21079                            continue;
21080                        }
21081
21082                        dlg.finished(false);
21083
21084                        return Err(match error {
21085                            Ok(value) => common::Error::BadRequest(value),
21086                            _ => common::Error::Failure(response),
21087                        });
21088                    }
21089                    let response = {
21090                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21091                        let encoded = common::to_string(&bytes);
21092                        match serde_json::from_str(&encoded) {
21093                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21094                            Err(error) => {
21095                                dlg.response_json_decode_error(&encoded, &error);
21096                                return Err(common::Error::JsonDecodeError(
21097                                    encoded.to_string(),
21098                                    error,
21099                                ));
21100                            }
21101                        }
21102                    };
21103
21104                    dlg.finished(true);
21105                    return Ok(response);
21106                }
21107            }
21108        }
21109    }
21110
21111    ///
21112    /// Sets the *request* property to the given value.
21113    ///
21114    /// Even though the property as already been set when instantiating this call,
21115    /// we provide this method for API completeness.
21116    pub fn request(
21117        mut self,
21118        new_value: SwitchRuntimeRequest,
21119    ) -> ProjectLocationRuntimeSwitchCall<'a, C> {
21120        self._request = new_value;
21121        self
21122    }
21123    /// Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
21124    ///
21125    /// Sets the *name* path property to the given value.
21126    ///
21127    /// Even though the property as already been set when instantiating this call,
21128    /// we provide this method for API completeness.
21129    pub fn name(mut self, new_value: &str) -> ProjectLocationRuntimeSwitchCall<'a, C> {
21130        self._name = new_value.to_string();
21131        self
21132    }
21133    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21134    /// while executing the actual API request.
21135    ///
21136    /// ````text
21137    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21138    /// ````
21139    ///
21140    /// Sets the *delegate* property to the given value.
21141    pub fn delegate(
21142        mut self,
21143        new_value: &'a mut dyn common::Delegate,
21144    ) -> ProjectLocationRuntimeSwitchCall<'a, C> {
21145        self._delegate = Some(new_value);
21146        self
21147    }
21148
21149    /// Set any additional parameter of the query string used in the request.
21150    /// It should be used to set parameters which are not yet available through their own
21151    /// setters.
21152    ///
21153    /// Please note that this method must not be used to set any of the known parameters
21154    /// which have their own setter method. If done anyway, the request will fail.
21155    ///
21156    /// # Additional Parameters
21157    ///
21158    /// * *$.xgafv* (query-string) - V1 error format.
21159    /// * *access_token* (query-string) - OAuth access token.
21160    /// * *alt* (query-string) - Data format for response.
21161    /// * *callback* (query-string) - JSONP
21162    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21163    /// * *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.
21164    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21165    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21166    /// * *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.
21167    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21168    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21169    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRuntimeSwitchCall<'a, C>
21170    where
21171        T: AsRef<str>,
21172    {
21173        self._additional_params
21174            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21175        self
21176    }
21177
21178    /// Identifies the authorization scope for the method you are building.
21179    ///
21180    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21181    /// [`Scope::CloudPlatform`].
21182    ///
21183    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21184    /// tokens for more than one scope.
21185    ///
21186    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21187    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21188    /// sufficient, a read-write scope will do as well.
21189    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRuntimeSwitchCall<'a, C>
21190    where
21191        St: AsRef<str>,
21192    {
21193        self._scopes.insert(String::from(scope.as_ref()));
21194        self
21195    }
21196    /// Identifies the authorization scope(s) for the method you are building.
21197    ///
21198    /// See [`Self::add_scope()`] for details.
21199    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRuntimeSwitchCall<'a, C>
21200    where
21201        I: IntoIterator<Item = St>,
21202        St: AsRef<str>,
21203    {
21204        self._scopes
21205            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21206        self
21207    }
21208
21209    /// Removes all scopes, and no default scope will be used either.
21210    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21211    /// for details).
21212    pub fn clear_scopes(mut self) -> ProjectLocationRuntimeSwitchCall<'a, C> {
21213        self._scopes.clear();
21214        self
21215    }
21216}
21217
21218/// 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.
21219///
21220/// A builder for the *locations.runtimes.testIamPermissions* method supported by a *project* resource.
21221/// It is not used directly, but through a [`ProjectMethods`] instance.
21222///
21223/// # Example
21224///
21225/// Instantiate a resource method builder
21226///
21227/// ```test_harness,no_run
21228/// # extern crate hyper;
21229/// # extern crate hyper_rustls;
21230/// # extern crate google_notebooks1 as notebooks1;
21231/// use notebooks1::api::TestIamPermissionsRequest;
21232/// # async fn dox() {
21233/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21234///
21235/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21236/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21237/// #     .with_native_roots()
21238/// #     .unwrap()
21239/// #     .https_only()
21240/// #     .enable_http2()
21241/// #     .build();
21242///
21243/// # let executor = hyper_util::rt::TokioExecutor::new();
21244/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21245/// #     secret,
21246/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21247/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
21248/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
21249/// #     ),
21250/// # ).build().await.unwrap();
21251///
21252/// # let client = hyper_util::client::legacy::Client::builder(
21253/// #     hyper_util::rt::TokioExecutor::new()
21254/// # )
21255/// # .build(
21256/// #     hyper_rustls::HttpsConnectorBuilder::new()
21257/// #         .with_native_roots()
21258/// #         .unwrap()
21259/// #         .https_or_http()
21260/// #         .enable_http2()
21261/// #         .build()
21262/// # );
21263/// # let mut hub = AIPlatformNotebooks::new(client, auth);
21264/// // As the method needs a request, you would usually fill it with the desired information
21265/// // into the respective structure. Some of the parts shown here might not be applicable !
21266/// // Values shown here are possibly random and not representative !
21267/// let mut req = TestIamPermissionsRequest::default();
21268///
21269/// // You can configure optional parameters by calling the respective setters at will, and
21270/// // execute the final call using `doit()`.
21271/// // Values shown here are possibly random and not representative !
21272/// let result = hub.projects().locations_runtimes_test_iam_permissions(req, "resource")
21273///              .doit().await;
21274/// # }
21275/// ```
21276pub struct ProjectLocationRuntimeTestIamPermissionCall<'a, C>
21277where
21278    C: 'a,
21279{
21280    hub: &'a AIPlatformNotebooks<C>,
21281    _request: TestIamPermissionsRequest,
21282    _resource: String,
21283    _delegate: Option<&'a mut dyn common::Delegate>,
21284    _additional_params: HashMap<String, String>,
21285    _scopes: BTreeSet<String>,
21286}
21287
21288impl<'a, C> common::CallBuilder for ProjectLocationRuntimeTestIamPermissionCall<'a, C> {}
21289
21290impl<'a, C> ProjectLocationRuntimeTestIamPermissionCall<'a, C>
21291where
21292    C: common::Connector,
21293{
21294    /// Perform the operation you have build so far.
21295    pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
21296        use std::borrow::Cow;
21297        use std::io::{Read, Seek};
21298
21299        use common::{url::Params, ToParts};
21300        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21301
21302        let mut dd = common::DefaultDelegate;
21303        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21304        dlg.begin(common::MethodInfo {
21305            id: "notebooks.projects.locations.runtimes.testIamPermissions",
21306            http_method: hyper::Method::POST,
21307        });
21308
21309        for &field in ["alt", "resource"].iter() {
21310            if self._additional_params.contains_key(field) {
21311                dlg.finished(false);
21312                return Err(common::Error::FieldClash(field));
21313            }
21314        }
21315
21316        let mut params = Params::with_capacity(4 + self._additional_params.len());
21317        params.push("resource", self._resource);
21318
21319        params.extend(self._additional_params.iter());
21320
21321        params.push("alt", "json");
21322        let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
21323        if self._scopes.is_empty() {
21324            self._scopes
21325                .insert(Scope::CloudPlatform.as_ref().to_string());
21326        }
21327
21328        #[allow(clippy::single_element_loop)]
21329        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
21330            url = params.uri_replacement(url, param_name, find_this, true);
21331        }
21332        {
21333            let to_remove = ["resource"];
21334            params.remove_params(&to_remove);
21335        }
21336
21337        let url = params.parse_with_url(&url);
21338
21339        let mut json_mime_type = mime::APPLICATION_JSON;
21340        let mut request_value_reader = {
21341            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21342            common::remove_json_null_values(&mut value);
21343            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21344            serde_json::to_writer(&mut dst, &value).unwrap();
21345            dst
21346        };
21347        let request_size = request_value_reader
21348            .seek(std::io::SeekFrom::End(0))
21349            .unwrap();
21350        request_value_reader
21351            .seek(std::io::SeekFrom::Start(0))
21352            .unwrap();
21353
21354        loop {
21355            let token = match self
21356                .hub
21357                .auth
21358                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21359                .await
21360            {
21361                Ok(token) => token,
21362                Err(e) => match dlg.token(e) {
21363                    Ok(token) => token,
21364                    Err(e) => {
21365                        dlg.finished(false);
21366                        return Err(common::Error::MissingToken(e));
21367                    }
21368                },
21369            };
21370            request_value_reader
21371                .seek(std::io::SeekFrom::Start(0))
21372                .unwrap();
21373            let mut req_result = {
21374                let client = &self.hub.client;
21375                dlg.pre_request();
21376                let mut req_builder = hyper::Request::builder()
21377                    .method(hyper::Method::POST)
21378                    .uri(url.as_str())
21379                    .header(USER_AGENT, self.hub._user_agent.clone());
21380
21381                if let Some(token) = token.as_ref() {
21382                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21383                }
21384
21385                let request = req_builder
21386                    .header(CONTENT_TYPE, json_mime_type.to_string())
21387                    .header(CONTENT_LENGTH, request_size as u64)
21388                    .body(common::to_body(
21389                        request_value_reader.get_ref().clone().into(),
21390                    ));
21391
21392                client.request(request.unwrap()).await
21393            };
21394
21395            match req_result {
21396                Err(err) => {
21397                    if let common::Retry::After(d) = dlg.http_error(&err) {
21398                        sleep(d).await;
21399                        continue;
21400                    }
21401                    dlg.finished(false);
21402                    return Err(common::Error::HttpError(err));
21403                }
21404                Ok(res) => {
21405                    let (mut parts, body) = res.into_parts();
21406                    let mut body = common::Body::new(body);
21407                    if !parts.status.is_success() {
21408                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21409                        let error = serde_json::from_str(&common::to_string(&bytes));
21410                        let response = common::to_response(parts, bytes.into());
21411
21412                        if let common::Retry::After(d) =
21413                            dlg.http_failure(&response, error.as_ref().ok())
21414                        {
21415                            sleep(d).await;
21416                            continue;
21417                        }
21418
21419                        dlg.finished(false);
21420
21421                        return Err(match error {
21422                            Ok(value) => common::Error::BadRequest(value),
21423                            _ => common::Error::Failure(response),
21424                        });
21425                    }
21426                    let response = {
21427                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21428                        let encoded = common::to_string(&bytes);
21429                        match serde_json::from_str(&encoded) {
21430                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21431                            Err(error) => {
21432                                dlg.response_json_decode_error(&encoded, &error);
21433                                return Err(common::Error::JsonDecodeError(
21434                                    encoded.to_string(),
21435                                    error,
21436                                ));
21437                            }
21438                        }
21439                    };
21440
21441                    dlg.finished(true);
21442                    return Ok(response);
21443                }
21444            }
21445        }
21446    }
21447
21448    ///
21449    /// Sets the *request* property to the given value.
21450    ///
21451    /// Even though the property as already been set when instantiating this call,
21452    /// we provide this method for API completeness.
21453    pub fn request(
21454        mut self,
21455        new_value: TestIamPermissionsRequest,
21456    ) -> ProjectLocationRuntimeTestIamPermissionCall<'a, C> {
21457        self._request = new_value;
21458        self
21459    }
21460    /// 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.
21461    ///
21462    /// Sets the *resource* path property to the given value.
21463    ///
21464    /// Even though the property as already been set when instantiating this call,
21465    /// we provide this method for API completeness.
21466    pub fn resource(
21467        mut self,
21468        new_value: &str,
21469    ) -> ProjectLocationRuntimeTestIamPermissionCall<'a, C> {
21470        self._resource = new_value.to_string();
21471        self
21472    }
21473    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21474    /// while executing the actual API request.
21475    ///
21476    /// ````text
21477    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21478    /// ````
21479    ///
21480    /// Sets the *delegate* property to the given value.
21481    pub fn delegate(
21482        mut self,
21483        new_value: &'a mut dyn common::Delegate,
21484    ) -> ProjectLocationRuntimeTestIamPermissionCall<'a, C> {
21485        self._delegate = Some(new_value);
21486        self
21487    }
21488
21489    /// Set any additional parameter of the query string used in the request.
21490    /// It should be used to set parameters which are not yet available through their own
21491    /// setters.
21492    ///
21493    /// Please note that this method must not be used to set any of the known parameters
21494    /// which have their own setter method. If done anyway, the request will fail.
21495    ///
21496    /// # Additional Parameters
21497    ///
21498    /// * *$.xgafv* (query-string) - V1 error format.
21499    /// * *access_token* (query-string) - OAuth access token.
21500    /// * *alt* (query-string) - Data format for response.
21501    /// * *callback* (query-string) - JSONP
21502    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21503    /// * *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.
21504    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21505    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21506    /// * *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.
21507    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21508    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21509    pub fn param<T>(
21510        mut self,
21511        name: T,
21512        value: T,
21513    ) -> ProjectLocationRuntimeTestIamPermissionCall<'a, C>
21514    where
21515        T: AsRef<str>,
21516    {
21517        self._additional_params
21518            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21519        self
21520    }
21521
21522    /// Identifies the authorization scope for the method you are building.
21523    ///
21524    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21525    /// [`Scope::CloudPlatform`].
21526    ///
21527    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21528    /// tokens for more than one scope.
21529    ///
21530    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21531    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21532    /// sufficient, a read-write scope will do as well.
21533    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRuntimeTestIamPermissionCall<'a, C>
21534    where
21535        St: AsRef<str>,
21536    {
21537        self._scopes.insert(String::from(scope.as_ref()));
21538        self
21539    }
21540    /// Identifies the authorization scope(s) for the method you are building.
21541    ///
21542    /// See [`Self::add_scope()`] for details.
21543    pub fn add_scopes<I, St>(
21544        mut self,
21545        scopes: I,
21546    ) -> ProjectLocationRuntimeTestIamPermissionCall<'a, C>
21547    where
21548        I: IntoIterator<Item = St>,
21549        St: AsRef<str>,
21550    {
21551        self._scopes
21552            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21553        self
21554    }
21555
21556    /// Removes all scopes, and no default scope will be used either.
21557    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21558    /// for details).
21559    pub fn clear_scopes(mut self) -> ProjectLocationRuntimeTestIamPermissionCall<'a, C> {
21560        self._scopes.clear();
21561        self
21562    }
21563}
21564
21565/// Upgrades a Managed Notebook Runtime to the latest version.
21566///
21567/// A builder for the *locations.runtimes.upgrade* method supported by a *project* resource.
21568/// It is not used directly, but through a [`ProjectMethods`] instance.
21569///
21570/// # Example
21571///
21572/// Instantiate a resource method builder
21573///
21574/// ```test_harness,no_run
21575/// # extern crate hyper;
21576/// # extern crate hyper_rustls;
21577/// # extern crate google_notebooks1 as notebooks1;
21578/// use notebooks1::api::UpgradeRuntimeRequest;
21579/// # async fn dox() {
21580/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21581///
21582/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21583/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21584/// #     .with_native_roots()
21585/// #     .unwrap()
21586/// #     .https_only()
21587/// #     .enable_http2()
21588/// #     .build();
21589///
21590/// # let executor = hyper_util::rt::TokioExecutor::new();
21591/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21592/// #     secret,
21593/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21594/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
21595/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
21596/// #     ),
21597/// # ).build().await.unwrap();
21598///
21599/// # let client = hyper_util::client::legacy::Client::builder(
21600/// #     hyper_util::rt::TokioExecutor::new()
21601/// # )
21602/// # .build(
21603/// #     hyper_rustls::HttpsConnectorBuilder::new()
21604/// #         .with_native_roots()
21605/// #         .unwrap()
21606/// #         .https_or_http()
21607/// #         .enable_http2()
21608/// #         .build()
21609/// # );
21610/// # let mut hub = AIPlatformNotebooks::new(client, auth);
21611/// // As the method needs a request, you would usually fill it with the desired information
21612/// // into the respective structure. Some of the parts shown here might not be applicable !
21613/// // Values shown here are possibly random and not representative !
21614/// let mut req = UpgradeRuntimeRequest::default();
21615///
21616/// // You can configure optional parameters by calling the respective setters at will, and
21617/// // execute the final call using `doit()`.
21618/// // Values shown here are possibly random and not representative !
21619/// let result = hub.projects().locations_runtimes_upgrade(req, "name")
21620///              .doit().await;
21621/// # }
21622/// ```
21623pub struct ProjectLocationRuntimeUpgradeCall<'a, C>
21624where
21625    C: 'a,
21626{
21627    hub: &'a AIPlatformNotebooks<C>,
21628    _request: UpgradeRuntimeRequest,
21629    _name: String,
21630    _delegate: Option<&'a mut dyn common::Delegate>,
21631    _additional_params: HashMap<String, String>,
21632    _scopes: BTreeSet<String>,
21633}
21634
21635impl<'a, C> common::CallBuilder for ProjectLocationRuntimeUpgradeCall<'a, C> {}
21636
21637impl<'a, C> ProjectLocationRuntimeUpgradeCall<'a, C>
21638where
21639    C: common::Connector,
21640{
21641    /// Perform the operation you have build so far.
21642    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
21643        use std::borrow::Cow;
21644        use std::io::{Read, Seek};
21645
21646        use common::{url::Params, ToParts};
21647        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21648
21649        let mut dd = common::DefaultDelegate;
21650        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21651        dlg.begin(common::MethodInfo {
21652            id: "notebooks.projects.locations.runtimes.upgrade",
21653            http_method: hyper::Method::POST,
21654        });
21655
21656        for &field in ["alt", "name"].iter() {
21657            if self._additional_params.contains_key(field) {
21658                dlg.finished(false);
21659                return Err(common::Error::FieldClash(field));
21660            }
21661        }
21662
21663        let mut params = Params::with_capacity(4 + self._additional_params.len());
21664        params.push("name", self._name);
21665
21666        params.extend(self._additional_params.iter());
21667
21668        params.push("alt", "json");
21669        let mut url = self.hub._base_url.clone() + "v1/{+name}:upgrade";
21670        if self._scopes.is_empty() {
21671            self._scopes
21672                .insert(Scope::CloudPlatform.as_ref().to_string());
21673        }
21674
21675        #[allow(clippy::single_element_loop)]
21676        for &(find_this, param_name) in [("{+name}", "name")].iter() {
21677            url = params.uri_replacement(url, param_name, find_this, true);
21678        }
21679        {
21680            let to_remove = ["name"];
21681            params.remove_params(&to_remove);
21682        }
21683
21684        let url = params.parse_with_url(&url);
21685
21686        let mut json_mime_type = mime::APPLICATION_JSON;
21687        let mut request_value_reader = {
21688            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21689            common::remove_json_null_values(&mut value);
21690            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21691            serde_json::to_writer(&mut dst, &value).unwrap();
21692            dst
21693        };
21694        let request_size = request_value_reader
21695            .seek(std::io::SeekFrom::End(0))
21696            .unwrap();
21697        request_value_reader
21698            .seek(std::io::SeekFrom::Start(0))
21699            .unwrap();
21700
21701        loop {
21702            let token = match self
21703                .hub
21704                .auth
21705                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21706                .await
21707            {
21708                Ok(token) => token,
21709                Err(e) => match dlg.token(e) {
21710                    Ok(token) => token,
21711                    Err(e) => {
21712                        dlg.finished(false);
21713                        return Err(common::Error::MissingToken(e));
21714                    }
21715                },
21716            };
21717            request_value_reader
21718                .seek(std::io::SeekFrom::Start(0))
21719                .unwrap();
21720            let mut req_result = {
21721                let client = &self.hub.client;
21722                dlg.pre_request();
21723                let mut req_builder = hyper::Request::builder()
21724                    .method(hyper::Method::POST)
21725                    .uri(url.as_str())
21726                    .header(USER_AGENT, self.hub._user_agent.clone());
21727
21728                if let Some(token) = token.as_ref() {
21729                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21730                }
21731
21732                let request = req_builder
21733                    .header(CONTENT_TYPE, json_mime_type.to_string())
21734                    .header(CONTENT_LENGTH, request_size as u64)
21735                    .body(common::to_body(
21736                        request_value_reader.get_ref().clone().into(),
21737                    ));
21738
21739                client.request(request.unwrap()).await
21740            };
21741
21742            match req_result {
21743                Err(err) => {
21744                    if let common::Retry::After(d) = dlg.http_error(&err) {
21745                        sleep(d).await;
21746                        continue;
21747                    }
21748                    dlg.finished(false);
21749                    return Err(common::Error::HttpError(err));
21750                }
21751                Ok(res) => {
21752                    let (mut parts, body) = res.into_parts();
21753                    let mut body = common::Body::new(body);
21754                    if !parts.status.is_success() {
21755                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21756                        let error = serde_json::from_str(&common::to_string(&bytes));
21757                        let response = common::to_response(parts, bytes.into());
21758
21759                        if let common::Retry::After(d) =
21760                            dlg.http_failure(&response, error.as_ref().ok())
21761                        {
21762                            sleep(d).await;
21763                            continue;
21764                        }
21765
21766                        dlg.finished(false);
21767
21768                        return Err(match error {
21769                            Ok(value) => common::Error::BadRequest(value),
21770                            _ => common::Error::Failure(response),
21771                        });
21772                    }
21773                    let response = {
21774                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21775                        let encoded = common::to_string(&bytes);
21776                        match serde_json::from_str(&encoded) {
21777                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21778                            Err(error) => {
21779                                dlg.response_json_decode_error(&encoded, &error);
21780                                return Err(common::Error::JsonDecodeError(
21781                                    encoded.to_string(),
21782                                    error,
21783                                ));
21784                            }
21785                        }
21786                    };
21787
21788                    dlg.finished(true);
21789                    return Ok(response);
21790                }
21791            }
21792        }
21793    }
21794
21795    ///
21796    /// Sets the *request* property to the given value.
21797    ///
21798    /// Even though the property as already been set when instantiating this call,
21799    /// we provide this method for API completeness.
21800    pub fn request(
21801        mut self,
21802        new_value: UpgradeRuntimeRequest,
21803    ) -> ProjectLocationRuntimeUpgradeCall<'a, C> {
21804        self._request = new_value;
21805        self
21806    }
21807    /// Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
21808    ///
21809    /// Sets the *name* path property to the given value.
21810    ///
21811    /// Even though the property as already been set when instantiating this call,
21812    /// we provide this method for API completeness.
21813    pub fn name(mut self, new_value: &str) -> ProjectLocationRuntimeUpgradeCall<'a, C> {
21814        self._name = new_value.to_string();
21815        self
21816    }
21817    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21818    /// while executing the actual API request.
21819    ///
21820    /// ````text
21821    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21822    /// ````
21823    ///
21824    /// Sets the *delegate* property to the given value.
21825    pub fn delegate(
21826        mut self,
21827        new_value: &'a mut dyn common::Delegate,
21828    ) -> ProjectLocationRuntimeUpgradeCall<'a, C> {
21829        self._delegate = Some(new_value);
21830        self
21831    }
21832
21833    /// Set any additional parameter of the query string used in the request.
21834    /// It should be used to set parameters which are not yet available through their own
21835    /// setters.
21836    ///
21837    /// Please note that this method must not be used to set any of the known parameters
21838    /// which have their own setter method. If done anyway, the request will fail.
21839    ///
21840    /// # Additional Parameters
21841    ///
21842    /// * *$.xgafv* (query-string) - V1 error format.
21843    /// * *access_token* (query-string) - OAuth access token.
21844    /// * *alt* (query-string) - Data format for response.
21845    /// * *callback* (query-string) - JSONP
21846    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21847    /// * *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.
21848    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21849    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21850    /// * *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.
21851    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21852    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21853    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRuntimeUpgradeCall<'a, C>
21854    where
21855        T: AsRef<str>,
21856    {
21857        self._additional_params
21858            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21859        self
21860    }
21861
21862    /// Identifies the authorization scope for the method you are building.
21863    ///
21864    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21865    /// [`Scope::CloudPlatform`].
21866    ///
21867    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21868    /// tokens for more than one scope.
21869    ///
21870    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21871    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21872    /// sufficient, a read-write scope will do as well.
21873    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRuntimeUpgradeCall<'a, C>
21874    where
21875        St: AsRef<str>,
21876    {
21877        self._scopes.insert(String::from(scope.as_ref()));
21878        self
21879    }
21880    /// Identifies the authorization scope(s) for the method you are building.
21881    ///
21882    /// See [`Self::add_scope()`] for details.
21883    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRuntimeUpgradeCall<'a, C>
21884    where
21885        I: IntoIterator<Item = St>,
21886        St: AsRef<str>,
21887    {
21888        self._scopes
21889            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21890        self
21891    }
21892
21893    /// Removes all scopes, and no default scope will be used either.
21894    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21895    /// for details).
21896    pub fn clear_scopes(mut self) -> ProjectLocationRuntimeUpgradeCall<'a, C> {
21897        self._scopes.clear();
21898        self
21899    }
21900}
21901
21902/// Creates a new Scheduled Notebook in a given project and location.
21903///
21904/// A builder for the *locations.schedules.create* method supported by a *project* resource.
21905/// It is not used directly, but through a [`ProjectMethods`] instance.
21906///
21907/// # Example
21908///
21909/// Instantiate a resource method builder
21910///
21911/// ```test_harness,no_run
21912/// # extern crate hyper;
21913/// # extern crate hyper_rustls;
21914/// # extern crate google_notebooks1 as notebooks1;
21915/// use notebooks1::api::Schedule;
21916/// # async fn dox() {
21917/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21918///
21919/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21920/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21921/// #     .with_native_roots()
21922/// #     .unwrap()
21923/// #     .https_only()
21924/// #     .enable_http2()
21925/// #     .build();
21926///
21927/// # let executor = hyper_util::rt::TokioExecutor::new();
21928/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21929/// #     secret,
21930/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21931/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
21932/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
21933/// #     ),
21934/// # ).build().await.unwrap();
21935///
21936/// # let client = hyper_util::client::legacy::Client::builder(
21937/// #     hyper_util::rt::TokioExecutor::new()
21938/// # )
21939/// # .build(
21940/// #     hyper_rustls::HttpsConnectorBuilder::new()
21941/// #         .with_native_roots()
21942/// #         .unwrap()
21943/// #         .https_or_http()
21944/// #         .enable_http2()
21945/// #         .build()
21946/// # );
21947/// # let mut hub = AIPlatformNotebooks::new(client, auth);
21948/// // As the method needs a request, you would usually fill it with the desired information
21949/// // into the respective structure. Some of the parts shown here might not be applicable !
21950/// // Values shown here are possibly random and not representative !
21951/// let mut req = Schedule::default();
21952///
21953/// // You can configure optional parameters by calling the respective setters at will, and
21954/// // execute the final call using `doit()`.
21955/// // Values shown here are possibly random and not representative !
21956/// let result = hub.projects().locations_schedules_create(req, "parent")
21957///              .schedule_id("amet.")
21958///              .doit().await;
21959/// # }
21960/// ```
21961pub struct ProjectLocationScheduleCreateCall<'a, C>
21962where
21963    C: 'a,
21964{
21965    hub: &'a AIPlatformNotebooks<C>,
21966    _request: Schedule,
21967    _parent: String,
21968    _schedule_id: Option<String>,
21969    _delegate: Option<&'a mut dyn common::Delegate>,
21970    _additional_params: HashMap<String, String>,
21971    _scopes: BTreeSet<String>,
21972}
21973
21974impl<'a, C> common::CallBuilder for ProjectLocationScheduleCreateCall<'a, C> {}
21975
21976impl<'a, C> ProjectLocationScheduleCreateCall<'a, C>
21977where
21978    C: common::Connector,
21979{
21980    /// Perform the operation you have build so far.
21981    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
21982        use std::borrow::Cow;
21983        use std::io::{Read, Seek};
21984
21985        use common::{url::Params, ToParts};
21986        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21987
21988        let mut dd = common::DefaultDelegate;
21989        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21990        dlg.begin(common::MethodInfo {
21991            id: "notebooks.projects.locations.schedules.create",
21992            http_method: hyper::Method::POST,
21993        });
21994
21995        for &field in ["alt", "parent", "scheduleId"].iter() {
21996            if self._additional_params.contains_key(field) {
21997                dlg.finished(false);
21998                return Err(common::Error::FieldClash(field));
21999            }
22000        }
22001
22002        let mut params = Params::with_capacity(5 + self._additional_params.len());
22003        params.push("parent", self._parent);
22004        if let Some(value) = self._schedule_id.as_ref() {
22005            params.push("scheduleId", value);
22006        }
22007
22008        params.extend(self._additional_params.iter());
22009
22010        params.push("alt", "json");
22011        let mut url = self.hub._base_url.clone() + "v1/{+parent}/schedules";
22012        if self._scopes.is_empty() {
22013            self._scopes
22014                .insert(Scope::CloudPlatform.as_ref().to_string());
22015        }
22016
22017        #[allow(clippy::single_element_loop)]
22018        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
22019            url = params.uri_replacement(url, param_name, find_this, true);
22020        }
22021        {
22022            let to_remove = ["parent"];
22023            params.remove_params(&to_remove);
22024        }
22025
22026        let url = params.parse_with_url(&url);
22027
22028        let mut json_mime_type = mime::APPLICATION_JSON;
22029        let mut request_value_reader = {
22030            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
22031            common::remove_json_null_values(&mut value);
22032            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
22033            serde_json::to_writer(&mut dst, &value).unwrap();
22034            dst
22035        };
22036        let request_size = request_value_reader
22037            .seek(std::io::SeekFrom::End(0))
22038            .unwrap();
22039        request_value_reader
22040            .seek(std::io::SeekFrom::Start(0))
22041            .unwrap();
22042
22043        loop {
22044            let token = match self
22045                .hub
22046                .auth
22047                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22048                .await
22049            {
22050                Ok(token) => token,
22051                Err(e) => match dlg.token(e) {
22052                    Ok(token) => token,
22053                    Err(e) => {
22054                        dlg.finished(false);
22055                        return Err(common::Error::MissingToken(e));
22056                    }
22057                },
22058            };
22059            request_value_reader
22060                .seek(std::io::SeekFrom::Start(0))
22061                .unwrap();
22062            let mut req_result = {
22063                let client = &self.hub.client;
22064                dlg.pre_request();
22065                let mut req_builder = hyper::Request::builder()
22066                    .method(hyper::Method::POST)
22067                    .uri(url.as_str())
22068                    .header(USER_AGENT, self.hub._user_agent.clone());
22069
22070                if let Some(token) = token.as_ref() {
22071                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22072                }
22073
22074                let request = req_builder
22075                    .header(CONTENT_TYPE, json_mime_type.to_string())
22076                    .header(CONTENT_LENGTH, request_size as u64)
22077                    .body(common::to_body(
22078                        request_value_reader.get_ref().clone().into(),
22079                    ));
22080
22081                client.request(request.unwrap()).await
22082            };
22083
22084            match req_result {
22085                Err(err) => {
22086                    if let common::Retry::After(d) = dlg.http_error(&err) {
22087                        sleep(d).await;
22088                        continue;
22089                    }
22090                    dlg.finished(false);
22091                    return Err(common::Error::HttpError(err));
22092                }
22093                Ok(res) => {
22094                    let (mut parts, body) = res.into_parts();
22095                    let mut body = common::Body::new(body);
22096                    if !parts.status.is_success() {
22097                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22098                        let error = serde_json::from_str(&common::to_string(&bytes));
22099                        let response = common::to_response(parts, bytes.into());
22100
22101                        if let common::Retry::After(d) =
22102                            dlg.http_failure(&response, error.as_ref().ok())
22103                        {
22104                            sleep(d).await;
22105                            continue;
22106                        }
22107
22108                        dlg.finished(false);
22109
22110                        return Err(match error {
22111                            Ok(value) => common::Error::BadRequest(value),
22112                            _ => common::Error::Failure(response),
22113                        });
22114                    }
22115                    let response = {
22116                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22117                        let encoded = common::to_string(&bytes);
22118                        match serde_json::from_str(&encoded) {
22119                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22120                            Err(error) => {
22121                                dlg.response_json_decode_error(&encoded, &error);
22122                                return Err(common::Error::JsonDecodeError(
22123                                    encoded.to_string(),
22124                                    error,
22125                                ));
22126                            }
22127                        }
22128                    };
22129
22130                    dlg.finished(true);
22131                    return Ok(response);
22132                }
22133            }
22134        }
22135    }
22136
22137    ///
22138    /// Sets the *request* property to the given value.
22139    ///
22140    /// Even though the property as already been set when instantiating this call,
22141    /// we provide this method for API completeness.
22142    pub fn request(mut self, new_value: Schedule) -> ProjectLocationScheduleCreateCall<'a, C> {
22143        self._request = new_value;
22144        self
22145    }
22146    /// Required. Format: `parent=projects/{project_id}/locations/{location}`
22147    ///
22148    /// Sets the *parent* path property to the given value.
22149    ///
22150    /// Even though the property as already been set when instantiating this call,
22151    /// we provide this method for API completeness.
22152    pub fn parent(mut self, new_value: &str) -> ProjectLocationScheduleCreateCall<'a, C> {
22153        self._parent = new_value.to_string();
22154        self
22155    }
22156    /// Required. User-defined unique ID of this schedule.
22157    ///
22158    /// Sets the *schedule id* query property to the given value.
22159    pub fn schedule_id(mut self, new_value: &str) -> ProjectLocationScheduleCreateCall<'a, C> {
22160        self._schedule_id = Some(new_value.to_string());
22161        self
22162    }
22163    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22164    /// while executing the actual API request.
22165    ///
22166    /// ````text
22167    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22168    /// ````
22169    ///
22170    /// Sets the *delegate* property to the given value.
22171    pub fn delegate(
22172        mut self,
22173        new_value: &'a mut dyn common::Delegate,
22174    ) -> ProjectLocationScheduleCreateCall<'a, C> {
22175        self._delegate = Some(new_value);
22176        self
22177    }
22178
22179    /// Set any additional parameter of the query string used in the request.
22180    /// It should be used to set parameters which are not yet available through their own
22181    /// setters.
22182    ///
22183    /// Please note that this method must not be used to set any of the known parameters
22184    /// which have their own setter method. If done anyway, the request will fail.
22185    ///
22186    /// # Additional Parameters
22187    ///
22188    /// * *$.xgafv* (query-string) - V1 error format.
22189    /// * *access_token* (query-string) - OAuth access token.
22190    /// * *alt* (query-string) - Data format for response.
22191    /// * *callback* (query-string) - JSONP
22192    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22193    /// * *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.
22194    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22195    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22196    /// * *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.
22197    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22198    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22199    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationScheduleCreateCall<'a, C>
22200    where
22201        T: AsRef<str>,
22202    {
22203        self._additional_params
22204            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22205        self
22206    }
22207
22208    /// Identifies the authorization scope for the method you are building.
22209    ///
22210    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22211    /// [`Scope::CloudPlatform`].
22212    ///
22213    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22214    /// tokens for more than one scope.
22215    ///
22216    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22217    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22218    /// sufficient, a read-write scope will do as well.
22219    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationScheduleCreateCall<'a, C>
22220    where
22221        St: AsRef<str>,
22222    {
22223        self._scopes.insert(String::from(scope.as_ref()));
22224        self
22225    }
22226    /// Identifies the authorization scope(s) for the method you are building.
22227    ///
22228    /// See [`Self::add_scope()`] for details.
22229    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationScheduleCreateCall<'a, C>
22230    where
22231        I: IntoIterator<Item = St>,
22232        St: AsRef<str>,
22233    {
22234        self._scopes
22235            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22236        self
22237    }
22238
22239    /// Removes all scopes, and no default scope will be used either.
22240    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22241    /// for details).
22242    pub fn clear_scopes(mut self) -> ProjectLocationScheduleCreateCall<'a, C> {
22243        self._scopes.clear();
22244        self
22245    }
22246}
22247
22248/// Deletes schedule and all underlying jobs
22249///
22250/// A builder for the *locations.schedules.delete* method supported by a *project* resource.
22251/// It is not used directly, but through a [`ProjectMethods`] instance.
22252///
22253/// # Example
22254///
22255/// Instantiate a resource method builder
22256///
22257/// ```test_harness,no_run
22258/// # extern crate hyper;
22259/// # extern crate hyper_rustls;
22260/// # extern crate google_notebooks1 as notebooks1;
22261/// # async fn dox() {
22262/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22263///
22264/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22265/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22266/// #     .with_native_roots()
22267/// #     .unwrap()
22268/// #     .https_only()
22269/// #     .enable_http2()
22270/// #     .build();
22271///
22272/// # let executor = hyper_util::rt::TokioExecutor::new();
22273/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22274/// #     secret,
22275/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22276/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
22277/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
22278/// #     ),
22279/// # ).build().await.unwrap();
22280///
22281/// # let client = hyper_util::client::legacy::Client::builder(
22282/// #     hyper_util::rt::TokioExecutor::new()
22283/// # )
22284/// # .build(
22285/// #     hyper_rustls::HttpsConnectorBuilder::new()
22286/// #         .with_native_roots()
22287/// #         .unwrap()
22288/// #         .https_or_http()
22289/// #         .enable_http2()
22290/// #         .build()
22291/// # );
22292/// # let mut hub = AIPlatformNotebooks::new(client, auth);
22293/// // You can configure optional parameters by calling the respective setters at will, and
22294/// // execute the final call using `doit()`.
22295/// // Values shown here are possibly random and not representative !
22296/// let result = hub.projects().locations_schedules_delete("name")
22297///              .doit().await;
22298/// # }
22299/// ```
22300pub struct ProjectLocationScheduleDeleteCall<'a, C>
22301where
22302    C: 'a,
22303{
22304    hub: &'a AIPlatformNotebooks<C>,
22305    _name: String,
22306    _delegate: Option<&'a mut dyn common::Delegate>,
22307    _additional_params: HashMap<String, String>,
22308    _scopes: BTreeSet<String>,
22309}
22310
22311impl<'a, C> common::CallBuilder for ProjectLocationScheduleDeleteCall<'a, C> {}
22312
22313impl<'a, C> ProjectLocationScheduleDeleteCall<'a, C>
22314where
22315    C: common::Connector,
22316{
22317    /// Perform the operation you have build so far.
22318    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
22319        use std::borrow::Cow;
22320        use std::io::{Read, Seek};
22321
22322        use common::{url::Params, ToParts};
22323        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22324
22325        let mut dd = common::DefaultDelegate;
22326        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22327        dlg.begin(common::MethodInfo {
22328            id: "notebooks.projects.locations.schedules.delete",
22329            http_method: hyper::Method::DELETE,
22330        });
22331
22332        for &field in ["alt", "name"].iter() {
22333            if self._additional_params.contains_key(field) {
22334                dlg.finished(false);
22335                return Err(common::Error::FieldClash(field));
22336            }
22337        }
22338
22339        let mut params = Params::with_capacity(3 + self._additional_params.len());
22340        params.push("name", self._name);
22341
22342        params.extend(self._additional_params.iter());
22343
22344        params.push("alt", "json");
22345        let mut url = self.hub._base_url.clone() + "v1/{+name}";
22346        if self._scopes.is_empty() {
22347            self._scopes
22348                .insert(Scope::CloudPlatform.as_ref().to_string());
22349        }
22350
22351        #[allow(clippy::single_element_loop)]
22352        for &(find_this, param_name) in [("{+name}", "name")].iter() {
22353            url = params.uri_replacement(url, param_name, find_this, true);
22354        }
22355        {
22356            let to_remove = ["name"];
22357            params.remove_params(&to_remove);
22358        }
22359
22360        let url = params.parse_with_url(&url);
22361
22362        loop {
22363            let token = match self
22364                .hub
22365                .auth
22366                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22367                .await
22368            {
22369                Ok(token) => token,
22370                Err(e) => match dlg.token(e) {
22371                    Ok(token) => token,
22372                    Err(e) => {
22373                        dlg.finished(false);
22374                        return Err(common::Error::MissingToken(e));
22375                    }
22376                },
22377            };
22378            let mut req_result = {
22379                let client = &self.hub.client;
22380                dlg.pre_request();
22381                let mut req_builder = hyper::Request::builder()
22382                    .method(hyper::Method::DELETE)
22383                    .uri(url.as_str())
22384                    .header(USER_AGENT, self.hub._user_agent.clone());
22385
22386                if let Some(token) = token.as_ref() {
22387                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22388                }
22389
22390                let request = req_builder
22391                    .header(CONTENT_LENGTH, 0_u64)
22392                    .body(common::to_body::<String>(None));
22393
22394                client.request(request.unwrap()).await
22395            };
22396
22397            match req_result {
22398                Err(err) => {
22399                    if let common::Retry::After(d) = dlg.http_error(&err) {
22400                        sleep(d).await;
22401                        continue;
22402                    }
22403                    dlg.finished(false);
22404                    return Err(common::Error::HttpError(err));
22405                }
22406                Ok(res) => {
22407                    let (mut parts, body) = res.into_parts();
22408                    let mut body = common::Body::new(body);
22409                    if !parts.status.is_success() {
22410                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22411                        let error = serde_json::from_str(&common::to_string(&bytes));
22412                        let response = common::to_response(parts, bytes.into());
22413
22414                        if let common::Retry::After(d) =
22415                            dlg.http_failure(&response, error.as_ref().ok())
22416                        {
22417                            sleep(d).await;
22418                            continue;
22419                        }
22420
22421                        dlg.finished(false);
22422
22423                        return Err(match error {
22424                            Ok(value) => common::Error::BadRequest(value),
22425                            _ => common::Error::Failure(response),
22426                        });
22427                    }
22428                    let response = {
22429                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22430                        let encoded = common::to_string(&bytes);
22431                        match serde_json::from_str(&encoded) {
22432                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22433                            Err(error) => {
22434                                dlg.response_json_decode_error(&encoded, &error);
22435                                return Err(common::Error::JsonDecodeError(
22436                                    encoded.to_string(),
22437                                    error,
22438                                ));
22439                            }
22440                        }
22441                    };
22442
22443                    dlg.finished(true);
22444                    return Ok(response);
22445                }
22446            }
22447        }
22448    }
22449
22450    /// Required. Format: `projects/{project_id}/locations/{location}/schedules/{schedule_id}`
22451    ///
22452    /// Sets the *name* path property to the given value.
22453    ///
22454    /// Even though the property as already been set when instantiating this call,
22455    /// we provide this method for API completeness.
22456    pub fn name(mut self, new_value: &str) -> ProjectLocationScheduleDeleteCall<'a, C> {
22457        self._name = new_value.to_string();
22458        self
22459    }
22460    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22461    /// while executing the actual API request.
22462    ///
22463    /// ````text
22464    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22465    /// ````
22466    ///
22467    /// Sets the *delegate* property to the given value.
22468    pub fn delegate(
22469        mut self,
22470        new_value: &'a mut dyn common::Delegate,
22471    ) -> ProjectLocationScheduleDeleteCall<'a, C> {
22472        self._delegate = Some(new_value);
22473        self
22474    }
22475
22476    /// Set any additional parameter of the query string used in the request.
22477    /// It should be used to set parameters which are not yet available through their own
22478    /// setters.
22479    ///
22480    /// Please note that this method must not be used to set any of the known parameters
22481    /// which have their own setter method. If done anyway, the request will fail.
22482    ///
22483    /// # Additional Parameters
22484    ///
22485    /// * *$.xgafv* (query-string) - V1 error format.
22486    /// * *access_token* (query-string) - OAuth access token.
22487    /// * *alt* (query-string) - Data format for response.
22488    /// * *callback* (query-string) - JSONP
22489    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22490    /// * *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.
22491    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22492    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22493    /// * *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.
22494    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22495    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22496    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationScheduleDeleteCall<'a, C>
22497    where
22498        T: AsRef<str>,
22499    {
22500        self._additional_params
22501            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22502        self
22503    }
22504
22505    /// Identifies the authorization scope for the method you are building.
22506    ///
22507    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22508    /// [`Scope::CloudPlatform`].
22509    ///
22510    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22511    /// tokens for more than one scope.
22512    ///
22513    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22514    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22515    /// sufficient, a read-write scope will do as well.
22516    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationScheduleDeleteCall<'a, C>
22517    where
22518        St: AsRef<str>,
22519    {
22520        self._scopes.insert(String::from(scope.as_ref()));
22521        self
22522    }
22523    /// Identifies the authorization scope(s) for the method you are building.
22524    ///
22525    /// See [`Self::add_scope()`] for details.
22526    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationScheduleDeleteCall<'a, C>
22527    where
22528        I: IntoIterator<Item = St>,
22529        St: AsRef<str>,
22530    {
22531        self._scopes
22532            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22533        self
22534    }
22535
22536    /// Removes all scopes, and no default scope will be used either.
22537    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22538    /// for details).
22539    pub fn clear_scopes(mut self) -> ProjectLocationScheduleDeleteCall<'a, C> {
22540        self._scopes.clear();
22541        self
22542    }
22543}
22544
22545/// Gets details of schedule
22546///
22547/// A builder for the *locations.schedules.get* method supported by a *project* resource.
22548/// It is not used directly, but through a [`ProjectMethods`] instance.
22549///
22550/// # Example
22551///
22552/// Instantiate a resource method builder
22553///
22554/// ```test_harness,no_run
22555/// # extern crate hyper;
22556/// # extern crate hyper_rustls;
22557/// # extern crate google_notebooks1 as notebooks1;
22558/// # async fn dox() {
22559/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22560///
22561/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22562/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22563/// #     .with_native_roots()
22564/// #     .unwrap()
22565/// #     .https_only()
22566/// #     .enable_http2()
22567/// #     .build();
22568///
22569/// # let executor = hyper_util::rt::TokioExecutor::new();
22570/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22571/// #     secret,
22572/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22573/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
22574/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
22575/// #     ),
22576/// # ).build().await.unwrap();
22577///
22578/// # let client = hyper_util::client::legacy::Client::builder(
22579/// #     hyper_util::rt::TokioExecutor::new()
22580/// # )
22581/// # .build(
22582/// #     hyper_rustls::HttpsConnectorBuilder::new()
22583/// #         .with_native_roots()
22584/// #         .unwrap()
22585/// #         .https_or_http()
22586/// #         .enable_http2()
22587/// #         .build()
22588/// # );
22589/// # let mut hub = AIPlatformNotebooks::new(client, auth);
22590/// // You can configure optional parameters by calling the respective setters at will, and
22591/// // execute the final call using `doit()`.
22592/// // Values shown here are possibly random and not representative !
22593/// let result = hub.projects().locations_schedules_get("name")
22594///              .doit().await;
22595/// # }
22596/// ```
22597pub struct ProjectLocationScheduleGetCall<'a, C>
22598where
22599    C: 'a,
22600{
22601    hub: &'a AIPlatformNotebooks<C>,
22602    _name: String,
22603    _delegate: Option<&'a mut dyn common::Delegate>,
22604    _additional_params: HashMap<String, String>,
22605    _scopes: BTreeSet<String>,
22606}
22607
22608impl<'a, C> common::CallBuilder for ProjectLocationScheduleGetCall<'a, C> {}
22609
22610impl<'a, C> ProjectLocationScheduleGetCall<'a, C>
22611where
22612    C: common::Connector,
22613{
22614    /// Perform the operation you have build so far.
22615    pub async fn doit(mut self) -> common::Result<(common::Response, Schedule)> {
22616        use std::borrow::Cow;
22617        use std::io::{Read, Seek};
22618
22619        use common::{url::Params, ToParts};
22620        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22621
22622        let mut dd = common::DefaultDelegate;
22623        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22624        dlg.begin(common::MethodInfo {
22625            id: "notebooks.projects.locations.schedules.get",
22626            http_method: hyper::Method::GET,
22627        });
22628
22629        for &field in ["alt", "name"].iter() {
22630            if self._additional_params.contains_key(field) {
22631                dlg.finished(false);
22632                return Err(common::Error::FieldClash(field));
22633            }
22634        }
22635
22636        let mut params = Params::with_capacity(3 + self._additional_params.len());
22637        params.push("name", self._name);
22638
22639        params.extend(self._additional_params.iter());
22640
22641        params.push("alt", "json");
22642        let mut url = self.hub._base_url.clone() + "v1/{+name}";
22643        if self._scopes.is_empty() {
22644            self._scopes
22645                .insert(Scope::CloudPlatform.as_ref().to_string());
22646        }
22647
22648        #[allow(clippy::single_element_loop)]
22649        for &(find_this, param_name) in [("{+name}", "name")].iter() {
22650            url = params.uri_replacement(url, param_name, find_this, true);
22651        }
22652        {
22653            let to_remove = ["name"];
22654            params.remove_params(&to_remove);
22655        }
22656
22657        let url = params.parse_with_url(&url);
22658
22659        loop {
22660            let token = match self
22661                .hub
22662                .auth
22663                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22664                .await
22665            {
22666                Ok(token) => token,
22667                Err(e) => match dlg.token(e) {
22668                    Ok(token) => token,
22669                    Err(e) => {
22670                        dlg.finished(false);
22671                        return Err(common::Error::MissingToken(e));
22672                    }
22673                },
22674            };
22675            let mut req_result = {
22676                let client = &self.hub.client;
22677                dlg.pre_request();
22678                let mut req_builder = hyper::Request::builder()
22679                    .method(hyper::Method::GET)
22680                    .uri(url.as_str())
22681                    .header(USER_AGENT, self.hub._user_agent.clone());
22682
22683                if let Some(token) = token.as_ref() {
22684                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22685                }
22686
22687                let request = req_builder
22688                    .header(CONTENT_LENGTH, 0_u64)
22689                    .body(common::to_body::<String>(None));
22690
22691                client.request(request.unwrap()).await
22692            };
22693
22694            match req_result {
22695                Err(err) => {
22696                    if let common::Retry::After(d) = dlg.http_error(&err) {
22697                        sleep(d).await;
22698                        continue;
22699                    }
22700                    dlg.finished(false);
22701                    return Err(common::Error::HttpError(err));
22702                }
22703                Ok(res) => {
22704                    let (mut parts, body) = res.into_parts();
22705                    let mut body = common::Body::new(body);
22706                    if !parts.status.is_success() {
22707                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22708                        let error = serde_json::from_str(&common::to_string(&bytes));
22709                        let response = common::to_response(parts, bytes.into());
22710
22711                        if let common::Retry::After(d) =
22712                            dlg.http_failure(&response, error.as_ref().ok())
22713                        {
22714                            sleep(d).await;
22715                            continue;
22716                        }
22717
22718                        dlg.finished(false);
22719
22720                        return Err(match error {
22721                            Ok(value) => common::Error::BadRequest(value),
22722                            _ => common::Error::Failure(response),
22723                        });
22724                    }
22725                    let response = {
22726                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22727                        let encoded = common::to_string(&bytes);
22728                        match serde_json::from_str(&encoded) {
22729                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22730                            Err(error) => {
22731                                dlg.response_json_decode_error(&encoded, &error);
22732                                return Err(common::Error::JsonDecodeError(
22733                                    encoded.to_string(),
22734                                    error,
22735                                ));
22736                            }
22737                        }
22738                    };
22739
22740                    dlg.finished(true);
22741                    return Ok(response);
22742                }
22743            }
22744        }
22745    }
22746
22747    /// Required. Format: `projects/{project_id}/locations/{location}/schedules/{schedule_id}`
22748    ///
22749    /// Sets the *name* path property to the given value.
22750    ///
22751    /// Even though the property as already been set when instantiating this call,
22752    /// we provide this method for API completeness.
22753    pub fn name(mut self, new_value: &str) -> ProjectLocationScheduleGetCall<'a, C> {
22754        self._name = new_value.to_string();
22755        self
22756    }
22757    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22758    /// while executing the actual API request.
22759    ///
22760    /// ````text
22761    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22762    /// ````
22763    ///
22764    /// Sets the *delegate* property to the given value.
22765    pub fn delegate(
22766        mut self,
22767        new_value: &'a mut dyn common::Delegate,
22768    ) -> ProjectLocationScheduleGetCall<'a, C> {
22769        self._delegate = Some(new_value);
22770        self
22771    }
22772
22773    /// Set any additional parameter of the query string used in the request.
22774    /// It should be used to set parameters which are not yet available through their own
22775    /// setters.
22776    ///
22777    /// Please note that this method must not be used to set any of the known parameters
22778    /// which have their own setter method. If done anyway, the request will fail.
22779    ///
22780    /// # Additional Parameters
22781    ///
22782    /// * *$.xgafv* (query-string) - V1 error format.
22783    /// * *access_token* (query-string) - OAuth access token.
22784    /// * *alt* (query-string) - Data format for response.
22785    /// * *callback* (query-string) - JSONP
22786    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22787    /// * *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.
22788    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22789    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22790    /// * *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.
22791    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22792    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22793    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationScheduleGetCall<'a, C>
22794    where
22795        T: AsRef<str>,
22796    {
22797        self._additional_params
22798            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22799        self
22800    }
22801
22802    /// Identifies the authorization scope for the method you are building.
22803    ///
22804    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22805    /// [`Scope::CloudPlatform`].
22806    ///
22807    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22808    /// tokens for more than one scope.
22809    ///
22810    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22811    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22812    /// sufficient, a read-write scope will do as well.
22813    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationScheduleGetCall<'a, C>
22814    where
22815        St: AsRef<str>,
22816    {
22817        self._scopes.insert(String::from(scope.as_ref()));
22818        self
22819    }
22820    /// Identifies the authorization scope(s) for the method you are building.
22821    ///
22822    /// See [`Self::add_scope()`] for details.
22823    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationScheduleGetCall<'a, C>
22824    where
22825        I: IntoIterator<Item = St>,
22826        St: AsRef<str>,
22827    {
22828        self._scopes
22829            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22830        self
22831    }
22832
22833    /// Removes all scopes, and no default scope will be used either.
22834    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22835    /// for details).
22836    pub fn clear_scopes(mut self) -> ProjectLocationScheduleGetCall<'a, C> {
22837        self._scopes.clear();
22838        self
22839    }
22840}
22841
22842/// Lists schedules in a given project and location.
22843///
22844/// A builder for the *locations.schedules.list* method supported by a *project* resource.
22845/// It is not used directly, but through a [`ProjectMethods`] instance.
22846///
22847/// # Example
22848///
22849/// Instantiate a resource method builder
22850///
22851/// ```test_harness,no_run
22852/// # extern crate hyper;
22853/// # extern crate hyper_rustls;
22854/// # extern crate google_notebooks1 as notebooks1;
22855/// # async fn dox() {
22856/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22857///
22858/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22859/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22860/// #     .with_native_roots()
22861/// #     .unwrap()
22862/// #     .https_only()
22863/// #     .enable_http2()
22864/// #     .build();
22865///
22866/// # let executor = hyper_util::rt::TokioExecutor::new();
22867/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22868/// #     secret,
22869/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22870/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
22871/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
22872/// #     ),
22873/// # ).build().await.unwrap();
22874///
22875/// # let client = hyper_util::client::legacy::Client::builder(
22876/// #     hyper_util::rt::TokioExecutor::new()
22877/// # )
22878/// # .build(
22879/// #     hyper_rustls::HttpsConnectorBuilder::new()
22880/// #         .with_native_roots()
22881/// #         .unwrap()
22882/// #         .https_or_http()
22883/// #         .enable_http2()
22884/// #         .build()
22885/// # );
22886/// # let mut hub = AIPlatformNotebooks::new(client, auth);
22887/// // You can configure optional parameters by calling the respective setters at will, and
22888/// // execute the final call using `doit()`.
22889/// // Values shown here are possibly random and not representative !
22890/// let result = hub.projects().locations_schedules_list("parent")
22891///              .page_token("invidunt")
22892///              .page_size(-11)
22893///              .order_by("est")
22894///              .filter("At")
22895///              .doit().await;
22896/// # }
22897/// ```
22898pub struct ProjectLocationScheduleListCall<'a, C>
22899where
22900    C: 'a,
22901{
22902    hub: &'a AIPlatformNotebooks<C>,
22903    _parent: String,
22904    _page_token: Option<String>,
22905    _page_size: Option<i32>,
22906    _order_by: Option<String>,
22907    _filter: Option<String>,
22908    _delegate: Option<&'a mut dyn common::Delegate>,
22909    _additional_params: HashMap<String, String>,
22910    _scopes: BTreeSet<String>,
22911}
22912
22913impl<'a, C> common::CallBuilder for ProjectLocationScheduleListCall<'a, C> {}
22914
22915impl<'a, C> ProjectLocationScheduleListCall<'a, C>
22916where
22917    C: common::Connector,
22918{
22919    /// Perform the operation you have build so far.
22920    pub async fn doit(mut self) -> common::Result<(common::Response, ListSchedulesResponse)> {
22921        use std::borrow::Cow;
22922        use std::io::{Read, Seek};
22923
22924        use common::{url::Params, ToParts};
22925        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22926
22927        let mut dd = common::DefaultDelegate;
22928        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22929        dlg.begin(common::MethodInfo {
22930            id: "notebooks.projects.locations.schedules.list",
22931            http_method: hyper::Method::GET,
22932        });
22933
22934        for &field in [
22935            "alt",
22936            "parent",
22937            "pageToken",
22938            "pageSize",
22939            "orderBy",
22940            "filter",
22941        ]
22942        .iter()
22943        {
22944            if self._additional_params.contains_key(field) {
22945                dlg.finished(false);
22946                return Err(common::Error::FieldClash(field));
22947            }
22948        }
22949
22950        let mut params = Params::with_capacity(7 + self._additional_params.len());
22951        params.push("parent", self._parent);
22952        if let Some(value) = self._page_token.as_ref() {
22953            params.push("pageToken", value);
22954        }
22955        if let Some(value) = self._page_size.as_ref() {
22956            params.push("pageSize", value.to_string());
22957        }
22958        if let Some(value) = self._order_by.as_ref() {
22959            params.push("orderBy", value);
22960        }
22961        if let Some(value) = self._filter.as_ref() {
22962            params.push("filter", value);
22963        }
22964
22965        params.extend(self._additional_params.iter());
22966
22967        params.push("alt", "json");
22968        let mut url = self.hub._base_url.clone() + "v1/{+parent}/schedules";
22969        if self._scopes.is_empty() {
22970            self._scopes
22971                .insert(Scope::CloudPlatform.as_ref().to_string());
22972        }
22973
22974        #[allow(clippy::single_element_loop)]
22975        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
22976            url = params.uri_replacement(url, param_name, find_this, true);
22977        }
22978        {
22979            let to_remove = ["parent"];
22980            params.remove_params(&to_remove);
22981        }
22982
22983        let url = params.parse_with_url(&url);
22984
22985        loop {
22986            let token = match self
22987                .hub
22988                .auth
22989                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22990                .await
22991            {
22992                Ok(token) => token,
22993                Err(e) => match dlg.token(e) {
22994                    Ok(token) => token,
22995                    Err(e) => {
22996                        dlg.finished(false);
22997                        return Err(common::Error::MissingToken(e));
22998                    }
22999                },
23000            };
23001            let mut req_result = {
23002                let client = &self.hub.client;
23003                dlg.pre_request();
23004                let mut req_builder = hyper::Request::builder()
23005                    .method(hyper::Method::GET)
23006                    .uri(url.as_str())
23007                    .header(USER_AGENT, self.hub._user_agent.clone());
23008
23009                if let Some(token) = token.as_ref() {
23010                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23011                }
23012
23013                let request = req_builder
23014                    .header(CONTENT_LENGTH, 0_u64)
23015                    .body(common::to_body::<String>(None));
23016
23017                client.request(request.unwrap()).await
23018            };
23019
23020            match req_result {
23021                Err(err) => {
23022                    if let common::Retry::After(d) = dlg.http_error(&err) {
23023                        sleep(d).await;
23024                        continue;
23025                    }
23026                    dlg.finished(false);
23027                    return Err(common::Error::HttpError(err));
23028                }
23029                Ok(res) => {
23030                    let (mut parts, body) = res.into_parts();
23031                    let mut body = common::Body::new(body);
23032                    if !parts.status.is_success() {
23033                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23034                        let error = serde_json::from_str(&common::to_string(&bytes));
23035                        let response = common::to_response(parts, bytes.into());
23036
23037                        if let common::Retry::After(d) =
23038                            dlg.http_failure(&response, error.as_ref().ok())
23039                        {
23040                            sleep(d).await;
23041                            continue;
23042                        }
23043
23044                        dlg.finished(false);
23045
23046                        return Err(match error {
23047                            Ok(value) => common::Error::BadRequest(value),
23048                            _ => common::Error::Failure(response),
23049                        });
23050                    }
23051                    let response = {
23052                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23053                        let encoded = common::to_string(&bytes);
23054                        match serde_json::from_str(&encoded) {
23055                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23056                            Err(error) => {
23057                                dlg.response_json_decode_error(&encoded, &error);
23058                                return Err(common::Error::JsonDecodeError(
23059                                    encoded.to_string(),
23060                                    error,
23061                                ));
23062                            }
23063                        }
23064                    };
23065
23066                    dlg.finished(true);
23067                    return Ok(response);
23068                }
23069            }
23070        }
23071    }
23072
23073    /// Required. Format: `parent=projects/{project_id}/locations/{location}`
23074    ///
23075    /// Sets the *parent* path property to the given value.
23076    ///
23077    /// Even though the property as already been set when instantiating this call,
23078    /// we provide this method for API completeness.
23079    pub fn parent(mut self, new_value: &str) -> ProjectLocationScheduleListCall<'a, C> {
23080        self._parent = new_value.to_string();
23081        self
23082    }
23083    /// A previous returned page token that can be used to continue listing from the last result.
23084    ///
23085    /// Sets the *page token* query property to the given value.
23086    pub fn page_token(mut self, new_value: &str) -> ProjectLocationScheduleListCall<'a, C> {
23087        self._page_token = Some(new_value.to_string());
23088        self
23089    }
23090    /// Maximum return size of the list call.
23091    ///
23092    /// Sets the *page size* query property to the given value.
23093    pub fn page_size(mut self, new_value: i32) -> ProjectLocationScheduleListCall<'a, C> {
23094        self._page_size = Some(new_value);
23095        self
23096    }
23097    /// Field to order results by.
23098    ///
23099    /// Sets the *order by* query property to the given value.
23100    pub fn order_by(mut self, new_value: &str) -> ProjectLocationScheduleListCall<'a, C> {
23101        self._order_by = Some(new_value.to_string());
23102        self
23103    }
23104    /// Filter applied to resulting schedules.
23105    ///
23106    /// Sets the *filter* query property to the given value.
23107    pub fn filter(mut self, new_value: &str) -> ProjectLocationScheduleListCall<'a, C> {
23108        self._filter = Some(new_value.to_string());
23109        self
23110    }
23111    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23112    /// while executing the actual API request.
23113    ///
23114    /// ````text
23115    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
23116    /// ````
23117    ///
23118    /// Sets the *delegate* property to the given value.
23119    pub fn delegate(
23120        mut self,
23121        new_value: &'a mut dyn common::Delegate,
23122    ) -> ProjectLocationScheduleListCall<'a, C> {
23123        self._delegate = Some(new_value);
23124        self
23125    }
23126
23127    /// Set any additional parameter of the query string used in the request.
23128    /// It should be used to set parameters which are not yet available through their own
23129    /// setters.
23130    ///
23131    /// Please note that this method must not be used to set any of the known parameters
23132    /// which have their own setter method. If done anyway, the request will fail.
23133    ///
23134    /// # Additional Parameters
23135    ///
23136    /// * *$.xgafv* (query-string) - V1 error format.
23137    /// * *access_token* (query-string) - OAuth access token.
23138    /// * *alt* (query-string) - Data format for response.
23139    /// * *callback* (query-string) - JSONP
23140    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23141    /// * *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.
23142    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23143    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23144    /// * *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.
23145    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23146    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23147    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationScheduleListCall<'a, C>
23148    where
23149        T: AsRef<str>,
23150    {
23151        self._additional_params
23152            .insert(name.as_ref().to_string(), value.as_ref().to_string());
23153        self
23154    }
23155
23156    /// Identifies the authorization scope for the method you are building.
23157    ///
23158    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23159    /// [`Scope::CloudPlatform`].
23160    ///
23161    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23162    /// tokens for more than one scope.
23163    ///
23164    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23165    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23166    /// sufficient, a read-write scope will do as well.
23167    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationScheduleListCall<'a, C>
23168    where
23169        St: AsRef<str>,
23170    {
23171        self._scopes.insert(String::from(scope.as_ref()));
23172        self
23173    }
23174    /// Identifies the authorization scope(s) for the method you are building.
23175    ///
23176    /// See [`Self::add_scope()`] for details.
23177    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationScheduleListCall<'a, C>
23178    where
23179        I: IntoIterator<Item = St>,
23180        St: AsRef<str>,
23181    {
23182        self._scopes
23183            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23184        self
23185    }
23186
23187    /// Removes all scopes, and no default scope will be used either.
23188    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23189    /// for details).
23190    pub fn clear_scopes(mut self) -> ProjectLocationScheduleListCall<'a, C> {
23191        self._scopes.clear();
23192        self
23193    }
23194}
23195
23196/// Triggers execution of an existing schedule.
23197///
23198/// A builder for the *locations.schedules.trigger* method supported by a *project* resource.
23199/// It is not used directly, but through a [`ProjectMethods`] instance.
23200///
23201/// # Example
23202///
23203/// Instantiate a resource method builder
23204///
23205/// ```test_harness,no_run
23206/// # extern crate hyper;
23207/// # extern crate hyper_rustls;
23208/// # extern crate google_notebooks1 as notebooks1;
23209/// use notebooks1::api::TriggerScheduleRequest;
23210/// # async fn dox() {
23211/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23212///
23213/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23214/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23215/// #     .with_native_roots()
23216/// #     .unwrap()
23217/// #     .https_only()
23218/// #     .enable_http2()
23219/// #     .build();
23220///
23221/// # let executor = hyper_util::rt::TokioExecutor::new();
23222/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23223/// #     secret,
23224/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23225/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
23226/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
23227/// #     ),
23228/// # ).build().await.unwrap();
23229///
23230/// # let client = hyper_util::client::legacy::Client::builder(
23231/// #     hyper_util::rt::TokioExecutor::new()
23232/// # )
23233/// # .build(
23234/// #     hyper_rustls::HttpsConnectorBuilder::new()
23235/// #         .with_native_roots()
23236/// #         .unwrap()
23237/// #         .https_or_http()
23238/// #         .enable_http2()
23239/// #         .build()
23240/// # );
23241/// # let mut hub = AIPlatformNotebooks::new(client, auth);
23242/// // As the method needs a request, you would usually fill it with the desired information
23243/// // into the respective structure. Some of the parts shown here might not be applicable !
23244/// // Values shown here are possibly random and not representative !
23245/// let mut req = TriggerScheduleRequest::default();
23246///
23247/// // You can configure optional parameters by calling the respective setters at will, and
23248/// // execute the final call using `doit()`.
23249/// // Values shown here are possibly random and not representative !
23250/// let result = hub.projects().locations_schedules_trigger(req, "name")
23251///              .doit().await;
23252/// # }
23253/// ```
23254pub struct ProjectLocationScheduleTriggerCall<'a, C>
23255where
23256    C: 'a,
23257{
23258    hub: &'a AIPlatformNotebooks<C>,
23259    _request: TriggerScheduleRequest,
23260    _name: String,
23261    _delegate: Option<&'a mut dyn common::Delegate>,
23262    _additional_params: HashMap<String, String>,
23263    _scopes: BTreeSet<String>,
23264}
23265
23266impl<'a, C> common::CallBuilder for ProjectLocationScheduleTriggerCall<'a, C> {}
23267
23268impl<'a, C> ProjectLocationScheduleTriggerCall<'a, C>
23269where
23270    C: common::Connector,
23271{
23272    /// Perform the operation you have build so far.
23273    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
23274        use std::borrow::Cow;
23275        use std::io::{Read, Seek};
23276
23277        use common::{url::Params, ToParts};
23278        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23279
23280        let mut dd = common::DefaultDelegate;
23281        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23282        dlg.begin(common::MethodInfo {
23283            id: "notebooks.projects.locations.schedules.trigger",
23284            http_method: hyper::Method::POST,
23285        });
23286
23287        for &field in ["alt", "name"].iter() {
23288            if self._additional_params.contains_key(field) {
23289                dlg.finished(false);
23290                return Err(common::Error::FieldClash(field));
23291            }
23292        }
23293
23294        let mut params = Params::with_capacity(4 + self._additional_params.len());
23295        params.push("name", self._name);
23296
23297        params.extend(self._additional_params.iter());
23298
23299        params.push("alt", "json");
23300        let mut url = self.hub._base_url.clone() + "v1/{+name}:trigger";
23301        if self._scopes.is_empty() {
23302            self._scopes
23303                .insert(Scope::CloudPlatform.as_ref().to_string());
23304        }
23305
23306        #[allow(clippy::single_element_loop)]
23307        for &(find_this, param_name) in [("{+name}", "name")].iter() {
23308            url = params.uri_replacement(url, param_name, find_this, true);
23309        }
23310        {
23311            let to_remove = ["name"];
23312            params.remove_params(&to_remove);
23313        }
23314
23315        let url = params.parse_with_url(&url);
23316
23317        let mut json_mime_type = mime::APPLICATION_JSON;
23318        let mut request_value_reader = {
23319            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
23320            common::remove_json_null_values(&mut value);
23321            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
23322            serde_json::to_writer(&mut dst, &value).unwrap();
23323            dst
23324        };
23325        let request_size = request_value_reader
23326            .seek(std::io::SeekFrom::End(0))
23327            .unwrap();
23328        request_value_reader
23329            .seek(std::io::SeekFrom::Start(0))
23330            .unwrap();
23331
23332        loop {
23333            let token = match self
23334                .hub
23335                .auth
23336                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23337                .await
23338            {
23339                Ok(token) => token,
23340                Err(e) => match dlg.token(e) {
23341                    Ok(token) => token,
23342                    Err(e) => {
23343                        dlg.finished(false);
23344                        return Err(common::Error::MissingToken(e));
23345                    }
23346                },
23347            };
23348            request_value_reader
23349                .seek(std::io::SeekFrom::Start(0))
23350                .unwrap();
23351            let mut req_result = {
23352                let client = &self.hub.client;
23353                dlg.pre_request();
23354                let mut req_builder = hyper::Request::builder()
23355                    .method(hyper::Method::POST)
23356                    .uri(url.as_str())
23357                    .header(USER_AGENT, self.hub._user_agent.clone());
23358
23359                if let Some(token) = token.as_ref() {
23360                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23361                }
23362
23363                let request = req_builder
23364                    .header(CONTENT_TYPE, json_mime_type.to_string())
23365                    .header(CONTENT_LENGTH, request_size as u64)
23366                    .body(common::to_body(
23367                        request_value_reader.get_ref().clone().into(),
23368                    ));
23369
23370                client.request(request.unwrap()).await
23371            };
23372
23373            match req_result {
23374                Err(err) => {
23375                    if let common::Retry::After(d) = dlg.http_error(&err) {
23376                        sleep(d).await;
23377                        continue;
23378                    }
23379                    dlg.finished(false);
23380                    return Err(common::Error::HttpError(err));
23381                }
23382                Ok(res) => {
23383                    let (mut parts, body) = res.into_parts();
23384                    let mut body = common::Body::new(body);
23385                    if !parts.status.is_success() {
23386                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23387                        let error = serde_json::from_str(&common::to_string(&bytes));
23388                        let response = common::to_response(parts, bytes.into());
23389
23390                        if let common::Retry::After(d) =
23391                            dlg.http_failure(&response, error.as_ref().ok())
23392                        {
23393                            sleep(d).await;
23394                            continue;
23395                        }
23396
23397                        dlg.finished(false);
23398
23399                        return Err(match error {
23400                            Ok(value) => common::Error::BadRequest(value),
23401                            _ => common::Error::Failure(response),
23402                        });
23403                    }
23404                    let response = {
23405                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23406                        let encoded = common::to_string(&bytes);
23407                        match serde_json::from_str(&encoded) {
23408                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23409                            Err(error) => {
23410                                dlg.response_json_decode_error(&encoded, &error);
23411                                return Err(common::Error::JsonDecodeError(
23412                                    encoded.to_string(),
23413                                    error,
23414                                ));
23415                            }
23416                        }
23417                    };
23418
23419                    dlg.finished(true);
23420                    return Ok(response);
23421                }
23422            }
23423        }
23424    }
23425
23426    ///
23427    /// Sets the *request* property to the given value.
23428    ///
23429    /// Even though the property as already been set when instantiating this call,
23430    /// we provide this method for API completeness.
23431    pub fn request(
23432        mut self,
23433        new_value: TriggerScheduleRequest,
23434    ) -> ProjectLocationScheduleTriggerCall<'a, C> {
23435        self._request = new_value;
23436        self
23437    }
23438    /// Required. Format: `parent=projects/{project_id}/locations/{location}/schedules/{schedule_id}`
23439    ///
23440    /// Sets the *name* path property to the given value.
23441    ///
23442    /// Even though the property as already been set when instantiating this call,
23443    /// we provide this method for API completeness.
23444    pub fn name(mut self, new_value: &str) -> ProjectLocationScheduleTriggerCall<'a, C> {
23445        self._name = new_value.to_string();
23446        self
23447    }
23448    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23449    /// while executing the actual API request.
23450    ///
23451    /// ````text
23452    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
23453    /// ````
23454    ///
23455    /// Sets the *delegate* property to the given value.
23456    pub fn delegate(
23457        mut self,
23458        new_value: &'a mut dyn common::Delegate,
23459    ) -> ProjectLocationScheduleTriggerCall<'a, C> {
23460        self._delegate = Some(new_value);
23461        self
23462    }
23463
23464    /// Set any additional parameter of the query string used in the request.
23465    /// It should be used to set parameters which are not yet available through their own
23466    /// setters.
23467    ///
23468    /// Please note that this method must not be used to set any of the known parameters
23469    /// which have their own setter method. If done anyway, the request will fail.
23470    ///
23471    /// # Additional Parameters
23472    ///
23473    /// * *$.xgafv* (query-string) - V1 error format.
23474    /// * *access_token* (query-string) - OAuth access token.
23475    /// * *alt* (query-string) - Data format for response.
23476    /// * *callback* (query-string) - JSONP
23477    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23478    /// * *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.
23479    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23480    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23481    /// * *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.
23482    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23483    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23484    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationScheduleTriggerCall<'a, C>
23485    where
23486        T: AsRef<str>,
23487    {
23488        self._additional_params
23489            .insert(name.as_ref().to_string(), value.as_ref().to_string());
23490        self
23491    }
23492
23493    /// Identifies the authorization scope for the method you are building.
23494    ///
23495    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23496    /// [`Scope::CloudPlatform`].
23497    ///
23498    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23499    /// tokens for more than one scope.
23500    ///
23501    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23502    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23503    /// sufficient, a read-write scope will do as well.
23504    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationScheduleTriggerCall<'a, C>
23505    where
23506        St: AsRef<str>,
23507    {
23508        self._scopes.insert(String::from(scope.as_ref()));
23509        self
23510    }
23511    /// Identifies the authorization scope(s) for the method you are building.
23512    ///
23513    /// See [`Self::add_scope()`] for details.
23514    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationScheduleTriggerCall<'a, C>
23515    where
23516        I: IntoIterator<Item = St>,
23517        St: AsRef<str>,
23518    {
23519        self._scopes
23520            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23521        self
23522    }
23523
23524    /// Removes all scopes, and no default scope will be used either.
23525    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23526    /// for details).
23527    pub fn clear_scopes(mut self) -> ProjectLocationScheduleTriggerCall<'a, C> {
23528        self._scopes.clear();
23529        self
23530    }
23531}
23532
23533/// Gets information about a location.
23534///
23535/// A builder for the *locations.get* method supported by a *project* resource.
23536/// It is not used directly, but through a [`ProjectMethods`] instance.
23537///
23538/// # Example
23539///
23540/// Instantiate a resource method builder
23541///
23542/// ```test_harness,no_run
23543/// # extern crate hyper;
23544/// # extern crate hyper_rustls;
23545/// # extern crate google_notebooks1 as notebooks1;
23546/// # async fn dox() {
23547/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23548///
23549/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23550/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23551/// #     .with_native_roots()
23552/// #     .unwrap()
23553/// #     .https_only()
23554/// #     .enable_http2()
23555/// #     .build();
23556///
23557/// # let executor = hyper_util::rt::TokioExecutor::new();
23558/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23559/// #     secret,
23560/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23561/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
23562/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
23563/// #     ),
23564/// # ).build().await.unwrap();
23565///
23566/// # let client = hyper_util::client::legacy::Client::builder(
23567/// #     hyper_util::rt::TokioExecutor::new()
23568/// # )
23569/// # .build(
23570/// #     hyper_rustls::HttpsConnectorBuilder::new()
23571/// #         .with_native_roots()
23572/// #         .unwrap()
23573/// #         .https_or_http()
23574/// #         .enable_http2()
23575/// #         .build()
23576/// # );
23577/// # let mut hub = AIPlatformNotebooks::new(client, auth);
23578/// // You can configure optional parameters by calling the respective setters at will, and
23579/// // execute the final call using `doit()`.
23580/// // Values shown here are possibly random and not representative !
23581/// let result = hub.projects().locations_get("name")
23582///              .doit().await;
23583/// # }
23584/// ```
23585pub struct ProjectLocationGetCall<'a, C>
23586where
23587    C: 'a,
23588{
23589    hub: &'a AIPlatformNotebooks<C>,
23590    _name: String,
23591    _delegate: Option<&'a mut dyn common::Delegate>,
23592    _additional_params: HashMap<String, String>,
23593    _scopes: BTreeSet<String>,
23594}
23595
23596impl<'a, C> common::CallBuilder for ProjectLocationGetCall<'a, C> {}
23597
23598impl<'a, C> ProjectLocationGetCall<'a, C>
23599where
23600    C: common::Connector,
23601{
23602    /// Perform the operation you have build so far.
23603    pub async fn doit(mut self) -> common::Result<(common::Response, Location)> {
23604        use std::borrow::Cow;
23605        use std::io::{Read, Seek};
23606
23607        use common::{url::Params, ToParts};
23608        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23609
23610        let mut dd = common::DefaultDelegate;
23611        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23612        dlg.begin(common::MethodInfo {
23613            id: "notebooks.projects.locations.get",
23614            http_method: hyper::Method::GET,
23615        });
23616
23617        for &field in ["alt", "name"].iter() {
23618            if self._additional_params.contains_key(field) {
23619                dlg.finished(false);
23620                return Err(common::Error::FieldClash(field));
23621            }
23622        }
23623
23624        let mut params = Params::with_capacity(3 + self._additional_params.len());
23625        params.push("name", self._name);
23626
23627        params.extend(self._additional_params.iter());
23628
23629        params.push("alt", "json");
23630        let mut url = self.hub._base_url.clone() + "v1/{+name}";
23631        if self._scopes.is_empty() {
23632            self._scopes
23633                .insert(Scope::CloudPlatform.as_ref().to_string());
23634        }
23635
23636        #[allow(clippy::single_element_loop)]
23637        for &(find_this, param_name) in [("{+name}", "name")].iter() {
23638            url = params.uri_replacement(url, param_name, find_this, true);
23639        }
23640        {
23641            let to_remove = ["name"];
23642            params.remove_params(&to_remove);
23643        }
23644
23645        let url = params.parse_with_url(&url);
23646
23647        loop {
23648            let token = match self
23649                .hub
23650                .auth
23651                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23652                .await
23653            {
23654                Ok(token) => token,
23655                Err(e) => match dlg.token(e) {
23656                    Ok(token) => token,
23657                    Err(e) => {
23658                        dlg.finished(false);
23659                        return Err(common::Error::MissingToken(e));
23660                    }
23661                },
23662            };
23663            let mut req_result = {
23664                let client = &self.hub.client;
23665                dlg.pre_request();
23666                let mut req_builder = hyper::Request::builder()
23667                    .method(hyper::Method::GET)
23668                    .uri(url.as_str())
23669                    .header(USER_AGENT, self.hub._user_agent.clone());
23670
23671                if let Some(token) = token.as_ref() {
23672                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23673                }
23674
23675                let request = req_builder
23676                    .header(CONTENT_LENGTH, 0_u64)
23677                    .body(common::to_body::<String>(None));
23678
23679                client.request(request.unwrap()).await
23680            };
23681
23682            match req_result {
23683                Err(err) => {
23684                    if let common::Retry::After(d) = dlg.http_error(&err) {
23685                        sleep(d).await;
23686                        continue;
23687                    }
23688                    dlg.finished(false);
23689                    return Err(common::Error::HttpError(err));
23690                }
23691                Ok(res) => {
23692                    let (mut parts, body) = res.into_parts();
23693                    let mut body = common::Body::new(body);
23694                    if !parts.status.is_success() {
23695                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23696                        let error = serde_json::from_str(&common::to_string(&bytes));
23697                        let response = common::to_response(parts, bytes.into());
23698
23699                        if let common::Retry::After(d) =
23700                            dlg.http_failure(&response, error.as_ref().ok())
23701                        {
23702                            sleep(d).await;
23703                            continue;
23704                        }
23705
23706                        dlg.finished(false);
23707
23708                        return Err(match error {
23709                            Ok(value) => common::Error::BadRequest(value),
23710                            _ => common::Error::Failure(response),
23711                        });
23712                    }
23713                    let response = {
23714                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23715                        let encoded = common::to_string(&bytes);
23716                        match serde_json::from_str(&encoded) {
23717                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23718                            Err(error) => {
23719                                dlg.response_json_decode_error(&encoded, &error);
23720                                return Err(common::Error::JsonDecodeError(
23721                                    encoded.to_string(),
23722                                    error,
23723                                ));
23724                            }
23725                        }
23726                    };
23727
23728                    dlg.finished(true);
23729                    return Ok(response);
23730                }
23731            }
23732        }
23733    }
23734
23735    /// Resource name for the location.
23736    ///
23737    /// Sets the *name* path property to the given value.
23738    ///
23739    /// Even though the property as already been set when instantiating this call,
23740    /// we provide this method for API completeness.
23741    pub fn name(mut self, new_value: &str) -> ProjectLocationGetCall<'a, C> {
23742        self._name = new_value.to_string();
23743        self
23744    }
23745    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23746    /// while executing the actual API request.
23747    ///
23748    /// ````text
23749    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
23750    /// ````
23751    ///
23752    /// Sets the *delegate* property to the given value.
23753    pub fn delegate(
23754        mut self,
23755        new_value: &'a mut dyn common::Delegate,
23756    ) -> ProjectLocationGetCall<'a, C> {
23757        self._delegate = Some(new_value);
23758        self
23759    }
23760
23761    /// Set any additional parameter of the query string used in the request.
23762    /// It should be used to set parameters which are not yet available through their own
23763    /// setters.
23764    ///
23765    /// Please note that this method must not be used to set any of the known parameters
23766    /// which have their own setter method. If done anyway, the request will fail.
23767    ///
23768    /// # Additional Parameters
23769    ///
23770    /// * *$.xgafv* (query-string) - V1 error format.
23771    /// * *access_token* (query-string) - OAuth access token.
23772    /// * *alt* (query-string) - Data format for response.
23773    /// * *callback* (query-string) - JSONP
23774    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23775    /// * *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.
23776    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23777    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23778    /// * *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.
23779    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23780    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23781    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCall<'a, C>
23782    where
23783        T: AsRef<str>,
23784    {
23785        self._additional_params
23786            .insert(name.as_ref().to_string(), value.as_ref().to_string());
23787        self
23788    }
23789
23790    /// Identifies the authorization scope for the method you are building.
23791    ///
23792    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23793    /// [`Scope::CloudPlatform`].
23794    ///
23795    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23796    /// tokens for more than one scope.
23797    ///
23798    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23799    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23800    /// sufficient, a read-write scope will do as well.
23801    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCall<'a, C>
23802    where
23803        St: AsRef<str>,
23804    {
23805        self._scopes.insert(String::from(scope.as_ref()));
23806        self
23807    }
23808    /// Identifies the authorization scope(s) for the method you are building.
23809    ///
23810    /// See [`Self::add_scope()`] for details.
23811    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCall<'a, C>
23812    where
23813        I: IntoIterator<Item = St>,
23814        St: AsRef<str>,
23815    {
23816        self._scopes
23817            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23818        self
23819    }
23820
23821    /// Removes all scopes, and no default scope will be used either.
23822    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23823    /// for details).
23824    pub fn clear_scopes(mut self) -> ProjectLocationGetCall<'a, C> {
23825        self._scopes.clear();
23826        self
23827    }
23828}
23829
23830/// Lists information about the supported locations for this service.
23831///
23832/// A builder for the *locations.list* method supported by a *project* resource.
23833/// It is not used directly, but through a [`ProjectMethods`] instance.
23834///
23835/// # Example
23836///
23837/// Instantiate a resource method builder
23838///
23839/// ```test_harness,no_run
23840/// # extern crate hyper;
23841/// # extern crate hyper_rustls;
23842/// # extern crate google_notebooks1 as notebooks1;
23843/// # async fn dox() {
23844/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23845///
23846/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23847/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23848/// #     .with_native_roots()
23849/// #     .unwrap()
23850/// #     .https_only()
23851/// #     .enable_http2()
23852/// #     .build();
23853///
23854/// # let executor = hyper_util::rt::TokioExecutor::new();
23855/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23856/// #     secret,
23857/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23858/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
23859/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
23860/// #     ),
23861/// # ).build().await.unwrap();
23862///
23863/// # let client = hyper_util::client::legacy::Client::builder(
23864/// #     hyper_util::rt::TokioExecutor::new()
23865/// # )
23866/// # .build(
23867/// #     hyper_rustls::HttpsConnectorBuilder::new()
23868/// #         .with_native_roots()
23869/// #         .unwrap()
23870/// #         .https_or_http()
23871/// #         .enable_http2()
23872/// #         .build()
23873/// # );
23874/// # let mut hub = AIPlatformNotebooks::new(client, auth);
23875/// // You can configure optional parameters by calling the respective setters at will, and
23876/// // execute the final call using `doit()`.
23877/// // Values shown here are possibly random and not representative !
23878/// let result = hub.projects().locations_list("name")
23879///              .page_token("tempor")
23880///              .page_size(-32)
23881///              .filter("ipsum")
23882///              .add_extra_location_types("et")
23883///              .doit().await;
23884/// # }
23885/// ```
23886pub struct ProjectLocationListCall<'a, C>
23887where
23888    C: 'a,
23889{
23890    hub: &'a AIPlatformNotebooks<C>,
23891    _name: String,
23892    _page_token: Option<String>,
23893    _page_size: Option<i32>,
23894    _filter: Option<String>,
23895    _extra_location_types: Vec<String>,
23896    _delegate: Option<&'a mut dyn common::Delegate>,
23897    _additional_params: HashMap<String, String>,
23898    _scopes: BTreeSet<String>,
23899}
23900
23901impl<'a, C> common::CallBuilder for ProjectLocationListCall<'a, C> {}
23902
23903impl<'a, C> ProjectLocationListCall<'a, C>
23904where
23905    C: common::Connector,
23906{
23907    /// Perform the operation you have build so far.
23908    pub async fn doit(mut self) -> common::Result<(common::Response, ListLocationsResponse)> {
23909        use std::borrow::Cow;
23910        use std::io::{Read, Seek};
23911
23912        use common::{url::Params, ToParts};
23913        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23914
23915        let mut dd = common::DefaultDelegate;
23916        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23917        dlg.begin(common::MethodInfo {
23918            id: "notebooks.projects.locations.list",
23919            http_method: hyper::Method::GET,
23920        });
23921
23922        for &field in [
23923            "alt",
23924            "name",
23925            "pageToken",
23926            "pageSize",
23927            "filter",
23928            "extraLocationTypes",
23929        ]
23930        .iter()
23931        {
23932            if self._additional_params.contains_key(field) {
23933                dlg.finished(false);
23934                return Err(common::Error::FieldClash(field));
23935            }
23936        }
23937
23938        let mut params = Params::with_capacity(7 + self._additional_params.len());
23939        params.push("name", self._name);
23940        if let Some(value) = self._page_token.as_ref() {
23941            params.push("pageToken", value);
23942        }
23943        if let Some(value) = self._page_size.as_ref() {
23944            params.push("pageSize", value.to_string());
23945        }
23946        if let Some(value) = self._filter.as_ref() {
23947            params.push("filter", value);
23948        }
23949        if !self._extra_location_types.is_empty() {
23950            for f in self._extra_location_types.iter() {
23951                params.push("extraLocationTypes", f);
23952            }
23953        }
23954
23955        params.extend(self._additional_params.iter());
23956
23957        params.push("alt", "json");
23958        let mut url = self.hub._base_url.clone() + "v1/{+name}/locations";
23959        if self._scopes.is_empty() {
23960            self._scopes
23961                .insert(Scope::CloudPlatform.as_ref().to_string());
23962        }
23963
23964        #[allow(clippy::single_element_loop)]
23965        for &(find_this, param_name) in [("{+name}", "name")].iter() {
23966            url = params.uri_replacement(url, param_name, find_this, true);
23967        }
23968        {
23969            let to_remove = ["name"];
23970            params.remove_params(&to_remove);
23971        }
23972
23973        let url = params.parse_with_url(&url);
23974
23975        loop {
23976            let token = match self
23977                .hub
23978                .auth
23979                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23980                .await
23981            {
23982                Ok(token) => token,
23983                Err(e) => match dlg.token(e) {
23984                    Ok(token) => token,
23985                    Err(e) => {
23986                        dlg.finished(false);
23987                        return Err(common::Error::MissingToken(e));
23988                    }
23989                },
23990            };
23991            let mut req_result = {
23992                let client = &self.hub.client;
23993                dlg.pre_request();
23994                let mut req_builder = hyper::Request::builder()
23995                    .method(hyper::Method::GET)
23996                    .uri(url.as_str())
23997                    .header(USER_AGENT, self.hub._user_agent.clone());
23998
23999                if let Some(token) = token.as_ref() {
24000                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24001                }
24002
24003                let request = req_builder
24004                    .header(CONTENT_LENGTH, 0_u64)
24005                    .body(common::to_body::<String>(None));
24006
24007                client.request(request.unwrap()).await
24008            };
24009
24010            match req_result {
24011                Err(err) => {
24012                    if let common::Retry::After(d) = dlg.http_error(&err) {
24013                        sleep(d).await;
24014                        continue;
24015                    }
24016                    dlg.finished(false);
24017                    return Err(common::Error::HttpError(err));
24018                }
24019                Ok(res) => {
24020                    let (mut parts, body) = res.into_parts();
24021                    let mut body = common::Body::new(body);
24022                    if !parts.status.is_success() {
24023                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24024                        let error = serde_json::from_str(&common::to_string(&bytes));
24025                        let response = common::to_response(parts, bytes.into());
24026
24027                        if let common::Retry::After(d) =
24028                            dlg.http_failure(&response, error.as_ref().ok())
24029                        {
24030                            sleep(d).await;
24031                            continue;
24032                        }
24033
24034                        dlg.finished(false);
24035
24036                        return Err(match error {
24037                            Ok(value) => common::Error::BadRequest(value),
24038                            _ => common::Error::Failure(response),
24039                        });
24040                    }
24041                    let response = {
24042                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24043                        let encoded = common::to_string(&bytes);
24044                        match serde_json::from_str(&encoded) {
24045                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24046                            Err(error) => {
24047                                dlg.response_json_decode_error(&encoded, &error);
24048                                return Err(common::Error::JsonDecodeError(
24049                                    encoded.to_string(),
24050                                    error,
24051                                ));
24052                            }
24053                        }
24054                    };
24055
24056                    dlg.finished(true);
24057                    return Ok(response);
24058                }
24059            }
24060        }
24061    }
24062
24063    /// The resource that owns the locations collection, if applicable.
24064    ///
24065    /// Sets the *name* path property to the given value.
24066    ///
24067    /// Even though the property as already been set when instantiating this call,
24068    /// we provide this method for API completeness.
24069    pub fn name(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
24070        self._name = new_value.to_string();
24071        self
24072    }
24073    /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
24074    ///
24075    /// Sets the *page token* query property to the given value.
24076    pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
24077        self._page_token = Some(new_value.to_string());
24078        self
24079    }
24080    /// The maximum number of results to return. If not set, the service selects a default.
24081    ///
24082    /// Sets the *page size* query property to the given value.
24083    pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C> {
24084        self._page_size = Some(new_value);
24085        self
24086    }
24087    /// A filter to narrow down results to a preferred subset. The filtering language accepts strings like `"displayName=tokyo"`, and is documented in more detail in [AIP-160](https://google.aip.dev/160).
24088    ///
24089    /// Sets the *filter* query property to the given value.
24090    pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
24091        self._filter = Some(new_value.to_string());
24092        self
24093    }
24094    /// Optional. Do not use this field. It is unsupported and is ignored unless explicitly documented otherwise. This is primarily for internal usage.
24095    ///
24096    /// Append the given value to the *extra location types* query property.
24097    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
24098    pub fn add_extra_location_types(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
24099        self._extra_location_types.push(new_value.to_string());
24100        self
24101    }
24102    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24103    /// while executing the actual API request.
24104    ///
24105    /// ````text
24106    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
24107    /// ````
24108    ///
24109    /// Sets the *delegate* property to the given value.
24110    pub fn delegate(
24111        mut self,
24112        new_value: &'a mut dyn common::Delegate,
24113    ) -> ProjectLocationListCall<'a, C> {
24114        self._delegate = Some(new_value);
24115        self
24116    }
24117
24118    /// Set any additional parameter of the query string used in the request.
24119    /// It should be used to set parameters which are not yet available through their own
24120    /// setters.
24121    ///
24122    /// Please note that this method must not be used to set any of the known parameters
24123    /// which have their own setter method. If done anyway, the request will fail.
24124    ///
24125    /// # Additional Parameters
24126    ///
24127    /// * *$.xgafv* (query-string) - V1 error format.
24128    /// * *access_token* (query-string) - OAuth access token.
24129    /// * *alt* (query-string) - Data format for response.
24130    /// * *callback* (query-string) - JSONP
24131    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24132    /// * *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.
24133    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24134    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24135    /// * *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.
24136    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24137    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24138    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C>
24139    where
24140        T: AsRef<str>,
24141    {
24142        self._additional_params
24143            .insert(name.as_ref().to_string(), value.as_ref().to_string());
24144        self
24145    }
24146
24147    /// Identifies the authorization scope for the method you are building.
24148    ///
24149    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24150    /// [`Scope::CloudPlatform`].
24151    ///
24152    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24153    /// tokens for more than one scope.
24154    ///
24155    /// Usually there is more than one suitable scope to authorize an operation, some of which may
24156    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24157    /// sufficient, a read-write scope will do as well.
24158    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationListCall<'a, C>
24159    where
24160        St: AsRef<str>,
24161    {
24162        self._scopes.insert(String::from(scope.as_ref()));
24163        self
24164    }
24165    /// Identifies the authorization scope(s) for the method you are building.
24166    ///
24167    /// See [`Self::add_scope()`] for details.
24168    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationListCall<'a, C>
24169    where
24170        I: IntoIterator<Item = St>,
24171        St: AsRef<str>,
24172    {
24173        self._scopes
24174            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24175        self
24176    }
24177
24178    /// Removes all scopes, and no default scope will be used either.
24179    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24180    /// for details).
24181    pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, C> {
24182        self._scopes.clear();
24183        self
24184    }
24185}