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 auth = yup_oauth2::InstalledFlowAuthenticator::builder(
63///     secret,
64///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
65/// ).build().await.unwrap();
66///
67/// let client = hyper_util::client::legacy::Client::builder(
68///     hyper_util::rt::TokioExecutor::new()
69/// )
70/// .build(
71///     hyper_rustls::HttpsConnectorBuilder::new()
72///         .with_native_roots()
73///         .unwrap()
74///         .https_or_http()
75///         .enable_http1()
76///         .build()
77/// );
78/// let mut hub = AIPlatformNotebooks::new(client, auth);
79/// // As the method needs a request, you would usually fill it with the desired information
80/// // into the respective structure. Some of the parts shown here might not be applicable !
81/// // Values shown here are possibly random and not representative !
82/// let mut req = Runtime::default();
83///
84/// // You can configure optional parameters by calling the respective setters at will, and
85/// // execute the final call using `doit()`.
86/// // Values shown here are possibly random and not representative !
87/// let result = hub.projects().locations_runtimes_create(req, "parent")
88///              .runtime_id("sed")
89///              .request_id("amet.")
90///              .doit().await;
91///
92/// match result {
93///     Err(e) => match e {
94///         // The Error enum provides details about what exactly happened.
95///         // You can also just use its `Debug`, `Display` or `Error` traits
96///          Error::HttpError(_)
97///         |Error::Io(_)
98///         |Error::MissingAPIKey
99///         |Error::MissingToken(_)
100///         |Error::Cancelled
101///         |Error::UploadSizeLimitExceeded(_, _)
102///         |Error::Failure(_)
103///         |Error::BadRequest(_)
104///         |Error::FieldClash(_)
105///         |Error::JsonDecodeError(_, _) => println!("{}", e),
106///     },
107///     Ok(res) => println!("Success: {:?}", res),
108/// }
109/// # }
110/// ```
111#[derive(Clone)]
112pub struct AIPlatformNotebooks<C> {
113    pub client: common::Client<C>,
114    pub auth: Box<dyn common::GetToken>,
115    _user_agent: String,
116    _base_url: String,
117    _root_url: String,
118}
119
120impl<C> common::Hub for AIPlatformNotebooks<C> {}
121
122impl<'a, C> AIPlatformNotebooks<C> {
123    pub fn new<A: 'static + common::GetToken>(
124        client: common::Client<C>,
125        auth: A,
126    ) -> AIPlatformNotebooks<C> {
127        AIPlatformNotebooks {
128            client,
129            auth: Box::new(auth),
130            _user_agent: "google-api-rust-client/6.0.0".to_string(),
131            _base_url: "https://notebooks.googleapis.com/".to_string(),
132            _root_url: "https://notebooks.googleapis.com/".to_string(),
133        }
134    }
135
136    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
137        ProjectMethods { hub: self }
138    }
139
140    /// Set the user-agent header field to use in all requests to the server.
141    /// It defaults to `google-api-rust-client/6.0.0`.
142    ///
143    /// Returns the previously set user-agent.
144    pub fn user_agent(&mut self, agent_name: String) -> String {
145        std::mem::replace(&mut self._user_agent, agent_name)
146    }
147
148    /// Set the base url to use in all requests to the server.
149    /// It defaults to `https://notebooks.googleapis.com/`.
150    ///
151    /// Returns the previously set base url.
152    pub fn base_url(&mut self, new_base_url: String) -> String {
153        std::mem::replace(&mut self._base_url, new_base_url)
154    }
155
156    /// Set the root url to use in all requests to the server.
157    /// It defaults to `https://notebooks.googleapis.com/`.
158    ///
159    /// Returns the previously set root url.
160    pub fn root_url(&mut self, new_root_url: String) -> String {
161        std::mem::replace(&mut self._root_url, new_root_url)
162    }
163}
164
165// ############
166// SCHEMAS ###
167// ##########
168/// 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.
169///
170/// This type is not used in any activity, and only used as *part* of another schema.
171///
172#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
173#[serde_with::serde_as]
174#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
175pub struct AcceleratorConfig {
176    /// Count of cores of this accelerator.
177    #[serde(rename = "coreCount")]
178    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
179    pub core_count: Option<i64>,
180    /// Type of this accelerator.
181    #[serde(rename = "type")]
182    pub type_: Option<String>,
183}
184
185impl common::Part for AcceleratorConfig {}
186
187/// Associates `members`, or principals, with a `role`.
188///
189/// This type is not used in any activity, and only used as *part* of another schema.
190///
191#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
192#[serde_with::serde_as]
193#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
194pub struct Binding {
195    /// 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).
196    pub condition: Option<Expr>,
197    /// 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`.
198    pub members: Option<Vec<String>>,
199    /// 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).
200    pub role: Option<String>,
201}
202
203impl common::Part for Binding {}
204
205/// Definition of the boot image used by the Runtime. Used to facilitate runtime upgradeability.
206///
207/// This type is not used in any activity, and only used as *part* of another schema.
208///
209#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
210#[serde_with::serde_as]
211#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
212pub struct BootImage {
213    _never_set: Option<bool>,
214}
215
216impl common::Part for BootImage {}
217
218/// The request message for Operations.CancelOperation.
219///
220/// # Activities
221///
222/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
223/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
224///
225/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (request)
226#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
227#[serde_with::serde_as]
228#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
229pub struct CancelOperationRequest {
230    _never_set: Option<bool>,
231}
232
233impl common::RequestValue for CancelOperationRequest {}
234
235/// Definition of a container image for starting a notebook instance with the environment installed in a container.
236///
237/// This type is not used in any activity, and only used as *part* of another schema.
238///
239#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
240#[serde_with::serde_as]
241#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
242pub struct ContainerImage {
243    /// Required. The path to the container image repository. For example: `gcr.io/{project_id}/{image_name}`
244    pub repository: Option<String>,
245    /// The tag of the container image. If not specified, this defaults to the latest tag.
246    pub tag: Option<String>,
247}
248
249impl common::Part for ContainerImage {}
250
251/// Parameters used in Dataproc JobType executions.
252///
253/// This type is not used in any activity, and only used as *part* of another schema.
254///
255#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
256#[serde_with::serde_as]
257#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
258pub struct DataprocParameters {
259    /// URI for cluster used to run Dataproc execution. Format: `projects/{PROJECT_ID}/regions/{REGION}/clusters/{CLUSTER_NAME}`
260    pub cluster: Option<String>,
261}
262
263impl common::Part for DataprocParameters {}
264
265/// Request for creating a notebook instance diagnostic file.
266///
267/// # Activities
268///
269/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
270/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
271///
272/// * [locations instances diagnose projects](ProjectLocationInstanceDiagnoseCall) (request)
273#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
274#[serde_with::serde_as]
275#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
276pub struct DiagnoseInstanceRequest {
277    /// Required. Defines flags that are used to run the diagnostic tool
278    #[serde(rename = "diagnosticConfig")]
279    pub diagnostic_config: Option<DiagnosticConfig>,
280    /// Optional. Maxmium amount of time in minutes before the operation times out.
281    #[serde(rename = "timeoutMinutes")]
282    pub timeout_minutes: Option<i32>,
283}
284
285impl common::RequestValue for DiagnoseInstanceRequest {}
286
287/// Request for creating a notebook instance diagnostic file.
288///
289/// # Activities
290///
291/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
292/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
293///
294/// * [locations runtimes diagnose projects](ProjectLocationRuntimeDiagnoseCall) (request)
295#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
296#[serde_with::serde_as]
297#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
298pub struct DiagnoseRuntimeRequest {
299    /// Required. Defines flags that are used to run the diagnostic tool
300    #[serde(rename = "diagnosticConfig")]
301    pub diagnostic_config: Option<DiagnosticConfig>,
302    /// Optional. Maxmium amount of time in minutes before the operation times out.
303    #[serde(rename = "timeoutMinutes")]
304    pub timeout_minutes: Option<i32>,
305}
306
307impl common::RequestValue for DiagnoseRuntimeRequest {}
308
309/// Defines flags that are used to run the diagnostic tool
310///
311/// This type is not used in any activity, and only used as *part* of another schema.
312///
313#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
314#[serde_with::serde_as]
315#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
316pub struct DiagnosticConfig {
317    /// Optional. Enables flag to copy all `/home/jupyter` folder contents
318    #[serde(rename = "copyHomeFilesFlagEnabled")]
319    pub copy_home_files_flag_enabled: Option<bool>,
320    /// 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`
321    #[serde(rename = "gcsBucket")]
322    pub gcs_bucket: Option<String>,
323    /// Optional. Enables flag to capture packets from the instance for 30 seconds
324    #[serde(rename = "packetCaptureFlagEnabled")]
325    pub packet_capture_flag_enabled: Option<bool>,
326    /// 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/`
327    #[serde(rename = "relativePath")]
328    pub relative_path: Option<String>,
329    /// Optional. Enables flag to repair service for instance
330    #[serde(rename = "repairFlagEnabled")]
331    pub repair_flag_enabled: Option<bool>,
332}
333
334impl common::Part for DiagnosticConfig {}
335
336/// An instance-attached disk resource.
337///
338/// This type is not used in any activity, and only used as *part* of another schema.
339///
340#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
341#[serde_with::serde_as]
342#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
343pub struct Disk {
344    /// Indicates whether the disk will be auto-deleted when the instance is deleted (but not when the disk is detached from the instance).
345    #[serde(rename = "autoDelete")]
346    pub auto_delete: Option<bool>,
347    /// Indicates that this is a boot disk. The virtual machine will use the first partition of the disk for its root filesystem.
348    pub boot: Option<bool>,
349    /// 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.
350    #[serde(rename = "deviceName")]
351    pub device_name: Option<String>,
352    /// Indicates the size of the disk in base-2 GB.
353    #[serde(rename = "diskSizeGb")]
354    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
355    pub disk_size_gb: Option<i64>,
356    /// 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.
357    #[serde(rename = "guestOsFeatures")]
358    pub guest_os_features: Option<Vec<GuestOsFeature>>,
359    /// 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.
360    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
361    pub index: Option<i64>,
362    /// 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`
363    pub interface: Option<String>,
364    /// Type of the resource. Always compute#attachedDisk for attached disks.
365    pub kind: Option<String>,
366    /// A list of publicly visible licenses. Reserved for Google's use. A License represents billing and aggregate usage data for public and marketplace images.
367    pub licenses: Option<Vec<String>>,
368    /// 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`
369    pub mode: Option<String>,
370    /// Indicates a valid partial or full URL to an existing Persistent Disk resource.
371    pub source: Option<String>,
372    /// Indicates the type of the disk, either `SCRATCH` or `PERSISTENT`. Valid values: * `PERSISTENT` * `SCRATCH`
373    #[serde(rename = "type")]
374    pub type_: Option<String>,
375}
376
377impl common::Part for Disk {}
378
379/// 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); }
380///
381/// # Activities
382///
383/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
384/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
385///
386/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (response)
387/// * [locations operations delete projects](ProjectLocationOperationDeleteCall) (response)
388#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
389#[serde_with::serde_as]
390#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
391pub struct Empty {
392    _never_set: Option<bool>,
393}
394
395impl common::ResponseResult for Empty {}
396
397/// Represents a custom encryption key configuration that can be applied to a resource. This will encrypt all disks in Virtual Machine.
398///
399/// This type is not used in any activity, and only used as *part* of another schema.
400///
401#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
402#[serde_with::serde_as]
403#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
404pub struct EncryptionConfig {
405    /// 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}`
406    #[serde(rename = "kmsKey")]
407    pub kms_key: Option<String>,
408}
409
410impl common::Part for EncryptionConfig {}
411
412/// Definition of a software environment that is used to start a notebook instance.
413///
414/// # Activities
415///
416/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
417/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
418///
419/// * [locations environments create projects](ProjectLocationEnvironmentCreateCall) (request)
420/// * [locations environments get projects](ProjectLocationEnvironmentGetCall) (response)
421#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
422#[serde_with::serde_as]
423#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
424pub struct Environment {
425    /// Use a container image to start the notebook instance.
426    #[serde(rename = "containerImage")]
427    pub container_image: Option<ContainerImage>,
428    /// Output only. The time at which this environment was created.
429    #[serde(rename = "createTime")]
430    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
431    /// A brief description of this environment.
432    pub description: Option<String>,
433    /// Display name of this environment for the UI.
434    #[serde(rename = "displayName")]
435    pub display_name: Option<String>,
436    /// Output only. Name of this environment. Format: `projects/{project_id}/locations/{location}/environments/{environment_id}`
437    pub name: Option<String>,
438    /// 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"`
439    #[serde(rename = "postStartupScript")]
440    pub post_startup_script: Option<String>,
441    /// Use a Compute Engine VM image to start the notebook instance.
442    #[serde(rename = "vmImage")]
443    pub vm_image: Option<VmImage>,
444}
445
446impl common::RequestValue for Environment {}
447impl common::ResponseResult for Environment {}
448
449/// The definition of an Event for a managed / semi-managed notebook instance.
450///
451/// This type is not used in any activity, and only used as *part* of another schema.
452///
453#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
454#[serde_with::serde_as]
455#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
456pub struct Event {
457    /// Optional. Event details. This field is used to pass event information.
458    pub details: Option<HashMap<String, String>>,
459    /// Event report time.
460    #[serde(rename = "reportTime")]
461    pub report_time: Option<chrono::DateTime<chrono::offset::Utc>>,
462    /// Event type.
463    #[serde(rename = "type")]
464    pub type_: Option<String>,
465}
466
467impl common::Part for Event {}
468
469/// The definition of a single executed notebook.
470///
471/// # Activities
472///
473/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
474/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
475///
476/// * [locations executions create projects](ProjectLocationExecutionCreateCall) (request)
477/// * [locations executions get projects](ProjectLocationExecutionGetCall) (response)
478#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
479#[serde_with::serde_as]
480#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
481pub struct Execution {
482    /// Output only. Time the Execution was instantiated.
483    #[serde(rename = "createTime")]
484    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
485    /// A brief description of this execution.
486    pub description: Option<String>,
487    /// Output only. Name used for UI purposes. Name can only contain alphanumeric characters and underscores '_'.
488    #[serde(rename = "displayName")]
489    pub display_name: Option<String>,
490    /// execute metadata including name, hardware spec, region, labels, etc.
491    #[serde(rename = "executionTemplate")]
492    pub execution_template: Option<ExecutionTemplate>,
493    /// Output only. The URI of the external job used to execute the notebook.
494    #[serde(rename = "jobUri")]
495    pub job_uri: Option<String>,
496    /// Output only. The resource name of the execute. Format: `projects/{project_id}/locations/{location}/executions/{execution_id}`
497    pub name: Option<String>,
498    /// Output notebook file generated by this execution
499    #[serde(rename = "outputNotebookFile")]
500    pub output_notebook_file: Option<String>,
501    /// Output only. State of the underlying AI Platform job.
502    pub state: Option<String>,
503    /// Output only. Time the Execution was last updated.
504    #[serde(rename = "updateTime")]
505    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
506}
507
508impl common::RequestValue for Execution {}
509impl common::ResponseResult for Execution {}
510
511/// The description a notebook execution workload.
512///
513/// This type is not used in any activity, and only used as *part* of another schema.
514///
515#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
516#[serde_with::serde_as]
517#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
518pub struct ExecutionTemplate {
519    /// Configuration (count and accelerator type) for hardware running notebook execution.
520    #[serde(rename = "acceleratorConfig")]
521    pub accelerator_config: Option<SchedulerAcceleratorConfig>,
522    /// 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
523    #[serde(rename = "containerImageUri")]
524    pub container_image_uri: Option<String>,
525    /// Parameters used in Dataproc JobType executions.
526    #[serde(rename = "dataprocParameters")]
527    pub dataproc_parameters: Option<DataprocParameters>,
528    /// 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`
529    #[serde(rename = "inputNotebookFile")]
530    pub input_notebook_file: Option<String>,
531    /// The type of Job to be used on this execution.
532    #[serde(rename = "jobType")]
533    pub job_type: Option<String>,
534    /// 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.
535    #[serde(rename = "kernelSpec")]
536    pub kernel_spec: Option<String>,
537    /// 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.
538    pub labels: Option<HashMap<String, String>>,
539    /// 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).
540    #[serde(rename = "masterType")]
541    pub master_type: Option<String>,
542    /// 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`
543    #[serde(rename = "outputNotebookFolder")]
544    pub output_notebook_folder: Option<String>,
545    /// Parameters used within the 'input_notebook_file' notebook.
546    pub parameters: Option<String>,
547    /// 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`
548    #[serde(rename = "paramsYamlFile")]
549    pub params_yaml_file: Option<String>,
550    /// Required. Scale tier of the hardware used for notebook execution. DEPRECATED Will be discontinued. As right now only CUSTOM is supported.
551    #[serde(rename = "scaleTier")]
552    pub scale_tier: Option<String>,
553    /// 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.
554    #[serde(rename = "serviceAccount")]
555    pub service_account: Option<String>,
556    /// The name of a Vertex AI [Tensorboard] resource to which this execution will upload Tensorboard logs. Format: `projects/{project}/locations/{location}/tensorboards/{tensorboard}`
557    pub tensorboard: Option<String>,
558    /// Parameters used in Vertex AI JobType executions.
559    #[serde(rename = "vertexAiParameters")]
560    pub vertex_ai_parameters: Option<VertexAIParameters>,
561}
562
563impl common::Part for ExecutionTemplate {}
564
565/// 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.
566///
567/// This type is not used in any activity, and only used as *part* of another schema.
568///
569#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
570#[serde_with::serde_as]
571#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
572pub struct Expr {
573    /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
574    pub description: Option<String>,
575    /// Textual representation of an expression in Common Expression Language syntax.
576    pub expression: Option<String>,
577    /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
578    pub location: Option<String>,
579    /// 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.
580    pub title: Option<String>,
581}
582
583impl common::Part for Expr {}
584
585/// Response for checking if a notebook instance is healthy.
586///
587/// # Activities
588///
589/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
590/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
591///
592/// * [locations instances get instance health projects](ProjectLocationInstanceGetInstanceHealthCall) (response)
593#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
594#[serde_with::serde_as]
595#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
596pub struct GetInstanceHealthResponse {
597    /// 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" }
598    #[serde(rename = "healthInfo")]
599    pub health_info: Option<HashMap<String, String>>,
600    /// Output only. Runtime health_state.
601    #[serde(rename = "healthState")]
602    pub health_state: Option<String>,
603}
604
605impl common::ResponseResult for GetInstanceHealthResponse {}
606
607/// Guest OS features for boot disk.
608///
609/// This type is not used in any activity, and only used as *part* of another schema.
610///
611#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
612#[serde_with::serde_as]
613#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
614pub struct GuestOsFeature {
615    /// 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`
616    #[serde(rename = "type")]
617    pub type_: Option<String>,
618}
619
620impl common::Part for GuestOsFeature {}
621
622/// The definition of a notebook instance.
623///
624/// # Activities
625///
626/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
627/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
628///
629/// * [locations instances create projects](ProjectLocationInstanceCreateCall) (request)
630/// * [locations instances get projects](ProjectLocationInstanceGetCall) (response)
631#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
632#[serde_with::serde_as]
633#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
634pub struct Instance {
635    /// 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).
636    #[serde(rename = "acceleratorConfig")]
637    pub accelerator_config: Option<AcceleratorConfig>,
638    /// 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.
639    #[serde(rename = "bootDiskSizeGb")]
640    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
641    pub boot_disk_size_gb: Option<i64>,
642    /// Input only. The type of the boot disk attached to this instance, defaults to standard persistent disk (`PD_STANDARD`).
643    #[serde(rename = "bootDiskType")]
644    pub boot_disk_type: Option<String>,
645    /// Optional. Flag to enable ip forwarding or not, default false/off. https://cloud.google.com/vpc/docs/using-routes#canipforward
646    #[serde(rename = "canIpForward")]
647    pub can_ip_forward: Option<bool>,
648    /// Use a container image to start the notebook instance.
649    #[serde(rename = "containerImage")]
650    pub container_image: Option<ContainerImage>,
651    /// Output only. Instance creation time.
652    #[serde(rename = "createTime")]
653    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
654    /// Output only. Email address of entity that sent original CreateInstance request.
655    pub creator: Option<String>,
656    /// Specify a custom Cloud Storage path where the GPU driver is stored. If not specified, we'll automatically choose from official GPU drivers.
657    #[serde(rename = "customGpuDriverPath")]
658    pub custom_gpu_driver_path: Option<String>,
659    /// 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.
660    #[serde(rename = "dataDiskSizeGb")]
661    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
662    pub data_disk_size_gb: Option<i64>,
663    /// Input only. The type of the data disk attached to this instance, defaults to standard persistent disk (`PD_STANDARD`).
664    #[serde(rename = "dataDiskType")]
665    pub data_disk_type: Option<String>,
666    /// Input only. Disk encryption method used on the boot and data disks, defaults to GMEK.
667    #[serde(rename = "diskEncryption")]
668    pub disk_encryption: Option<String>,
669    /// Output only. Attached disks to notebook instance.
670    pub disks: Option<Vec<Disk>>,
671    /// 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.
672    #[serde(rename = "installGpuDriver")]
673    pub install_gpu_driver: Option<bool>,
674    /// Output only. Checks how feasible a migration from UmN to WbI is.
675    #[serde(rename = "instanceMigrationEligibility")]
676    pub instance_migration_eligibility: Option<InstanceMigrationEligibility>,
677    /// 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.
678    #[serde(rename = "instanceOwners")]
679    pub instance_owners: Option<Vec<String>>,
680    /// 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).
681    #[serde(rename = "kmsKey")]
682    pub kms_key: Option<String>,
683    /// Labels to apply to this instance. These can be later modified by the setLabels method.
684    pub labels: Option<HashMap<String, String>>,
685    /// Required. The [Compute Engine machine type](https://cloud.google.com/compute/docs/machine-types) of this instance.
686    #[serde(rename = "machineType")]
687    pub machine_type: Option<String>,
688    /// 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"`.
689    pub metadata: Option<HashMap<String, String>>,
690    /// Output only. Bool indicating whether this notebook has been migrated to a Workbench Instance
691    pub migrated: Option<bool>,
692    /// Output only. The name of this notebook instance. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
693    pub name: Option<String>,
694    /// The name of the VPC that this instance is in. Format: `projects/{project_id}/global/networks/{network_id}`
695    pub network: Option<String>,
696    /// Optional. The type of vNIC to be used on this interface. This may be gVNIC or VirtioNet.
697    #[serde(rename = "nicType")]
698    pub nic_type: Option<String>,
699    /// If true, the notebook instance will not register with the proxy.
700    #[serde(rename = "noProxyAccess")]
701    pub no_proxy_access: Option<bool>,
702    /// If true, no external IP will be assigned to this instance.
703    #[serde(rename = "noPublicIp")]
704    pub no_public_ip: Option<bool>,
705    /// Input only. If true, the data disk will not be auto deleted when deleting the instance.
706    #[serde(rename = "noRemoveDataDisk")]
707    pub no_remove_data_disk: Option<bool>,
708    /// 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`).
709    #[serde(rename = "postStartupScript")]
710    pub post_startup_script: Option<String>,
711    /// Output only. The proxy endpoint that is used to access the Jupyter notebook.
712    #[serde(rename = "proxyUri")]
713    pub proxy_uri: Option<String>,
714    /// 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.
715    #[serde(rename = "reservationAffinity")]
716    pub reservation_affinity: Option<ReservationAffinity>,
717    /// 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.
718    #[serde(rename = "serviceAccount")]
719    pub service_account: Option<String>,
720    /// 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
721    #[serde(rename = "serviceAccountScopes")]
722    pub service_account_scopes: Option<Vec<String>>,
723    /// Optional. Shielded VM configuration. [Images using supported Shielded VM features](https://cloud.google.com/compute/docs/instances/modifying-shielded-vm).
724    #[serde(rename = "shieldedInstanceConfig")]
725    pub shielded_instance_config: Option<ShieldedInstanceConfig>,
726    /// Output only. The state of this instance.
727    pub state: Option<String>,
728    /// The name of the subnet that this instance is in. Format: `projects/{project_id}/regions/{region}/subnetworks/{subnetwork_id}`
729    pub subnet: Option<String>,
730    /// Optional. The Compute Engine tags to add to runtime (see [Tagging instances](https://cloud.google.com/compute/docs/label-or-tag-resources#tags)).
731    pub tags: Option<Vec<String>>,
732    /// Output only. Instance update time.
733    #[serde(rename = "updateTime")]
734    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
735    /// The upgrade history of this instance.
736    #[serde(rename = "upgradeHistory")]
737    pub upgrade_history: Option<Vec<UpgradeHistoryEntry>>,
738    /// Use a Compute Engine VM image to start the notebook instance.
739    #[serde(rename = "vmImage")]
740    pub vm_image: Option<VmImage>,
741}
742
743impl common::RequestValue for Instance {}
744impl common::ResponseResult for Instance {}
745
746/// Notebook instance configurations that can be updated.
747///
748/// This type is not used in any activity, and only used as *part* of another schema.
749///
750#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
751#[serde_with::serde_as]
752#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
753pub struct InstanceConfig {
754    /// Verifies core internal services are running.
755    #[serde(rename = "enableHealthMonitoring")]
756    pub enable_health_monitoring: Option<bool>,
757    /// Cron expression in UTC timezone, used to schedule instance auto upgrade. Please follow the [cron format](https://en.wikipedia.org/wiki/Cron).
758    #[serde(rename = "notebookUpgradeSchedule")]
759    pub notebook_upgrade_schedule: Option<String>,
760}
761
762impl common::Part for InstanceConfig {}
763
764/// InstanceMigrationEligibility represents the feasibility information of a migration from UmN to WbI.
765///
766/// This type is not used in any activity, and only used as *part* of another schema.
767///
768#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
769#[serde_with::serde_as]
770#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
771pub struct InstanceMigrationEligibility {
772    /// Output only. Certain configurations make the UmN ineligible for an automatic migration. A manual migration is required.
773    pub errors: Option<Vec<String>>,
774    /// Output only. Certain configurations will be defaulted during the migration.
775    pub warnings: Option<Vec<String>>,
776}
777
778impl common::Part for InstanceMigrationEligibility {}
779
780/// Response for checking if a notebook instance is upgradeable.
781///
782/// # Activities
783///
784/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
785/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
786///
787/// * [locations instances is upgradeable projects](ProjectLocationInstanceIsUpgradeableCall) (response)
788#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
789#[serde_with::serde_as]
790#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
791pub struct IsInstanceUpgradeableResponse {
792    /// 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.
793    #[serde(rename = "upgradeImage")]
794    pub upgrade_image: Option<String>,
795    /// Additional information about upgrade.
796    #[serde(rename = "upgradeInfo")]
797    pub upgrade_info: Option<String>,
798    /// The version this instance will be upgraded to if calling the upgrade endpoint. This field will only be populated if field upgradeable is true.
799    #[serde(rename = "upgradeVersion")]
800    pub upgrade_version: Option<String>,
801    /// If an instance is upgradeable.
802    pub upgradeable: Option<bool>,
803}
804
805impl common::ResponseResult for IsInstanceUpgradeableResponse {}
806
807/// Response for listing environments.
808///
809/// # Activities
810///
811/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
812/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
813///
814/// * [locations environments list projects](ProjectLocationEnvironmentListCall) (response)
815#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
816#[serde_with::serde_as]
817#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
818pub struct ListEnvironmentsResponse {
819    /// A list of returned environments.
820    pub environments: Option<Vec<Environment>>,
821    /// A page token that can be used to continue listing from the last result in the next list call.
822    #[serde(rename = "nextPageToken")]
823    pub next_page_token: Option<String>,
824    /// Locations that could not be reached.
825    pub unreachable: Option<Vec<String>>,
826}
827
828impl common::ResponseResult for ListEnvironmentsResponse {}
829
830/// Response for listing scheduled notebook executions
831///
832/// # Activities
833///
834/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
835/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
836///
837/// * [locations executions list projects](ProjectLocationExecutionListCall) (response)
838#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
839#[serde_with::serde_as]
840#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
841pub struct ListExecutionsResponse {
842    /// A list of returned instances.
843    pub executions: Option<Vec<Execution>>,
844    /// Page token that can be used to continue listing from the last result in the next list call.
845    #[serde(rename = "nextPageToken")]
846    pub next_page_token: Option<String>,
847    /// 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']
848    pub unreachable: Option<Vec<String>>,
849}
850
851impl common::ResponseResult for ListExecutionsResponse {}
852
853/// Response for listing notebook instances.
854///
855/// # Activities
856///
857/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
858/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
859///
860/// * [locations instances list projects](ProjectLocationInstanceListCall) (response)
861#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
862#[serde_with::serde_as]
863#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
864pub struct ListInstancesResponse {
865    /// A list of returned instances.
866    pub instances: Option<Vec<Instance>>,
867    /// Page token that can be used to continue listing from the last result in the next list call.
868    #[serde(rename = "nextPageToken")]
869    pub next_page_token: Option<String>,
870    /// Locations that could not be reached. For example, `['us-west1-a', 'us-central1-b']`. A ListInstancesResponse will only contain either instances or unreachables,
871    pub unreachable: Option<Vec<String>>,
872}
873
874impl common::ResponseResult for ListInstancesResponse {}
875
876/// The response message for Locations.ListLocations.
877///
878/// # Activities
879///
880/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
881/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
882///
883/// * [locations list projects](ProjectLocationListCall) (response)
884#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
885#[serde_with::serde_as]
886#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
887pub struct ListLocationsResponse {
888    /// A list of locations that matches the specified filter in the request.
889    pub locations: Option<Vec<Location>>,
890    /// The standard List next-page token.
891    #[serde(rename = "nextPageToken")]
892    pub next_page_token: Option<String>,
893}
894
895impl common::ResponseResult for ListLocationsResponse {}
896
897/// The response message for Operations.ListOperations.
898///
899/// # Activities
900///
901/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
902/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
903///
904/// * [locations operations list projects](ProjectLocationOperationListCall) (response)
905#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
906#[serde_with::serde_as]
907#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
908pub struct ListOperationsResponse {
909    /// The standard List next-page token.
910    #[serde(rename = "nextPageToken")]
911    pub next_page_token: Option<String>,
912    /// A list of operations that matches the specified filter in the request.
913    pub operations: Option<Vec<Operation>>,
914}
915
916impl common::ResponseResult for ListOperationsResponse {}
917
918/// Response for listing Managed Notebook Runtimes.
919///
920/// # Activities
921///
922/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
923/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
924///
925/// * [locations runtimes list projects](ProjectLocationRuntimeListCall) (response)
926#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
927#[serde_with::serde_as]
928#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
929pub struct ListRuntimesResponse {
930    /// Page token that can be used to continue listing from the last result in the next list call.
931    #[serde(rename = "nextPageToken")]
932    pub next_page_token: Option<String>,
933    /// A list of returned Runtimes.
934    pub runtimes: Option<Vec<Runtime>>,
935    /// Locations that could not be reached. For example, `['us-west1', 'us-central1']`. A ListRuntimesResponse will only contain either runtimes or unreachables,
936    pub unreachable: Option<Vec<String>>,
937}
938
939impl common::ResponseResult for ListRuntimesResponse {}
940
941/// Response for listing scheduled notebook job.
942///
943/// # Activities
944///
945/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
946/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
947///
948/// * [locations schedules list projects](ProjectLocationScheduleListCall) (response)
949#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
950#[serde_with::serde_as]
951#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
952pub struct ListSchedulesResponse {
953    /// Page token that can be used to continue listing from the last result in the next list call.
954    #[serde(rename = "nextPageToken")]
955    pub next_page_token: Option<String>,
956    /// A list of returned instances.
957    pub schedules: Option<Vec<Schedule>>,
958    /// Schedules that could not be reached. For example: ['projects/{project_id}/location/{location}/schedules/monthly_digest', 'projects/{project_id}/location/{location}/schedules/weekly_sentiment']
959    pub unreachable: Option<Vec<String>>,
960}
961
962impl common::ResponseResult for ListSchedulesResponse {}
963
964/// A Local attached disk resource.
965///
966/// This type is not used in any activity, and only used as *part* of another schema.
967///
968#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
969#[serde_with::serde_as]
970#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
971pub struct LocalDisk {
972    /// 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).
973    #[serde(rename = "autoDelete")]
974    pub auto_delete: Option<bool>,
975    /// 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.
976    pub boot: Option<bool>,
977    /// 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.
978    #[serde(rename = "deviceName")]
979    pub device_name: Option<String>,
980    /// 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.
981    #[serde(rename = "guestOsFeatures")]
982    pub guest_os_features: Option<Vec<RuntimeGuestOsFeature>>,
983    /// 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.
984    pub index: Option<i32>,
985    /// 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.
986    #[serde(rename = "initializeParams")]
987    pub initialize_params: Option<LocalDiskInitializeParams>,
988    /// 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`
989    pub interface: Option<String>,
990    /// Output only. Type of the resource. Always compute#attachedDisk for attached disks.
991    pub kind: Option<String>,
992    /// Output only. Any valid publicly visible licenses.
993    pub licenses: Option<Vec<String>>,
994    /// 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`
995    pub mode: Option<String>,
996    /// Specifies a valid partial or full URL to an existing Persistent Disk resource.
997    pub source: Option<String>,
998    /// Specifies the type of the disk, either `SCRATCH` or `PERSISTENT`. If not specified, the default is `PERSISTENT`. Valid values: * `PERSISTENT` * `SCRATCH`
999    #[serde(rename = "type")]
1000    pub type_: Option<String>,
1001}
1002
1003impl common::Part for LocalDisk {}
1004
1005/// 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.
1006///
1007/// This type is not used in any activity, and only used as *part* of another schema.
1008///
1009#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1010#[serde_with::serde_as]
1011#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1012pub struct LocalDiskInitializeParams {
1013    /// Optional. Provide this property when creating the disk.
1014    pub description: Option<String>,
1015    /// 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.
1016    #[serde(rename = "diskName")]
1017    pub disk_name: Option<String>,
1018    /// 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.
1019    #[serde(rename = "diskSizeGb")]
1020    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1021    pub disk_size_gb: Option<i64>,
1022    /// Input only. The type of the boot disk attached to this instance, defaults to standard persistent disk (`PD_STANDARD`).
1023    #[serde(rename = "diskType")]
1024    pub disk_type: Option<String>,
1025    /// 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.
1026    pub labels: Option<HashMap<String, String>>,
1027}
1028
1029impl common::Part for LocalDiskInitializeParams {}
1030
1031/// A resource that represents a Google Cloud location.
1032///
1033/// # Activities
1034///
1035/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1036/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1037///
1038/// * [locations get projects](ProjectLocationGetCall) (response)
1039#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1040#[serde_with::serde_as]
1041#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1042pub struct Location {
1043    /// The friendly name for this location, typically a nearby city name. For example, "Tokyo".
1044    #[serde(rename = "displayName")]
1045    pub display_name: Option<String>,
1046    /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"}
1047    pub labels: Option<HashMap<String, String>>,
1048    /// The canonical id for this location. For example: `"us-east1"`.
1049    #[serde(rename = "locationId")]
1050    pub location_id: Option<String>,
1051    /// Service-specific metadata. For example the available capacity at the given location.
1052    pub metadata: Option<HashMap<String, serde_json::Value>>,
1053    /// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"`
1054    pub name: Option<String>,
1055}
1056
1057impl common::ResponseResult for Location {}
1058
1059/// Request for migrating a User-Managed Notebook to Workbench Instances.
1060///
1061/// # Activities
1062///
1063/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1064/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1065///
1066/// * [locations instances migrate projects](ProjectLocationInstanceMigrateCall) (request)
1067#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1068#[serde_with::serde_as]
1069#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1070pub struct MigrateInstanceRequest {
1071    /// Optional. Specifies the behavior of post startup script during migration.
1072    #[serde(rename = "postStartupScriptOption")]
1073    pub post_startup_script_option: Option<String>,
1074}
1075
1076impl common::RequestValue for MigrateInstanceRequest {}
1077
1078/// Request for migrating a Runtime to a Workbench Instance.
1079///
1080/// # Activities
1081///
1082/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1083/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1084///
1085/// * [locations runtimes migrate projects](ProjectLocationRuntimeMigrateCall) (request)
1086#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1087#[serde_with::serde_as]
1088#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1089pub struct MigrateRuntimeRequest {
1090    /// 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}`
1091    pub network: Option<String>,
1092    /// Optional. Specifies the behavior of post startup script during migration.
1093    #[serde(rename = "postStartupScriptOption")]
1094    pub post_startup_script_option: Option<String>,
1095    /// Optional. Idempotent request UUID.
1096    #[serde(rename = "requestId")]
1097    pub request_id: Option<String>,
1098    /// 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.
1099    #[serde(rename = "serviceAccount")]
1100    pub service_account: Option<String>,
1101    /// 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}`
1102    pub subnet: Option<String>,
1103}
1104
1105impl common::RequestValue for MigrateRuntimeRequest {}
1106
1107/// This resource represents a long-running operation that is the result of a network API call.
1108///
1109/// # Activities
1110///
1111/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1112/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1113///
1114/// * [locations environments create projects](ProjectLocationEnvironmentCreateCall) (response)
1115/// * [locations environments delete projects](ProjectLocationEnvironmentDeleteCall) (response)
1116/// * [locations executions create projects](ProjectLocationExecutionCreateCall) (response)
1117/// * [locations executions delete projects](ProjectLocationExecutionDeleteCall) (response)
1118/// * [locations instances create projects](ProjectLocationInstanceCreateCall) (response)
1119/// * [locations instances delete projects](ProjectLocationInstanceDeleteCall) (response)
1120/// * [locations instances diagnose projects](ProjectLocationInstanceDiagnoseCall) (response)
1121/// * [locations instances migrate projects](ProjectLocationInstanceMigrateCall) (response)
1122/// * [locations instances register projects](ProjectLocationInstanceRegisterCall) (response)
1123/// * [locations instances report projects](ProjectLocationInstanceReportCall) (response)
1124/// * [locations instances report event projects](ProjectLocationInstanceReportEventCall) (response)
1125/// * [locations instances reset projects](ProjectLocationInstanceResetCall) (response)
1126/// * [locations instances rollback projects](ProjectLocationInstanceRollbackCall) (response)
1127/// * [locations instances set accelerator projects](ProjectLocationInstanceSetAcceleratorCall) (response)
1128/// * [locations instances set labels projects](ProjectLocationInstanceSetLabelCall) (response)
1129/// * [locations instances set machine type projects](ProjectLocationInstanceSetMachineTypeCall) (response)
1130/// * [locations instances start projects](ProjectLocationInstanceStartCall) (response)
1131/// * [locations instances stop projects](ProjectLocationInstanceStopCall) (response)
1132/// * [locations instances update config projects](ProjectLocationInstanceUpdateConfigCall) (response)
1133/// * [locations instances update shielded instance config projects](ProjectLocationInstanceUpdateShieldedInstanceConfigCall) (response)
1134/// * [locations instances upgrade projects](ProjectLocationInstanceUpgradeCall) (response)
1135/// * [locations instances upgrade internal projects](ProjectLocationInstanceUpgradeInternalCall) (response)
1136/// * [locations operations get projects](ProjectLocationOperationGetCall) (response)
1137/// * [locations runtimes create projects](ProjectLocationRuntimeCreateCall) (response)
1138/// * [locations runtimes delete projects](ProjectLocationRuntimeDeleteCall) (response)
1139/// * [locations runtimes diagnose projects](ProjectLocationRuntimeDiagnoseCall) (response)
1140/// * [locations runtimes migrate projects](ProjectLocationRuntimeMigrateCall) (response)
1141/// * [locations runtimes patch projects](ProjectLocationRuntimePatchCall) (response)
1142/// * [locations runtimes report event projects](ProjectLocationRuntimeReportEventCall) (response)
1143/// * [locations runtimes reset projects](ProjectLocationRuntimeResetCall) (response)
1144/// * [locations runtimes start projects](ProjectLocationRuntimeStartCall) (response)
1145/// * [locations runtimes stop projects](ProjectLocationRuntimeStopCall) (response)
1146/// * [locations runtimes switch projects](ProjectLocationRuntimeSwitchCall) (response)
1147/// * [locations runtimes upgrade projects](ProjectLocationRuntimeUpgradeCall) (response)
1148/// * [locations schedules create projects](ProjectLocationScheduleCreateCall) (response)
1149/// * [locations schedules delete projects](ProjectLocationScheduleDeleteCall) (response)
1150/// * [locations schedules trigger projects](ProjectLocationScheduleTriggerCall) (response)
1151#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1152#[serde_with::serde_as]
1153#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1154pub struct Operation {
1155    /// 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.
1156    pub done: Option<bool>,
1157    /// The error result of the operation in case of failure or cancellation.
1158    pub error: Option<Status>,
1159    /// 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.
1160    pub metadata: Option<HashMap<String, serde_json::Value>>,
1161    /// 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}`.
1162    pub name: Option<String>,
1163    /// 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`.
1164    pub response: Option<HashMap<String, serde_json::Value>>,
1165}
1166
1167impl common::ResponseResult for Operation {}
1168
1169/// 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/).
1170///
1171/// # Activities
1172///
1173/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1174/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1175///
1176/// * [locations instances get iam policy projects](ProjectLocationInstanceGetIamPolicyCall) (response)
1177/// * [locations instances set iam policy projects](ProjectLocationInstanceSetIamPolicyCall) (response)
1178/// * [locations runtimes get iam policy projects](ProjectLocationRuntimeGetIamPolicyCall) (response)
1179/// * [locations runtimes set iam policy projects](ProjectLocationRuntimeSetIamPolicyCall) (response)
1180#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1181#[serde_with::serde_as]
1182#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1183pub struct Policy {
1184    /// 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`.
1185    pub bindings: Option<Vec<Binding>>,
1186    /// `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.
1187    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1188    pub etag: Option<Vec<u8>>,
1189    /// 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).
1190    pub version: Option<i32>,
1191}
1192
1193impl common::ResponseResult for Policy {}
1194
1195/// Request for getting a new access token.
1196///
1197/// # Activities
1198///
1199/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1200/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1201///
1202/// * [locations runtimes refresh runtime token internal projects](ProjectLocationRuntimeRefreshRuntimeTokenInternalCall) (request)
1203#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1204#[serde_with::serde_as]
1205#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1206pub struct RefreshRuntimeTokenInternalRequest {
1207    /// Required. The VM hardware token for authenticating the VM. https://cloud.google.com/compute/docs/instances/verifying-instance-identity
1208    #[serde(rename = "vmId")]
1209    pub vm_id: Option<String>,
1210}
1211
1212impl common::RequestValue for RefreshRuntimeTokenInternalRequest {}
1213
1214/// Response with a new access token.
1215///
1216/// # Activities
1217///
1218/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1219/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1220///
1221/// * [locations runtimes refresh runtime token internal projects](ProjectLocationRuntimeRefreshRuntimeTokenInternalCall) (response)
1222#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1223#[serde_with::serde_as]
1224#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1225pub struct RefreshRuntimeTokenInternalResponse {
1226    /// The OAuth 2.0 access token.
1227    #[serde(rename = "accessToken")]
1228    pub access_token: Option<String>,
1229    /// Output only. Token expiration time.
1230    #[serde(rename = "expireTime")]
1231    pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1232}
1233
1234impl common::ResponseResult for RefreshRuntimeTokenInternalResponse {}
1235
1236/// Request for registering a notebook instance.
1237///
1238/// # Activities
1239///
1240/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1241/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1242///
1243/// * [locations instances register projects](ProjectLocationInstanceRegisterCall) (request)
1244#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1245#[serde_with::serde_as]
1246#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1247pub struct RegisterInstanceRequest {
1248    /// 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.
1249    #[serde(rename = "instanceId")]
1250    pub instance_id: Option<String>,
1251}
1252
1253impl common::RequestValue for RegisterInstanceRequest {}
1254
1255/// Request for reporting a Managed Notebook Event.
1256///
1257/// # Activities
1258///
1259/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1260/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1261///
1262/// * [locations instances report event projects](ProjectLocationInstanceReportEventCall) (request)
1263#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1264#[serde_with::serde_as]
1265#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1266pub struct ReportInstanceEventRequest {
1267    /// Required. The Event to be reported.
1268    pub event: Option<Event>,
1269    /// Required. The VM hardware token for authenticating the VM. https://cloud.google.com/compute/docs/instances/verifying-instance-identity
1270    #[serde(rename = "vmId")]
1271    pub vm_id: Option<String>,
1272}
1273
1274impl common::RequestValue for ReportInstanceEventRequest {}
1275
1276/// Request for notebook instances to report information to Notebooks API.
1277///
1278/// # Activities
1279///
1280/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1281/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1282///
1283/// * [locations instances report projects](ProjectLocationInstanceReportCall) (request)
1284#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1285#[serde_with::serde_as]
1286#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1287pub struct ReportInstanceInfoRequest {
1288    /// The metadata reported to Notebooks API. This will be merged to the instance metadata store
1289    pub metadata: Option<HashMap<String, String>>,
1290    /// Required. The VM hardware token for authenticating the VM. https://cloud.google.com/compute/docs/instances/verifying-instance-identity
1291    #[serde(rename = "vmId")]
1292    pub vm_id: Option<String>,
1293}
1294
1295impl common::RequestValue for ReportInstanceInfoRequest {}
1296
1297/// Request for reporting a Managed Notebook Event.
1298///
1299/// # Activities
1300///
1301/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1302/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1303///
1304/// * [locations runtimes report event projects](ProjectLocationRuntimeReportEventCall) (request)
1305#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1306#[serde_with::serde_as]
1307#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1308pub struct ReportRuntimeEventRequest {
1309    /// Required. The Event to be reported.
1310    pub event: Option<Event>,
1311    /// Required. The VM hardware token for authenticating the VM. https://cloud.google.com/compute/docs/instances/verifying-instance-identity
1312    #[serde(rename = "vmId")]
1313    pub vm_id: Option<String>,
1314}
1315
1316impl common::RequestValue for ReportRuntimeEventRequest {}
1317
1318/// Reservation Affinity for consuming Zonal reservation.
1319///
1320/// This type is not used in any activity, and only used as *part* of another schema.
1321///
1322#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1323#[serde_with::serde_as]
1324#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1325pub struct ReservationAffinity {
1326    /// Optional. Type of reservation to consume
1327    #[serde(rename = "consumeReservationType")]
1328    pub consume_reservation_type: Option<String>,
1329    /// Optional. Corresponds to the label key of reservation resource.
1330    pub key: Option<String>,
1331    /// Optional. Corresponds to the label values of reservation resource.
1332    pub values: Option<Vec<String>>,
1333}
1334
1335impl common::Part for ReservationAffinity {}
1336
1337/// Request for resetting a notebook instance
1338///
1339/// # Activities
1340///
1341/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1342/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1343///
1344/// * [locations instances reset projects](ProjectLocationInstanceResetCall) (request)
1345#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1346#[serde_with::serde_as]
1347#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1348pub struct ResetInstanceRequest {
1349    _never_set: Option<bool>,
1350}
1351
1352impl common::RequestValue for ResetInstanceRequest {}
1353
1354/// Request for resetting a Managed Notebook Runtime.
1355///
1356/// # Activities
1357///
1358/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1359/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1360///
1361/// * [locations runtimes reset projects](ProjectLocationRuntimeResetCall) (request)
1362#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1363#[serde_with::serde_as]
1364#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1365pub struct ResetRuntimeRequest {
1366    /// Idempotent request UUID.
1367    #[serde(rename = "requestId")]
1368    pub request_id: Option<String>,
1369}
1370
1371impl common::RequestValue for ResetRuntimeRequest {}
1372
1373/// Request for rollbacking a notebook instance
1374///
1375/// # Activities
1376///
1377/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1378/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1379///
1380/// * [locations instances rollback projects](ProjectLocationInstanceRollbackCall) (request)
1381#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1382#[serde_with::serde_as]
1383#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1384pub struct RollbackInstanceRequest {
1385    /// Required. The snapshot for rollback. Example: `projects/test-project/global/snapshots/krwlzipynril`.
1386    #[serde(rename = "targetSnapshot")]
1387    pub target_snapshot: Option<String>,
1388}
1389
1390impl common::RequestValue for RollbackInstanceRequest {}
1391
1392/// The definition of a Runtime for a managed notebook instance.
1393///
1394/// # Activities
1395///
1396/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1397/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1398///
1399/// * [locations runtimes create projects](ProjectLocationRuntimeCreateCall) (request)
1400/// * [locations runtimes get projects](ProjectLocationRuntimeGetCall) (response)
1401/// * [locations runtimes patch projects](ProjectLocationRuntimePatchCall) (request)
1402#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1403#[serde_with::serde_as]
1404#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1405pub struct Runtime {
1406    /// The config settings for accessing runtime.
1407    #[serde(rename = "accessConfig")]
1408    pub access_config: Option<RuntimeAccessConfig>,
1409    /// Output only. Runtime creation time.
1410    #[serde(rename = "createTime")]
1411    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1412    /// Output only. Runtime health_state.
1413    #[serde(rename = "healthState")]
1414    pub health_state: Option<String>,
1415    /// 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.
1416    pub labels: Option<HashMap<String, String>>,
1417    /// Output only. Contains Runtime daemon metrics such as Service status and JupyterLab stats.
1418    pub metrics: Option<RuntimeMetrics>,
1419    /// Output only. Bool indicating whether this notebook has been migrated to a Workbench Instance
1420    pub migrated: Option<bool>,
1421    /// Output only. The resource name of the runtime. Format: `projects/{project}/locations/{location}/runtimes/{runtimeId}`
1422    pub name: Option<String>,
1423    /// Output only. Checks how feasible a migration from GmN to WbI is.
1424    #[serde(rename = "runtimeMigrationEligibility")]
1425    pub runtime_migration_eligibility: Option<RuntimeMigrationEligibility>,
1426    /// The config settings for software inside the runtime.
1427    #[serde(rename = "softwareConfig")]
1428    pub software_config: Option<RuntimeSoftwareConfig>,
1429    /// Output only. Runtime state.
1430    pub state: Option<String>,
1431    /// Output only. Runtime update time.
1432    #[serde(rename = "updateTime")]
1433    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1434    /// Use a Compute Engine VM image to start the managed notebook instance.
1435    #[serde(rename = "virtualMachine")]
1436    pub virtual_machine: Option<VirtualMachine>,
1437}
1438
1439impl common::RequestValue for Runtime {}
1440impl common::ResponseResult for Runtime {}
1441
1442/// 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`
1443///
1444/// This type is not used in any activity, and only used as *part* of another schema.
1445///
1446#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1447#[serde_with::serde_as]
1448#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1449pub struct RuntimeAcceleratorConfig {
1450    /// Count of cores of this accelerator.
1451    #[serde(rename = "coreCount")]
1452    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1453    pub core_count: Option<i64>,
1454    /// Accelerator model.
1455    #[serde(rename = "type")]
1456    pub type_: Option<String>,
1457}
1458
1459impl common::Part for RuntimeAcceleratorConfig {}
1460
1461/// Specifies the login configuration for Runtime
1462///
1463/// This type is not used in any activity, and only used as *part* of another schema.
1464///
1465#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1466#[serde_with::serde_as]
1467#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1468pub struct RuntimeAccessConfig {
1469    /// The type of access mode this instance.
1470    #[serde(rename = "accessType")]
1471    pub access_type: Option<String>,
1472    /// Output only. The proxy endpoint that is used to access the runtime.
1473    #[serde(rename = "proxyUri")]
1474    pub proxy_uri: Option<String>,
1475    /// The owner of this runtime after creation. Format: `alias@example.com` Currently supports one owner only.
1476    #[serde(rename = "runtimeOwner")]
1477    pub runtime_owner: Option<String>,
1478}
1479
1480impl common::Part for RuntimeAccessConfig {}
1481
1482/// 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.
1483///
1484/// This type is not used in any activity, and only used as *part* of another schema.
1485///
1486#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1487#[serde_with::serde_as]
1488#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1489pub struct RuntimeGuestOsFeature {
1490    /// 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`
1491    #[serde(rename = "type")]
1492    pub type_: Option<String>,
1493}
1494
1495impl common::Part for RuntimeGuestOsFeature {}
1496
1497/// Contains runtime daemon metrics, such as OS and kernels and sessions stats.
1498///
1499/// This type is not used in any activity, and only used as *part* of another schema.
1500///
1501#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1502#[serde_with::serde_as]
1503#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1504pub struct RuntimeMetrics {
1505    /// Output only. The system metrics.
1506    #[serde(rename = "systemMetrics")]
1507    pub system_metrics: Option<HashMap<String, String>>,
1508}
1509
1510impl common::Part for RuntimeMetrics {}
1511
1512/// RuntimeMigrationEligibility represents the feasibility information of a migration from GmN to WbI.
1513///
1514/// This type is not used in any activity, and only used as *part* of another schema.
1515///
1516#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1517#[serde_with::serde_as]
1518#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1519pub struct RuntimeMigrationEligibility {
1520    /// Output only. Certain configurations make the GmN ineligible for an automatic migration. A manual migration is required.
1521    pub errors: Option<Vec<String>>,
1522    /// Output only. Certain configurations will be defaulted during the migration.
1523    pub warnings: Option<Vec<String>>,
1524}
1525
1526impl common::Part for RuntimeMigrationEligibility {}
1527
1528/// 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.
1529///
1530/// This type is not used in any activity, and only used as *part* of another schema.
1531///
1532#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1533#[serde_with::serde_as]
1534#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1535pub struct RuntimeShieldedInstanceConfig {
1536    /// 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.
1537    #[serde(rename = "enableIntegrityMonitoring")]
1538    pub enable_integrity_monitoring: Option<bool>,
1539    /// 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.
1540    #[serde(rename = "enableSecureBoot")]
1541    pub enable_secure_boot: Option<bool>,
1542    /// Defines whether the instance has the vTPM enabled. Enabled by default.
1543    #[serde(rename = "enableVtpm")]
1544    pub enable_vtpm: Option<bool>,
1545}
1546
1547impl common::Part for RuntimeShieldedInstanceConfig {}
1548
1549/// 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`
1550///
1551/// This type is not used in any activity, and only used as *part* of another schema.
1552///
1553#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1554#[serde_with::serde_as]
1555#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1556pub struct RuntimeSoftwareConfig {
1557    /// Specify a custom Cloud Storage path where the GPU driver is stored. If not specified, we'll automatically choose from official GPU drivers.
1558    #[serde(rename = "customGpuDriverPath")]
1559    pub custom_gpu_driver_path: Option<String>,
1560    /// Bool indicating whether JupyterLab terminal will be available or not. Default: False
1561    #[serde(rename = "disableTerminal")]
1562    pub disable_terminal: Option<bool>,
1563    /// Verifies core internal services are running. Default: True
1564    #[serde(rename = "enableHealthMonitoring")]
1565    pub enable_health_monitoring: Option<bool>,
1566    /// Runtime will automatically shutdown after idle_shutdown_time. Default: True
1567    #[serde(rename = "idleShutdown")]
1568    pub idle_shutdown: Option<bool>,
1569    /// Time in minutes to wait before shutting down runtime. Default: 180 minutes
1570    #[serde(rename = "idleShutdownTimeout")]
1571    pub idle_shutdown_timeout: Option<i32>,
1572    /// Install Nvidia Driver automatically. Default: True
1573    #[serde(rename = "installGpuDriver")]
1574    pub install_gpu_driver: Option<bool>,
1575    /// Optional. Use a list of container images to use as Kernels in the notebook instance.
1576    pub kernels: Option<Vec<ContainerImage>>,
1577    /// Bool indicating whether mixer client should be disabled. Default: False
1578    #[serde(rename = "mixerDisabled")]
1579    pub mixer_disabled: Option<bool>,
1580    /// Cron expression in UTC timezone, used to schedule instance auto upgrade. Please follow the [cron format](https://en.wikipedia.org/wiki/Cron).
1581    #[serde(rename = "notebookUpgradeSchedule")]
1582    pub notebook_upgrade_schedule: Option<String>,
1583    /// 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`).
1584    #[serde(rename = "postStartupScript")]
1585    pub post_startup_script: Option<String>,
1586    /// Behavior for the post startup script.
1587    #[serde(rename = "postStartupScriptBehavior")]
1588    pub post_startup_script_behavior: Option<String>,
1589    /// Output only. Bool indicating whether an newer image is available in an image family.
1590    pub upgradeable: Option<bool>,
1591    /// Output only. version of boot image such as M100, from release label of the image.
1592    pub version: Option<String>,
1593}
1594
1595impl common::Part for RuntimeSoftwareConfig {}
1596
1597/// The definition of a schedule.
1598///
1599/// # Activities
1600///
1601/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1602/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1603///
1604/// * [locations schedules create projects](ProjectLocationScheduleCreateCall) (request)
1605/// * [locations schedules get projects](ProjectLocationScheduleGetCall) (response)
1606#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1607#[serde_with::serde_as]
1608#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1609pub struct Schedule {
1610    /// Output only. Time the schedule was created.
1611    #[serde(rename = "createTime")]
1612    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1613    /// 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
1614    #[serde(rename = "cronSchedule")]
1615    pub cron_schedule: Option<String>,
1616    /// A brief description of this environment.
1617    pub description: Option<String>,
1618    /// Output only. Display name used for UI purposes. Name can only contain alphanumeric characters, hyphens `-`, and underscores `_`.
1619    #[serde(rename = "displayName")]
1620    pub display_name: Option<String>,
1621    /// Notebook Execution Template corresponding to this schedule.
1622    #[serde(rename = "executionTemplate")]
1623    pub execution_template: Option<ExecutionTemplate>,
1624    /// Output only. The name of this schedule. Format: `projects/{project_id}/locations/{location}/schedules/{schedule_id}`
1625    pub name: Option<String>,
1626    /// Output only. The most recent execution names triggered from this schedule and their corresponding states.
1627    #[serde(rename = "recentExecutions")]
1628    pub recent_executions: Option<Vec<Execution>>,
1629    /// no description provided
1630    pub state: Option<String>,
1631    /// 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).
1632    #[serde(rename = "timeZone")]
1633    pub time_zone: Option<String>,
1634    /// Output only. Time the schedule was last updated.
1635    #[serde(rename = "updateTime")]
1636    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1637}
1638
1639impl common::RequestValue for Schedule {}
1640impl common::ResponseResult for Schedule {}
1641
1642/// 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.
1643///
1644/// This type is not used in any activity, and only used as *part* of another schema.
1645///
1646#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1647#[serde_with::serde_as]
1648#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1649pub struct SchedulerAcceleratorConfig {
1650    /// Count of cores of this accelerator.
1651    #[serde(rename = "coreCount")]
1652    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1653    pub core_count: Option<i64>,
1654    /// Type of this accelerator.
1655    #[serde(rename = "type")]
1656    pub type_: Option<String>,
1657}
1658
1659impl common::Part for SchedulerAcceleratorConfig {}
1660
1661/// Request message for `SetIamPolicy` method.
1662///
1663/// # Activities
1664///
1665/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1666/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1667///
1668/// * [locations instances set iam policy projects](ProjectLocationInstanceSetIamPolicyCall) (request)
1669/// * [locations runtimes set iam policy projects](ProjectLocationRuntimeSetIamPolicyCall) (request)
1670#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1671#[serde_with::serde_as]
1672#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1673pub struct SetIamPolicyRequest {
1674    /// 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.
1675    pub policy: Option<Policy>,
1676}
1677
1678impl common::RequestValue for SetIamPolicyRequest {}
1679
1680/// Request for setting instance accelerator.
1681///
1682/// # Activities
1683///
1684/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1685/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1686///
1687/// * [locations instances set accelerator projects](ProjectLocationInstanceSetAcceleratorCall) (request)
1688#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1689#[serde_with::serde_as]
1690#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1691pub struct SetInstanceAcceleratorRequest {
1692    /// 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.
1693    #[serde(rename = "coreCount")]
1694    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1695    pub core_count: Option<i64>,
1696    /// Required. Type of this accelerator.
1697    #[serde(rename = "type")]
1698    pub type_: Option<String>,
1699}
1700
1701impl common::RequestValue for SetInstanceAcceleratorRequest {}
1702
1703/// Request for setting instance labels.
1704///
1705/// # Activities
1706///
1707/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1708/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1709///
1710/// * [locations instances set labels projects](ProjectLocationInstanceSetLabelCall) (request)
1711#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1712#[serde_with::serde_as]
1713#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1714pub struct SetInstanceLabelsRequest {
1715    /// Labels to apply to this instance. These can be later modified by the setLabels method
1716    pub labels: Option<HashMap<String, String>>,
1717}
1718
1719impl common::RequestValue for SetInstanceLabelsRequest {}
1720
1721/// Request for setting instance machine type.
1722///
1723/// # Activities
1724///
1725/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1726/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1727///
1728/// * [locations instances set machine type projects](ProjectLocationInstanceSetMachineTypeCall) (request)
1729#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1730#[serde_with::serde_as]
1731#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1732pub struct SetInstanceMachineTypeRequest {
1733    /// Required. The [Compute Engine machine type](https://cloud.google.com/compute/docs/machine-types).
1734    #[serde(rename = "machineType")]
1735    pub machine_type: Option<String>,
1736}
1737
1738impl common::RequestValue for SetInstanceMachineTypeRequest {}
1739
1740/// 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.
1741///
1742/// This type is not used in any activity, and only used as *part* of another schema.
1743///
1744#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1745#[serde_with::serde_as]
1746#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1747pub struct ShieldedInstanceConfig {
1748    /// 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.
1749    #[serde(rename = "enableIntegrityMonitoring")]
1750    pub enable_integrity_monitoring: Option<bool>,
1751    /// 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.
1752    #[serde(rename = "enableSecureBoot")]
1753    pub enable_secure_boot: Option<bool>,
1754    /// Defines whether the instance has the vTPM enabled. Enabled by default.
1755    #[serde(rename = "enableVtpm")]
1756    pub enable_vtpm: Option<bool>,
1757}
1758
1759impl common::Part for ShieldedInstanceConfig {}
1760
1761/// Request for starting a notebook instance
1762///
1763/// # Activities
1764///
1765/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1766/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1767///
1768/// * [locations instances start projects](ProjectLocationInstanceStartCall) (request)
1769#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1770#[serde_with::serde_as]
1771#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1772pub struct StartInstanceRequest {
1773    _never_set: Option<bool>,
1774}
1775
1776impl common::RequestValue for StartInstanceRequest {}
1777
1778/// Request for starting a Managed Notebook Runtime.
1779///
1780/// # Activities
1781///
1782/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1783/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1784///
1785/// * [locations runtimes start projects](ProjectLocationRuntimeStartCall) (request)
1786#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1787#[serde_with::serde_as]
1788#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1789pub struct StartRuntimeRequest {
1790    /// Idempotent request UUID.
1791    #[serde(rename = "requestId")]
1792    pub request_id: Option<String>,
1793}
1794
1795impl common::RequestValue for StartRuntimeRequest {}
1796
1797/// 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).
1798///
1799/// This type is not used in any activity, and only used as *part* of another schema.
1800///
1801#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1802#[serde_with::serde_as]
1803#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1804pub struct Status {
1805    /// The status code, which should be an enum value of google.rpc.Code.
1806    pub code: Option<i32>,
1807    /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
1808    pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
1809    /// 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.
1810    pub message: Option<String>,
1811}
1812
1813impl common::Part for Status {}
1814
1815/// Request for stopping a notebook instance
1816///
1817/// # Activities
1818///
1819/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1820/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1821///
1822/// * [locations instances stop projects](ProjectLocationInstanceStopCall) (request)
1823#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1824#[serde_with::serde_as]
1825#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1826pub struct StopInstanceRequest {
1827    _never_set: Option<bool>,
1828}
1829
1830impl common::RequestValue for StopInstanceRequest {}
1831
1832/// Request for stopping a Managed Notebook Runtime.
1833///
1834/// # Activities
1835///
1836/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1837/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1838///
1839/// * [locations runtimes stop projects](ProjectLocationRuntimeStopCall) (request)
1840#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1841#[serde_with::serde_as]
1842#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1843pub struct StopRuntimeRequest {
1844    /// Idempotent request UUID.
1845    #[serde(rename = "requestId")]
1846    pub request_id: Option<String>,
1847}
1848
1849impl common::RequestValue for StopRuntimeRequest {}
1850
1851/// Request for switching a Managed Notebook Runtime.
1852///
1853/// # Activities
1854///
1855/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1856/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1857///
1858/// * [locations runtimes switch projects](ProjectLocationRuntimeSwitchCall) (request)
1859#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1860#[serde_with::serde_as]
1861#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1862pub struct SwitchRuntimeRequest {
1863    /// accelerator config.
1864    #[serde(rename = "acceleratorConfig")]
1865    pub accelerator_config: Option<RuntimeAcceleratorConfig>,
1866    /// machine type.
1867    #[serde(rename = "machineType")]
1868    pub machine_type: Option<String>,
1869    /// Idempotent request UUID.
1870    #[serde(rename = "requestId")]
1871    pub request_id: Option<String>,
1872}
1873
1874impl common::RequestValue for SwitchRuntimeRequest {}
1875
1876/// Request message for `TestIamPermissions` method.
1877///
1878/// # Activities
1879///
1880/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1881/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1882///
1883/// * [locations instances test iam permissions projects](ProjectLocationInstanceTestIamPermissionCall) (request)
1884/// * [locations runtimes test iam permissions projects](ProjectLocationRuntimeTestIamPermissionCall) (request)
1885#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1886#[serde_with::serde_as]
1887#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1888pub struct TestIamPermissionsRequest {
1889    /// 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).
1890    pub permissions: Option<Vec<String>>,
1891}
1892
1893impl common::RequestValue for TestIamPermissionsRequest {}
1894
1895/// Response message for `TestIamPermissions` method.
1896///
1897/// # Activities
1898///
1899/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1900/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1901///
1902/// * [locations instances test iam permissions projects](ProjectLocationInstanceTestIamPermissionCall) (response)
1903/// * [locations runtimes test iam permissions projects](ProjectLocationRuntimeTestIamPermissionCall) (response)
1904#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1905#[serde_with::serde_as]
1906#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1907pub struct TestIamPermissionsResponse {
1908    /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed.
1909    pub permissions: Option<Vec<String>>,
1910}
1911
1912impl common::ResponseResult for TestIamPermissionsResponse {}
1913
1914/// Request for created scheduled notebooks
1915///
1916/// # Activities
1917///
1918/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1919/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1920///
1921/// * [locations schedules trigger projects](ProjectLocationScheduleTriggerCall) (request)
1922#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1923#[serde_with::serde_as]
1924#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1925pub struct TriggerScheduleRequest {
1926    _never_set: Option<bool>,
1927}
1928
1929impl common::RequestValue for TriggerScheduleRequest {}
1930
1931/// Request for updating instance configurations.
1932///
1933/// # Activities
1934///
1935/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1936/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1937///
1938/// * [locations instances update config projects](ProjectLocationInstanceUpdateConfigCall) (request)
1939#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1940#[serde_with::serde_as]
1941#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1942pub struct UpdateInstanceConfigRequest {
1943    /// The instance configurations to be updated.
1944    pub config: Option<InstanceConfig>,
1945}
1946
1947impl common::RequestValue for UpdateInstanceConfigRequest {}
1948
1949/// Request for adding/changing metadata items for an instance.
1950///
1951/// # Activities
1952///
1953/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1954/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1955///
1956/// * [locations instances update metadata items projects](ProjectLocationInstanceUpdateMetadataItemCall) (request)
1957#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1958#[serde_with::serde_as]
1959#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1960pub struct UpdateInstanceMetadataItemsRequest {
1961    /// Metadata items to add/update for the instance.
1962    pub items: Option<HashMap<String, String>>,
1963}
1964
1965impl common::RequestValue for UpdateInstanceMetadataItemsRequest {}
1966
1967/// Response for adding/changing metadata items for an instance.
1968///
1969/// # Activities
1970///
1971/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1972/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1973///
1974/// * [locations instances update metadata items projects](ProjectLocationInstanceUpdateMetadataItemCall) (response)
1975#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1976#[serde_with::serde_as]
1977#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1978pub struct UpdateInstanceMetadataItemsResponse {
1979    /// Map of items that were added/updated to/in the metadata.
1980    pub items: Option<HashMap<String, String>>,
1981}
1982
1983impl common::ResponseResult for UpdateInstanceMetadataItemsResponse {}
1984
1985/// Request for updating the Shielded Instance config for a notebook instance. You can only use this method on a stopped instance
1986///
1987/// # Activities
1988///
1989/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1990/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1991///
1992/// * [locations instances update shielded instance config projects](ProjectLocationInstanceUpdateShieldedInstanceConfigCall) (request)
1993#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1994#[serde_with::serde_as]
1995#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1996pub struct UpdateShieldedInstanceConfigRequest {
1997    /// ShieldedInstance configuration to be updated.
1998    #[serde(rename = "shieldedInstanceConfig")]
1999    pub shielded_instance_config: Option<ShieldedInstanceConfig>,
2000}
2001
2002impl common::RequestValue for UpdateShieldedInstanceConfigRequest {}
2003
2004/// The entry of VM image upgrade history.
2005///
2006/// This type is not used in any activity, and only used as *part* of another schema.
2007///
2008#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2009#[serde_with::serde_as]
2010#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2011pub struct UpgradeHistoryEntry {
2012    /// Action. Rolloback or Upgrade.
2013    pub action: Option<String>,
2014    /// The container image before this instance upgrade.
2015    #[serde(rename = "containerImage")]
2016    pub container_image: Option<String>,
2017    /// The time that this instance upgrade history entry is created.
2018    #[serde(rename = "createTime")]
2019    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2020    /// The framework of this notebook instance.
2021    pub framework: Option<String>,
2022    /// The snapshot of the boot disk of this notebook instance before upgrade.
2023    pub snapshot: Option<String>,
2024    /// The state of this instance upgrade history entry.
2025    pub state: Option<String>,
2026    /// Target VM Image. Format: `ainotebooks-vm/project/image-name/name`.
2027    #[serde(rename = "targetImage")]
2028    pub target_image: Option<String>,
2029    /// Target VM Version, like m63.
2030    #[serde(rename = "targetVersion")]
2031    pub target_version: Option<String>,
2032    /// The version of the notebook instance before this upgrade.
2033    pub version: Option<String>,
2034    /// The VM image before this instance upgrade.
2035    #[serde(rename = "vmImage")]
2036    pub vm_image: Option<String>,
2037}
2038
2039impl common::Part for UpgradeHistoryEntry {}
2040
2041/// Request for upgrading a notebook instance from within the VM
2042///
2043/// # Activities
2044///
2045/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2046/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2047///
2048/// * [locations instances upgrade internal projects](ProjectLocationInstanceUpgradeInternalCall) (request)
2049#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2050#[serde_with::serde_as]
2051#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2052pub struct UpgradeInstanceInternalRequest {
2053    /// Optional. The optional UpgradeType. Setting this field will search for additional compute images to upgrade this instance.
2054    #[serde(rename = "type")]
2055    pub type_: Option<String>,
2056    /// Required. The VM hardware token for authenticating the VM. https://cloud.google.com/compute/docs/instances/verifying-instance-identity
2057    #[serde(rename = "vmId")]
2058    pub vm_id: Option<String>,
2059}
2060
2061impl common::RequestValue for UpgradeInstanceInternalRequest {}
2062
2063/// Request for upgrading a notebook instance
2064///
2065/// # Activities
2066///
2067/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2068/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2069///
2070/// * [locations instances upgrade projects](ProjectLocationInstanceUpgradeCall) (request)
2071#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2072#[serde_with::serde_as]
2073#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2074pub struct UpgradeInstanceRequest {
2075    /// Optional. The optional UpgradeType. Setting this field will search for additional compute images to upgrade this instance.
2076    #[serde(rename = "type")]
2077    pub type_: Option<String>,
2078}
2079
2080impl common::RequestValue for UpgradeInstanceRequest {}
2081
2082/// Request for upgrading a Managed Notebook Runtime to the latest version. option (google.api.message_visibility).restriction = “TRUSTED_TESTER,SPECIAL_TESTER”;
2083///
2084/// # Activities
2085///
2086/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2087/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2088///
2089/// * [locations runtimes upgrade projects](ProjectLocationRuntimeUpgradeCall) (request)
2090#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2091#[serde_with::serde_as]
2092#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2093pub struct UpgradeRuntimeRequest {
2094    /// Idempotent request UUID.
2095    #[serde(rename = "requestId")]
2096    pub request_id: Option<String>,
2097}
2098
2099impl common::RequestValue for UpgradeRuntimeRequest {}
2100
2101/// Parameters used in Vertex AI JobType executions.
2102///
2103/// This type is not used in any activity, and only used as *part* of another schema.
2104///
2105#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2106#[serde_with::serde_as]
2107#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2108pub struct VertexAIParameters {
2109    /// Environment variables. At most 100 environment variables can be specified and unique. Example: `GCP_BUCKET=gs://my-bucket/samples/`
2110    pub env: Option<HashMap<String, String>>,
2111    /// 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.
2112    pub network: Option<String>,
2113}
2114
2115impl common::Part for VertexAIParameters {}
2116
2117/// Runtime using Virtual Machine for computing.
2118///
2119/// This type is not used in any activity, and only used as *part* of another schema.
2120///
2121#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2122#[serde_with::serde_as]
2123#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2124pub struct VirtualMachine {
2125    /// Output only. The unique identifier of the Managed Compute Engine instance.
2126    #[serde(rename = "instanceId")]
2127    pub instance_id: Option<String>,
2128    /// Output only. The user-friendly name of the Managed Compute Engine instance.
2129    #[serde(rename = "instanceName")]
2130    pub instance_name: Option<String>,
2131    /// Virtual Machine configuration settings.
2132    #[serde(rename = "virtualMachineConfig")]
2133    pub virtual_machine_config: Option<VirtualMachineConfig>,
2134}
2135
2136impl common::Part for VirtualMachine {}
2137
2138/// The config settings for virtual machine.
2139///
2140/// This type is not used in any activity, and only used as *part* of another schema.
2141///
2142#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2143#[serde_with::serde_as]
2144#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2145pub struct VirtualMachineConfig {
2146    /// Optional. The Compute Engine accelerator configuration for this runtime.
2147    #[serde(rename = "acceleratorConfig")]
2148    pub accelerator_config: Option<RuntimeAcceleratorConfig>,
2149    /// Optional. Boot image metadata used for runtime upgradeability.
2150    #[serde(rename = "bootImage")]
2151    pub boot_image: Option<BootImage>,
2152    /// Optional. Use a list of container images to use as Kernels in the notebook instance.
2153    #[serde(rename = "containerImages")]
2154    pub container_images: Option<Vec<ContainerImage>>,
2155    /// Required. Data disk option configuration settings.
2156    #[serde(rename = "dataDisk")]
2157    pub data_disk: Option<LocalDisk>,
2158    /// Optional. Encryption settings for virtual machine data disk.
2159    #[serde(rename = "encryptionConfig")]
2160    pub encryption_config: Option<EncryptionConfig>,
2161    /// Output only. The Compute Engine guest attributes. (see [Project and instance guest attributes](https://cloud.google.com/compute/docs/storing-retrieving-metadata#guest_attributes)).
2162    #[serde(rename = "guestAttributes")]
2163    pub guest_attributes: Option<HashMap<String, String>>,
2164    /// 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.
2165    #[serde(rename = "internalIpOnly")]
2166    pub internal_ip_only: Option<bool>,
2167    /// 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.
2168    pub labels: Option<HashMap<String, String>>,
2169    /// Required. The Compute Engine machine type used for runtimes. Short name is valid. Examples: * `n1-standard-2` * `e2-standard-8`
2170    #[serde(rename = "machineType")]
2171    pub machine_type: Option<String>,
2172    /// 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)).
2173    pub metadata: Option<HashMap<String, String>>,
2174    /// 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.
2175    pub network: Option<String>,
2176    /// Optional. The type of vNIC to be used on this interface. This may be gVNIC or VirtioNet.
2177    #[serde(rename = "nicType")]
2178    pub nic_type: Option<String>,
2179    /// 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`
2180    #[serde(rename = "reservedIpRange")]
2181    pub reserved_ip_range: Option<String>,
2182    /// Optional. Shielded VM Instance configuration settings.
2183    #[serde(rename = "shieldedInstanceConfig")]
2184    pub shielded_instance_config: Option<RuntimeShieldedInstanceConfig>,
2185    /// 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`
2186    pub subnet: Option<String>,
2187    /// Optional. The Compute Engine tags to add to runtime (see [Tagging instances](https://cloud.google.com/compute/docs/label-or-tag-resources#tags)).
2188    pub tags: Option<Vec<String>>,
2189    /// 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`
2190    pub zone: Option<String>,
2191}
2192
2193impl common::Part for VirtualMachineConfig {}
2194
2195/// Definition of a custom Compute Engine virtual machine image for starting a notebook instance with the environment installed directly on the VM.
2196///
2197/// This type is not used in any activity, and only used as *part* of another schema.
2198///
2199#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2200#[serde_with::serde_as]
2201#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2202pub struct VmImage {
2203    /// Use this VM image family to find the image; the newest image in this family will be used.
2204    #[serde(rename = "imageFamily")]
2205    pub image_family: Option<String>,
2206    /// Use VM image name to find the image.
2207    #[serde(rename = "imageName")]
2208    pub image_name: Option<String>,
2209    /// Required. The name of the Google Cloud project that this VM image belongs to. Format: `{project_id}`
2210    pub project: Option<String>,
2211}
2212
2213impl common::Part for VmImage {}
2214
2215// ###################
2216// MethodBuilders ###
2217// #################
2218
2219/// A builder providing access to all methods supported on *project* resources.
2220/// It is not used directly, but through the [`AIPlatformNotebooks`] hub.
2221///
2222/// # Example
2223///
2224/// Instantiate a resource builder
2225///
2226/// ```test_harness,no_run
2227/// extern crate hyper;
2228/// extern crate hyper_rustls;
2229/// extern crate google_notebooks1 as notebooks1;
2230///
2231/// # async fn dox() {
2232/// use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2233///
2234/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2235/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2236///     secret,
2237///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2238/// ).build().await.unwrap();
2239///
2240/// let client = hyper_util::client::legacy::Client::builder(
2241///     hyper_util::rt::TokioExecutor::new()
2242/// )
2243/// .build(
2244///     hyper_rustls::HttpsConnectorBuilder::new()
2245///         .with_native_roots()
2246///         .unwrap()
2247///         .https_or_http()
2248///         .enable_http1()
2249///         .build()
2250/// );
2251/// let mut hub = AIPlatformNotebooks::new(client, auth);
2252/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2253/// // 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(...)`
2254/// // to build up your call.
2255/// let rb = hub.projects();
2256/// # }
2257/// ```
2258pub struct ProjectMethods<'a, C>
2259where
2260    C: 'a,
2261{
2262    hub: &'a AIPlatformNotebooks<C>,
2263}
2264
2265impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
2266
2267impl<'a, C> ProjectMethods<'a, C> {
2268    /// Create a builder to help you perform the following task:
2269    ///
2270    /// Creates a new Environment.
2271    ///
2272    /// # Arguments
2273    ///
2274    /// * `request` - No description provided.
2275    /// * `parent` - Required. Format: `projects/{project_id}/locations/{location}`
2276    pub fn locations_environments_create(
2277        &self,
2278        request: Environment,
2279        parent: &str,
2280    ) -> ProjectLocationEnvironmentCreateCall<'a, C> {
2281        ProjectLocationEnvironmentCreateCall {
2282            hub: self.hub,
2283            _request: request,
2284            _parent: parent.to_string(),
2285            _environment_id: Default::default(),
2286            _delegate: Default::default(),
2287            _additional_params: Default::default(),
2288            _scopes: Default::default(),
2289        }
2290    }
2291
2292    /// Create a builder to help you perform the following task:
2293    ///
2294    /// Deletes a single Environment.
2295    ///
2296    /// # Arguments
2297    ///
2298    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/environments/{environment_id}`
2299    pub fn locations_environments_delete(
2300        &self,
2301        name: &str,
2302    ) -> ProjectLocationEnvironmentDeleteCall<'a, C> {
2303        ProjectLocationEnvironmentDeleteCall {
2304            hub: self.hub,
2305            _name: name.to_string(),
2306            _delegate: Default::default(),
2307            _additional_params: Default::default(),
2308            _scopes: Default::default(),
2309        }
2310    }
2311
2312    /// Create a builder to help you perform the following task:
2313    ///
2314    /// Gets details of a single Environment.
2315    ///
2316    /// # Arguments
2317    ///
2318    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/environments/{environment_id}`
2319    pub fn locations_environments_get(
2320        &self,
2321        name: &str,
2322    ) -> ProjectLocationEnvironmentGetCall<'a, C> {
2323        ProjectLocationEnvironmentGetCall {
2324            hub: self.hub,
2325            _name: name.to_string(),
2326            _delegate: Default::default(),
2327            _additional_params: Default::default(),
2328            _scopes: Default::default(),
2329        }
2330    }
2331
2332    /// Create a builder to help you perform the following task:
2333    ///
2334    /// Lists environments in a project.
2335    ///
2336    /// # Arguments
2337    ///
2338    /// * `parent` - Required. Format: `projects/{project_id}/locations/{location}`
2339    pub fn locations_environments_list(
2340        &self,
2341        parent: &str,
2342    ) -> ProjectLocationEnvironmentListCall<'a, C> {
2343        ProjectLocationEnvironmentListCall {
2344            hub: self.hub,
2345            _parent: parent.to_string(),
2346            _page_token: Default::default(),
2347            _page_size: Default::default(),
2348            _delegate: Default::default(),
2349            _additional_params: Default::default(),
2350            _scopes: Default::default(),
2351        }
2352    }
2353
2354    /// Create a builder to help you perform the following task:
2355    ///
2356    /// Creates a new Execution in a given project and location.
2357    ///
2358    /// # Arguments
2359    ///
2360    /// * `request` - No description provided.
2361    /// * `parent` - Required. Format: `parent=projects/{project_id}/locations/{location}`
2362    pub fn locations_executions_create(
2363        &self,
2364        request: Execution,
2365        parent: &str,
2366    ) -> ProjectLocationExecutionCreateCall<'a, C> {
2367        ProjectLocationExecutionCreateCall {
2368            hub: self.hub,
2369            _request: request,
2370            _parent: parent.to_string(),
2371            _execution_id: 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    /// Deletes execution
2381    ///
2382    /// # Arguments
2383    ///
2384    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/executions/{execution_id}`
2385    pub fn locations_executions_delete(
2386        &self,
2387        name: &str,
2388    ) -> ProjectLocationExecutionDeleteCall<'a, C> {
2389        ProjectLocationExecutionDeleteCall {
2390            hub: self.hub,
2391            _name: name.to_string(),
2392            _delegate: Default::default(),
2393            _additional_params: Default::default(),
2394            _scopes: Default::default(),
2395        }
2396    }
2397
2398    /// Create a builder to help you perform the following task:
2399    ///
2400    /// Gets details of executions
2401    ///
2402    /// # Arguments
2403    ///
2404    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/executions/{execution_id}`
2405    pub fn locations_executions_get(&self, name: &str) -> ProjectLocationExecutionGetCall<'a, C> {
2406        ProjectLocationExecutionGetCall {
2407            hub: self.hub,
2408            _name: name.to_string(),
2409            _delegate: Default::default(),
2410            _additional_params: Default::default(),
2411            _scopes: Default::default(),
2412        }
2413    }
2414
2415    /// Create a builder to help you perform the following task:
2416    ///
2417    /// Lists executions in a given project and location
2418    ///
2419    /// # Arguments
2420    ///
2421    /// * `parent` - Required. Format: `parent=projects/{project_id}/locations/{location}`
2422    pub fn locations_executions_list(
2423        &self,
2424        parent: &str,
2425    ) -> ProjectLocationExecutionListCall<'a, C> {
2426        ProjectLocationExecutionListCall {
2427            hub: self.hub,
2428            _parent: parent.to_string(),
2429            _page_token: Default::default(),
2430            _page_size: Default::default(),
2431            _order_by: Default::default(),
2432            _filter: Default::default(),
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    /// Creates a new Instance in a given project and location.
2442    ///
2443    /// # Arguments
2444    ///
2445    /// * `request` - No description provided.
2446    /// * `parent` - Required. Format: `parent=projects/{project_id}/locations/{location}`
2447    pub fn locations_instances_create(
2448        &self,
2449        request: Instance,
2450        parent: &str,
2451    ) -> ProjectLocationInstanceCreateCall<'a, C> {
2452        ProjectLocationInstanceCreateCall {
2453            hub: self.hub,
2454            _request: request,
2455            _parent: parent.to_string(),
2456            _instance_id: 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    /// Deletes a single Instance.
2466    ///
2467    /// # Arguments
2468    ///
2469    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2470    pub fn locations_instances_delete(
2471        &self,
2472        name: &str,
2473    ) -> ProjectLocationInstanceDeleteCall<'a, C> {
2474        ProjectLocationInstanceDeleteCall {
2475            hub: self.hub,
2476            _name: name.to_string(),
2477            _delegate: Default::default(),
2478            _additional_params: Default::default(),
2479            _scopes: Default::default(),
2480        }
2481    }
2482
2483    /// Create a builder to help you perform the following task:
2484    ///
2485    /// Creates a Diagnostic File and runs Diagnostic Tool given an Instance.
2486    ///
2487    /// # Arguments
2488    ///
2489    /// * `request` - No description provided.
2490    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2491    pub fn locations_instances_diagnose(
2492        &self,
2493        request: DiagnoseInstanceRequest,
2494        name: &str,
2495    ) -> ProjectLocationInstanceDiagnoseCall<'a, C> {
2496        ProjectLocationInstanceDiagnoseCall {
2497            hub: self.hub,
2498            _request: request,
2499            _name: name.to_string(),
2500            _delegate: Default::default(),
2501            _additional_params: Default::default(),
2502            _scopes: Default::default(),
2503        }
2504    }
2505
2506    /// Create a builder to help you perform the following task:
2507    ///
2508    /// Gets details of a single Instance.
2509    ///
2510    /// # Arguments
2511    ///
2512    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2513    pub fn locations_instances_get(&self, name: &str) -> ProjectLocationInstanceGetCall<'a, C> {
2514        ProjectLocationInstanceGetCall {
2515            hub: self.hub,
2516            _name: name.to_string(),
2517            _delegate: Default::default(),
2518            _additional_params: Default::default(),
2519            _scopes: Default::default(),
2520        }
2521    }
2522
2523    /// Create a builder to help you perform the following task:
2524    ///
2525    /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
2526    ///
2527    /// # Arguments
2528    ///
2529    /// * `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.
2530    pub fn locations_instances_get_iam_policy(
2531        &self,
2532        resource: &str,
2533    ) -> ProjectLocationInstanceGetIamPolicyCall<'a, C> {
2534        ProjectLocationInstanceGetIamPolicyCall {
2535            hub: self.hub,
2536            _resource: resource.to_string(),
2537            _options_requested_policy_version: Default::default(),
2538            _delegate: Default::default(),
2539            _additional_params: Default::default(),
2540            _scopes: Default::default(),
2541        }
2542    }
2543
2544    /// Create a builder to help you perform the following task:
2545    ///
2546    /// Checks whether a notebook instance is healthy.
2547    ///
2548    /// # Arguments
2549    ///
2550    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2551    pub fn locations_instances_get_instance_health(
2552        &self,
2553        name: &str,
2554    ) -> ProjectLocationInstanceGetInstanceHealthCall<'a, C> {
2555        ProjectLocationInstanceGetInstanceHealthCall {
2556            hub: self.hub,
2557            _name: name.to_string(),
2558            _delegate: Default::default(),
2559            _additional_params: Default::default(),
2560            _scopes: Default::default(),
2561        }
2562    }
2563
2564    /// Create a builder to help you perform the following task:
2565    ///
2566    /// Checks whether a notebook instance is upgradable.
2567    ///
2568    /// # Arguments
2569    ///
2570    /// * `notebookInstance` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2571    pub fn locations_instances_is_upgradeable(
2572        &self,
2573        notebook_instance: &str,
2574    ) -> ProjectLocationInstanceIsUpgradeableCall<'a, C> {
2575        ProjectLocationInstanceIsUpgradeableCall {
2576            hub: self.hub,
2577            _notebook_instance: notebook_instance.to_string(),
2578            _type_: Default::default(),
2579            _delegate: Default::default(),
2580            _additional_params: Default::default(),
2581            _scopes: Default::default(),
2582        }
2583    }
2584
2585    /// Create a builder to help you perform the following task:
2586    ///
2587    /// Lists instances in a given project and location.
2588    ///
2589    /// # Arguments
2590    ///
2591    /// * `parent` - Required. Format: `parent=projects/{project_id}/locations/{location}`
2592    pub fn locations_instances_list(&self, parent: &str) -> ProjectLocationInstanceListCall<'a, C> {
2593        ProjectLocationInstanceListCall {
2594            hub: self.hub,
2595            _parent: parent.to_string(),
2596            _page_token: Default::default(),
2597            _page_size: Default::default(),
2598            _order_by: Default::default(),
2599            _filter: Default::default(),
2600            _delegate: Default::default(),
2601            _additional_params: Default::default(),
2602            _scopes: Default::default(),
2603        }
2604    }
2605
2606    /// Create a builder to help you perform the following task:
2607    ///
2608    /// Migrates an existing User-Managed Notebook to Workbench Instances.
2609    ///
2610    /// # Arguments
2611    ///
2612    /// * `request` - No description provided.
2613    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2614    pub fn locations_instances_migrate(
2615        &self,
2616        request: MigrateInstanceRequest,
2617        name: &str,
2618    ) -> ProjectLocationInstanceMigrateCall<'a, C> {
2619        ProjectLocationInstanceMigrateCall {
2620            hub: self.hub,
2621            _request: request,
2622            _name: name.to_string(),
2623            _delegate: Default::default(),
2624            _additional_params: Default::default(),
2625            _scopes: Default::default(),
2626        }
2627    }
2628
2629    /// Create a builder to help you perform the following task:
2630    ///
2631    /// 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.
2632    ///
2633    /// # Arguments
2634    ///
2635    /// * `request` - No description provided.
2636    /// * `parent` - Required. Format: `parent=projects/{project_id}/locations/{location}`
2637    pub fn locations_instances_register(
2638        &self,
2639        request: RegisterInstanceRequest,
2640        parent: &str,
2641    ) -> ProjectLocationInstanceRegisterCall<'a, C> {
2642        ProjectLocationInstanceRegisterCall {
2643            hub: self.hub,
2644            _request: request,
2645            _parent: parent.to_string(),
2646            _delegate: Default::default(),
2647            _additional_params: Default::default(),
2648            _scopes: Default::default(),
2649        }
2650    }
2651
2652    /// Create a builder to help you perform the following task:
2653    ///
2654    /// 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.
2655    ///
2656    /// # Arguments
2657    ///
2658    /// * `request` - No description provided.
2659    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2660    pub fn locations_instances_report(
2661        &self,
2662        request: ReportInstanceInfoRequest,
2663        name: &str,
2664    ) -> ProjectLocationInstanceReportCall<'a, C> {
2665        ProjectLocationInstanceReportCall {
2666            hub: self.hub,
2667            _request: request,
2668            _name: name.to_string(),
2669            _delegate: Default::default(),
2670            _additional_params: Default::default(),
2671            _scopes: Default::default(),
2672        }
2673    }
2674
2675    /// Create a builder to help you perform the following task:
2676    ///
2677    /// Reports and processes an instance event.
2678    ///
2679    /// # Arguments
2680    ///
2681    /// * `request` - No description provided.
2682    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2683    pub fn locations_instances_report_event(
2684        &self,
2685        request: ReportInstanceEventRequest,
2686        name: &str,
2687    ) -> ProjectLocationInstanceReportEventCall<'a, C> {
2688        ProjectLocationInstanceReportEventCall {
2689            hub: self.hub,
2690            _request: request,
2691            _name: name.to_string(),
2692            _delegate: Default::default(),
2693            _additional_params: Default::default(),
2694            _scopes: Default::default(),
2695        }
2696    }
2697
2698    /// Create a builder to help you perform the following task:
2699    ///
2700    /// Resets a notebook instance.
2701    ///
2702    /// # Arguments
2703    ///
2704    /// * `request` - No description provided.
2705    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2706    pub fn locations_instances_reset(
2707        &self,
2708        request: ResetInstanceRequest,
2709        name: &str,
2710    ) -> ProjectLocationInstanceResetCall<'a, C> {
2711        ProjectLocationInstanceResetCall {
2712            hub: self.hub,
2713            _request: request,
2714            _name: name.to_string(),
2715            _delegate: Default::default(),
2716            _additional_params: Default::default(),
2717            _scopes: Default::default(),
2718        }
2719    }
2720
2721    /// Create a builder to help you perform the following task:
2722    ///
2723    /// Rollbacks a notebook instance to the previous version.
2724    ///
2725    /// # Arguments
2726    ///
2727    /// * `request` - No description provided.
2728    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2729    pub fn locations_instances_rollback(
2730        &self,
2731        request: RollbackInstanceRequest,
2732        name: &str,
2733    ) -> ProjectLocationInstanceRollbackCall<'a, C> {
2734        ProjectLocationInstanceRollbackCall {
2735            hub: self.hub,
2736            _request: request,
2737            _name: name.to_string(),
2738            _delegate: Default::default(),
2739            _additional_params: Default::default(),
2740            _scopes: Default::default(),
2741        }
2742    }
2743
2744    /// Create a builder to help you perform the following task:
2745    ///
2746    /// Updates the guest accelerators of a single Instance.
2747    ///
2748    /// # Arguments
2749    ///
2750    /// * `request` - No description provided.
2751    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2752    pub fn locations_instances_set_accelerator(
2753        &self,
2754        request: SetInstanceAcceleratorRequest,
2755        name: &str,
2756    ) -> ProjectLocationInstanceSetAcceleratorCall<'a, C> {
2757        ProjectLocationInstanceSetAcceleratorCall {
2758            hub: self.hub,
2759            _request: request,
2760            _name: name.to_string(),
2761            _delegate: Default::default(),
2762            _additional_params: Default::default(),
2763            _scopes: Default::default(),
2764        }
2765    }
2766
2767    /// Create a builder to help you perform the following task:
2768    ///
2769    /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
2770    ///
2771    /// # Arguments
2772    ///
2773    /// * `request` - No description provided.
2774    /// * `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.
2775    pub fn locations_instances_set_iam_policy(
2776        &self,
2777        request: SetIamPolicyRequest,
2778        resource: &str,
2779    ) -> ProjectLocationInstanceSetIamPolicyCall<'a, C> {
2780        ProjectLocationInstanceSetIamPolicyCall {
2781            hub: self.hub,
2782            _request: request,
2783            _resource: resource.to_string(),
2784            _delegate: Default::default(),
2785            _additional_params: Default::default(),
2786            _scopes: Default::default(),
2787        }
2788    }
2789
2790    /// Create a builder to help you perform the following task:
2791    ///
2792    /// Replaces all the labels of an Instance.
2793    ///
2794    /// # Arguments
2795    ///
2796    /// * `request` - No description provided.
2797    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2798    pub fn locations_instances_set_labels(
2799        &self,
2800        request: SetInstanceLabelsRequest,
2801        name: &str,
2802    ) -> ProjectLocationInstanceSetLabelCall<'a, C> {
2803        ProjectLocationInstanceSetLabelCall {
2804            hub: self.hub,
2805            _request: request,
2806            _name: name.to_string(),
2807            _delegate: Default::default(),
2808            _additional_params: Default::default(),
2809            _scopes: Default::default(),
2810        }
2811    }
2812
2813    /// Create a builder to help you perform the following task:
2814    ///
2815    /// Updates the machine type of a single Instance.
2816    ///
2817    /// # Arguments
2818    ///
2819    /// * `request` - No description provided.
2820    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2821    pub fn locations_instances_set_machine_type(
2822        &self,
2823        request: SetInstanceMachineTypeRequest,
2824        name: &str,
2825    ) -> ProjectLocationInstanceSetMachineTypeCall<'a, C> {
2826        ProjectLocationInstanceSetMachineTypeCall {
2827            hub: self.hub,
2828            _request: request,
2829            _name: name.to_string(),
2830            _delegate: Default::default(),
2831            _additional_params: Default::default(),
2832            _scopes: Default::default(),
2833        }
2834    }
2835
2836    /// Create a builder to help you perform the following task:
2837    ///
2838    /// Starts a notebook instance.
2839    ///
2840    /// # Arguments
2841    ///
2842    /// * `request` - No description provided.
2843    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2844    pub fn locations_instances_start(
2845        &self,
2846        request: StartInstanceRequest,
2847        name: &str,
2848    ) -> ProjectLocationInstanceStartCall<'a, C> {
2849        ProjectLocationInstanceStartCall {
2850            hub: self.hub,
2851            _request: request,
2852            _name: name.to_string(),
2853            _delegate: Default::default(),
2854            _additional_params: Default::default(),
2855            _scopes: Default::default(),
2856        }
2857    }
2858
2859    /// Create a builder to help you perform the following task:
2860    ///
2861    /// Stops a notebook instance.
2862    ///
2863    /// # Arguments
2864    ///
2865    /// * `request` - No description provided.
2866    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2867    pub fn locations_instances_stop(
2868        &self,
2869        request: StopInstanceRequest,
2870        name: &str,
2871    ) -> ProjectLocationInstanceStopCall<'a, C> {
2872        ProjectLocationInstanceStopCall {
2873            hub: self.hub,
2874            _request: request,
2875            _name: name.to_string(),
2876            _delegate: Default::default(),
2877            _additional_params: Default::default(),
2878            _scopes: Default::default(),
2879        }
2880    }
2881
2882    /// Create a builder to help you perform the following task:
2883    ///
2884    /// 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.
2885    ///
2886    /// # Arguments
2887    ///
2888    /// * `request` - No description provided.
2889    /// * `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.
2890    pub fn locations_instances_test_iam_permissions(
2891        &self,
2892        request: TestIamPermissionsRequest,
2893        resource: &str,
2894    ) -> ProjectLocationInstanceTestIamPermissionCall<'a, C> {
2895        ProjectLocationInstanceTestIamPermissionCall {
2896            hub: self.hub,
2897            _request: request,
2898            _resource: resource.to_string(),
2899            _delegate: Default::default(),
2900            _additional_params: Default::default(),
2901            _scopes: Default::default(),
2902        }
2903    }
2904
2905    /// Create a builder to help you perform the following task:
2906    ///
2907    /// Update Notebook Instance configurations.
2908    ///
2909    /// # Arguments
2910    ///
2911    /// * `request` - No description provided.
2912    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2913    pub fn locations_instances_update_config(
2914        &self,
2915        request: UpdateInstanceConfigRequest,
2916        name: &str,
2917    ) -> ProjectLocationInstanceUpdateConfigCall<'a, C> {
2918        ProjectLocationInstanceUpdateConfigCall {
2919            hub: self.hub,
2920            _request: request,
2921            _name: name.to_string(),
2922            _delegate: Default::default(),
2923            _additional_params: Default::default(),
2924            _scopes: Default::default(),
2925        }
2926    }
2927
2928    /// Create a builder to help you perform the following task:
2929    ///
2930    /// Add/update metadata items for an instance.
2931    ///
2932    /// # Arguments
2933    ///
2934    /// * `request` - No description provided.
2935    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2936    pub fn locations_instances_update_metadata_items(
2937        &self,
2938        request: UpdateInstanceMetadataItemsRequest,
2939        name: &str,
2940    ) -> ProjectLocationInstanceUpdateMetadataItemCall<'a, C> {
2941        ProjectLocationInstanceUpdateMetadataItemCall {
2942            hub: self.hub,
2943            _request: request,
2944            _name: name.to_string(),
2945            _delegate: Default::default(),
2946            _additional_params: Default::default(),
2947            _scopes: Default::default(),
2948        }
2949    }
2950
2951    /// Create a builder to help you perform the following task:
2952    ///
2953    /// Updates the Shielded instance configuration of a single Instance.
2954    ///
2955    /// # Arguments
2956    ///
2957    /// * `request` - No description provided.
2958    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2959    pub fn locations_instances_update_shielded_instance_config(
2960        &self,
2961        request: UpdateShieldedInstanceConfigRequest,
2962        name: &str,
2963    ) -> ProjectLocationInstanceUpdateShieldedInstanceConfigCall<'a, C> {
2964        ProjectLocationInstanceUpdateShieldedInstanceConfigCall {
2965            hub: self.hub,
2966            _request: request,
2967            _name: name.to_string(),
2968            _delegate: Default::default(),
2969            _additional_params: Default::default(),
2970            _scopes: Default::default(),
2971        }
2972    }
2973
2974    /// Create a builder to help you perform the following task:
2975    ///
2976    /// Upgrades a notebook instance to the latest version.
2977    ///
2978    /// # Arguments
2979    ///
2980    /// * `request` - No description provided.
2981    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
2982    pub fn locations_instances_upgrade(
2983        &self,
2984        request: UpgradeInstanceRequest,
2985        name: &str,
2986    ) -> ProjectLocationInstanceUpgradeCall<'a, C> {
2987        ProjectLocationInstanceUpgradeCall {
2988            hub: self.hub,
2989            _request: request,
2990            _name: name.to_string(),
2991            _delegate: Default::default(),
2992            _additional_params: Default::default(),
2993            _scopes: Default::default(),
2994        }
2995    }
2996
2997    /// Create a builder to help you perform the following task:
2998    ///
2999    /// Allows notebook instances to call this endpoint to upgrade themselves. Do not use this method directly.
3000    ///
3001    /// # Arguments
3002    ///
3003    /// * `request` - No description provided.
3004    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
3005    pub fn locations_instances_upgrade_internal(
3006        &self,
3007        request: UpgradeInstanceInternalRequest,
3008        name: &str,
3009    ) -> ProjectLocationInstanceUpgradeInternalCall<'a, C> {
3010        ProjectLocationInstanceUpgradeInternalCall {
3011            hub: self.hub,
3012            _request: request,
3013            _name: name.to_string(),
3014            _delegate: Default::default(),
3015            _additional_params: Default::default(),
3016            _scopes: Default::default(),
3017        }
3018    }
3019
3020    /// Create a builder to help you perform the following task:
3021    ///
3022    /// 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`.
3023    ///
3024    /// # Arguments
3025    ///
3026    /// * `request` - No description provided.
3027    /// * `name` - The name of the operation resource to be cancelled.
3028    pub fn locations_operations_cancel(
3029        &self,
3030        request: CancelOperationRequest,
3031        name: &str,
3032    ) -> ProjectLocationOperationCancelCall<'a, C> {
3033        ProjectLocationOperationCancelCall {
3034            hub: self.hub,
3035            _request: request,
3036            _name: name.to_string(),
3037            _delegate: Default::default(),
3038            _additional_params: Default::default(),
3039            _scopes: Default::default(),
3040        }
3041    }
3042
3043    /// Create a builder to help you perform the following task:
3044    ///
3045    /// 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`.
3046    ///
3047    /// # Arguments
3048    ///
3049    /// * `name` - The name of the operation resource to be deleted.
3050    pub fn locations_operations_delete(
3051        &self,
3052        name: &str,
3053    ) -> ProjectLocationOperationDeleteCall<'a, C> {
3054        ProjectLocationOperationDeleteCall {
3055            hub: self.hub,
3056            _name: name.to_string(),
3057            _delegate: Default::default(),
3058            _additional_params: Default::default(),
3059            _scopes: Default::default(),
3060        }
3061    }
3062
3063    /// Create a builder to help you perform the following task:
3064    ///
3065    /// 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.
3066    ///
3067    /// # Arguments
3068    ///
3069    /// * `name` - The name of the operation resource.
3070    pub fn locations_operations_get(&self, name: &str) -> ProjectLocationOperationGetCall<'a, C> {
3071        ProjectLocationOperationGetCall {
3072            hub: self.hub,
3073            _name: name.to_string(),
3074            _delegate: Default::default(),
3075            _additional_params: Default::default(),
3076            _scopes: Default::default(),
3077        }
3078    }
3079
3080    /// Create a builder to help you perform the following task:
3081    ///
3082    /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
3083    ///
3084    /// # Arguments
3085    ///
3086    /// * `name` - The name of the operation's parent resource.
3087    pub fn locations_operations_list(&self, name: &str) -> ProjectLocationOperationListCall<'a, C> {
3088        ProjectLocationOperationListCall {
3089            hub: self.hub,
3090            _name: name.to_string(),
3091            _page_token: Default::default(),
3092            _page_size: Default::default(),
3093            _filter: Default::default(),
3094            _delegate: Default::default(),
3095            _additional_params: Default::default(),
3096            _scopes: Default::default(),
3097        }
3098    }
3099
3100    /// Create a builder to help you perform the following task:
3101    ///
3102    /// Creates a new Runtime in a given project and location.
3103    ///
3104    /// # Arguments
3105    ///
3106    /// * `request` - No description provided.
3107    /// * `parent` - Required. Format: `parent=projects/{project_id}/locations/{location}`
3108    pub fn locations_runtimes_create(
3109        &self,
3110        request: Runtime,
3111        parent: &str,
3112    ) -> ProjectLocationRuntimeCreateCall<'a, C> {
3113        ProjectLocationRuntimeCreateCall {
3114            hub: self.hub,
3115            _request: request,
3116            _parent: parent.to_string(),
3117            _runtime_id: Default::default(),
3118            _request_id: 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    /// Deletes a single Runtime.
3128    ///
3129    /// # Arguments
3130    ///
3131    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
3132    pub fn locations_runtimes_delete(&self, name: &str) -> ProjectLocationRuntimeDeleteCall<'a, C> {
3133        ProjectLocationRuntimeDeleteCall {
3134            hub: self.hub,
3135            _name: name.to_string(),
3136            _request_id: Default::default(),
3137            _delegate: Default::default(),
3138            _additional_params: Default::default(),
3139            _scopes: Default::default(),
3140        }
3141    }
3142
3143    /// Create a builder to help you perform the following task:
3144    ///
3145    /// Creates a Diagnostic File and runs Diagnostic Tool given a Runtime.
3146    ///
3147    /// # Arguments
3148    ///
3149    /// * `request` - No description provided.
3150    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtimes_id}`
3151    pub fn locations_runtimes_diagnose(
3152        &self,
3153        request: DiagnoseRuntimeRequest,
3154        name: &str,
3155    ) -> ProjectLocationRuntimeDiagnoseCall<'a, C> {
3156        ProjectLocationRuntimeDiagnoseCall {
3157            hub: self.hub,
3158            _request: request,
3159            _name: name.to_string(),
3160            _delegate: Default::default(),
3161            _additional_params: Default::default(),
3162            _scopes: Default::default(),
3163        }
3164    }
3165
3166    /// Create a builder to help you perform the following task:
3167    ///
3168    /// Gets details of a single Runtime. The location must be a regional endpoint rather than zonal.
3169    ///
3170    /// # Arguments
3171    ///
3172    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
3173    pub fn locations_runtimes_get(&self, name: &str) -> ProjectLocationRuntimeGetCall<'a, C> {
3174        ProjectLocationRuntimeGetCall {
3175            hub: self.hub,
3176            _name: name.to_string(),
3177            _delegate: Default::default(),
3178            _additional_params: Default::default(),
3179            _scopes: Default::default(),
3180        }
3181    }
3182
3183    /// Create a builder to help you perform the following task:
3184    ///
3185    /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
3186    ///
3187    /// # Arguments
3188    ///
3189    /// * `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.
3190    pub fn locations_runtimes_get_iam_policy(
3191        &self,
3192        resource: &str,
3193    ) -> ProjectLocationRuntimeGetIamPolicyCall<'a, C> {
3194        ProjectLocationRuntimeGetIamPolicyCall {
3195            hub: self.hub,
3196            _resource: resource.to_string(),
3197            _options_requested_policy_version: Default::default(),
3198            _delegate: Default::default(),
3199            _additional_params: Default::default(),
3200            _scopes: Default::default(),
3201        }
3202    }
3203
3204    /// Create a builder to help you perform the following task:
3205    ///
3206    /// Lists Runtimes in a given project and location.
3207    ///
3208    /// # Arguments
3209    ///
3210    /// * `parent` - Required. Format: `parent=projects/{project_id}/locations/{location}`
3211    pub fn locations_runtimes_list(&self, parent: &str) -> ProjectLocationRuntimeListCall<'a, C> {
3212        ProjectLocationRuntimeListCall {
3213            hub: self.hub,
3214            _parent: parent.to_string(),
3215            _page_token: Default::default(),
3216            _page_size: Default::default(),
3217            _order_by: Default::default(),
3218            _filter: Default::default(),
3219            _delegate: Default::default(),
3220            _additional_params: Default::default(),
3221            _scopes: Default::default(),
3222        }
3223    }
3224
3225    /// Create a builder to help you perform the following task:
3226    ///
3227    /// Migrate an existing Runtime to a new Workbench Instance.
3228    ///
3229    /// # Arguments
3230    ///
3231    /// * `request` - No description provided.
3232    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
3233    pub fn locations_runtimes_migrate(
3234        &self,
3235        request: MigrateRuntimeRequest,
3236        name: &str,
3237    ) -> ProjectLocationRuntimeMigrateCall<'a, C> {
3238        ProjectLocationRuntimeMigrateCall {
3239            hub: self.hub,
3240            _request: request,
3241            _name: name.to_string(),
3242            _delegate: Default::default(),
3243            _additional_params: Default::default(),
3244            _scopes: Default::default(),
3245        }
3246    }
3247
3248    /// Create a builder to help you perform the following task:
3249    ///
3250    /// Update Notebook Runtime configuration.
3251    ///
3252    /// # Arguments
3253    ///
3254    /// * `request` - No description provided.
3255    /// * `name` - Output only. The resource name of the runtime. Format: `projects/{project}/locations/{location}/runtimes/{runtimeId}`
3256    pub fn locations_runtimes_patch(
3257        &self,
3258        request: Runtime,
3259        name: &str,
3260    ) -> ProjectLocationRuntimePatchCall<'a, C> {
3261        ProjectLocationRuntimePatchCall {
3262            hub: self.hub,
3263            _request: request,
3264            _name: name.to_string(),
3265            _update_mask: Default::default(),
3266            _request_id: Default::default(),
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    /// Gets an access token for the consumer service account that the customer attached to the runtime. Only accessible from the tenant instance.
3276    ///
3277    /// # Arguments
3278    ///
3279    /// * `request` - No description provided.
3280    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
3281    pub fn locations_runtimes_refresh_runtime_token_internal(
3282        &self,
3283        request: RefreshRuntimeTokenInternalRequest,
3284        name: &str,
3285    ) -> ProjectLocationRuntimeRefreshRuntimeTokenInternalCall<'a, C> {
3286        ProjectLocationRuntimeRefreshRuntimeTokenInternalCall {
3287            hub: self.hub,
3288            _request: request,
3289            _name: name.to_string(),
3290            _delegate: Default::default(),
3291            _additional_params: Default::default(),
3292            _scopes: Default::default(),
3293        }
3294    }
3295
3296    /// Create a builder to help you perform the following task:
3297    ///
3298    /// Reports and processes a runtime event.
3299    ///
3300    /// # Arguments
3301    ///
3302    /// * `request` - No description provided.
3303    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
3304    pub fn locations_runtimes_report_event(
3305        &self,
3306        request: ReportRuntimeEventRequest,
3307        name: &str,
3308    ) -> ProjectLocationRuntimeReportEventCall<'a, C> {
3309        ProjectLocationRuntimeReportEventCall {
3310            hub: self.hub,
3311            _request: request,
3312            _name: name.to_string(),
3313            _delegate: Default::default(),
3314            _additional_params: Default::default(),
3315            _scopes: Default::default(),
3316        }
3317    }
3318
3319    /// Create a builder to help you perform the following task:
3320    ///
3321    /// Resets a Managed Notebook Runtime.
3322    ///
3323    /// # Arguments
3324    ///
3325    /// * `request` - No description provided.
3326    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
3327    pub fn locations_runtimes_reset(
3328        &self,
3329        request: ResetRuntimeRequest,
3330        name: &str,
3331    ) -> ProjectLocationRuntimeResetCall<'a, C> {
3332        ProjectLocationRuntimeResetCall {
3333            hub: self.hub,
3334            _request: request,
3335            _name: name.to_string(),
3336            _delegate: Default::default(),
3337            _additional_params: Default::default(),
3338            _scopes: Default::default(),
3339        }
3340    }
3341
3342    /// Create a builder to help you perform the following task:
3343    ///
3344    /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
3345    ///
3346    /// # Arguments
3347    ///
3348    /// * `request` - No description provided.
3349    /// * `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.
3350    pub fn locations_runtimes_set_iam_policy(
3351        &self,
3352        request: SetIamPolicyRequest,
3353        resource: &str,
3354    ) -> ProjectLocationRuntimeSetIamPolicyCall<'a, C> {
3355        ProjectLocationRuntimeSetIamPolicyCall {
3356            hub: self.hub,
3357            _request: request,
3358            _resource: resource.to_string(),
3359            _delegate: Default::default(),
3360            _additional_params: Default::default(),
3361            _scopes: Default::default(),
3362        }
3363    }
3364
3365    /// Create a builder to help you perform the following task:
3366    ///
3367    /// 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
3368    ///
3369    /// # Arguments
3370    ///
3371    /// * `request` - No description provided.
3372    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
3373    pub fn locations_runtimes_start(
3374        &self,
3375        request: StartRuntimeRequest,
3376        name: &str,
3377    ) -> ProjectLocationRuntimeStartCall<'a, C> {
3378        ProjectLocationRuntimeStartCall {
3379            hub: self.hub,
3380            _request: request,
3381            _name: name.to_string(),
3382            _delegate: Default::default(),
3383            _additional_params: Default::default(),
3384            _scopes: Default::default(),
3385        }
3386    }
3387
3388    /// Create a builder to help you perform the following task:
3389    ///
3390    /// 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
3391    ///
3392    /// # Arguments
3393    ///
3394    /// * `request` - No description provided.
3395    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
3396    pub fn locations_runtimes_stop(
3397        &self,
3398        request: StopRuntimeRequest,
3399        name: &str,
3400    ) -> ProjectLocationRuntimeStopCall<'a, C> {
3401        ProjectLocationRuntimeStopCall {
3402            hub: self.hub,
3403            _request: request,
3404            _name: name.to_string(),
3405            _delegate: Default::default(),
3406            _additional_params: Default::default(),
3407            _scopes: Default::default(),
3408        }
3409    }
3410
3411    /// Create a builder to help you perform the following task:
3412    ///
3413    /// Switch a Managed Notebook Runtime.
3414    ///
3415    /// # Arguments
3416    ///
3417    /// * `request` - No description provided.
3418    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
3419    pub fn locations_runtimes_switch(
3420        &self,
3421        request: SwitchRuntimeRequest,
3422        name: &str,
3423    ) -> ProjectLocationRuntimeSwitchCall<'a, C> {
3424        ProjectLocationRuntimeSwitchCall {
3425            hub: self.hub,
3426            _request: request,
3427            _name: name.to_string(),
3428            _delegate: Default::default(),
3429            _additional_params: Default::default(),
3430            _scopes: Default::default(),
3431        }
3432    }
3433
3434    /// Create a builder to help you perform the following task:
3435    ///
3436    /// 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.
3437    ///
3438    /// # Arguments
3439    ///
3440    /// * `request` - No description provided.
3441    /// * `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.
3442    pub fn locations_runtimes_test_iam_permissions(
3443        &self,
3444        request: TestIamPermissionsRequest,
3445        resource: &str,
3446    ) -> ProjectLocationRuntimeTestIamPermissionCall<'a, C> {
3447        ProjectLocationRuntimeTestIamPermissionCall {
3448            hub: self.hub,
3449            _request: request,
3450            _resource: resource.to_string(),
3451            _delegate: Default::default(),
3452            _additional_params: Default::default(),
3453            _scopes: Default::default(),
3454        }
3455    }
3456
3457    /// Create a builder to help you perform the following task:
3458    ///
3459    /// Upgrades a Managed Notebook Runtime to the latest version.
3460    ///
3461    /// # Arguments
3462    ///
3463    /// * `request` - No description provided.
3464    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
3465    pub fn locations_runtimes_upgrade(
3466        &self,
3467        request: UpgradeRuntimeRequest,
3468        name: &str,
3469    ) -> ProjectLocationRuntimeUpgradeCall<'a, C> {
3470        ProjectLocationRuntimeUpgradeCall {
3471            hub: self.hub,
3472            _request: request,
3473            _name: name.to_string(),
3474            _delegate: Default::default(),
3475            _additional_params: Default::default(),
3476            _scopes: Default::default(),
3477        }
3478    }
3479
3480    /// Create a builder to help you perform the following task:
3481    ///
3482    /// Creates a new Scheduled Notebook in a given project and location.
3483    ///
3484    /// # Arguments
3485    ///
3486    /// * `request` - No description provided.
3487    /// * `parent` - Required. Format: `parent=projects/{project_id}/locations/{location}`
3488    pub fn locations_schedules_create(
3489        &self,
3490        request: Schedule,
3491        parent: &str,
3492    ) -> ProjectLocationScheduleCreateCall<'a, C> {
3493        ProjectLocationScheduleCreateCall {
3494            hub: self.hub,
3495            _request: request,
3496            _parent: parent.to_string(),
3497            _schedule_id: Default::default(),
3498            _delegate: Default::default(),
3499            _additional_params: Default::default(),
3500            _scopes: Default::default(),
3501        }
3502    }
3503
3504    /// Create a builder to help you perform the following task:
3505    ///
3506    /// Deletes schedule and all underlying jobs
3507    ///
3508    /// # Arguments
3509    ///
3510    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/schedules/{schedule_id}`
3511    pub fn locations_schedules_delete(
3512        &self,
3513        name: &str,
3514    ) -> ProjectLocationScheduleDeleteCall<'a, C> {
3515        ProjectLocationScheduleDeleteCall {
3516            hub: self.hub,
3517            _name: name.to_string(),
3518            _delegate: Default::default(),
3519            _additional_params: Default::default(),
3520            _scopes: Default::default(),
3521        }
3522    }
3523
3524    /// Create a builder to help you perform the following task:
3525    ///
3526    /// Gets details of schedule
3527    ///
3528    /// # Arguments
3529    ///
3530    /// * `name` - Required. Format: `projects/{project_id}/locations/{location}/schedules/{schedule_id}`
3531    pub fn locations_schedules_get(&self, name: &str) -> ProjectLocationScheduleGetCall<'a, C> {
3532        ProjectLocationScheduleGetCall {
3533            hub: self.hub,
3534            _name: name.to_string(),
3535            _delegate: Default::default(),
3536            _additional_params: Default::default(),
3537            _scopes: Default::default(),
3538        }
3539    }
3540
3541    /// Create a builder to help you perform the following task:
3542    ///
3543    /// Lists schedules in a given project and location.
3544    ///
3545    /// # Arguments
3546    ///
3547    /// * `parent` - Required. Format: `parent=projects/{project_id}/locations/{location}`
3548    pub fn locations_schedules_list(&self, parent: &str) -> ProjectLocationScheduleListCall<'a, C> {
3549        ProjectLocationScheduleListCall {
3550            hub: self.hub,
3551            _parent: parent.to_string(),
3552            _page_token: Default::default(),
3553            _page_size: Default::default(),
3554            _order_by: Default::default(),
3555            _filter: Default::default(),
3556            _delegate: Default::default(),
3557            _additional_params: Default::default(),
3558            _scopes: Default::default(),
3559        }
3560    }
3561
3562    /// Create a builder to help you perform the following task:
3563    ///
3564    /// Triggers execution of an existing schedule.
3565    ///
3566    /// # Arguments
3567    ///
3568    /// * `request` - No description provided.
3569    /// * `name` - Required. Format: `parent=projects/{project_id}/locations/{location}/schedules/{schedule_id}`
3570    pub fn locations_schedules_trigger(
3571        &self,
3572        request: TriggerScheduleRequest,
3573        name: &str,
3574    ) -> ProjectLocationScheduleTriggerCall<'a, C> {
3575        ProjectLocationScheduleTriggerCall {
3576            hub: self.hub,
3577            _request: request,
3578            _name: name.to_string(),
3579            _delegate: Default::default(),
3580            _additional_params: Default::default(),
3581            _scopes: Default::default(),
3582        }
3583    }
3584
3585    /// Create a builder to help you perform the following task:
3586    ///
3587    /// Gets information about a location.
3588    ///
3589    /// # Arguments
3590    ///
3591    /// * `name` - Resource name for the location.
3592    pub fn locations_get(&self, name: &str) -> ProjectLocationGetCall<'a, C> {
3593        ProjectLocationGetCall {
3594            hub: self.hub,
3595            _name: name.to_string(),
3596            _delegate: Default::default(),
3597            _additional_params: Default::default(),
3598            _scopes: Default::default(),
3599        }
3600    }
3601
3602    /// Create a builder to help you perform the following task:
3603    ///
3604    /// Lists information about the supported locations for this service.
3605    ///
3606    /// # Arguments
3607    ///
3608    /// * `name` - The resource that owns the locations collection, if applicable.
3609    pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C> {
3610        ProjectLocationListCall {
3611            hub: self.hub,
3612            _name: name.to_string(),
3613            _page_token: Default::default(),
3614            _page_size: Default::default(),
3615            _filter: Default::default(),
3616            _delegate: Default::default(),
3617            _additional_params: Default::default(),
3618            _scopes: Default::default(),
3619        }
3620    }
3621}
3622
3623// ###################
3624// CallBuilders   ###
3625// #################
3626
3627/// Creates a new Environment.
3628///
3629/// A builder for the *locations.environments.create* method supported by a *project* resource.
3630/// It is not used directly, but through a [`ProjectMethods`] instance.
3631///
3632/// # Example
3633///
3634/// Instantiate a resource method builder
3635///
3636/// ```test_harness,no_run
3637/// # extern crate hyper;
3638/// # extern crate hyper_rustls;
3639/// # extern crate google_notebooks1 as notebooks1;
3640/// use notebooks1::api::Environment;
3641/// # async fn dox() {
3642/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3643///
3644/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3645/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3646/// #     secret,
3647/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3648/// # ).build().await.unwrap();
3649///
3650/// # let client = hyper_util::client::legacy::Client::builder(
3651/// #     hyper_util::rt::TokioExecutor::new()
3652/// # )
3653/// # .build(
3654/// #     hyper_rustls::HttpsConnectorBuilder::new()
3655/// #         .with_native_roots()
3656/// #         .unwrap()
3657/// #         .https_or_http()
3658/// #         .enable_http1()
3659/// #         .build()
3660/// # );
3661/// # let mut hub = AIPlatformNotebooks::new(client, auth);
3662/// // As the method needs a request, you would usually fill it with the desired information
3663/// // into the respective structure. Some of the parts shown here might not be applicable !
3664/// // Values shown here are possibly random and not representative !
3665/// let mut req = Environment::default();
3666///
3667/// // You can configure optional parameters by calling the respective setters at will, and
3668/// // execute the final call using `doit()`.
3669/// // Values shown here are possibly random and not representative !
3670/// let result = hub.projects().locations_environments_create(req, "parent")
3671///              .environment_id("amet.")
3672///              .doit().await;
3673/// # }
3674/// ```
3675pub struct ProjectLocationEnvironmentCreateCall<'a, C>
3676where
3677    C: 'a,
3678{
3679    hub: &'a AIPlatformNotebooks<C>,
3680    _request: Environment,
3681    _parent: String,
3682    _environment_id: Option<String>,
3683    _delegate: Option<&'a mut dyn common::Delegate>,
3684    _additional_params: HashMap<String, String>,
3685    _scopes: BTreeSet<String>,
3686}
3687
3688impl<'a, C> common::CallBuilder for ProjectLocationEnvironmentCreateCall<'a, C> {}
3689
3690impl<'a, C> ProjectLocationEnvironmentCreateCall<'a, C>
3691where
3692    C: common::Connector,
3693{
3694    /// Perform the operation you have build so far.
3695    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3696        use std::borrow::Cow;
3697        use std::io::{Read, Seek};
3698
3699        use common::{url::Params, ToParts};
3700        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3701
3702        let mut dd = common::DefaultDelegate;
3703        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3704        dlg.begin(common::MethodInfo {
3705            id: "notebooks.projects.locations.environments.create",
3706            http_method: hyper::Method::POST,
3707        });
3708
3709        for &field in ["alt", "parent", "environmentId"].iter() {
3710            if self._additional_params.contains_key(field) {
3711                dlg.finished(false);
3712                return Err(common::Error::FieldClash(field));
3713            }
3714        }
3715
3716        let mut params = Params::with_capacity(5 + self._additional_params.len());
3717        params.push("parent", self._parent);
3718        if let Some(value) = self._environment_id.as_ref() {
3719            params.push("environmentId", value);
3720        }
3721
3722        params.extend(self._additional_params.iter());
3723
3724        params.push("alt", "json");
3725        let mut url = self.hub._base_url.clone() + "v1/{+parent}/environments";
3726        if self._scopes.is_empty() {
3727            self._scopes
3728                .insert(Scope::CloudPlatform.as_ref().to_string());
3729        }
3730
3731        #[allow(clippy::single_element_loop)]
3732        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3733            url = params.uri_replacement(url, param_name, find_this, true);
3734        }
3735        {
3736            let to_remove = ["parent"];
3737            params.remove_params(&to_remove);
3738        }
3739
3740        let url = params.parse_with_url(&url);
3741
3742        let mut json_mime_type = mime::APPLICATION_JSON;
3743        let mut request_value_reader = {
3744            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3745            common::remove_json_null_values(&mut value);
3746            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3747            serde_json::to_writer(&mut dst, &value).unwrap();
3748            dst
3749        };
3750        let request_size = request_value_reader
3751            .seek(std::io::SeekFrom::End(0))
3752            .unwrap();
3753        request_value_reader
3754            .seek(std::io::SeekFrom::Start(0))
3755            .unwrap();
3756
3757        loop {
3758            let token = match self
3759                .hub
3760                .auth
3761                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3762                .await
3763            {
3764                Ok(token) => token,
3765                Err(e) => match dlg.token(e) {
3766                    Ok(token) => token,
3767                    Err(e) => {
3768                        dlg.finished(false);
3769                        return Err(common::Error::MissingToken(e));
3770                    }
3771                },
3772            };
3773            request_value_reader
3774                .seek(std::io::SeekFrom::Start(0))
3775                .unwrap();
3776            let mut req_result = {
3777                let client = &self.hub.client;
3778                dlg.pre_request();
3779                let mut req_builder = hyper::Request::builder()
3780                    .method(hyper::Method::POST)
3781                    .uri(url.as_str())
3782                    .header(USER_AGENT, self.hub._user_agent.clone());
3783
3784                if let Some(token) = token.as_ref() {
3785                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3786                }
3787
3788                let request = req_builder
3789                    .header(CONTENT_TYPE, json_mime_type.to_string())
3790                    .header(CONTENT_LENGTH, request_size as u64)
3791                    .body(common::to_body(
3792                        request_value_reader.get_ref().clone().into(),
3793                    ));
3794
3795                client.request(request.unwrap()).await
3796            };
3797
3798            match req_result {
3799                Err(err) => {
3800                    if let common::Retry::After(d) = dlg.http_error(&err) {
3801                        sleep(d).await;
3802                        continue;
3803                    }
3804                    dlg.finished(false);
3805                    return Err(common::Error::HttpError(err));
3806                }
3807                Ok(res) => {
3808                    let (mut parts, body) = res.into_parts();
3809                    let mut body = common::Body::new(body);
3810                    if !parts.status.is_success() {
3811                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3812                        let error = serde_json::from_str(&common::to_string(&bytes));
3813                        let response = common::to_response(parts, bytes.into());
3814
3815                        if let common::Retry::After(d) =
3816                            dlg.http_failure(&response, error.as_ref().ok())
3817                        {
3818                            sleep(d).await;
3819                            continue;
3820                        }
3821
3822                        dlg.finished(false);
3823
3824                        return Err(match error {
3825                            Ok(value) => common::Error::BadRequest(value),
3826                            _ => common::Error::Failure(response),
3827                        });
3828                    }
3829                    let response = {
3830                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3831                        let encoded = common::to_string(&bytes);
3832                        match serde_json::from_str(&encoded) {
3833                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3834                            Err(error) => {
3835                                dlg.response_json_decode_error(&encoded, &error);
3836                                return Err(common::Error::JsonDecodeError(
3837                                    encoded.to_string(),
3838                                    error,
3839                                ));
3840                            }
3841                        }
3842                    };
3843
3844                    dlg.finished(true);
3845                    return Ok(response);
3846                }
3847            }
3848        }
3849    }
3850
3851    ///
3852    /// Sets the *request* property to the given value.
3853    ///
3854    /// Even though the property as already been set when instantiating this call,
3855    /// we provide this method for API completeness.
3856    pub fn request(
3857        mut self,
3858        new_value: Environment,
3859    ) -> ProjectLocationEnvironmentCreateCall<'a, C> {
3860        self._request = new_value;
3861        self
3862    }
3863    /// Required. Format: `projects/{project_id}/locations/{location}`
3864    ///
3865    /// Sets the *parent* path property to the given value.
3866    ///
3867    /// Even though the property as already been set when instantiating this call,
3868    /// we provide this method for API completeness.
3869    pub fn parent(mut self, new_value: &str) -> ProjectLocationEnvironmentCreateCall<'a, C> {
3870        self._parent = new_value.to_string();
3871        self
3872    }
3873    /// 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.
3874    ///
3875    /// Sets the *environment id* query property to the given value.
3876    pub fn environment_id(
3877        mut self,
3878        new_value: &str,
3879    ) -> ProjectLocationEnvironmentCreateCall<'a, C> {
3880        self._environment_id = Some(new_value.to_string());
3881        self
3882    }
3883    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3884    /// while executing the actual API request.
3885    ///
3886    /// ````text
3887    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3888    /// ````
3889    ///
3890    /// Sets the *delegate* property to the given value.
3891    pub fn delegate(
3892        mut self,
3893        new_value: &'a mut dyn common::Delegate,
3894    ) -> ProjectLocationEnvironmentCreateCall<'a, C> {
3895        self._delegate = Some(new_value);
3896        self
3897    }
3898
3899    /// Set any additional parameter of the query string used in the request.
3900    /// It should be used to set parameters which are not yet available through their own
3901    /// setters.
3902    ///
3903    /// Please note that this method must not be used to set any of the known parameters
3904    /// which have their own setter method. If done anyway, the request will fail.
3905    ///
3906    /// # Additional Parameters
3907    ///
3908    /// * *$.xgafv* (query-string) - V1 error format.
3909    /// * *access_token* (query-string) - OAuth access token.
3910    /// * *alt* (query-string) - Data format for response.
3911    /// * *callback* (query-string) - JSONP
3912    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3913    /// * *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.
3914    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3915    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3916    /// * *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.
3917    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3918    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3919    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEnvironmentCreateCall<'a, C>
3920    where
3921        T: AsRef<str>,
3922    {
3923        self._additional_params
3924            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3925        self
3926    }
3927
3928    /// Identifies the authorization scope for the method you are building.
3929    ///
3930    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3931    /// [`Scope::CloudPlatform`].
3932    ///
3933    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3934    /// tokens for more than one scope.
3935    ///
3936    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3937    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3938    /// sufficient, a read-write scope will do as well.
3939    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEnvironmentCreateCall<'a, C>
3940    where
3941        St: AsRef<str>,
3942    {
3943        self._scopes.insert(String::from(scope.as_ref()));
3944        self
3945    }
3946    /// Identifies the authorization scope(s) for the method you are building.
3947    ///
3948    /// See [`Self::add_scope()`] for details.
3949    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEnvironmentCreateCall<'a, C>
3950    where
3951        I: IntoIterator<Item = St>,
3952        St: AsRef<str>,
3953    {
3954        self._scopes
3955            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3956        self
3957    }
3958
3959    /// Removes all scopes, and no default scope will be used either.
3960    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3961    /// for details).
3962    pub fn clear_scopes(mut self) -> ProjectLocationEnvironmentCreateCall<'a, C> {
3963        self._scopes.clear();
3964        self
3965    }
3966}
3967
3968/// Deletes a single Environment.
3969///
3970/// A builder for the *locations.environments.delete* method supported by a *project* resource.
3971/// It is not used directly, but through a [`ProjectMethods`] instance.
3972///
3973/// # Example
3974///
3975/// Instantiate a resource method builder
3976///
3977/// ```test_harness,no_run
3978/// # extern crate hyper;
3979/// # extern crate hyper_rustls;
3980/// # extern crate google_notebooks1 as notebooks1;
3981/// # async fn dox() {
3982/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3983///
3984/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3985/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3986/// #     secret,
3987/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3988/// # ).build().await.unwrap();
3989///
3990/// # let client = hyper_util::client::legacy::Client::builder(
3991/// #     hyper_util::rt::TokioExecutor::new()
3992/// # )
3993/// # .build(
3994/// #     hyper_rustls::HttpsConnectorBuilder::new()
3995/// #         .with_native_roots()
3996/// #         .unwrap()
3997/// #         .https_or_http()
3998/// #         .enable_http1()
3999/// #         .build()
4000/// # );
4001/// # let mut hub = AIPlatformNotebooks::new(client, auth);
4002/// // You can configure optional parameters by calling the respective setters at will, and
4003/// // execute the final call using `doit()`.
4004/// // Values shown here are possibly random and not representative !
4005/// let result = hub.projects().locations_environments_delete("name")
4006///              .doit().await;
4007/// # }
4008/// ```
4009pub struct ProjectLocationEnvironmentDeleteCall<'a, C>
4010where
4011    C: 'a,
4012{
4013    hub: &'a AIPlatformNotebooks<C>,
4014    _name: String,
4015    _delegate: Option<&'a mut dyn common::Delegate>,
4016    _additional_params: HashMap<String, String>,
4017    _scopes: BTreeSet<String>,
4018}
4019
4020impl<'a, C> common::CallBuilder for ProjectLocationEnvironmentDeleteCall<'a, C> {}
4021
4022impl<'a, C> ProjectLocationEnvironmentDeleteCall<'a, C>
4023where
4024    C: common::Connector,
4025{
4026    /// Perform the operation you have build so far.
4027    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4028        use std::borrow::Cow;
4029        use std::io::{Read, Seek};
4030
4031        use common::{url::Params, ToParts};
4032        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4033
4034        let mut dd = common::DefaultDelegate;
4035        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4036        dlg.begin(common::MethodInfo {
4037            id: "notebooks.projects.locations.environments.delete",
4038            http_method: hyper::Method::DELETE,
4039        });
4040
4041        for &field in ["alt", "name"].iter() {
4042            if self._additional_params.contains_key(field) {
4043                dlg.finished(false);
4044                return Err(common::Error::FieldClash(field));
4045            }
4046        }
4047
4048        let mut params = Params::with_capacity(3 + self._additional_params.len());
4049        params.push("name", self._name);
4050
4051        params.extend(self._additional_params.iter());
4052
4053        params.push("alt", "json");
4054        let mut url = self.hub._base_url.clone() + "v1/{+name}";
4055        if self._scopes.is_empty() {
4056            self._scopes
4057                .insert(Scope::CloudPlatform.as_ref().to_string());
4058        }
4059
4060        #[allow(clippy::single_element_loop)]
4061        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4062            url = params.uri_replacement(url, param_name, find_this, true);
4063        }
4064        {
4065            let to_remove = ["name"];
4066            params.remove_params(&to_remove);
4067        }
4068
4069        let url = params.parse_with_url(&url);
4070
4071        loop {
4072            let token = match self
4073                .hub
4074                .auth
4075                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4076                .await
4077            {
4078                Ok(token) => token,
4079                Err(e) => match dlg.token(e) {
4080                    Ok(token) => token,
4081                    Err(e) => {
4082                        dlg.finished(false);
4083                        return Err(common::Error::MissingToken(e));
4084                    }
4085                },
4086            };
4087            let mut req_result = {
4088                let client = &self.hub.client;
4089                dlg.pre_request();
4090                let mut req_builder = hyper::Request::builder()
4091                    .method(hyper::Method::DELETE)
4092                    .uri(url.as_str())
4093                    .header(USER_AGENT, self.hub._user_agent.clone());
4094
4095                if let Some(token) = token.as_ref() {
4096                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4097                }
4098
4099                let request = req_builder
4100                    .header(CONTENT_LENGTH, 0_u64)
4101                    .body(common::to_body::<String>(None));
4102
4103                client.request(request.unwrap()).await
4104            };
4105
4106            match req_result {
4107                Err(err) => {
4108                    if let common::Retry::After(d) = dlg.http_error(&err) {
4109                        sleep(d).await;
4110                        continue;
4111                    }
4112                    dlg.finished(false);
4113                    return Err(common::Error::HttpError(err));
4114                }
4115                Ok(res) => {
4116                    let (mut parts, body) = res.into_parts();
4117                    let mut body = common::Body::new(body);
4118                    if !parts.status.is_success() {
4119                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4120                        let error = serde_json::from_str(&common::to_string(&bytes));
4121                        let response = common::to_response(parts, bytes.into());
4122
4123                        if let common::Retry::After(d) =
4124                            dlg.http_failure(&response, error.as_ref().ok())
4125                        {
4126                            sleep(d).await;
4127                            continue;
4128                        }
4129
4130                        dlg.finished(false);
4131
4132                        return Err(match error {
4133                            Ok(value) => common::Error::BadRequest(value),
4134                            _ => common::Error::Failure(response),
4135                        });
4136                    }
4137                    let response = {
4138                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4139                        let encoded = common::to_string(&bytes);
4140                        match serde_json::from_str(&encoded) {
4141                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4142                            Err(error) => {
4143                                dlg.response_json_decode_error(&encoded, &error);
4144                                return Err(common::Error::JsonDecodeError(
4145                                    encoded.to_string(),
4146                                    error,
4147                                ));
4148                            }
4149                        }
4150                    };
4151
4152                    dlg.finished(true);
4153                    return Ok(response);
4154                }
4155            }
4156        }
4157    }
4158
4159    /// Required. Format: `projects/{project_id}/locations/{location}/environments/{environment_id}`
4160    ///
4161    /// Sets the *name* path property to the given value.
4162    ///
4163    /// Even though the property as already been set when instantiating this call,
4164    /// we provide this method for API completeness.
4165    pub fn name(mut self, new_value: &str) -> ProjectLocationEnvironmentDeleteCall<'a, C> {
4166        self._name = new_value.to_string();
4167        self
4168    }
4169    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4170    /// while executing the actual API request.
4171    ///
4172    /// ````text
4173    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4174    /// ````
4175    ///
4176    /// Sets the *delegate* property to the given value.
4177    pub fn delegate(
4178        mut self,
4179        new_value: &'a mut dyn common::Delegate,
4180    ) -> ProjectLocationEnvironmentDeleteCall<'a, C> {
4181        self._delegate = Some(new_value);
4182        self
4183    }
4184
4185    /// Set any additional parameter of the query string used in the request.
4186    /// It should be used to set parameters which are not yet available through their own
4187    /// setters.
4188    ///
4189    /// Please note that this method must not be used to set any of the known parameters
4190    /// which have their own setter method. If done anyway, the request will fail.
4191    ///
4192    /// # Additional Parameters
4193    ///
4194    /// * *$.xgafv* (query-string) - V1 error format.
4195    /// * *access_token* (query-string) - OAuth access token.
4196    /// * *alt* (query-string) - Data format for response.
4197    /// * *callback* (query-string) - JSONP
4198    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4199    /// * *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.
4200    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4201    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4202    /// * *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.
4203    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4204    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4205    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEnvironmentDeleteCall<'a, C>
4206    where
4207        T: AsRef<str>,
4208    {
4209        self._additional_params
4210            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4211        self
4212    }
4213
4214    /// Identifies the authorization scope for the method you are building.
4215    ///
4216    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4217    /// [`Scope::CloudPlatform`].
4218    ///
4219    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4220    /// tokens for more than one scope.
4221    ///
4222    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4223    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4224    /// sufficient, a read-write scope will do as well.
4225    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEnvironmentDeleteCall<'a, C>
4226    where
4227        St: AsRef<str>,
4228    {
4229        self._scopes.insert(String::from(scope.as_ref()));
4230        self
4231    }
4232    /// Identifies the authorization scope(s) for the method you are building.
4233    ///
4234    /// See [`Self::add_scope()`] for details.
4235    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEnvironmentDeleteCall<'a, C>
4236    where
4237        I: IntoIterator<Item = St>,
4238        St: AsRef<str>,
4239    {
4240        self._scopes
4241            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4242        self
4243    }
4244
4245    /// Removes all scopes, and no default scope will be used either.
4246    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4247    /// for details).
4248    pub fn clear_scopes(mut self) -> ProjectLocationEnvironmentDeleteCall<'a, C> {
4249        self._scopes.clear();
4250        self
4251    }
4252}
4253
4254/// Gets details of a single Environment.
4255///
4256/// A builder for the *locations.environments.get* method supported by a *project* resource.
4257/// It is not used directly, but through a [`ProjectMethods`] instance.
4258///
4259/// # Example
4260///
4261/// Instantiate a resource method builder
4262///
4263/// ```test_harness,no_run
4264/// # extern crate hyper;
4265/// # extern crate hyper_rustls;
4266/// # extern crate google_notebooks1 as notebooks1;
4267/// # async fn dox() {
4268/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4269///
4270/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4271/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4272/// #     secret,
4273/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4274/// # ).build().await.unwrap();
4275///
4276/// # let client = hyper_util::client::legacy::Client::builder(
4277/// #     hyper_util::rt::TokioExecutor::new()
4278/// # )
4279/// # .build(
4280/// #     hyper_rustls::HttpsConnectorBuilder::new()
4281/// #         .with_native_roots()
4282/// #         .unwrap()
4283/// #         .https_or_http()
4284/// #         .enable_http1()
4285/// #         .build()
4286/// # );
4287/// # let mut hub = AIPlatformNotebooks::new(client, auth);
4288/// // You can configure optional parameters by calling the respective setters at will, and
4289/// // execute the final call using `doit()`.
4290/// // Values shown here are possibly random and not representative !
4291/// let result = hub.projects().locations_environments_get("name")
4292///              .doit().await;
4293/// # }
4294/// ```
4295pub struct ProjectLocationEnvironmentGetCall<'a, C>
4296where
4297    C: 'a,
4298{
4299    hub: &'a AIPlatformNotebooks<C>,
4300    _name: String,
4301    _delegate: Option<&'a mut dyn common::Delegate>,
4302    _additional_params: HashMap<String, String>,
4303    _scopes: BTreeSet<String>,
4304}
4305
4306impl<'a, C> common::CallBuilder for ProjectLocationEnvironmentGetCall<'a, C> {}
4307
4308impl<'a, C> ProjectLocationEnvironmentGetCall<'a, C>
4309where
4310    C: common::Connector,
4311{
4312    /// Perform the operation you have build so far.
4313    pub async fn doit(mut self) -> common::Result<(common::Response, Environment)> {
4314        use std::borrow::Cow;
4315        use std::io::{Read, Seek};
4316
4317        use common::{url::Params, ToParts};
4318        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4319
4320        let mut dd = common::DefaultDelegate;
4321        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4322        dlg.begin(common::MethodInfo {
4323            id: "notebooks.projects.locations.environments.get",
4324            http_method: hyper::Method::GET,
4325        });
4326
4327        for &field in ["alt", "name"].iter() {
4328            if self._additional_params.contains_key(field) {
4329                dlg.finished(false);
4330                return Err(common::Error::FieldClash(field));
4331            }
4332        }
4333
4334        let mut params = Params::with_capacity(3 + self._additional_params.len());
4335        params.push("name", self._name);
4336
4337        params.extend(self._additional_params.iter());
4338
4339        params.push("alt", "json");
4340        let mut url = self.hub._base_url.clone() + "v1/{+name}";
4341        if self._scopes.is_empty() {
4342            self._scopes
4343                .insert(Scope::CloudPlatform.as_ref().to_string());
4344        }
4345
4346        #[allow(clippy::single_element_loop)]
4347        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4348            url = params.uri_replacement(url, param_name, find_this, true);
4349        }
4350        {
4351            let to_remove = ["name"];
4352            params.remove_params(&to_remove);
4353        }
4354
4355        let url = params.parse_with_url(&url);
4356
4357        loop {
4358            let token = match self
4359                .hub
4360                .auth
4361                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4362                .await
4363            {
4364                Ok(token) => token,
4365                Err(e) => match dlg.token(e) {
4366                    Ok(token) => token,
4367                    Err(e) => {
4368                        dlg.finished(false);
4369                        return Err(common::Error::MissingToken(e));
4370                    }
4371                },
4372            };
4373            let mut req_result = {
4374                let client = &self.hub.client;
4375                dlg.pre_request();
4376                let mut req_builder = hyper::Request::builder()
4377                    .method(hyper::Method::GET)
4378                    .uri(url.as_str())
4379                    .header(USER_AGENT, self.hub._user_agent.clone());
4380
4381                if let Some(token) = token.as_ref() {
4382                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4383                }
4384
4385                let request = req_builder
4386                    .header(CONTENT_LENGTH, 0_u64)
4387                    .body(common::to_body::<String>(None));
4388
4389                client.request(request.unwrap()).await
4390            };
4391
4392            match req_result {
4393                Err(err) => {
4394                    if let common::Retry::After(d) = dlg.http_error(&err) {
4395                        sleep(d).await;
4396                        continue;
4397                    }
4398                    dlg.finished(false);
4399                    return Err(common::Error::HttpError(err));
4400                }
4401                Ok(res) => {
4402                    let (mut parts, body) = res.into_parts();
4403                    let mut body = common::Body::new(body);
4404                    if !parts.status.is_success() {
4405                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4406                        let error = serde_json::from_str(&common::to_string(&bytes));
4407                        let response = common::to_response(parts, bytes.into());
4408
4409                        if let common::Retry::After(d) =
4410                            dlg.http_failure(&response, error.as_ref().ok())
4411                        {
4412                            sleep(d).await;
4413                            continue;
4414                        }
4415
4416                        dlg.finished(false);
4417
4418                        return Err(match error {
4419                            Ok(value) => common::Error::BadRequest(value),
4420                            _ => common::Error::Failure(response),
4421                        });
4422                    }
4423                    let response = {
4424                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4425                        let encoded = common::to_string(&bytes);
4426                        match serde_json::from_str(&encoded) {
4427                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4428                            Err(error) => {
4429                                dlg.response_json_decode_error(&encoded, &error);
4430                                return Err(common::Error::JsonDecodeError(
4431                                    encoded.to_string(),
4432                                    error,
4433                                ));
4434                            }
4435                        }
4436                    };
4437
4438                    dlg.finished(true);
4439                    return Ok(response);
4440                }
4441            }
4442        }
4443    }
4444
4445    /// Required. Format: `projects/{project_id}/locations/{location}/environments/{environment_id}`
4446    ///
4447    /// Sets the *name* path property to the given value.
4448    ///
4449    /// Even though the property as already been set when instantiating this call,
4450    /// we provide this method for API completeness.
4451    pub fn name(mut self, new_value: &str) -> ProjectLocationEnvironmentGetCall<'a, C> {
4452        self._name = new_value.to_string();
4453        self
4454    }
4455    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4456    /// while executing the actual API request.
4457    ///
4458    /// ````text
4459    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4460    /// ````
4461    ///
4462    /// Sets the *delegate* property to the given value.
4463    pub fn delegate(
4464        mut self,
4465        new_value: &'a mut dyn common::Delegate,
4466    ) -> ProjectLocationEnvironmentGetCall<'a, C> {
4467        self._delegate = Some(new_value);
4468        self
4469    }
4470
4471    /// Set any additional parameter of the query string used in the request.
4472    /// It should be used to set parameters which are not yet available through their own
4473    /// setters.
4474    ///
4475    /// Please note that this method must not be used to set any of the known parameters
4476    /// which have their own setter method. If done anyway, the request will fail.
4477    ///
4478    /// # Additional Parameters
4479    ///
4480    /// * *$.xgafv* (query-string) - V1 error format.
4481    /// * *access_token* (query-string) - OAuth access token.
4482    /// * *alt* (query-string) - Data format for response.
4483    /// * *callback* (query-string) - JSONP
4484    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4485    /// * *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.
4486    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4487    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4488    /// * *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.
4489    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4490    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4491    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEnvironmentGetCall<'a, C>
4492    where
4493        T: AsRef<str>,
4494    {
4495        self._additional_params
4496            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4497        self
4498    }
4499
4500    /// Identifies the authorization scope for the method you are building.
4501    ///
4502    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4503    /// [`Scope::CloudPlatform`].
4504    ///
4505    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4506    /// tokens for more than one scope.
4507    ///
4508    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4509    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4510    /// sufficient, a read-write scope will do as well.
4511    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEnvironmentGetCall<'a, C>
4512    where
4513        St: AsRef<str>,
4514    {
4515        self._scopes.insert(String::from(scope.as_ref()));
4516        self
4517    }
4518    /// Identifies the authorization scope(s) for the method you are building.
4519    ///
4520    /// See [`Self::add_scope()`] for details.
4521    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEnvironmentGetCall<'a, C>
4522    where
4523        I: IntoIterator<Item = St>,
4524        St: AsRef<str>,
4525    {
4526        self._scopes
4527            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4528        self
4529    }
4530
4531    /// Removes all scopes, and no default scope will be used either.
4532    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4533    /// for details).
4534    pub fn clear_scopes(mut self) -> ProjectLocationEnvironmentGetCall<'a, C> {
4535        self._scopes.clear();
4536        self
4537    }
4538}
4539
4540/// Lists environments in a project.
4541///
4542/// A builder for the *locations.environments.list* method supported by a *project* resource.
4543/// It is not used directly, but through a [`ProjectMethods`] instance.
4544///
4545/// # Example
4546///
4547/// Instantiate a resource method builder
4548///
4549/// ```test_harness,no_run
4550/// # extern crate hyper;
4551/// # extern crate hyper_rustls;
4552/// # extern crate google_notebooks1 as notebooks1;
4553/// # async fn dox() {
4554/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4555///
4556/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4557/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4558/// #     secret,
4559/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4560/// # ).build().await.unwrap();
4561///
4562/// # let client = hyper_util::client::legacy::Client::builder(
4563/// #     hyper_util::rt::TokioExecutor::new()
4564/// # )
4565/// # .build(
4566/// #     hyper_rustls::HttpsConnectorBuilder::new()
4567/// #         .with_native_roots()
4568/// #         .unwrap()
4569/// #         .https_or_http()
4570/// #         .enable_http1()
4571/// #         .build()
4572/// # );
4573/// # let mut hub = AIPlatformNotebooks::new(client, auth);
4574/// // You can configure optional parameters by calling the respective setters at will, and
4575/// // execute the final call using `doit()`.
4576/// // Values shown here are possibly random and not representative !
4577/// let result = hub.projects().locations_environments_list("parent")
4578///              .page_token("Lorem")
4579///              .page_size(-12)
4580///              .doit().await;
4581/// # }
4582/// ```
4583pub struct ProjectLocationEnvironmentListCall<'a, C>
4584where
4585    C: 'a,
4586{
4587    hub: &'a AIPlatformNotebooks<C>,
4588    _parent: String,
4589    _page_token: Option<String>,
4590    _page_size: Option<i32>,
4591    _delegate: Option<&'a mut dyn common::Delegate>,
4592    _additional_params: HashMap<String, String>,
4593    _scopes: BTreeSet<String>,
4594}
4595
4596impl<'a, C> common::CallBuilder for ProjectLocationEnvironmentListCall<'a, C> {}
4597
4598impl<'a, C> ProjectLocationEnvironmentListCall<'a, C>
4599where
4600    C: common::Connector,
4601{
4602    /// Perform the operation you have build so far.
4603    pub async fn doit(mut self) -> common::Result<(common::Response, ListEnvironmentsResponse)> {
4604        use std::borrow::Cow;
4605        use std::io::{Read, Seek};
4606
4607        use common::{url::Params, ToParts};
4608        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4609
4610        let mut dd = common::DefaultDelegate;
4611        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4612        dlg.begin(common::MethodInfo {
4613            id: "notebooks.projects.locations.environments.list",
4614            http_method: hyper::Method::GET,
4615        });
4616
4617        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
4618            if self._additional_params.contains_key(field) {
4619                dlg.finished(false);
4620                return Err(common::Error::FieldClash(field));
4621            }
4622        }
4623
4624        let mut params = Params::with_capacity(5 + self._additional_params.len());
4625        params.push("parent", self._parent);
4626        if let Some(value) = self._page_token.as_ref() {
4627            params.push("pageToken", value);
4628        }
4629        if let Some(value) = self._page_size.as_ref() {
4630            params.push("pageSize", value.to_string());
4631        }
4632
4633        params.extend(self._additional_params.iter());
4634
4635        params.push("alt", "json");
4636        let mut url = self.hub._base_url.clone() + "v1/{+parent}/environments";
4637        if self._scopes.is_empty() {
4638            self._scopes
4639                .insert(Scope::CloudPlatform.as_ref().to_string());
4640        }
4641
4642        #[allow(clippy::single_element_loop)]
4643        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4644            url = params.uri_replacement(url, param_name, find_this, true);
4645        }
4646        {
4647            let to_remove = ["parent"];
4648            params.remove_params(&to_remove);
4649        }
4650
4651        let url = params.parse_with_url(&url);
4652
4653        loop {
4654            let token = match self
4655                .hub
4656                .auth
4657                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4658                .await
4659            {
4660                Ok(token) => token,
4661                Err(e) => match dlg.token(e) {
4662                    Ok(token) => token,
4663                    Err(e) => {
4664                        dlg.finished(false);
4665                        return Err(common::Error::MissingToken(e));
4666                    }
4667                },
4668            };
4669            let mut req_result = {
4670                let client = &self.hub.client;
4671                dlg.pre_request();
4672                let mut req_builder = hyper::Request::builder()
4673                    .method(hyper::Method::GET)
4674                    .uri(url.as_str())
4675                    .header(USER_AGENT, self.hub._user_agent.clone());
4676
4677                if let Some(token) = token.as_ref() {
4678                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4679                }
4680
4681                let request = req_builder
4682                    .header(CONTENT_LENGTH, 0_u64)
4683                    .body(common::to_body::<String>(None));
4684
4685                client.request(request.unwrap()).await
4686            };
4687
4688            match req_result {
4689                Err(err) => {
4690                    if let common::Retry::After(d) = dlg.http_error(&err) {
4691                        sleep(d).await;
4692                        continue;
4693                    }
4694                    dlg.finished(false);
4695                    return Err(common::Error::HttpError(err));
4696                }
4697                Ok(res) => {
4698                    let (mut parts, body) = res.into_parts();
4699                    let mut body = common::Body::new(body);
4700                    if !parts.status.is_success() {
4701                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4702                        let error = serde_json::from_str(&common::to_string(&bytes));
4703                        let response = common::to_response(parts, bytes.into());
4704
4705                        if let common::Retry::After(d) =
4706                            dlg.http_failure(&response, error.as_ref().ok())
4707                        {
4708                            sleep(d).await;
4709                            continue;
4710                        }
4711
4712                        dlg.finished(false);
4713
4714                        return Err(match error {
4715                            Ok(value) => common::Error::BadRequest(value),
4716                            _ => common::Error::Failure(response),
4717                        });
4718                    }
4719                    let response = {
4720                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4721                        let encoded = common::to_string(&bytes);
4722                        match serde_json::from_str(&encoded) {
4723                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4724                            Err(error) => {
4725                                dlg.response_json_decode_error(&encoded, &error);
4726                                return Err(common::Error::JsonDecodeError(
4727                                    encoded.to_string(),
4728                                    error,
4729                                ));
4730                            }
4731                        }
4732                    };
4733
4734                    dlg.finished(true);
4735                    return Ok(response);
4736                }
4737            }
4738        }
4739    }
4740
4741    /// Required. Format: `projects/{project_id}/locations/{location}`
4742    ///
4743    /// Sets the *parent* path property to the given value.
4744    ///
4745    /// Even though the property as already been set when instantiating this call,
4746    /// we provide this method for API completeness.
4747    pub fn parent(mut self, new_value: &str) -> ProjectLocationEnvironmentListCall<'a, C> {
4748        self._parent = new_value.to_string();
4749        self
4750    }
4751    /// A previous returned page token that can be used to continue listing from the last result.
4752    ///
4753    /// Sets the *page token* query property to the given value.
4754    pub fn page_token(mut self, new_value: &str) -> ProjectLocationEnvironmentListCall<'a, C> {
4755        self._page_token = Some(new_value.to_string());
4756        self
4757    }
4758    /// Maximum return size of the list call.
4759    ///
4760    /// Sets the *page size* query property to the given value.
4761    pub fn page_size(mut self, new_value: i32) -> ProjectLocationEnvironmentListCall<'a, C> {
4762        self._page_size = Some(new_value);
4763        self
4764    }
4765    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4766    /// while executing the actual API request.
4767    ///
4768    /// ````text
4769    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4770    /// ````
4771    ///
4772    /// Sets the *delegate* property to the given value.
4773    pub fn delegate(
4774        mut self,
4775        new_value: &'a mut dyn common::Delegate,
4776    ) -> ProjectLocationEnvironmentListCall<'a, C> {
4777        self._delegate = Some(new_value);
4778        self
4779    }
4780
4781    /// Set any additional parameter of the query string used in the request.
4782    /// It should be used to set parameters which are not yet available through their own
4783    /// setters.
4784    ///
4785    /// Please note that this method must not be used to set any of the known parameters
4786    /// which have their own setter method. If done anyway, the request will fail.
4787    ///
4788    /// # Additional Parameters
4789    ///
4790    /// * *$.xgafv* (query-string) - V1 error format.
4791    /// * *access_token* (query-string) - OAuth access token.
4792    /// * *alt* (query-string) - Data format for response.
4793    /// * *callback* (query-string) - JSONP
4794    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4795    /// * *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.
4796    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4797    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4798    /// * *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.
4799    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4800    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4801    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEnvironmentListCall<'a, C>
4802    where
4803        T: AsRef<str>,
4804    {
4805        self._additional_params
4806            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4807        self
4808    }
4809
4810    /// Identifies the authorization scope for the method you are building.
4811    ///
4812    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4813    /// [`Scope::CloudPlatform`].
4814    ///
4815    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4816    /// tokens for more than one scope.
4817    ///
4818    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4819    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4820    /// sufficient, a read-write scope will do as well.
4821    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEnvironmentListCall<'a, C>
4822    where
4823        St: AsRef<str>,
4824    {
4825        self._scopes.insert(String::from(scope.as_ref()));
4826        self
4827    }
4828    /// Identifies the authorization scope(s) for the method you are building.
4829    ///
4830    /// See [`Self::add_scope()`] for details.
4831    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEnvironmentListCall<'a, C>
4832    where
4833        I: IntoIterator<Item = St>,
4834        St: AsRef<str>,
4835    {
4836        self._scopes
4837            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4838        self
4839    }
4840
4841    /// Removes all scopes, and no default scope will be used either.
4842    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4843    /// for details).
4844    pub fn clear_scopes(mut self) -> ProjectLocationEnvironmentListCall<'a, C> {
4845        self._scopes.clear();
4846        self
4847    }
4848}
4849
4850/// Creates a new Execution in a given project and location.
4851///
4852/// A builder for the *locations.executions.create* method supported by a *project* resource.
4853/// It is not used directly, but through a [`ProjectMethods`] instance.
4854///
4855/// # Example
4856///
4857/// Instantiate a resource method builder
4858///
4859/// ```test_harness,no_run
4860/// # extern crate hyper;
4861/// # extern crate hyper_rustls;
4862/// # extern crate google_notebooks1 as notebooks1;
4863/// use notebooks1::api::Execution;
4864/// # async fn dox() {
4865/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4866///
4867/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4868/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4869/// #     secret,
4870/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4871/// # ).build().await.unwrap();
4872///
4873/// # let client = hyper_util::client::legacy::Client::builder(
4874/// #     hyper_util::rt::TokioExecutor::new()
4875/// # )
4876/// # .build(
4877/// #     hyper_rustls::HttpsConnectorBuilder::new()
4878/// #         .with_native_roots()
4879/// #         .unwrap()
4880/// #         .https_or_http()
4881/// #         .enable_http1()
4882/// #         .build()
4883/// # );
4884/// # let mut hub = AIPlatformNotebooks::new(client, auth);
4885/// // As the method needs a request, you would usually fill it with the desired information
4886/// // into the respective structure. Some of the parts shown here might not be applicable !
4887/// // Values shown here are possibly random and not representative !
4888/// let mut req = Execution::default();
4889///
4890/// // You can configure optional parameters by calling the respective setters at will, and
4891/// // execute the final call using `doit()`.
4892/// // Values shown here are possibly random and not representative !
4893/// let result = hub.projects().locations_executions_create(req, "parent")
4894///              .execution_id("dolor")
4895///              .doit().await;
4896/// # }
4897/// ```
4898pub struct ProjectLocationExecutionCreateCall<'a, C>
4899where
4900    C: 'a,
4901{
4902    hub: &'a AIPlatformNotebooks<C>,
4903    _request: Execution,
4904    _parent: String,
4905    _execution_id: Option<String>,
4906    _delegate: Option<&'a mut dyn common::Delegate>,
4907    _additional_params: HashMap<String, String>,
4908    _scopes: BTreeSet<String>,
4909}
4910
4911impl<'a, C> common::CallBuilder for ProjectLocationExecutionCreateCall<'a, C> {}
4912
4913impl<'a, C> ProjectLocationExecutionCreateCall<'a, C>
4914where
4915    C: common::Connector,
4916{
4917    /// Perform the operation you have build so far.
4918    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4919        use std::borrow::Cow;
4920        use std::io::{Read, Seek};
4921
4922        use common::{url::Params, ToParts};
4923        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4924
4925        let mut dd = common::DefaultDelegate;
4926        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4927        dlg.begin(common::MethodInfo {
4928            id: "notebooks.projects.locations.executions.create",
4929            http_method: hyper::Method::POST,
4930        });
4931
4932        for &field in ["alt", "parent", "executionId"].iter() {
4933            if self._additional_params.contains_key(field) {
4934                dlg.finished(false);
4935                return Err(common::Error::FieldClash(field));
4936            }
4937        }
4938
4939        let mut params = Params::with_capacity(5 + self._additional_params.len());
4940        params.push("parent", self._parent);
4941        if let Some(value) = self._execution_id.as_ref() {
4942            params.push("executionId", value);
4943        }
4944
4945        params.extend(self._additional_params.iter());
4946
4947        params.push("alt", "json");
4948        let mut url = self.hub._base_url.clone() + "v1/{+parent}/executions";
4949        if self._scopes.is_empty() {
4950            self._scopes
4951                .insert(Scope::CloudPlatform.as_ref().to_string());
4952        }
4953
4954        #[allow(clippy::single_element_loop)]
4955        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4956            url = params.uri_replacement(url, param_name, find_this, true);
4957        }
4958        {
4959            let to_remove = ["parent"];
4960            params.remove_params(&to_remove);
4961        }
4962
4963        let url = params.parse_with_url(&url);
4964
4965        let mut json_mime_type = mime::APPLICATION_JSON;
4966        let mut request_value_reader = {
4967            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4968            common::remove_json_null_values(&mut value);
4969            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4970            serde_json::to_writer(&mut dst, &value).unwrap();
4971            dst
4972        };
4973        let request_size = request_value_reader
4974            .seek(std::io::SeekFrom::End(0))
4975            .unwrap();
4976        request_value_reader
4977            .seek(std::io::SeekFrom::Start(0))
4978            .unwrap();
4979
4980        loop {
4981            let token = match self
4982                .hub
4983                .auth
4984                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4985                .await
4986            {
4987                Ok(token) => token,
4988                Err(e) => match dlg.token(e) {
4989                    Ok(token) => token,
4990                    Err(e) => {
4991                        dlg.finished(false);
4992                        return Err(common::Error::MissingToken(e));
4993                    }
4994                },
4995            };
4996            request_value_reader
4997                .seek(std::io::SeekFrom::Start(0))
4998                .unwrap();
4999            let mut req_result = {
5000                let client = &self.hub.client;
5001                dlg.pre_request();
5002                let mut req_builder = hyper::Request::builder()
5003                    .method(hyper::Method::POST)
5004                    .uri(url.as_str())
5005                    .header(USER_AGENT, self.hub._user_agent.clone());
5006
5007                if let Some(token) = token.as_ref() {
5008                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5009                }
5010
5011                let request = req_builder
5012                    .header(CONTENT_TYPE, json_mime_type.to_string())
5013                    .header(CONTENT_LENGTH, request_size as u64)
5014                    .body(common::to_body(
5015                        request_value_reader.get_ref().clone().into(),
5016                    ));
5017
5018                client.request(request.unwrap()).await
5019            };
5020
5021            match req_result {
5022                Err(err) => {
5023                    if let common::Retry::After(d) = dlg.http_error(&err) {
5024                        sleep(d).await;
5025                        continue;
5026                    }
5027                    dlg.finished(false);
5028                    return Err(common::Error::HttpError(err));
5029                }
5030                Ok(res) => {
5031                    let (mut parts, body) = res.into_parts();
5032                    let mut body = common::Body::new(body);
5033                    if !parts.status.is_success() {
5034                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5035                        let error = serde_json::from_str(&common::to_string(&bytes));
5036                        let response = common::to_response(parts, bytes.into());
5037
5038                        if let common::Retry::After(d) =
5039                            dlg.http_failure(&response, error.as_ref().ok())
5040                        {
5041                            sleep(d).await;
5042                            continue;
5043                        }
5044
5045                        dlg.finished(false);
5046
5047                        return Err(match error {
5048                            Ok(value) => common::Error::BadRequest(value),
5049                            _ => common::Error::Failure(response),
5050                        });
5051                    }
5052                    let response = {
5053                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5054                        let encoded = common::to_string(&bytes);
5055                        match serde_json::from_str(&encoded) {
5056                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5057                            Err(error) => {
5058                                dlg.response_json_decode_error(&encoded, &error);
5059                                return Err(common::Error::JsonDecodeError(
5060                                    encoded.to_string(),
5061                                    error,
5062                                ));
5063                            }
5064                        }
5065                    };
5066
5067                    dlg.finished(true);
5068                    return Ok(response);
5069                }
5070            }
5071        }
5072    }
5073
5074    ///
5075    /// Sets the *request* property to the given value.
5076    ///
5077    /// Even though the property as already been set when instantiating this call,
5078    /// we provide this method for API completeness.
5079    pub fn request(mut self, new_value: Execution) -> ProjectLocationExecutionCreateCall<'a, C> {
5080        self._request = new_value;
5081        self
5082    }
5083    /// Required. Format: `parent=projects/{project_id}/locations/{location}`
5084    ///
5085    /// Sets the *parent* path property to the given value.
5086    ///
5087    /// Even though the property as already been set when instantiating this call,
5088    /// we provide this method for API completeness.
5089    pub fn parent(mut self, new_value: &str) -> ProjectLocationExecutionCreateCall<'a, C> {
5090        self._parent = new_value.to_string();
5091        self
5092    }
5093    /// Required. User-defined unique ID of this execution.
5094    ///
5095    /// Sets the *execution id* query property to the given value.
5096    pub fn execution_id(mut self, new_value: &str) -> ProjectLocationExecutionCreateCall<'a, C> {
5097        self._execution_id = Some(new_value.to_string());
5098        self
5099    }
5100    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5101    /// while executing the actual API request.
5102    ///
5103    /// ````text
5104    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5105    /// ````
5106    ///
5107    /// Sets the *delegate* property to the given value.
5108    pub fn delegate(
5109        mut self,
5110        new_value: &'a mut dyn common::Delegate,
5111    ) -> ProjectLocationExecutionCreateCall<'a, C> {
5112        self._delegate = Some(new_value);
5113        self
5114    }
5115
5116    /// Set any additional parameter of the query string used in the request.
5117    /// It should be used to set parameters which are not yet available through their own
5118    /// setters.
5119    ///
5120    /// Please note that this method must not be used to set any of the known parameters
5121    /// which have their own setter method. If done anyway, the request will fail.
5122    ///
5123    /// # Additional Parameters
5124    ///
5125    /// * *$.xgafv* (query-string) - V1 error format.
5126    /// * *access_token* (query-string) - OAuth access token.
5127    /// * *alt* (query-string) - Data format for response.
5128    /// * *callback* (query-string) - JSONP
5129    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5130    /// * *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.
5131    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5132    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5133    /// * *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.
5134    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5135    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5136    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationExecutionCreateCall<'a, C>
5137    where
5138        T: AsRef<str>,
5139    {
5140        self._additional_params
5141            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5142        self
5143    }
5144
5145    /// Identifies the authorization scope for the method you are building.
5146    ///
5147    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5148    /// [`Scope::CloudPlatform`].
5149    ///
5150    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5151    /// tokens for more than one scope.
5152    ///
5153    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5154    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5155    /// sufficient, a read-write scope will do as well.
5156    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationExecutionCreateCall<'a, C>
5157    where
5158        St: AsRef<str>,
5159    {
5160        self._scopes.insert(String::from(scope.as_ref()));
5161        self
5162    }
5163    /// Identifies the authorization scope(s) for the method you are building.
5164    ///
5165    /// See [`Self::add_scope()`] for details.
5166    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationExecutionCreateCall<'a, C>
5167    where
5168        I: IntoIterator<Item = St>,
5169        St: AsRef<str>,
5170    {
5171        self._scopes
5172            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5173        self
5174    }
5175
5176    /// Removes all scopes, and no default scope will be used either.
5177    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5178    /// for details).
5179    pub fn clear_scopes(mut self) -> ProjectLocationExecutionCreateCall<'a, C> {
5180        self._scopes.clear();
5181        self
5182    }
5183}
5184
5185/// Deletes execution
5186///
5187/// A builder for the *locations.executions.delete* method supported by a *project* resource.
5188/// It is not used directly, but through a [`ProjectMethods`] instance.
5189///
5190/// # Example
5191///
5192/// Instantiate a resource method builder
5193///
5194/// ```test_harness,no_run
5195/// # extern crate hyper;
5196/// # extern crate hyper_rustls;
5197/// # extern crate google_notebooks1 as notebooks1;
5198/// # async fn dox() {
5199/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5200///
5201/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5202/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5203/// #     secret,
5204/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5205/// # ).build().await.unwrap();
5206///
5207/// # let client = hyper_util::client::legacy::Client::builder(
5208/// #     hyper_util::rt::TokioExecutor::new()
5209/// # )
5210/// # .build(
5211/// #     hyper_rustls::HttpsConnectorBuilder::new()
5212/// #         .with_native_roots()
5213/// #         .unwrap()
5214/// #         .https_or_http()
5215/// #         .enable_http1()
5216/// #         .build()
5217/// # );
5218/// # let mut hub = AIPlatformNotebooks::new(client, auth);
5219/// // You can configure optional parameters by calling the respective setters at will, and
5220/// // execute the final call using `doit()`.
5221/// // Values shown here are possibly random and not representative !
5222/// let result = hub.projects().locations_executions_delete("name")
5223///              .doit().await;
5224/// # }
5225/// ```
5226pub struct ProjectLocationExecutionDeleteCall<'a, C>
5227where
5228    C: 'a,
5229{
5230    hub: &'a AIPlatformNotebooks<C>,
5231    _name: String,
5232    _delegate: Option<&'a mut dyn common::Delegate>,
5233    _additional_params: HashMap<String, String>,
5234    _scopes: BTreeSet<String>,
5235}
5236
5237impl<'a, C> common::CallBuilder for ProjectLocationExecutionDeleteCall<'a, C> {}
5238
5239impl<'a, C> ProjectLocationExecutionDeleteCall<'a, C>
5240where
5241    C: common::Connector,
5242{
5243    /// Perform the operation you have build so far.
5244    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5245        use std::borrow::Cow;
5246        use std::io::{Read, Seek};
5247
5248        use common::{url::Params, ToParts};
5249        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5250
5251        let mut dd = common::DefaultDelegate;
5252        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5253        dlg.begin(common::MethodInfo {
5254            id: "notebooks.projects.locations.executions.delete",
5255            http_method: hyper::Method::DELETE,
5256        });
5257
5258        for &field in ["alt", "name"].iter() {
5259            if self._additional_params.contains_key(field) {
5260                dlg.finished(false);
5261                return Err(common::Error::FieldClash(field));
5262            }
5263        }
5264
5265        let mut params = Params::with_capacity(3 + self._additional_params.len());
5266        params.push("name", self._name);
5267
5268        params.extend(self._additional_params.iter());
5269
5270        params.push("alt", "json");
5271        let mut url = self.hub._base_url.clone() + "v1/{+name}";
5272        if self._scopes.is_empty() {
5273            self._scopes
5274                .insert(Scope::CloudPlatform.as_ref().to_string());
5275        }
5276
5277        #[allow(clippy::single_element_loop)]
5278        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5279            url = params.uri_replacement(url, param_name, find_this, true);
5280        }
5281        {
5282            let to_remove = ["name"];
5283            params.remove_params(&to_remove);
5284        }
5285
5286        let url = params.parse_with_url(&url);
5287
5288        loop {
5289            let token = match self
5290                .hub
5291                .auth
5292                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5293                .await
5294            {
5295                Ok(token) => token,
5296                Err(e) => match dlg.token(e) {
5297                    Ok(token) => token,
5298                    Err(e) => {
5299                        dlg.finished(false);
5300                        return Err(common::Error::MissingToken(e));
5301                    }
5302                },
5303            };
5304            let mut req_result = {
5305                let client = &self.hub.client;
5306                dlg.pre_request();
5307                let mut req_builder = hyper::Request::builder()
5308                    .method(hyper::Method::DELETE)
5309                    .uri(url.as_str())
5310                    .header(USER_AGENT, self.hub._user_agent.clone());
5311
5312                if let Some(token) = token.as_ref() {
5313                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5314                }
5315
5316                let request = req_builder
5317                    .header(CONTENT_LENGTH, 0_u64)
5318                    .body(common::to_body::<String>(None));
5319
5320                client.request(request.unwrap()).await
5321            };
5322
5323            match req_result {
5324                Err(err) => {
5325                    if let common::Retry::After(d) = dlg.http_error(&err) {
5326                        sleep(d).await;
5327                        continue;
5328                    }
5329                    dlg.finished(false);
5330                    return Err(common::Error::HttpError(err));
5331                }
5332                Ok(res) => {
5333                    let (mut parts, body) = res.into_parts();
5334                    let mut body = common::Body::new(body);
5335                    if !parts.status.is_success() {
5336                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5337                        let error = serde_json::from_str(&common::to_string(&bytes));
5338                        let response = common::to_response(parts, bytes.into());
5339
5340                        if let common::Retry::After(d) =
5341                            dlg.http_failure(&response, error.as_ref().ok())
5342                        {
5343                            sleep(d).await;
5344                            continue;
5345                        }
5346
5347                        dlg.finished(false);
5348
5349                        return Err(match error {
5350                            Ok(value) => common::Error::BadRequest(value),
5351                            _ => common::Error::Failure(response),
5352                        });
5353                    }
5354                    let response = {
5355                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5356                        let encoded = common::to_string(&bytes);
5357                        match serde_json::from_str(&encoded) {
5358                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5359                            Err(error) => {
5360                                dlg.response_json_decode_error(&encoded, &error);
5361                                return Err(common::Error::JsonDecodeError(
5362                                    encoded.to_string(),
5363                                    error,
5364                                ));
5365                            }
5366                        }
5367                    };
5368
5369                    dlg.finished(true);
5370                    return Ok(response);
5371                }
5372            }
5373        }
5374    }
5375
5376    /// Required. Format: `projects/{project_id}/locations/{location}/executions/{execution_id}`
5377    ///
5378    /// Sets the *name* path property to the given value.
5379    ///
5380    /// Even though the property as already been set when instantiating this call,
5381    /// we provide this method for API completeness.
5382    pub fn name(mut self, new_value: &str) -> ProjectLocationExecutionDeleteCall<'a, C> {
5383        self._name = new_value.to_string();
5384        self
5385    }
5386    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5387    /// while executing the actual API request.
5388    ///
5389    /// ````text
5390    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5391    /// ````
5392    ///
5393    /// Sets the *delegate* property to the given value.
5394    pub fn delegate(
5395        mut self,
5396        new_value: &'a mut dyn common::Delegate,
5397    ) -> ProjectLocationExecutionDeleteCall<'a, C> {
5398        self._delegate = Some(new_value);
5399        self
5400    }
5401
5402    /// Set any additional parameter of the query string used in the request.
5403    /// It should be used to set parameters which are not yet available through their own
5404    /// setters.
5405    ///
5406    /// Please note that this method must not be used to set any of the known parameters
5407    /// which have their own setter method. If done anyway, the request will fail.
5408    ///
5409    /// # Additional Parameters
5410    ///
5411    /// * *$.xgafv* (query-string) - V1 error format.
5412    /// * *access_token* (query-string) - OAuth access token.
5413    /// * *alt* (query-string) - Data format for response.
5414    /// * *callback* (query-string) - JSONP
5415    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5416    /// * *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.
5417    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5418    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5419    /// * *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.
5420    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5421    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5422    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationExecutionDeleteCall<'a, C>
5423    where
5424        T: AsRef<str>,
5425    {
5426        self._additional_params
5427            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5428        self
5429    }
5430
5431    /// Identifies the authorization scope for the method you are building.
5432    ///
5433    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5434    /// [`Scope::CloudPlatform`].
5435    ///
5436    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5437    /// tokens for more than one scope.
5438    ///
5439    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5440    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5441    /// sufficient, a read-write scope will do as well.
5442    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationExecutionDeleteCall<'a, C>
5443    where
5444        St: AsRef<str>,
5445    {
5446        self._scopes.insert(String::from(scope.as_ref()));
5447        self
5448    }
5449    /// Identifies the authorization scope(s) for the method you are building.
5450    ///
5451    /// See [`Self::add_scope()`] for details.
5452    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationExecutionDeleteCall<'a, C>
5453    where
5454        I: IntoIterator<Item = St>,
5455        St: AsRef<str>,
5456    {
5457        self._scopes
5458            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5459        self
5460    }
5461
5462    /// Removes all scopes, and no default scope will be used either.
5463    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5464    /// for details).
5465    pub fn clear_scopes(mut self) -> ProjectLocationExecutionDeleteCall<'a, C> {
5466        self._scopes.clear();
5467        self
5468    }
5469}
5470
5471/// Gets details of executions
5472///
5473/// A builder for the *locations.executions.get* method supported by a *project* resource.
5474/// It is not used directly, but through a [`ProjectMethods`] instance.
5475///
5476/// # Example
5477///
5478/// Instantiate a resource method builder
5479///
5480/// ```test_harness,no_run
5481/// # extern crate hyper;
5482/// # extern crate hyper_rustls;
5483/// # extern crate google_notebooks1 as notebooks1;
5484/// # async fn dox() {
5485/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5486///
5487/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5488/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5489/// #     secret,
5490/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5491/// # ).build().await.unwrap();
5492///
5493/// # let client = hyper_util::client::legacy::Client::builder(
5494/// #     hyper_util::rt::TokioExecutor::new()
5495/// # )
5496/// # .build(
5497/// #     hyper_rustls::HttpsConnectorBuilder::new()
5498/// #         .with_native_roots()
5499/// #         .unwrap()
5500/// #         .https_or_http()
5501/// #         .enable_http1()
5502/// #         .build()
5503/// # );
5504/// # let mut hub = AIPlatformNotebooks::new(client, auth);
5505/// // You can configure optional parameters by calling the respective setters at will, and
5506/// // execute the final call using `doit()`.
5507/// // Values shown here are possibly random and not representative !
5508/// let result = hub.projects().locations_executions_get("name")
5509///              .doit().await;
5510/// # }
5511/// ```
5512pub struct ProjectLocationExecutionGetCall<'a, C>
5513where
5514    C: 'a,
5515{
5516    hub: &'a AIPlatformNotebooks<C>,
5517    _name: String,
5518    _delegate: Option<&'a mut dyn common::Delegate>,
5519    _additional_params: HashMap<String, String>,
5520    _scopes: BTreeSet<String>,
5521}
5522
5523impl<'a, C> common::CallBuilder for ProjectLocationExecutionGetCall<'a, C> {}
5524
5525impl<'a, C> ProjectLocationExecutionGetCall<'a, C>
5526where
5527    C: common::Connector,
5528{
5529    /// Perform the operation you have build so far.
5530    pub async fn doit(mut self) -> common::Result<(common::Response, Execution)> {
5531        use std::borrow::Cow;
5532        use std::io::{Read, Seek};
5533
5534        use common::{url::Params, ToParts};
5535        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5536
5537        let mut dd = common::DefaultDelegate;
5538        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5539        dlg.begin(common::MethodInfo {
5540            id: "notebooks.projects.locations.executions.get",
5541            http_method: hyper::Method::GET,
5542        });
5543
5544        for &field in ["alt", "name"].iter() {
5545            if self._additional_params.contains_key(field) {
5546                dlg.finished(false);
5547                return Err(common::Error::FieldClash(field));
5548            }
5549        }
5550
5551        let mut params = Params::with_capacity(3 + self._additional_params.len());
5552        params.push("name", self._name);
5553
5554        params.extend(self._additional_params.iter());
5555
5556        params.push("alt", "json");
5557        let mut url = self.hub._base_url.clone() + "v1/{+name}";
5558        if self._scopes.is_empty() {
5559            self._scopes
5560                .insert(Scope::CloudPlatform.as_ref().to_string());
5561        }
5562
5563        #[allow(clippy::single_element_loop)]
5564        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5565            url = params.uri_replacement(url, param_name, find_this, true);
5566        }
5567        {
5568            let to_remove = ["name"];
5569            params.remove_params(&to_remove);
5570        }
5571
5572        let url = params.parse_with_url(&url);
5573
5574        loop {
5575            let token = match self
5576                .hub
5577                .auth
5578                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5579                .await
5580            {
5581                Ok(token) => token,
5582                Err(e) => match dlg.token(e) {
5583                    Ok(token) => token,
5584                    Err(e) => {
5585                        dlg.finished(false);
5586                        return Err(common::Error::MissingToken(e));
5587                    }
5588                },
5589            };
5590            let mut req_result = {
5591                let client = &self.hub.client;
5592                dlg.pre_request();
5593                let mut req_builder = hyper::Request::builder()
5594                    .method(hyper::Method::GET)
5595                    .uri(url.as_str())
5596                    .header(USER_AGENT, self.hub._user_agent.clone());
5597
5598                if let Some(token) = token.as_ref() {
5599                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5600                }
5601
5602                let request = req_builder
5603                    .header(CONTENT_LENGTH, 0_u64)
5604                    .body(common::to_body::<String>(None));
5605
5606                client.request(request.unwrap()).await
5607            };
5608
5609            match req_result {
5610                Err(err) => {
5611                    if let common::Retry::After(d) = dlg.http_error(&err) {
5612                        sleep(d).await;
5613                        continue;
5614                    }
5615                    dlg.finished(false);
5616                    return Err(common::Error::HttpError(err));
5617                }
5618                Ok(res) => {
5619                    let (mut parts, body) = res.into_parts();
5620                    let mut body = common::Body::new(body);
5621                    if !parts.status.is_success() {
5622                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5623                        let error = serde_json::from_str(&common::to_string(&bytes));
5624                        let response = common::to_response(parts, bytes.into());
5625
5626                        if let common::Retry::After(d) =
5627                            dlg.http_failure(&response, error.as_ref().ok())
5628                        {
5629                            sleep(d).await;
5630                            continue;
5631                        }
5632
5633                        dlg.finished(false);
5634
5635                        return Err(match error {
5636                            Ok(value) => common::Error::BadRequest(value),
5637                            _ => common::Error::Failure(response),
5638                        });
5639                    }
5640                    let response = {
5641                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5642                        let encoded = common::to_string(&bytes);
5643                        match serde_json::from_str(&encoded) {
5644                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5645                            Err(error) => {
5646                                dlg.response_json_decode_error(&encoded, &error);
5647                                return Err(common::Error::JsonDecodeError(
5648                                    encoded.to_string(),
5649                                    error,
5650                                ));
5651                            }
5652                        }
5653                    };
5654
5655                    dlg.finished(true);
5656                    return Ok(response);
5657                }
5658            }
5659        }
5660    }
5661
5662    /// Required. Format: `projects/{project_id}/locations/{location}/executions/{execution_id}`
5663    ///
5664    /// Sets the *name* path property to the given value.
5665    ///
5666    /// Even though the property as already been set when instantiating this call,
5667    /// we provide this method for API completeness.
5668    pub fn name(mut self, new_value: &str) -> ProjectLocationExecutionGetCall<'a, C> {
5669        self._name = new_value.to_string();
5670        self
5671    }
5672    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5673    /// while executing the actual API request.
5674    ///
5675    /// ````text
5676    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5677    /// ````
5678    ///
5679    /// Sets the *delegate* property to the given value.
5680    pub fn delegate(
5681        mut self,
5682        new_value: &'a mut dyn common::Delegate,
5683    ) -> ProjectLocationExecutionGetCall<'a, C> {
5684        self._delegate = Some(new_value);
5685        self
5686    }
5687
5688    /// Set any additional parameter of the query string used in the request.
5689    /// It should be used to set parameters which are not yet available through their own
5690    /// setters.
5691    ///
5692    /// Please note that this method must not be used to set any of the known parameters
5693    /// which have their own setter method. If done anyway, the request will fail.
5694    ///
5695    /// # Additional Parameters
5696    ///
5697    /// * *$.xgafv* (query-string) - V1 error format.
5698    /// * *access_token* (query-string) - OAuth access token.
5699    /// * *alt* (query-string) - Data format for response.
5700    /// * *callback* (query-string) - JSONP
5701    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5702    /// * *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.
5703    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5704    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5705    /// * *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.
5706    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5707    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5708    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationExecutionGetCall<'a, C>
5709    where
5710        T: AsRef<str>,
5711    {
5712        self._additional_params
5713            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5714        self
5715    }
5716
5717    /// Identifies the authorization scope for the method you are building.
5718    ///
5719    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5720    /// [`Scope::CloudPlatform`].
5721    ///
5722    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5723    /// tokens for more than one scope.
5724    ///
5725    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5726    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5727    /// sufficient, a read-write scope will do as well.
5728    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationExecutionGetCall<'a, C>
5729    where
5730        St: AsRef<str>,
5731    {
5732        self._scopes.insert(String::from(scope.as_ref()));
5733        self
5734    }
5735    /// Identifies the authorization scope(s) for the method you are building.
5736    ///
5737    /// See [`Self::add_scope()`] for details.
5738    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationExecutionGetCall<'a, C>
5739    where
5740        I: IntoIterator<Item = St>,
5741        St: AsRef<str>,
5742    {
5743        self._scopes
5744            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5745        self
5746    }
5747
5748    /// Removes all scopes, and no default scope will be used either.
5749    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5750    /// for details).
5751    pub fn clear_scopes(mut self) -> ProjectLocationExecutionGetCall<'a, C> {
5752        self._scopes.clear();
5753        self
5754    }
5755}
5756
5757/// Lists executions in a given project and location
5758///
5759/// A builder for the *locations.executions.list* method supported by a *project* resource.
5760/// It is not used directly, but through a [`ProjectMethods`] instance.
5761///
5762/// # Example
5763///
5764/// Instantiate a resource method builder
5765///
5766/// ```test_harness,no_run
5767/// # extern crate hyper;
5768/// # extern crate hyper_rustls;
5769/// # extern crate google_notebooks1 as notebooks1;
5770/// # async fn dox() {
5771/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5772///
5773/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5774/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5775/// #     secret,
5776/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5777/// # ).build().await.unwrap();
5778///
5779/// # let client = hyper_util::client::legacy::Client::builder(
5780/// #     hyper_util::rt::TokioExecutor::new()
5781/// # )
5782/// # .build(
5783/// #     hyper_rustls::HttpsConnectorBuilder::new()
5784/// #         .with_native_roots()
5785/// #         .unwrap()
5786/// #         .https_or_http()
5787/// #         .enable_http1()
5788/// #         .build()
5789/// # );
5790/// # let mut hub = AIPlatformNotebooks::new(client, auth);
5791/// // You can configure optional parameters by calling the respective setters at will, and
5792/// // execute the final call using `doit()`.
5793/// // Values shown here are possibly random and not representative !
5794/// let result = hub.projects().locations_executions_list("parent")
5795///              .page_token("amet")
5796///              .page_size(-20)
5797///              .order_by("ipsum")
5798///              .filter("sed")
5799///              .doit().await;
5800/// # }
5801/// ```
5802pub struct ProjectLocationExecutionListCall<'a, C>
5803where
5804    C: 'a,
5805{
5806    hub: &'a AIPlatformNotebooks<C>,
5807    _parent: String,
5808    _page_token: Option<String>,
5809    _page_size: Option<i32>,
5810    _order_by: Option<String>,
5811    _filter: Option<String>,
5812    _delegate: Option<&'a mut dyn common::Delegate>,
5813    _additional_params: HashMap<String, String>,
5814    _scopes: BTreeSet<String>,
5815}
5816
5817impl<'a, C> common::CallBuilder for ProjectLocationExecutionListCall<'a, C> {}
5818
5819impl<'a, C> ProjectLocationExecutionListCall<'a, C>
5820where
5821    C: common::Connector,
5822{
5823    /// Perform the operation you have build so far.
5824    pub async fn doit(mut self) -> common::Result<(common::Response, ListExecutionsResponse)> {
5825        use std::borrow::Cow;
5826        use std::io::{Read, Seek};
5827
5828        use common::{url::Params, ToParts};
5829        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5830
5831        let mut dd = common::DefaultDelegate;
5832        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5833        dlg.begin(common::MethodInfo {
5834            id: "notebooks.projects.locations.executions.list",
5835            http_method: hyper::Method::GET,
5836        });
5837
5838        for &field in [
5839            "alt",
5840            "parent",
5841            "pageToken",
5842            "pageSize",
5843            "orderBy",
5844            "filter",
5845        ]
5846        .iter()
5847        {
5848            if self._additional_params.contains_key(field) {
5849                dlg.finished(false);
5850                return Err(common::Error::FieldClash(field));
5851            }
5852        }
5853
5854        let mut params = Params::with_capacity(7 + self._additional_params.len());
5855        params.push("parent", self._parent);
5856        if let Some(value) = self._page_token.as_ref() {
5857            params.push("pageToken", value);
5858        }
5859        if let Some(value) = self._page_size.as_ref() {
5860            params.push("pageSize", value.to_string());
5861        }
5862        if let Some(value) = self._order_by.as_ref() {
5863            params.push("orderBy", value);
5864        }
5865        if let Some(value) = self._filter.as_ref() {
5866            params.push("filter", value);
5867        }
5868
5869        params.extend(self._additional_params.iter());
5870
5871        params.push("alt", "json");
5872        let mut url = self.hub._base_url.clone() + "v1/{+parent}/executions";
5873        if self._scopes.is_empty() {
5874            self._scopes
5875                .insert(Scope::CloudPlatform.as_ref().to_string());
5876        }
5877
5878        #[allow(clippy::single_element_loop)]
5879        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5880            url = params.uri_replacement(url, param_name, find_this, true);
5881        }
5882        {
5883            let to_remove = ["parent"];
5884            params.remove_params(&to_remove);
5885        }
5886
5887        let url = params.parse_with_url(&url);
5888
5889        loop {
5890            let token = match self
5891                .hub
5892                .auth
5893                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5894                .await
5895            {
5896                Ok(token) => token,
5897                Err(e) => match dlg.token(e) {
5898                    Ok(token) => token,
5899                    Err(e) => {
5900                        dlg.finished(false);
5901                        return Err(common::Error::MissingToken(e));
5902                    }
5903                },
5904            };
5905            let mut req_result = {
5906                let client = &self.hub.client;
5907                dlg.pre_request();
5908                let mut req_builder = hyper::Request::builder()
5909                    .method(hyper::Method::GET)
5910                    .uri(url.as_str())
5911                    .header(USER_AGENT, self.hub._user_agent.clone());
5912
5913                if let Some(token) = token.as_ref() {
5914                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5915                }
5916
5917                let request = req_builder
5918                    .header(CONTENT_LENGTH, 0_u64)
5919                    .body(common::to_body::<String>(None));
5920
5921                client.request(request.unwrap()).await
5922            };
5923
5924            match req_result {
5925                Err(err) => {
5926                    if let common::Retry::After(d) = dlg.http_error(&err) {
5927                        sleep(d).await;
5928                        continue;
5929                    }
5930                    dlg.finished(false);
5931                    return Err(common::Error::HttpError(err));
5932                }
5933                Ok(res) => {
5934                    let (mut parts, body) = res.into_parts();
5935                    let mut body = common::Body::new(body);
5936                    if !parts.status.is_success() {
5937                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5938                        let error = serde_json::from_str(&common::to_string(&bytes));
5939                        let response = common::to_response(parts, bytes.into());
5940
5941                        if let common::Retry::After(d) =
5942                            dlg.http_failure(&response, error.as_ref().ok())
5943                        {
5944                            sleep(d).await;
5945                            continue;
5946                        }
5947
5948                        dlg.finished(false);
5949
5950                        return Err(match error {
5951                            Ok(value) => common::Error::BadRequest(value),
5952                            _ => common::Error::Failure(response),
5953                        });
5954                    }
5955                    let response = {
5956                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5957                        let encoded = common::to_string(&bytes);
5958                        match serde_json::from_str(&encoded) {
5959                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5960                            Err(error) => {
5961                                dlg.response_json_decode_error(&encoded, &error);
5962                                return Err(common::Error::JsonDecodeError(
5963                                    encoded.to_string(),
5964                                    error,
5965                                ));
5966                            }
5967                        }
5968                    };
5969
5970                    dlg.finished(true);
5971                    return Ok(response);
5972                }
5973            }
5974        }
5975    }
5976
5977    /// Required. Format: `parent=projects/{project_id}/locations/{location}`
5978    ///
5979    /// Sets the *parent* path property to the given value.
5980    ///
5981    /// Even though the property as already been set when instantiating this call,
5982    /// we provide this method for API completeness.
5983    pub fn parent(mut self, new_value: &str) -> ProjectLocationExecutionListCall<'a, C> {
5984        self._parent = new_value.to_string();
5985        self
5986    }
5987    /// A previous returned page token that can be used to continue listing from the last result.
5988    ///
5989    /// Sets the *page token* query property to the given value.
5990    pub fn page_token(mut self, new_value: &str) -> ProjectLocationExecutionListCall<'a, C> {
5991        self._page_token = Some(new_value.to_string());
5992        self
5993    }
5994    /// Maximum return size of the list call.
5995    ///
5996    /// Sets the *page size* query property to the given value.
5997    pub fn page_size(mut self, new_value: i32) -> ProjectLocationExecutionListCall<'a, C> {
5998        self._page_size = Some(new_value);
5999        self
6000    }
6001    /// Sort by field.
6002    ///
6003    /// Sets the *order by* query property to the given value.
6004    pub fn order_by(mut self, new_value: &str) -> ProjectLocationExecutionListCall<'a, C> {
6005        self._order_by = Some(new_value.to_string());
6006        self
6007    }
6008    /// Filter applied to resulting executions. Currently only supports filtering executions by a specified `schedule_id`. Format: `schedule_id=`
6009    ///
6010    /// Sets the *filter* query property to the given value.
6011    pub fn filter(mut self, new_value: &str) -> ProjectLocationExecutionListCall<'a, C> {
6012        self._filter = Some(new_value.to_string());
6013        self
6014    }
6015    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6016    /// while executing the actual API request.
6017    ///
6018    /// ````text
6019    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6020    /// ````
6021    ///
6022    /// Sets the *delegate* property to the given value.
6023    pub fn delegate(
6024        mut self,
6025        new_value: &'a mut dyn common::Delegate,
6026    ) -> ProjectLocationExecutionListCall<'a, C> {
6027        self._delegate = Some(new_value);
6028        self
6029    }
6030
6031    /// Set any additional parameter of the query string used in the request.
6032    /// It should be used to set parameters which are not yet available through their own
6033    /// setters.
6034    ///
6035    /// Please note that this method must not be used to set any of the known parameters
6036    /// which have their own setter method. If done anyway, the request will fail.
6037    ///
6038    /// # Additional Parameters
6039    ///
6040    /// * *$.xgafv* (query-string) - V1 error format.
6041    /// * *access_token* (query-string) - OAuth access token.
6042    /// * *alt* (query-string) - Data format for response.
6043    /// * *callback* (query-string) - JSONP
6044    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6045    /// * *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.
6046    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6047    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6048    /// * *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.
6049    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6050    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6051    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationExecutionListCall<'a, C>
6052    where
6053        T: AsRef<str>,
6054    {
6055        self._additional_params
6056            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6057        self
6058    }
6059
6060    /// Identifies the authorization scope for the method you are building.
6061    ///
6062    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6063    /// [`Scope::CloudPlatform`].
6064    ///
6065    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6066    /// tokens for more than one scope.
6067    ///
6068    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6069    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6070    /// sufficient, a read-write scope will do as well.
6071    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationExecutionListCall<'a, C>
6072    where
6073        St: AsRef<str>,
6074    {
6075        self._scopes.insert(String::from(scope.as_ref()));
6076        self
6077    }
6078    /// Identifies the authorization scope(s) for the method you are building.
6079    ///
6080    /// See [`Self::add_scope()`] for details.
6081    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationExecutionListCall<'a, C>
6082    where
6083        I: IntoIterator<Item = St>,
6084        St: AsRef<str>,
6085    {
6086        self._scopes
6087            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6088        self
6089    }
6090
6091    /// Removes all scopes, and no default scope will be used either.
6092    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6093    /// for details).
6094    pub fn clear_scopes(mut self) -> ProjectLocationExecutionListCall<'a, C> {
6095        self._scopes.clear();
6096        self
6097    }
6098}
6099
6100/// Creates a new Instance in a given project and location.
6101///
6102/// A builder for the *locations.instances.create* method supported by a *project* resource.
6103/// It is not used directly, but through a [`ProjectMethods`] instance.
6104///
6105/// # Example
6106///
6107/// Instantiate a resource method builder
6108///
6109/// ```test_harness,no_run
6110/// # extern crate hyper;
6111/// # extern crate hyper_rustls;
6112/// # extern crate google_notebooks1 as notebooks1;
6113/// use notebooks1::api::Instance;
6114/// # async fn dox() {
6115/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6116///
6117/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6118/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6119/// #     secret,
6120/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6121/// # ).build().await.unwrap();
6122///
6123/// # let client = hyper_util::client::legacy::Client::builder(
6124/// #     hyper_util::rt::TokioExecutor::new()
6125/// # )
6126/// # .build(
6127/// #     hyper_rustls::HttpsConnectorBuilder::new()
6128/// #         .with_native_roots()
6129/// #         .unwrap()
6130/// #         .https_or_http()
6131/// #         .enable_http1()
6132/// #         .build()
6133/// # );
6134/// # let mut hub = AIPlatformNotebooks::new(client, auth);
6135/// // As the method needs a request, you would usually fill it with the desired information
6136/// // into the respective structure. Some of the parts shown here might not be applicable !
6137/// // Values shown here are possibly random and not representative !
6138/// let mut req = Instance::default();
6139///
6140/// // You can configure optional parameters by calling the respective setters at will, and
6141/// // execute the final call using `doit()`.
6142/// // Values shown here are possibly random and not representative !
6143/// let result = hub.projects().locations_instances_create(req, "parent")
6144///              .instance_id("gubergren")
6145///              .doit().await;
6146/// # }
6147/// ```
6148pub struct ProjectLocationInstanceCreateCall<'a, C>
6149where
6150    C: 'a,
6151{
6152    hub: &'a AIPlatformNotebooks<C>,
6153    _request: Instance,
6154    _parent: String,
6155    _instance_id: Option<String>,
6156    _delegate: Option<&'a mut dyn common::Delegate>,
6157    _additional_params: HashMap<String, String>,
6158    _scopes: BTreeSet<String>,
6159}
6160
6161impl<'a, C> common::CallBuilder for ProjectLocationInstanceCreateCall<'a, C> {}
6162
6163impl<'a, C> ProjectLocationInstanceCreateCall<'a, C>
6164where
6165    C: common::Connector,
6166{
6167    /// Perform the operation you have build so far.
6168    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6169        use std::borrow::Cow;
6170        use std::io::{Read, Seek};
6171
6172        use common::{url::Params, ToParts};
6173        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6174
6175        let mut dd = common::DefaultDelegate;
6176        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6177        dlg.begin(common::MethodInfo {
6178            id: "notebooks.projects.locations.instances.create",
6179            http_method: hyper::Method::POST,
6180        });
6181
6182        for &field in ["alt", "parent", "instanceId"].iter() {
6183            if self._additional_params.contains_key(field) {
6184                dlg.finished(false);
6185                return Err(common::Error::FieldClash(field));
6186            }
6187        }
6188
6189        let mut params = Params::with_capacity(5 + self._additional_params.len());
6190        params.push("parent", self._parent);
6191        if let Some(value) = self._instance_id.as_ref() {
6192            params.push("instanceId", value);
6193        }
6194
6195        params.extend(self._additional_params.iter());
6196
6197        params.push("alt", "json");
6198        let mut url = self.hub._base_url.clone() + "v1/{+parent}/instances";
6199        if self._scopes.is_empty() {
6200            self._scopes
6201                .insert(Scope::CloudPlatform.as_ref().to_string());
6202        }
6203
6204        #[allow(clippy::single_element_loop)]
6205        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6206            url = params.uri_replacement(url, param_name, find_this, true);
6207        }
6208        {
6209            let to_remove = ["parent"];
6210            params.remove_params(&to_remove);
6211        }
6212
6213        let url = params.parse_with_url(&url);
6214
6215        let mut json_mime_type = mime::APPLICATION_JSON;
6216        let mut request_value_reader = {
6217            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6218            common::remove_json_null_values(&mut value);
6219            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6220            serde_json::to_writer(&mut dst, &value).unwrap();
6221            dst
6222        };
6223        let request_size = request_value_reader
6224            .seek(std::io::SeekFrom::End(0))
6225            .unwrap();
6226        request_value_reader
6227            .seek(std::io::SeekFrom::Start(0))
6228            .unwrap();
6229
6230        loop {
6231            let token = match self
6232                .hub
6233                .auth
6234                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6235                .await
6236            {
6237                Ok(token) => token,
6238                Err(e) => match dlg.token(e) {
6239                    Ok(token) => token,
6240                    Err(e) => {
6241                        dlg.finished(false);
6242                        return Err(common::Error::MissingToken(e));
6243                    }
6244                },
6245            };
6246            request_value_reader
6247                .seek(std::io::SeekFrom::Start(0))
6248                .unwrap();
6249            let mut req_result = {
6250                let client = &self.hub.client;
6251                dlg.pre_request();
6252                let mut req_builder = hyper::Request::builder()
6253                    .method(hyper::Method::POST)
6254                    .uri(url.as_str())
6255                    .header(USER_AGENT, self.hub._user_agent.clone());
6256
6257                if let Some(token) = token.as_ref() {
6258                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6259                }
6260
6261                let request = req_builder
6262                    .header(CONTENT_TYPE, json_mime_type.to_string())
6263                    .header(CONTENT_LENGTH, request_size as u64)
6264                    .body(common::to_body(
6265                        request_value_reader.get_ref().clone().into(),
6266                    ));
6267
6268                client.request(request.unwrap()).await
6269            };
6270
6271            match req_result {
6272                Err(err) => {
6273                    if let common::Retry::After(d) = dlg.http_error(&err) {
6274                        sleep(d).await;
6275                        continue;
6276                    }
6277                    dlg.finished(false);
6278                    return Err(common::Error::HttpError(err));
6279                }
6280                Ok(res) => {
6281                    let (mut parts, body) = res.into_parts();
6282                    let mut body = common::Body::new(body);
6283                    if !parts.status.is_success() {
6284                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6285                        let error = serde_json::from_str(&common::to_string(&bytes));
6286                        let response = common::to_response(parts, bytes.into());
6287
6288                        if let common::Retry::After(d) =
6289                            dlg.http_failure(&response, error.as_ref().ok())
6290                        {
6291                            sleep(d).await;
6292                            continue;
6293                        }
6294
6295                        dlg.finished(false);
6296
6297                        return Err(match error {
6298                            Ok(value) => common::Error::BadRequest(value),
6299                            _ => common::Error::Failure(response),
6300                        });
6301                    }
6302                    let response = {
6303                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6304                        let encoded = common::to_string(&bytes);
6305                        match serde_json::from_str(&encoded) {
6306                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6307                            Err(error) => {
6308                                dlg.response_json_decode_error(&encoded, &error);
6309                                return Err(common::Error::JsonDecodeError(
6310                                    encoded.to_string(),
6311                                    error,
6312                                ));
6313                            }
6314                        }
6315                    };
6316
6317                    dlg.finished(true);
6318                    return Ok(response);
6319                }
6320            }
6321        }
6322    }
6323
6324    ///
6325    /// Sets the *request* property to the given value.
6326    ///
6327    /// Even though the property as already been set when instantiating this call,
6328    /// we provide this method for API completeness.
6329    pub fn request(mut self, new_value: Instance) -> ProjectLocationInstanceCreateCall<'a, C> {
6330        self._request = new_value;
6331        self
6332    }
6333    /// Required. Format: `parent=projects/{project_id}/locations/{location}`
6334    ///
6335    /// Sets the *parent* path property to the given value.
6336    ///
6337    /// Even though the property as already been set when instantiating this call,
6338    /// we provide this method for API completeness.
6339    pub fn parent(mut self, new_value: &str) -> ProjectLocationInstanceCreateCall<'a, C> {
6340        self._parent = new_value.to_string();
6341        self
6342    }
6343    /// Required. User-defined unique ID of this instance.
6344    ///
6345    /// Sets the *instance id* query property to the given value.
6346    pub fn instance_id(mut self, new_value: &str) -> ProjectLocationInstanceCreateCall<'a, C> {
6347        self._instance_id = Some(new_value.to_string());
6348        self
6349    }
6350    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6351    /// while executing the actual API request.
6352    ///
6353    /// ````text
6354    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6355    /// ````
6356    ///
6357    /// Sets the *delegate* property to the given value.
6358    pub fn delegate(
6359        mut self,
6360        new_value: &'a mut dyn common::Delegate,
6361    ) -> ProjectLocationInstanceCreateCall<'a, C> {
6362        self._delegate = Some(new_value);
6363        self
6364    }
6365
6366    /// Set any additional parameter of the query string used in the request.
6367    /// It should be used to set parameters which are not yet available through their own
6368    /// setters.
6369    ///
6370    /// Please note that this method must not be used to set any of the known parameters
6371    /// which have their own setter method. If done anyway, the request will fail.
6372    ///
6373    /// # Additional Parameters
6374    ///
6375    /// * *$.xgafv* (query-string) - V1 error format.
6376    /// * *access_token* (query-string) - OAuth access token.
6377    /// * *alt* (query-string) - Data format for response.
6378    /// * *callback* (query-string) - JSONP
6379    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6380    /// * *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.
6381    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6382    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6383    /// * *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.
6384    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6385    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6386    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceCreateCall<'a, C>
6387    where
6388        T: AsRef<str>,
6389    {
6390        self._additional_params
6391            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6392        self
6393    }
6394
6395    /// Identifies the authorization scope for the method you are building.
6396    ///
6397    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6398    /// [`Scope::CloudPlatform`].
6399    ///
6400    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6401    /// tokens for more than one scope.
6402    ///
6403    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6404    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6405    /// sufficient, a read-write scope will do as well.
6406    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceCreateCall<'a, C>
6407    where
6408        St: AsRef<str>,
6409    {
6410        self._scopes.insert(String::from(scope.as_ref()));
6411        self
6412    }
6413    /// Identifies the authorization scope(s) for the method you are building.
6414    ///
6415    /// See [`Self::add_scope()`] for details.
6416    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceCreateCall<'a, C>
6417    where
6418        I: IntoIterator<Item = St>,
6419        St: AsRef<str>,
6420    {
6421        self._scopes
6422            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6423        self
6424    }
6425
6426    /// Removes all scopes, and no default scope will be used either.
6427    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6428    /// for details).
6429    pub fn clear_scopes(mut self) -> ProjectLocationInstanceCreateCall<'a, C> {
6430        self._scopes.clear();
6431        self
6432    }
6433}
6434
6435/// Deletes a single Instance.
6436///
6437/// A builder for the *locations.instances.delete* method supported by a *project* resource.
6438/// It is not used directly, but through a [`ProjectMethods`] instance.
6439///
6440/// # Example
6441///
6442/// Instantiate a resource method builder
6443///
6444/// ```test_harness,no_run
6445/// # extern crate hyper;
6446/// # extern crate hyper_rustls;
6447/// # extern crate google_notebooks1 as notebooks1;
6448/// # async fn dox() {
6449/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6450///
6451/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6452/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6453/// #     secret,
6454/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6455/// # ).build().await.unwrap();
6456///
6457/// # let client = hyper_util::client::legacy::Client::builder(
6458/// #     hyper_util::rt::TokioExecutor::new()
6459/// # )
6460/// # .build(
6461/// #     hyper_rustls::HttpsConnectorBuilder::new()
6462/// #         .with_native_roots()
6463/// #         .unwrap()
6464/// #         .https_or_http()
6465/// #         .enable_http1()
6466/// #         .build()
6467/// # );
6468/// # let mut hub = AIPlatformNotebooks::new(client, auth);
6469/// // You can configure optional parameters by calling the respective setters at will, and
6470/// // execute the final call using `doit()`.
6471/// // Values shown here are possibly random and not representative !
6472/// let result = hub.projects().locations_instances_delete("name")
6473///              .doit().await;
6474/// # }
6475/// ```
6476pub struct ProjectLocationInstanceDeleteCall<'a, C>
6477where
6478    C: 'a,
6479{
6480    hub: &'a AIPlatformNotebooks<C>,
6481    _name: String,
6482    _delegate: Option<&'a mut dyn common::Delegate>,
6483    _additional_params: HashMap<String, String>,
6484    _scopes: BTreeSet<String>,
6485}
6486
6487impl<'a, C> common::CallBuilder for ProjectLocationInstanceDeleteCall<'a, C> {}
6488
6489impl<'a, C> ProjectLocationInstanceDeleteCall<'a, C>
6490where
6491    C: common::Connector,
6492{
6493    /// Perform the operation you have build so far.
6494    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6495        use std::borrow::Cow;
6496        use std::io::{Read, Seek};
6497
6498        use common::{url::Params, ToParts};
6499        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6500
6501        let mut dd = common::DefaultDelegate;
6502        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6503        dlg.begin(common::MethodInfo {
6504            id: "notebooks.projects.locations.instances.delete",
6505            http_method: hyper::Method::DELETE,
6506        });
6507
6508        for &field in ["alt", "name"].iter() {
6509            if self._additional_params.contains_key(field) {
6510                dlg.finished(false);
6511                return Err(common::Error::FieldClash(field));
6512            }
6513        }
6514
6515        let mut params = Params::with_capacity(3 + self._additional_params.len());
6516        params.push("name", self._name);
6517
6518        params.extend(self._additional_params.iter());
6519
6520        params.push("alt", "json");
6521        let mut url = self.hub._base_url.clone() + "v1/{+name}";
6522        if self._scopes.is_empty() {
6523            self._scopes
6524                .insert(Scope::CloudPlatform.as_ref().to_string());
6525        }
6526
6527        #[allow(clippy::single_element_loop)]
6528        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6529            url = params.uri_replacement(url, param_name, find_this, true);
6530        }
6531        {
6532            let to_remove = ["name"];
6533            params.remove_params(&to_remove);
6534        }
6535
6536        let url = params.parse_with_url(&url);
6537
6538        loop {
6539            let token = match self
6540                .hub
6541                .auth
6542                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6543                .await
6544            {
6545                Ok(token) => token,
6546                Err(e) => match dlg.token(e) {
6547                    Ok(token) => token,
6548                    Err(e) => {
6549                        dlg.finished(false);
6550                        return Err(common::Error::MissingToken(e));
6551                    }
6552                },
6553            };
6554            let mut req_result = {
6555                let client = &self.hub.client;
6556                dlg.pre_request();
6557                let mut req_builder = hyper::Request::builder()
6558                    .method(hyper::Method::DELETE)
6559                    .uri(url.as_str())
6560                    .header(USER_AGENT, self.hub._user_agent.clone());
6561
6562                if let Some(token) = token.as_ref() {
6563                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6564                }
6565
6566                let request = req_builder
6567                    .header(CONTENT_LENGTH, 0_u64)
6568                    .body(common::to_body::<String>(None));
6569
6570                client.request(request.unwrap()).await
6571            };
6572
6573            match req_result {
6574                Err(err) => {
6575                    if let common::Retry::After(d) = dlg.http_error(&err) {
6576                        sleep(d).await;
6577                        continue;
6578                    }
6579                    dlg.finished(false);
6580                    return Err(common::Error::HttpError(err));
6581                }
6582                Ok(res) => {
6583                    let (mut parts, body) = res.into_parts();
6584                    let mut body = common::Body::new(body);
6585                    if !parts.status.is_success() {
6586                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6587                        let error = serde_json::from_str(&common::to_string(&bytes));
6588                        let response = common::to_response(parts, bytes.into());
6589
6590                        if let common::Retry::After(d) =
6591                            dlg.http_failure(&response, error.as_ref().ok())
6592                        {
6593                            sleep(d).await;
6594                            continue;
6595                        }
6596
6597                        dlg.finished(false);
6598
6599                        return Err(match error {
6600                            Ok(value) => common::Error::BadRequest(value),
6601                            _ => common::Error::Failure(response),
6602                        });
6603                    }
6604                    let response = {
6605                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6606                        let encoded = common::to_string(&bytes);
6607                        match serde_json::from_str(&encoded) {
6608                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6609                            Err(error) => {
6610                                dlg.response_json_decode_error(&encoded, &error);
6611                                return Err(common::Error::JsonDecodeError(
6612                                    encoded.to_string(),
6613                                    error,
6614                                ));
6615                            }
6616                        }
6617                    };
6618
6619                    dlg.finished(true);
6620                    return Ok(response);
6621                }
6622            }
6623        }
6624    }
6625
6626    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
6627    ///
6628    /// Sets the *name* path property to the given value.
6629    ///
6630    /// Even though the property as already been set when instantiating this call,
6631    /// we provide this method for API completeness.
6632    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceDeleteCall<'a, C> {
6633        self._name = new_value.to_string();
6634        self
6635    }
6636    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6637    /// while executing the actual API request.
6638    ///
6639    /// ````text
6640    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6641    /// ````
6642    ///
6643    /// Sets the *delegate* property to the given value.
6644    pub fn delegate(
6645        mut self,
6646        new_value: &'a mut dyn common::Delegate,
6647    ) -> ProjectLocationInstanceDeleteCall<'a, C> {
6648        self._delegate = Some(new_value);
6649        self
6650    }
6651
6652    /// Set any additional parameter of the query string used in the request.
6653    /// It should be used to set parameters which are not yet available through their own
6654    /// setters.
6655    ///
6656    /// Please note that this method must not be used to set any of the known parameters
6657    /// which have their own setter method. If done anyway, the request will fail.
6658    ///
6659    /// # Additional Parameters
6660    ///
6661    /// * *$.xgafv* (query-string) - V1 error format.
6662    /// * *access_token* (query-string) - OAuth access token.
6663    /// * *alt* (query-string) - Data format for response.
6664    /// * *callback* (query-string) - JSONP
6665    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6666    /// * *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.
6667    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6668    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6669    /// * *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.
6670    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6671    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6672    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceDeleteCall<'a, C>
6673    where
6674        T: AsRef<str>,
6675    {
6676        self._additional_params
6677            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6678        self
6679    }
6680
6681    /// Identifies the authorization scope for the method you are building.
6682    ///
6683    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6684    /// [`Scope::CloudPlatform`].
6685    ///
6686    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6687    /// tokens for more than one scope.
6688    ///
6689    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6690    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6691    /// sufficient, a read-write scope will do as well.
6692    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceDeleteCall<'a, C>
6693    where
6694        St: AsRef<str>,
6695    {
6696        self._scopes.insert(String::from(scope.as_ref()));
6697        self
6698    }
6699    /// Identifies the authorization scope(s) for the method you are building.
6700    ///
6701    /// See [`Self::add_scope()`] for details.
6702    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceDeleteCall<'a, C>
6703    where
6704        I: IntoIterator<Item = St>,
6705        St: AsRef<str>,
6706    {
6707        self._scopes
6708            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6709        self
6710    }
6711
6712    /// Removes all scopes, and no default scope will be used either.
6713    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6714    /// for details).
6715    pub fn clear_scopes(mut self) -> ProjectLocationInstanceDeleteCall<'a, C> {
6716        self._scopes.clear();
6717        self
6718    }
6719}
6720
6721/// Creates a Diagnostic File and runs Diagnostic Tool given an Instance.
6722///
6723/// A builder for the *locations.instances.diagnose* method supported by a *project* resource.
6724/// It is not used directly, but through a [`ProjectMethods`] instance.
6725///
6726/// # Example
6727///
6728/// Instantiate a resource method builder
6729///
6730/// ```test_harness,no_run
6731/// # extern crate hyper;
6732/// # extern crate hyper_rustls;
6733/// # extern crate google_notebooks1 as notebooks1;
6734/// use notebooks1::api::DiagnoseInstanceRequest;
6735/// # async fn dox() {
6736/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6737///
6738/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6739/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6740/// #     secret,
6741/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6742/// # ).build().await.unwrap();
6743///
6744/// # let client = hyper_util::client::legacy::Client::builder(
6745/// #     hyper_util::rt::TokioExecutor::new()
6746/// # )
6747/// # .build(
6748/// #     hyper_rustls::HttpsConnectorBuilder::new()
6749/// #         .with_native_roots()
6750/// #         .unwrap()
6751/// #         .https_or_http()
6752/// #         .enable_http1()
6753/// #         .build()
6754/// # );
6755/// # let mut hub = AIPlatformNotebooks::new(client, auth);
6756/// // As the method needs a request, you would usually fill it with the desired information
6757/// // into the respective structure. Some of the parts shown here might not be applicable !
6758/// // Values shown here are possibly random and not representative !
6759/// let mut req = DiagnoseInstanceRequest::default();
6760///
6761/// // You can configure optional parameters by calling the respective setters at will, and
6762/// // execute the final call using `doit()`.
6763/// // Values shown here are possibly random and not representative !
6764/// let result = hub.projects().locations_instances_diagnose(req, "name")
6765///              .doit().await;
6766/// # }
6767/// ```
6768pub struct ProjectLocationInstanceDiagnoseCall<'a, C>
6769where
6770    C: 'a,
6771{
6772    hub: &'a AIPlatformNotebooks<C>,
6773    _request: DiagnoseInstanceRequest,
6774    _name: String,
6775    _delegate: Option<&'a mut dyn common::Delegate>,
6776    _additional_params: HashMap<String, String>,
6777    _scopes: BTreeSet<String>,
6778}
6779
6780impl<'a, C> common::CallBuilder for ProjectLocationInstanceDiagnoseCall<'a, C> {}
6781
6782impl<'a, C> ProjectLocationInstanceDiagnoseCall<'a, C>
6783where
6784    C: common::Connector,
6785{
6786    /// Perform the operation you have build so far.
6787    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6788        use std::borrow::Cow;
6789        use std::io::{Read, Seek};
6790
6791        use common::{url::Params, ToParts};
6792        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6793
6794        let mut dd = common::DefaultDelegate;
6795        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6796        dlg.begin(common::MethodInfo {
6797            id: "notebooks.projects.locations.instances.diagnose",
6798            http_method: hyper::Method::POST,
6799        });
6800
6801        for &field in ["alt", "name"].iter() {
6802            if self._additional_params.contains_key(field) {
6803                dlg.finished(false);
6804                return Err(common::Error::FieldClash(field));
6805            }
6806        }
6807
6808        let mut params = Params::with_capacity(4 + self._additional_params.len());
6809        params.push("name", self._name);
6810
6811        params.extend(self._additional_params.iter());
6812
6813        params.push("alt", "json");
6814        let mut url = self.hub._base_url.clone() + "v1/{+name}:diagnose";
6815        if self._scopes.is_empty() {
6816            self._scopes
6817                .insert(Scope::CloudPlatform.as_ref().to_string());
6818        }
6819
6820        #[allow(clippy::single_element_loop)]
6821        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6822            url = params.uri_replacement(url, param_name, find_this, true);
6823        }
6824        {
6825            let to_remove = ["name"];
6826            params.remove_params(&to_remove);
6827        }
6828
6829        let url = params.parse_with_url(&url);
6830
6831        let mut json_mime_type = mime::APPLICATION_JSON;
6832        let mut request_value_reader = {
6833            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6834            common::remove_json_null_values(&mut value);
6835            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6836            serde_json::to_writer(&mut dst, &value).unwrap();
6837            dst
6838        };
6839        let request_size = request_value_reader
6840            .seek(std::io::SeekFrom::End(0))
6841            .unwrap();
6842        request_value_reader
6843            .seek(std::io::SeekFrom::Start(0))
6844            .unwrap();
6845
6846        loop {
6847            let token = match self
6848                .hub
6849                .auth
6850                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6851                .await
6852            {
6853                Ok(token) => token,
6854                Err(e) => match dlg.token(e) {
6855                    Ok(token) => token,
6856                    Err(e) => {
6857                        dlg.finished(false);
6858                        return Err(common::Error::MissingToken(e));
6859                    }
6860                },
6861            };
6862            request_value_reader
6863                .seek(std::io::SeekFrom::Start(0))
6864                .unwrap();
6865            let mut req_result = {
6866                let client = &self.hub.client;
6867                dlg.pre_request();
6868                let mut req_builder = hyper::Request::builder()
6869                    .method(hyper::Method::POST)
6870                    .uri(url.as_str())
6871                    .header(USER_AGENT, self.hub._user_agent.clone());
6872
6873                if let Some(token) = token.as_ref() {
6874                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6875                }
6876
6877                let request = req_builder
6878                    .header(CONTENT_TYPE, json_mime_type.to_string())
6879                    .header(CONTENT_LENGTH, request_size as u64)
6880                    .body(common::to_body(
6881                        request_value_reader.get_ref().clone().into(),
6882                    ));
6883
6884                client.request(request.unwrap()).await
6885            };
6886
6887            match req_result {
6888                Err(err) => {
6889                    if let common::Retry::After(d) = dlg.http_error(&err) {
6890                        sleep(d).await;
6891                        continue;
6892                    }
6893                    dlg.finished(false);
6894                    return Err(common::Error::HttpError(err));
6895                }
6896                Ok(res) => {
6897                    let (mut parts, body) = res.into_parts();
6898                    let mut body = common::Body::new(body);
6899                    if !parts.status.is_success() {
6900                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6901                        let error = serde_json::from_str(&common::to_string(&bytes));
6902                        let response = common::to_response(parts, bytes.into());
6903
6904                        if let common::Retry::After(d) =
6905                            dlg.http_failure(&response, error.as_ref().ok())
6906                        {
6907                            sleep(d).await;
6908                            continue;
6909                        }
6910
6911                        dlg.finished(false);
6912
6913                        return Err(match error {
6914                            Ok(value) => common::Error::BadRequest(value),
6915                            _ => common::Error::Failure(response),
6916                        });
6917                    }
6918                    let response = {
6919                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6920                        let encoded = common::to_string(&bytes);
6921                        match serde_json::from_str(&encoded) {
6922                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6923                            Err(error) => {
6924                                dlg.response_json_decode_error(&encoded, &error);
6925                                return Err(common::Error::JsonDecodeError(
6926                                    encoded.to_string(),
6927                                    error,
6928                                ));
6929                            }
6930                        }
6931                    };
6932
6933                    dlg.finished(true);
6934                    return Ok(response);
6935                }
6936            }
6937        }
6938    }
6939
6940    ///
6941    /// Sets the *request* property to the given value.
6942    ///
6943    /// Even though the property as already been set when instantiating this call,
6944    /// we provide this method for API completeness.
6945    pub fn request(
6946        mut self,
6947        new_value: DiagnoseInstanceRequest,
6948    ) -> ProjectLocationInstanceDiagnoseCall<'a, C> {
6949        self._request = new_value;
6950        self
6951    }
6952    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
6953    ///
6954    /// Sets the *name* path property to the given value.
6955    ///
6956    /// Even though the property as already been set when instantiating this call,
6957    /// we provide this method for API completeness.
6958    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceDiagnoseCall<'a, C> {
6959        self._name = new_value.to_string();
6960        self
6961    }
6962    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6963    /// while executing the actual API request.
6964    ///
6965    /// ````text
6966    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6967    /// ````
6968    ///
6969    /// Sets the *delegate* property to the given value.
6970    pub fn delegate(
6971        mut self,
6972        new_value: &'a mut dyn common::Delegate,
6973    ) -> ProjectLocationInstanceDiagnoseCall<'a, C> {
6974        self._delegate = Some(new_value);
6975        self
6976    }
6977
6978    /// Set any additional parameter of the query string used in the request.
6979    /// It should be used to set parameters which are not yet available through their own
6980    /// setters.
6981    ///
6982    /// Please note that this method must not be used to set any of the known parameters
6983    /// which have their own setter method. If done anyway, the request will fail.
6984    ///
6985    /// # Additional Parameters
6986    ///
6987    /// * *$.xgafv* (query-string) - V1 error format.
6988    /// * *access_token* (query-string) - OAuth access token.
6989    /// * *alt* (query-string) - Data format for response.
6990    /// * *callback* (query-string) - JSONP
6991    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6992    /// * *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.
6993    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6994    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6995    /// * *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.
6996    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6997    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6998    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceDiagnoseCall<'a, C>
6999    where
7000        T: AsRef<str>,
7001    {
7002        self._additional_params
7003            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7004        self
7005    }
7006
7007    /// Identifies the authorization scope for the method you are building.
7008    ///
7009    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7010    /// [`Scope::CloudPlatform`].
7011    ///
7012    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7013    /// tokens for more than one scope.
7014    ///
7015    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7016    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7017    /// sufficient, a read-write scope will do as well.
7018    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceDiagnoseCall<'a, C>
7019    where
7020        St: AsRef<str>,
7021    {
7022        self._scopes.insert(String::from(scope.as_ref()));
7023        self
7024    }
7025    /// Identifies the authorization scope(s) for the method you are building.
7026    ///
7027    /// See [`Self::add_scope()`] for details.
7028    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceDiagnoseCall<'a, C>
7029    where
7030        I: IntoIterator<Item = St>,
7031        St: AsRef<str>,
7032    {
7033        self._scopes
7034            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7035        self
7036    }
7037
7038    /// Removes all scopes, and no default scope will be used either.
7039    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7040    /// for details).
7041    pub fn clear_scopes(mut self) -> ProjectLocationInstanceDiagnoseCall<'a, C> {
7042        self._scopes.clear();
7043        self
7044    }
7045}
7046
7047/// Gets details of a single Instance.
7048///
7049/// A builder for the *locations.instances.get* method supported by a *project* resource.
7050/// It is not used directly, but through a [`ProjectMethods`] instance.
7051///
7052/// # Example
7053///
7054/// Instantiate a resource method builder
7055///
7056/// ```test_harness,no_run
7057/// # extern crate hyper;
7058/// # extern crate hyper_rustls;
7059/// # extern crate google_notebooks1 as notebooks1;
7060/// # async fn dox() {
7061/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7062///
7063/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7064/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7065/// #     secret,
7066/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7067/// # ).build().await.unwrap();
7068///
7069/// # let client = hyper_util::client::legacy::Client::builder(
7070/// #     hyper_util::rt::TokioExecutor::new()
7071/// # )
7072/// # .build(
7073/// #     hyper_rustls::HttpsConnectorBuilder::new()
7074/// #         .with_native_roots()
7075/// #         .unwrap()
7076/// #         .https_or_http()
7077/// #         .enable_http1()
7078/// #         .build()
7079/// # );
7080/// # let mut hub = AIPlatformNotebooks::new(client, auth);
7081/// // You can configure optional parameters by calling the respective setters at will, and
7082/// // execute the final call using `doit()`.
7083/// // Values shown here are possibly random and not representative !
7084/// let result = hub.projects().locations_instances_get("name")
7085///              .doit().await;
7086/// # }
7087/// ```
7088pub struct ProjectLocationInstanceGetCall<'a, C>
7089where
7090    C: 'a,
7091{
7092    hub: &'a AIPlatformNotebooks<C>,
7093    _name: String,
7094    _delegate: Option<&'a mut dyn common::Delegate>,
7095    _additional_params: HashMap<String, String>,
7096    _scopes: BTreeSet<String>,
7097}
7098
7099impl<'a, C> common::CallBuilder for ProjectLocationInstanceGetCall<'a, C> {}
7100
7101impl<'a, C> ProjectLocationInstanceGetCall<'a, C>
7102where
7103    C: common::Connector,
7104{
7105    /// Perform the operation you have build so far.
7106    pub async fn doit(mut self) -> common::Result<(common::Response, Instance)> {
7107        use std::borrow::Cow;
7108        use std::io::{Read, Seek};
7109
7110        use common::{url::Params, ToParts};
7111        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7112
7113        let mut dd = common::DefaultDelegate;
7114        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7115        dlg.begin(common::MethodInfo {
7116            id: "notebooks.projects.locations.instances.get",
7117            http_method: hyper::Method::GET,
7118        });
7119
7120        for &field in ["alt", "name"].iter() {
7121            if self._additional_params.contains_key(field) {
7122                dlg.finished(false);
7123                return Err(common::Error::FieldClash(field));
7124            }
7125        }
7126
7127        let mut params = Params::with_capacity(3 + self._additional_params.len());
7128        params.push("name", self._name);
7129
7130        params.extend(self._additional_params.iter());
7131
7132        params.push("alt", "json");
7133        let mut url = self.hub._base_url.clone() + "v1/{+name}";
7134        if self._scopes.is_empty() {
7135            self._scopes
7136                .insert(Scope::CloudPlatform.as_ref().to_string());
7137        }
7138
7139        #[allow(clippy::single_element_loop)]
7140        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7141            url = params.uri_replacement(url, param_name, find_this, true);
7142        }
7143        {
7144            let to_remove = ["name"];
7145            params.remove_params(&to_remove);
7146        }
7147
7148        let url = params.parse_with_url(&url);
7149
7150        loop {
7151            let token = match self
7152                .hub
7153                .auth
7154                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7155                .await
7156            {
7157                Ok(token) => token,
7158                Err(e) => match dlg.token(e) {
7159                    Ok(token) => token,
7160                    Err(e) => {
7161                        dlg.finished(false);
7162                        return Err(common::Error::MissingToken(e));
7163                    }
7164                },
7165            };
7166            let mut req_result = {
7167                let client = &self.hub.client;
7168                dlg.pre_request();
7169                let mut req_builder = hyper::Request::builder()
7170                    .method(hyper::Method::GET)
7171                    .uri(url.as_str())
7172                    .header(USER_AGENT, self.hub._user_agent.clone());
7173
7174                if let Some(token) = token.as_ref() {
7175                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7176                }
7177
7178                let request = req_builder
7179                    .header(CONTENT_LENGTH, 0_u64)
7180                    .body(common::to_body::<String>(None));
7181
7182                client.request(request.unwrap()).await
7183            };
7184
7185            match req_result {
7186                Err(err) => {
7187                    if let common::Retry::After(d) = dlg.http_error(&err) {
7188                        sleep(d).await;
7189                        continue;
7190                    }
7191                    dlg.finished(false);
7192                    return Err(common::Error::HttpError(err));
7193                }
7194                Ok(res) => {
7195                    let (mut parts, body) = res.into_parts();
7196                    let mut body = common::Body::new(body);
7197                    if !parts.status.is_success() {
7198                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7199                        let error = serde_json::from_str(&common::to_string(&bytes));
7200                        let response = common::to_response(parts, bytes.into());
7201
7202                        if let common::Retry::After(d) =
7203                            dlg.http_failure(&response, error.as_ref().ok())
7204                        {
7205                            sleep(d).await;
7206                            continue;
7207                        }
7208
7209                        dlg.finished(false);
7210
7211                        return Err(match error {
7212                            Ok(value) => common::Error::BadRequest(value),
7213                            _ => common::Error::Failure(response),
7214                        });
7215                    }
7216                    let response = {
7217                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7218                        let encoded = common::to_string(&bytes);
7219                        match serde_json::from_str(&encoded) {
7220                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7221                            Err(error) => {
7222                                dlg.response_json_decode_error(&encoded, &error);
7223                                return Err(common::Error::JsonDecodeError(
7224                                    encoded.to_string(),
7225                                    error,
7226                                ));
7227                            }
7228                        }
7229                    };
7230
7231                    dlg.finished(true);
7232                    return Ok(response);
7233                }
7234            }
7235        }
7236    }
7237
7238    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
7239    ///
7240    /// Sets the *name* path property to the given value.
7241    ///
7242    /// Even though the property as already been set when instantiating this call,
7243    /// we provide this method for API completeness.
7244    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceGetCall<'a, C> {
7245        self._name = new_value.to_string();
7246        self
7247    }
7248    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7249    /// while executing the actual API request.
7250    ///
7251    /// ````text
7252    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7253    /// ````
7254    ///
7255    /// Sets the *delegate* property to the given value.
7256    pub fn delegate(
7257        mut self,
7258        new_value: &'a mut dyn common::Delegate,
7259    ) -> ProjectLocationInstanceGetCall<'a, C> {
7260        self._delegate = Some(new_value);
7261        self
7262    }
7263
7264    /// Set any additional parameter of the query string used in the request.
7265    /// It should be used to set parameters which are not yet available through their own
7266    /// setters.
7267    ///
7268    /// Please note that this method must not be used to set any of the known parameters
7269    /// which have their own setter method. If done anyway, the request will fail.
7270    ///
7271    /// # Additional Parameters
7272    ///
7273    /// * *$.xgafv* (query-string) - V1 error format.
7274    /// * *access_token* (query-string) - OAuth access token.
7275    /// * *alt* (query-string) - Data format for response.
7276    /// * *callback* (query-string) - JSONP
7277    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7278    /// * *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.
7279    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7280    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7281    /// * *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.
7282    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7283    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7284    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceGetCall<'a, C>
7285    where
7286        T: AsRef<str>,
7287    {
7288        self._additional_params
7289            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7290        self
7291    }
7292
7293    /// Identifies the authorization scope for the method you are building.
7294    ///
7295    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7296    /// [`Scope::CloudPlatform`].
7297    ///
7298    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7299    /// tokens for more than one scope.
7300    ///
7301    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7302    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7303    /// sufficient, a read-write scope will do as well.
7304    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceGetCall<'a, C>
7305    where
7306        St: AsRef<str>,
7307    {
7308        self._scopes.insert(String::from(scope.as_ref()));
7309        self
7310    }
7311    /// Identifies the authorization scope(s) for the method you are building.
7312    ///
7313    /// See [`Self::add_scope()`] for details.
7314    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceGetCall<'a, C>
7315    where
7316        I: IntoIterator<Item = St>,
7317        St: AsRef<str>,
7318    {
7319        self._scopes
7320            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7321        self
7322    }
7323
7324    /// Removes all scopes, and no default scope will be used either.
7325    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7326    /// for details).
7327    pub fn clear_scopes(mut self) -> ProjectLocationInstanceGetCall<'a, C> {
7328        self._scopes.clear();
7329        self
7330    }
7331}
7332
7333/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
7334///
7335/// A builder for the *locations.instances.getIamPolicy* method supported by a *project* resource.
7336/// It is not used directly, but through a [`ProjectMethods`] instance.
7337///
7338/// # Example
7339///
7340/// Instantiate a resource method builder
7341///
7342/// ```test_harness,no_run
7343/// # extern crate hyper;
7344/// # extern crate hyper_rustls;
7345/// # extern crate google_notebooks1 as notebooks1;
7346/// # async fn dox() {
7347/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7348///
7349/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7350/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7351/// #     secret,
7352/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7353/// # ).build().await.unwrap();
7354///
7355/// # let client = hyper_util::client::legacy::Client::builder(
7356/// #     hyper_util::rt::TokioExecutor::new()
7357/// # )
7358/// # .build(
7359/// #     hyper_rustls::HttpsConnectorBuilder::new()
7360/// #         .with_native_roots()
7361/// #         .unwrap()
7362/// #         .https_or_http()
7363/// #         .enable_http1()
7364/// #         .build()
7365/// # );
7366/// # let mut hub = AIPlatformNotebooks::new(client, auth);
7367/// // You can configure optional parameters by calling the respective setters at will, and
7368/// // execute the final call using `doit()`.
7369/// // Values shown here are possibly random and not representative !
7370/// let result = hub.projects().locations_instances_get_iam_policy("resource")
7371///              .options_requested_policy_version(-7)
7372///              .doit().await;
7373/// # }
7374/// ```
7375pub struct ProjectLocationInstanceGetIamPolicyCall<'a, C>
7376where
7377    C: 'a,
7378{
7379    hub: &'a AIPlatformNotebooks<C>,
7380    _resource: String,
7381    _options_requested_policy_version: Option<i32>,
7382    _delegate: Option<&'a mut dyn common::Delegate>,
7383    _additional_params: HashMap<String, String>,
7384    _scopes: BTreeSet<String>,
7385}
7386
7387impl<'a, C> common::CallBuilder for ProjectLocationInstanceGetIamPolicyCall<'a, C> {}
7388
7389impl<'a, C> ProjectLocationInstanceGetIamPolicyCall<'a, C>
7390where
7391    C: common::Connector,
7392{
7393    /// Perform the operation you have build so far.
7394    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
7395        use std::borrow::Cow;
7396        use std::io::{Read, Seek};
7397
7398        use common::{url::Params, ToParts};
7399        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7400
7401        let mut dd = common::DefaultDelegate;
7402        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7403        dlg.begin(common::MethodInfo {
7404            id: "notebooks.projects.locations.instances.getIamPolicy",
7405            http_method: hyper::Method::GET,
7406        });
7407
7408        for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
7409            if self._additional_params.contains_key(field) {
7410                dlg.finished(false);
7411                return Err(common::Error::FieldClash(field));
7412            }
7413        }
7414
7415        let mut params = Params::with_capacity(4 + self._additional_params.len());
7416        params.push("resource", self._resource);
7417        if let Some(value) = self._options_requested_policy_version.as_ref() {
7418            params.push("options.requestedPolicyVersion", value.to_string());
7419        }
7420
7421        params.extend(self._additional_params.iter());
7422
7423        params.push("alt", "json");
7424        let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
7425        if self._scopes.is_empty() {
7426            self._scopes
7427                .insert(Scope::CloudPlatform.as_ref().to_string());
7428        }
7429
7430        #[allow(clippy::single_element_loop)]
7431        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
7432            url = params.uri_replacement(url, param_name, find_this, true);
7433        }
7434        {
7435            let to_remove = ["resource"];
7436            params.remove_params(&to_remove);
7437        }
7438
7439        let url = params.parse_with_url(&url);
7440
7441        loop {
7442            let token = match self
7443                .hub
7444                .auth
7445                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7446                .await
7447            {
7448                Ok(token) => token,
7449                Err(e) => match dlg.token(e) {
7450                    Ok(token) => token,
7451                    Err(e) => {
7452                        dlg.finished(false);
7453                        return Err(common::Error::MissingToken(e));
7454                    }
7455                },
7456            };
7457            let mut req_result = {
7458                let client = &self.hub.client;
7459                dlg.pre_request();
7460                let mut req_builder = hyper::Request::builder()
7461                    .method(hyper::Method::GET)
7462                    .uri(url.as_str())
7463                    .header(USER_AGENT, self.hub._user_agent.clone());
7464
7465                if let Some(token) = token.as_ref() {
7466                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7467                }
7468
7469                let request = req_builder
7470                    .header(CONTENT_LENGTH, 0_u64)
7471                    .body(common::to_body::<String>(None));
7472
7473                client.request(request.unwrap()).await
7474            };
7475
7476            match req_result {
7477                Err(err) => {
7478                    if let common::Retry::After(d) = dlg.http_error(&err) {
7479                        sleep(d).await;
7480                        continue;
7481                    }
7482                    dlg.finished(false);
7483                    return Err(common::Error::HttpError(err));
7484                }
7485                Ok(res) => {
7486                    let (mut parts, body) = res.into_parts();
7487                    let mut body = common::Body::new(body);
7488                    if !parts.status.is_success() {
7489                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7490                        let error = serde_json::from_str(&common::to_string(&bytes));
7491                        let response = common::to_response(parts, bytes.into());
7492
7493                        if let common::Retry::After(d) =
7494                            dlg.http_failure(&response, error.as_ref().ok())
7495                        {
7496                            sleep(d).await;
7497                            continue;
7498                        }
7499
7500                        dlg.finished(false);
7501
7502                        return Err(match error {
7503                            Ok(value) => common::Error::BadRequest(value),
7504                            _ => common::Error::Failure(response),
7505                        });
7506                    }
7507                    let response = {
7508                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7509                        let encoded = common::to_string(&bytes);
7510                        match serde_json::from_str(&encoded) {
7511                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7512                            Err(error) => {
7513                                dlg.response_json_decode_error(&encoded, &error);
7514                                return Err(common::Error::JsonDecodeError(
7515                                    encoded.to_string(),
7516                                    error,
7517                                ));
7518                            }
7519                        }
7520                    };
7521
7522                    dlg.finished(true);
7523                    return Ok(response);
7524                }
7525            }
7526        }
7527    }
7528
7529    /// 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.
7530    ///
7531    /// Sets the *resource* path property to the given value.
7532    ///
7533    /// Even though the property as already been set when instantiating this call,
7534    /// we provide this method for API completeness.
7535    pub fn resource(mut self, new_value: &str) -> ProjectLocationInstanceGetIamPolicyCall<'a, C> {
7536        self._resource = new_value.to_string();
7537        self
7538    }
7539    /// 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).
7540    ///
7541    /// Sets the *options.requested policy version* query property to the given value.
7542    pub fn options_requested_policy_version(
7543        mut self,
7544        new_value: i32,
7545    ) -> ProjectLocationInstanceGetIamPolicyCall<'a, C> {
7546        self._options_requested_policy_version = Some(new_value);
7547        self
7548    }
7549    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7550    /// while executing the actual API request.
7551    ///
7552    /// ````text
7553    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7554    /// ````
7555    ///
7556    /// Sets the *delegate* property to the given value.
7557    pub fn delegate(
7558        mut self,
7559        new_value: &'a mut dyn common::Delegate,
7560    ) -> ProjectLocationInstanceGetIamPolicyCall<'a, C> {
7561        self._delegate = Some(new_value);
7562        self
7563    }
7564
7565    /// Set any additional parameter of the query string used in the request.
7566    /// It should be used to set parameters which are not yet available through their own
7567    /// setters.
7568    ///
7569    /// Please note that this method must not be used to set any of the known parameters
7570    /// which have their own setter method. If done anyway, the request will fail.
7571    ///
7572    /// # Additional Parameters
7573    ///
7574    /// * *$.xgafv* (query-string) - V1 error format.
7575    /// * *access_token* (query-string) - OAuth access token.
7576    /// * *alt* (query-string) - Data format for response.
7577    /// * *callback* (query-string) - JSONP
7578    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7579    /// * *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.
7580    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7581    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7582    /// * *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.
7583    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7584    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7585    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceGetIamPolicyCall<'a, C>
7586    where
7587        T: AsRef<str>,
7588    {
7589        self._additional_params
7590            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7591        self
7592    }
7593
7594    /// Identifies the authorization scope for the method you are building.
7595    ///
7596    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7597    /// [`Scope::CloudPlatform`].
7598    ///
7599    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7600    /// tokens for more than one scope.
7601    ///
7602    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7603    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7604    /// sufficient, a read-write scope will do as well.
7605    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceGetIamPolicyCall<'a, C>
7606    where
7607        St: AsRef<str>,
7608    {
7609        self._scopes.insert(String::from(scope.as_ref()));
7610        self
7611    }
7612    /// Identifies the authorization scope(s) for the method you are building.
7613    ///
7614    /// See [`Self::add_scope()`] for details.
7615    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceGetIamPolicyCall<'a, C>
7616    where
7617        I: IntoIterator<Item = St>,
7618        St: AsRef<str>,
7619    {
7620        self._scopes
7621            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7622        self
7623    }
7624
7625    /// Removes all scopes, and no default scope will be used either.
7626    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7627    /// for details).
7628    pub fn clear_scopes(mut self) -> ProjectLocationInstanceGetIamPolicyCall<'a, C> {
7629        self._scopes.clear();
7630        self
7631    }
7632}
7633
7634/// Checks whether a notebook instance is healthy.
7635///
7636/// A builder for the *locations.instances.getInstanceHealth* method supported by a *project* resource.
7637/// It is not used directly, but through a [`ProjectMethods`] instance.
7638///
7639/// # Example
7640///
7641/// Instantiate a resource method builder
7642///
7643/// ```test_harness,no_run
7644/// # extern crate hyper;
7645/// # extern crate hyper_rustls;
7646/// # extern crate google_notebooks1 as notebooks1;
7647/// # async fn dox() {
7648/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7649///
7650/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7651/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7652/// #     secret,
7653/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7654/// # ).build().await.unwrap();
7655///
7656/// # let client = hyper_util::client::legacy::Client::builder(
7657/// #     hyper_util::rt::TokioExecutor::new()
7658/// # )
7659/// # .build(
7660/// #     hyper_rustls::HttpsConnectorBuilder::new()
7661/// #         .with_native_roots()
7662/// #         .unwrap()
7663/// #         .https_or_http()
7664/// #         .enable_http1()
7665/// #         .build()
7666/// # );
7667/// # let mut hub = AIPlatformNotebooks::new(client, auth);
7668/// // You can configure optional parameters by calling the respective setters at will, and
7669/// // execute the final call using `doit()`.
7670/// // Values shown here are possibly random and not representative !
7671/// let result = hub.projects().locations_instances_get_instance_health("name")
7672///              .doit().await;
7673/// # }
7674/// ```
7675pub struct ProjectLocationInstanceGetInstanceHealthCall<'a, C>
7676where
7677    C: 'a,
7678{
7679    hub: &'a AIPlatformNotebooks<C>,
7680    _name: String,
7681    _delegate: Option<&'a mut dyn common::Delegate>,
7682    _additional_params: HashMap<String, String>,
7683    _scopes: BTreeSet<String>,
7684}
7685
7686impl<'a, C> common::CallBuilder for ProjectLocationInstanceGetInstanceHealthCall<'a, C> {}
7687
7688impl<'a, C> ProjectLocationInstanceGetInstanceHealthCall<'a, C>
7689where
7690    C: common::Connector,
7691{
7692    /// Perform the operation you have build so far.
7693    pub async fn doit(mut self) -> common::Result<(common::Response, GetInstanceHealthResponse)> {
7694        use std::borrow::Cow;
7695        use std::io::{Read, Seek};
7696
7697        use common::{url::Params, ToParts};
7698        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7699
7700        let mut dd = common::DefaultDelegate;
7701        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7702        dlg.begin(common::MethodInfo {
7703            id: "notebooks.projects.locations.instances.getInstanceHealth",
7704            http_method: hyper::Method::GET,
7705        });
7706
7707        for &field in ["alt", "name"].iter() {
7708            if self._additional_params.contains_key(field) {
7709                dlg.finished(false);
7710                return Err(common::Error::FieldClash(field));
7711            }
7712        }
7713
7714        let mut params = Params::with_capacity(3 + self._additional_params.len());
7715        params.push("name", self._name);
7716
7717        params.extend(self._additional_params.iter());
7718
7719        params.push("alt", "json");
7720        let mut url = self.hub._base_url.clone() + "v1/{+name}:getInstanceHealth";
7721        if self._scopes.is_empty() {
7722            self._scopes
7723                .insert(Scope::CloudPlatform.as_ref().to_string());
7724        }
7725
7726        #[allow(clippy::single_element_loop)]
7727        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7728            url = params.uri_replacement(url, param_name, find_this, true);
7729        }
7730        {
7731            let to_remove = ["name"];
7732            params.remove_params(&to_remove);
7733        }
7734
7735        let url = params.parse_with_url(&url);
7736
7737        loop {
7738            let token = match self
7739                .hub
7740                .auth
7741                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7742                .await
7743            {
7744                Ok(token) => token,
7745                Err(e) => match dlg.token(e) {
7746                    Ok(token) => token,
7747                    Err(e) => {
7748                        dlg.finished(false);
7749                        return Err(common::Error::MissingToken(e));
7750                    }
7751                },
7752            };
7753            let mut req_result = {
7754                let client = &self.hub.client;
7755                dlg.pre_request();
7756                let mut req_builder = hyper::Request::builder()
7757                    .method(hyper::Method::GET)
7758                    .uri(url.as_str())
7759                    .header(USER_AGENT, self.hub._user_agent.clone());
7760
7761                if let Some(token) = token.as_ref() {
7762                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7763                }
7764
7765                let request = req_builder
7766                    .header(CONTENT_LENGTH, 0_u64)
7767                    .body(common::to_body::<String>(None));
7768
7769                client.request(request.unwrap()).await
7770            };
7771
7772            match req_result {
7773                Err(err) => {
7774                    if let common::Retry::After(d) = dlg.http_error(&err) {
7775                        sleep(d).await;
7776                        continue;
7777                    }
7778                    dlg.finished(false);
7779                    return Err(common::Error::HttpError(err));
7780                }
7781                Ok(res) => {
7782                    let (mut parts, body) = res.into_parts();
7783                    let mut body = common::Body::new(body);
7784                    if !parts.status.is_success() {
7785                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7786                        let error = serde_json::from_str(&common::to_string(&bytes));
7787                        let response = common::to_response(parts, bytes.into());
7788
7789                        if let common::Retry::After(d) =
7790                            dlg.http_failure(&response, error.as_ref().ok())
7791                        {
7792                            sleep(d).await;
7793                            continue;
7794                        }
7795
7796                        dlg.finished(false);
7797
7798                        return Err(match error {
7799                            Ok(value) => common::Error::BadRequest(value),
7800                            _ => common::Error::Failure(response),
7801                        });
7802                    }
7803                    let response = {
7804                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7805                        let encoded = common::to_string(&bytes);
7806                        match serde_json::from_str(&encoded) {
7807                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7808                            Err(error) => {
7809                                dlg.response_json_decode_error(&encoded, &error);
7810                                return Err(common::Error::JsonDecodeError(
7811                                    encoded.to_string(),
7812                                    error,
7813                                ));
7814                            }
7815                        }
7816                    };
7817
7818                    dlg.finished(true);
7819                    return Ok(response);
7820                }
7821            }
7822        }
7823    }
7824
7825    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
7826    ///
7827    /// Sets the *name* path property to the given value.
7828    ///
7829    /// Even though the property as already been set when instantiating this call,
7830    /// we provide this method for API completeness.
7831    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceGetInstanceHealthCall<'a, C> {
7832        self._name = new_value.to_string();
7833        self
7834    }
7835    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7836    /// while executing the actual API request.
7837    ///
7838    /// ````text
7839    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7840    /// ````
7841    ///
7842    /// Sets the *delegate* property to the given value.
7843    pub fn delegate(
7844        mut self,
7845        new_value: &'a mut dyn common::Delegate,
7846    ) -> ProjectLocationInstanceGetInstanceHealthCall<'a, C> {
7847        self._delegate = Some(new_value);
7848        self
7849    }
7850
7851    /// Set any additional parameter of the query string used in the request.
7852    /// It should be used to set parameters which are not yet available through their own
7853    /// setters.
7854    ///
7855    /// Please note that this method must not be used to set any of the known parameters
7856    /// which have their own setter method. If done anyway, the request will fail.
7857    ///
7858    /// # Additional Parameters
7859    ///
7860    /// * *$.xgafv* (query-string) - V1 error format.
7861    /// * *access_token* (query-string) - OAuth access token.
7862    /// * *alt* (query-string) - Data format for response.
7863    /// * *callback* (query-string) - JSONP
7864    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7865    /// * *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.
7866    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7867    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7868    /// * *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.
7869    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7870    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7871    pub fn param<T>(
7872        mut self,
7873        name: T,
7874        value: T,
7875    ) -> ProjectLocationInstanceGetInstanceHealthCall<'a, C>
7876    where
7877        T: AsRef<str>,
7878    {
7879        self._additional_params
7880            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7881        self
7882    }
7883
7884    /// Identifies the authorization scope for the method you are building.
7885    ///
7886    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7887    /// [`Scope::CloudPlatform`].
7888    ///
7889    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7890    /// tokens for more than one scope.
7891    ///
7892    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7893    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7894    /// sufficient, a read-write scope will do as well.
7895    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceGetInstanceHealthCall<'a, C>
7896    where
7897        St: AsRef<str>,
7898    {
7899        self._scopes.insert(String::from(scope.as_ref()));
7900        self
7901    }
7902    /// Identifies the authorization scope(s) for the method you are building.
7903    ///
7904    /// See [`Self::add_scope()`] for details.
7905    pub fn add_scopes<I, St>(
7906        mut self,
7907        scopes: I,
7908    ) -> ProjectLocationInstanceGetInstanceHealthCall<'a, C>
7909    where
7910        I: IntoIterator<Item = St>,
7911        St: AsRef<str>,
7912    {
7913        self._scopes
7914            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7915        self
7916    }
7917
7918    /// Removes all scopes, and no default scope will be used either.
7919    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7920    /// for details).
7921    pub fn clear_scopes(mut self) -> ProjectLocationInstanceGetInstanceHealthCall<'a, C> {
7922        self._scopes.clear();
7923        self
7924    }
7925}
7926
7927/// Checks whether a notebook instance is upgradable.
7928///
7929/// A builder for the *locations.instances.isUpgradeable* method supported by a *project* resource.
7930/// It is not used directly, but through a [`ProjectMethods`] instance.
7931///
7932/// # Example
7933///
7934/// Instantiate a resource method builder
7935///
7936/// ```test_harness,no_run
7937/// # extern crate hyper;
7938/// # extern crate hyper_rustls;
7939/// # extern crate google_notebooks1 as notebooks1;
7940/// # async fn dox() {
7941/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7942///
7943/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7944/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7945/// #     secret,
7946/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7947/// # ).build().await.unwrap();
7948///
7949/// # let client = hyper_util::client::legacy::Client::builder(
7950/// #     hyper_util::rt::TokioExecutor::new()
7951/// # )
7952/// # .build(
7953/// #     hyper_rustls::HttpsConnectorBuilder::new()
7954/// #         .with_native_roots()
7955/// #         .unwrap()
7956/// #         .https_or_http()
7957/// #         .enable_http1()
7958/// #         .build()
7959/// # );
7960/// # let mut hub = AIPlatformNotebooks::new(client, auth);
7961/// // You can configure optional parameters by calling the respective setters at will, and
7962/// // execute the final call using `doit()`.
7963/// // Values shown here are possibly random and not representative !
7964/// let result = hub.projects().locations_instances_is_upgradeable("notebookInstance")
7965///              .type_("dolor")
7966///              .doit().await;
7967/// # }
7968/// ```
7969pub struct ProjectLocationInstanceIsUpgradeableCall<'a, C>
7970where
7971    C: 'a,
7972{
7973    hub: &'a AIPlatformNotebooks<C>,
7974    _notebook_instance: String,
7975    _type_: Option<String>,
7976    _delegate: Option<&'a mut dyn common::Delegate>,
7977    _additional_params: HashMap<String, String>,
7978    _scopes: BTreeSet<String>,
7979}
7980
7981impl<'a, C> common::CallBuilder for ProjectLocationInstanceIsUpgradeableCall<'a, C> {}
7982
7983impl<'a, C> ProjectLocationInstanceIsUpgradeableCall<'a, C>
7984where
7985    C: common::Connector,
7986{
7987    /// Perform the operation you have build so far.
7988    pub async fn doit(
7989        mut self,
7990    ) -> common::Result<(common::Response, IsInstanceUpgradeableResponse)> {
7991        use std::borrow::Cow;
7992        use std::io::{Read, Seek};
7993
7994        use common::{url::Params, ToParts};
7995        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7996
7997        let mut dd = common::DefaultDelegate;
7998        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7999        dlg.begin(common::MethodInfo {
8000            id: "notebooks.projects.locations.instances.isUpgradeable",
8001            http_method: hyper::Method::GET,
8002        });
8003
8004        for &field in ["alt", "notebookInstance", "type"].iter() {
8005            if self._additional_params.contains_key(field) {
8006                dlg.finished(false);
8007                return Err(common::Error::FieldClash(field));
8008            }
8009        }
8010
8011        let mut params = Params::with_capacity(4 + self._additional_params.len());
8012        params.push("notebookInstance", self._notebook_instance);
8013        if let Some(value) = self._type_.as_ref() {
8014            params.push("type", value);
8015        }
8016
8017        params.extend(self._additional_params.iter());
8018
8019        params.push("alt", "json");
8020        let mut url = self.hub._base_url.clone() + "v1/{+notebookInstance}:isUpgradeable";
8021        if self._scopes.is_empty() {
8022            self._scopes
8023                .insert(Scope::CloudPlatform.as_ref().to_string());
8024        }
8025
8026        #[allow(clippy::single_element_loop)]
8027        for &(find_this, param_name) in [("{+notebookInstance}", "notebookInstance")].iter() {
8028            url = params.uri_replacement(url, param_name, find_this, true);
8029        }
8030        {
8031            let to_remove = ["notebookInstance"];
8032            params.remove_params(&to_remove);
8033        }
8034
8035        let url = params.parse_with_url(&url);
8036
8037        loop {
8038            let token = match self
8039                .hub
8040                .auth
8041                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8042                .await
8043            {
8044                Ok(token) => token,
8045                Err(e) => match dlg.token(e) {
8046                    Ok(token) => token,
8047                    Err(e) => {
8048                        dlg.finished(false);
8049                        return Err(common::Error::MissingToken(e));
8050                    }
8051                },
8052            };
8053            let mut req_result = {
8054                let client = &self.hub.client;
8055                dlg.pre_request();
8056                let mut req_builder = hyper::Request::builder()
8057                    .method(hyper::Method::GET)
8058                    .uri(url.as_str())
8059                    .header(USER_AGENT, self.hub._user_agent.clone());
8060
8061                if let Some(token) = token.as_ref() {
8062                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8063                }
8064
8065                let request = req_builder
8066                    .header(CONTENT_LENGTH, 0_u64)
8067                    .body(common::to_body::<String>(None));
8068
8069                client.request(request.unwrap()).await
8070            };
8071
8072            match req_result {
8073                Err(err) => {
8074                    if let common::Retry::After(d) = dlg.http_error(&err) {
8075                        sleep(d).await;
8076                        continue;
8077                    }
8078                    dlg.finished(false);
8079                    return Err(common::Error::HttpError(err));
8080                }
8081                Ok(res) => {
8082                    let (mut parts, body) = res.into_parts();
8083                    let mut body = common::Body::new(body);
8084                    if !parts.status.is_success() {
8085                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8086                        let error = serde_json::from_str(&common::to_string(&bytes));
8087                        let response = common::to_response(parts, bytes.into());
8088
8089                        if let common::Retry::After(d) =
8090                            dlg.http_failure(&response, error.as_ref().ok())
8091                        {
8092                            sleep(d).await;
8093                            continue;
8094                        }
8095
8096                        dlg.finished(false);
8097
8098                        return Err(match error {
8099                            Ok(value) => common::Error::BadRequest(value),
8100                            _ => common::Error::Failure(response),
8101                        });
8102                    }
8103                    let response = {
8104                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8105                        let encoded = common::to_string(&bytes);
8106                        match serde_json::from_str(&encoded) {
8107                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8108                            Err(error) => {
8109                                dlg.response_json_decode_error(&encoded, &error);
8110                                return Err(common::Error::JsonDecodeError(
8111                                    encoded.to_string(),
8112                                    error,
8113                                ));
8114                            }
8115                        }
8116                    };
8117
8118                    dlg.finished(true);
8119                    return Ok(response);
8120                }
8121            }
8122        }
8123    }
8124
8125    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
8126    ///
8127    /// Sets the *notebook instance* path property to the given value.
8128    ///
8129    /// Even though the property as already been set when instantiating this call,
8130    /// we provide this method for API completeness.
8131    pub fn notebook_instance(
8132        mut self,
8133        new_value: &str,
8134    ) -> ProjectLocationInstanceIsUpgradeableCall<'a, C> {
8135        self._notebook_instance = new_value.to_string();
8136        self
8137    }
8138    /// Optional. The optional UpgradeType. Setting this field will search for additional compute images to upgrade this instance.
8139    ///
8140    /// Sets the *type* query property to the given value.
8141    pub fn type_(mut self, new_value: &str) -> ProjectLocationInstanceIsUpgradeableCall<'a, C> {
8142        self._type_ = Some(new_value.to_string());
8143        self
8144    }
8145    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8146    /// while executing the actual API request.
8147    ///
8148    /// ````text
8149    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8150    /// ````
8151    ///
8152    /// Sets the *delegate* property to the given value.
8153    pub fn delegate(
8154        mut self,
8155        new_value: &'a mut dyn common::Delegate,
8156    ) -> ProjectLocationInstanceIsUpgradeableCall<'a, C> {
8157        self._delegate = Some(new_value);
8158        self
8159    }
8160
8161    /// Set any additional parameter of the query string used in the request.
8162    /// It should be used to set parameters which are not yet available through their own
8163    /// setters.
8164    ///
8165    /// Please note that this method must not be used to set any of the known parameters
8166    /// which have their own setter method. If done anyway, the request will fail.
8167    ///
8168    /// # Additional Parameters
8169    ///
8170    /// * *$.xgafv* (query-string) - V1 error format.
8171    /// * *access_token* (query-string) - OAuth access token.
8172    /// * *alt* (query-string) - Data format for response.
8173    /// * *callback* (query-string) - JSONP
8174    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8175    /// * *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.
8176    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8177    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8178    /// * *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.
8179    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8180    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8181    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceIsUpgradeableCall<'a, C>
8182    where
8183        T: AsRef<str>,
8184    {
8185        self._additional_params
8186            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8187        self
8188    }
8189
8190    /// Identifies the authorization scope for the method you are building.
8191    ///
8192    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8193    /// [`Scope::CloudPlatform`].
8194    ///
8195    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8196    /// tokens for more than one scope.
8197    ///
8198    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8199    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8200    /// sufficient, a read-write scope will do as well.
8201    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceIsUpgradeableCall<'a, C>
8202    where
8203        St: AsRef<str>,
8204    {
8205        self._scopes.insert(String::from(scope.as_ref()));
8206        self
8207    }
8208    /// Identifies the authorization scope(s) for the method you are building.
8209    ///
8210    /// See [`Self::add_scope()`] for details.
8211    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceIsUpgradeableCall<'a, C>
8212    where
8213        I: IntoIterator<Item = St>,
8214        St: AsRef<str>,
8215    {
8216        self._scopes
8217            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8218        self
8219    }
8220
8221    /// Removes all scopes, and no default scope will be used either.
8222    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8223    /// for details).
8224    pub fn clear_scopes(mut self) -> ProjectLocationInstanceIsUpgradeableCall<'a, C> {
8225        self._scopes.clear();
8226        self
8227    }
8228}
8229
8230/// Lists instances in a given project and location.
8231///
8232/// A builder for the *locations.instances.list* method supported by a *project* resource.
8233/// It is not used directly, but through a [`ProjectMethods`] instance.
8234///
8235/// # Example
8236///
8237/// Instantiate a resource method builder
8238///
8239/// ```test_harness,no_run
8240/// # extern crate hyper;
8241/// # extern crate hyper_rustls;
8242/// # extern crate google_notebooks1 as notebooks1;
8243/// # async fn dox() {
8244/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8245///
8246/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8247/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8248/// #     secret,
8249/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8250/// # ).build().await.unwrap();
8251///
8252/// # let client = hyper_util::client::legacy::Client::builder(
8253/// #     hyper_util::rt::TokioExecutor::new()
8254/// # )
8255/// # .build(
8256/// #     hyper_rustls::HttpsConnectorBuilder::new()
8257/// #         .with_native_roots()
8258/// #         .unwrap()
8259/// #         .https_or_http()
8260/// #         .enable_http1()
8261/// #         .build()
8262/// # );
8263/// # let mut hub = AIPlatformNotebooks::new(client, auth);
8264/// // You can configure optional parameters by calling the respective setters at will, and
8265/// // execute the final call using `doit()`.
8266/// // Values shown here are possibly random and not representative !
8267/// let result = hub.projects().locations_instances_list("parent")
8268///              .page_token("eos")
8269///              .page_size(-86)
8270///              .order_by("sed")
8271///              .filter("duo")
8272///              .doit().await;
8273/// # }
8274/// ```
8275pub struct ProjectLocationInstanceListCall<'a, C>
8276where
8277    C: 'a,
8278{
8279    hub: &'a AIPlatformNotebooks<C>,
8280    _parent: String,
8281    _page_token: Option<String>,
8282    _page_size: Option<i32>,
8283    _order_by: Option<String>,
8284    _filter: Option<String>,
8285    _delegate: Option<&'a mut dyn common::Delegate>,
8286    _additional_params: HashMap<String, String>,
8287    _scopes: BTreeSet<String>,
8288}
8289
8290impl<'a, C> common::CallBuilder for ProjectLocationInstanceListCall<'a, C> {}
8291
8292impl<'a, C> ProjectLocationInstanceListCall<'a, C>
8293where
8294    C: common::Connector,
8295{
8296    /// Perform the operation you have build so far.
8297    pub async fn doit(mut self) -> common::Result<(common::Response, ListInstancesResponse)> {
8298        use std::borrow::Cow;
8299        use std::io::{Read, Seek};
8300
8301        use common::{url::Params, ToParts};
8302        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8303
8304        let mut dd = common::DefaultDelegate;
8305        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8306        dlg.begin(common::MethodInfo {
8307            id: "notebooks.projects.locations.instances.list",
8308            http_method: hyper::Method::GET,
8309        });
8310
8311        for &field in [
8312            "alt",
8313            "parent",
8314            "pageToken",
8315            "pageSize",
8316            "orderBy",
8317            "filter",
8318        ]
8319        .iter()
8320        {
8321            if self._additional_params.contains_key(field) {
8322                dlg.finished(false);
8323                return Err(common::Error::FieldClash(field));
8324            }
8325        }
8326
8327        let mut params = Params::with_capacity(7 + self._additional_params.len());
8328        params.push("parent", self._parent);
8329        if let Some(value) = self._page_token.as_ref() {
8330            params.push("pageToken", value);
8331        }
8332        if let Some(value) = self._page_size.as_ref() {
8333            params.push("pageSize", value.to_string());
8334        }
8335        if let Some(value) = self._order_by.as_ref() {
8336            params.push("orderBy", value);
8337        }
8338        if let Some(value) = self._filter.as_ref() {
8339            params.push("filter", value);
8340        }
8341
8342        params.extend(self._additional_params.iter());
8343
8344        params.push("alt", "json");
8345        let mut url = self.hub._base_url.clone() + "v1/{+parent}/instances";
8346        if self._scopes.is_empty() {
8347            self._scopes
8348                .insert(Scope::CloudPlatform.as_ref().to_string());
8349        }
8350
8351        #[allow(clippy::single_element_loop)]
8352        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8353            url = params.uri_replacement(url, param_name, find_this, true);
8354        }
8355        {
8356            let to_remove = ["parent"];
8357            params.remove_params(&to_remove);
8358        }
8359
8360        let url = params.parse_with_url(&url);
8361
8362        loop {
8363            let token = match self
8364                .hub
8365                .auth
8366                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8367                .await
8368            {
8369                Ok(token) => token,
8370                Err(e) => match dlg.token(e) {
8371                    Ok(token) => token,
8372                    Err(e) => {
8373                        dlg.finished(false);
8374                        return Err(common::Error::MissingToken(e));
8375                    }
8376                },
8377            };
8378            let mut req_result = {
8379                let client = &self.hub.client;
8380                dlg.pre_request();
8381                let mut req_builder = hyper::Request::builder()
8382                    .method(hyper::Method::GET)
8383                    .uri(url.as_str())
8384                    .header(USER_AGENT, self.hub._user_agent.clone());
8385
8386                if let Some(token) = token.as_ref() {
8387                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8388                }
8389
8390                let request = req_builder
8391                    .header(CONTENT_LENGTH, 0_u64)
8392                    .body(common::to_body::<String>(None));
8393
8394                client.request(request.unwrap()).await
8395            };
8396
8397            match req_result {
8398                Err(err) => {
8399                    if let common::Retry::After(d) = dlg.http_error(&err) {
8400                        sleep(d).await;
8401                        continue;
8402                    }
8403                    dlg.finished(false);
8404                    return Err(common::Error::HttpError(err));
8405                }
8406                Ok(res) => {
8407                    let (mut parts, body) = res.into_parts();
8408                    let mut body = common::Body::new(body);
8409                    if !parts.status.is_success() {
8410                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8411                        let error = serde_json::from_str(&common::to_string(&bytes));
8412                        let response = common::to_response(parts, bytes.into());
8413
8414                        if let common::Retry::After(d) =
8415                            dlg.http_failure(&response, error.as_ref().ok())
8416                        {
8417                            sleep(d).await;
8418                            continue;
8419                        }
8420
8421                        dlg.finished(false);
8422
8423                        return Err(match error {
8424                            Ok(value) => common::Error::BadRequest(value),
8425                            _ => common::Error::Failure(response),
8426                        });
8427                    }
8428                    let response = {
8429                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8430                        let encoded = common::to_string(&bytes);
8431                        match serde_json::from_str(&encoded) {
8432                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8433                            Err(error) => {
8434                                dlg.response_json_decode_error(&encoded, &error);
8435                                return Err(common::Error::JsonDecodeError(
8436                                    encoded.to_string(),
8437                                    error,
8438                                ));
8439                            }
8440                        }
8441                    };
8442
8443                    dlg.finished(true);
8444                    return Ok(response);
8445                }
8446            }
8447        }
8448    }
8449
8450    /// Required. Format: `parent=projects/{project_id}/locations/{location}`
8451    ///
8452    /// Sets the *parent* path property to the given value.
8453    ///
8454    /// Even though the property as already been set when instantiating this call,
8455    /// we provide this method for API completeness.
8456    pub fn parent(mut self, new_value: &str) -> ProjectLocationInstanceListCall<'a, C> {
8457        self._parent = new_value.to_string();
8458        self
8459    }
8460    /// A previous returned page token that can be used to continue listing from the last result.
8461    ///
8462    /// Sets the *page token* query property to the given value.
8463    pub fn page_token(mut self, new_value: &str) -> ProjectLocationInstanceListCall<'a, C> {
8464        self._page_token = Some(new_value.to_string());
8465        self
8466    }
8467    /// Maximum return size of the list call.
8468    ///
8469    /// Sets the *page size* query property to the given value.
8470    pub fn page_size(mut self, new_value: i32) -> ProjectLocationInstanceListCall<'a, C> {
8471        self._page_size = Some(new_value);
8472        self
8473    }
8474    /// Optional. Sort results. Supported values are "name", "name desc" or "" (unsorted).
8475    ///
8476    /// Sets the *order by* query property to the given value.
8477    pub fn order_by(mut self, new_value: &str) -> ProjectLocationInstanceListCall<'a, C> {
8478        self._order_by = Some(new_value.to_string());
8479        self
8480    }
8481    /// Optional. List filter.
8482    ///
8483    /// Sets the *filter* query property to the given value.
8484    pub fn filter(mut self, new_value: &str) -> ProjectLocationInstanceListCall<'a, C> {
8485        self._filter = Some(new_value.to_string());
8486        self
8487    }
8488    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8489    /// while executing the actual API request.
8490    ///
8491    /// ````text
8492    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8493    /// ````
8494    ///
8495    /// Sets the *delegate* property to the given value.
8496    pub fn delegate(
8497        mut self,
8498        new_value: &'a mut dyn common::Delegate,
8499    ) -> ProjectLocationInstanceListCall<'a, C> {
8500        self._delegate = Some(new_value);
8501        self
8502    }
8503
8504    /// Set any additional parameter of the query string used in the request.
8505    /// It should be used to set parameters which are not yet available through their own
8506    /// setters.
8507    ///
8508    /// Please note that this method must not be used to set any of the known parameters
8509    /// which have their own setter method. If done anyway, the request will fail.
8510    ///
8511    /// # Additional Parameters
8512    ///
8513    /// * *$.xgafv* (query-string) - V1 error format.
8514    /// * *access_token* (query-string) - OAuth access token.
8515    /// * *alt* (query-string) - Data format for response.
8516    /// * *callback* (query-string) - JSONP
8517    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8518    /// * *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.
8519    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8520    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8521    /// * *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.
8522    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8523    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8524    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceListCall<'a, C>
8525    where
8526        T: AsRef<str>,
8527    {
8528        self._additional_params
8529            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8530        self
8531    }
8532
8533    /// Identifies the authorization scope for the method you are building.
8534    ///
8535    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8536    /// [`Scope::CloudPlatform`].
8537    ///
8538    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8539    /// tokens for more than one scope.
8540    ///
8541    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8542    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8543    /// sufficient, a read-write scope will do as well.
8544    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceListCall<'a, C>
8545    where
8546        St: AsRef<str>,
8547    {
8548        self._scopes.insert(String::from(scope.as_ref()));
8549        self
8550    }
8551    /// Identifies the authorization scope(s) for the method you are building.
8552    ///
8553    /// See [`Self::add_scope()`] for details.
8554    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceListCall<'a, C>
8555    where
8556        I: IntoIterator<Item = St>,
8557        St: AsRef<str>,
8558    {
8559        self._scopes
8560            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8561        self
8562    }
8563
8564    /// Removes all scopes, and no default scope will be used either.
8565    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8566    /// for details).
8567    pub fn clear_scopes(mut self) -> ProjectLocationInstanceListCall<'a, C> {
8568        self._scopes.clear();
8569        self
8570    }
8571}
8572
8573/// Migrates an existing User-Managed Notebook to Workbench Instances.
8574///
8575/// A builder for the *locations.instances.migrate* method supported by a *project* resource.
8576/// It is not used directly, but through a [`ProjectMethods`] instance.
8577///
8578/// # Example
8579///
8580/// Instantiate a resource method builder
8581///
8582/// ```test_harness,no_run
8583/// # extern crate hyper;
8584/// # extern crate hyper_rustls;
8585/// # extern crate google_notebooks1 as notebooks1;
8586/// use notebooks1::api::MigrateInstanceRequest;
8587/// # async fn dox() {
8588/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8589///
8590/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8591/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8592/// #     secret,
8593/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8594/// # ).build().await.unwrap();
8595///
8596/// # let client = hyper_util::client::legacy::Client::builder(
8597/// #     hyper_util::rt::TokioExecutor::new()
8598/// # )
8599/// # .build(
8600/// #     hyper_rustls::HttpsConnectorBuilder::new()
8601/// #         .with_native_roots()
8602/// #         .unwrap()
8603/// #         .https_or_http()
8604/// #         .enable_http1()
8605/// #         .build()
8606/// # );
8607/// # let mut hub = AIPlatformNotebooks::new(client, auth);
8608/// // As the method needs a request, you would usually fill it with the desired information
8609/// // into the respective structure. Some of the parts shown here might not be applicable !
8610/// // Values shown here are possibly random and not representative !
8611/// let mut req = MigrateInstanceRequest::default();
8612///
8613/// // You can configure optional parameters by calling the respective setters at will, and
8614/// // execute the final call using `doit()`.
8615/// // Values shown here are possibly random and not representative !
8616/// let result = hub.projects().locations_instances_migrate(req, "name")
8617///              .doit().await;
8618/// # }
8619/// ```
8620pub struct ProjectLocationInstanceMigrateCall<'a, C>
8621where
8622    C: 'a,
8623{
8624    hub: &'a AIPlatformNotebooks<C>,
8625    _request: MigrateInstanceRequest,
8626    _name: String,
8627    _delegate: Option<&'a mut dyn common::Delegate>,
8628    _additional_params: HashMap<String, String>,
8629    _scopes: BTreeSet<String>,
8630}
8631
8632impl<'a, C> common::CallBuilder for ProjectLocationInstanceMigrateCall<'a, C> {}
8633
8634impl<'a, C> ProjectLocationInstanceMigrateCall<'a, C>
8635where
8636    C: common::Connector,
8637{
8638    /// Perform the operation you have build so far.
8639    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
8640        use std::borrow::Cow;
8641        use std::io::{Read, Seek};
8642
8643        use common::{url::Params, ToParts};
8644        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8645
8646        let mut dd = common::DefaultDelegate;
8647        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8648        dlg.begin(common::MethodInfo {
8649            id: "notebooks.projects.locations.instances.migrate",
8650            http_method: hyper::Method::POST,
8651        });
8652
8653        for &field in ["alt", "name"].iter() {
8654            if self._additional_params.contains_key(field) {
8655                dlg.finished(false);
8656                return Err(common::Error::FieldClash(field));
8657            }
8658        }
8659
8660        let mut params = Params::with_capacity(4 + self._additional_params.len());
8661        params.push("name", self._name);
8662
8663        params.extend(self._additional_params.iter());
8664
8665        params.push("alt", "json");
8666        let mut url = self.hub._base_url.clone() + "v1/{+name}:migrate";
8667        if self._scopes.is_empty() {
8668            self._scopes
8669                .insert(Scope::CloudPlatform.as_ref().to_string());
8670        }
8671
8672        #[allow(clippy::single_element_loop)]
8673        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8674            url = params.uri_replacement(url, param_name, find_this, true);
8675        }
8676        {
8677            let to_remove = ["name"];
8678            params.remove_params(&to_remove);
8679        }
8680
8681        let url = params.parse_with_url(&url);
8682
8683        let mut json_mime_type = mime::APPLICATION_JSON;
8684        let mut request_value_reader = {
8685            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8686            common::remove_json_null_values(&mut value);
8687            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8688            serde_json::to_writer(&mut dst, &value).unwrap();
8689            dst
8690        };
8691        let request_size = request_value_reader
8692            .seek(std::io::SeekFrom::End(0))
8693            .unwrap();
8694        request_value_reader
8695            .seek(std::io::SeekFrom::Start(0))
8696            .unwrap();
8697
8698        loop {
8699            let token = match self
8700                .hub
8701                .auth
8702                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8703                .await
8704            {
8705                Ok(token) => token,
8706                Err(e) => match dlg.token(e) {
8707                    Ok(token) => token,
8708                    Err(e) => {
8709                        dlg.finished(false);
8710                        return Err(common::Error::MissingToken(e));
8711                    }
8712                },
8713            };
8714            request_value_reader
8715                .seek(std::io::SeekFrom::Start(0))
8716                .unwrap();
8717            let mut req_result = {
8718                let client = &self.hub.client;
8719                dlg.pre_request();
8720                let mut req_builder = hyper::Request::builder()
8721                    .method(hyper::Method::POST)
8722                    .uri(url.as_str())
8723                    .header(USER_AGENT, self.hub._user_agent.clone());
8724
8725                if let Some(token) = token.as_ref() {
8726                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8727                }
8728
8729                let request = req_builder
8730                    .header(CONTENT_TYPE, json_mime_type.to_string())
8731                    .header(CONTENT_LENGTH, request_size as u64)
8732                    .body(common::to_body(
8733                        request_value_reader.get_ref().clone().into(),
8734                    ));
8735
8736                client.request(request.unwrap()).await
8737            };
8738
8739            match req_result {
8740                Err(err) => {
8741                    if let common::Retry::After(d) = dlg.http_error(&err) {
8742                        sleep(d).await;
8743                        continue;
8744                    }
8745                    dlg.finished(false);
8746                    return Err(common::Error::HttpError(err));
8747                }
8748                Ok(res) => {
8749                    let (mut parts, body) = res.into_parts();
8750                    let mut body = common::Body::new(body);
8751                    if !parts.status.is_success() {
8752                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8753                        let error = serde_json::from_str(&common::to_string(&bytes));
8754                        let response = common::to_response(parts, bytes.into());
8755
8756                        if let common::Retry::After(d) =
8757                            dlg.http_failure(&response, error.as_ref().ok())
8758                        {
8759                            sleep(d).await;
8760                            continue;
8761                        }
8762
8763                        dlg.finished(false);
8764
8765                        return Err(match error {
8766                            Ok(value) => common::Error::BadRequest(value),
8767                            _ => common::Error::Failure(response),
8768                        });
8769                    }
8770                    let response = {
8771                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8772                        let encoded = common::to_string(&bytes);
8773                        match serde_json::from_str(&encoded) {
8774                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8775                            Err(error) => {
8776                                dlg.response_json_decode_error(&encoded, &error);
8777                                return Err(common::Error::JsonDecodeError(
8778                                    encoded.to_string(),
8779                                    error,
8780                                ));
8781                            }
8782                        }
8783                    };
8784
8785                    dlg.finished(true);
8786                    return Ok(response);
8787                }
8788            }
8789        }
8790    }
8791
8792    ///
8793    /// Sets the *request* property to the given value.
8794    ///
8795    /// Even though the property as already been set when instantiating this call,
8796    /// we provide this method for API completeness.
8797    pub fn request(
8798        mut self,
8799        new_value: MigrateInstanceRequest,
8800    ) -> ProjectLocationInstanceMigrateCall<'a, C> {
8801        self._request = new_value;
8802        self
8803    }
8804    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
8805    ///
8806    /// Sets the *name* path property to the given value.
8807    ///
8808    /// Even though the property as already been set when instantiating this call,
8809    /// we provide this method for API completeness.
8810    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceMigrateCall<'a, C> {
8811        self._name = new_value.to_string();
8812        self
8813    }
8814    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8815    /// while executing the actual API request.
8816    ///
8817    /// ````text
8818    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8819    /// ````
8820    ///
8821    /// Sets the *delegate* property to the given value.
8822    pub fn delegate(
8823        mut self,
8824        new_value: &'a mut dyn common::Delegate,
8825    ) -> ProjectLocationInstanceMigrateCall<'a, C> {
8826        self._delegate = Some(new_value);
8827        self
8828    }
8829
8830    /// Set any additional parameter of the query string used in the request.
8831    /// It should be used to set parameters which are not yet available through their own
8832    /// setters.
8833    ///
8834    /// Please note that this method must not be used to set any of the known parameters
8835    /// which have their own setter method. If done anyway, the request will fail.
8836    ///
8837    /// # Additional Parameters
8838    ///
8839    /// * *$.xgafv* (query-string) - V1 error format.
8840    /// * *access_token* (query-string) - OAuth access token.
8841    /// * *alt* (query-string) - Data format for response.
8842    /// * *callback* (query-string) - JSONP
8843    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8844    /// * *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.
8845    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8846    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8847    /// * *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.
8848    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8849    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8850    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceMigrateCall<'a, C>
8851    where
8852        T: AsRef<str>,
8853    {
8854        self._additional_params
8855            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8856        self
8857    }
8858
8859    /// Identifies the authorization scope for the method you are building.
8860    ///
8861    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8862    /// [`Scope::CloudPlatform`].
8863    ///
8864    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8865    /// tokens for more than one scope.
8866    ///
8867    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8868    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8869    /// sufficient, a read-write scope will do as well.
8870    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceMigrateCall<'a, C>
8871    where
8872        St: AsRef<str>,
8873    {
8874        self._scopes.insert(String::from(scope.as_ref()));
8875        self
8876    }
8877    /// Identifies the authorization scope(s) for the method you are building.
8878    ///
8879    /// See [`Self::add_scope()`] for details.
8880    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceMigrateCall<'a, C>
8881    where
8882        I: IntoIterator<Item = St>,
8883        St: AsRef<str>,
8884    {
8885        self._scopes
8886            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8887        self
8888    }
8889
8890    /// Removes all scopes, and no default scope will be used either.
8891    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8892    /// for details).
8893    pub fn clear_scopes(mut self) -> ProjectLocationInstanceMigrateCall<'a, C> {
8894        self._scopes.clear();
8895        self
8896    }
8897}
8898
8899/// 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.
8900///
8901/// A builder for the *locations.instances.register* method supported by a *project* resource.
8902/// It is not used directly, but through a [`ProjectMethods`] instance.
8903///
8904/// # Example
8905///
8906/// Instantiate a resource method builder
8907///
8908/// ```test_harness,no_run
8909/// # extern crate hyper;
8910/// # extern crate hyper_rustls;
8911/// # extern crate google_notebooks1 as notebooks1;
8912/// use notebooks1::api::RegisterInstanceRequest;
8913/// # async fn dox() {
8914/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8915///
8916/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8917/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8918/// #     secret,
8919/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8920/// # ).build().await.unwrap();
8921///
8922/// # let client = hyper_util::client::legacy::Client::builder(
8923/// #     hyper_util::rt::TokioExecutor::new()
8924/// # )
8925/// # .build(
8926/// #     hyper_rustls::HttpsConnectorBuilder::new()
8927/// #         .with_native_roots()
8928/// #         .unwrap()
8929/// #         .https_or_http()
8930/// #         .enable_http1()
8931/// #         .build()
8932/// # );
8933/// # let mut hub = AIPlatformNotebooks::new(client, auth);
8934/// // As the method needs a request, you would usually fill it with the desired information
8935/// // into the respective structure. Some of the parts shown here might not be applicable !
8936/// // Values shown here are possibly random and not representative !
8937/// let mut req = RegisterInstanceRequest::default();
8938///
8939/// // You can configure optional parameters by calling the respective setters at will, and
8940/// // execute the final call using `doit()`.
8941/// // Values shown here are possibly random and not representative !
8942/// let result = hub.projects().locations_instances_register(req, "parent")
8943///              .doit().await;
8944/// # }
8945/// ```
8946pub struct ProjectLocationInstanceRegisterCall<'a, C>
8947where
8948    C: 'a,
8949{
8950    hub: &'a AIPlatformNotebooks<C>,
8951    _request: RegisterInstanceRequest,
8952    _parent: String,
8953    _delegate: Option<&'a mut dyn common::Delegate>,
8954    _additional_params: HashMap<String, String>,
8955    _scopes: BTreeSet<String>,
8956}
8957
8958impl<'a, C> common::CallBuilder for ProjectLocationInstanceRegisterCall<'a, C> {}
8959
8960impl<'a, C> ProjectLocationInstanceRegisterCall<'a, C>
8961where
8962    C: common::Connector,
8963{
8964    /// Perform the operation you have build so far.
8965    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
8966        use std::borrow::Cow;
8967        use std::io::{Read, Seek};
8968
8969        use common::{url::Params, ToParts};
8970        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8971
8972        let mut dd = common::DefaultDelegate;
8973        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8974        dlg.begin(common::MethodInfo {
8975            id: "notebooks.projects.locations.instances.register",
8976            http_method: hyper::Method::POST,
8977        });
8978
8979        for &field in ["alt", "parent"].iter() {
8980            if self._additional_params.contains_key(field) {
8981                dlg.finished(false);
8982                return Err(common::Error::FieldClash(field));
8983            }
8984        }
8985
8986        let mut params = Params::with_capacity(4 + self._additional_params.len());
8987        params.push("parent", self._parent);
8988
8989        params.extend(self._additional_params.iter());
8990
8991        params.push("alt", "json");
8992        let mut url = self.hub._base_url.clone() + "v1/{+parent}/instances:register";
8993        if self._scopes.is_empty() {
8994            self._scopes
8995                .insert(Scope::CloudPlatform.as_ref().to_string());
8996        }
8997
8998        #[allow(clippy::single_element_loop)]
8999        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9000            url = params.uri_replacement(url, param_name, find_this, true);
9001        }
9002        {
9003            let to_remove = ["parent"];
9004            params.remove_params(&to_remove);
9005        }
9006
9007        let url = params.parse_with_url(&url);
9008
9009        let mut json_mime_type = mime::APPLICATION_JSON;
9010        let mut request_value_reader = {
9011            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9012            common::remove_json_null_values(&mut value);
9013            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9014            serde_json::to_writer(&mut dst, &value).unwrap();
9015            dst
9016        };
9017        let request_size = request_value_reader
9018            .seek(std::io::SeekFrom::End(0))
9019            .unwrap();
9020        request_value_reader
9021            .seek(std::io::SeekFrom::Start(0))
9022            .unwrap();
9023
9024        loop {
9025            let token = match self
9026                .hub
9027                .auth
9028                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9029                .await
9030            {
9031                Ok(token) => token,
9032                Err(e) => match dlg.token(e) {
9033                    Ok(token) => token,
9034                    Err(e) => {
9035                        dlg.finished(false);
9036                        return Err(common::Error::MissingToken(e));
9037                    }
9038                },
9039            };
9040            request_value_reader
9041                .seek(std::io::SeekFrom::Start(0))
9042                .unwrap();
9043            let mut req_result = {
9044                let client = &self.hub.client;
9045                dlg.pre_request();
9046                let mut req_builder = hyper::Request::builder()
9047                    .method(hyper::Method::POST)
9048                    .uri(url.as_str())
9049                    .header(USER_AGENT, self.hub._user_agent.clone());
9050
9051                if let Some(token) = token.as_ref() {
9052                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9053                }
9054
9055                let request = req_builder
9056                    .header(CONTENT_TYPE, json_mime_type.to_string())
9057                    .header(CONTENT_LENGTH, request_size as u64)
9058                    .body(common::to_body(
9059                        request_value_reader.get_ref().clone().into(),
9060                    ));
9061
9062                client.request(request.unwrap()).await
9063            };
9064
9065            match req_result {
9066                Err(err) => {
9067                    if let common::Retry::After(d) = dlg.http_error(&err) {
9068                        sleep(d).await;
9069                        continue;
9070                    }
9071                    dlg.finished(false);
9072                    return Err(common::Error::HttpError(err));
9073                }
9074                Ok(res) => {
9075                    let (mut parts, body) = res.into_parts();
9076                    let mut body = common::Body::new(body);
9077                    if !parts.status.is_success() {
9078                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9079                        let error = serde_json::from_str(&common::to_string(&bytes));
9080                        let response = common::to_response(parts, bytes.into());
9081
9082                        if let common::Retry::After(d) =
9083                            dlg.http_failure(&response, error.as_ref().ok())
9084                        {
9085                            sleep(d).await;
9086                            continue;
9087                        }
9088
9089                        dlg.finished(false);
9090
9091                        return Err(match error {
9092                            Ok(value) => common::Error::BadRequest(value),
9093                            _ => common::Error::Failure(response),
9094                        });
9095                    }
9096                    let response = {
9097                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9098                        let encoded = common::to_string(&bytes);
9099                        match serde_json::from_str(&encoded) {
9100                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9101                            Err(error) => {
9102                                dlg.response_json_decode_error(&encoded, &error);
9103                                return Err(common::Error::JsonDecodeError(
9104                                    encoded.to_string(),
9105                                    error,
9106                                ));
9107                            }
9108                        }
9109                    };
9110
9111                    dlg.finished(true);
9112                    return Ok(response);
9113                }
9114            }
9115        }
9116    }
9117
9118    ///
9119    /// Sets the *request* property to the given value.
9120    ///
9121    /// Even though the property as already been set when instantiating this call,
9122    /// we provide this method for API completeness.
9123    pub fn request(
9124        mut self,
9125        new_value: RegisterInstanceRequest,
9126    ) -> ProjectLocationInstanceRegisterCall<'a, C> {
9127        self._request = new_value;
9128        self
9129    }
9130    /// Required. Format: `parent=projects/{project_id}/locations/{location}`
9131    ///
9132    /// Sets the *parent* path property to the given value.
9133    ///
9134    /// Even though the property as already been set when instantiating this call,
9135    /// we provide this method for API completeness.
9136    pub fn parent(mut self, new_value: &str) -> ProjectLocationInstanceRegisterCall<'a, C> {
9137        self._parent = new_value.to_string();
9138        self
9139    }
9140    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9141    /// while executing the actual API request.
9142    ///
9143    /// ````text
9144    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9145    /// ````
9146    ///
9147    /// Sets the *delegate* property to the given value.
9148    pub fn delegate(
9149        mut self,
9150        new_value: &'a mut dyn common::Delegate,
9151    ) -> ProjectLocationInstanceRegisterCall<'a, C> {
9152        self._delegate = Some(new_value);
9153        self
9154    }
9155
9156    /// Set any additional parameter of the query string used in the request.
9157    /// It should be used to set parameters which are not yet available through their own
9158    /// setters.
9159    ///
9160    /// Please note that this method must not be used to set any of the known parameters
9161    /// which have their own setter method. If done anyway, the request will fail.
9162    ///
9163    /// # Additional Parameters
9164    ///
9165    /// * *$.xgafv* (query-string) - V1 error format.
9166    /// * *access_token* (query-string) - OAuth access token.
9167    /// * *alt* (query-string) - Data format for response.
9168    /// * *callback* (query-string) - JSONP
9169    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9170    /// * *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.
9171    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9172    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9173    /// * *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.
9174    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9175    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9176    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceRegisterCall<'a, C>
9177    where
9178        T: AsRef<str>,
9179    {
9180        self._additional_params
9181            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9182        self
9183    }
9184
9185    /// Identifies the authorization scope for the method you are building.
9186    ///
9187    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9188    /// [`Scope::CloudPlatform`].
9189    ///
9190    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9191    /// tokens for more than one scope.
9192    ///
9193    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9194    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9195    /// sufficient, a read-write scope will do as well.
9196    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceRegisterCall<'a, C>
9197    where
9198        St: AsRef<str>,
9199    {
9200        self._scopes.insert(String::from(scope.as_ref()));
9201        self
9202    }
9203    /// Identifies the authorization scope(s) for the method you are building.
9204    ///
9205    /// See [`Self::add_scope()`] for details.
9206    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceRegisterCall<'a, C>
9207    where
9208        I: IntoIterator<Item = St>,
9209        St: AsRef<str>,
9210    {
9211        self._scopes
9212            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9213        self
9214    }
9215
9216    /// Removes all scopes, and no default scope will be used either.
9217    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9218    /// for details).
9219    pub fn clear_scopes(mut self) -> ProjectLocationInstanceRegisterCall<'a, C> {
9220        self._scopes.clear();
9221        self
9222    }
9223}
9224
9225/// 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.
9226///
9227/// A builder for the *locations.instances.report* method supported by a *project* resource.
9228/// It is not used directly, but through a [`ProjectMethods`] instance.
9229///
9230/// # Example
9231///
9232/// Instantiate a resource method builder
9233///
9234/// ```test_harness,no_run
9235/// # extern crate hyper;
9236/// # extern crate hyper_rustls;
9237/// # extern crate google_notebooks1 as notebooks1;
9238/// use notebooks1::api::ReportInstanceInfoRequest;
9239/// # async fn dox() {
9240/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9241///
9242/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9243/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9244/// #     secret,
9245/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9246/// # ).build().await.unwrap();
9247///
9248/// # let client = hyper_util::client::legacy::Client::builder(
9249/// #     hyper_util::rt::TokioExecutor::new()
9250/// # )
9251/// # .build(
9252/// #     hyper_rustls::HttpsConnectorBuilder::new()
9253/// #         .with_native_roots()
9254/// #         .unwrap()
9255/// #         .https_or_http()
9256/// #         .enable_http1()
9257/// #         .build()
9258/// # );
9259/// # let mut hub = AIPlatformNotebooks::new(client, auth);
9260/// // As the method needs a request, you would usually fill it with the desired information
9261/// // into the respective structure. Some of the parts shown here might not be applicable !
9262/// // Values shown here are possibly random and not representative !
9263/// let mut req = ReportInstanceInfoRequest::default();
9264///
9265/// // You can configure optional parameters by calling the respective setters at will, and
9266/// // execute the final call using `doit()`.
9267/// // Values shown here are possibly random and not representative !
9268/// let result = hub.projects().locations_instances_report(req, "name")
9269///              .doit().await;
9270/// # }
9271/// ```
9272pub struct ProjectLocationInstanceReportCall<'a, C>
9273where
9274    C: 'a,
9275{
9276    hub: &'a AIPlatformNotebooks<C>,
9277    _request: ReportInstanceInfoRequest,
9278    _name: String,
9279    _delegate: Option<&'a mut dyn common::Delegate>,
9280    _additional_params: HashMap<String, String>,
9281    _scopes: BTreeSet<String>,
9282}
9283
9284impl<'a, C> common::CallBuilder for ProjectLocationInstanceReportCall<'a, C> {}
9285
9286impl<'a, C> ProjectLocationInstanceReportCall<'a, C>
9287where
9288    C: common::Connector,
9289{
9290    /// Perform the operation you have build so far.
9291    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
9292        use std::borrow::Cow;
9293        use std::io::{Read, Seek};
9294
9295        use common::{url::Params, ToParts};
9296        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9297
9298        let mut dd = common::DefaultDelegate;
9299        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9300        dlg.begin(common::MethodInfo {
9301            id: "notebooks.projects.locations.instances.report",
9302            http_method: hyper::Method::POST,
9303        });
9304
9305        for &field in ["alt", "name"].iter() {
9306            if self._additional_params.contains_key(field) {
9307                dlg.finished(false);
9308                return Err(common::Error::FieldClash(field));
9309            }
9310        }
9311
9312        let mut params = Params::with_capacity(4 + self._additional_params.len());
9313        params.push("name", self._name);
9314
9315        params.extend(self._additional_params.iter());
9316
9317        params.push("alt", "json");
9318        let mut url = self.hub._base_url.clone() + "v1/{+name}:report";
9319        if self._scopes.is_empty() {
9320            self._scopes
9321                .insert(Scope::CloudPlatform.as_ref().to_string());
9322        }
9323
9324        #[allow(clippy::single_element_loop)]
9325        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9326            url = params.uri_replacement(url, param_name, find_this, true);
9327        }
9328        {
9329            let to_remove = ["name"];
9330            params.remove_params(&to_remove);
9331        }
9332
9333        let url = params.parse_with_url(&url);
9334
9335        let mut json_mime_type = mime::APPLICATION_JSON;
9336        let mut request_value_reader = {
9337            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9338            common::remove_json_null_values(&mut value);
9339            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9340            serde_json::to_writer(&mut dst, &value).unwrap();
9341            dst
9342        };
9343        let request_size = request_value_reader
9344            .seek(std::io::SeekFrom::End(0))
9345            .unwrap();
9346        request_value_reader
9347            .seek(std::io::SeekFrom::Start(0))
9348            .unwrap();
9349
9350        loop {
9351            let token = match self
9352                .hub
9353                .auth
9354                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9355                .await
9356            {
9357                Ok(token) => token,
9358                Err(e) => match dlg.token(e) {
9359                    Ok(token) => token,
9360                    Err(e) => {
9361                        dlg.finished(false);
9362                        return Err(common::Error::MissingToken(e));
9363                    }
9364                },
9365            };
9366            request_value_reader
9367                .seek(std::io::SeekFrom::Start(0))
9368                .unwrap();
9369            let mut req_result = {
9370                let client = &self.hub.client;
9371                dlg.pre_request();
9372                let mut req_builder = hyper::Request::builder()
9373                    .method(hyper::Method::POST)
9374                    .uri(url.as_str())
9375                    .header(USER_AGENT, self.hub._user_agent.clone());
9376
9377                if let Some(token) = token.as_ref() {
9378                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9379                }
9380
9381                let request = req_builder
9382                    .header(CONTENT_TYPE, json_mime_type.to_string())
9383                    .header(CONTENT_LENGTH, request_size as u64)
9384                    .body(common::to_body(
9385                        request_value_reader.get_ref().clone().into(),
9386                    ));
9387
9388                client.request(request.unwrap()).await
9389            };
9390
9391            match req_result {
9392                Err(err) => {
9393                    if let common::Retry::After(d) = dlg.http_error(&err) {
9394                        sleep(d).await;
9395                        continue;
9396                    }
9397                    dlg.finished(false);
9398                    return Err(common::Error::HttpError(err));
9399                }
9400                Ok(res) => {
9401                    let (mut parts, body) = res.into_parts();
9402                    let mut body = common::Body::new(body);
9403                    if !parts.status.is_success() {
9404                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9405                        let error = serde_json::from_str(&common::to_string(&bytes));
9406                        let response = common::to_response(parts, bytes.into());
9407
9408                        if let common::Retry::After(d) =
9409                            dlg.http_failure(&response, error.as_ref().ok())
9410                        {
9411                            sleep(d).await;
9412                            continue;
9413                        }
9414
9415                        dlg.finished(false);
9416
9417                        return Err(match error {
9418                            Ok(value) => common::Error::BadRequest(value),
9419                            _ => common::Error::Failure(response),
9420                        });
9421                    }
9422                    let response = {
9423                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9424                        let encoded = common::to_string(&bytes);
9425                        match serde_json::from_str(&encoded) {
9426                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9427                            Err(error) => {
9428                                dlg.response_json_decode_error(&encoded, &error);
9429                                return Err(common::Error::JsonDecodeError(
9430                                    encoded.to_string(),
9431                                    error,
9432                                ));
9433                            }
9434                        }
9435                    };
9436
9437                    dlg.finished(true);
9438                    return Ok(response);
9439                }
9440            }
9441        }
9442    }
9443
9444    ///
9445    /// Sets the *request* property to the given value.
9446    ///
9447    /// Even though the property as already been set when instantiating this call,
9448    /// we provide this method for API completeness.
9449    pub fn request(
9450        mut self,
9451        new_value: ReportInstanceInfoRequest,
9452    ) -> ProjectLocationInstanceReportCall<'a, C> {
9453        self._request = new_value;
9454        self
9455    }
9456    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
9457    ///
9458    /// Sets the *name* path property to the given value.
9459    ///
9460    /// Even though the property as already been set when instantiating this call,
9461    /// we provide this method for API completeness.
9462    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceReportCall<'a, C> {
9463        self._name = new_value.to_string();
9464        self
9465    }
9466    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9467    /// while executing the actual API request.
9468    ///
9469    /// ````text
9470    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9471    /// ````
9472    ///
9473    /// Sets the *delegate* property to the given value.
9474    pub fn delegate(
9475        mut self,
9476        new_value: &'a mut dyn common::Delegate,
9477    ) -> ProjectLocationInstanceReportCall<'a, C> {
9478        self._delegate = Some(new_value);
9479        self
9480    }
9481
9482    /// Set any additional parameter of the query string used in the request.
9483    /// It should be used to set parameters which are not yet available through their own
9484    /// setters.
9485    ///
9486    /// Please note that this method must not be used to set any of the known parameters
9487    /// which have their own setter method. If done anyway, the request will fail.
9488    ///
9489    /// # Additional Parameters
9490    ///
9491    /// * *$.xgafv* (query-string) - V1 error format.
9492    /// * *access_token* (query-string) - OAuth access token.
9493    /// * *alt* (query-string) - Data format for response.
9494    /// * *callback* (query-string) - JSONP
9495    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9496    /// * *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.
9497    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9498    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9499    /// * *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.
9500    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9501    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9502    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceReportCall<'a, C>
9503    where
9504        T: AsRef<str>,
9505    {
9506        self._additional_params
9507            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9508        self
9509    }
9510
9511    /// Identifies the authorization scope for the method you are building.
9512    ///
9513    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9514    /// [`Scope::CloudPlatform`].
9515    ///
9516    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9517    /// tokens for more than one scope.
9518    ///
9519    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9520    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9521    /// sufficient, a read-write scope will do as well.
9522    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceReportCall<'a, C>
9523    where
9524        St: AsRef<str>,
9525    {
9526        self._scopes.insert(String::from(scope.as_ref()));
9527        self
9528    }
9529    /// Identifies the authorization scope(s) for the method you are building.
9530    ///
9531    /// See [`Self::add_scope()`] for details.
9532    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceReportCall<'a, C>
9533    where
9534        I: IntoIterator<Item = St>,
9535        St: AsRef<str>,
9536    {
9537        self._scopes
9538            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9539        self
9540    }
9541
9542    /// Removes all scopes, and no default scope will be used either.
9543    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9544    /// for details).
9545    pub fn clear_scopes(mut self) -> ProjectLocationInstanceReportCall<'a, C> {
9546        self._scopes.clear();
9547        self
9548    }
9549}
9550
9551/// Reports and processes an instance event.
9552///
9553/// A builder for the *locations.instances.reportEvent* method supported by a *project* resource.
9554/// It is not used directly, but through a [`ProjectMethods`] instance.
9555///
9556/// # Example
9557///
9558/// Instantiate a resource method builder
9559///
9560/// ```test_harness,no_run
9561/// # extern crate hyper;
9562/// # extern crate hyper_rustls;
9563/// # extern crate google_notebooks1 as notebooks1;
9564/// use notebooks1::api::ReportInstanceEventRequest;
9565/// # async fn dox() {
9566/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9567///
9568/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9569/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9570/// #     secret,
9571/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9572/// # ).build().await.unwrap();
9573///
9574/// # let client = hyper_util::client::legacy::Client::builder(
9575/// #     hyper_util::rt::TokioExecutor::new()
9576/// # )
9577/// # .build(
9578/// #     hyper_rustls::HttpsConnectorBuilder::new()
9579/// #         .with_native_roots()
9580/// #         .unwrap()
9581/// #         .https_or_http()
9582/// #         .enable_http1()
9583/// #         .build()
9584/// # );
9585/// # let mut hub = AIPlatformNotebooks::new(client, auth);
9586/// // As the method needs a request, you would usually fill it with the desired information
9587/// // into the respective structure. Some of the parts shown here might not be applicable !
9588/// // Values shown here are possibly random and not representative !
9589/// let mut req = ReportInstanceEventRequest::default();
9590///
9591/// // You can configure optional parameters by calling the respective setters at will, and
9592/// // execute the final call using `doit()`.
9593/// // Values shown here are possibly random and not representative !
9594/// let result = hub.projects().locations_instances_report_event(req, "name")
9595///              .doit().await;
9596/// # }
9597/// ```
9598pub struct ProjectLocationInstanceReportEventCall<'a, C>
9599where
9600    C: 'a,
9601{
9602    hub: &'a AIPlatformNotebooks<C>,
9603    _request: ReportInstanceEventRequest,
9604    _name: String,
9605    _delegate: Option<&'a mut dyn common::Delegate>,
9606    _additional_params: HashMap<String, String>,
9607    _scopes: BTreeSet<String>,
9608}
9609
9610impl<'a, C> common::CallBuilder for ProjectLocationInstanceReportEventCall<'a, C> {}
9611
9612impl<'a, C> ProjectLocationInstanceReportEventCall<'a, C>
9613where
9614    C: common::Connector,
9615{
9616    /// Perform the operation you have build so far.
9617    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
9618        use std::borrow::Cow;
9619        use std::io::{Read, Seek};
9620
9621        use common::{url::Params, ToParts};
9622        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9623
9624        let mut dd = common::DefaultDelegate;
9625        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9626        dlg.begin(common::MethodInfo {
9627            id: "notebooks.projects.locations.instances.reportEvent",
9628            http_method: hyper::Method::POST,
9629        });
9630
9631        for &field in ["alt", "name"].iter() {
9632            if self._additional_params.contains_key(field) {
9633                dlg.finished(false);
9634                return Err(common::Error::FieldClash(field));
9635            }
9636        }
9637
9638        let mut params = Params::with_capacity(4 + self._additional_params.len());
9639        params.push("name", self._name);
9640
9641        params.extend(self._additional_params.iter());
9642
9643        params.push("alt", "json");
9644        let mut url = self.hub._base_url.clone() + "v1/{+name}:reportEvent";
9645        if self._scopes.is_empty() {
9646            self._scopes
9647                .insert(Scope::CloudPlatform.as_ref().to_string());
9648        }
9649
9650        #[allow(clippy::single_element_loop)]
9651        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9652            url = params.uri_replacement(url, param_name, find_this, true);
9653        }
9654        {
9655            let to_remove = ["name"];
9656            params.remove_params(&to_remove);
9657        }
9658
9659        let url = params.parse_with_url(&url);
9660
9661        let mut json_mime_type = mime::APPLICATION_JSON;
9662        let mut request_value_reader = {
9663            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9664            common::remove_json_null_values(&mut value);
9665            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9666            serde_json::to_writer(&mut dst, &value).unwrap();
9667            dst
9668        };
9669        let request_size = request_value_reader
9670            .seek(std::io::SeekFrom::End(0))
9671            .unwrap();
9672        request_value_reader
9673            .seek(std::io::SeekFrom::Start(0))
9674            .unwrap();
9675
9676        loop {
9677            let token = match self
9678                .hub
9679                .auth
9680                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9681                .await
9682            {
9683                Ok(token) => token,
9684                Err(e) => match dlg.token(e) {
9685                    Ok(token) => token,
9686                    Err(e) => {
9687                        dlg.finished(false);
9688                        return Err(common::Error::MissingToken(e));
9689                    }
9690                },
9691            };
9692            request_value_reader
9693                .seek(std::io::SeekFrom::Start(0))
9694                .unwrap();
9695            let mut req_result = {
9696                let client = &self.hub.client;
9697                dlg.pre_request();
9698                let mut req_builder = hyper::Request::builder()
9699                    .method(hyper::Method::POST)
9700                    .uri(url.as_str())
9701                    .header(USER_AGENT, self.hub._user_agent.clone());
9702
9703                if let Some(token) = token.as_ref() {
9704                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9705                }
9706
9707                let request = req_builder
9708                    .header(CONTENT_TYPE, json_mime_type.to_string())
9709                    .header(CONTENT_LENGTH, request_size as u64)
9710                    .body(common::to_body(
9711                        request_value_reader.get_ref().clone().into(),
9712                    ));
9713
9714                client.request(request.unwrap()).await
9715            };
9716
9717            match req_result {
9718                Err(err) => {
9719                    if let common::Retry::After(d) = dlg.http_error(&err) {
9720                        sleep(d).await;
9721                        continue;
9722                    }
9723                    dlg.finished(false);
9724                    return Err(common::Error::HttpError(err));
9725                }
9726                Ok(res) => {
9727                    let (mut parts, body) = res.into_parts();
9728                    let mut body = common::Body::new(body);
9729                    if !parts.status.is_success() {
9730                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9731                        let error = serde_json::from_str(&common::to_string(&bytes));
9732                        let response = common::to_response(parts, bytes.into());
9733
9734                        if let common::Retry::After(d) =
9735                            dlg.http_failure(&response, error.as_ref().ok())
9736                        {
9737                            sleep(d).await;
9738                            continue;
9739                        }
9740
9741                        dlg.finished(false);
9742
9743                        return Err(match error {
9744                            Ok(value) => common::Error::BadRequest(value),
9745                            _ => common::Error::Failure(response),
9746                        });
9747                    }
9748                    let response = {
9749                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9750                        let encoded = common::to_string(&bytes);
9751                        match serde_json::from_str(&encoded) {
9752                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9753                            Err(error) => {
9754                                dlg.response_json_decode_error(&encoded, &error);
9755                                return Err(common::Error::JsonDecodeError(
9756                                    encoded.to_string(),
9757                                    error,
9758                                ));
9759                            }
9760                        }
9761                    };
9762
9763                    dlg.finished(true);
9764                    return Ok(response);
9765                }
9766            }
9767        }
9768    }
9769
9770    ///
9771    /// Sets the *request* property to the given value.
9772    ///
9773    /// Even though the property as already been set when instantiating this call,
9774    /// we provide this method for API completeness.
9775    pub fn request(
9776        mut self,
9777        new_value: ReportInstanceEventRequest,
9778    ) -> ProjectLocationInstanceReportEventCall<'a, C> {
9779        self._request = new_value;
9780        self
9781    }
9782    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
9783    ///
9784    /// Sets the *name* path property to the given value.
9785    ///
9786    /// Even though the property as already been set when instantiating this call,
9787    /// we provide this method for API completeness.
9788    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceReportEventCall<'a, C> {
9789        self._name = new_value.to_string();
9790        self
9791    }
9792    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9793    /// while executing the actual API request.
9794    ///
9795    /// ````text
9796    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9797    /// ````
9798    ///
9799    /// Sets the *delegate* property to the given value.
9800    pub fn delegate(
9801        mut self,
9802        new_value: &'a mut dyn common::Delegate,
9803    ) -> ProjectLocationInstanceReportEventCall<'a, C> {
9804        self._delegate = Some(new_value);
9805        self
9806    }
9807
9808    /// Set any additional parameter of the query string used in the request.
9809    /// It should be used to set parameters which are not yet available through their own
9810    /// setters.
9811    ///
9812    /// Please note that this method must not be used to set any of the known parameters
9813    /// which have their own setter method. If done anyway, the request will fail.
9814    ///
9815    /// # Additional Parameters
9816    ///
9817    /// * *$.xgafv* (query-string) - V1 error format.
9818    /// * *access_token* (query-string) - OAuth access token.
9819    /// * *alt* (query-string) - Data format for response.
9820    /// * *callback* (query-string) - JSONP
9821    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9822    /// * *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.
9823    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9824    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9825    /// * *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.
9826    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9827    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9828    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceReportEventCall<'a, C>
9829    where
9830        T: AsRef<str>,
9831    {
9832        self._additional_params
9833            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9834        self
9835    }
9836
9837    /// Identifies the authorization scope for the method you are building.
9838    ///
9839    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9840    /// [`Scope::CloudPlatform`].
9841    ///
9842    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9843    /// tokens for more than one scope.
9844    ///
9845    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9846    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9847    /// sufficient, a read-write scope will do as well.
9848    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceReportEventCall<'a, C>
9849    where
9850        St: AsRef<str>,
9851    {
9852        self._scopes.insert(String::from(scope.as_ref()));
9853        self
9854    }
9855    /// Identifies the authorization scope(s) for the method you are building.
9856    ///
9857    /// See [`Self::add_scope()`] for details.
9858    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceReportEventCall<'a, C>
9859    where
9860        I: IntoIterator<Item = St>,
9861        St: AsRef<str>,
9862    {
9863        self._scopes
9864            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9865        self
9866    }
9867
9868    /// Removes all scopes, and no default scope will be used either.
9869    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9870    /// for details).
9871    pub fn clear_scopes(mut self) -> ProjectLocationInstanceReportEventCall<'a, C> {
9872        self._scopes.clear();
9873        self
9874    }
9875}
9876
9877/// Resets a notebook instance.
9878///
9879/// A builder for the *locations.instances.reset* method supported by a *project* resource.
9880/// It is not used directly, but through a [`ProjectMethods`] instance.
9881///
9882/// # Example
9883///
9884/// Instantiate a resource method builder
9885///
9886/// ```test_harness,no_run
9887/// # extern crate hyper;
9888/// # extern crate hyper_rustls;
9889/// # extern crate google_notebooks1 as notebooks1;
9890/// use notebooks1::api::ResetInstanceRequest;
9891/// # async fn dox() {
9892/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9893///
9894/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9895/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9896/// #     secret,
9897/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9898/// # ).build().await.unwrap();
9899///
9900/// # let client = hyper_util::client::legacy::Client::builder(
9901/// #     hyper_util::rt::TokioExecutor::new()
9902/// # )
9903/// # .build(
9904/// #     hyper_rustls::HttpsConnectorBuilder::new()
9905/// #         .with_native_roots()
9906/// #         .unwrap()
9907/// #         .https_or_http()
9908/// #         .enable_http1()
9909/// #         .build()
9910/// # );
9911/// # let mut hub = AIPlatformNotebooks::new(client, auth);
9912/// // As the method needs a request, you would usually fill it with the desired information
9913/// // into the respective structure. Some of the parts shown here might not be applicable !
9914/// // Values shown here are possibly random and not representative !
9915/// let mut req = ResetInstanceRequest::default();
9916///
9917/// // You can configure optional parameters by calling the respective setters at will, and
9918/// // execute the final call using `doit()`.
9919/// // Values shown here are possibly random and not representative !
9920/// let result = hub.projects().locations_instances_reset(req, "name")
9921///              .doit().await;
9922/// # }
9923/// ```
9924pub struct ProjectLocationInstanceResetCall<'a, C>
9925where
9926    C: 'a,
9927{
9928    hub: &'a AIPlatformNotebooks<C>,
9929    _request: ResetInstanceRequest,
9930    _name: String,
9931    _delegate: Option<&'a mut dyn common::Delegate>,
9932    _additional_params: HashMap<String, String>,
9933    _scopes: BTreeSet<String>,
9934}
9935
9936impl<'a, C> common::CallBuilder for ProjectLocationInstanceResetCall<'a, C> {}
9937
9938impl<'a, C> ProjectLocationInstanceResetCall<'a, C>
9939where
9940    C: common::Connector,
9941{
9942    /// Perform the operation you have build so far.
9943    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
9944        use std::borrow::Cow;
9945        use std::io::{Read, Seek};
9946
9947        use common::{url::Params, ToParts};
9948        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9949
9950        let mut dd = common::DefaultDelegate;
9951        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9952        dlg.begin(common::MethodInfo {
9953            id: "notebooks.projects.locations.instances.reset",
9954            http_method: hyper::Method::POST,
9955        });
9956
9957        for &field in ["alt", "name"].iter() {
9958            if self._additional_params.contains_key(field) {
9959                dlg.finished(false);
9960                return Err(common::Error::FieldClash(field));
9961            }
9962        }
9963
9964        let mut params = Params::with_capacity(4 + self._additional_params.len());
9965        params.push("name", self._name);
9966
9967        params.extend(self._additional_params.iter());
9968
9969        params.push("alt", "json");
9970        let mut url = self.hub._base_url.clone() + "v1/{+name}:reset";
9971        if self._scopes.is_empty() {
9972            self._scopes
9973                .insert(Scope::CloudPlatform.as_ref().to_string());
9974        }
9975
9976        #[allow(clippy::single_element_loop)]
9977        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9978            url = params.uri_replacement(url, param_name, find_this, true);
9979        }
9980        {
9981            let to_remove = ["name"];
9982            params.remove_params(&to_remove);
9983        }
9984
9985        let url = params.parse_with_url(&url);
9986
9987        let mut json_mime_type = mime::APPLICATION_JSON;
9988        let mut request_value_reader = {
9989            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9990            common::remove_json_null_values(&mut value);
9991            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9992            serde_json::to_writer(&mut dst, &value).unwrap();
9993            dst
9994        };
9995        let request_size = request_value_reader
9996            .seek(std::io::SeekFrom::End(0))
9997            .unwrap();
9998        request_value_reader
9999            .seek(std::io::SeekFrom::Start(0))
10000            .unwrap();
10001
10002        loop {
10003            let token = match self
10004                .hub
10005                .auth
10006                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10007                .await
10008            {
10009                Ok(token) => token,
10010                Err(e) => match dlg.token(e) {
10011                    Ok(token) => token,
10012                    Err(e) => {
10013                        dlg.finished(false);
10014                        return Err(common::Error::MissingToken(e));
10015                    }
10016                },
10017            };
10018            request_value_reader
10019                .seek(std::io::SeekFrom::Start(0))
10020                .unwrap();
10021            let mut req_result = {
10022                let client = &self.hub.client;
10023                dlg.pre_request();
10024                let mut req_builder = hyper::Request::builder()
10025                    .method(hyper::Method::POST)
10026                    .uri(url.as_str())
10027                    .header(USER_AGENT, self.hub._user_agent.clone());
10028
10029                if let Some(token) = token.as_ref() {
10030                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10031                }
10032
10033                let request = req_builder
10034                    .header(CONTENT_TYPE, json_mime_type.to_string())
10035                    .header(CONTENT_LENGTH, request_size as u64)
10036                    .body(common::to_body(
10037                        request_value_reader.get_ref().clone().into(),
10038                    ));
10039
10040                client.request(request.unwrap()).await
10041            };
10042
10043            match req_result {
10044                Err(err) => {
10045                    if let common::Retry::After(d) = dlg.http_error(&err) {
10046                        sleep(d).await;
10047                        continue;
10048                    }
10049                    dlg.finished(false);
10050                    return Err(common::Error::HttpError(err));
10051                }
10052                Ok(res) => {
10053                    let (mut parts, body) = res.into_parts();
10054                    let mut body = common::Body::new(body);
10055                    if !parts.status.is_success() {
10056                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10057                        let error = serde_json::from_str(&common::to_string(&bytes));
10058                        let response = common::to_response(parts, bytes.into());
10059
10060                        if let common::Retry::After(d) =
10061                            dlg.http_failure(&response, error.as_ref().ok())
10062                        {
10063                            sleep(d).await;
10064                            continue;
10065                        }
10066
10067                        dlg.finished(false);
10068
10069                        return Err(match error {
10070                            Ok(value) => common::Error::BadRequest(value),
10071                            _ => common::Error::Failure(response),
10072                        });
10073                    }
10074                    let response = {
10075                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10076                        let encoded = common::to_string(&bytes);
10077                        match serde_json::from_str(&encoded) {
10078                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10079                            Err(error) => {
10080                                dlg.response_json_decode_error(&encoded, &error);
10081                                return Err(common::Error::JsonDecodeError(
10082                                    encoded.to_string(),
10083                                    error,
10084                                ));
10085                            }
10086                        }
10087                    };
10088
10089                    dlg.finished(true);
10090                    return Ok(response);
10091                }
10092            }
10093        }
10094    }
10095
10096    ///
10097    /// Sets the *request* property to the given value.
10098    ///
10099    /// Even though the property as already been set when instantiating this call,
10100    /// we provide this method for API completeness.
10101    pub fn request(
10102        mut self,
10103        new_value: ResetInstanceRequest,
10104    ) -> ProjectLocationInstanceResetCall<'a, C> {
10105        self._request = new_value;
10106        self
10107    }
10108    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
10109    ///
10110    /// Sets the *name* path property to the given value.
10111    ///
10112    /// Even though the property as already been set when instantiating this call,
10113    /// we provide this method for API completeness.
10114    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceResetCall<'a, C> {
10115        self._name = new_value.to_string();
10116        self
10117    }
10118    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10119    /// while executing the actual API request.
10120    ///
10121    /// ````text
10122    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10123    /// ````
10124    ///
10125    /// Sets the *delegate* property to the given value.
10126    pub fn delegate(
10127        mut self,
10128        new_value: &'a mut dyn common::Delegate,
10129    ) -> ProjectLocationInstanceResetCall<'a, C> {
10130        self._delegate = Some(new_value);
10131        self
10132    }
10133
10134    /// Set any additional parameter of the query string used in the request.
10135    /// It should be used to set parameters which are not yet available through their own
10136    /// setters.
10137    ///
10138    /// Please note that this method must not be used to set any of the known parameters
10139    /// which have their own setter method. If done anyway, the request will fail.
10140    ///
10141    /// # Additional Parameters
10142    ///
10143    /// * *$.xgafv* (query-string) - V1 error format.
10144    /// * *access_token* (query-string) - OAuth access token.
10145    /// * *alt* (query-string) - Data format for response.
10146    /// * *callback* (query-string) - JSONP
10147    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10148    /// * *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.
10149    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10150    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10151    /// * *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.
10152    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10153    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10154    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceResetCall<'a, C>
10155    where
10156        T: AsRef<str>,
10157    {
10158        self._additional_params
10159            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10160        self
10161    }
10162
10163    /// Identifies the authorization scope for the method you are building.
10164    ///
10165    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10166    /// [`Scope::CloudPlatform`].
10167    ///
10168    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10169    /// tokens for more than one scope.
10170    ///
10171    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10172    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10173    /// sufficient, a read-write scope will do as well.
10174    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceResetCall<'a, C>
10175    where
10176        St: AsRef<str>,
10177    {
10178        self._scopes.insert(String::from(scope.as_ref()));
10179        self
10180    }
10181    /// Identifies the authorization scope(s) for the method you are building.
10182    ///
10183    /// See [`Self::add_scope()`] for details.
10184    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceResetCall<'a, C>
10185    where
10186        I: IntoIterator<Item = St>,
10187        St: AsRef<str>,
10188    {
10189        self._scopes
10190            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10191        self
10192    }
10193
10194    /// Removes all scopes, and no default scope will be used either.
10195    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10196    /// for details).
10197    pub fn clear_scopes(mut self) -> ProjectLocationInstanceResetCall<'a, C> {
10198        self._scopes.clear();
10199        self
10200    }
10201}
10202
10203/// Rollbacks a notebook instance to the previous version.
10204///
10205/// A builder for the *locations.instances.rollback* method supported by a *project* resource.
10206/// It is not used directly, but through a [`ProjectMethods`] instance.
10207///
10208/// # Example
10209///
10210/// Instantiate a resource method builder
10211///
10212/// ```test_harness,no_run
10213/// # extern crate hyper;
10214/// # extern crate hyper_rustls;
10215/// # extern crate google_notebooks1 as notebooks1;
10216/// use notebooks1::api::RollbackInstanceRequest;
10217/// # async fn dox() {
10218/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10219///
10220/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10221/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10222/// #     secret,
10223/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10224/// # ).build().await.unwrap();
10225///
10226/// # let client = hyper_util::client::legacy::Client::builder(
10227/// #     hyper_util::rt::TokioExecutor::new()
10228/// # )
10229/// # .build(
10230/// #     hyper_rustls::HttpsConnectorBuilder::new()
10231/// #         .with_native_roots()
10232/// #         .unwrap()
10233/// #         .https_or_http()
10234/// #         .enable_http1()
10235/// #         .build()
10236/// # );
10237/// # let mut hub = AIPlatformNotebooks::new(client, auth);
10238/// // As the method needs a request, you would usually fill it with the desired information
10239/// // into the respective structure. Some of the parts shown here might not be applicable !
10240/// // Values shown here are possibly random and not representative !
10241/// let mut req = RollbackInstanceRequest::default();
10242///
10243/// // You can configure optional parameters by calling the respective setters at will, and
10244/// // execute the final call using `doit()`.
10245/// // Values shown here are possibly random and not representative !
10246/// let result = hub.projects().locations_instances_rollback(req, "name")
10247///              .doit().await;
10248/// # }
10249/// ```
10250pub struct ProjectLocationInstanceRollbackCall<'a, C>
10251where
10252    C: 'a,
10253{
10254    hub: &'a AIPlatformNotebooks<C>,
10255    _request: RollbackInstanceRequest,
10256    _name: String,
10257    _delegate: Option<&'a mut dyn common::Delegate>,
10258    _additional_params: HashMap<String, String>,
10259    _scopes: BTreeSet<String>,
10260}
10261
10262impl<'a, C> common::CallBuilder for ProjectLocationInstanceRollbackCall<'a, C> {}
10263
10264impl<'a, C> ProjectLocationInstanceRollbackCall<'a, C>
10265where
10266    C: common::Connector,
10267{
10268    /// Perform the operation you have build so far.
10269    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
10270        use std::borrow::Cow;
10271        use std::io::{Read, Seek};
10272
10273        use common::{url::Params, ToParts};
10274        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10275
10276        let mut dd = common::DefaultDelegate;
10277        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10278        dlg.begin(common::MethodInfo {
10279            id: "notebooks.projects.locations.instances.rollback",
10280            http_method: hyper::Method::POST,
10281        });
10282
10283        for &field in ["alt", "name"].iter() {
10284            if self._additional_params.contains_key(field) {
10285                dlg.finished(false);
10286                return Err(common::Error::FieldClash(field));
10287            }
10288        }
10289
10290        let mut params = Params::with_capacity(4 + self._additional_params.len());
10291        params.push("name", self._name);
10292
10293        params.extend(self._additional_params.iter());
10294
10295        params.push("alt", "json");
10296        let mut url = self.hub._base_url.clone() + "v1/{+name}:rollback";
10297        if self._scopes.is_empty() {
10298            self._scopes
10299                .insert(Scope::CloudPlatform.as_ref().to_string());
10300        }
10301
10302        #[allow(clippy::single_element_loop)]
10303        for &(find_this, param_name) in [("{+name}", "name")].iter() {
10304            url = params.uri_replacement(url, param_name, find_this, true);
10305        }
10306        {
10307            let to_remove = ["name"];
10308            params.remove_params(&to_remove);
10309        }
10310
10311        let url = params.parse_with_url(&url);
10312
10313        let mut json_mime_type = mime::APPLICATION_JSON;
10314        let mut request_value_reader = {
10315            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10316            common::remove_json_null_values(&mut value);
10317            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10318            serde_json::to_writer(&mut dst, &value).unwrap();
10319            dst
10320        };
10321        let request_size = request_value_reader
10322            .seek(std::io::SeekFrom::End(0))
10323            .unwrap();
10324        request_value_reader
10325            .seek(std::io::SeekFrom::Start(0))
10326            .unwrap();
10327
10328        loop {
10329            let token = match self
10330                .hub
10331                .auth
10332                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10333                .await
10334            {
10335                Ok(token) => token,
10336                Err(e) => match dlg.token(e) {
10337                    Ok(token) => token,
10338                    Err(e) => {
10339                        dlg.finished(false);
10340                        return Err(common::Error::MissingToken(e));
10341                    }
10342                },
10343            };
10344            request_value_reader
10345                .seek(std::io::SeekFrom::Start(0))
10346                .unwrap();
10347            let mut req_result = {
10348                let client = &self.hub.client;
10349                dlg.pre_request();
10350                let mut req_builder = hyper::Request::builder()
10351                    .method(hyper::Method::POST)
10352                    .uri(url.as_str())
10353                    .header(USER_AGENT, self.hub._user_agent.clone());
10354
10355                if let Some(token) = token.as_ref() {
10356                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10357                }
10358
10359                let request = req_builder
10360                    .header(CONTENT_TYPE, json_mime_type.to_string())
10361                    .header(CONTENT_LENGTH, request_size as u64)
10362                    .body(common::to_body(
10363                        request_value_reader.get_ref().clone().into(),
10364                    ));
10365
10366                client.request(request.unwrap()).await
10367            };
10368
10369            match req_result {
10370                Err(err) => {
10371                    if let common::Retry::After(d) = dlg.http_error(&err) {
10372                        sleep(d).await;
10373                        continue;
10374                    }
10375                    dlg.finished(false);
10376                    return Err(common::Error::HttpError(err));
10377                }
10378                Ok(res) => {
10379                    let (mut parts, body) = res.into_parts();
10380                    let mut body = common::Body::new(body);
10381                    if !parts.status.is_success() {
10382                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10383                        let error = serde_json::from_str(&common::to_string(&bytes));
10384                        let response = common::to_response(parts, bytes.into());
10385
10386                        if let common::Retry::After(d) =
10387                            dlg.http_failure(&response, error.as_ref().ok())
10388                        {
10389                            sleep(d).await;
10390                            continue;
10391                        }
10392
10393                        dlg.finished(false);
10394
10395                        return Err(match error {
10396                            Ok(value) => common::Error::BadRequest(value),
10397                            _ => common::Error::Failure(response),
10398                        });
10399                    }
10400                    let response = {
10401                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10402                        let encoded = common::to_string(&bytes);
10403                        match serde_json::from_str(&encoded) {
10404                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10405                            Err(error) => {
10406                                dlg.response_json_decode_error(&encoded, &error);
10407                                return Err(common::Error::JsonDecodeError(
10408                                    encoded.to_string(),
10409                                    error,
10410                                ));
10411                            }
10412                        }
10413                    };
10414
10415                    dlg.finished(true);
10416                    return Ok(response);
10417                }
10418            }
10419        }
10420    }
10421
10422    ///
10423    /// Sets the *request* property to the given value.
10424    ///
10425    /// Even though the property as already been set when instantiating this call,
10426    /// we provide this method for API completeness.
10427    pub fn request(
10428        mut self,
10429        new_value: RollbackInstanceRequest,
10430    ) -> ProjectLocationInstanceRollbackCall<'a, C> {
10431        self._request = new_value;
10432        self
10433    }
10434    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
10435    ///
10436    /// Sets the *name* path property to the given value.
10437    ///
10438    /// Even though the property as already been set when instantiating this call,
10439    /// we provide this method for API completeness.
10440    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceRollbackCall<'a, C> {
10441        self._name = new_value.to_string();
10442        self
10443    }
10444    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10445    /// while executing the actual API request.
10446    ///
10447    /// ````text
10448    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10449    /// ````
10450    ///
10451    /// Sets the *delegate* property to the given value.
10452    pub fn delegate(
10453        mut self,
10454        new_value: &'a mut dyn common::Delegate,
10455    ) -> ProjectLocationInstanceRollbackCall<'a, C> {
10456        self._delegate = Some(new_value);
10457        self
10458    }
10459
10460    /// Set any additional parameter of the query string used in the request.
10461    /// It should be used to set parameters which are not yet available through their own
10462    /// setters.
10463    ///
10464    /// Please note that this method must not be used to set any of the known parameters
10465    /// which have their own setter method. If done anyway, the request will fail.
10466    ///
10467    /// # Additional Parameters
10468    ///
10469    /// * *$.xgafv* (query-string) - V1 error format.
10470    /// * *access_token* (query-string) - OAuth access token.
10471    /// * *alt* (query-string) - Data format for response.
10472    /// * *callback* (query-string) - JSONP
10473    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10474    /// * *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.
10475    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10476    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10477    /// * *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.
10478    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10479    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10480    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceRollbackCall<'a, C>
10481    where
10482        T: AsRef<str>,
10483    {
10484        self._additional_params
10485            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10486        self
10487    }
10488
10489    /// Identifies the authorization scope for the method you are building.
10490    ///
10491    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10492    /// [`Scope::CloudPlatform`].
10493    ///
10494    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10495    /// tokens for more than one scope.
10496    ///
10497    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10498    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10499    /// sufficient, a read-write scope will do as well.
10500    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceRollbackCall<'a, C>
10501    where
10502        St: AsRef<str>,
10503    {
10504        self._scopes.insert(String::from(scope.as_ref()));
10505        self
10506    }
10507    /// Identifies the authorization scope(s) for the method you are building.
10508    ///
10509    /// See [`Self::add_scope()`] for details.
10510    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceRollbackCall<'a, C>
10511    where
10512        I: IntoIterator<Item = St>,
10513        St: AsRef<str>,
10514    {
10515        self._scopes
10516            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10517        self
10518    }
10519
10520    /// Removes all scopes, and no default scope will be used either.
10521    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10522    /// for details).
10523    pub fn clear_scopes(mut self) -> ProjectLocationInstanceRollbackCall<'a, C> {
10524        self._scopes.clear();
10525        self
10526    }
10527}
10528
10529/// Updates the guest accelerators of a single Instance.
10530///
10531/// A builder for the *locations.instances.setAccelerator* method supported by a *project* resource.
10532/// It is not used directly, but through a [`ProjectMethods`] instance.
10533///
10534/// # Example
10535///
10536/// Instantiate a resource method builder
10537///
10538/// ```test_harness,no_run
10539/// # extern crate hyper;
10540/// # extern crate hyper_rustls;
10541/// # extern crate google_notebooks1 as notebooks1;
10542/// use notebooks1::api::SetInstanceAcceleratorRequest;
10543/// # async fn dox() {
10544/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10545///
10546/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10547/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10548/// #     secret,
10549/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10550/// # ).build().await.unwrap();
10551///
10552/// # let client = hyper_util::client::legacy::Client::builder(
10553/// #     hyper_util::rt::TokioExecutor::new()
10554/// # )
10555/// # .build(
10556/// #     hyper_rustls::HttpsConnectorBuilder::new()
10557/// #         .with_native_roots()
10558/// #         .unwrap()
10559/// #         .https_or_http()
10560/// #         .enable_http1()
10561/// #         .build()
10562/// # );
10563/// # let mut hub = AIPlatformNotebooks::new(client, auth);
10564/// // As the method needs a request, you would usually fill it with the desired information
10565/// // into the respective structure. Some of the parts shown here might not be applicable !
10566/// // Values shown here are possibly random and not representative !
10567/// let mut req = SetInstanceAcceleratorRequest::default();
10568///
10569/// // You can configure optional parameters by calling the respective setters at will, and
10570/// // execute the final call using `doit()`.
10571/// // Values shown here are possibly random and not representative !
10572/// let result = hub.projects().locations_instances_set_accelerator(req, "name")
10573///              .doit().await;
10574/// # }
10575/// ```
10576pub struct ProjectLocationInstanceSetAcceleratorCall<'a, C>
10577where
10578    C: 'a,
10579{
10580    hub: &'a AIPlatformNotebooks<C>,
10581    _request: SetInstanceAcceleratorRequest,
10582    _name: String,
10583    _delegate: Option<&'a mut dyn common::Delegate>,
10584    _additional_params: HashMap<String, String>,
10585    _scopes: BTreeSet<String>,
10586}
10587
10588impl<'a, C> common::CallBuilder for ProjectLocationInstanceSetAcceleratorCall<'a, C> {}
10589
10590impl<'a, C> ProjectLocationInstanceSetAcceleratorCall<'a, C>
10591where
10592    C: common::Connector,
10593{
10594    /// Perform the operation you have build so far.
10595    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
10596        use std::borrow::Cow;
10597        use std::io::{Read, Seek};
10598
10599        use common::{url::Params, ToParts};
10600        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10601
10602        let mut dd = common::DefaultDelegate;
10603        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10604        dlg.begin(common::MethodInfo {
10605            id: "notebooks.projects.locations.instances.setAccelerator",
10606            http_method: hyper::Method::PATCH,
10607        });
10608
10609        for &field in ["alt", "name"].iter() {
10610            if self._additional_params.contains_key(field) {
10611                dlg.finished(false);
10612                return Err(common::Error::FieldClash(field));
10613            }
10614        }
10615
10616        let mut params = Params::with_capacity(4 + self._additional_params.len());
10617        params.push("name", self._name);
10618
10619        params.extend(self._additional_params.iter());
10620
10621        params.push("alt", "json");
10622        let mut url = self.hub._base_url.clone() + "v1/{+name}:setAccelerator";
10623        if self._scopes.is_empty() {
10624            self._scopes
10625                .insert(Scope::CloudPlatform.as_ref().to_string());
10626        }
10627
10628        #[allow(clippy::single_element_loop)]
10629        for &(find_this, param_name) in [("{+name}", "name")].iter() {
10630            url = params.uri_replacement(url, param_name, find_this, true);
10631        }
10632        {
10633            let to_remove = ["name"];
10634            params.remove_params(&to_remove);
10635        }
10636
10637        let url = params.parse_with_url(&url);
10638
10639        let mut json_mime_type = mime::APPLICATION_JSON;
10640        let mut request_value_reader = {
10641            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10642            common::remove_json_null_values(&mut value);
10643            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10644            serde_json::to_writer(&mut dst, &value).unwrap();
10645            dst
10646        };
10647        let request_size = request_value_reader
10648            .seek(std::io::SeekFrom::End(0))
10649            .unwrap();
10650        request_value_reader
10651            .seek(std::io::SeekFrom::Start(0))
10652            .unwrap();
10653
10654        loop {
10655            let token = match self
10656                .hub
10657                .auth
10658                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10659                .await
10660            {
10661                Ok(token) => token,
10662                Err(e) => match dlg.token(e) {
10663                    Ok(token) => token,
10664                    Err(e) => {
10665                        dlg.finished(false);
10666                        return Err(common::Error::MissingToken(e));
10667                    }
10668                },
10669            };
10670            request_value_reader
10671                .seek(std::io::SeekFrom::Start(0))
10672                .unwrap();
10673            let mut req_result = {
10674                let client = &self.hub.client;
10675                dlg.pre_request();
10676                let mut req_builder = hyper::Request::builder()
10677                    .method(hyper::Method::PATCH)
10678                    .uri(url.as_str())
10679                    .header(USER_AGENT, self.hub._user_agent.clone());
10680
10681                if let Some(token) = token.as_ref() {
10682                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10683                }
10684
10685                let request = req_builder
10686                    .header(CONTENT_TYPE, json_mime_type.to_string())
10687                    .header(CONTENT_LENGTH, request_size as u64)
10688                    .body(common::to_body(
10689                        request_value_reader.get_ref().clone().into(),
10690                    ));
10691
10692                client.request(request.unwrap()).await
10693            };
10694
10695            match req_result {
10696                Err(err) => {
10697                    if let common::Retry::After(d) = dlg.http_error(&err) {
10698                        sleep(d).await;
10699                        continue;
10700                    }
10701                    dlg.finished(false);
10702                    return Err(common::Error::HttpError(err));
10703                }
10704                Ok(res) => {
10705                    let (mut parts, body) = res.into_parts();
10706                    let mut body = common::Body::new(body);
10707                    if !parts.status.is_success() {
10708                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10709                        let error = serde_json::from_str(&common::to_string(&bytes));
10710                        let response = common::to_response(parts, bytes.into());
10711
10712                        if let common::Retry::After(d) =
10713                            dlg.http_failure(&response, error.as_ref().ok())
10714                        {
10715                            sleep(d).await;
10716                            continue;
10717                        }
10718
10719                        dlg.finished(false);
10720
10721                        return Err(match error {
10722                            Ok(value) => common::Error::BadRequest(value),
10723                            _ => common::Error::Failure(response),
10724                        });
10725                    }
10726                    let response = {
10727                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10728                        let encoded = common::to_string(&bytes);
10729                        match serde_json::from_str(&encoded) {
10730                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10731                            Err(error) => {
10732                                dlg.response_json_decode_error(&encoded, &error);
10733                                return Err(common::Error::JsonDecodeError(
10734                                    encoded.to_string(),
10735                                    error,
10736                                ));
10737                            }
10738                        }
10739                    };
10740
10741                    dlg.finished(true);
10742                    return Ok(response);
10743                }
10744            }
10745        }
10746    }
10747
10748    ///
10749    /// Sets the *request* property to the given value.
10750    ///
10751    /// Even though the property as already been set when instantiating this call,
10752    /// we provide this method for API completeness.
10753    pub fn request(
10754        mut self,
10755        new_value: SetInstanceAcceleratorRequest,
10756    ) -> ProjectLocationInstanceSetAcceleratorCall<'a, C> {
10757        self._request = new_value;
10758        self
10759    }
10760    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
10761    ///
10762    /// Sets the *name* path property to the given value.
10763    ///
10764    /// Even though the property as already been set when instantiating this call,
10765    /// we provide this method for API completeness.
10766    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceSetAcceleratorCall<'a, C> {
10767        self._name = new_value.to_string();
10768        self
10769    }
10770    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10771    /// while executing the actual API request.
10772    ///
10773    /// ````text
10774    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10775    /// ````
10776    ///
10777    /// Sets the *delegate* property to the given value.
10778    pub fn delegate(
10779        mut self,
10780        new_value: &'a mut dyn common::Delegate,
10781    ) -> ProjectLocationInstanceSetAcceleratorCall<'a, C> {
10782        self._delegate = Some(new_value);
10783        self
10784    }
10785
10786    /// Set any additional parameter of the query string used in the request.
10787    /// It should be used to set parameters which are not yet available through their own
10788    /// setters.
10789    ///
10790    /// Please note that this method must not be used to set any of the known parameters
10791    /// which have their own setter method. If done anyway, the request will fail.
10792    ///
10793    /// # Additional Parameters
10794    ///
10795    /// * *$.xgafv* (query-string) - V1 error format.
10796    /// * *access_token* (query-string) - OAuth access token.
10797    /// * *alt* (query-string) - Data format for response.
10798    /// * *callback* (query-string) - JSONP
10799    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10800    /// * *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.
10801    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10802    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10803    /// * *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.
10804    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10805    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10806    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceSetAcceleratorCall<'a, C>
10807    where
10808        T: AsRef<str>,
10809    {
10810        self._additional_params
10811            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10812        self
10813    }
10814
10815    /// Identifies the authorization scope for the method you are building.
10816    ///
10817    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10818    /// [`Scope::CloudPlatform`].
10819    ///
10820    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10821    /// tokens for more than one scope.
10822    ///
10823    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10824    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10825    /// sufficient, a read-write scope will do as well.
10826    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceSetAcceleratorCall<'a, C>
10827    where
10828        St: AsRef<str>,
10829    {
10830        self._scopes.insert(String::from(scope.as_ref()));
10831        self
10832    }
10833    /// Identifies the authorization scope(s) for the method you are building.
10834    ///
10835    /// See [`Self::add_scope()`] for details.
10836    pub fn add_scopes<I, St>(
10837        mut self,
10838        scopes: I,
10839    ) -> ProjectLocationInstanceSetAcceleratorCall<'a, C>
10840    where
10841        I: IntoIterator<Item = St>,
10842        St: AsRef<str>,
10843    {
10844        self._scopes
10845            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10846        self
10847    }
10848
10849    /// Removes all scopes, and no default scope will be used either.
10850    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10851    /// for details).
10852    pub fn clear_scopes(mut self) -> ProjectLocationInstanceSetAcceleratorCall<'a, C> {
10853        self._scopes.clear();
10854        self
10855    }
10856}
10857
10858/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
10859///
10860/// A builder for the *locations.instances.setIamPolicy* method supported by a *project* resource.
10861/// It is not used directly, but through a [`ProjectMethods`] instance.
10862///
10863/// # Example
10864///
10865/// Instantiate a resource method builder
10866///
10867/// ```test_harness,no_run
10868/// # extern crate hyper;
10869/// # extern crate hyper_rustls;
10870/// # extern crate google_notebooks1 as notebooks1;
10871/// use notebooks1::api::SetIamPolicyRequest;
10872/// # async fn dox() {
10873/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10874///
10875/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10876/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10877/// #     secret,
10878/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10879/// # ).build().await.unwrap();
10880///
10881/// # let client = hyper_util::client::legacy::Client::builder(
10882/// #     hyper_util::rt::TokioExecutor::new()
10883/// # )
10884/// # .build(
10885/// #     hyper_rustls::HttpsConnectorBuilder::new()
10886/// #         .with_native_roots()
10887/// #         .unwrap()
10888/// #         .https_or_http()
10889/// #         .enable_http1()
10890/// #         .build()
10891/// # );
10892/// # let mut hub = AIPlatformNotebooks::new(client, auth);
10893/// // As the method needs a request, you would usually fill it with the desired information
10894/// // into the respective structure. Some of the parts shown here might not be applicable !
10895/// // Values shown here are possibly random and not representative !
10896/// let mut req = SetIamPolicyRequest::default();
10897///
10898/// // You can configure optional parameters by calling the respective setters at will, and
10899/// // execute the final call using `doit()`.
10900/// // Values shown here are possibly random and not representative !
10901/// let result = hub.projects().locations_instances_set_iam_policy(req, "resource")
10902///              .doit().await;
10903/// # }
10904/// ```
10905pub struct ProjectLocationInstanceSetIamPolicyCall<'a, C>
10906where
10907    C: 'a,
10908{
10909    hub: &'a AIPlatformNotebooks<C>,
10910    _request: SetIamPolicyRequest,
10911    _resource: String,
10912    _delegate: Option<&'a mut dyn common::Delegate>,
10913    _additional_params: HashMap<String, String>,
10914    _scopes: BTreeSet<String>,
10915}
10916
10917impl<'a, C> common::CallBuilder for ProjectLocationInstanceSetIamPolicyCall<'a, C> {}
10918
10919impl<'a, C> ProjectLocationInstanceSetIamPolicyCall<'a, C>
10920where
10921    C: common::Connector,
10922{
10923    /// Perform the operation you have build so far.
10924    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
10925        use std::borrow::Cow;
10926        use std::io::{Read, Seek};
10927
10928        use common::{url::Params, ToParts};
10929        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10930
10931        let mut dd = common::DefaultDelegate;
10932        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10933        dlg.begin(common::MethodInfo {
10934            id: "notebooks.projects.locations.instances.setIamPolicy",
10935            http_method: hyper::Method::POST,
10936        });
10937
10938        for &field in ["alt", "resource"].iter() {
10939            if self._additional_params.contains_key(field) {
10940                dlg.finished(false);
10941                return Err(common::Error::FieldClash(field));
10942            }
10943        }
10944
10945        let mut params = Params::with_capacity(4 + self._additional_params.len());
10946        params.push("resource", self._resource);
10947
10948        params.extend(self._additional_params.iter());
10949
10950        params.push("alt", "json");
10951        let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
10952        if self._scopes.is_empty() {
10953            self._scopes
10954                .insert(Scope::CloudPlatform.as_ref().to_string());
10955        }
10956
10957        #[allow(clippy::single_element_loop)]
10958        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
10959            url = params.uri_replacement(url, param_name, find_this, true);
10960        }
10961        {
10962            let to_remove = ["resource"];
10963            params.remove_params(&to_remove);
10964        }
10965
10966        let url = params.parse_with_url(&url);
10967
10968        let mut json_mime_type = mime::APPLICATION_JSON;
10969        let mut request_value_reader = {
10970            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10971            common::remove_json_null_values(&mut value);
10972            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10973            serde_json::to_writer(&mut dst, &value).unwrap();
10974            dst
10975        };
10976        let request_size = request_value_reader
10977            .seek(std::io::SeekFrom::End(0))
10978            .unwrap();
10979        request_value_reader
10980            .seek(std::io::SeekFrom::Start(0))
10981            .unwrap();
10982
10983        loop {
10984            let token = match self
10985                .hub
10986                .auth
10987                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10988                .await
10989            {
10990                Ok(token) => token,
10991                Err(e) => match dlg.token(e) {
10992                    Ok(token) => token,
10993                    Err(e) => {
10994                        dlg.finished(false);
10995                        return Err(common::Error::MissingToken(e));
10996                    }
10997                },
10998            };
10999            request_value_reader
11000                .seek(std::io::SeekFrom::Start(0))
11001                .unwrap();
11002            let mut req_result = {
11003                let client = &self.hub.client;
11004                dlg.pre_request();
11005                let mut req_builder = hyper::Request::builder()
11006                    .method(hyper::Method::POST)
11007                    .uri(url.as_str())
11008                    .header(USER_AGENT, self.hub._user_agent.clone());
11009
11010                if let Some(token) = token.as_ref() {
11011                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11012                }
11013
11014                let request = req_builder
11015                    .header(CONTENT_TYPE, json_mime_type.to_string())
11016                    .header(CONTENT_LENGTH, request_size as u64)
11017                    .body(common::to_body(
11018                        request_value_reader.get_ref().clone().into(),
11019                    ));
11020
11021                client.request(request.unwrap()).await
11022            };
11023
11024            match req_result {
11025                Err(err) => {
11026                    if let common::Retry::After(d) = dlg.http_error(&err) {
11027                        sleep(d).await;
11028                        continue;
11029                    }
11030                    dlg.finished(false);
11031                    return Err(common::Error::HttpError(err));
11032                }
11033                Ok(res) => {
11034                    let (mut parts, body) = res.into_parts();
11035                    let mut body = common::Body::new(body);
11036                    if !parts.status.is_success() {
11037                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11038                        let error = serde_json::from_str(&common::to_string(&bytes));
11039                        let response = common::to_response(parts, bytes.into());
11040
11041                        if let common::Retry::After(d) =
11042                            dlg.http_failure(&response, error.as_ref().ok())
11043                        {
11044                            sleep(d).await;
11045                            continue;
11046                        }
11047
11048                        dlg.finished(false);
11049
11050                        return Err(match error {
11051                            Ok(value) => common::Error::BadRequest(value),
11052                            _ => common::Error::Failure(response),
11053                        });
11054                    }
11055                    let response = {
11056                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11057                        let encoded = common::to_string(&bytes);
11058                        match serde_json::from_str(&encoded) {
11059                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11060                            Err(error) => {
11061                                dlg.response_json_decode_error(&encoded, &error);
11062                                return Err(common::Error::JsonDecodeError(
11063                                    encoded.to_string(),
11064                                    error,
11065                                ));
11066                            }
11067                        }
11068                    };
11069
11070                    dlg.finished(true);
11071                    return Ok(response);
11072                }
11073            }
11074        }
11075    }
11076
11077    ///
11078    /// Sets the *request* property to the given value.
11079    ///
11080    /// Even though the property as already been set when instantiating this call,
11081    /// we provide this method for API completeness.
11082    pub fn request(
11083        mut self,
11084        new_value: SetIamPolicyRequest,
11085    ) -> ProjectLocationInstanceSetIamPolicyCall<'a, C> {
11086        self._request = new_value;
11087        self
11088    }
11089    /// 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.
11090    ///
11091    /// Sets the *resource* path property to the given value.
11092    ///
11093    /// Even though the property as already been set when instantiating this call,
11094    /// we provide this method for API completeness.
11095    pub fn resource(mut self, new_value: &str) -> ProjectLocationInstanceSetIamPolicyCall<'a, C> {
11096        self._resource = new_value.to_string();
11097        self
11098    }
11099    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11100    /// while executing the actual API request.
11101    ///
11102    /// ````text
11103    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11104    /// ````
11105    ///
11106    /// Sets the *delegate* property to the given value.
11107    pub fn delegate(
11108        mut self,
11109        new_value: &'a mut dyn common::Delegate,
11110    ) -> ProjectLocationInstanceSetIamPolicyCall<'a, C> {
11111        self._delegate = Some(new_value);
11112        self
11113    }
11114
11115    /// Set any additional parameter of the query string used in the request.
11116    /// It should be used to set parameters which are not yet available through their own
11117    /// setters.
11118    ///
11119    /// Please note that this method must not be used to set any of the known parameters
11120    /// which have their own setter method. If done anyway, the request will fail.
11121    ///
11122    /// # Additional Parameters
11123    ///
11124    /// * *$.xgafv* (query-string) - V1 error format.
11125    /// * *access_token* (query-string) - OAuth access token.
11126    /// * *alt* (query-string) - Data format for response.
11127    /// * *callback* (query-string) - JSONP
11128    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11129    /// * *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.
11130    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11131    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11132    /// * *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.
11133    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11134    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11135    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceSetIamPolicyCall<'a, C>
11136    where
11137        T: AsRef<str>,
11138    {
11139        self._additional_params
11140            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11141        self
11142    }
11143
11144    /// Identifies the authorization scope for the method you are building.
11145    ///
11146    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11147    /// [`Scope::CloudPlatform`].
11148    ///
11149    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11150    /// tokens for more than one scope.
11151    ///
11152    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11153    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11154    /// sufficient, a read-write scope will do as well.
11155    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceSetIamPolicyCall<'a, C>
11156    where
11157        St: AsRef<str>,
11158    {
11159        self._scopes.insert(String::from(scope.as_ref()));
11160        self
11161    }
11162    /// Identifies the authorization scope(s) for the method you are building.
11163    ///
11164    /// See [`Self::add_scope()`] for details.
11165    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceSetIamPolicyCall<'a, C>
11166    where
11167        I: IntoIterator<Item = St>,
11168        St: AsRef<str>,
11169    {
11170        self._scopes
11171            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11172        self
11173    }
11174
11175    /// Removes all scopes, and no default scope will be used either.
11176    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11177    /// for details).
11178    pub fn clear_scopes(mut self) -> ProjectLocationInstanceSetIamPolicyCall<'a, C> {
11179        self._scopes.clear();
11180        self
11181    }
11182}
11183
11184/// Replaces all the labels of an Instance.
11185///
11186/// A builder for the *locations.instances.setLabels* method supported by a *project* resource.
11187/// It is not used directly, but through a [`ProjectMethods`] instance.
11188///
11189/// # Example
11190///
11191/// Instantiate a resource method builder
11192///
11193/// ```test_harness,no_run
11194/// # extern crate hyper;
11195/// # extern crate hyper_rustls;
11196/// # extern crate google_notebooks1 as notebooks1;
11197/// use notebooks1::api::SetInstanceLabelsRequest;
11198/// # async fn dox() {
11199/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11200///
11201/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11202/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11203/// #     secret,
11204/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11205/// # ).build().await.unwrap();
11206///
11207/// # let client = hyper_util::client::legacy::Client::builder(
11208/// #     hyper_util::rt::TokioExecutor::new()
11209/// # )
11210/// # .build(
11211/// #     hyper_rustls::HttpsConnectorBuilder::new()
11212/// #         .with_native_roots()
11213/// #         .unwrap()
11214/// #         .https_or_http()
11215/// #         .enable_http1()
11216/// #         .build()
11217/// # );
11218/// # let mut hub = AIPlatformNotebooks::new(client, auth);
11219/// // As the method needs a request, you would usually fill it with the desired information
11220/// // into the respective structure. Some of the parts shown here might not be applicable !
11221/// // Values shown here are possibly random and not representative !
11222/// let mut req = SetInstanceLabelsRequest::default();
11223///
11224/// // You can configure optional parameters by calling the respective setters at will, and
11225/// // execute the final call using `doit()`.
11226/// // Values shown here are possibly random and not representative !
11227/// let result = hub.projects().locations_instances_set_labels(req, "name")
11228///              .doit().await;
11229/// # }
11230/// ```
11231pub struct ProjectLocationInstanceSetLabelCall<'a, C>
11232where
11233    C: 'a,
11234{
11235    hub: &'a AIPlatformNotebooks<C>,
11236    _request: SetInstanceLabelsRequest,
11237    _name: String,
11238    _delegate: Option<&'a mut dyn common::Delegate>,
11239    _additional_params: HashMap<String, String>,
11240    _scopes: BTreeSet<String>,
11241}
11242
11243impl<'a, C> common::CallBuilder for ProjectLocationInstanceSetLabelCall<'a, C> {}
11244
11245impl<'a, C> ProjectLocationInstanceSetLabelCall<'a, C>
11246where
11247    C: common::Connector,
11248{
11249    /// Perform the operation you have build so far.
11250    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
11251        use std::borrow::Cow;
11252        use std::io::{Read, Seek};
11253
11254        use common::{url::Params, ToParts};
11255        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11256
11257        let mut dd = common::DefaultDelegate;
11258        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11259        dlg.begin(common::MethodInfo {
11260            id: "notebooks.projects.locations.instances.setLabels",
11261            http_method: hyper::Method::PATCH,
11262        });
11263
11264        for &field in ["alt", "name"].iter() {
11265            if self._additional_params.contains_key(field) {
11266                dlg.finished(false);
11267                return Err(common::Error::FieldClash(field));
11268            }
11269        }
11270
11271        let mut params = Params::with_capacity(4 + self._additional_params.len());
11272        params.push("name", self._name);
11273
11274        params.extend(self._additional_params.iter());
11275
11276        params.push("alt", "json");
11277        let mut url = self.hub._base_url.clone() + "v1/{+name}:setLabels";
11278        if self._scopes.is_empty() {
11279            self._scopes
11280                .insert(Scope::CloudPlatform.as_ref().to_string());
11281        }
11282
11283        #[allow(clippy::single_element_loop)]
11284        for &(find_this, param_name) in [("{+name}", "name")].iter() {
11285            url = params.uri_replacement(url, param_name, find_this, true);
11286        }
11287        {
11288            let to_remove = ["name"];
11289            params.remove_params(&to_remove);
11290        }
11291
11292        let url = params.parse_with_url(&url);
11293
11294        let mut json_mime_type = mime::APPLICATION_JSON;
11295        let mut request_value_reader = {
11296            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11297            common::remove_json_null_values(&mut value);
11298            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11299            serde_json::to_writer(&mut dst, &value).unwrap();
11300            dst
11301        };
11302        let request_size = request_value_reader
11303            .seek(std::io::SeekFrom::End(0))
11304            .unwrap();
11305        request_value_reader
11306            .seek(std::io::SeekFrom::Start(0))
11307            .unwrap();
11308
11309        loop {
11310            let token = match self
11311                .hub
11312                .auth
11313                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11314                .await
11315            {
11316                Ok(token) => token,
11317                Err(e) => match dlg.token(e) {
11318                    Ok(token) => token,
11319                    Err(e) => {
11320                        dlg.finished(false);
11321                        return Err(common::Error::MissingToken(e));
11322                    }
11323                },
11324            };
11325            request_value_reader
11326                .seek(std::io::SeekFrom::Start(0))
11327                .unwrap();
11328            let mut req_result = {
11329                let client = &self.hub.client;
11330                dlg.pre_request();
11331                let mut req_builder = hyper::Request::builder()
11332                    .method(hyper::Method::PATCH)
11333                    .uri(url.as_str())
11334                    .header(USER_AGENT, self.hub._user_agent.clone());
11335
11336                if let Some(token) = token.as_ref() {
11337                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11338                }
11339
11340                let request = req_builder
11341                    .header(CONTENT_TYPE, json_mime_type.to_string())
11342                    .header(CONTENT_LENGTH, request_size as u64)
11343                    .body(common::to_body(
11344                        request_value_reader.get_ref().clone().into(),
11345                    ));
11346
11347                client.request(request.unwrap()).await
11348            };
11349
11350            match req_result {
11351                Err(err) => {
11352                    if let common::Retry::After(d) = dlg.http_error(&err) {
11353                        sleep(d).await;
11354                        continue;
11355                    }
11356                    dlg.finished(false);
11357                    return Err(common::Error::HttpError(err));
11358                }
11359                Ok(res) => {
11360                    let (mut parts, body) = res.into_parts();
11361                    let mut body = common::Body::new(body);
11362                    if !parts.status.is_success() {
11363                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11364                        let error = serde_json::from_str(&common::to_string(&bytes));
11365                        let response = common::to_response(parts, bytes.into());
11366
11367                        if let common::Retry::After(d) =
11368                            dlg.http_failure(&response, error.as_ref().ok())
11369                        {
11370                            sleep(d).await;
11371                            continue;
11372                        }
11373
11374                        dlg.finished(false);
11375
11376                        return Err(match error {
11377                            Ok(value) => common::Error::BadRequest(value),
11378                            _ => common::Error::Failure(response),
11379                        });
11380                    }
11381                    let response = {
11382                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11383                        let encoded = common::to_string(&bytes);
11384                        match serde_json::from_str(&encoded) {
11385                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11386                            Err(error) => {
11387                                dlg.response_json_decode_error(&encoded, &error);
11388                                return Err(common::Error::JsonDecodeError(
11389                                    encoded.to_string(),
11390                                    error,
11391                                ));
11392                            }
11393                        }
11394                    };
11395
11396                    dlg.finished(true);
11397                    return Ok(response);
11398                }
11399            }
11400        }
11401    }
11402
11403    ///
11404    /// Sets the *request* property to the given value.
11405    ///
11406    /// Even though the property as already been set when instantiating this call,
11407    /// we provide this method for API completeness.
11408    pub fn request(
11409        mut self,
11410        new_value: SetInstanceLabelsRequest,
11411    ) -> ProjectLocationInstanceSetLabelCall<'a, C> {
11412        self._request = new_value;
11413        self
11414    }
11415    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
11416    ///
11417    /// Sets the *name* path property to the given value.
11418    ///
11419    /// Even though the property as already been set when instantiating this call,
11420    /// we provide this method for API completeness.
11421    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceSetLabelCall<'a, C> {
11422        self._name = new_value.to_string();
11423        self
11424    }
11425    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11426    /// while executing the actual API request.
11427    ///
11428    /// ````text
11429    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11430    /// ````
11431    ///
11432    /// Sets the *delegate* property to the given value.
11433    pub fn delegate(
11434        mut self,
11435        new_value: &'a mut dyn common::Delegate,
11436    ) -> ProjectLocationInstanceSetLabelCall<'a, C> {
11437        self._delegate = Some(new_value);
11438        self
11439    }
11440
11441    /// Set any additional parameter of the query string used in the request.
11442    /// It should be used to set parameters which are not yet available through their own
11443    /// setters.
11444    ///
11445    /// Please note that this method must not be used to set any of the known parameters
11446    /// which have their own setter method. If done anyway, the request will fail.
11447    ///
11448    /// # Additional Parameters
11449    ///
11450    /// * *$.xgafv* (query-string) - V1 error format.
11451    /// * *access_token* (query-string) - OAuth access token.
11452    /// * *alt* (query-string) - Data format for response.
11453    /// * *callback* (query-string) - JSONP
11454    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11455    /// * *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.
11456    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11457    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11458    /// * *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.
11459    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11460    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11461    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceSetLabelCall<'a, C>
11462    where
11463        T: AsRef<str>,
11464    {
11465        self._additional_params
11466            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11467        self
11468    }
11469
11470    /// Identifies the authorization scope for the method you are building.
11471    ///
11472    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11473    /// [`Scope::CloudPlatform`].
11474    ///
11475    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11476    /// tokens for more than one scope.
11477    ///
11478    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11479    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11480    /// sufficient, a read-write scope will do as well.
11481    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceSetLabelCall<'a, C>
11482    where
11483        St: AsRef<str>,
11484    {
11485        self._scopes.insert(String::from(scope.as_ref()));
11486        self
11487    }
11488    /// Identifies the authorization scope(s) for the method you are building.
11489    ///
11490    /// See [`Self::add_scope()`] for details.
11491    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceSetLabelCall<'a, C>
11492    where
11493        I: IntoIterator<Item = St>,
11494        St: AsRef<str>,
11495    {
11496        self._scopes
11497            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11498        self
11499    }
11500
11501    /// Removes all scopes, and no default scope will be used either.
11502    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11503    /// for details).
11504    pub fn clear_scopes(mut self) -> ProjectLocationInstanceSetLabelCall<'a, C> {
11505        self._scopes.clear();
11506        self
11507    }
11508}
11509
11510/// Updates the machine type of a single Instance.
11511///
11512/// A builder for the *locations.instances.setMachineType* method supported by a *project* resource.
11513/// It is not used directly, but through a [`ProjectMethods`] instance.
11514///
11515/// # Example
11516///
11517/// Instantiate a resource method builder
11518///
11519/// ```test_harness,no_run
11520/// # extern crate hyper;
11521/// # extern crate hyper_rustls;
11522/// # extern crate google_notebooks1 as notebooks1;
11523/// use notebooks1::api::SetInstanceMachineTypeRequest;
11524/// # async fn dox() {
11525/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11526///
11527/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11528/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11529/// #     secret,
11530/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11531/// # ).build().await.unwrap();
11532///
11533/// # let client = hyper_util::client::legacy::Client::builder(
11534/// #     hyper_util::rt::TokioExecutor::new()
11535/// # )
11536/// # .build(
11537/// #     hyper_rustls::HttpsConnectorBuilder::new()
11538/// #         .with_native_roots()
11539/// #         .unwrap()
11540/// #         .https_or_http()
11541/// #         .enable_http1()
11542/// #         .build()
11543/// # );
11544/// # let mut hub = AIPlatformNotebooks::new(client, auth);
11545/// // As the method needs a request, you would usually fill it with the desired information
11546/// // into the respective structure. Some of the parts shown here might not be applicable !
11547/// // Values shown here are possibly random and not representative !
11548/// let mut req = SetInstanceMachineTypeRequest::default();
11549///
11550/// // You can configure optional parameters by calling the respective setters at will, and
11551/// // execute the final call using `doit()`.
11552/// // Values shown here are possibly random and not representative !
11553/// let result = hub.projects().locations_instances_set_machine_type(req, "name")
11554///              .doit().await;
11555/// # }
11556/// ```
11557pub struct ProjectLocationInstanceSetMachineTypeCall<'a, C>
11558where
11559    C: 'a,
11560{
11561    hub: &'a AIPlatformNotebooks<C>,
11562    _request: SetInstanceMachineTypeRequest,
11563    _name: String,
11564    _delegate: Option<&'a mut dyn common::Delegate>,
11565    _additional_params: HashMap<String, String>,
11566    _scopes: BTreeSet<String>,
11567}
11568
11569impl<'a, C> common::CallBuilder for ProjectLocationInstanceSetMachineTypeCall<'a, C> {}
11570
11571impl<'a, C> ProjectLocationInstanceSetMachineTypeCall<'a, C>
11572where
11573    C: common::Connector,
11574{
11575    /// Perform the operation you have build so far.
11576    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
11577        use std::borrow::Cow;
11578        use std::io::{Read, Seek};
11579
11580        use common::{url::Params, ToParts};
11581        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11582
11583        let mut dd = common::DefaultDelegate;
11584        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11585        dlg.begin(common::MethodInfo {
11586            id: "notebooks.projects.locations.instances.setMachineType",
11587            http_method: hyper::Method::PATCH,
11588        });
11589
11590        for &field in ["alt", "name"].iter() {
11591            if self._additional_params.contains_key(field) {
11592                dlg.finished(false);
11593                return Err(common::Error::FieldClash(field));
11594            }
11595        }
11596
11597        let mut params = Params::with_capacity(4 + self._additional_params.len());
11598        params.push("name", self._name);
11599
11600        params.extend(self._additional_params.iter());
11601
11602        params.push("alt", "json");
11603        let mut url = self.hub._base_url.clone() + "v1/{+name}:setMachineType";
11604        if self._scopes.is_empty() {
11605            self._scopes
11606                .insert(Scope::CloudPlatform.as_ref().to_string());
11607        }
11608
11609        #[allow(clippy::single_element_loop)]
11610        for &(find_this, param_name) in [("{+name}", "name")].iter() {
11611            url = params.uri_replacement(url, param_name, find_this, true);
11612        }
11613        {
11614            let to_remove = ["name"];
11615            params.remove_params(&to_remove);
11616        }
11617
11618        let url = params.parse_with_url(&url);
11619
11620        let mut json_mime_type = mime::APPLICATION_JSON;
11621        let mut request_value_reader = {
11622            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11623            common::remove_json_null_values(&mut value);
11624            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11625            serde_json::to_writer(&mut dst, &value).unwrap();
11626            dst
11627        };
11628        let request_size = request_value_reader
11629            .seek(std::io::SeekFrom::End(0))
11630            .unwrap();
11631        request_value_reader
11632            .seek(std::io::SeekFrom::Start(0))
11633            .unwrap();
11634
11635        loop {
11636            let token = match self
11637                .hub
11638                .auth
11639                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11640                .await
11641            {
11642                Ok(token) => token,
11643                Err(e) => match dlg.token(e) {
11644                    Ok(token) => token,
11645                    Err(e) => {
11646                        dlg.finished(false);
11647                        return Err(common::Error::MissingToken(e));
11648                    }
11649                },
11650            };
11651            request_value_reader
11652                .seek(std::io::SeekFrom::Start(0))
11653                .unwrap();
11654            let mut req_result = {
11655                let client = &self.hub.client;
11656                dlg.pre_request();
11657                let mut req_builder = hyper::Request::builder()
11658                    .method(hyper::Method::PATCH)
11659                    .uri(url.as_str())
11660                    .header(USER_AGENT, self.hub._user_agent.clone());
11661
11662                if let Some(token) = token.as_ref() {
11663                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11664                }
11665
11666                let request = req_builder
11667                    .header(CONTENT_TYPE, json_mime_type.to_string())
11668                    .header(CONTENT_LENGTH, request_size as u64)
11669                    .body(common::to_body(
11670                        request_value_reader.get_ref().clone().into(),
11671                    ));
11672
11673                client.request(request.unwrap()).await
11674            };
11675
11676            match req_result {
11677                Err(err) => {
11678                    if let common::Retry::After(d) = dlg.http_error(&err) {
11679                        sleep(d).await;
11680                        continue;
11681                    }
11682                    dlg.finished(false);
11683                    return Err(common::Error::HttpError(err));
11684                }
11685                Ok(res) => {
11686                    let (mut parts, body) = res.into_parts();
11687                    let mut body = common::Body::new(body);
11688                    if !parts.status.is_success() {
11689                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11690                        let error = serde_json::from_str(&common::to_string(&bytes));
11691                        let response = common::to_response(parts, bytes.into());
11692
11693                        if let common::Retry::After(d) =
11694                            dlg.http_failure(&response, error.as_ref().ok())
11695                        {
11696                            sleep(d).await;
11697                            continue;
11698                        }
11699
11700                        dlg.finished(false);
11701
11702                        return Err(match error {
11703                            Ok(value) => common::Error::BadRequest(value),
11704                            _ => common::Error::Failure(response),
11705                        });
11706                    }
11707                    let response = {
11708                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11709                        let encoded = common::to_string(&bytes);
11710                        match serde_json::from_str(&encoded) {
11711                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11712                            Err(error) => {
11713                                dlg.response_json_decode_error(&encoded, &error);
11714                                return Err(common::Error::JsonDecodeError(
11715                                    encoded.to_string(),
11716                                    error,
11717                                ));
11718                            }
11719                        }
11720                    };
11721
11722                    dlg.finished(true);
11723                    return Ok(response);
11724                }
11725            }
11726        }
11727    }
11728
11729    ///
11730    /// Sets the *request* property to the given value.
11731    ///
11732    /// Even though the property as already been set when instantiating this call,
11733    /// we provide this method for API completeness.
11734    pub fn request(
11735        mut self,
11736        new_value: SetInstanceMachineTypeRequest,
11737    ) -> ProjectLocationInstanceSetMachineTypeCall<'a, C> {
11738        self._request = new_value;
11739        self
11740    }
11741    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
11742    ///
11743    /// Sets the *name* path property to the given value.
11744    ///
11745    /// Even though the property as already been set when instantiating this call,
11746    /// we provide this method for API completeness.
11747    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceSetMachineTypeCall<'a, C> {
11748        self._name = new_value.to_string();
11749        self
11750    }
11751    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11752    /// while executing the actual API request.
11753    ///
11754    /// ````text
11755    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11756    /// ````
11757    ///
11758    /// Sets the *delegate* property to the given value.
11759    pub fn delegate(
11760        mut self,
11761        new_value: &'a mut dyn common::Delegate,
11762    ) -> ProjectLocationInstanceSetMachineTypeCall<'a, C> {
11763        self._delegate = Some(new_value);
11764        self
11765    }
11766
11767    /// Set any additional parameter of the query string used in the request.
11768    /// It should be used to set parameters which are not yet available through their own
11769    /// setters.
11770    ///
11771    /// Please note that this method must not be used to set any of the known parameters
11772    /// which have their own setter method. If done anyway, the request will fail.
11773    ///
11774    /// # Additional Parameters
11775    ///
11776    /// * *$.xgafv* (query-string) - V1 error format.
11777    /// * *access_token* (query-string) - OAuth access token.
11778    /// * *alt* (query-string) - Data format for response.
11779    /// * *callback* (query-string) - JSONP
11780    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11781    /// * *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.
11782    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11783    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11784    /// * *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.
11785    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11786    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11787    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceSetMachineTypeCall<'a, C>
11788    where
11789        T: AsRef<str>,
11790    {
11791        self._additional_params
11792            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11793        self
11794    }
11795
11796    /// Identifies the authorization scope for the method you are building.
11797    ///
11798    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11799    /// [`Scope::CloudPlatform`].
11800    ///
11801    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11802    /// tokens for more than one scope.
11803    ///
11804    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11805    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11806    /// sufficient, a read-write scope will do as well.
11807    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceSetMachineTypeCall<'a, C>
11808    where
11809        St: AsRef<str>,
11810    {
11811        self._scopes.insert(String::from(scope.as_ref()));
11812        self
11813    }
11814    /// Identifies the authorization scope(s) for the method you are building.
11815    ///
11816    /// See [`Self::add_scope()`] for details.
11817    pub fn add_scopes<I, St>(
11818        mut self,
11819        scopes: I,
11820    ) -> ProjectLocationInstanceSetMachineTypeCall<'a, C>
11821    where
11822        I: IntoIterator<Item = St>,
11823        St: AsRef<str>,
11824    {
11825        self._scopes
11826            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11827        self
11828    }
11829
11830    /// Removes all scopes, and no default scope will be used either.
11831    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11832    /// for details).
11833    pub fn clear_scopes(mut self) -> ProjectLocationInstanceSetMachineTypeCall<'a, C> {
11834        self._scopes.clear();
11835        self
11836    }
11837}
11838
11839/// Starts a notebook instance.
11840///
11841/// A builder for the *locations.instances.start* method supported by a *project* resource.
11842/// It is not used directly, but through a [`ProjectMethods`] instance.
11843///
11844/// # Example
11845///
11846/// Instantiate a resource method builder
11847///
11848/// ```test_harness,no_run
11849/// # extern crate hyper;
11850/// # extern crate hyper_rustls;
11851/// # extern crate google_notebooks1 as notebooks1;
11852/// use notebooks1::api::StartInstanceRequest;
11853/// # async fn dox() {
11854/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11855///
11856/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11857/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11858/// #     secret,
11859/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11860/// # ).build().await.unwrap();
11861///
11862/// # let client = hyper_util::client::legacy::Client::builder(
11863/// #     hyper_util::rt::TokioExecutor::new()
11864/// # )
11865/// # .build(
11866/// #     hyper_rustls::HttpsConnectorBuilder::new()
11867/// #         .with_native_roots()
11868/// #         .unwrap()
11869/// #         .https_or_http()
11870/// #         .enable_http1()
11871/// #         .build()
11872/// # );
11873/// # let mut hub = AIPlatformNotebooks::new(client, auth);
11874/// // As the method needs a request, you would usually fill it with the desired information
11875/// // into the respective structure. Some of the parts shown here might not be applicable !
11876/// // Values shown here are possibly random and not representative !
11877/// let mut req = StartInstanceRequest::default();
11878///
11879/// // You can configure optional parameters by calling the respective setters at will, and
11880/// // execute the final call using `doit()`.
11881/// // Values shown here are possibly random and not representative !
11882/// let result = hub.projects().locations_instances_start(req, "name")
11883///              .doit().await;
11884/// # }
11885/// ```
11886pub struct ProjectLocationInstanceStartCall<'a, C>
11887where
11888    C: 'a,
11889{
11890    hub: &'a AIPlatformNotebooks<C>,
11891    _request: StartInstanceRequest,
11892    _name: String,
11893    _delegate: Option<&'a mut dyn common::Delegate>,
11894    _additional_params: HashMap<String, String>,
11895    _scopes: BTreeSet<String>,
11896}
11897
11898impl<'a, C> common::CallBuilder for ProjectLocationInstanceStartCall<'a, C> {}
11899
11900impl<'a, C> ProjectLocationInstanceStartCall<'a, C>
11901where
11902    C: common::Connector,
11903{
11904    /// Perform the operation you have build so far.
11905    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
11906        use std::borrow::Cow;
11907        use std::io::{Read, Seek};
11908
11909        use common::{url::Params, ToParts};
11910        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11911
11912        let mut dd = common::DefaultDelegate;
11913        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11914        dlg.begin(common::MethodInfo {
11915            id: "notebooks.projects.locations.instances.start",
11916            http_method: hyper::Method::POST,
11917        });
11918
11919        for &field in ["alt", "name"].iter() {
11920            if self._additional_params.contains_key(field) {
11921                dlg.finished(false);
11922                return Err(common::Error::FieldClash(field));
11923            }
11924        }
11925
11926        let mut params = Params::with_capacity(4 + self._additional_params.len());
11927        params.push("name", self._name);
11928
11929        params.extend(self._additional_params.iter());
11930
11931        params.push("alt", "json");
11932        let mut url = self.hub._base_url.clone() + "v1/{+name}:start";
11933        if self._scopes.is_empty() {
11934            self._scopes
11935                .insert(Scope::CloudPlatform.as_ref().to_string());
11936        }
11937
11938        #[allow(clippy::single_element_loop)]
11939        for &(find_this, param_name) in [("{+name}", "name")].iter() {
11940            url = params.uri_replacement(url, param_name, find_this, true);
11941        }
11942        {
11943            let to_remove = ["name"];
11944            params.remove_params(&to_remove);
11945        }
11946
11947        let url = params.parse_with_url(&url);
11948
11949        let mut json_mime_type = mime::APPLICATION_JSON;
11950        let mut request_value_reader = {
11951            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11952            common::remove_json_null_values(&mut value);
11953            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11954            serde_json::to_writer(&mut dst, &value).unwrap();
11955            dst
11956        };
11957        let request_size = request_value_reader
11958            .seek(std::io::SeekFrom::End(0))
11959            .unwrap();
11960        request_value_reader
11961            .seek(std::io::SeekFrom::Start(0))
11962            .unwrap();
11963
11964        loop {
11965            let token = match self
11966                .hub
11967                .auth
11968                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11969                .await
11970            {
11971                Ok(token) => token,
11972                Err(e) => match dlg.token(e) {
11973                    Ok(token) => token,
11974                    Err(e) => {
11975                        dlg.finished(false);
11976                        return Err(common::Error::MissingToken(e));
11977                    }
11978                },
11979            };
11980            request_value_reader
11981                .seek(std::io::SeekFrom::Start(0))
11982                .unwrap();
11983            let mut req_result = {
11984                let client = &self.hub.client;
11985                dlg.pre_request();
11986                let mut req_builder = hyper::Request::builder()
11987                    .method(hyper::Method::POST)
11988                    .uri(url.as_str())
11989                    .header(USER_AGENT, self.hub._user_agent.clone());
11990
11991                if let Some(token) = token.as_ref() {
11992                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11993                }
11994
11995                let request = req_builder
11996                    .header(CONTENT_TYPE, json_mime_type.to_string())
11997                    .header(CONTENT_LENGTH, request_size as u64)
11998                    .body(common::to_body(
11999                        request_value_reader.get_ref().clone().into(),
12000                    ));
12001
12002                client.request(request.unwrap()).await
12003            };
12004
12005            match req_result {
12006                Err(err) => {
12007                    if let common::Retry::After(d) = dlg.http_error(&err) {
12008                        sleep(d).await;
12009                        continue;
12010                    }
12011                    dlg.finished(false);
12012                    return Err(common::Error::HttpError(err));
12013                }
12014                Ok(res) => {
12015                    let (mut parts, body) = res.into_parts();
12016                    let mut body = common::Body::new(body);
12017                    if !parts.status.is_success() {
12018                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12019                        let error = serde_json::from_str(&common::to_string(&bytes));
12020                        let response = common::to_response(parts, bytes.into());
12021
12022                        if let common::Retry::After(d) =
12023                            dlg.http_failure(&response, error.as_ref().ok())
12024                        {
12025                            sleep(d).await;
12026                            continue;
12027                        }
12028
12029                        dlg.finished(false);
12030
12031                        return Err(match error {
12032                            Ok(value) => common::Error::BadRequest(value),
12033                            _ => common::Error::Failure(response),
12034                        });
12035                    }
12036                    let response = {
12037                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12038                        let encoded = common::to_string(&bytes);
12039                        match serde_json::from_str(&encoded) {
12040                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12041                            Err(error) => {
12042                                dlg.response_json_decode_error(&encoded, &error);
12043                                return Err(common::Error::JsonDecodeError(
12044                                    encoded.to_string(),
12045                                    error,
12046                                ));
12047                            }
12048                        }
12049                    };
12050
12051                    dlg.finished(true);
12052                    return Ok(response);
12053                }
12054            }
12055        }
12056    }
12057
12058    ///
12059    /// Sets the *request* property to the given value.
12060    ///
12061    /// Even though the property as already been set when instantiating this call,
12062    /// we provide this method for API completeness.
12063    pub fn request(
12064        mut self,
12065        new_value: StartInstanceRequest,
12066    ) -> ProjectLocationInstanceStartCall<'a, C> {
12067        self._request = new_value;
12068        self
12069    }
12070    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
12071    ///
12072    /// Sets the *name* path property to the given value.
12073    ///
12074    /// Even though the property as already been set when instantiating this call,
12075    /// we provide this method for API completeness.
12076    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceStartCall<'a, C> {
12077        self._name = new_value.to_string();
12078        self
12079    }
12080    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12081    /// while executing the actual API request.
12082    ///
12083    /// ````text
12084    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12085    /// ````
12086    ///
12087    /// Sets the *delegate* property to the given value.
12088    pub fn delegate(
12089        mut self,
12090        new_value: &'a mut dyn common::Delegate,
12091    ) -> ProjectLocationInstanceStartCall<'a, C> {
12092        self._delegate = Some(new_value);
12093        self
12094    }
12095
12096    /// Set any additional parameter of the query string used in the request.
12097    /// It should be used to set parameters which are not yet available through their own
12098    /// setters.
12099    ///
12100    /// Please note that this method must not be used to set any of the known parameters
12101    /// which have their own setter method. If done anyway, the request will fail.
12102    ///
12103    /// # Additional Parameters
12104    ///
12105    /// * *$.xgafv* (query-string) - V1 error format.
12106    /// * *access_token* (query-string) - OAuth access token.
12107    /// * *alt* (query-string) - Data format for response.
12108    /// * *callback* (query-string) - JSONP
12109    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12110    /// * *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.
12111    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12112    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12113    /// * *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.
12114    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12115    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12116    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceStartCall<'a, C>
12117    where
12118        T: AsRef<str>,
12119    {
12120        self._additional_params
12121            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12122        self
12123    }
12124
12125    /// Identifies the authorization scope for the method you are building.
12126    ///
12127    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12128    /// [`Scope::CloudPlatform`].
12129    ///
12130    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12131    /// tokens for more than one scope.
12132    ///
12133    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12134    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12135    /// sufficient, a read-write scope will do as well.
12136    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceStartCall<'a, C>
12137    where
12138        St: AsRef<str>,
12139    {
12140        self._scopes.insert(String::from(scope.as_ref()));
12141        self
12142    }
12143    /// Identifies the authorization scope(s) for the method you are building.
12144    ///
12145    /// See [`Self::add_scope()`] for details.
12146    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceStartCall<'a, C>
12147    where
12148        I: IntoIterator<Item = St>,
12149        St: AsRef<str>,
12150    {
12151        self._scopes
12152            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12153        self
12154    }
12155
12156    /// Removes all scopes, and no default scope will be used either.
12157    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12158    /// for details).
12159    pub fn clear_scopes(mut self) -> ProjectLocationInstanceStartCall<'a, C> {
12160        self._scopes.clear();
12161        self
12162    }
12163}
12164
12165/// Stops a notebook instance.
12166///
12167/// A builder for the *locations.instances.stop* method supported by a *project* resource.
12168/// It is not used directly, but through a [`ProjectMethods`] instance.
12169///
12170/// # Example
12171///
12172/// Instantiate a resource method builder
12173///
12174/// ```test_harness,no_run
12175/// # extern crate hyper;
12176/// # extern crate hyper_rustls;
12177/// # extern crate google_notebooks1 as notebooks1;
12178/// use notebooks1::api::StopInstanceRequest;
12179/// # async fn dox() {
12180/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12181///
12182/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12183/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12184/// #     secret,
12185/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12186/// # ).build().await.unwrap();
12187///
12188/// # let client = hyper_util::client::legacy::Client::builder(
12189/// #     hyper_util::rt::TokioExecutor::new()
12190/// # )
12191/// # .build(
12192/// #     hyper_rustls::HttpsConnectorBuilder::new()
12193/// #         .with_native_roots()
12194/// #         .unwrap()
12195/// #         .https_or_http()
12196/// #         .enable_http1()
12197/// #         .build()
12198/// # );
12199/// # let mut hub = AIPlatformNotebooks::new(client, auth);
12200/// // As the method needs a request, you would usually fill it with the desired information
12201/// // into the respective structure. Some of the parts shown here might not be applicable !
12202/// // Values shown here are possibly random and not representative !
12203/// let mut req = StopInstanceRequest::default();
12204///
12205/// // You can configure optional parameters by calling the respective setters at will, and
12206/// // execute the final call using `doit()`.
12207/// // Values shown here are possibly random and not representative !
12208/// let result = hub.projects().locations_instances_stop(req, "name")
12209///              .doit().await;
12210/// # }
12211/// ```
12212pub struct ProjectLocationInstanceStopCall<'a, C>
12213where
12214    C: 'a,
12215{
12216    hub: &'a AIPlatformNotebooks<C>,
12217    _request: StopInstanceRequest,
12218    _name: String,
12219    _delegate: Option<&'a mut dyn common::Delegate>,
12220    _additional_params: HashMap<String, String>,
12221    _scopes: BTreeSet<String>,
12222}
12223
12224impl<'a, C> common::CallBuilder for ProjectLocationInstanceStopCall<'a, C> {}
12225
12226impl<'a, C> ProjectLocationInstanceStopCall<'a, C>
12227where
12228    C: common::Connector,
12229{
12230    /// Perform the operation you have build so far.
12231    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
12232        use std::borrow::Cow;
12233        use std::io::{Read, Seek};
12234
12235        use common::{url::Params, ToParts};
12236        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12237
12238        let mut dd = common::DefaultDelegate;
12239        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12240        dlg.begin(common::MethodInfo {
12241            id: "notebooks.projects.locations.instances.stop",
12242            http_method: hyper::Method::POST,
12243        });
12244
12245        for &field in ["alt", "name"].iter() {
12246            if self._additional_params.contains_key(field) {
12247                dlg.finished(false);
12248                return Err(common::Error::FieldClash(field));
12249            }
12250        }
12251
12252        let mut params = Params::with_capacity(4 + self._additional_params.len());
12253        params.push("name", self._name);
12254
12255        params.extend(self._additional_params.iter());
12256
12257        params.push("alt", "json");
12258        let mut url = self.hub._base_url.clone() + "v1/{+name}:stop";
12259        if self._scopes.is_empty() {
12260            self._scopes
12261                .insert(Scope::CloudPlatform.as_ref().to_string());
12262        }
12263
12264        #[allow(clippy::single_element_loop)]
12265        for &(find_this, param_name) in [("{+name}", "name")].iter() {
12266            url = params.uri_replacement(url, param_name, find_this, true);
12267        }
12268        {
12269            let to_remove = ["name"];
12270            params.remove_params(&to_remove);
12271        }
12272
12273        let url = params.parse_with_url(&url);
12274
12275        let mut json_mime_type = mime::APPLICATION_JSON;
12276        let mut request_value_reader = {
12277            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12278            common::remove_json_null_values(&mut value);
12279            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12280            serde_json::to_writer(&mut dst, &value).unwrap();
12281            dst
12282        };
12283        let request_size = request_value_reader
12284            .seek(std::io::SeekFrom::End(0))
12285            .unwrap();
12286        request_value_reader
12287            .seek(std::io::SeekFrom::Start(0))
12288            .unwrap();
12289
12290        loop {
12291            let token = match self
12292                .hub
12293                .auth
12294                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12295                .await
12296            {
12297                Ok(token) => token,
12298                Err(e) => match dlg.token(e) {
12299                    Ok(token) => token,
12300                    Err(e) => {
12301                        dlg.finished(false);
12302                        return Err(common::Error::MissingToken(e));
12303                    }
12304                },
12305            };
12306            request_value_reader
12307                .seek(std::io::SeekFrom::Start(0))
12308                .unwrap();
12309            let mut req_result = {
12310                let client = &self.hub.client;
12311                dlg.pre_request();
12312                let mut req_builder = hyper::Request::builder()
12313                    .method(hyper::Method::POST)
12314                    .uri(url.as_str())
12315                    .header(USER_AGENT, self.hub._user_agent.clone());
12316
12317                if let Some(token) = token.as_ref() {
12318                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12319                }
12320
12321                let request = req_builder
12322                    .header(CONTENT_TYPE, json_mime_type.to_string())
12323                    .header(CONTENT_LENGTH, request_size as u64)
12324                    .body(common::to_body(
12325                        request_value_reader.get_ref().clone().into(),
12326                    ));
12327
12328                client.request(request.unwrap()).await
12329            };
12330
12331            match req_result {
12332                Err(err) => {
12333                    if let common::Retry::After(d) = dlg.http_error(&err) {
12334                        sleep(d).await;
12335                        continue;
12336                    }
12337                    dlg.finished(false);
12338                    return Err(common::Error::HttpError(err));
12339                }
12340                Ok(res) => {
12341                    let (mut parts, body) = res.into_parts();
12342                    let mut body = common::Body::new(body);
12343                    if !parts.status.is_success() {
12344                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12345                        let error = serde_json::from_str(&common::to_string(&bytes));
12346                        let response = common::to_response(parts, bytes.into());
12347
12348                        if let common::Retry::After(d) =
12349                            dlg.http_failure(&response, error.as_ref().ok())
12350                        {
12351                            sleep(d).await;
12352                            continue;
12353                        }
12354
12355                        dlg.finished(false);
12356
12357                        return Err(match error {
12358                            Ok(value) => common::Error::BadRequest(value),
12359                            _ => common::Error::Failure(response),
12360                        });
12361                    }
12362                    let response = {
12363                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12364                        let encoded = common::to_string(&bytes);
12365                        match serde_json::from_str(&encoded) {
12366                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12367                            Err(error) => {
12368                                dlg.response_json_decode_error(&encoded, &error);
12369                                return Err(common::Error::JsonDecodeError(
12370                                    encoded.to_string(),
12371                                    error,
12372                                ));
12373                            }
12374                        }
12375                    };
12376
12377                    dlg.finished(true);
12378                    return Ok(response);
12379                }
12380            }
12381        }
12382    }
12383
12384    ///
12385    /// Sets the *request* property to the given value.
12386    ///
12387    /// Even though the property as already been set when instantiating this call,
12388    /// we provide this method for API completeness.
12389    pub fn request(
12390        mut self,
12391        new_value: StopInstanceRequest,
12392    ) -> ProjectLocationInstanceStopCall<'a, C> {
12393        self._request = new_value;
12394        self
12395    }
12396    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
12397    ///
12398    /// Sets the *name* path property to the given value.
12399    ///
12400    /// Even though the property as already been set when instantiating this call,
12401    /// we provide this method for API completeness.
12402    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceStopCall<'a, C> {
12403        self._name = new_value.to_string();
12404        self
12405    }
12406    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12407    /// while executing the actual API request.
12408    ///
12409    /// ````text
12410    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12411    /// ````
12412    ///
12413    /// Sets the *delegate* property to the given value.
12414    pub fn delegate(
12415        mut self,
12416        new_value: &'a mut dyn common::Delegate,
12417    ) -> ProjectLocationInstanceStopCall<'a, C> {
12418        self._delegate = Some(new_value);
12419        self
12420    }
12421
12422    /// Set any additional parameter of the query string used in the request.
12423    /// It should be used to set parameters which are not yet available through their own
12424    /// setters.
12425    ///
12426    /// Please note that this method must not be used to set any of the known parameters
12427    /// which have their own setter method. If done anyway, the request will fail.
12428    ///
12429    /// # Additional Parameters
12430    ///
12431    /// * *$.xgafv* (query-string) - V1 error format.
12432    /// * *access_token* (query-string) - OAuth access token.
12433    /// * *alt* (query-string) - Data format for response.
12434    /// * *callback* (query-string) - JSONP
12435    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12436    /// * *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.
12437    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12438    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12439    /// * *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.
12440    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12441    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12442    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceStopCall<'a, C>
12443    where
12444        T: AsRef<str>,
12445    {
12446        self._additional_params
12447            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12448        self
12449    }
12450
12451    /// Identifies the authorization scope for the method you are building.
12452    ///
12453    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12454    /// [`Scope::CloudPlatform`].
12455    ///
12456    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12457    /// tokens for more than one scope.
12458    ///
12459    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12460    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12461    /// sufficient, a read-write scope will do as well.
12462    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceStopCall<'a, C>
12463    where
12464        St: AsRef<str>,
12465    {
12466        self._scopes.insert(String::from(scope.as_ref()));
12467        self
12468    }
12469    /// Identifies the authorization scope(s) for the method you are building.
12470    ///
12471    /// See [`Self::add_scope()`] for details.
12472    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceStopCall<'a, C>
12473    where
12474        I: IntoIterator<Item = St>,
12475        St: AsRef<str>,
12476    {
12477        self._scopes
12478            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12479        self
12480    }
12481
12482    /// Removes all scopes, and no default scope will be used either.
12483    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12484    /// for details).
12485    pub fn clear_scopes(mut self) -> ProjectLocationInstanceStopCall<'a, C> {
12486        self._scopes.clear();
12487        self
12488    }
12489}
12490
12491/// 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.
12492///
12493/// A builder for the *locations.instances.testIamPermissions* method supported by a *project* resource.
12494/// It is not used directly, but through a [`ProjectMethods`] instance.
12495///
12496/// # Example
12497///
12498/// Instantiate a resource method builder
12499///
12500/// ```test_harness,no_run
12501/// # extern crate hyper;
12502/// # extern crate hyper_rustls;
12503/// # extern crate google_notebooks1 as notebooks1;
12504/// use notebooks1::api::TestIamPermissionsRequest;
12505/// # async fn dox() {
12506/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12507///
12508/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12509/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12510/// #     secret,
12511/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12512/// # ).build().await.unwrap();
12513///
12514/// # let client = hyper_util::client::legacy::Client::builder(
12515/// #     hyper_util::rt::TokioExecutor::new()
12516/// # )
12517/// # .build(
12518/// #     hyper_rustls::HttpsConnectorBuilder::new()
12519/// #         .with_native_roots()
12520/// #         .unwrap()
12521/// #         .https_or_http()
12522/// #         .enable_http1()
12523/// #         .build()
12524/// # );
12525/// # let mut hub = AIPlatformNotebooks::new(client, auth);
12526/// // As the method needs a request, you would usually fill it with the desired information
12527/// // into the respective structure. Some of the parts shown here might not be applicable !
12528/// // Values shown here are possibly random and not representative !
12529/// let mut req = TestIamPermissionsRequest::default();
12530///
12531/// // You can configure optional parameters by calling the respective setters at will, and
12532/// // execute the final call using `doit()`.
12533/// // Values shown here are possibly random and not representative !
12534/// let result = hub.projects().locations_instances_test_iam_permissions(req, "resource")
12535///              .doit().await;
12536/// # }
12537/// ```
12538pub struct ProjectLocationInstanceTestIamPermissionCall<'a, C>
12539where
12540    C: 'a,
12541{
12542    hub: &'a AIPlatformNotebooks<C>,
12543    _request: TestIamPermissionsRequest,
12544    _resource: String,
12545    _delegate: Option<&'a mut dyn common::Delegate>,
12546    _additional_params: HashMap<String, String>,
12547    _scopes: BTreeSet<String>,
12548}
12549
12550impl<'a, C> common::CallBuilder for ProjectLocationInstanceTestIamPermissionCall<'a, C> {}
12551
12552impl<'a, C> ProjectLocationInstanceTestIamPermissionCall<'a, C>
12553where
12554    C: common::Connector,
12555{
12556    /// Perform the operation you have build so far.
12557    pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
12558        use std::borrow::Cow;
12559        use std::io::{Read, Seek};
12560
12561        use common::{url::Params, ToParts};
12562        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12563
12564        let mut dd = common::DefaultDelegate;
12565        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12566        dlg.begin(common::MethodInfo {
12567            id: "notebooks.projects.locations.instances.testIamPermissions",
12568            http_method: hyper::Method::POST,
12569        });
12570
12571        for &field in ["alt", "resource"].iter() {
12572            if self._additional_params.contains_key(field) {
12573                dlg.finished(false);
12574                return Err(common::Error::FieldClash(field));
12575            }
12576        }
12577
12578        let mut params = Params::with_capacity(4 + self._additional_params.len());
12579        params.push("resource", self._resource);
12580
12581        params.extend(self._additional_params.iter());
12582
12583        params.push("alt", "json");
12584        let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
12585        if self._scopes.is_empty() {
12586            self._scopes
12587                .insert(Scope::CloudPlatform.as_ref().to_string());
12588        }
12589
12590        #[allow(clippy::single_element_loop)]
12591        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
12592            url = params.uri_replacement(url, param_name, find_this, true);
12593        }
12594        {
12595            let to_remove = ["resource"];
12596            params.remove_params(&to_remove);
12597        }
12598
12599        let url = params.parse_with_url(&url);
12600
12601        let mut json_mime_type = mime::APPLICATION_JSON;
12602        let mut request_value_reader = {
12603            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12604            common::remove_json_null_values(&mut value);
12605            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12606            serde_json::to_writer(&mut dst, &value).unwrap();
12607            dst
12608        };
12609        let request_size = request_value_reader
12610            .seek(std::io::SeekFrom::End(0))
12611            .unwrap();
12612        request_value_reader
12613            .seek(std::io::SeekFrom::Start(0))
12614            .unwrap();
12615
12616        loop {
12617            let token = match self
12618                .hub
12619                .auth
12620                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12621                .await
12622            {
12623                Ok(token) => token,
12624                Err(e) => match dlg.token(e) {
12625                    Ok(token) => token,
12626                    Err(e) => {
12627                        dlg.finished(false);
12628                        return Err(common::Error::MissingToken(e));
12629                    }
12630                },
12631            };
12632            request_value_reader
12633                .seek(std::io::SeekFrom::Start(0))
12634                .unwrap();
12635            let mut req_result = {
12636                let client = &self.hub.client;
12637                dlg.pre_request();
12638                let mut req_builder = hyper::Request::builder()
12639                    .method(hyper::Method::POST)
12640                    .uri(url.as_str())
12641                    .header(USER_AGENT, self.hub._user_agent.clone());
12642
12643                if let Some(token) = token.as_ref() {
12644                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12645                }
12646
12647                let request = req_builder
12648                    .header(CONTENT_TYPE, json_mime_type.to_string())
12649                    .header(CONTENT_LENGTH, request_size as u64)
12650                    .body(common::to_body(
12651                        request_value_reader.get_ref().clone().into(),
12652                    ));
12653
12654                client.request(request.unwrap()).await
12655            };
12656
12657            match req_result {
12658                Err(err) => {
12659                    if let common::Retry::After(d) = dlg.http_error(&err) {
12660                        sleep(d).await;
12661                        continue;
12662                    }
12663                    dlg.finished(false);
12664                    return Err(common::Error::HttpError(err));
12665                }
12666                Ok(res) => {
12667                    let (mut parts, body) = res.into_parts();
12668                    let mut body = common::Body::new(body);
12669                    if !parts.status.is_success() {
12670                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12671                        let error = serde_json::from_str(&common::to_string(&bytes));
12672                        let response = common::to_response(parts, bytes.into());
12673
12674                        if let common::Retry::After(d) =
12675                            dlg.http_failure(&response, error.as_ref().ok())
12676                        {
12677                            sleep(d).await;
12678                            continue;
12679                        }
12680
12681                        dlg.finished(false);
12682
12683                        return Err(match error {
12684                            Ok(value) => common::Error::BadRequest(value),
12685                            _ => common::Error::Failure(response),
12686                        });
12687                    }
12688                    let response = {
12689                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12690                        let encoded = common::to_string(&bytes);
12691                        match serde_json::from_str(&encoded) {
12692                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12693                            Err(error) => {
12694                                dlg.response_json_decode_error(&encoded, &error);
12695                                return Err(common::Error::JsonDecodeError(
12696                                    encoded.to_string(),
12697                                    error,
12698                                ));
12699                            }
12700                        }
12701                    };
12702
12703                    dlg.finished(true);
12704                    return Ok(response);
12705                }
12706            }
12707        }
12708    }
12709
12710    ///
12711    /// Sets the *request* property to the given value.
12712    ///
12713    /// Even though the property as already been set when instantiating this call,
12714    /// we provide this method for API completeness.
12715    pub fn request(
12716        mut self,
12717        new_value: TestIamPermissionsRequest,
12718    ) -> ProjectLocationInstanceTestIamPermissionCall<'a, C> {
12719        self._request = new_value;
12720        self
12721    }
12722    /// 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.
12723    ///
12724    /// Sets the *resource* path property to the given value.
12725    ///
12726    /// Even though the property as already been set when instantiating this call,
12727    /// we provide this method for API completeness.
12728    pub fn resource(
12729        mut self,
12730        new_value: &str,
12731    ) -> ProjectLocationInstanceTestIamPermissionCall<'a, C> {
12732        self._resource = new_value.to_string();
12733        self
12734    }
12735    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12736    /// while executing the actual API request.
12737    ///
12738    /// ````text
12739    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12740    /// ````
12741    ///
12742    /// Sets the *delegate* property to the given value.
12743    pub fn delegate(
12744        mut self,
12745        new_value: &'a mut dyn common::Delegate,
12746    ) -> ProjectLocationInstanceTestIamPermissionCall<'a, C> {
12747        self._delegate = Some(new_value);
12748        self
12749    }
12750
12751    /// Set any additional parameter of the query string used in the request.
12752    /// It should be used to set parameters which are not yet available through their own
12753    /// setters.
12754    ///
12755    /// Please note that this method must not be used to set any of the known parameters
12756    /// which have their own setter method. If done anyway, the request will fail.
12757    ///
12758    /// # Additional Parameters
12759    ///
12760    /// * *$.xgafv* (query-string) - V1 error format.
12761    /// * *access_token* (query-string) - OAuth access token.
12762    /// * *alt* (query-string) - Data format for response.
12763    /// * *callback* (query-string) - JSONP
12764    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12765    /// * *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.
12766    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12767    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12768    /// * *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.
12769    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12770    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12771    pub fn param<T>(
12772        mut self,
12773        name: T,
12774        value: T,
12775    ) -> ProjectLocationInstanceTestIamPermissionCall<'a, C>
12776    where
12777        T: AsRef<str>,
12778    {
12779        self._additional_params
12780            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12781        self
12782    }
12783
12784    /// Identifies the authorization scope for the method you are building.
12785    ///
12786    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12787    /// [`Scope::CloudPlatform`].
12788    ///
12789    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12790    /// tokens for more than one scope.
12791    ///
12792    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12793    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12794    /// sufficient, a read-write scope will do as well.
12795    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceTestIamPermissionCall<'a, C>
12796    where
12797        St: AsRef<str>,
12798    {
12799        self._scopes.insert(String::from(scope.as_ref()));
12800        self
12801    }
12802    /// Identifies the authorization scope(s) for the method you are building.
12803    ///
12804    /// See [`Self::add_scope()`] for details.
12805    pub fn add_scopes<I, St>(
12806        mut self,
12807        scopes: I,
12808    ) -> ProjectLocationInstanceTestIamPermissionCall<'a, C>
12809    where
12810        I: IntoIterator<Item = St>,
12811        St: AsRef<str>,
12812    {
12813        self._scopes
12814            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12815        self
12816    }
12817
12818    /// Removes all scopes, and no default scope will be used either.
12819    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12820    /// for details).
12821    pub fn clear_scopes(mut self) -> ProjectLocationInstanceTestIamPermissionCall<'a, C> {
12822        self._scopes.clear();
12823        self
12824    }
12825}
12826
12827/// Update Notebook Instance configurations.
12828///
12829/// A builder for the *locations.instances.updateConfig* method supported by a *project* resource.
12830/// It is not used directly, but through a [`ProjectMethods`] instance.
12831///
12832/// # Example
12833///
12834/// Instantiate a resource method builder
12835///
12836/// ```test_harness,no_run
12837/// # extern crate hyper;
12838/// # extern crate hyper_rustls;
12839/// # extern crate google_notebooks1 as notebooks1;
12840/// use notebooks1::api::UpdateInstanceConfigRequest;
12841/// # async fn dox() {
12842/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12843///
12844/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12845/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12846/// #     secret,
12847/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12848/// # ).build().await.unwrap();
12849///
12850/// # let client = hyper_util::client::legacy::Client::builder(
12851/// #     hyper_util::rt::TokioExecutor::new()
12852/// # )
12853/// # .build(
12854/// #     hyper_rustls::HttpsConnectorBuilder::new()
12855/// #         .with_native_roots()
12856/// #         .unwrap()
12857/// #         .https_or_http()
12858/// #         .enable_http1()
12859/// #         .build()
12860/// # );
12861/// # let mut hub = AIPlatformNotebooks::new(client, auth);
12862/// // As the method needs a request, you would usually fill it with the desired information
12863/// // into the respective structure. Some of the parts shown here might not be applicable !
12864/// // Values shown here are possibly random and not representative !
12865/// let mut req = UpdateInstanceConfigRequest::default();
12866///
12867/// // You can configure optional parameters by calling the respective setters at will, and
12868/// // execute the final call using `doit()`.
12869/// // Values shown here are possibly random and not representative !
12870/// let result = hub.projects().locations_instances_update_config(req, "name")
12871///              .doit().await;
12872/// # }
12873/// ```
12874pub struct ProjectLocationInstanceUpdateConfigCall<'a, C>
12875where
12876    C: 'a,
12877{
12878    hub: &'a AIPlatformNotebooks<C>,
12879    _request: UpdateInstanceConfigRequest,
12880    _name: String,
12881    _delegate: Option<&'a mut dyn common::Delegate>,
12882    _additional_params: HashMap<String, String>,
12883    _scopes: BTreeSet<String>,
12884}
12885
12886impl<'a, C> common::CallBuilder for ProjectLocationInstanceUpdateConfigCall<'a, C> {}
12887
12888impl<'a, C> ProjectLocationInstanceUpdateConfigCall<'a, C>
12889where
12890    C: common::Connector,
12891{
12892    /// Perform the operation you have build so far.
12893    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
12894        use std::borrow::Cow;
12895        use std::io::{Read, Seek};
12896
12897        use common::{url::Params, ToParts};
12898        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12899
12900        let mut dd = common::DefaultDelegate;
12901        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12902        dlg.begin(common::MethodInfo {
12903            id: "notebooks.projects.locations.instances.updateConfig",
12904            http_method: hyper::Method::PATCH,
12905        });
12906
12907        for &field in ["alt", "name"].iter() {
12908            if self._additional_params.contains_key(field) {
12909                dlg.finished(false);
12910                return Err(common::Error::FieldClash(field));
12911            }
12912        }
12913
12914        let mut params = Params::with_capacity(4 + self._additional_params.len());
12915        params.push("name", self._name);
12916
12917        params.extend(self._additional_params.iter());
12918
12919        params.push("alt", "json");
12920        let mut url = self.hub._base_url.clone() + "v1/{+name}:updateConfig";
12921        if self._scopes.is_empty() {
12922            self._scopes
12923                .insert(Scope::CloudPlatform.as_ref().to_string());
12924        }
12925
12926        #[allow(clippy::single_element_loop)]
12927        for &(find_this, param_name) in [("{+name}", "name")].iter() {
12928            url = params.uri_replacement(url, param_name, find_this, true);
12929        }
12930        {
12931            let to_remove = ["name"];
12932            params.remove_params(&to_remove);
12933        }
12934
12935        let url = params.parse_with_url(&url);
12936
12937        let mut json_mime_type = mime::APPLICATION_JSON;
12938        let mut request_value_reader = {
12939            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12940            common::remove_json_null_values(&mut value);
12941            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12942            serde_json::to_writer(&mut dst, &value).unwrap();
12943            dst
12944        };
12945        let request_size = request_value_reader
12946            .seek(std::io::SeekFrom::End(0))
12947            .unwrap();
12948        request_value_reader
12949            .seek(std::io::SeekFrom::Start(0))
12950            .unwrap();
12951
12952        loop {
12953            let token = match self
12954                .hub
12955                .auth
12956                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12957                .await
12958            {
12959                Ok(token) => token,
12960                Err(e) => match dlg.token(e) {
12961                    Ok(token) => token,
12962                    Err(e) => {
12963                        dlg.finished(false);
12964                        return Err(common::Error::MissingToken(e));
12965                    }
12966                },
12967            };
12968            request_value_reader
12969                .seek(std::io::SeekFrom::Start(0))
12970                .unwrap();
12971            let mut req_result = {
12972                let client = &self.hub.client;
12973                dlg.pre_request();
12974                let mut req_builder = hyper::Request::builder()
12975                    .method(hyper::Method::PATCH)
12976                    .uri(url.as_str())
12977                    .header(USER_AGENT, self.hub._user_agent.clone());
12978
12979                if let Some(token) = token.as_ref() {
12980                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12981                }
12982
12983                let request = req_builder
12984                    .header(CONTENT_TYPE, json_mime_type.to_string())
12985                    .header(CONTENT_LENGTH, request_size as u64)
12986                    .body(common::to_body(
12987                        request_value_reader.get_ref().clone().into(),
12988                    ));
12989
12990                client.request(request.unwrap()).await
12991            };
12992
12993            match req_result {
12994                Err(err) => {
12995                    if let common::Retry::After(d) = dlg.http_error(&err) {
12996                        sleep(d).await;
12997                        continue;
12998                    }
12999                    dlg.finished(false);
13000                    return Err(common::Error::HttpError(err));
13001                }
13002                Ok(res) => {
13003                    let (mut parts, body) = res.into_parts();
13004                    let mut body = common::Body::new(body);
13005                    if !parts.status.is_success() {
13006                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13007                        let error = serde_json::from_str(&common::to_string(&bytes));
13008                        let response = common::to_response(parts, bytes.into());
13009
13010                        if let common::Retry::After(d) =
13011                            dlg.http_failure(&response, error.as_ref().ok())
13012                        {
13013                            sleep(d).await;
13014                            continue;
13015                        }
13016
13017                        dlg.finished(false);
13018
13019                        return Err(match error {
13020                            Ok(value) => common::Error::BadRequest(value),
13021                            _ => common::Error::Failure(response),
13022                        });
13023                    }
13024                    let response = {
13025                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13026                        let encoded = common::to_string(&bytes);
13027                        match serde_json::from_str(&encoded) {
13028                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13029                            Err(error) => {
13030                                dlg.response_json_decode_error(&encoded, &error);
13031                                return Err(common::Error::JsonDecodeError(
13032                                    encoded.to_string(),
13033                                    error,
13034                                ));
13035                            }
13036                        }
13037                    };
13038
13039                    dlg.finished(true);
13040                    return Ok(response);
13041                }
13042            }
13043        }
13044    }
13045
13046    ///
13047    /// Sets the *request* property to the given value.
13048    ///
13049    /// Even though the property as already been set when instantiating this call,
13050    /// we provide this method for API completeness.
13051    pub fn request(
13052        mut self,
13053        new_value: UpdateInstanceConfigRequest,
13054    ) -> ProjectLocationInstanceUpdateConfigCall<'a, C> {
13055        self._request = new_value;
13056        self
13057    }
13058    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
13059    ///
13060    /// Sets the *name* path property to the given value.
13061    ///
13062    /// Even though the property as already been set when instantiating this call,
13063    /// we provide this method for API completeness.
13064    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceUpdateConfigCall<'a, C> {
13065        self._name = new_value.to_string();
13066        self
13067    }
13068    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13069    /// while executing the actual API request.
13070    ///
13071    /// ````text
13072    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13073    /// ````
13074    ///
13075    /// Sets the *delegate* property to the given value.
13076    pub fn delegate(
13077        mut self,
13078        new_value: &'a mut dyn common::Delegate,
13079    ) -> ProjectLocationInstanceUpdateConfigCall<'a, C> {
13080        self._delegate = Some(new_value);
13081        self
13082    }
13083
13084    /// Set any additional parameter of the query string used in the request.
13085    /// It should be used to set parameters which are not yet available through their own
13086    /// setters.
13087    ///
13088    /// Please note that this method must not be used to set any of the known parameters
13089    /// which have their own setter method. If done anyway, the request will fail.
13090    ///
13091    /// # Additional Parameters
13092    ///
13093    /// * *$.xgafv* (query-string) - V1 error format.
13094    /// * *access_token* (query-string) - OAuth access token.
13095    /// * *alt* (query-string) - Data format for response.
13096    /// * *callback* (query-string) - JSONP
13097    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13098    /// * *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.
13099    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13100    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13101    /// * *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.
13102    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13103    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13104    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceUpdateConfigCall<'a, C>
13105    where
13106        T: AsRef<str>,
13107    {
13108        self._additional_params
13109            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13110        self
13111    }
13112
13113    /// Identifies the authorization scope for the method you are building.
13114    ///
13115    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13116    /// [`Scope::CloudPlatform`].
13117    ///
13118    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13119    /// tokens for more than one scope.
13120    ///
13121    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13122    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13123    /// sufficient, a read-write scope will do as well.
13124    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceUpdateConfigCall<'a, C>
13125    where
13126        St: AsRef<str>,
13127    {
13128        self._scopes.insert(String::from(scope.as_ref()));
13129        self
13130    }
13131    /// Identifies the authorization scope(s) for the method you are building.
13132    ///
13133    /// See [`Self::add_scope()`] for details.
13134    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceUpdateConfigCall<'a, C>
13135    where
13136        I: IntoIterator<Item = St>,
13137        St: AsRef<str>,
13138    {
13139        self._scopes
13140            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13141        self
13142    }
13143
13144    /// Removes all scopes, and no default scope will be used either.
13145    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13146    /// for details).
13147    pub fn clear_scopes(mut self) -> ProjectLocationInstanceUpdateConfigCall<'a, C> {
13148        self._scopes.clear();
13149        self
13150    }
13151}
13152
13153/// Add/update metadata items for an instance.
13154///
13155/// A builder for the *locations.instances.updateMetadataItems* method supported by a *project* resource.
13156/// It is not used directly, but through a [`ProjectMethods`] instance.
13157///
13158/// # Example
13159///
13160/// Instantiate a resource method builder
13161///
13162/// ```test_harness,no_run
13163/// # extern crate hyper;
13164/// # extern crate hyper_rustls;
13165/// # extern crate google_notebooks1 as notebooks1;
13166/// use notebooks1::api::UpdateInstanceMetadataItemsRequest;
13167/// # async fn dox() {
13168/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13169///
13170/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13171/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13172/// #     secret,
13173/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13174/// # ).build().await.unwrap();
13175///
13176/// # let client = hyper_util::client::legacy::Client::builder(
13177/// #     hyper_util::rt::TokioExecutor::new()
13178/// # )
13179/// # .build(
13180/// #     hyper_rustls::HttpsConnectorBuilder::new()
13181/// #         .with_native_roots()
13182/// #         .unwrap()
13183/// #         .https_or_http()
13184/// #         .enable_http1()
13185/// #         .build()
13186/// # );
13187/// # let mut hub = AIPlatformNotebooks::new(client, auth);
13188/// // As the method needs a request, you would usually fill it with the desired information
13189/// // into the respective structure. Some of the parts shown here might not be applicable !
13190/// // Values shown here are possibly random and not representative !
13191/// let mut req = UpdateInstanceMetadataItemsRequest::default();
13192///
13193/// // You can configure optional parameters by calling the respective setters at will, and
13194/// // execute the final call using `doit()`.
13195/// // Values shown here are possibly random and not representative !
13196/// let result = hub.projects().locations_instances_update_metadata_items(req, "name")
13197///              .doit().await;
13198/// # }
13199/// ```
13200pub struct ProjectLocationInstanceUpdateMetadataItemCall<'a, C>
13201where
13202    C: 'a,
13203{
13204    hub: &'a AIPlatformNotebooks<C>,
13205    _request: UpdateInstanceMetadataItemsRequest,
13206    _name: String,
13207    _delegate: Option<&'a mut dyn common::Delegate>,
13208    _additional_params: HashMap<String, String>,
13209    _scopes: BTreeSet<String>,
13210}
13211
13212impl<'a, C> common::CallBuilder for ProjectLocationInstanceUpdateMetadataItemCall<'a, C> {}
13213
13214impl<'a, C> ProjectLocationInstanceUpdateMetadataItemCall<'a, C>
13215where
13216    C: common::Connector,
13217{
13218    /// Perform the operation you have build so far.
13219    pub async fn doit(
13220        mut self,
13221    ) -> common::Result<(common::Response, UpdateInstanceMetadataItemsResponse)> {
13222        use std::borrow::Cow;
13223        use std::io::{Read, Seek};
13224
13225        use common::{url::Params, ToParts};
13226        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13227
13228        let mut dd = common::DefaultDelegate;
13229        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13230        dlg.begin(common::MethodInfo {
13231            id: "notebooks.projects.locations.instances.updateMetadataItems",
13232            http_method: hyper::Method::PATCH,
13233        });
13234
13235        for &field in ["alt", "name"].iter() {
13236            if self._additional_params.contains_key(field) {
13237                dlg.finished(false);
13238                return Err(common::Error::FieldClash(field));
13239            }
13240        }
13241
13242        let mut params = Params::with_capacity(4 + self._additional_params.len());
13243        params.push("name", self._name);
13244
13245        params.extend(self._additional_params.iter());
13246
13247        params.push("alt", "json");
13248        let mut url = self.hub._base_url.clone() + "v1/{+name}:updateMetadataItems";
13249        if self._scopes.is_empty() {
13250            self._scopes
13251                .insert(Scope::CloudPlatform.as_ref().to_string());
13252        }
13253
13254        #[allow(clippy::single_element_loop)]
13255        for &(find_this, param_name) in [("{+name}", "name")].iter() {
13256            url = params.uri_replacement(url, param_name, find_this, true);
13257        }
13258        {
13259            let to_remove = ["name"];
13260            params.remove_params(&to_remove);
13261        }
13262
13263        let url = params.parse_with_url(&url);
13264
13265        let mut json_mime_type = mime::APPLICATION_JSON;
13266        let mut request_value_reader = {
13267            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13268            common::remove_json_null_values(&mut value);
13269            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13270            serde_json::to_writer(&mut dst, &value).unwrap();
13271            dst
13272        };
13273        let request_size = request_value_reader
13274            .seek(std::io::SeekFrom::End(0))
13275            .unwrap();
13276        request_value_reader
13277            .seek(std::io::SeekFrom::Start(0))
13278            .unwrap();
13279
13280        loop {
13281            let token = match self
13282                .hub
13283                .auth
13284                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13285                .await
13286            {
13287                Ok(token) => token,
13288                Err(e) => match dlg.token(e) {
13289                    Ok(token) => token,
13290                    Err(e) => {
13291                        dlg.finished(false);
13292                        return Err(common::Error::MissingToken(e));
13293                    }
13294                },
13295            };
13296            request_value_reader
13297                .seek(std::io::SeekFrom::Start(0))
13298                .unwrap();
13299            let mut req_result = {
13300                let client = &self.hub.client;
13301                dlg.pre_request();
13302                let mut req_builder = hyper::Request::builder()
13303                    .method(hyper::Method::PATCH)
13304                    .uri(url.as_str())
13305                    .header(USER_AGENT, self.hub._user_agent.clone());
13306
13307                if let Some(token) = token.as_ref() {
13308                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13309                }
13310
13311                let request = req_builder
13312                    .header(CONTENT_TYPE, json_mime_type.to_string())
13313                    .header(CONTENT_LENGTH, request_size as u64)
13314                    .body(common::to_body(
13315                        request_value_reader.get_ref().clone().into(),
13316                    ));
13317
13318                client.request(request.unwrap()).await
13319            };
13320
13321            match req_result {
13322                Err(err) => {
13323                    if let common::Retry::After(d) = dlg.http_error(&err) {
13324                        sleep(d).await;
13325                        continue;
13326                    }
13327                    dlg.finished(false);
13328                    return Err(common::Error::HttpError(err));
13329                }
13330                Ok(res) => {
13331                    let (mut parts, body) = res.into_parts();
13332                    let mut body = common::Body::new(body);
13333                    if !parts.status.is_success() {
13334                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13335                        let error = serde_json::from_str(&common::to_string(&bytes));
13336                        let response = common::to_response(parts, bytes.into());
13337
13338                        if let common::Retry::After(d) =
13339                            dlg.http_failure(&response, error.as_ref().ok())
13340                        {
13341                            sleep(d).await;
13342                            continue;
13343                        }
13344
13345                        dlg.finished(false);
13346
13347                        return Err(match error {
13348                            Ok(value) => common::Error::BadRequest(value),
13349                            _ => common::Error::Failure(response),
13350                        });
13351                    }
13352                    let response = {
13353                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13354                        let encoded = common::to_string(&bytes);
13355                        match serde_json::from_str(&encoded) {
13356                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13357                            Err(error) => {
13358                                dlg.response_json_decode_error(&encoded, &error);
13359                                return Err(common::Error::JsonDecodeError(
13360                                    encoded.to_string(),
13361                                    error,
13362                                ));
13363                            }
13364                        }
13365                    };
13366
13367                    dlg.finished(true);
13368                    return Ok(response);
13369                }
13370            }
13371        }
13372    }
13373
13374    ///
13375    /// Sets the *request* property to the given value.
13376    ///
13377    /// Even though the property as already been set when instantiating this call,
13378    /// we provide this method for API completeness.
13379    pub fn request(
13380        mut self,
13381        new_value: UpdateInstanceMetadataItemsRequest,
13382    ) -> ProjectLocationInstanceUpdateMetadataItemCall<'a, C> {
13383        self._request = new_value;
13384        self
13385    }
13386    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
13387    ///
13388    /// Sets the *name* path property to the given value.
13389    ///
13390    /// Even though the property as already been set when instantiating this call,
13391    /// we provide this method for API completeness.
13392    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceUpdateMetadataItemCall<'a, C> {
13393        self._name = new_value.to_string();
13394        self
13395    }
13396    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13397    /// while executing the actual API request.
13398    ///
13399    /// ````text
13400    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13401    /// ````
13402    ///
13403    /// Sets the *delegate* property to the given value.
13404    pub fn delegate(
13405        mut self,
13406        new_value: &'a mut dyn common::Delegate,
13407    ) -> ProjectLocationInstanceUpdateMetadataItemCall<'a, C> {
13408        self._delegate = Some(new_value);
13409        self
13410    }
13411
13412    /// Set any additional parameter of the query string used in the request.
13413    /// It should be used to set parameters which are not yet available through their own
13414    /// setters.
13415    ///
13416    /// Please note that this method must not be used to set any of the known parameters
13417    /// which have their own setter method. If done anyway, the request will fail.
13418    ///
13419    /// # Additional Parameters
13420    ///
13421    /// * *$.xgafv* (query-string) - V1 error format.
13422    /// * *access_token* (query-string) - OAuth access token.
13423    /// * *alt* (query-string) - Data format for response.
13424    /// * *callback* (query-string) - JSONP
13425    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13426    /// * *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.
13427    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13428    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13429    /// * *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.
13430    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13431    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13432    pub fn param<T>(
13433        mut self,
13434        name: T,
13435        value: T,
13436    ) -> ProjectLocationInstanceUpdateMetadataItemCall<'a, C>
13437    where
13438        T: AsRef<str>,
13439    {
13440        self._additional_params
13441            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13442        self
13443    }
13444
13445    /// Identifies the authorization scope for the method you are building.
13446    ///
13447    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13448    /// [`Scope::CloudPlatform`].
13449    ///
13450    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13451    /// tokens for more than one scope.
13452    ///
13453    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13454    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13455    /// sufficient, a read-write scope will do as well.
13456    pub fn add_scope<St>(
13457        mut self,
13458        scope: St,
13459    ) -> ProjectLocationInstanceUpdateMetadataItemCall<'a, C>
13460    where
13461        St: AsRef<str>,
13462    {
13463        self._scopes.insert(String::from(scope.as_ref()));
13464        self
13465    }
13466    /// Identifies the authorization scope(s) for the method you are building.
13467    ///
13468    /// See [`Self::add_scope()`] for details.
13469    pub fn add_scopes<I, St>(
13470        mut self,
13471        scopes: I,
13472    ) -> ProjectLocationInstanceUpdateMetadataItemCall<'a, C>
13473    where
13474        I: IntoIterator<Item = St>,
13475        St: AsRef<str>,
13476    {
13477        self._scopes
13478            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13479        self
13480    }
13481
13482    /// Removes all scopes, and no default scope will be used either.
13483    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13484    /// for details).
13485    pub fn clear_scopes(mut self) -> ProjectLocationInstanceUpdateMetadataItemCall<'a, C> {
13486        self._scopes.clear();
13487        self
13488    }
13489}
13490
13491/// Updates the Shielded instance configuration of a single Instance.
13492///
13493/// A builder for the *locations.instances.updateShieldedInstanceConfig* method supported by a *project* resource.
13494/// It is not used directly, but through a [`ProjectMethods`] instance.
13495///
13496/// # Example
13497///
13498/// Instantiate a resource method builder
13499///
13500/// ```test_harness,no_run
13501/// # extern crate hyper;
13502/// # extern crate hyper_rustls;
13503/// # extern crate google_notebooks1 as notebooks1;
13504/// use notebooks1::api::UpdateShieldedInstanceConfigRequest;
13505/// # async fn dox() {
13506/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13507///
13508/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13509/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13510/// #     secret,
13511/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13512/// # ).build().await.unwrap();
13513///
13514/// # let client = hyper_util::client::legacy::Client::builder(
13515/// #     hyper_util::rt::TokioExecutor::new()
13516/// # )
13517/// # .build(
13518/// #     hyper_rustls::HttpsConnectorBuilder::new()
13519/// #         .with_native_roots()
13520/// #         .unwrap()
13521/// #         .https_or_http()
13522/// #         .enable_http1()
13523/// #         .build()
13524/// # );
13525/// # let mut hub = AIPlatformNotebooks::new(client, auth);
13526/// // As the method needs a request, you would usually fill it with the desired information
13527/// // into the respective structure. Some of the parts shown here might not be applicable !
13528/// // Values shown here are possibly random and not representative !
13529/// let mut req = UpdateShieldedInstanceConfigRequest::default();
13530///
13531/// // You can configure optional parameters by calling the respective setters at will, and
13532/// // execute the final call using `doit()`.
13533/// // Values shown here are possibly random and not representative !
13534/// let result = hub.projects().locations_instances_update_shielded_instance_config(req, "name")
13535///              .doit().await;
13536/// # }
13537/// ```
13538pub struct ProjectLocationInstanceUpdateShieldedInstanceConfigCall<'a, C>
13539where
13540    C: 'a,
13541{
13542    hub: &'a AIPlatformNotebooks<C>,
13543    _request: UpdateShieldedInstanceConfigRequest,
13544    _name: String,
13545    _delegate: Option<&'a mut dyn common::Delegate>,
13546    _additional_params: HashMap<String, String>,
13547    _scopes: BTreeSet<String>,
13548}
13549
13550impl<'a, C> common::CallBuilder for ProjectLocationInstanceUpdateShieldedInstanceConfigCall<'a, C> {}
13551
13552impl<'a, C> ProjectLocationInstanceUpdateShieldedInstanceConfigCall<'a, C>
13553where
13554    C: common::Connector,
13555{
13556    /// Perform the operation you have build so far.
13557    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
13558        use std::borrow::Cow;
13559        use std::io::{Read, Seek};
13560
13561        use common::{url::Params, ToParts};
13562        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13563
13564        let mut dd = common::DefaultDelegate;
13565        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13566        dlg.begin(common::MethodInfo {
13567            id: "notebooks.projects.locations.instances.updateShieldedInstanceConfig",
13568            http_method: hyper::Method::PATCH,
13569        });
13570
13571        for &field in ["alt", "name"].iter() {
13572            if self._additional_params.contains_key(field) {
13573                dlg.finished(false);
13574                return Err(common::Error::FieldClash(field));
13575            }
13576        }
13577
13578        let mut params = Params::with_capacity(4 + self._additional_params.len());
13579        params.push("name", self._name);
13580
13581        params.extend(self._additional_params.iter());
13582
13583        params.push("alt", "json");
13584        let mut url = self.hub._base_url.clone() + "v1/{+name}:updateShieldedInstanceConfig";
13585        if self._scopes.is_empty() {
13586            self._scopes
13587                .insert(Scope::CloudPlatform.as_ref().to_string());
13588        }
13589
13590        #[allow(clippy::single_element_loop)]
13591        for &(find_this, param_name) in [("{+name}", "name")].iter() {
13592            url = params.uri_replacement(url, param_name, find_this, true);
13593        }
13594        {
13595            let to_remove = ["name"];
13596            params.remove_params(&to_remove);
13597        }
13598
13599        let url = params.parse_with_url(&url);
13600
13601        let mut json_mime_type = mime::APPLICATION_JSON;
13602        let mut request_value_reader = {
13603            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13604            common::remove_json_null_values(&mut value);
13605            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13606            serde_json::to_writer(&mut dst, &value).unwrap();
13607            dst
13608        };
13609        let request_size = request_value_reader
13610            .seek(std::io::SeekFrom::End(0))
13611            .unwrap();
13612        request_value_reader
13613            .seek(std::io::SeekFrom::Start(0))
13614            .unwrap();
13615
13616        loop {
13617            let token = match self
13618                .hub
13619                .auth
13620                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13621                .await
13622            {
13623                Ok(token) => token,
13624                Err(e) => match dlg.token(e) {
13625                    Ok(token) => token,
13626                    Err(e) => {
13627                        dlg.finished(false);
13628                        return Err(common::Error::MissingToken(e));
13629                    }
13630                },
13631            };
13632            request_value_reader
13633                .seek(std::io::SeekFrom::Start(0))
13634                .unwrap();
13635            let mut req_result = {
13636                let client = &self.hub.client;
13637                dlg.pre_request();
13638                let mut req_builder = hyper::Request::builder()
13639                    .method(hyper::Method::PATCH)
13640                    .uri(url.as_str())
13641                    .header(USER_AGENT, self.hub._user_agent.clone());
13642
13643                if let Some(token) = token.as_ref() {
13644                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13645                }
13646
13647                let request = req_builder
13648                    .header(CONTENT_TYPE, json_mime_type.to_string())
13649                    .header(CONTENT_LENGTH, request_size as u64)
13650                    .body(common::to_body(
13651                        request_value_reader.get_ref().clone().into(),
13652                    ));
13653
13654                client.request(request.unwrap()).await
13655            };
13656
13657            match req_result {
13658                Err(err) => {
13659                    if let common::Retry::After(d) = dlg.http_error(&err) {
13660                        sleep(d).await;
13661                        continue;
13662                    }
13663                    dlg.finished(false);
13664                    return Err(common::Error::HttpError(err));
13665                }
13666                Ok(res) => {
13667                    let (mut parts, body) = res.into_parts();
13668                    let mut body = common::Body::new(body);
13669                    if !parts.status.is_success() {
13670                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13671                        let error = serde_json::from_str(&common::to_string(&bytes));
13672                        let response = common::to_response(parts, bytes.into());
13673
13674                        if let common::Retry::After(d) =
13675                            dlg.http_failure(&response, error.as_ref().ok())
13676                        {
13677                            sleep(d).await;
13678                            continue;
13679                        }
13680
13681                        dlg.finished(false);
13682
13683                        return Err(match error {
13684                            Ok(value) => common::Error::BadRequest(value),
13685                            _ => common::Error::Failure(response),
13686                        });
13687                    }
13688                    let response = {
13689                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13690                        let encoded = common::to_string(&bytes);
13691                        match serde_json::from_str(&encoded) {
13692                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13693                            Err(error) => {
13694                                dlg.response_json_decode_error(&encoded, &error);
13695                                return Err(common::Error::JsonDecodeError(
13696                                    encoded.to_string(),
13697                                    error,
13698                                ));
13699                            }
13700                        }
13701                    };
13702
13703                    dlg.finished(true);
13704                    return Ok(response);
13705                }
13706            }
13707        }
13708    }
13709
13710    ///
13711    /// Sets the *request* property to the given value.
13712    ///
13713    /// Even though the property as already been set when instantiating this call,
13714    /// we provide this method for API completeness.
13715    pub fn request(
13716        mut self,
13717        new_value: UpdateShieldedInstanceConfigRequest,
13718    ) -> ProjectLocationInstanceUpdateShieldedInstanceConfigCall<'a, C> {
13719        self._request = new_value;
13720        self
13721    }
13722    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
13723    ///
13724    /// Sets the *name* path property to the given value.
13725    ///
13726    /// Even though the property as already been set when instantiating this call,
13727    /// we provide this method for API completeness.
13728    pub fn name(
13729        mut self,
13730        new_value: &str,
13731    ) -> ProjectLocationInstanceUpdateShieldedInstanceConfigCall<'a, C> {
13732        self._name = new_value.to_string();
13733        self
13734    }
13735    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13736    /// while executing the actual API request.
13737    ///
13738    /// ````text
13739    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13740    /// ````
13741    ///
13742    /// Sets the *delegate* property to the given value.
13743    pub fn delegate(
13744        mut self,
13745        new_value: &'a mut dyn common::Delegate,
13746    ) -> ProjectLocationInstanceUpdateShieldedInstanceConfigCall<'a, C> {
13747        self._delegate = Some(new_value);
13748        self
13749    }
13750
13751    /// Set any additional parameter of the query string used in the request.
13752    /// It should be used to set parameters which are not yet available through their own
13753    /// setters.
13754    ///
13755    /// Please note that this method must not be used to set any of the known parameters
13756    /// which have their own setter method. If done anyway, the request will fail.
13757    ///
13758    /// # Additional Parameters
13759    ///
13760    /// * *$.xgafv* (query-string) - V1 error format.
13761    /// * *access_token* (query-string) - OAuth access token.
13762    /// * *alt* (query-string) - Data format for response.
13763    /// * *callback* (query-string) - JSONP
13764    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13765    /// * *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.
13766    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13767    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13768    /// * *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.
13769    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13770    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13771    pub fn param<T>(
13772        mut self,
13773        name: T,
13774        value: T,
13775    ) -> ProjectLocationInstanceUpdateShieldedInstanceConfigCall<'a, C>
13776    where
13777        T: AsRef<str>,
13778    {
13779        self._additional_params
13780            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13781        self
13782    }
13783
13784    /// Identifies the authorization scope for the method you are building.
13785    ///
13786    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13787    /// [`Scope::CloudPlatform`].
13788    ///
13789    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13790    /// tokens for more than one scope.
13791    ///
13792    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13793    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13794    /// sufficient, a read-write scope will do as well.
13795    pub fn add_scope<St>(
13796        mut self,
13797        scope: St,
13798    ) -> ProjectLocationInstanceUpdateShieldedInstanceConfigCall<'a, C>
13799    where
13800        St: AsRef<str>,
13801    {
13802        self._scopes.insert(String::from(scope.as_ref()));
13803        self
13804    }
13805    /// Identifies the authorization scope(s) for the method you are building.
13806    ///
13807    /// See [`Self::add_scope()`] for details.
13808    pub fn add_scopes<I, St>(
13809        mut self,
13810        scopes: I,
13811    ) -> ProjectLocationInstanceUpdateShieldedInstanceConfigCall<'a, C>
13812    where
13813        I: IntoIterator<Item = St>,
13814        St: AsRef<str>,
13815    {
13816        self._scopes
13817            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13818        self
13819    }
13820
13821    /// Removes all scopes, and no default scope will be used either.
13822    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13823    /// for details).
13824    pub fn clear_scopes(
13825        mut self,
13826    ) -> ProjectLocationInstanceUpdateShieldedInstanceConfigCall<'a, C> {
13827        self._scopes.clear();
13828        self
13829    }
13830}
13831
13832/// Upgrades a notebook instance to the latest version.
13833///
13834/// A builder for the *locations.instances.upgrade* method supported by a *project* resource.
13835/// It is not used directly, but through a [`ProjectMethods`] instance.
13836///
13837/// # Example
13838///
13839/// Instantiate a resource method builder
13840///
13841/// ```test_harness,no_run
13842/// # extern crate hyper;
13843/// # extern crate hyper_rustls;
13844/// # extern crate google_notebooks1 as notebooks1;
13845/// use notebooks1::api::UpgradeInstanceRequest;
13846/// # async fn dox() {
13847/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13848///
13849/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13850/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13851/// #     secret,
13852/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13853/// # ).build().await.unwrap();
13854///
13855/// # let client = hyper_util::client::legacy::Client::builder(
13856/// #     hyper_util::rt::TokioExecutor::new()
13857/// # )
13858/// # .build(
13859/// #     hyper_rustls::HttpsConnectorBuilder::new()
13860/// #         .with_native_roots()
13861/// #         .unwrap()
13862/// #         .https_or_http()
13863/// #         .enable_http1()
13864/// #         .build()
13865/// # );
13866/// # let mut hub = AIPlatformNotebooks::new(client, auth);
13867/// // As the method needs a request, you would usually fill it with the desired information
13868/// // into the respective structure. Some of the parts shown here might not be applicable !
13869/// // Values shown here are possibly random and not representative !
13870/// let mut req = UpgradeInstanceRequest::default();
13871///
13872/// // You can configure optional parameters by calling the respective setters at will, and
13873/// // execute the final call using `doit()`.
13874/// // Values shown here are possibly random and not representative !
13875/// let result = hub.projects().locations_instances_upgrade(req, "name")
13876///              .doit().await;
13877/// # }
13878/// ```
13879pub struct ProjectLocationInstanceUpgradeCall<'a, C>
13880where
13881    C: 'a,
13882{
13883    hub: &'a AIPlatformNotebooks<C>,
13884    _request: UpgradeInstanceRequest,
13885    _name: String,
13886    _delegate: Option<&'a mut dyn common::Delegate>,
13887    _additional_params: HashMap<String, String>,
13888    _scopes: BTreeSet<String>,
13889}
13890
13891impl<'a, C> common::CallBuilder for ProjectLocationInstanceUpgradeCall<'a, C> {}
13892
13893impl<'a, C> ProjectLocationInstanceUpgradeCall<'a, C>
13894where
13895    C: common::Connector,
13896{
13897    /// Perform the operation you have build so far.
13898    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
13899        use std::borrow::Cow;
13900        use std::io::{Read, Seek};
13901
13902        use common::{url::Params, ToParts};
13903        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13904
13905        let mut dd = common::DefaultDelegate;
13906        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13907        dlg.begin(common::MethodInfo {
13908            id: "notebooks.projects.locations.instances.upgrade",
13909            http_method: hyper::Method::POST,
13910        });
13911
13912        for &field in ["alt", "name"].iter() {
13913            if self._additional_params.contains_key(field) {
13914                dlg.finished(false);
13915                return Err(common::Error::FieldClash(field));
13916            }
13917        }
13918
13919        let mut params = Params::with_capacity(4 + self._additional_params.len());
13920        params.push("name", self._name);
13921
13922        params.extend(self._additional_params.iter());
13923
13924        params.push("alt", "json");
13925        let mut url = self.hub._base_url.clone() + "v1/{+name}:upgrade";
13926        if self._scopes.is_empty() {
13927            self._scopes
13928                .insert(Scope::CloudPlatform.as_ref().to_string());
13929        }
13930
13931        #[allow(clippy::single_element_loop)]
13932        for &(find_this, param_name) in [("{+name}", "name")].iter() {
13933            url = params.uri_replacement(url, param_name, find_this, true);
13934        }
13935        {
13936            let to_remove = ["name"];
13937            params.remove_params(&to_remove);
13938        }
13939
13940        let url = params.parse_with_url(&url);
13941
13942        let mut json_mime_type = mime::APPLICATION_JSON;
13943        let mut request_value_reader = {
13944            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13945            common::remove_json_null_values(&mut value);
13946            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13947            serde_json::to_writer(&mut dst, &value).unwrap();
13948            dst
13949        };
13950        let request_size = request_value_reader
13951            .seek(std::io::SeekFrom::End(0))
13952            .unwrap();
13953        request_value_reader
13954            .seek(std::io::SeekFrom::Start(0))
13955            .unwrap();
13956
13957        loop {
13958            let token = match self
13959                .hub
13960                .auth
13961                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13962                .await
13963            {
13964                Ok(token) => token,
13965                Err(e) => match dlg.token(e) {
13966                    Ok(token) => token,
13967                    Err(e) => {
13968                        dlg.finished(false);
13969                        return Err(common::Error::MissingToken(e));
13970                    }
13971                },
13972            };
13973            request_value_reader
13974                .seek(std::io::SeekFrom::Start(0))
13975                .unwrap();
13976            let mut req_result = {
13977                let client = &self.hub.client;
13978                dlg.pre_request();
13979                let mut req_builder = hyper::Request::builder()
13980                    .method(hyper::Method::POST)
13981                    .uri(url.as_str())
13982                    .header(USER_AGENT, self.hub._user_agent.clone());
13983
13984                if let Some(token) = token.as_ref() {
13985                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13986                }
13987
13988                let request = req_builder
13989                    .header(CONTENT_TYPE, json_mime_type.to_string())
13990                    .header(CONTENT_LENGTH, request_size as u64)
13991                    .body(common::to_body(
13992                        request_value_reader.get_ref().clone().into(),
13993                    ));
13994
13995                client.request(request.unwrap()).await
13996            };
13997
13998            match req_result {
13999                Err(err) => {
14000                    if let common::Retry::After(d) = dlg.http_error(&err) {
14001                        sleep(d).await;
14002                        continue;
14003                    }
14004                    dlg.finished(false);
14005                    return Err(common::Error::HttpError(err));
14006                }
14007                Ok(res) => {
14008                    let (mut parts, body) = res.into_parts();
14009                    let mut body = common::Body::new(body);
14010                    if !parts.status.is_success() {
14011                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14012                        let error = serde_json::from_str(&common::to_string(&bytes));
14013                        let response = common::to_response(parts, bytes.into());
14014
14015                        if let common::Retry::After(d) =
14016                            dlg.http_failure(&response, error.as_ref().ok())
14017                        {
14018                            sleep(d).await;
14019                            continue;
14020                        }
14021
14022                        dlg.finished(false);
14023
14024                        return Err(match error {
14025                            Ok(value) => common::Error::BadRequest(value),
14026                            _ => common::Error::Failure(response),
14027                        });
14028                    }
14029                    let response = {
14030                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14031                        let encoded = common::to_string(&bytes);
14032                        match serde_json::from_str(&encoded) {
14033                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14034                            Err(error) => {
14035                                dlg.response_json_decode_error(&encoded, &error);
14036                                return Err(common::Error::JsonDecodeError(
14037                                    encoded.to_string(),
14038                                    error,
14039                                ));
14040                            }
14041                        }
14042                    };
14043
14044                    dlg.finished(true);
14045                    return Ok(response);
14046                }
14047            }
14048        }
14049    }
14050
14051    ///
14052    /// Sets the *request* property to the given value.
14053    ///
14054    /// Even though the property as already been set when instantiating this call,
14055    /// we provide this method for API completeness.
14056    pub fn request(
14057        mut self,
14058        new_value: UpgradeInstanceRequest,
14059    ) -> ProjectLocationInstanceUpgradeCall<'a, C> {
14060        self._request = new_value;
14061        self
14062    }
14063    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
14064    ///
14065    /// Sets the *name* path property to the given value.
14066    ///
14067    /// Even though the property as already been set when instantiating this call,
14068    /// we provide this method for API completeness.
14069    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceUpgradeCall<'a, C> {
14070        self._name = new_value.to_string();
14071        self
14072    }
14073    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14074    /// while executing the actual API request.
14075    ///
14076    /// ````text
14077    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14078    /// ````
14079    ///
14080    /// Sets the *delegate* property to the given value.
14081    pub fn delegate(
14082        mut self,
14083        new_value: &'a mut dyn common::Delegate,
14084    ) -> ProjectLocationInstanceUpgradeCall<'a, C> {
14085        self._delegate = Some(new_value);
14086        self
14087    }
14088
14089    /// Set any additional parameter of the query string used in the request.
14090    /// It should be used to set parameters which are not yet available through their own
14091    /// setters.
14092    ///
14093    /// Please note that this method must not be used to set any of the known parameters
14094    /// which have their own setter method. If done anyway, the request will fail.
14095    ///
14096    /// # Additional Parameters
14097    ///
14098    /// * *$.xgafv* (query-string) - V1 error format.
14099    /// * *access_token* (query-string) - OAuth access token.
14100    /// * *alt* (query-string) - Data format for response.
14101    /// * *callback* (query-string) - JSONP
14102    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14103    /// * *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.
14104    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14105    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14106    /// * *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.
14107    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14108    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14109    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceUpgradeCall<'a, C>
14110    where
14111        T: AsRef<str>,
14112    {
14113        self._additional_params
14114            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14115        self
14116    }
14117
14118    /// Identifies the authorization scope for the method you are building.
14119    ///
14120    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14121    /// [`Scope::CloudPlatform`].
14122    ///
14123    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14124    /// tokens for more than one scope.
14125    ///
14126    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14127    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14128    /// sufficient, a read-write scope will do as well.
14129    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceUpgradeCall<'a, C>
14130    where
14131        St: AsRef<str>,
14132    {
14133        self._scopes.insert(String::from(scope.as_ref()));
14134        self
14135    }
14136    /// Identifies the authorization scope(s) for the method you are building.
14137    ///
14138    /// See [`Self::add_scope()`] for details.
14139    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceUpgradeCall<'a, C>
14140    where
14141        I: IntoIterator<Item = St>,
14142        St: AsRef<str>,
14143    {
14144        self._scopes
14145            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14146        self
14147    }
14148
14149    /// Removes all scopes, and no default scope will be used either.
14150    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14151    /// for details).
14152    pub fn clear_scopes(mut self) -> ProjectLocationInstanceUpgradeCall<'a, C> {
14153        self._scopes.clear();
14154        self
14155    }
14156}
14157
14158/// Allows notebook instances to call this endpoint to upgrade themselves. Do not use this method directly.
14159///
14160/// A builder for the *locations.instances.upgradeInternal* method supported by a *project* resource.
14161/// It is not used directly, but through a [`ProjectMethods`] instance.
14162///
14163/// # Example
14164///
14165/// Instantiate a resource method builder
14166///
14167/// ```test_harness,no_run
14168/// # extern crate hyper;
14169/// # extern crate hyper_rustls;
14170/// # extern crate google_notebooks1 as notebooks1;
14171/// use notebooks1::api::UpgradeInstanceInternalRequest;
14172/// # async fn dox() {
14173/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14174///
14175/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14176/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14177/// #     secret,
14178/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14179/// # ).build().await.unwrap();
14180///
14181/// # let client = hyper_util::client::legacy::Client::builder(
14182/// #     hyper_util::rt::TokioExecutor::new()
14183/// # )
14184/// # .build(
14185/// #     hyper_rustls::HttpsConnectorBuilder::new()
14186/// #         .with_native_roots()
14187/// #         .unwrap()
14188/// #         .https_or_http()
14189/// #         .enable_http1()
14190/// #         .build()
14191/// # );
14192/// # let mut hub = AIPlatformNotebooks::new(client, auth);
14193/// // As the method needs a request, you would usually fill it with the desired information
14194/// // into the respective structure. Some of the parts shown here might not be applicable !
14195/// // Values shown here are possibly random and not representative !
14196/// let mut req = UpgradeInstanceInternalRequest::default();
14197///
14198/// // You can configure optional parameters by calling the respective setters at will, and
14199/// // execute the final call using `doit()`.
14200/// // Values shown here are possibly random and not representative !
14201/// let result = hub.projects().locations_instances_upgrade_internal(req, "name")
14202///              .doit().await;
14203/// # }
14204/// ```
14205pub struct ProjectLocationInstanceUpgradeInternalCall<'a, C>
14206where
14207    C: 'a,
14208{
14209    hub: &'a AIPlatformNotebooks<C>,
14210    _request: UpgradeInstanceInternalRequest,
14211    _name: String,
14212    _delegate: Option<&'a mut dyn common::Delegate>,
14213    _additional_params: HashMap<String, String>,
14214    _scopes: BTreeSet<String>,
14215}
14216
14217impl<'a, C> common::CallBuilder for ProjectLocationInstanceUpgradeInternalCall<'a, C> {}
14218
14219impl<'a, C> ProjectLocationInstanceUpgradeInternalCall<'a, C>
14220where
14221    C: common::Connector,
14222{
14223    /// Perform the operation you have build so far.
14224    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
14225        use std::borrow::Cow;
14226        use std::io::{Read, Seek};
14227
14228        use common::{url::Params, ToParts};
14229        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14230
14231        let mut dd = common::DefaultDelegate;
14232        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14233        dlg.begin(common::MethodInfo {
14234            id: "notebooks.projects.locations.instances.upgradeInternal",
14235            http_method: hyper::Method::POST,
14236        });
14237
14238        for &field in ["alt", "name"].iter() {
14239            if self._additional_params.contains_key(field) {
14240                dlg.finished(false);
14241                return Err(common::Error::FieldClash(field));
14242            }
14243        }
14244
14245        let mut params = Params::with_capacity(4 + self._additional_params.len());
14246        params.push("name", self._name);
14247
14248        params.extend(self._additional_params.iter());
14249
14250        params.push("alt", "json");
14251        let mut url = self.hub._base_url.clone() + "v1/{+name}:upgradeInternal";
14252        if self._scopes.is_empty() {
14253            self._scopes
14254                .insert(Scope::CloudPlatform.as_ref().to_string());
14255        }
14256
14257        #[allow(clippy::single_element_loop)]
14258        for &(find_this, param_name) in [("{+name}", "name")].iter() {
14259            url = params.uri_replacement(url, param_name, find_this, true);
14260        }
14261        {
14262            let to_remove = ["name"];
14263            params.remove_params(&to_remove);
14264        }
14265
14266        let url = params.parse_with_url(&url);
14267
14268        let mut json_mime_type = mime::APPLICATION_JSON;
14269        let mut request_value_reader = {
14270            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14271            common::remove_json_null_values(&mut value);
14272            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14273            serde_json::to_writer(&mut dst, &value).unwrap();
14274            dst
14275        };
14276        let request_size = request_value_reader
14277            .seek(std::io::SeekFrom::End(0))
14278            .unwrap();
14279        request_value_reader
14280            .seek(std::io::SeekFrom::Start(0))
14281            .unwrap();
14282
14283        loop {
14284            let token = match self
14285                .hub
14286                .auth
14287                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14288                .await
14289            {
14290                Ok(token) => token,
14291                Err(e) => match dlg.token(e) {
14292                    Ok(token) => token,
14293                    Err(e) => {
14294                        dlg.finished(false);
14295                        return Err(common::Error::MissingToken(e));
14296                    }
14297                },
14298            };
14299            request_value_reader
14300                .seek(std::io::SeekFrom::Start(0))
14301                .unwrap();
14302            let mut req_result = {
14303                let client = &self.hub.client;
14304                dlg.pre_request();
14305                let mut req_builder = hyper::Request::builder()
14306                    .method(hyper::Method::POST)
14307                    .uri(url.as_str())
14308                    .header(USER_AGENT, self.hub._user_agent.clone());
14309
14310                if let Some(token) = token.as_ref() {
14311                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14312                }
14313
14314                let request = req_builder
14315                    .header(CONTENT_TYPE, json_mime_type.to_string())
14316                    .header(CONTENT_LENGTH, request_size as u64)
14317                    .body(common::to_body(
14318                        request_value_reader.get_ref().clone().into(),
14319                    ));
14320
14321                client.request(request.unwrap()).await
14322            };
14323
14324            match req_result {
14325                Err(err) => {
14326                    if let common::Retry::After(d) = dlg.http_error(&err) {
14327                        sleep(d).await;
14328                        continue;
14329                    }
14330                    dlg.finished(false);
14331                    return Err(common::Error::HttpError(err));
14332                }
14333                Ok(res) => {
14334                    let (mut parts, body) = res.into_parts();
14335                    let mut body = common::Body::new(body);
14336                    if !parts.status.is_success() {
14337                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14338                        let error = serde_json::from_str(&common::to_string(&bytes));
14339                        let response = common::to_response(parts, bytes.into());
14340
14341                        if let common::Retry::After(d) =
14342                            dlg.http_failure(&response, error.as_ref().ok())
14343                        {
14344                            sleep(d).await;
14345                            continue;
14346                        }
14347
14348                        dlg.finished(false);
14349
14350                        return Err(match error {
14351                            Ok(value) => common::Error::BadRequest(value),
14352                            _ => common::Error::Failure(response),
14353                        });
14354                    }
14355                    let response = {
14356                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14357                        let encoded = common::to_string(&bytes);
14358                        match serde_json::from_str(&encoded) {
14359                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14360                            Err(error) => {
14361                                dlg.response_json_decode_error(&encoded, &error);
14362                                return Err(common::Error::JsonDecodeError(
14363                                    encoded.to_string(),
14364                                    error,
14365                                ));
14366                            }
14367                        }
14368                    };
14369
14370                    dlg.finished(true);
14371                    return Ok(response);
14372                }
14373            }
14374        }
14375    }
14376
14377    ///
14378    /// Sets the *request* property to the given value.
14379    ///
14380    /// Even though the property as already been set when instantiating this call,
14381    /// we provide this method for API completeness.
14382    pub fn request(
14383        mut self,
14384        new_value: UpgradeInstanceInternalRequest,
14385    ) -> ProjectLocationInstanceUpgradeInternalCall<'a, C> {
14386        self._request = new_value;
14387        self
14388    }
14389    /// Required. Format: `projects/{project_id}/locations/{location}/instances/{instance_id}`
14390    ///
14391    /// Sets the *name* path property to the given value.
14392    ///
14393    /// Even though the property as already been set when instantiating this call,
14394    /// we provide this method for API completeness.
14395    pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceUpgradeInternalCall<'a, C> {
14396        self._name = new_value.to_string();
14397        self
14398    }
14399    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14400    /// while executing the actual API request.
14401    ///
14402    /// ````text
14403    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14404    /// ````
14405    ///
14406    /// Sets the *delegate* property to the given value.
14407    pub fn delegate(
14408        mut self,
14409        new_value: &'a mut dyn common::Delegate,
14410    ) -> ProjectLocationInstanceUpgradeInternalCall<'a, C> {
14411        self._delegate = Some(new_value);
14412        self
14413    }
14414
14415    /// Set any additional parameter of the query string used in the request.
14416    /// It should be used to set parameters which are not yet available through their own
14417    /// setters.
14418    ///
14419    /// Please note that this method must not be used to set any of the known parameters
14420    /// which have their own setter method. If done anyway, the request will fail.
14421    ///
14422    /// # Additional Parameters
14423    ///
14424    /// * *$.xgafv* (query-string) - V1 error format.
14425    /// * *access_token* (query-string) - OAuth access token.
14426    /// * *alt* (query-string) - Data format for response.
14427    /// * *callback* (query-string) - JSONP
14428    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14429    /// * *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.
14430    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14431    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14432    /// * *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.
14433    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14434    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14435    pub fn param<T>(
14436        mut self,
14437        name: T,
14438        value: T,
14439    ) -> ProjectLocationInstanceUpgradeInternalCall<'a, C>
14440    where
14441        T: AsRef<str>,
14442    {
14443        self._additional_params
14444            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14445        self
14446    }
14447
14448    /// Identifies the authorization scope for the method you are building.
14449    ///
14450    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14451    /// [`Scope::CloudPlatform`].
14452    ///
14453    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14454    /// tokens for more than one scope.
14455    ///
14456    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14457    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14458    /// sufficient, a read-write scope will do as well.
14459    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceUpgradeInternalCall<'a, C>
14460    where
14461        St: AsRef<str>,
14462    {
14463        self._scopes.insert(String::from(scope.as_ref()));
14464        self
14465    }
14466    /// Identifies the authorization scope(s) for the method you are building.
14467    ///
14468    /// See [`Self::add_scope()`] for details.
14469    pub fn add_scopes<I, St>(
14470        mut self,
14471        scopes: I,
14472    ) -> ProjectLocationInstanceUpgradeInternalCall<'a, C>
14473    where
14474        I: IntoIterator<Item = St>,
14475        St: AsRef<str>,
14476    {
14477        self._scopes
14478            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14479        self
14480    }
14481
14482    /// Removes all scopes, and no default scope will be used either.
14483    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14484    /// for details).
14485    pub fn clear_scopes(mut self) -> ProjectLocationInstanceUpgradeInternalCall<'a, C> {
14486        self._scopes.clear();
14487        self
14488    }
14489}
14490
14491/// 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`.
14492///
14493/// A builder for the *locations.operations.cancel* method supported by a *project* resource.
14494/// It is not used directly, but through a [`ProjectMethods`] instance.
14495///
14496/// # Example
14497///
14498/// Instantiate a resource method builder
14499///
14500/// ```test_harness,no_run
14501/// # extern crate hyper;
14502/// # extern crate hyper_rustls;
14503/// # extern crate google_notebooks1 as notebooks1;
14504/// use notebooks1::api::CancelOperationRequest;
14505/// # async fn dox() {
14506/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14507///
14508/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14509/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14510/// #     secret,
14511/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14512/// # ).build().await.unwrap();
14513///
14514/// # let client = hyper_util::client::legacy::Client::builder(
14515/// #     hyper_util::rt::TokioExecutor::new()
14516/// # )
14517/// # .build(
14518/// #     hyper_rustls::HttpsConnectorBuilder::new()
14519/// #         .with_native_roots()
14520/// #         .unwrap()
14521/// #         .https_or_http()
14522/// #         .enable_http1()
14523/// #         .build()
14524/// # );
14525/// # let mut hub = AIPlatformNotebooks::new(client, auth);
14526/// // As the method needs a request, you would usually fill it with the desired information
14527/// // into the respective structure. Some of the parts shown here might not be applicable !
14528/// // Values shown here are possibly random and not representative !
14529/// let mut req = CancelOperationRequest::default();
14530///
14531/// // You can configure optional parameters by calling the respective setters at will, and
14532/// // execute the final call using `doit()`.
14533/// // Values shown here are possibly random and not representative !
14534/// let result = hub.projects().locations_operations_cancel(req, "name")
14535///              .doit().await;
14536/// # }
14537/// ```
14538pub struct ProjectLocationOperationCancelCall<'a, C>
14539where
14540    C: 'a,
14541{
14542    hub: &'a AIPlatformNotebooks<C>,
14543    _request: CancelOperationRequest,
14544    _name: String,
14545    _delegate: Option<&'a mut dyn common::Delegate>,
14546    _additional_params: HashMap<String, String>,
14547    _scopes: BTreeSet<String>,
14548}
14549
14550impl<'a, C> common::CallBuilder for ProjectLocationOperationCancelCall<'a, C> {}
14551
14552impl<'a, C> ProjectLocationOperationCancelCall<'a, C>
14553where
14554    C: common::Connector,
14555{
14556    /// Perform the operation you have build so far.
14557    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
14558        use std::borrow::Cow;
14559        use std::io::{Read, Seek};
14560
14561        use common::{url::Params, ToParts};
14562        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14563
14564        let mut dd = common::DefaultDelegate;
14565        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14566        dlg.begin(common::MethodInfo {
14567            id: "notebooks.projects.locations.operations.cancel",
14568            http_method: hyper::Method::POST,
14569        });
14570
14571        for &field in ["alt", "name"].iter() {
14572            if self._additional_params.contains_key(field) {
14573                dlg.finished(false);
14574                return Err(common::Error::FieldClash(field));
14575            }
14576        }
14577
14578        let mut params = Params::with_capacity(4 + self._additional_params.len());
14579        params.push("name", self._name);
14580
14581        params.extend(self._additional_params.iter());
14582
14583        params.push("alt", "json");
14584        let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
14585        if self._scopes.is_empty() {
14586            self._scopes
14587                .insert(Scope::CloudPlatform.as_ref().to_string());
14588        }
14589
14590        #[allow(clippy::single_element_loop)]
14591        for &(find_this, param_name) in [("{+name}", "name")].iter() {
14592            url = params.uri_replacement(url, param_name, find_this, true);
14593        }
14594        {
14595            let to_remove = ["name"];
14596            params.remove_params(&to_remove);
14597        }
14598
14599        let url = params.parse_with_url(&url);
14600
14601        let mut json_mime_type = mime::APPLICATION_JSON;
14602        let mut request_value_reader = {
14603            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14604            common::remove_json_null_values(&mut value);
14605            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14606            serde_json::to_writer(&mut dst, &value).unwrap();
14607            dst
14608        };
14609        let request_size = request_value_reader
14610            .seek(std::io::SeekFrom::End(0))
14611            .unwrap();
14612        request_value_reader
14613            .seek(std::io::SeekFrom::Start(0))
14614            .unwrap();
14615
14616        loop {
14617            let token = match self
14618                .hub
14619                .auth
14620                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14621                .await
14622            {
14623                Ok(token) => token,
14624                Err(e) => match dlg.token(e) {
14625                    Ok(token) => token,
14626                    Err(e) => {
14627                        dlg.finished(false);
14628                        return Err(common::Error::MissingToken(e));
14629                    }
14630                },
14631            };
14632            request_value_reader
14633                .seek(std::io::SeekFrom::Start(0))
14634                .unwrap();
14635            let mut req_result = {
14636                let client = &self.hub.client;
14637                dlg.pre_request();
14638                let mut req_builder = hyper::Request::builder()
14639                    .method(hyper::Method::POST)
14640                    .uri(url.as_str())
14641                    .header(USER_AGENT, self.hub._user_agent.clone());
14642
14643                if let Some(token) = token.as_ref() {
14644                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14645                }
14646
14647                let request = req_builder
14648                    .header(CONTENT_TYPE, json_mime_type.to_string())
14649                    .header(CONTENT_LENGTH, request_size as u64)
14650                    .body(common::to_body(
14651                        request_value_reader.get_ref().clone().into(),
14652                    ));
14653
14654                client.request(request.unwrap()).await
14655            };
14656
14657            match req_result {
14658                Err(err) => {
14659                    if let common::Retry::After(d) = dlg.http_error(&err) {
14660                        sleep(d).await;
14661                        continue;
14662                    }
14663                    dlg.finished(false);
14664                    return Err(common::Error::HttpError(err));
14665                }
14666                Ok(res) => {
14667                    let (mut parts, body) = res.into_parts();
14668                    let mut body = common::Body::new(body);
14669                    if !parts.status.is_success() {
14670                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14671                        let error = serde_json::from_str(&common::to_string(&bytes));
14672                        let response = common::to_response(parts, bytes.into());
14673
14674                        if let common::Retry::After(d) =
14675                            dlg.http_failure(&response, error.as_ref().ok())
14676                        {
14677                            sleep(d).await;
14678                            continue;
14679                        }
14680
14681                        dlg.finished(false);
14682
14683                        return Err(match error {
14684                            Ok(value) => common::Error::BadRequest(value),
14685                            _ => common::Error::Failure(response),
14686                        });
14687                    }
14688                    let response = {
14689                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14690                        let encoded = common::to_string(&bytes);
14691                        match serde_json::from_str(&encoded) {
14692                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14693                            Err(error) => {
14694                                dlg.response_json_decode_error(&encoded, &error);
14695                                return Err(common::Error::JsonDecodeError(
14696                                    encoded.to_string(),
14697                                    error,
14698                                ));
14699                            }
14700                        }
14701                    };
14702
14703                    dlg.finished(true);
14704                    return Ok(response);
14705                }
14706            }
14707        }
14708    }
14709
14710    ///
14711    /// Sets the *request* property to the given value.
14712    ///
14713    /// Even though the property as already been set when instantiating this call,
14714    /// we provide this method for API completeness.
14715    pub fn request(
14716        mut self,
14717        new_value: CancelOperationRequest,
14718    ) -> ProjectLocationOperationCancelCall<'a, C> {
14719        self._request = new_value;
14720        self
14721    }
14722    /// The name of the operation resource to be cancelled.
14723    ///
14724    /// Sets the *name* path property to the given value.
14725    ///
14726    /// Even though the property as already been set when instantiating this call,
14727    /// we provide this method for API completeness.
14728    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationCancelCall<'a, C> {
14729        self._name = new_value.to_string();
14730        self
14731    }
14732    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14733    /// while executing the actual API request.
14734    ///
14735    /// ````text
14736    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14737    /// ````
14738    ///
14739    /// Sets the *delegate* property to the given value.
14740    pub fn delegate(
14741        mut self,
14742        new_value: &'a mut dyn common::Delegate,
14743    ) -> ProjectLocationOperationCancelCall<'a, C> {
14744        self._delegate = Some(new_value);
14745        self
14746    }
14747
14748    /// Set any additional parameter of the query string used in the request.
14749    /// It should be used to set parameters which are not yet available through their own
14750    /// setters.
14751    ///
14752    /// Please note that this method must not be used to set any of the known parameters
14753    /// which have their own setter method. If done anyway, the request will fail.
14754    ///
14755    /// # Additional Parameters
14756    ///
14757    /// * *$.xgafv* (query-string) - V1 error format.
14758    /// * *access_token* (query-string) - OAuth access token.
14759    /// * *alt* (query-string) - Data format for response.
14760    /// * *callback* (query-string) - JSONP
14761    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14762    /// * *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.
14763    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14764    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14765    /// * *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.
14766    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14767    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14768    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationCancelCall<'a, C>
14769    where
14770        T: AsRef<str>,
14771    {
14772        self._additional_params
14773            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14774        self
14775    }
14776
14777    /// Identifies the authorization scope for the method you are building.
14778    ///
14779    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14780    /// [`Scope::CloudPlatform`].
14781    ///
14782    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14783    /// tokens for more than one scope.
14784    ///
14785    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14786    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14787    /// sufficient, a read-write scope will do as well.
14788    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationCancelCall<'a, C>
14789    where
14790        St: AsRef<str>,
14791    {
14792        self._scopes.insert(String::from(scope.as_ref()));
14793        self
14794    }
14795    /// Identifies the authorization scope(s) for the method you are building.
14796    ///
14797    /// See [`Self::add_scope()`] for details.
14798    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationCancelCall<'a, C>
14799    where
14800        I: IntoIterator<Item = St>,
14801        St: AsRef<str>,
14802    {
14803        self._scopes
14804            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14805        self
14806    }
14807
14808    /// Removes all scopes, and no default scope will be used either.
14809    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14810    /// for details).
14811    pub fn clear_scopes(mut self) -> ProjectLocationOperationCancelCall<'a, C> {
14812        self._scopes.clear();
14813        self
14814    }
14815}
14816
14817/// 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`.
14818///
14819/// A builder for the *locations.operations.delete* method supported by a *project* resource.
14820/// It is not used directly, but through a [`ProjectMethods`] instance.
14821///
14822/// # Example
14823///
14824/// Instantiate a resource method builder
14825///
14826/// ```test_harness,no_run
14827/// # extern crate hyper;
14828/// # extern crate hyper_rustls;
14829/// # extern crate google_notebooks1 as notebooks1;
14830/// # async fn dox() {
14831/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14832///
14833/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14834/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14835/// #     secret,
14836/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14837/// # ).build().await.unwrap();
14838///
14839/// # let client = hyper_util::client::legacy::Client::builder(
14840/// #     hyper_util::rt::TokioExecutor::new()
14841/// # )
14842/// # .build(
14843/// #     hyper_rustls::HttpsConnectorBuilder::new()
14844/// #         .with_native_roots()
14845/// #         .unwrap()
14846/// #         .https_or_http()
14847/// #         .enable_http1()
14848/// #         .build()
14849/// # );
14850/// # let mut hub = AIPlatformNotebooks::new(client, auth);
14851/// // You can configure optional parameters by calling the respective setters at will, and
14852/// // execute the final call using `doit()`.
14853/// // Values shown here are possibly random and not representative !
14854/// let result = hub.projects().locations_operations_delete("name")
14855///              .doit().await;
14856/// # }
14857/// ```
14858pub struct ProjectLocationOperationDeleteCall<'a, C>
14859where
14860    C: 'a,
14861{
14862    hub: &'a AIPlatformNotebooks<C>,
14863    _name: String,
14864    _delegate: Option<&'a mut dyn common::Delegate>,
14865    _additional_params: HashMap<String, String>,
14866    _scopes: BTreeSet<String>,
14867}
14868
14869impl<'a, C> common::CallBuilder for ProjectLocationOperationDeleteCall<'a, C> {}
14870
14871impl<'a, C> ProjectLocationOperationDeleteCall<'a, C>
14872where
14873    C: common::Connector,
14874{
14875    /// Perform the operation you have build so far.
14876    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
14877        use std::borrow::Cow;
14878        use std::io::{Read, Seek};
14879
14880        use common::{url::Params, ToParts};
14881        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14882
14883        let mut dd = common::DefaultDelegate;
14884        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14885        dlg.begin(common::MethodInfo {
14886            id: "notebooks.projects.locations.operations.delete",
14887            http_method: hyper::Method::DELETE,
14888        });
14889
14890        for &field in ["alt", "name"].iter() {
14891            if self._additional_params.contains_key(field) {
14892                dlg.finished(false);
14893                return Err(common::Error::FieldClash(field));
14894            }
14895        }
14896
14897        let mut params = Params::with_capacity(3 + self._additional_params.len());
14898        params.push("name", self._name);
14899
14900        params.extend(self._additional_params.iter());
14901
14902        params.push("alt", "json");
14903        let mut url = self.hub._base_url.clone() + "v1/{+name}";
14904        if self._scopes.is_empty() {
14905            self._scopes
14906                .insert(Scope::CloudPlatform.as_ref().to_string());
14907        }
14908
14909        #[allow(clippy::single_element_loop)]
14910        for &(find_this, param_name) in [("{+name}", "name")].iter() {
14911            url = params.uri_replacement(url, param_name, find_this, true);
14912        }
14913        {
14914            let to_remove = ["name"];
14915            params.remove_params(&to_remove);
14916        }
14917
14918        let url = params.parse_with_url(&url);
14919
14920        loop {
14921            let token = match self
14922                .hub
14923                .auth
14924                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14925                .await
14926            {
14927                Ok(token) => token,
14928                Err(e) => match dlg.token(e) {
14929                    Ok(token) => token,
14930                    Err(e) => {
14931                        dlg.finished(false);
14932                        return Err(common::Error::MissingToken(e));
14933                    }
14934                },
14935            };
14936            let mut req_result = {
14937                let client = &self.hub.client;
14938                dlg.pre_request();
14939                let mut req_builder = hyper::Request::builder()
14940                    .method(hyper::Method::DELETE)
14941                    .uri(url.as_str())
14942                    .header(USER_AGENT, self.hub._user_agent.clone());
14943
14944                if let Some(token) = token.as_ref() {
14945                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14946                }
14947
14948                let request = req_builder
14949                    .header(CONTENT_LENGTH, 0_u64)
14950                    .body(common::to_body::<String>(None));
14951
14952                client.request(request.unwrap()).await
14953            };
14954
14955            match req_result {
14956                Err(err) => {
14957                    if let common::Retry::After(d) = dlg.http_error(&err) {
14958                        sleep(d).await;
14959                        continue;
14960                    }
14961                    dlg.finished(false);
14962                    return Err(common::Error::HttpError(err));
14963                }
14964                Ok(res) => {
14965                    let (mut parts, body) = res.into_parts();
14966                    let mut body = common::Body::new(body);
14967                    if !parts.status.is_success() {
14968                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14969                        let error = serde_json::from_str(&common::to_string(&bytes));
14970                        let response = common::to_response(parts, bytes.into());
14971
14972                        if let common::Retry::After(d) =
14973                            dlg.http_failure(&response, error.as_ref().ok())
14974                        {
14975                            sleep(d).await;
14976                            continue;
14977                        }
14978
14979                        dlg.finished(false);
14980
14981                        return Err(match error {
14982                            Ok(value) => common::Error::BadRequest(value),
14983                            _ => common::Error::Failure(response),
14984                        });
14985                    }
14986                    let response = {
14987                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14988                        let encoded = common::to_string(&bytes);
14989                        match serde_json::from_str(&encoded) {
14990                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14991                            Err(error) => {
14992                                dlg.response_json_decode_error(&encoded, &error);
14993                                return Err(common::Error::JsonDecodeError(
14994                                    encoded.to_string(),
14995                                    error,
14996                                ));
14997                            }
14998                        }
14999                    };
15000
15001                    dlg.finished(true);
15002                    return Ok(response);
15003                }
15004            }
15005        }
15006    }
15007
15008    /// The name of the operation resource to be deleted.
15009    ///
15010    /// Sets the *name* path property to the given value.
15011    ///
15012    /// Even though the property as already been set when instantiating this call,
15013    /// we provide this method for API completeness.
15014    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationDeleteCall<'a, C> {
15015        self._name = new_value.to_string();
15016        self
15017    }
15018    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15019    /// while executing the actual API request.
15020    ///
15021    /// ````text
15022    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15023    /// ````
15024    ///
15025    /// Sets the *delegate* property to the given value.
15026    pub fn delegate(
15027        mut self,
15028        new_value: &'a mut dyn common::Delegate,
15029    ) -> ProjectLocationOperationDeleteCall<'a, C> {
15030        self._delegate = Some(new_value);
15031        self
15032    }
15033
15034    /// Set any additional parameter of the query string used in the request.
15035    /// It should be used to set parameters which are not yet available through their own
15036    /// setters.
15037    ///
15038    /// Please note that this method must not be used to set any of the known parameters
15039    /// which have their own setter method. If done anyway, the request will fail.
15040    ///
15041    /// # Additional Parameters
15042    ///
15043    /// * *$.xgafv* (query-string) - V1 error format.
15044    /// * *access_token* (query-string) - OAuth access token.
15045    /// * *alt* (query-string) - Data format for response.
15046    /// * *callback* (query-string) - JSONP
15047    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15048    /// * *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.
15049    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15050    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15051    /// * *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.
15052    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15053    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15054    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationDeleteCall<'a, C>
15055    where
15056        T: AsRef<str>,
15057    {
15058        self._additional_params
15059            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15060        self
15061    }
15062
15063    /// Identifies the authorization scope for the method you are building.
15064    ///
15065    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15066    /// [`Scope::CloudPlatform`].
15067    ///
15068    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15069    /// tokens for more than one scope.
15070    ///
15071    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15072    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15073    /// sufficient, a read-write scope will do as well.
15074    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationDeleteCall<'a, C>
15075    where
15076        St: AsRef<str>,
15077    {
15078        self._scopes.insert(String::from(scope.as_ref()));
15079        self
15080    }
15081    /// Identifies the authorization scope(s) for the method you are building.
15082    ///
15083    /// See [`Self::add_scope()`] for details.
15084    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationDeleteCall<'a, C>
15085    where
15086        I: IntoIterator<Item = St>,
15087        St: AsRef<str>,
15088    {
15089        self._scopes
15090            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15091        self
15092    }
15093
15094    /// Removes all scopes, and no default scope will be used either.
15095    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15096    /// for details).
15097    pub fn clear_scopes(mut self) -> ProjectLocationOperationDeleteCall<'a, C> {
15098        self._scopes.clear();
15099        self
15100    }
15101}
15102
15103/// 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.
15104///
15105/// A builder for the *locations.operations.get* method supported by a *project* resource.
15106/// It is not used directly, but through a [`ProjectMethods`] instance.
15107///
15108/// # Example
15109///
15110/// Instantiate a resource method builder
15111///
15112/// ```test_harness,no_run
15113/// # extern crate hyper;
15114/// # extern crate hyper_rustls;
15115/// # extern crate google_notebooks1 as notebooks1;
15116/// # async fn dox() {
15117/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15118///
15119/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15120/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15121/// #     secret,
15122/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15123/// # ).build().await.unwrap();
15124///
15125/// # let client = hyper_util::client::legacy::Client::builder(
15126/// #     hyper_util::rt::TokioExecutor::new()
15127/// # )
15128/// # .build(
15129/// #     hyper_rustls::HttpsConnectorBuilder::new()
15130/// #         .with_native_roots()
15131/// #         .unwrap()
15132/// #         .https_or_http()
15133/// #         .enable_http1()
15134/// #         .build()
15135/// # );
15136/// # let mut hub = AIPlatformNotebooks::new(client, auth);
15137/// // You can configure optional parameters by calling the respective setters at will, and
15138/// // execute the final call using `doit()`.
15139/// // Values shown here are possibly random and not representative !
15140/// let result = hub.projects().locations_operations_get("name")
15141///              .doit().await;
15142/// # }
15143/// ```
15144pub struct ProjectLocationOperationGetCall<'a, C>
15145where
15146    C: 'a,
15147{
15148    hub: &'a AIPlatformNotebooks<C>,
15149    _name: String,
15150    _delegate: Option<&'a mut dyn common::Delegate>,
15151    _additional_params: HashMap<String, String>,
15152    _scopes: BTreeSet<String>,
15153}
15154
15155impl<'a, C> common::CallBuilder for ProjectLocationOperationGetCall<'a, C> {}
15156
15157impl<'a, C> ProjectLocationOperationGetCall<'a, C>
15158where
15159    C: common::Connector,
15160{
15161    /// Perform the operation you have build so far.
15162    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
15163        use std::borrow::Cow;
15164        use std::io::{Read, Seek};
15165
15166        use common::{url::Params, ToParts};
15167        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15168
15169        let mut dd = common::DefaultDelegate;
15170        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15171        dlg.begin(common::MethodInfo {
15172            id: "notebooks.projects.locations.operations.get",
15173            http_method: hyper::Method::GET,
15174        });
15175
15176        for &field in ["alt", "name"].iter() {
15177            if self._additional_params.contains_key(field) {
15178                dlg.finished(false);
15179                return Err(common::Error::FieldClash(field));
15180            }
15181        }
15182
15183        let mut params = Params::with_capacity(3 + self._additional_params.len());
15184        params.push("name", self._name);
15185
15186        params.extend(self._additional_params.iter());
15187
15188        params.push("alt", "json");
15189        let mut url = self.hub._base_url.clone() + "v1/{+name}";
15190        if self._scopes.is_empty() {
15191            self._scopes
15192                .insert(Scope::CloudPlatform.as_ref().to_string());
15193        }
15194
15195        #[allow(clippy::single_element_loop)]
15196        for &(find_this, param_name) in [("{+name}", "name")].iter() {
15197            url = params.uri_replacement(url, param_name, find_this, true);
15198        }
15199        {
15200            let to_remove = ["name"];
15201            params.remove_params(&to_remove);
15202        }
15203
15204        let url = params.parse_with_url(&url);
15205
15206        loop {
15207            let token = match self
15208                .hub
15209                .auth
15210                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15211                .await
15212            {
15213                Ok(token) => token,
15214                Err(e) => match dlg.token(e) {
15215                    Ok(token) => token,
15216                    Err(e) => {
15217                        dlg.finished(false);
15218                        return Err(common::Error::MissingToken(e));
15219                    }
15220                },
15221            };
15222            let mut req_result = {
15223                let client = &self.hub.client;
15224                dlg.pre_request();
15225                let mut req_builder = hyper::Request::builder()
15226                    .method(hyper::Method::GET)
15227                    .uri(url.as_str())
15228                    .header(USER_AGENT, self.hub._user_agent.clone());
15229
15230                if let Some(token) = token.as_ref() {
15231                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15232                }
15233
15234                let request = req_builder
15235                    .header(CONTENT_LENGTH, 0_u64)
15236                    .body(common::to_body::<String>(None));
15237
15238                client.request(request.unwrap()).await
15239            };
15240
15241            match req_result {
15242                Err(err) => {
15243                    if let common::Retry::After(d) = dlg.http_error(&err) {
15244                        sleep(d).await;
15245                        continue;
15246                    }
15247                    dlg.finished(false);
15248                    return Err(common::Error::HttpError(err));
15249                }
15250                Ok(res) => {
15251                    let (mut parts, body) = res.into_parts();
15252                    let mut body = common::Body::new(body);
15253                    if !parts.status.is_success() {
15254                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15255                        let error = serde_json::from_str(&common::to_string(&bytes));
15256                        let response = common::to_response(parts, bytes.into());
15257
15258                        if let common::Retry::After(d) =
15259                            dlg.http_failure(&response, error.as_ref().ok())
15260                        {
15261                            sleep(d).await;
15262                            continue;
15263                        }
15264
15265                        dlg.finished(false);
15266
15267                        return Err(match error {
15268                            Ok(value) => common::Error::BadRequest(value),
15269                            _ => common::Error::Failure(response),
15270                        });
15271                    }
15272                    let response = {
15273                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15274                        let encoded = common::to_string(&bytes);
15275                        match serde_json::from_str(&encoded) {
15276                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15277                            Err(error) => {
15278                                dlg.response_json_decode_error(&encoded, &error);
15279                                return Err(common::Error::JsonDecodeError(
15280                                    encoded.to_string(),
15281                                    error,
15282                                ));
15283                            }
15284                        }
15285                    };
15286
15287                    dlg.finished(true);
15288                    return Ok(response);
15289                }
15290            }
15291        }
15292    }
15293
15294    /// The name of the operation resource.
15295    ///
15296    /// Sets the *name* path property to the given value.
15297    ///
15298    /// Even though the property as already been set when instantiating this call,
15299    /// we provide this method for API completeness.
15300    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationGetCall<'a, C> {
15301        self._name = new_value.to_string();
15302        self
15303    }
15304    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15305    /// while executing the actual API request.
15306    ///
15307    /// ````text
15308    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15309    /// ````
15310    ///
15311    /// Sets the *delegate* property to the given value.
15312    pub fn delegate(
15313        mut self,
15314        new_value: &'a mut dyn common::Delegate,
15315    ) -> ProjectLocationOperationGetCall<'a, C> {
15316        self._delegate = Some(new_value);
15317        self
15318    }
15319
15320    /// Set any additional parameter of the query string used in the request.
15321    /// It should be used to set parameters which are not yet available through their own
15322    /// setters.
15323    ///
15324    /// Please note that this method must not be used to set any of the known parameters
15325    /// which have their own setter method. If done anyway, the request will fail.
15326    ///
15327    /// # Additional Parameters
15328    ///
15329    /// * *$.xgafv* (query-string) - V1 error format.
15330    /// * *access_token* (query-string) - OAuth access token.
15331    /// * *alt* (query-string) - Data format for response.
15332    /// * *callback* (query-string) - JSONP
15333    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15334    /// * *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.
15335    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15336    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15337    /// * *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.
15338    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15339    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15340    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationGetCall<'a, C>
15341    where
15342        T: AsRef<str>,
15343    {
15344        self._additional_params
15345            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15346        self
15347    }
15348
15349    /// Identifies the authorization scope for the method you are building.
15350    ///
15351    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15352    /// [`Scope::CloudPlatform`].
15353    ///
15354    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15355    /// tokens for more than one scope.
15356    ///
15357    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15358    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15359    /// sufficient, a read-write scope will do as well.
15360    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationGetCall<'a, C>
15361    where
15362        St: AsRef<str>,
15363    {
15364        self._scopes.insert(String::from(scope.as_ref()));
15365        self
15366    }
15367    /// Identifies the authorization scope(s) for the method you are building.
15368    ///
15369    /// See [`Self::add_scope()`] for details.
15370    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationGetCall<'a, C>
15371    where
15372        I: IntoIterator<Item = St>,
15373        St: AsRef<str>,
15374    {
15375        self._scopes
15376            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15377        self
15378    }
15379
15380    /// Removes all scopes, and no default scope will be used either.
15381    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15382    /// for details).
15383    pub fn clear_scopes(mut self) -> ProjectLocationOperationGetCall<'a, C> {
15384        self._scopes.clear();
15385        self
15386    }
15387}
15388
15389/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
15390///
15391/// A builder for the *locations.operations.list* method supported by a *project* resource.
15392/// It is not used directly, but through a [`ProjectMethods`] instance.
15393///
15394/// # Example
15395///
15396/// Instantiate a resource method builder
15397///
15398/// ```test_harness,no_run
15399/// # extern crate hyper;
15400/// # extern crate hyper_rustls;
15401/// # extern crate google_notebooks1 as notebooks1;
15402/// # async fn dox() {
15403/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15404///
15405/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15406/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15407/// #     secret,
15408/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15409/// # ).build().await.unwrap();
15410///
15411/// # let client = hyper_util::client::legacy::Client::builder(
15412/// #     hyper_util::rt::TokioExecutor::new()
15413/// # )
15414/// # .build(
15415/// #     hyper_rustls::HttpsConnectorBuilder::new()
15416/// #         .with_native_roots()
15417/// #         .unwrap()
15418/// #         .https_or_http()
15419/// #         .enable_http1()
15420/// #         .build()
15421/// # );
15422/// # let mut hub = AIPlatformNotebooks::new(client, auth);
15423/// // You can configure optional parameters by calling the respective setters at will, and
15424/// // execute the final call using `doit()`.
15425/// // Values shown here are possibly random and not representative !
15426/// let result = hub.projects().locations_operations_list("name")
15427///              .page_token("Stet")
15428///              .page_size(-99)
15429///              .filter("duo")
15430///              .doit().await;
15431/// # }
15432/// ```
15433pub struct ProjectLocationOperationListCall<'a, C>
15434where
15435    C: 'a,
15436{
15437    hub: &'a AIPlatformNotebooks<C>,
15438    _name: String,
15439    _page_token: Option<String>,
15440    _page_size: Option<i32>,
15441    _filter: Option<String>,
15442    _delegate: Option<&'a mut dyn common::Delegate>,
15443    _additional_params: HashMap<String, String>,
15444    _scopes: BTreeSet<String>,
15445}
15446
15447impl<'a, C> common::CallBuilder for ProjectLocationOperationListCall<'a, C> {}
15448
15449impl<'a, C> ProjectLocationOperationListCall<'a, C>
15450where
15451    C: common::Connector,
15452{
15453    /// Perform the operation you have build so far.
15454    pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
15455        use std::borrow::Cow;
15456        use std::io::{Read, Seek};
15457
15458        use common::{url::Params, ToParts};
15459        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15460
15461        let mut dd = common::DefaultDelegate;
15462        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15463        dlg.begin(common::MethodInfo {
15464            id: "notebooks.projects.locations.operations.list",
15465            http_method: hyper::Method::GET,
15466        });
15467
15468        for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
15469            if self._additional_params.contains_key(field) {
15470                dlg.finished(false);
15471                return Err(common::Error::FieldClash(field));
15472            }
15473        }
15474
15475        let mut params = Params::with_capacity(6 + self._additional_params.len());
15476        params.push("name", self._name);
15477        if let Some(value) = self._page_token.as_ref() {
15478            params.push("pageToken", value);
15479        }
15480        if let Some(value) = self._page_size.as_ref() {
15481            params.push("pageSize", value.to_string());
15482        }
15483        if let Some(value) = self._filter.as_ref() {
15484            params.push("filter", value);
15485        }
15486
15487        params.extend(self._additional_params.iter());
15488
15489        params.push("alt", "json");
15490        let mut url = self.hub._base_url.clone() + "v1/{+name}/operations";
15491        if self._scopes.is_empty() {
15492            self._scopes
15493                .insert(Scope::CloudPlatform.as_ref().to_string());
15494        }
15495
15496        #[allow(clippy::single_element_loop)]
15497        for &(find_this, param_name) in [("{+name}", "name")].iter() {
15498            url = params.uri_replacement(url, param_name, find_this, true);
15499        }
15500        {
15501            let to_remove = ["name"];
15502            params.remove_params(&to_remove);
15503        }
15504
15505        let url = params.parse_with_url(&url);
15506
15507        loop {
15508            let token = match self
15509                .hub
15510                .auth
15511                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15512                .await
15513            {
15514                Ok(token) => token,
15515                Err(e) => match dlg.token(e) {
15516                    Ok(token) => token,
15517                    Err(e) => {
15518                        dlg.finished(false);
15519                        return Err(common::Error::MissingToken(e));
15520                    }
15521                },
15522            };
15523            let mut req_result = {
15524                let client = &self.hub.client;
15525                dlg.pre_request();
15526                let mut req_builder = hyper::Request::builder()
15527                    .method(hyper::Method::GET)
15528                    .uri(url.as_str())
15529                    .header(USER_AGENT, self.hub._user_agent.clone());
15530
15531                if let Some(token) = token.as_ref() {
15532                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15533                }
15534
15535                let request = req_builder
15536                    .header(CONTENT_LENGTH, 0_u64)
15537                    .body(common::to_body::<String>(None));
15538
15539                client.request(request.unwrap()).await
15540            };
15541
15542            match req_result {
15543                Err(err) => {
15544                    if let common::Retry::After(d) = dlg.http_error(&err) {
15545                        sleep(d).await;
15546                        continue;
15547                    }
15548                    dlg.finished(false);
15549                    return Err(common::Error::HttpError(err));
15550                }
15551                Ok(res) => {
15552                    let (mut parts, body) = res.into_parts();
15553                    let mut body = common::Body::new(body);
15554                    if !parts.status.is_success() {
15555                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15556                        let error = serde_json::from_str(&common::to_string(&bytes));
15557                        let response = common::to_response(parts, bytes.into());
15558
15559                        if let common::Retry::After(d) =
15560                            dlg.http_failure(&response, error.as_ref().ok())
15561                        {
15562                            sleep(d).await;
15563                            continue;
15564                        }
15565
15566                        dlg.finished(false);
15567
15568                        return Err(match error {
15569                            Ok(value) => common::Error::BadRequest(value),
15570                            _ => common::Error::Failure(response),
15571                        });
15572                    }
15573                    let response = {
15574                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15575                        let encoded = common::to_string(&bytes);
15576                        match serde_json::from_str(&encoded) {
15577                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15578                            Err(error) => {
15579                                dlg.response_json_decode_error(&encoded, &error);
15580                                return Err(common::Error::JsonDecodeError(
15581                                    encoded.to_string(),
15582                                    error,
15583                                ));
15584                            }
15585                        }
15586                    };
15587
15588                    dlg.finished(true);
15589                    return Ok(response);
15590                }
15591            }
15592        }
15593    }
15594
15595    /// The name of the operation's parent resource.
15596    ///
15597    /// Sets the *name* path property to the given value.
15598    ///
15599    /// Even though the property as already been set when instantiating this call,
15600    /// we provide this method for API completeness.
15601    pub fn name(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
15602        self._name = new_value.to_string();
15603        self
15604    }
15605    /// The standard list page token.
15606    ///
15607    /// Sets the *page token* query property to the given value.
15608    pub fn page_token(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
15609        self._page_token = Some(new_value.to_string());
15610        self
15611    }
15612    /// The standard list page size.
15613    ///
15614    /// Sets the *page size* query property to the given value.
15615    pub fn page_size(mut self, new_value: i32) -> ProjectLocationOperationListCall<'a, C> {
15616        self._page_size = Some(new_value);
15617        self
15618    }
15619    /// The standard list filter.
15620    ///
15621    /// Sets the *filter* query property to the given value.
15622    pub fn filter(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
15623        self._filter = Some(new_value.to_string());
15624        self
15625    }
15626    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15627    /// while executing the actual API request.
15628    ///
15629    /// ````text
15630    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15631    /// ````
15632    ///
15633    /// Sets the *delegate* property to the given value.
15634    pub fn delegate(
15635        mut self,
15636        new_value: &'a mut dyn common::Delegate,
15637    ) -> ProjectLocationOperationListCall<'a, C> {
15638        self._delegate = Some(new_value);
15639        self
15640    }
15641
15642    /// Set any additional parameter of the query string used in the request.
15643    /// It should be used to set parameters which are not yet available through their own
15644    /// setters.
15645    ///
15646    /// Please note that this method must not be used to set any of the known parameters
15647    /// which have their own setter method. If done anyway, the request will fail.
15648    ///
15649    /// # Additional Parameters
15650    ///
15651    /// * *$.xgafv* (query-string) - V1 error format.
15652    /// * *access_token* (query-string) - OAuth access token.
15653    /// * *alt* (query-string) - Data format for response.
15654    /// * *callback* (query-string) - JSONP
15655    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15656    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
15657    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15658    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15659    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
15660    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15661    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15662    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationListCall<'a, C>
15663    where
15664        T: AsRef<str>,
15665    {
15666        self._additional_params
15667            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15668        self
15669    }
15670
15671    /// Identifies the authorization scope for the method you are building.
15672    ///
15673    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15674    /// [`Scope::CloudPlatform`].
15675    ///
15676    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15677    /// tokens for more than one scope.
15678    ///
15679    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15680    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15681    /// sufficient, a read-write scope will do as well.
15682    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationListCall<'a, C>
15683    where
15684        St: AsRef<str>,
15685    {
15686        self._scopes.insert(String::from(scope.as_ref()));
15687        self
15688    }
15689    /// Identifies the authorization scope(s) for the method you are building.
15690    ///
15691    /// See [`Self::add_scope()`] for details.
15692    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationListCall<'a, C>
15693    where
15694        I: IntoIterator<Item = St>,
15695        St: AsRef<str>,
15696    {
15697        self._scopes
15698            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15699        self
15700    }
15701
15702    /// Removes all scopes, and no default scope will be used either.
15703    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15704    /// for details).
15705    pub fn clear_scopes(mut self) -> ProjectLocationOperationListCall<'a, C> {
15706        self._scopes.clear();
15707        self
15708    }
15709}
15710
15711/// Creates a new Runtime in a given project and location.
15712///
15713/// A builder for the *locations.runtimes.create* method supported by a *project* resource.
15714/// It is not used directly, but through a [`ProjectMethods`] instance.
15715///
15716/// # Example
15717///
15718/// Instantiate a resource method builder
15719///
15720/// ```test_harness,no_run
15721/// # extern crate hyper;
15722/// # extern crate hyper_rustls;
15723/// # extern crate google_notebooks1 as notebooks1;
15724/// use notebooks1::api::Runtime;
15725/// # async fn dox() {
15726/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15727///
15728/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15729/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15730/// #     secret,
15731/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15732/// # ).build().await.unwrap();
15733///
15734/// # let client = hyper_util::client::legacy::Client::builder(
15735/// #     hyper_util::rt::TokioExecutor::new()
15736/// # )
15737/// # .build(
15738/// #     hyper_rustls::HttpsConnectorBuilder::new()
15739/// #         .with_native_roots()
15740/// #         .unwrap()
15741/// #         .https_or_http()
15742/// #         .enable_http1()
15743/// #         .build()
15744/// # );
15745/// # let mut hub = AIPlatformNotebooks::new(client, auth);
15746/// // As the method needs a request, you would usually fill it with the desired information
15747/// // into the respective structure. Some of the parts shown here might not be applicable !
15748/// // Values shown here are possibly random and not representative !
15749/// let mut req = Runtime::default();
15750///
15751/// // You can configure optional parameters by calling the respective setters at will, and
15752/// // execute the final call using `doit()`.
15753/// // Values shown here are possibly random and not representative !
15754/// let result = hub.projects().locations_runtimes_create(req, "parent")
15755///              .runtime_id("vero")
15756///              .request_id("invidunt")
15757///              .doit().await;
15758/// # }
15759/// ```
15760pub struct ProjectLocationRuntimeCreateCall<'a, C>
15761where
15762    C: 'a,
15763{
15764    hub: &'a AIPlatformNotebooks<C>,
15765    _request: Runtime,
15766    _parent: String,
15767    _runtime_id: Option<String>,
15768    _request_id: Option<String>,
15769    _delegate: Option<&'a mut dyn common::Delegate>,
15770    _additional_params: HashMap<String, String>,
15771    _scopes: BTreeSet<String>,
15772}
15773
15774impl<'a, C> common::CallBuilder for ProjectLocationRuntimeCreateCall<'a, C> {}
15775
15776impl<'a, C> ProjectLocationRuntimeCreateCall<'a, C>
15777where
15778    C: common::Connector,
15779{
15780    /// Perform the operation you have build so far.
15781    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
15782        use std::borrow::Cow;
15783        use std::io::{Read, Seek};
15784
15785        use common::{url::Params, ToParts};
15786        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15787
15788        let mut dd = common::DefaultDelegate;
15789        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15790        dlg.begin(common::MethodInfo {
15791            id: "notebooks.projects.locations.runtimes.create",
15792            http_method: hyper::Method::POST,
15793        });
15794
15795        for &field in ["alt", "parent", "runtimeId", "requestId"].iter() {
15796            if self._additional_params.contains_key(field) {
15797                dlg.finished(false);
15798                return Err(common::Error::FieldClash(field));
15799            }
15800        }
15801
15802        let mut params = Params::with_capacity(6 + self._additional_params.len());
15803        params.push("parent", self._parent);
15804        if let Some(value) = self._runtime_id.as_ref() {
15805            params.push("runtimeId", value);
15806        }
15807        if let Some(value) = self._request_id.as_ref() {
15808            params.push("requestId", value);
15809        }
15810
15811        params.extend(self._additional_params.iter());
15812
15813        params.push("alt", "json");
15814        let mut url = self.hub._base_url.clone() + "v1/{+parent}/runtimes";
15815        if self._scopes.is_empty() {
15816            self._scopes
15817                .insert(Scope::CloudPlatform.as_ref().to_string());
15818        }
15819
15820        #[allow(clippy::single_element_loop)]
15821        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
15822            url = params.uri_replacement(url, param_name, find_this, true);
15823        }
15824        {
15825            let to_remove = ["parent"];
15826            params.remove_params(&to_remove);
15827        }
15828
15829        let url = params.parse_with_url(&url);
15830
15831        let mut json_mime_type = mime::APPLICATION_JSON;
15832        let mut request_value_reader = {
15833            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15834            common::remove_json_null_values(&mut value);
15835            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15836            serde_json::to_writer(&mut dst, &value).unwrap();
15837            dst
15838        };
15839        let request_size = request_value_reader
15840            .seek(std::io::SeekFrom::End(0))
15841            .unwrap();
15842        request_value_reader
15843            .seek(std::io::SeekFrom::Start(0))
15844            .unwrap();
15845
15846        loop {
15847            let token = match self
15848                .hub
15849                .auth
15850                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15851                .await
15852            {
15853                Ok(token) => token,
15854                Err(e) => match dlg.token(e) {
15855                    Ok(token) => token,
15856                    Err(e) => {
15857                        dlg.finished(false);
15858                        return Err(common::Error::MissingToken(e));
15859                    }
15860                },
15861            };
15862            request_value_reader
15863                .seek(std::io::SeekFrom::Start(0))
15864                .unwrap();
15865            let mut req_result = {
15866                let client = &self.hub.client;
15867                dlg.pre_request();
15868                let mut req_builder = hyper::Request::builder()
15869                    .method(hyper::Method::POST)
15870                    .uri(url.as_str())
15871                    .header(USER_AGENT, self.hub._user_agent.clone());
15872
15873                if let Some(token) = token.as_ref() {
15874                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15875                }
15876
15877                let request = req_builder
15878                    .header(CONTENT_TYPE, json_mime_type.to_string())
15879                    .header(CONTENT_LENGTH, request_size as u64)
15880                    .body(common::to_body(
15881                        request_value_reader.get_ref().clone().into(),
15882                    ));
15883
15884                client.request(request.unwrap()).await
15885            };
15886
15887            match req_result {
15888                Err(err) => {
15889                    if let common::Retry::After(d) = dlg.http_error(&err) {
15890                        sleep(d).await;
15891                        continue;
15892                    }
15893                    dlg.finished(false);
15894                    return Err(common::Error::HttpError(err));
15895                }
15896                Ok(res) => {
15897                    let (mut parts, body) = res.into_parts();
15898                    let mut body = common::Body::new(body);
15899                    if !parts.status.is_success() {
15900                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15901                        let error = serde_json::from_str(&common::to_string(&bytes));
15902                        let response = common::to_response(parts, bytes.into());
15903
15904                        if let common::Retry::After(d) =
15905                            dlg.http_failure(&response, error.as_ref().ok())
15906                        {
15907                            sleep(d).await;
15908                            continue;
15909                        }
15910
15911                        dlg.finished(false);
15912
15913                        return Err(match error {
15914                            Ok(value) => common::Error::BadRequest(value),
15915                            _ => common::Error::Failure(response),
15916                        });
15917                    }
15918                    let response = {
15919                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15920                        let encoded = common::to_string(&bytes);
15921                        match serde_json::from_str(&encoded) {
15922                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15923                            Err(error) => {
15924                                dlg.response_json_decode_error(&encoded, &error);
15925                                return Err(common::Error::JsonDecodeError(
15926                                    encoded.to_string(),
15927                                    error,
15928                                ));
15929                            }
15930                        }
15931                    };
15932
15933                    dlg.finished(true);
15934                    return Ok(response);
15935                }
15936            }
15937        }
15938    }
15939
15940    ///
15941    /// Sets the *request* property to the given value.
15942    ///
15943    /// Even though the property as already been set when instantiating this call,
15944    /// we provide this method for API completeness.
15945    pub fn request(mut self, new_value: Runtime) -> ProjectLocationRuntimeCreateCall<'a, C> {
15946        self._request = new_value;
15947        self
15948    }
15949    /// Required. Format: `parent=projects/{project_id}/locations/{location}`
15950    ///
15951    /// Sets the *parent* path property to the given value.
15952    ///
15953    /// Even though the property as already been set when instantiating this call,
15954    /// we provide this method for API completeness.
15955    pub fn parent(mut self, new_value: &str) -> ProjectLocationRuntimeCreateCall<'a, C> {
15956        self._parent = new_value.to_string();
15957        self
15958    }
15959    /// Required. User-defined unique ID of this Runtime.
15960    ///
15961    /// Sets the *runtime id* query property to the given value.
15962    pub fn runtime_id(mut self, new_value: &str) -> ProjectLocationRuntimeCreateCall<'a, C> {
15963        self._runtime_id = Some(new_value.to_string());
15964        self
15965    }
15966    /// Idempotent request UUID.
15967    ///
15968    /// Sets the *request id* query property to the given value.
15969    pub fn request_id(mut self, new_value: &str) -> ProjectLocationRuntimeCreateCall<'a, C> {
15970        self._request_id = Some(new_value.to_string());
15971        self
15972    }
15973    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15974    /// while executing the actual API request.
15975    ///
15976    /// ````text
15977    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15978    /// ````
15979    ///
15980    /// Sets the *delegate* property to the given value.
15981    pub fn delegate(
15982        mut self,
15983        new_value: &'a mut dyn common::Delegate,
15984    ) -> ProjectLocationRuntimeCreateCall<'a, C> {
15985        self._delegate = Some(new_value);
15986        self
15987    }
15988
15989    /// Set any additional parameter of the query string used in the request.
15990    /// It should be used to set parameters which are not yet available through their own
15991    /// setters.
15992    ///
15993    /// Please note that this method must not be used to set any of the known parameters
15994    /// which have their own setter method. If done anyway, the request will fail.
15995    ///
15996    /// # Additional Parameters
15997    ///
15998    /// * *$.xgafv* (query-string) - V1 error format.
15999    /// * *access_token* (query-string) - OAuth access token.
16000    /// * *alt* (query-string) - Data format for response.
16001    /// * *callback* (query-string) - JSONP
16002    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16003    /// * *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.
16004    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16005    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16006    /// * *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.
16007    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16008    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16009    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRuntimeCreateCall<'a, C>
16010    where
16011        T: AsRef<str>,
16012    {
16013        self._additional_params
16014            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16015        self
16016    }
16017
16018    /// Identifies the authorization scope for the method you are building.
16019    ///
16020    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16021    /// [`Scope::CloudPlatform`].
16022    ///
16023    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16024    /// tokens for more than one scope.
16025    ///
16026    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16027    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16028    /// sufficient, a read-write scope will do as well.
16029    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRuntimeCreateCall<'a, C>
16030    where
16031        St: AsRef<str>,
16032    {
16033        self._scopes.insert(String::from(scope.as_ref()));
16034        self
16035    }
16036    /// Identifies the authorization scope(s) for the method you are building.
16037    ///
16038    /// See [`Self::add_scope()`] for details.
16039    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRuntimeCreateCall<'a, C>
16040    where
16041        I: IntoIterator<Item = St>,
16042        St: AsRef<str>,
16043    {
16044        self._scopes
16045            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16046        self
16047    }
16048
16049    /// Removes all scopes, and no default scope will be used either.
16050    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16051    /// for details).
16052    pub fn clear_scopes(mut self) -> ProjectLocationRuntimeCreateCall<'a, C> {
16053        self._scopes.clear();
16054        self
16055    }
16056}
16057
16058/// Deletes a single Runtime.
16059///
16060/// A builder for the *locations.runtimes.delete* method supported by a *project* resource.
16061/// It is not used directly, but through a [`ProjectMethods`] instance.
16062///
16063/// # Example
16064///
16065/// Instantiate a resource method builder
16066///
16067/// ```test_harness,no_run
16068/// # extern crate hyper;
16069/// # extern crate hyper_rustls;
16070/// # extern crate google_notebooks1 as notebooks1;
16071/// # async fn dox() {
16072/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16073///
16074/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16075/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16076/// #     secret,
16077/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16078/// # ).build().await.unwrap();
16079///
16080/// # let client = hyper_util::client::legacy::Client::builder(
16081/// #     hyper_util::rt::TokioExecutor::new()
16082/// # )
16083/// # .build(
16084/// #     hyper_rustls::HttpsConnectorBuilder::new()
16085/// #         .with_native_roots()
16086/// #         .unwrap()
16087/// #         .https_or_http()
16088/// #         .enable_http1()
16089/// #         .build()
16090/// # );
16091/// # let mut hub = AIPlatformNotebooks::new(client, auth);
16092/// // You can configure optional parameters by calling the respective setters at will, and
16093/// // execute the final call using `doit()`.
16094/// // Values shown here are possibly random and not representative !
16095/// let result = hub.projects().locations_runtimes_delete("name")
16096///              .request_id("vero")
16097///              .doit().await;
16098/// # }
16099/// ```
16100pub struct ProjectLocationRuntimeDeleteCall<'a, C>
16101where
16102    C: 'a,
16103{
16104    hub: &'a AIPlatformNotebooks<C>,
16105    _name: String,
16106    _request_id: Option<String>,
16107    _delegate: Option<&'a mut dyn common::Delegate>,
16108    _additional_params: HashMap<String, String>,
16109    _scopes: BTreeSet<String>,
16110}
16111
16112impl<'a, C> common::CallBuilder for ProjectLocationRuntimeDeleteCall<'a, C> {}
16113
16114impl<'a, C> ProjectLocationRuntimeDeleteCall<'a, C>
16115where
16116    C: common::Connector,
16117{
16118    /// Perform the operation you have build so far.
16119    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
16120        use std::borrow::Cow;
16121        use std::io::{Read, Seek};
16122
16123        use common::{url::Params, ToParts};
16124        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16125
16126        let mut dd = common::DefaultDelegate;
16127        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16128        dlg.begin(common::MethodInfo {
16129            id: "notebooks.projects.locations.runtimes.delete",
16130            http_method: hyper::Method::DELETE,
16131        });
16132
16133        for &field in ["alt", "name", "requestId"].iter() {
16134            if self._additional_params.contains_key(field) {
16135                dlg.finished(false);
16136                return Err(common::Error::FieldClash(field));
16137            }
16138        }
16139
16140        let mut params = Params::with_capacity(4 + self._additional_params.len());
16141        params.push("name", self._name);
16142        if let Some(value) = self._request_id.as_ref() {
16143            params.push("requestId", value);
16144        }
16145
16146        params.extend(self._additional_params.iter());
16147
16148        params.push("alt", "json");
16149        let mut url = self.hub._base_url.clone() + "v1/{+name}";
16150        if self._scopes.is_empty() {
16151            self._scopes
16152                .insert(Scope::CloudPlatform.as_ref().to_string());
16153        }
16154
16155        #[allow(clippy::single_element_loop)]
16156        for &(find_this, param_name) in [("{+name}", "name")].iter() {
16157            url = params.uri_replacement(url, param_name, find_this, true);
16158        }
16159        {
16160            let to_remove = ["name"];
16161            params.remove_params(&to_remove);
16162        }
16163
16164        let url = params.parse_with_url(&url);
16165
16166        loop {
16167            let token = match self
16168                .hub
16169                .auth
16170                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16171                .await
16172            {
16173                Ok(token) => token,
16174                Err(e) => match dlg.token(e) {
16175                    Ok(token) => token,
16176                    Err(e) => {
16177                        dlg.finished(false);
16178                        return Err(common::Error::MissingToken(e));
16179                    }
16180                },
16181            };
16182            let mut req_result = {
16183                let client = &self.hub.client;
16184                dlg.pre_request();
16185                let mut req_builder = hyper::Request::builder()
16186                    .method(hyper::Method::DELETE)
16187                    .uri(url.as_str())
16188                    .header(USER_AGENT, self.hub._user_agent.clone());
16189
16190                if let Some(token) = token.as_ref() {
16191                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16192                }
16193
16194                let request = req_builder
16195                    .header(CONTENT_LENGTH, 0_u64)
16196                    .body(common::to_body::<String>(None));
16197
16198                client.request(request.unwrap()).await
16199            };
16200
16201            match req_result {
16202                Err(err) => {
16203                    if let common::Retry::After(d) = dlg.http_error(&err) {
16204                        sleep(d).await;
16205                        continue;
16206                    }
16207                    dlg.finished(false);
16208                    return Err(common::Error::HttpError(err));
16209                }
16210                Ok(res) => {
16211                    let (mut parts, body) = res.into_parts();
16212                    let mut body = common::Body::new(body);
16213                    if !parts.status.is_success() {
16214                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16215                        let error = serde_json::from_str(&common::to_string(&bytes));
16216                        let response = common::to_response(parts, bytes.into());
16217
16218                        if let common::Retry::After(d) =
16219                            dlg.http_failure(&response, error.as_ref().ok())
16220                        {
16221                            sleep(d).await;
16222                            continue;
16223                        }
16224
16225                        dlg.finished(false);
16226
16227                        return Err(match error {
16228                            Ok(value) => common::Error::BadRequest(value),
16229                            _ => common::Error::Failure(response),
16230                        });
16231                    }
16232                    let response = {
16233                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16234                        let encoded = common::to_string(&bytes);
16235                        match serde_json::from_str(&encoded) {
16236                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16237                            Err(error) => {
16238                                dlg.response_json_decode_error(&encoded, &error);
16239                                return Err(common::Error::JsonDecodeError(
16240                                    encoded.to_string(),
16241                                    error,
16242                                ));
16243                            }
16244                        }
16245                    };
16246
16247                    dlg.finished(true);
16248                    return Ok(response);
16249                }
16250            }
16251        }
16252    }
16253
16254    /// Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
16255    ///
16256    /// Sets the *name* path property to the given value.
16257    ///
16258    /// Even though the property as already been set when instantiating this call,
16259    /// we provide this method for API completeness.
16260    pub fn name(mut self, new_value: &str) -> ProjectLocationRuntimeDeleteCall<'a, C> {
16261        self._name = new_value.to_string();
16262        self
16263    }
16264    /// Idempotent request UUID.
16265    ///
16266    /// Sets the *request id* query property to the given value.
16267    pub fn request_id(mut self, new_value: &str) -> ProjectLocationRuntimeDeleteCall<'a, C> {
16268        self._request_id = Some(new_value.to_string());
16269        self
16270    }
16271    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16272    /// while executing the actual API request.
16273    ///
16274    /// ````text
16275    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16276    /// ````
16277    ///
16278    /// Sets the *delegate* property to the given value.
16279    pub fn delegate(
16280        mut self,
16281        new_value: &'a mut dyn common::Delegate,
16282    ) -> ProjectLocationRuntimeDeleteCall<'a, C> {
16283        self._delegate = Some(new_value);
16284        self
16285    }
16286
16287    /// Set any additional parameter of the query string used in the request.
16288    /// It should be used to set parameters which are not yet available through their own
16289    /// setters.
16290    ///
16291    /// Please note that this method must not be used to set any of the known parameters
16292    /// which have their own setter method. If done anyway, the request will fail.
16293    ///
16294    /// # Additional Parameters
16295    ///
16296    /// * *$.xgafv* (query-string) - V1 error format.
16297    /// * *access_token* (query-string) - OAuth access token.
16298    /// * *alt* (query-string) - Data format for response.
16299    /// * *callback* (query-string) - JSONP
16300    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16301    /// * *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.
16302    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16303    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16304    /// * *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.
16305    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16306    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16307    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRuntimeDeleteCall<'a, C>
16308    where
16309        T: AsRef<str>,
16310    {
16311        self._additional_params
16312            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16313        self
16314    }
16315
16316    /// Identifies the authorization scope for the method you are building.
16317    ///
16318    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16319    /// [`Scope::CloudPlatform`].
16320    ///
16321    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16322    /// tokens for more than one scope.
16323    ///
16324    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16325    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16326    /// sufficient, a read-write scope will do as well.
16327    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRuntimeDeleteCall<'a, C>
16328    where
16329        St: AsRef<str>,
16330    {
16331        self._scopes.insert(String::from(scope.as_ref()));
16332        self
16333    }
16334    /// Identifies the authorization scope(s) for the method you are building.
16335    ///
16336    /// See [`Self::add_scope()`] for details.
16337    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRuntimeDeleteCall<'a, C>
16338    where
16339        I: IntoIterator<Item = St>,
16340        St: AsRef<str>,
16341    {
16342        self._scopes
16343            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16344        self
16345    }
16346
16347    /// Removes all scopes, and no default scope will be used either.
16348    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16349    /// for details).
16350    pub fn clear_scopes(mut self) -> ProjectLocationRuntimeDeleteCall<'a, C> {
16351        self._scopes.clear();
16352        self
16353    }
16354}
16355
16356/// Creates a Diagnostic File and runs Diagnostic Tool given a Runtime.
16357///
16358/// A builder for the *locations.runtimes.diagnose* method supported by a *project* resource.
16359/// It is not used directly, but through a [`ProjectMethods`] instance.
16360///
16361/// # Example
16362///
16363/// Instantiate a resource method builder
16364///
16365/// ```test_harness,no_run
16366/// # extern crate hyper;
16367/// # extern crate hyper_rustls;
16368/// # extern crate google_notebooks1 as notebooks1;
16369/// use notebooks1::api::DiagnoseRuntimeRequest;
16370/// # async fn dox() {
16371/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16372///
16373/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16374/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16375/// #     secret,
16376/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16377/// # ).build().await.unwrap();
16378///
16379/// # let client = hyper_util::client::legacy::Client::builder(
16380/// #     hyper_util::rt::TokioExecutor::new()
16381/// # )
16382/// # .build(
16383/// #     hyper_rustls::HttpsConnectorBuilder::new()
16384/// #         .with_native_roots()
16385/// #         .unwrap()
16386/// #         .https_or_http()
16387/// #         .enable_http1()
16388/// #         .build()
16389/// # );
16390/// # let mut hub = AIPlatformNotebooks::new(client, auth);
16391/// // As the method needs a request, you would usually fill it with the desired information
16392/// // into the respective structure. Some of the parts shown here might not be applicable !
16393/// // Values shown here are possibly random and not representative !
16394/// let mut req = DiagnoseRuntimeRequest::default();
16395///
16396/// // You can configure optional parameters by calling the respective setters at will, and
16397/// // execute the final call using `doit()`.
16398/// // Values shown here are possibly random and not representative !
16399/// let result = hub.projects().locations_runtimes_diagnose(req, "name")
16400///              .doit().await;
16401/// # }
16402/// ```
16403pub struct ProjectLocationRuntimeDiagnoseCall<'a, C>
16404where
16405    C: 'a,
16406{
16407    hub: &'a AIPlatformNotebooks<C>,
16408    _request: DiagnoseRuntimeRequest,
16409    _name: String,
16410    _delegate: Option<&'a mut dyn common::Delegate>,
16411    _additional_params: HashMap<String, String>,
16412    _scopes: BTreeSet<String>,
16413}
16414
16415impl<'a, C> common::CallBuilder for ProjectLocationRuntimeDiagnoseCall<'a, C> {}
16416
16417impl<'a, C> ProjectLocationRuntimeDiagnoseCall<'a, C>
16418where
16419    C: common::Connector,
16420{
16421    /// Perform the operation you have build so far.
16422    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
16423        use std::borrow::Cow;
16424        use std::io::{Read, Seek};
16425
16426        use common::{url::Params, ToParts};
16427        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16428
16429        let mut dd = common::DefaultDelegate;
16430        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16431        dlg.begin(common::MethodInfo {
16432            id: "notebooks.projects.locations.runtimes.diagnose",
16433            http_method: hyper::Method::POST,
16434        });
16435
16436        for &field in ["alt", "name"].iter() {
16437            if self._additional_params.contains_key(field) {
16438                dlg.finished(false);
16439                return Err(common::Error::FieldClash(field));
16440            }
16441        }
16442
16443        let mut params = Params::with_capacity(4 + self._additional_params.len());
16444        params.push("name", self._name);
16445
16446        params.extend(self._additional_params.iter());
16447
16448        params.push("alt", "json");
16449        let mut url = self.hub._base_url.clone() + "v1/{+name}:diagnose";
16450        if self._scopes.is_empty() {
16451            self._scopes
16452                .insert(Scope::CloudPlatform.as_ref().to_string());
16453        }
16454
16455        #[allow(clippy::single_element_loop)]
16456        for &(find_this, param_name) in [("{+name}", "name")].iter() {
16457            url = params.uri_replacement(url, param_name, find_this, true);
16458        }
16459        {
16460            let to_remove = ["name"];
16461            params.remove_params(&to_remove);
16462        }
16463
16464        let url = params.parse_with_url(&url);
16465
16466        let mut json_mime_type = mime::APPLICATION_JSON;
16467        let mut request_value_reader = {
16468            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16469            common::remove_json_null_values(&mut value);
16470            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16471            serde_json::to_writer(&mut dst, &value).unwrap();
16472            dst
16473        };
16474        let request_size = request_value_reader
16475            .seek(std::io::SeekFrom::End(0))
16476            .unwrap();
16477        request_value_reader
16478            .seek(std::io::SeekFrom::Start(0))
16479            .unwrap();
16480
16481        loop {
16482            let token = match self
16483                .hub
16484                .auth
16485                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16486                .await
16487            {
16488                Ok(token) => token,
16489                Err(e) => match dlg.token(e) {
16490                    Ok(token) => token,
16491                    Err(e) => {
16492                        dlg.finished(false);
16493                        return Err(common::Error::MissingToken(e));
16494                    }
16495                },
16496            };
16497            request_value_reader
16498                .seek(std::io::SeekFrom::Start(0))
16499                .unwrap();
16500            let mut req_result = {
16501                let client = &self.hub.client;
16502                dlg.pre_request();
16503                let mut req_builder = hyper::Request::builder()
16504                    .method(hyper::Method::POST)
16505                    .uri(url.as_str())
16506                    .header(USER_AGENT, self.hub._user_agent.clone());
16507
16508                if let Some(token) = token.as_ref() {
16509                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16510                }
16511
16512                let request = req_builder
16513                    .header(CONTENT_TYPE, json_mime_type.to_string())
16514                    .header(CONTENT_LENGTH, request_size as u64)
16515                    .body(common::to_body(
16516                        request_value_reader.get_ref().clone().into(),
16517                    ));
16518
16519                client.request(request.unwrap()).await
16520            };
16521
16522            match req_result {
16523                Err(err) => {
16524                    if let common::Retry::After(d) = dlg.http_error(&err) {
16525                        sleep(d).await;
16526                        continue;
16527                    }
16528                    dlg.finished(false);
16529                    return Err(common::Error::HttpError(err));
16530                }
16531                Ok(res) => {
16532                    let (mut parts, body) = res.into_parts();
16533                    let mut body = common::Body::new(body);
16534                    if !parts.status.is_success() {
16535                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16536                        let error = serde_json::from_str(&common::to_string(&bytes));
16537                        let response = common::to_response(parts, bytes.into());
16538
16539                        if let common::Retry::After(d) =
16540                            dlg.http_failure(&response, error.as_ref().ok())
16541                        {
16542                            sleep(d).await;
16543                            continue;
16544                        }
16545
16546                        dlg.finished(false);
16547
16548                        return Err(match error {
16549                            Ok(value) => common::Error::BadRequest(value),
16550                            _ => common::Error::Failure(response),
16551                        });
16552                    }
16553                    let response = {
16554                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16555                        let encoded = common::to_string(&bytes);
16556                        match serde_json::from_str(&encoded) {
16557                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16558                            Err(error) => {
16559                                dlg.response_json_decode_error(&encoded, &error);
16560                                return Err(common::Error::JsonDecodeError(
16561                                    encoded.to_string(),
16562                                    error,
16563                                ));
16564                            }
16565                        }
16566                    };
16567
16568                    dlg.finished(true);
16569                    return Ok(response);
16570                }
16571            }
16572        }
16573    }
16574
16575    ///
16576    /// Sets the *request* property to the given value.
16577    ///
16578    /// Even though the property as already been set when instantiating this call,
16579    /// we provide this method for API completeness.
16580    pub fn request(
16581        mut self,
16582        new_value: DiagnoseRuntimeRequest,
16583    ) -> ProjectLocationRuntimeDiagnoseCall<'a, C> {
16584        self._request = new_value;
16585        self
16586    }
16587    /// Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtimes_id}`
16588    ///
16589    /// Sets the *name* path property to the given value.
16590    ///
16591    /// Even though the property as already been set when instantiating this call,
16592    /// we provide this method for API completeness.
16593    pub fn name(mut self, new_value: &str) -> ProjectLocationRuntimeDiagnoseCall<'a, C> {
16594        self._name = new_value.to_string();
16595        self
16596    }
16597    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16598    /// while executing the actual API request.
16599    ///
16600    /// ````text
16601    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16602    /// ````
16603    ///
16604    /// Sets the *delegate* property to the given value.
16605    pub fn delegate(
16606        mut self,
16607        new_value: &'a mut dyn common::Delegate,
16608    ) -> ProjectLocationRuntimeDiagnoseCall<'a, C> {
16609        self._delegate = Some(new_value);
16610        self
16611    }
16612
16613    /// Set any additional parameter of the query string used in the request.
16614    /// It should be used to set parameters which are not yet available through their own
16615    /// setters.
16616    ///
16617    /// Please note that this method must not be used to set any of the known parameters
16618    /// which have their own setter method. If done anyway, the request will fail.
16619    ///
16620    /// # Additional Parameters
16621    ///
16622    /// * *$.xgafv* (query-string) - V1 error format.
16623    /// * *access_token* (query-string) - OAuth access token.
16624    /// * *alt* (query-string) - Data format for response.
16625    /// * *callback* (query-string) - JSONP
16626    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16627    /// * *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.
16628    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16629    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16630    /// * *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.
16631    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16632    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16633    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRuntimeDiagnoseCall<'a, C>
16634    where
16635        T: AsRef<str>,
16636    {
16637        self._additional_params
16638            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16639        self
16640    }
16641
16642    /// Identifies the authorization scope for the method you are building.
16643    ///
16644    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16645    /// [`Scope::CloudPlatform`].
16646    ///
16647    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16648    /// tokens for more than one scope.
16649    ///
16650    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16651    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16652    /// sufficient, a read-write scope will do as well.
16653    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRuntimeDiagnoseCall<'a, C>
16654    where
16655        St: AsRef<str>,
16656    {
16657        self._scopes.insert(String::from(scope.as_ref()));
16658        self
16659    }
16660    /// Identifies the authorization scope(s) for the method you are building.
16661    ///
16662    /// See [`Self::add_scope()`] for details.
16663    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRuntimeDiagnoseCall<'a, C>
16664    where
16665        I: IntoIterator<Item = St>,
16666        St: AsRef<str>,
16667    {
16668        self._scopes
16669            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16670        self
16671    }
16672
16673    /// Removes all scopes, and no default scope will be used either.
16674    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16675    /// for details).
16676    pub fn clear_scopes(mut self) -> ProjectLocationRuntimeDiagnoseCall<'a, C> {
16677        self._scopes.clear();
16678        self
16679    }
16680}
16681
16682/// Gets details of a single Runtime. The location must be a regional endpoint rather than zonal.
16683///
16684/// A builder for the *locations.runtimes.get* method supported by a *project* resource.
16685/// It is not used directly, but through a [`ProjectMethods`] instance.
16686///
16687/// # Example
16688///
16689/// Instantiate a resource method builder
16690///
16691/// ```test_harness,no_run
16692/// # extern crate hyper;
16693/// # extern crate hyper_rustls;
16694/// # extern crate google_notebooks1 as notebooks1;
16695/// # async fn dox() {
16696/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16697///
16698/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16699/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16700/// #     secret,
16701/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16702/// # ).build().await.unwrap();
16703///
16704/// # let client = hyper_util::client::legacy::Client::builder(
16705/// #     hyper_util::rt::TokioExecutor::new()
16706/// # )
16707/// # .build(
16708/// #     hyper_rustls::HttpsConnectorBuilder::new()
16709/// #         .with_native_roots()
16710/// #         .unwrap()
16711/// #         .https_or_http()
16712/// #         .enable_http1()
16713/// #         .build()
16714/// # );
16715/// # let mut hub = AIPlatformNotebooks::new(client, auth);
16716/// // You can configure optional parameters by calling the respective setters at will, and
16717/// // execute the final call using `doit()`.
16718/// // Values shown here are possibly random and not representative !
16719/// let result = hub.projects().locations_runtimes_get("name")
16720///              .doit().await;
16721/// # }
16722/// ```
16723pub struct ProjectLocationRuntimeGetCall<'a, C>
16724where
16725    C: 'a,
16726{
16727    hub: &'a AIPlatformNotebooks<C>,
16728    _name: String,
16729    _delegate: Option<&'a mut dyn common::Delegate>,
16730    _additional_params: HashMap<String, String>,
16731    _scopes: BTreeSet<String>,
16732}
16733
16734impl<'a, C> common::CallBuilder for ProjectLocationRuntimeGetCall<'a, C> {}
16735
16736impl<'a, C> ProjectLocationRuntimeGetCall<'a, C>
16737where
16738    C: common::Connector,
16739{
16740    /// Perform the operation you have build so far.
16741    pub async fn doit(mut self) -> common::Result<(common::Response, Runtime)> {
16742        use std::borrow::Cow;
16743        use std::io::{Read, Seek};
16744
16745        use common::{url::Params, ToParts};
16746        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16747
16748        let mut dd = common::DefaultDelegate;
16749        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16750        dlg.begin(common::MethodInfo {
16751            id: "notebooks.projects.locations.runtimes.get",
16752            http_method: hyper::Method::GET,
16753        });
16754
16755        for &field in ["alt", "name"].iter() {
16756            if self._additional_params.contains_key(field) {
16757                dlg.finished(false);
16758                return Err(common::Error::FieldClash(field));
16759            }
16760        }
16761
16762        let mut params = Params::with_capacity(3 + self._additional_params.len());
16763        params.push("name", self._name);
16764
16765        params.extend(self._additional_params.iter());
16766
16767        params.push("alt", "json");
16768        let mut url = self.hub._base_url.clone() + "v1/{+name}";
16769        if self._scopes.is_empty() {
16770            self._scopes
16771                .insert(Scope::CloudPlatform.as_ref().to_string());
16772        }
16773
16774        #[allow(clippy::single_element_loop)]
16775        for &(find_this, param_name) in [("{+name}", "name")].iter() {
16776            url = params.uri_replacement(url, param_name, find_this, true);
16777        }
16778        {
16779            let to_remove = ["name"];
16780            params.remove_params(&to_remove);
16781        }
16782
16783        let url = params.parse_with_url(&url);
16784
16785        loop {
16786            let token = match self
16787                .hub
16788                .auth
16789                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16790                .await
16791            {
16792                Ok(token) => token,
16793                Err(e) => match dlg.token(e) {
16794                    Ok(token) => token,
16795                    Err(e) => {
16796                        dlg.finished(false);
16797                        return Err(common::Error::MissingToken(e));
16798                    }
16799                },
16800            };
16801            let mut req_result = {
16802                let client = &self.hub.client;
16803                dlg.pre_request();
16804                let mut req_builder = hyper::Request::builder()
16805                    .method(hyper::Method::GET)
16806                    .uri(url.as_str())
16807                    .header(USER_AGENT, self.hub._user_agent.clone());
16808
16809                if let Some(token) = token.as_ref() {
16810                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16811                }
16812
16813                let request = req_builder
16814                    .header(CONTENT_LENGTH, 0_u64)
16815                    .body(common::to_body::<String>(None));
16816
16817                client.request(request.unwrap()).await
16818            };
16819
16820            match req_result {
16821                Err(err) => {
16822                    if let common::Retry::After(d) = dlg.http_error(&err) {
16823                        sleep(d).await;
16824                        continue;
16825                    }
16826                    dlg.finished(false);
16827                    return Err(common::Error::HttpError(err));
16828                }
16829                Ok(res) => {
16830                    let (mut parts, body) = res.into_parts();
16831                    let mut body = common::Body::new(body);
16832                    if !parts.status.is_success() {
16833                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16834                        let error = serde_json::from_str(&common::to_string(&bytes));
16835                        let response = common::to_response(parts, bytes.into());
16836
16837                        if let common::Retry::After(d) =
16838                            dlg.http_failure(&response, error.as_ref().ok())
16839                        {
16840                            sleep(d).await;
16841                            continue;
16842                        }
16843
16844                        dlg.finished(false);
16845
16846                        return Err(match error {
16847                            Ok(value) => common::Error::BadRequest(value),
16848                            _ => common::Error::Failure(response),
16849                        });
16850                    }
16851                    let response = {
16852                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16853                        let encoded = common::to_string(&bytes);
16854                        match serde_json::from_str(&encoded) {
16855                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16856                            Err(error) => {
16857                                dlg.response_json_decode_error(&encoded, &error);
16858                                return Err(common::Error::JsonDecodeError(
16859                                    encoded.to_string(),
16860                                    error,
16861                                ));
16862                            }
16863                        }
16864                    };
16865
16866                    dlg.finished(true);
16867                    return Ok(response);
16868                }
16869            }
16870        }
16871    }
16872
16873    /// Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
16874    ///
16875    /// Sets the *name* path property to the given value.
16876    ///
16877    /// Even though the property as already been set when instantiating this call,
16878    /// we provide this method for API completeness.
16879    pub fn name(mut self, new_value: &str) -> ProjectLocationRuntimeGetCall<'a, C> {
16880        self._name = new_value.to_string();
16881        self
16882    }
16883    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16884    /// while executing the actual API request.
16885    ///
16886    /// ````text
16887    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16888    /// ````
16889    ///
16890    /// Sets the *delegate* property to the given value.
16891    pub fn delegate(
16892        mut self,
16893        new_value: &'a mut dyn common::Delegate,
16894    ) -> ProjectLocationRuntimeGetCall<'a, C> {
16895        self._delegate = Some(new_value);
16896        self
16897    }
16898
16899    /// Set any additional parameter of the query string used in the request.
16900    /// It should be used to set parameters which are not yet available through their own
16901    /// setters.
16902    ///
16903    /// Please note that this method must not be used to set any of the known parameters
16904    /// which have their own setter method. If done anyway, the request will fail.
16905    ///
16906    /// # Additional Parameters
16907    ///
16908    /// * *$.xgafv* (query-string) - V1 error format.
16909    /// * *access_token* (query-string) - OAuth access token.
16910    /// * *alt* (query-string) - Data format for response.
16911    /// * *callback* (query-string) - JSONP
16912    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16913    /// * *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.
16914    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16915    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16916    /// * *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.
16917    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16918    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16919    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRuntimeGetCall<'a, C>
16920    where
16921        T: AsRef<str>,
16922    {
16923        self._additional_params
16924            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16925        self
16926    }
16927
16928    /// Identifies the authorization scope for the method you are building.
16929    ///
16930    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16931    /// [`Scope::CloudPlatform`].
16932    ///
16933    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16934    /// tokens for more than one scope.
16935    ///
16936    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16937    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16938    /// sufficient, a read-write scope will do as well.
16939    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRuntimeGetCall<'a, C>
16940    where
16941        St: AsRef<str>,
16942    {
16943        self._scopes.insert(String::from(scope.as_ref()));
16944        self
16945    }
16946    /// Identifies the authorization scope(s) for the method you are building.
16947    ///
16948    /// See [`Self::add_scope()`] for details.
16949    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRuntimeGetCall<'a, C>
16950    where
16951        I: IntoIterator<Item = St>,
16952        St: AsRef<str>,
16953    {
16954        self._scopes
16955            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16956        self
16957    }
16958
16959    /// Removes all scopes, and no default scope will be used either.
16960    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16961    /// for details).
16962    pub fn clear_scopes(mut self) -> ProjectLocationRuntimeGetCall<'a, C> {
16963        self._scopes.clear();
16964        self
16965    }
16966}
16967
16968/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
16969///
16970/// A builder for the *locations.runtimes.getIamPolicy* method supported by a *project* resource.
16971/// It is not used directly, but through a [`ProjectMethods`] instance.
16972///
16973/// # Example
16974///
16975/// Instantiate a resource method builder
16976///
16977/// ```test_harness,no_run
16978/// # extern crate hyper;
16979/// # extern crate hyper_rustls;
16980/// # extern crate google_notebooks1 as notebooks1;
16981/// # async fn dox() {
16982/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16983///
16984/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16985/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16986/// #     secret,
16987/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16988/// # ).build().await.unwrap();
16989///
16990/// # let client = hyper_util::client::legacy::Client::builder(
16991/// #     hyper_util::rt::TokioExecutor::new()
16992/// # )
16993/// # .build(
16994/// #     hyper_rustls::HttpsConnectorBuilder::new()
16995/// #         .with_native_roots()
16996/// #         .unwrap()
16997/// #         .https_or_http()
16998/// #         .enable_http1()
16999/// #         .build()
17000/// # );
17001/// # let mut hub = AIPlatformNotebooks::new(client, auth);
17002/// // You can configure optional parameters by calling the respective setters at will, and
17003/// // execute the final call using `doit()`.
17004/// // Values shown here are possibly random and not representative !
17005/// let result = hub.projects().locations_runtimes_get_iam_policy("resource")
17006///              .options_requested_policy_version(-61)
17007///              .doit().await;
17008/// # }
17009/// ```
17010pub struct ProjectLocationRuntimeGetIamPolicyCall<'a, C>
17011where
17012    C: 'a,
17013{
17014    hub: &'a AIPlatformNotebooks<C>,
17015    _resource: String,
17016    _options_requested_policy_version: Option<i32>,
17017    _delegate: Option<&'a mut dyn common::Delegate>,
17018    _additional_params: HashMap<String, String>,
17019    _scopes: BTreeSet<String>,
17020}
17021
17022impl<'a, C> common::CallBuilder for ProjectLocationRuntimeGetIamPolicyCall<'a, C> {}
17023
17024impl<'a, C> ProjectLocationRuntimeGetIamPolicyCall<'a, C>
17025where
17026    C: common::Connector,
17027{
17028    /// Perform the operation you have build so far.
17029    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
17030        use std::borrow::Cow;
17031        use std::io::{Read, Seek};
17032
17033        use common::{url::Params, ToParts};
17034        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17035
17036        let mut dd = common::DefaultDelegate;
17037        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17038        dlg.begin(common::MethodInfo {
17039            id: "notebooks.projects.locations.runtimes.getIamPolicy",
17040            http_method: hyper::Method::GET,
17041        });
17042
17043        for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
17044            if self._additional_params.contains_key(field) {
17045                dlg.finished(false);
17046                return Err(common::Error::FieldClash(field));
17047            }
17048        }
17049
17050        let mut params = Params::with_capacity(4 + self._additional_params.len());
17051        params.push("resource", self._resource);
17052        if let Some(value) = self._options_requested_policy_version.as_ref() {
17053            params.push("options.requestedPolicyVersion", value.to_string());
17054        }
17055
17056        params.extend(self._additional_params.iter());
17057
17058        params.push("alt", "json");
17059        let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
17060        if self._scopes.is_empty() {
17061            self._scopes
17062                .insert(Scope::CloudPlatform.as_ref().to_string());
17063        }
17064
17065        #[allow(clippy::single_element_loop)]
17066        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
17067            url = params.uri_replacement(url, param_name, find_this, true);
17068        }
17069        {
17070            let to_remove = ["resource"];
17071            params.remove_params(&to_remove);
17072        }
17073
17074        let url = params.parse_with_url(&url);
17075
17076        loop {
17077            let token = match self
17078                .hub
17079                .auth
17080                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17081                .await
17082            {
17083                Ok(token) => token,
17084                Err(e) => match dlg.token(e) {
17085                    Ok(token) => token,
17086                    Err(e) => {
17087                        dlg.finished(false);
17088                        return Err(common::Error::MissingToken(e));
17089                    }
17090                },
17091            };
17092            let mut req_result = {
17093                let client = &self.hub.client;
17094                dlg.pre_request();
17095                let mut req_builder = hyper::Request::builder()
17096                    .method(hyper::Method::GET)
17097                    .uri(url.as_str())
17098                    .header(USER_AGENT, self.hub._user_agent.clone());
17099
17100                if let Some(token) = token.as_ref() {
17101                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17102                }
17103
17104                let request = req_builder
17105                    .header(CONTENT_LENGTH, 0_u64)
17106                    .body(common::to_body::<String>(None));
17107
17108                client.request(request.unwrap()).await
17109            };
17110
17111            match req_result {
17112                Err(err) => {
17113                    if let common::Retry::After(d) = dlg.http_error(&err) {
17114                        sleep(d).await;
17115                        continue;
17116                    }
17117                    dlg.finished(false);
17118                    return Err(common::Error::HttpError(err));
17119                }
17120                Ok(res) => {
17121                    let (mut parts, body) = res.into_parts();
17122                    let mut body = common::Body::new(body);
17123                    if !parts.status.is_success() {
17124                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17125                        let error = serde_json::from_str(&common::to_string(&bytes));
17126                        let response = common::to_response(parts, bytes.into());
17127
17128                        if let common::Retry::After(d) =
17129                            dlg.http_failure(&response, error.as_ref().ok())
17130                        {
17131                            sleep(d).await;
17132                            continue;
17133                        }
17134
17135                        dlg.finished(false);
17136
17137                        return Err(match error {
17138                            Ok(value) => common::Error::BadRequest(value),
17139                            _ => common::Error::Failure(response),
17140                        });
17141                    }
17142                    let response = {
17143                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17144                        let encoded = common::to_string(&bytes);
17145                        match serde_json::from_str(&encoded) {
17146                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17147                            Err(error) => {
17148                                dlg.response_json_decode_error(&encoded, &error);
17149                                return Err(common::Error::JsonDecodeError(
17150                                    encoded.to_string(),
17151                                    error,
17152                                ));
17153                            }
17154                        }
17155                    };
17156
17157                    dlg.finished(true);
17158                    return Ok(response);
17159                }
17160            }
17161        }
17162    }
17163
17164    /// 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.
17165    ///
17166    /// Sets the *resource* path property to the given value.
17167    ///
17168    /// Even though the property as already been set when instantiating this call,
17169    /// we provide this method for API completeness.
17170    pub fn resource(mut self, new_value: &str) -> ProjectLocationRuntimeGetIamPolicyCall<'a, C> {
17171        self._resource = new_value.to_string();
17172        self
17173    }
17174    /// 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).
17175    ///
17176    /// Sets the *options.requested policy version* query property to the given value.
17177    pub fn options_requested_policy_version(
17178        mut self,
17179        new_value: i32,
17180    ) -> ProjectLocationRuntimeGetIamPolicyCall<'a, C> {
17181        self._options_requested_policy_version = Some(new_value);
17182        self
17183    }
17184    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17185    /// while executing the actual API request.
17186    ///
17187    /// ````text
17188    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17189    /// ````
17190    ///
17191    /// Sets the *delegate* property to the given value.
17192    pub fn delegate(
17193        mut self,
17194        new_value: &'a mut dyn common::Delegate,
17195    ) -> ProjectLocationRuntimeGetIamPolicyCall<'a, C> {
17196        self._delegate = Some(new_value);
17197        self
17198    }
17199
17200    /// Set any additional parameter of the query string used in the request.
17201    /// It should be used to set parameters which are not yet available through their own
17202    /// setters.
17203    ///
17204    /// Please note that this method must not be used to set any of the known parameters
17205    /// which have their own setter method. If done anyway, the request will fail.
17206    ///
17207    /// # Additional Parameters
17208    ///
17209    /// * *$.xgafv* (query-string) - V1 error format.
17210    /// * *access_token* (query-string) - OAuth access token.
17211    /// * *alt* (query-string) - Data format for response.
17212    /// * *callback* (query-string) - JSONP
17213    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17214    /// * *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.
17215    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17216    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17217    /// * *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.
17218    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17219    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17220    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRuntimeGetIamPolicyCall<'a, C>
17221    where
17222        T: AsRef<str>,
17223    {
17224        self._additional_params
17225            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17226        self
17227    }
17228
17229    /// Identifies the authorization scope for the method you are building.
17230    ///
17231    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17232    /// [`Scope::CloudPlatform`].
17233    ///
17234    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17235    /// tokens for more than one scope.
17236    ///
17237    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17238    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17239    /// sufficient, a read-write scope will do as well.
17240    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRuntimeGetIamPolicyCall<'a, C>
17241    where
17242        St: AsRef<str>,
17243    {
17244        self._scopes.insert(String::from(scope.as_ref()));
17245        self
17246    }
17247    /// Identifies the authorization scope(s) for the method you are building.
17248    ///
17249    /// See [`Self::add_scope()`] for details.
17250    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRuntimeGetIamPolicyCall<'a, C>
17251    where
17252        I: IntoIterator<Item = St>,
17253        St: AsRef<str>,
17254    {
17255        self._scopes
17256            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17257        self
17258    }
17259
17260    /// Removes all scopes, and no default scope will be used either.
17261    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17262    /// for details).
17263    pub fn clear_scopes(mut self) -> ProjectLocationRuntimeGetIamPolicyCall<'a, C> {
17264        self._scopes.clear();
17265        self
17266    }
17267}
17268
17269/// Lists Runtimes in a given project and location.
17270///
17271/// A builder for the *locations.runtimes.list* method supported by a *project* resource.
17272/// It is not used directly, but through a [`ProjectMethods`] instance.
17273///
17274/// # Example
17275///
17276/// Instantiate a resource method builder
17277///
17278/// ```test_harness,no_run
17279/// # extern crate hyper;
17280/// # extern crate hyper_rustls;
17281/// # extern crate google_notebooks1 as notebooks1;
17282/// # async fn dox() {
17283/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17284///
17285/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17286/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17287/// #     secret,
17288/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17289/// # ).build().await.unwrap();
17290///
17291/// # let client = hyper_util::client::legacy::Client::builder(
17292/// #     hyper_util::rt::TokioExecutor::new()
17293/// # )
17294/// # .build(
17295/// #     hyper_rustls::HttpsConnectorBuilder::new()
17296/// #         .with_native_roots()
17297/// #         .unwrap()
17298/// #         .https_or_http()
17299/// #         .enable_http1()
17300/// #         .build()
17301/// # );
17302/// # let mut hub = AIPlatformNotebooks::new(client, auth);
17303/// // You can configure optional parameters by calling the respective setters at will, and
17304/// // execute the final call using `doit()`.
17305/// // Values shown here are possibly random and not representative !
17306/// let result = hub.projects().locations_runtimes_list("parent")
17307///              .page_token("accusam")
17308///              .page_size(-59)
17309///              .order_by("consetetur")
17310///              .filter("voluptua.")
17311///              .doit().await;
17312/// # }
17313/// ```
17314pub struct ProjectLocationRuntimeListCall<'a, C>
17315where
17316    C: 'a,
17317{
17318    hub: &'a AIPlatformNotebooks<C>,
17319    _parent: String,
17320    _page_token: Option<String>,
17321    _page_size: Option<i32>,
17322    _order_by: Option<String>,
17323    _filter: Option<String>,
17324    _delegate: Option<&'a mut dyn common::Delegate>,
17325    _additional_params: HashMap<String, String>,
17326    _scopes: BTreeSet<String>,
17327}
17328
17329impl<'a, C> common::CallBuilder for ProjectLocationRuntimeListCall<'a, C> {}
17330
17331impl<'a, C> ProjectLocationRuntimeListCall<'a, C>
17332where
17333    C: common::Connector,
17334{
17335    /// Perform the operation you have build so far.
17336    pub async fn doit(mut self) -> common::Result<(common::Response, ListRuntimesResponse)> {
17337        use std::borrow::Cow;
17338        use std::io::{Read, Seek};
17339
17340        use common::{url::Params, ToParts};
17341        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17342
17343        let mut dd = common::DefaultDelegate;
17344        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17345        dlg.begin(common::MethodInfo {
17346            id: "notebooks.projects.locations.runtimes.list",
17347            http_method: hyper::Method::GET,
17348        });
17349
17350        for &field in [
17351            "alt",
17352            "parent",
17353            "pageToken",
17354            "pageSize",
17355            "orderBy",
17356            "filter",
17357        ]
17358        .iter()
17359        {
17360            if self._additional_params.contains_key(field) {
17361                dlg.finished(false);
17362                return Err(common::Error::FieldClash(field));
17363            }
17364        }
17365
17366        let mut params = Params::with_capacity(7 + self._additional_params.len());
17367        params.push("parent", self._parent);
17368        if let Some(value) = self._page_token.as_ref() {
17369            params.push("pageToken", value);
17370        }
17371        if let Some(value) = self._page_size.as_ref() {
17372            params.push("pageSize", value.to_string());
17373        }
17374        if let Some(value) = self._order_by.as_ref() {
17375            params.push("orderBy", value);
17376        }
17377        if let Some(value) = self._filter.as_ref() {
17378            params.push("filter", value);
17379        }
17380
17381        params.extend(self._additional_params.iter());
17382
17383        params.push("alt", "json");
17384        let mut url = self.hub._base_url.clone() + "v1/{+parent}/runtimes";
17385        if self._scopes.is_empty() {
17386            self._scopes
17387                .insert(Scope::CloudPlatform.as_ref().to_string());
17388        }
17389
17390        #[allow(clippy::single_element_loop)]
17391        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
17392            url = params.uri_replacement(url, param_name, find_this, true);
17393        }
17394        {
17395            let to_remove = ["parent"];
17396            params.remove_params(&to_remove);
17397        }
17398
17399        let url = params.parse_with_url(&url);
17400
17401        loop {
17402            let token = match self
17403                .hub
17404                .auth
17405                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17406                .await
17407            {
17408                Ok(token) => token,
17409                Err(e) => match dlg.token(e) {
17410                    Ok(token) => token,
17411                    Err(e) => {
17412                        dlg.finished(false);
17413                        return Err(common::Error::MissingToken(e));
17414                    }
17415                },
17416            };
17417            let mut req_result = {
17418                let client = &self.hub.client;
17419                dlg.pre_request();
17420                let mut req_builder = hyper::Request::builder()
17421                    .method(hyper::Method::GET)
17422                    .uri(url.as_str())
17423                    .header(USER_AGENT, self.hub._user_agent.clone());
17424
17425                if let Some(token) = token.as_ref() {
17426                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17427                }
17428
17429                let request = req_builder
17430                    .header(CONTENT_LENGTH, 0_u64)
17431                    .body(common::to_body::<String>(None));
17432
17433                client.request(request.unwrap()).await
17434            };
17435
17436            match req_result {
17437                Err(err) => {
17438                    if let common::Retry::After(d) = dlg.http_error(&err) {
17439                        sleep(d).await;
17440                        continue;
17441                    }
17442                    dlg.finished(false);
17443                    return Err(common::Error::HttpError(err));
17444                }
17445                Ok(res) => {
17446                    let (mut parts, body) = res.into_parts();
17447                    let mut body = common::Body::new(body);
17448                    if !parts.status.is_success() {
17449                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17450                        let error = serde_json::from_str(&common::to_string(&bytes));
17451                        let response = common::to_response(parts, bytes.into());
17452
17453                        if let common::Retry::After(d) =
17454                            dlg.http_failure(&response, error.as_ref().ok())
17455                        {
17456                            sleep(d).await;
17457                            continue;
17458                        }
17459
17460                        dlg.finished(false);
17461
17462                        return Err(match error {
17463                            Ok(value) => common::Error::BadRequest(value),
17464                            _ => common::Error::Failure(response),
17465                        });
17466                    }
17467                    let response = {
17468                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17469                        let encoded = common::to_string(&bytes);
17470                        match serde_json::from_str(&encoded) {
17471                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17472                            Err(error) => {
17473                                dlg.response_json_decode_error(&encoded, &error);
17474                                return Err(common::Error::JsonDecodeError(
17475                                    encoded.to_string(),
17476                                    error,
17477                                ));
17478                            }
17479                        }
17480                    };
17481
17482                    dlg.finished(true);
17483                    return Ok(response);
17484                }
17485            }
17486        }
17487    }
17488
17489    /// Required. Format: `parent=projects/{project_id}/locations/{location}`
17490    ///
17491    /// Sets the *parent* path property to the given value.
17492    ///
17493    /// Even though the property as already been set when instantiating this call,
17494    /// we provide this method for API completeness.
17495    pub fn parent(mut self, new_value: &str) -> ProjectLocationRuntimeListCall<'a, C> {
17496        self._parent = new_value.to_string();
17497        self
17498    }
17499    /// A previous returned page token that can be used to continue listing from the last result.
17500    ///
17501    /// Sets the *page token* query property to the given value.
17502    pub fn page_token(mut self, new_value: &str) -> ProjectLocationRuntimeListCall<'a, C> {
17503        self._page_token = Some(new_value.to_string());
17504        self
17505    }
17506    /// Maximum return size of the list call.
17507    ///
17508    /// Sets the *page size* query property to the given value.
17509    pub fn page_size(mut self, new_value: i32) -> ProjectLocationRuntimeListCall<'a, C> {
17510        self._page_size = Some(new_value);
17511        self
17512    }
17513    /// Optional. Sort results. Supported values are "name", "name desc" or "" (unsorted).
17514    ///
17515    /// Sets the *order by* query property to the given value.
17516    pub fn order_by(mut self, new_value: &str) -> ProjectLocationRuntimeListCall<'a, C> {
17517        self._order_by = Some(new_value.to_string());
17518        self
17519    }
17520    /// Optional. List filter.
17521    ///
17522    /// Sets the *filter* query property to the given value.
17523    pub fn filter(mut self, new_value: &str) -> ProjectLocationRuntimeListCall<'a, C> {
17524        self._filter = Some(new_value.to_string());
17525        self
17526    }
17527    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17528    /// while executing the actual API request.
17529    ///
17530    /// ````text
17531    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17532    /// ````
17533    ///
17534    /// Sets the *delegate* property to the given value.
17535    pub fn delegate(
17536        mut self,
17537        new_value: &'a mut dyn common::Delegate,
17538    ) -> ProjectLocationRuntimeListCall<'a, C> {
17539        self._delegate = Some(new_value);
17540        self
17541    }
17542
17543    /// Set any additional parameter of the query string used in the request.
17544    /// It should be used to set parameters which are not yet available through their own
17545    /// setters.
17546    ///
17547    /// Please note that this method must not be used to set any of the known parameters
17548    /// which have their own setter method. If done anyway, the request will fail.
17549    ///
17550    /// # Additional Parameters
17551    ///
17552    /// * *$.xgafv* (query-string) - V1 error format.
17553    /// * *access_token* (query-string) - OAuth access token.
17554    /// * *alt* (query-string) - Data format for response.
17555    /// * *callback* (query-string) - JSONP
17556    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17557    /// * *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.
17558    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17559    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17560    /// * *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.
17561    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17562    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17563    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRuntimeListCall<'a, C>
17564    where
17565        T: AsRef<str>,
17566    {
17567        self._additional_params
17568            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17569        self
17570    }
17571
17572    /// Identifies the authorization scope for the method you are building.
17573    ///
17574    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17575    /// [`Scope::CloudPlatform`].
17576    ///
17577    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17578    /// tokens for more than one scope.
17579    ///
17580    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17581    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17582    /// sufficient, a read-write scope will do as well.
17583    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRuntimeListCall<'a, C>
17584    where
17585        St: AsRef<str>,
17586    {
17587        self._scopes.insert(String::from(scope.as_ref()));
17588        self
17589    }
17590    /// Identifies the authorization scope(s) for the method you are building.
17591    ///
17592    /// See [`Self::add_scope()`] for details.
17593    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRuntimeListCall<'a, C>
17594    where
17595        I: IntoIterator<Item = St>,
17596        St: AsRef<str>,
17597    {
17598        self._scopes
17599            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17600        self
17601    }
17602
17603    /// Removes all scopes, and no default scope will be used either.
17604    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17605    /// for details).
17606    pub fn clear_scopes(mut self) -> ProjectLocationRuntimeListCall<'a, C> {
17607        self._scopes.clear();
17608        self
17609    }
17610}
17611
17612/// Migrate an existing Runtime to a new Workbench Instance.
17613///
17614/// A builder for the *locations.runtimes.migrate* method supported by a *project* resource.
17615/// It is not used directly, but through a [`ProjectMethods`] instance.
17616///
17617/// # Example
17618///
17619/// Instantiate a resource method builder
17620///
17621/// ```test_harness,no_run
17622/// # extern crate hyper;
17623/// # extern crate hyper_rustls;
17624/// # extern crate google_notebooks1 as notebooks1;
17625/// use notebooks1::api::MigrateRuntimeRequest;
17626/// # async fn dox() {
17627/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17628///
17629/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17630/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17631/// #     secret,
17632/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17633/// # ).build().await.unwrap();
17634///
17635/// # let client = hyper_util::client::legacy::Client::builder(
17636/// #     hyper_util::rt::TokioExecutor::new()
17637/// # )
17638/// # .build(
17639/// #     hyper_rustls::HttpsConnectorBuilder::new()
17640/// #         .with_native_roots()
17641/// #         .unwrap()
17642/// #         .https_or_http()
17643/// #         .enable_http1()
17644/// #         .build()
17645/// # );
17646/// # let mut hub = AIPlatformNotebooks::new(client, auth);
17647/// // As the method needs a request, you would usually fill it with the desired information
17648/// // into the respective structure. Some of the parts shown here might not be applicable !
17649/// // Values shown here are possibly random and not representative !
17650/// let mut req = MigrateRuntimeRequest::default();
17651///
17652/// // You can configure optional parameters by calling the respective setters at will, and
17653/// // execute the final call using `doit()`.
17654/// // Values shown here are possibly random and not representative !
17655/// let result = hub.projects().locations_runtimes_migrate(req, "name")
17656///              .doit().await;
17657/// # }
17658/// ```
17659pub struct ProjectLocationRuntimeMigrateCall<'a, C>
17660where
17661    C: 'a,
17662{
17663    hub: &'a AIPlatformNotebooks<C>,
17664    _request: MigrateRuntimeRequest,
17665    _name: String,
17666    _delegate: Option<&'a mut dyn common::Delegate>,
17667    _additional_params: HashMap<String, String>,
17668    _scopes: BTreeSet<String>,
17669}
17670
17671impl<'a, C> common::CallBuilder for ProjectLocationRuntimeMigrateCall<'a, C> {}
17672
17673impl<'a, C> ProjectLocationRuntimeMigrateCall<'a, C>
17674where
17675    C: common::Connector,
17676{
17677    /// Perform the operation you have build so far.
17678    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
17679        use std::borrow::Cow;
17680        use std::io::{Read, Seek};
17681
17682        use common::{url::Params, ToParts};
17683        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17684
17685        let mut dd = common::DefaultDelegate;
17686        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17687        dlg.begin(common::MethodInfo {
17688            id: "notebooks.projects.locations.runtimes.migrate",
17689            http_method: hyper::Method::POST,
17690        });
17691
17692        for &field in ["alt", "name"].iter() {
17693            if self._additional_params.contains_key(field) {
17694                dlg.finished(false);
17695                return Err(common::Error::FieldClash(field));
17696            }
17697        }
17698
17699        let mut params = Params::with_capacity(4 + self._additional_params.len());
17700        params.push("name", self._name);
17701
17702        params.extend(self._additional_params.iter());
17703
17704        params.push("alt", "json");
17705        let mut url = self.hub._base_url.clone() + "v1/{+name}:migrate";
17706        if self._scopes.is_empty() {
17707            self._scopes
17708                .insert(Scope::CloudPlatform.as_ref().to_string());
17709        }
17710
17711        #[allow(clippy::single_element_loop)]
17712        for &(find_this, param_name) in [("{+name}", "name")].iter() {
17713            url = params.uri_replacement(url, param_name, find_this, true);
17714        }
17715        {
17716            let to_remove = ["name"];
17717            params.remove_params(&to_remove);
17718        }
17719
17720        let url = params.parse_with_url(&url);
17721
17722        let mut json_mime_type = mime::APPLICATION_JSON;
17723        let mut request_value_reader = {
17724            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17725            common::remove_json_null_values(&mut value);
17726            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17727            serde_json::to_writer(&mut dst, &value).unwrap();
17728            dst
17729        };
17730        let request_size = request_value_reader
17731            .seek(std::io::SeekFrom::End(0))
17732            .unwrap();
17733        request_value_reader
17734            .seek(std::io::SeekFrom::Start(0))
17735            .unwrap();
17736
17737        loop {
17738            let token = match self
17739                .hub
17740                .auth
17741                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17742                .await
17743            {
17744                Ok(token) => token,
17745                Err(e) => match dlg.token(e) {
17746                    Ok(token) => token,
17747                    Err(e) => {
17748                        dlg.finished(false);
17749                        return Err(common::Error::MissingToken(e));
17750                    }
17751                },
17752            };
17753            request_value_reader
17754                .seek(std::io::SeekFrom::Start(0))
17755                .unwrap();
17756            let mut req_result = {
17757                let client = &self.hub.client;
17758                dlg.pre_request();
17759                let mut req_builder = hyper::Request::builder()
17760                    .method(hyper::Method::POST)
17761                    .uri(url.as_str())
17762                    .header(USER_AGENT, self.hub._user_agent.clone());
17763
17764                if let Some(token) = token.as_ref() {
17765                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17766                }
17767
17768                let request = req_builder
17769                    .header(CONTENT_TYPE, json_mime_type.to_string())
17770                    .header(CONTENT_LENGTH, request_size as u64)
17771                    .body(common::to_body(
17772                        request_value_reader.get_ref().clone().into(),
17773                    ));
17774
17775                client.request(request.unwrap()).await
17776            };
17777
17778            match req_result {
17779                Err(err) => {
17780                    if let common::Retry::After(d) = dlg.http_error(&err) {
17781                        sleep(d).await;
17782                        continue;
17783                    }
17784                    dlg.finished(false);
17785                    return Err(common::Error::HttpError(err));
17786                }
17787                Ok(res) => {
17788                    let (mut parts, body) = res.into_parts();
17789                    let mut body = common::Body::new(body);
17790                    if !parts.status.is_success() {
17791                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17792                        let error = serde_json::from_str(&common::to_string(&bytes));
17793                        let response = common::to_response(parts, bytes.into());
17794
17795                        if let common::Retry::After(d) =
17796                            dlg.http_failure(&response, error.as_ref().ok())
17797                        {
17798                            sleep(d).await;
17799                            continue;
17800                        }
17801
17802                        dlg.finished(false);
17803
17804                        return Err(match error {
17805                            Ok(value) => common::Error::BadRequest(value),
17806                            _ => common::Error::Failure(response),
17807                        });
17808                    }
17809                    let response = {
17810                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17811                        let encoded = common::to_string(&bytes);
17812                        match serde_json::from_str(&encoded) {
17813                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17814                            Err(error) => {
17815                                dlg.response_json_decode_error(&encoded, &error);
17816                                return Err(common::Error::JsonDecodeError(
17817                                    encoded.to_string(),
17818                                    error,
17819                                ));
17820                            }
17821                        }
17822                    };
17823
17824                    dlg.finished(true);
17825                    return Ok(response);
17826                }
17827            }
17828        }
17829    }
17830
17831    ///
17832    /// Sets the *request* property to the given value.
17833    ///
17834    /// Even though the property as already been set when instantiating this call,
17835    /// we provide this method for API completeness.
17836    pub fn request(
17837        mut self,
17838        new_value: MigrateRuntimeRequest,
17839    ) -> ProjectLocationRuntimeMigrateCall<'a, C> {
17840        self._request = new_value;
17841        self
17842    }
17843    /// Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
17844    ///
17845    /// Sets the *name* path property to the given value.
17846    ///
17847    /// Even though the property as already been set when instantiating this call,
17848    /// we provide this method for API completeness.
17849    pub fn name(mut self, new_value: &str) -> ProjectLocationRuntimeMigrateCall<'a, C> {
17850        self._name = new_value.to_string();
17851        self
17852    }
17853    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17854    /// while executing the actual API request.
17855    ///
17856    /// ````text
17857    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17858    /// ````
17859    ///
17860    /// Sets the *delegate* property to the given value.
17861    pub fn delegate(
17862        mut self,
17863        new_value: &'a mut dyn common::Delegate,
17864    ) -> ProjectLocationRuntimeMigrateCall<'a, C> {
17865        self._delegate = Some(new_value);
17866        self
17867    }
17868
17869    /// Set any additional parameter of the query string used in the request.
17870    /// It should be used to set parameters which are not yet available through their own
17871    /// setters.
17872    ///
17873    /// Please note that this method must not be used to set any of the known parameters
17874    /// which have their own setter method. If done anyway, the request will fail.
17875    ///
17876    /// # Additional Parameters
17877    ///
17878    /// * *$.xgafv* (query-string) - V1 error format.
17879    /// * *access_token* (query-string) - OAuth access token.
17880    /// * *alt* (query-string) - Data format for response.
17881    /// * *callback* (query-string) - JSONP
17882    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17883    /// * *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.
17884    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17885    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17886    /// * *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.
17887    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17888    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17889    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRuntimeMigrateCall<'a, C>
17890    where
17891        T: AsRef<str>,
17892    {
17893        self._additional_params
17894            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17895        self
17896    }
17897
17898    /// Identifies the authorization scope for the method you are building.
17899    ///
17900    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17901    /// [`Scope::CloudPlatform`].
17902    ///
17903    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17904    /// tokens for more than one scope.
17905    ///
17906    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17907    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17908    /// sufficient, a read-write scope will do as well.
17909    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRuntimeMigrateCall<'a, C>
17910    where
17911        St: AsRef<str>,
17912    {
17913        self._scopes.insert(String::from(scope.as_ref()));
17914        self
17915    }
17916    /// Identifies the authorization scope(s) for the method you are building.
17917    ///
17918    /// See [`Self::add_scope()`] for details.
17919    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRuntimeMigrateCall<'a, C>
17920    where
17921        I: IntoIterator<Item = St>,
17922        St: AsRef<str>,
17923    {
17924        self._scopes
17925            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17926        self
17927    }
17928
17929    /// Removes all scopes, and no default scope will be used either.
17930    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17931    /// for details).
17932    pub fn clear_scopes(mut self) -> ProjectLocationRuntimeMigrateCall<'a, C> {
17933        self._scopes.clear();
17934        self
17935    }
17936}
17937
17938/// Update Notebook Runtime configuration.
17939///
17940/// A builder for the *locations.runtimes.patch* method supported by a *project* resource.
17941/// It is not used directly, but through a [`ProjectMethods`] instance.
17942///
17943/// # Example
17944///
17945/// Instantiate a resource method builder
17946///
17947/// ```test_harness,no_run
17948/// # extern crate hyper;
17949/// # extern crate hyper_rustls;
17950/// # extern crate google_notebooks1 as notebooks1;
17951/// use notebooks1::api::Runtime;
17952/// # async fn dox() {
17953/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17954///
17955/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17956/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17957/// #     secret,
17958/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17959/// # ).build().await.unwrap();
17960///
17961/// # let client = hyper_util::client::legacy::Client::builder(
17962/// #     hyper_util::rt::TokioExecutor::new()
17963/// # )
17964/// # .build(
17965/// #     hyper_rustls::HttpsConnectorBuilder::new()
17966/// #         .with_native_roots()
17967/// #         .unwrap()
17968/// #         .https_or_http()
17969/// #         .enable_http1()
17970/// #         .build()
17971/// # );
17972/// # let mut hub = AIPlatformNotebooks::new(client, auth);
17973/// // As the method needs a request, you would usually fill it with the desired information
17974/// // into the respective structure. Some of the parts shown here might not be applicable !
17975/// // Values shown here are possibly random and not representative !
17976/// let mut req = Runtime::default();
17977///
17978/// // You can configure optional parameters by calling the respective setters at will, and
17979/// // execute the final call using `doit()`.
17980/// // Values shown here are possibly random and not representative !
17981/// let result = hub.projects().locations_runtimes_patch(req, "name")
17982///              .update_mask(FieldMask::new::<&str>(&[]))
17983///              .request_id("consetetur")
17984///              .doit().await;
17985/// # }
17986/// ```
17987pub struct ProjectLocationRuntimePatchCall<'a, C>
17988where
17989    C: 'a,
17990{
17991    hub: &'a AIPlatformNotebooks<C>,
17992    _request: Runtime,
17993    _name: String,
17994    _update_mask: Option<common::FieldMask>,
17995    _request_id: Option<String>,
17996    _delegate: Option<&'a mut dyn common::Delegate>,
17997    _additional_params: HashMap<String, String>,
17998    _scopes: BTreeSet<String>,
17999}
18000
18001impl<'a, C> common::CallBuilder for ProjectLocationRuntimePatchCall<'a, C> {}
18002
18003impl<'a, C> ProjectLocationRuntimePatchCall<'a, C>
18004where
18005    C: common::Connector,
18006{
18007    /// Perform the operation you have build so far.
18008    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
18009        use std::borrow::Cow;
18010        use std::io::{Read, Seek};
18011
18012        use common::{url::Params, ToParts};
18013        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18014
18015        let mut dd = common::DefaultDelegate;
18016        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18017        dlg.begin(common::MethodInfo {
18018            id: "notebooks.projects.locations.runtimes.patch",
18019            http_method: hyper::Method::PATCH,
18020        });
18021
18022        for &field in ["alt", "name", "updateMask", "requestId"].iter() {
18023            if self._additional_params.contains_key(field) {
18024                dlg.finished(false);
18025                return Err(common::Error::FieldClash(field));
18026            }
18027        }
18028
18029        let mut params = Params::with_capacity(6 + self._additional_params.len());
18030        params.push("name", self._name);
18031        if let Some(value) = self._update_mask.as_ref() {
18032            params.push("updateMask", value.to_string());
18033        }
18034        if let Some(value) = self._request_id.as_ref() {
18035            params.push("requestId", value);
18036        }
18037
18038        params.extend(self._additional_params.iter());
18039
18040        params.push("alt", "json");
18041        let mut url = self.hub._base_url.clone() + "v1/{+name}";
18042        if self._scopes.is_empty() {
18043            self._scopes
18044                .insert(Scope::CloudPlatform.as_ref().to_string());
18045        }
18046
18047        #[allow(clippy::single_element_loop)]
18048        for &(find_this, param_name) in [("{+name}", "name")].iter() {
18049            url = params.uri_replacement(url, param_name, find_this, true);
18050        }
18051        {
18052            let to_remove = ["name"];
18053            params.remove_params(&to_remove);
18054        }
18055
18056        let url = params.parse_with_url(&url);
18057
18058        let mut json_mime_type = mime::APPLICATION_JSON;
18059        let mut request_value_reader = {
18060            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18061            common::remove_json_null_values(&mut value);
18062            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18063            serde_json::to_writer(&mut dst, &value).unwrap();
18064            dst
18065        };
18066        let request_size = request_value_reader
18067            .seek(std::io::SeekFrom::End(0))
18068            .unwrap();
18069        request_value_reader
18070            .seek(std::io::SeekFrom::Start(0))
18071            .unwrap();
18072
18073        loop {
18074            let token = match self
18075                .hub
18076                .auth
18077                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18078                .await
18079            {
18080                Ok(token) => token,
18081                Err(e) => match dlg.token(e) {
18082                    Ok(token) => token,
18083                    Err(e) => {
18084                        dlg.finished(false);
18085                        return Err(common::Error::MissingToken(e));
18086                    }
18087                },
18088            };
18089            request_value_reader
18090                .seek(std::io::SeekFrom::Start(0))
18091                .unwrap();
18092            let mut req_result = {
18093                let client = &self.hub.client;
18094                dlg.pre_request();
18095                let mut req_builder = hyper::Request::builder()
18096                    .method(hyper::Method::PATCH)
18097                    .uri(url.as_str())
18098                    .header(USER_AGENT, self.hub._user_agent.clone());
18099
18100                if let Some(token) = token.as_ref() {
18101                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18102                }
18103
18104                let request = req_builder
18105                    .header(CONTENT_TYPE, json_mime_type.to_string())
18106                    .header(CONTENT_LENGTH, request_size as u64)
18107                    .body(common::to_body(
18108                        request_value_reader.get_ref().clone().into(),
18109                    ));
18110
18111                client.request(request.unwrap()).await
18112            };
18113
18114            match req_result {
18115                Err(err) => {
18116                    if let common::Retry::After(d) = dlg.http_error(&err) {
18117                        sleep(d).await;
18118                        continue;
18119                    }
18120                    dlg.finished(false);
18121                    return Err(common::Error::HttpError(err));
18122                }
18123                Ok(res) => {
18124                    let (mut parts, body) = res.into_parts();
18125                    let mut body = common::Body::new(body);
18126                    if !parts.status.is_success() {
18127                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18128                        let error = serde_json::from_str(&common::to_string(&bytes));
18129                        let response = common::to_response(parts, bytes.into());
18130
18131                        if let common::Retry::After(d) =
18132                            dlg.http_failure(&response, error.as_ref().ok())
18133                        {
18134                            sleep(d).await;
18135                            continue;
18136                        }
18137
18138                        dlg.finished(false);
18139
18140                        return Err(match error {
18141                            Ok(value) => common::Error::BadRequest(value),
18142                            _ => common::Error::Failure(response),
18143                        });
18144                    }
18145                    let response = {
18146                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18147                        let encoded = common::to_string(&bytes);
18148                        match serde_json::from_str(&encoded) {
18149                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18150                            Err(error) => {
18151                                dlg.response_json_decode_error(&encoded, &error);
18152                                return Err(common::Error::JsonDecodeError(
18153                                    encoded.to_string(),
18154                                    error,
18155                                ));
18156                            }
18157                        }
18158                    };
18159
18160                    dlg.finished(true);
18161                    return Ok(response);
18162                }
18163            }
18164        }
18165    }
18166
18167    ///
18168    /// Sets the *request* property to the given value.
18169    ///
18170    /// Even though the property as already been set when instantiating this call,
18171    /// we provide this method for API completeness.
18172    pub fn request(mut self, new_value: Runtime) -> ProjectLocationRuntimePatchCall<'a, C> {
18173        self._request = new_value;
18174        self
18175    }
18176    /// Output only. The resource name of the runtime. Format: `projects/{project}/locations/{location}/runtimes/{runtimeId}`
18177    ///
18178    /// Sets the *name* path property to the given value.
18179    ///
18180    /// Even though the property as already been set when instantiating this call,
18181    /// we provide this method for API completeness.
18182    pub fn name(mut self, new_value: &str) -> ProjectLocationRuntimePatchCall<'a, C> {
18183        self._name = new_value.to_string();
18184        self
18185    }
18186    /// 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`
18187    ///
18188    /// Sets the *update mask* query property to the given value.
18189    pub fn update_mask(
18190        mut self,
18191        new_value: common::FieldMask,
18192    ) -> ProjectLocationRuntimePatchCall<'a, C> {
18193        self._update_mask = Some(new_value);
18194        self
18195    }
18196    /// Idempotent request UUID.
18197    ///
18198    /// Sets the *request id* query property to the given value.
18199    pub fn request_id(mut self, new_value: &str) -> ProjectLocationRuntimePatchCall<'a, C> {
18200        self._request_id = Some(new_value.to_string());
18201        self
18202    }
18203    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18204    /// while executing the actual API request.
18205    ///
18206    /// ````text
18207    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18208    /// ````
18209    ///
18210    /// Sets the *delegate* property to the given value.
18211    pub fn delegate(
18212        mut self,
18213        new_value: &'a mut dyn common::Delegate,
18214    ) -> ProjectLocationRuntimePatchCall<'a, C> {
18215        self._delegate = Some(new_value);
18216        self
18217    }
18218
18219    /// Set any additional parameter of the query string used in the request.
18220    /// It should be used to set parameters which are not yet available through their own
18221    /// setters.
18222    ///
18223    /// Please note that this method must not be used to set any of the known parameters
18224    /// which have their own setter method. If done anyway, the request will fail.
18225    ///
18226    /// # Additional Parameters
18227    ///
18228    /// * *$.xgafv* (query-string) - V1 error format.
18229    /// * *access_token* (query-string) - OAuth access token.
18230    /// * *alt* (query-string) - Data format for response.
18231    /// * *callback* (query-string) - JSONP
18232    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18233    /// * *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.
18234    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18235    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18236    /// * *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.
18237    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18238    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18239    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRuntimePatchCall<'a, C>
18240    where
18241        T: AsRef<str>,
18242    {
18243        self._additional_params
18244            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18245        self
18246    }
18247
18248    /// Identifies the authorization scope for the method you are building.
18249    ///
18250    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18251    /// [`Scope::CloudPlatform`].
18252    ///
18253    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18254    /// tokens for more than one scope.
18255    ///
18256    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18257    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18258    /// sufficient, a read-write scope will do as well.
18259    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRuntimePatchCall<'a, C>
18260    where
18261        St: AsRef<str>,
18262    {
18263        self._scopes.insert(String::from(scope.as_ref()));
18264        self
18265    }
18266    /// Identifies the authorization scope(s) for the method you are building.
18267    ///
18268    /// See [`Self::add_scope()`] for details.
18269    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRuntimePatchCall<'a, C>
18270    where
18271        I: IntoIterator<Item = St>,
18272        St: AsRef<str>,
18273    {
18274        self._scopes
18275            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18276        self
18277    }
18278
18279    /// Removes all scopes, and no default scope will be used either.
18280    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18281    /// for details).
18282    pub fn clear_scopes(mut self) -> ProjectLocationRuntimePatchCall<'a, C> {
18283        self._scopes.clear();
18284        self
18285    }
18286}
18287
18288/// Gets an access token for the consumer service account that the customer attached to the runtime. Only accessible from the tenant instance.
18289///
18290/// A builder for the *locations.runtimes.refreshRuntimeTokenInternal* method supported by a *project* resource.
18291/// It is not used directly, but through a [`ProjectMethods`] instance.
18292///
18293/// # Example
18294///
18295/// Instantiate a resource method builder
18296///
18297/// ```test_harness,no_run
18298/// # extern crate hyper;
18299/// # extern crate hyper_rustls;
18300/// # extern crate google_notebooks1 as notebooks1;
18301/// use notebooks1::api::RefreshRuntimeTokenInternalRequest;
18302/// # async fn dox() {
18303/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18304///
18305/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18306/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18307/// #     secret,
18308/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18309/// # ).build().await.unwrap();
18310///
18311/// # let client = hyper_util::client::legacy::Client::builder(
18312/// #     hyper_util::rt::TokioExecutor::new()
18313/// # )
18314/// # .build(
18315/// #     hyper_rustls::HttpsConnectorBuilder::new()
18316/// #         .with_native_roots()
18317/// #         .unwrap()
18318/// #         .https_or_http()
18319/// #         .enable_http1()
18320/// #         .build()
18321/// # );
18322/// # let mut hub = AIPlatformNotebooks::new(client, auth);
18323/// // As the method needs a request, you would usually fill it with the desired information
18324/// // into the respective structure. Some of the parts shown here might not be applicable !
18325/// // Values shown here are possibly random and not representative !
18326/// let mut req = RefreshRuntimeTokenInternalRequest::default();
18327///
18328/// // You can configure optional parameters by calling the respective setters at will, and
18329/// // execute the final call using `doit()`.
18330/// // Values shown here are possibly random and not representative !
18331/// let result = hub.projects().locations_runtimes_refresh_runtime_token_internal(req, "name")
18332///              .doit().await;
18333/// # }
18334/// ```
18335pub struct ProjectLocationRuntimeRefreshRuntimeTokenInternalCall<'a, C>
18336where
18337    C: 'a,
18338{
18339    hub: &'a AIPlatformNotebooks<C>,
18340    _request: RefreshRuntimeTokenInternalRequest,
18341    _name: String,
18342    _delegate: Option<&'a mut dyn common::Delegate>,
18343    _additional_params: HashMap<String, String>,
18344    _scopes: BTreeSet<String>,
18345}
18346
18347impl<'a, C> common::CallBuilder for ProjectLocationRuntimeRefreshRuntimeTokenInternalCall<'a, C> {}
18348
18349impl<'a, C> ProjectLocationRuntimeRefreshRuntimeTokenInternalCall<'a, C>
18350where
18351    C: common::Connector,
18352{
18353    /// Perform the operation you have build so far.
18354    pub async fn doit(
18355        mut self,
18356    ) -> common::Result<(common::Response, RefreshRuntimeTokenInternalResponse)> {
18357        use std::borrow::Cow;
18358        use std::io::{Read, Seek};
18359
18360        use common::{url::Params, ToParts};
18361        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18362
18363        let mut dd = common::DefaultDelegate;
18364        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18365        dlg.begin(common::MethodInfo {
18366            id: "notebooks.projects.locations.runtimes.refreshRuntimeTokenInternal",
18367            http_method: hyper::Method::POST,
18368        });
18369
18370        for &field in ["alt", "name"].iter() {
18371            if self._additional_params.contains_key(field) {
18372                dlg.finished(false);
18373                return Err(common::Error::FieldClash(field));
18374            }
18375        }
18376
18377        let mut params = Params::with_capacity(4 + self._additional_params.len());
18378        params.push("name", self._name);
18379
18380        params.extend(self._additional_params.iter());
18381
18382        params.push("alt", "json");
18383        let mut url = self.hub._base_url.clone() + "v1/{+name}:refreshRuntimeTokenInternal";
18384        if self._scopes.is_empty() {
18385            self._scopes
18386                .insert(Scope::CloudPlatform.as_ref().to_string());
18387        }
18388
18389        #[allow(clippy::single_element_loop)]
18390        for &(find_this, param_name) in [("{+name}", "name")].iter() {
18391            url = params.uri_replacement(url, param_name, find_this, true);
18392        }
18393        {
18394            let to_remove = ["name"];
18395            params.remove_params(&to_remove);
18396        }
18397
18398        let url = params.parse_with_url(&url);
18399
18400        let mut json_mime_type = mime::APPLICATION_JSON;
18401        let mut request_value_reader = {
18402            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18403            common::remove_json_null_values(&mut value);
18404            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18405            serde_json::to_writer(&mut dst, &value).unwrap();
18406            dst
18407        };
18408        let request_size = request_value_reader
18409            .seek(std::io::SeekFrom::End(0))
18410            .unwrap();
18411        request_value_reader
18412            .seek(std::io::SeekFrom::Start(0))
18413            .unwrap();
18414
18415        loop {
18416            let token = match self
18417                .hub
18418                .auth
18419                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18420                .await
18421            {
18422                Ok(token) => token,
18423                Err(e) => match dlg.token(e) {
18424                    Ok(token) => token,
18425                    Err(e) => {
18426                        dlg.finished(false);
18427                        return Err(common::Error::MissingToken(e));
18428                    }
18429                },
18430            };
18431            request_value_reader
18432                .seek(std::io::SeekFrom::Start(0))
18433                .unwrap();
18434            let mut req_result = {
18435                let client = &self.hub.client;
18436                dlg.pre_request();
18437                let mut req_builder = hyper::Request::builder()
18438                    .method(hyper::Method::POST)
18439                    .uri(url.as_str())
18440                    .header(USER_AGENT, self.hub._user_agent.clone());
18441
18442                if let Some(token) = token.as_ref() {
18443                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18444                }
18445
18446                let request = req_builder
18447                    .header(CONTENT_TYPE, json_mime_type.to_string())
18448                    .header(CONTENT_LENGTH, request_size as u64)
18449                    .body(common::to_body(
18450                        request_value_reader.get_ref().clone().into(),
18451                    ));
18452
18453                client.request(request.unwrap()).await
18454            };
18455
18456            match req_result {
18457                Err(err) => {
18458                    if let common::Retry::After(d) = dlg.http_error(&err) {
18459                        sleep(d).await;
18460                        continue;
18461                    }
18462                    dlg.finished(false);
18463                    return Err(common::Error::HttpError(err));
18464                }
18465                Ok(res) => {
18466                    let (mut parts, body) = res.into_parts();
18467                    let mut body = common::Body::new(body);
18468                    if !parts.status.is_success() {
18469                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18470                        let error = serde_json::from_str(&common::to_string(&bytes));
18471                        let response = common::to_response(parts, bytes.into());
18472
18473                        if let common::Retry::After(d) =
18474                            dlg.http_failure(&response, error.as_ref().ok())
18475                        {
18476                            sleep(d).await;
18477                            continue;
18478                        }
18479
18480                        dlg.finished(false);
18481
18482                        return Err(match error {
18483                            Ok(value) => common::Error::BadRequest(value),
18484                            _ => common::Error::Failure(response),
18485                        });
18486                    }
18487                    let response = {
18488                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18489                        let encoded = common::to_string(&bytes);
18490                        match serde_json::from_str(&encoded) {
18491                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18492                            Err(error) => {
18493                                dlg.response_json_decode_error(&encoded, &error);
18494                                return Err(common::Error::JsonDecodeError(
18495                                    encoded.to_string(),
18496                                    error,
18497                                ));
18498                            }
18499                        }
18500                    };
18501
18502                    dlg.finished(true);
18503                    return Ok(response);
18504                }
18505            }
18506        }
18507    }
18508
18509    ///
18510    /// Sets the *request* property to the given value.
18511    ///
18512    /// Even though the property as already been set when instantiating this call,
18513    /// we provide this method for API completeness.
18514    pub fn request(
18515        mut self,
18516        new_value: RefreshRuntimeTokenInternalRequest,
18517    ) -> ProjectLocationRuntimeRefreshRuntimeTokenInternalCall<'a, C> {
18518        self._request = new_value;
18519        self
18520    }
18521    /// Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
18522    ///
18523    /// Sets the *name* path property to the given value.
18524    ///
18525    /// Even though the property as already been set when instantiating this call,
18526    /// we provide this method for API completeness.
18527    pub fn name(
18528        mut self,
18529        new_value: &str,
18530    ) -> ProjectLocationRuntimeRefreshRuntimeTokenInternalCall<'a, C> {
18531        self._name = new_value.to_string();
18532        self
18533    }
18534    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18535    /// while executing the actual API request.
18536    ///
18537    /// ````text
18538    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18539    /// ````
18540    ///
18541    /// Sets the *delegate* property to the given value.
18542    pub fn delegate(
18543        mut self,
18544        new_value: &'a mut dyn common::Delegate,
18545    ) -> ProjectLocationRuntimeRefreshRuntimeTokenInternalCall<'a, C> {
18546        self._delegate = Some(new_value);
18547        self
18548    }
18549
18550    /// Set any additional parameter of the query string used in the request.
18551    /// It should be used to set parameters which are not yet available through their own
18552    /// setters.
18553    ///
18554    /// Please note that this method must not be used to set any of the known parameters
18555    /// which have their own setter method. If done anyway, the request will fail.
18556    ///
18557    /// # Additional Parameters
18558    ///
18559    /// * *$.xgafv* (query-string) - V1 error format.
18560    /// * *access_token* (query-string) - OAuth access token.
18561    /// * *alt* (query-string) - Data format for response.
18562    /// * *callback* (query-string) - JSONP
18563    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18564    /// * *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.
18565    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18566    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18567    /// * *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.
18568    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18569    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18570    pub fn param<T>(
18571        mut self,
18572        name: T,
18573        value: T,
18574    ) -> ProjectLocationRuntimeRefreshRuntimeTokenInternalCall<'a, C>
18575    where
18576        T: AsRef<str>,
18577    {
18578        self._additional_params
18579            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18580        self
18581    }
18582
18583    /// Identifies the authorization scope for the method you are building.
18584    ///
18585    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18586    /// [`Scope::CloudPlatform`].
18587    ///
18588    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18589    /// tokens for more than one scope.
18590    ///
18591    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18592    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18593    /// sufficient, a read-write scope will do as well.
18594    pub fn add_scope<St>(
18595        mut self,
18596        scope: St,
18597    ) -> ProjectLocationRuntimeRefreshRuntimeTokenInternalCall<'a, C>
18598    where
18599        St: AsRef<str>,
18600    {
18601        self._scopes.insert(String::from(scope.as_ref()));
18602        self
18603    }
18604    /// Identifies the authorization scope(s) for the method you are building.
18605    ///
18606    /// See [`Self::add_scope()`] for details.
18607    pub fn add_scopes<I, St>(
18608        mut self,
18609        scopes: I,
18610    ) -> ProjectLocationRuntimeRefreshRuntimeTokenInternalCall<'a, C>
18611    where
18612        I: IntoIterator<Item = St>,
18613        St: AsRef<str>,
18614    {
18615        self._scopes
18616            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18617        self
18618    }
18619
18620    /// Removes all scopes, and no default scope will be used either.
18621    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18622    /// for details).
18623    pub fn clear_scopes(mut self) -> ProjectLocationRuntimeRefreshRuntimeTokenInternalCall<'a, C> {
18624        self._scopes.clear();
18625        self
18626    }
18627}
18628
18629/// Reports and processes a runtime event.
18630///
18631/// A builder for the *locations.runtimes.reportEvent* method supported by a *project* resource.
18632/// It is not used directly, but through a [`ProjectMethods`] instance.
18633///
18634/// # Example
18635///
18636/// Instantiate a resource method builder
18637///
18638/// ```test_harness,no_run
18639/// # extern crate hyper;
18640/// # extern crate hyper_rustls;
18641/// # extern crate google_notebooks1 as notebooks1;
18642/// use notebooks1::api::ReportRuntimeEventRequest;
18643/// # async fn dox() {
18644/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18645///
18646/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18647/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18648/// #     secret,
18649/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18650/// # ).build().await.unwrap();
18651///
18652/// # let client = hyper_util::client::legacy::Client::builder(
18653/// #     hyper_util::rt::TokioExecutor::new()
18654/// # )
18655/// # .build(
18656/// #     hyper_rustls::HttpsConnectorBuilder::new()
18657/// #         .with_native_roots()
18658/// #         .unwrap()
18659/// #         .https_or_http()
18660/// #         .enable_http1()
18661/// #         .build()
18662/// # );
18663/// # let mut hub = AIPlatformNotebooks::new(client, auth);
18664/// // As the method needs a request, you would usually fill it with the desired information
18665/// // into the respective structure. Some of the parts shown here might not be applicable !
18666/// // Values shown here are possibly random and not representative !
18667/// let mut req = ReportRuntimeEventRequest::default();
18668///
18669/// // You can configure optional parameters by calling the respective setters at will, and
18670/// // execute the final call using `doit()`.
18671/// // Values shown here are possibly random and not representative !
18672/// let result = hub.projects().locations_runtimes_report_event(req, "name")
18673///              .doit().await;
18674/// # }
18675/// ```
18676pub struct ProjectLocationRuntimeReportEventCall<'a, C>
18677where
18678    C: 'a,
18679{
18680    hub: &'a AIPlatformNotebooks<C>,
18681    _request: ReportRuntimeEventRequest,
18682    _name: String,
18683    _delegate: Option<&'a mut dyn common::Delegate>,
18684    _additional_params: HashMap<String, String>,
18685    _scopes: BTreeSet<String>,
18686}
18687
18688impl<'a, C> common::CallBuilder for ProjectLocationRuntimeReportEventCall<'a, C> {}
18689
18690impl<'a, C> ProjectLocationRuntimeReportEventCall<'a, C>
18691where
18692    C: common::Connector,
18693{
18694    /// Perform the operation you have build so far.
18695    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
18696        use std::borrow::Cow;
18697        use std::io::{Read, Seek};
18698
18699        use common::{url::Params, ToParts};
18700        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18701
18702        let mut dd = common::DefaultDelegate;
18703        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18704        dlg.begin(common::MethodInfo {
18705            id: "notebooks.projects.locations.runtimes.reportEvent",
18706            http_method: hyper::Method::POST,
18707        });
18708
18709        for &field in ["alt", "name"].iter() {
18710            if self._additional_params.contains_key(field) {
18711                dlg.finished(false);
18712                return Err(common::Error::FieldClash(field));
18713            }
18714        }
18715
18716        let mut params = Params::with_capacity(4 + self._additional_params.len());
18717        params.push("name", self._name);
18718
18719        params.extend(self._additional_params.iter());
18720
18721        params.push("alt", "json");
18722        let mut url = self.hub._base_url.clone() + "v1/{+name}:reportEvent";
18723        if self._scopes.is_empty() {
18724            self._scopes
18725                .insert(Scope::CloudPlatform.as_ref().to_string());
18726        }
18727
18728        #[allow(clippy::single_element_loop)]
18729        for &(find_this, param_name) in [("{+name}", "name")].iter() {
18730            url = params.uri_replacement(url, param_name, find_this, true);
18731        }
18732        {
18733            let to_remove = ["name"];
18734            params.remove_params(&to_remove);
18735        }
18736
18737        let url = params.parse_with_url(&url);
18738
18739        let mut json_mime_type = mime::APPLICATION_JSON;
18740        let mut request_value_reader = {
18741            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18742            common::remove_json_null_values(&mut value);
18743            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18744            serde_json::to_writer(&mut dst, &value).unwrap();
18745            dst
18746        };
18747        let request_size = request_value_reader
18748            .seek(std::io::SeekFrom::End(0))
18749            .unwrap();
18750        request_value_reader
18751            .seek(std::io::SeekFrom::Start(0))
18752            .unwrap();
18753
18754        loop {
18755            let token = match self
18756                .hub
18757                .auth
18758                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18759                .await
18760            {
18761                Ok(token) => token,
18762                Err(e) => match dlg.token(e) {
18763                    Ok(token) => token,
18764                    Err(e) => {
18765                        dlg.finished(false);
18766                        return Err(common::Error::MissingToken(e));
18767                    }
18768                },
18769            };
18770            request_value_reader
18771                .seek(std::io::SeekFrom::Start(0))
18772                .unwrap();
18773            let mut req_result = {
18774                let client = &self.hub.client;
18775                dlg.pre_request();
18776                let mut req_builder = hyper::Request::builder()
18777                    .method(hyper::Method::POST)
18778                    .uri(url.as_str())
18779                    .header(USER_AGENT, self.hub._user_agent.clone());
18780
18781                if let Some(token) = token.as_ref() {
18782                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18783                }
18784
18785                let request = req_builder
18786                    .header(CONTENT_TYPE, json_mime_type.to_string())
18787                    .header(CONTENT_LENGTH, request_size as u64)
18788                    .body(common::to_body(
18789                        request_value_reader.get_ref().clone().into(),
18790                    ));
18791
18792                client.request(request.unwrap()).await
18793            };
18794
18795            match req_result {
18796                Err(err) => {
18797                    if let common::Retry::After(d) = dlg.http_error(&err) {
18798                        sleep(d).await;
18799                        continue;
18800                    }
18801                    dlg.finished(false);
18802                    return Err(common::Error::HttpError(err));
18803                }
18804                Ok(res) => {
18805                    let (mut parts, body) = res.into_parts();
18806                    let mut body = common::Body::new(body);
18807                    if !parts.status.is_success() {
18808                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18809                        let error = serde_json::from_str(&common::to_string(&bytes));
18810                        let response = common::to_response(parts, bytes.into());
18811
18812                        if let common::Retry::After(d) =
18813                            dlg.http_failure(&response, error.as_ref().ok())
18814                        {
18815                            sleep(d).await;
18816                            continue;
18817                        }
18818
18819                        dlg.finished(false);
18820
18821                        return Err(match error {
18822                            Ok(value) => common::Error::BadRequest(value),
18823                            _ => common::Error::Failure(response),
18824                        });
18825                    }
18826                    let response = {
18827                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18828                        let encoded = common::to_string(&bytes);
18829                        match serde_json::from_str(&encoded) {
18830                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18831                            Err(error) => {
18832                                dlg.response_json_decode_error(&encoded, &error);
18833                                return Err(common::Error::JsonDecodeError(
18834                                    encoded.to_string(),
18835                                    error,
18836                                ));
18837                            }
18838                        }
18839                    };
18840
18841                    dlg.finished(true);
18842                    return Ok(response);
18843                }
18844            }
18845        }
18846    }
18847
18848    ///
18849    /// Sets the *request* property to the given value.
18850    ///
18851    /// Even though the property as already been set when instantiating this call,
18852    /// we provide this method for API completeness.
18853    pub fn request(
18854        mut self,
18855        new_value: ReportRuntimeEventRequest,
18856    ) -> ProjectLocationRuntimeReportEventCall<'a, C> {
18857        self._request = new_value;
18858        self
18859    }
18860    /// Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
18861    ///
18862    /// Sets the *name* path property to the given value.
18863    ///
18864    /// Even though the property as already been set when instantiating this call,
18865    /// we provide this method for API completeness.
18866    pub fn name(mut self, new_value: &str) -> ProjectLocationRuntimeReportEventCall<'a, C> {
18867        self._name = new_value.to_string();
18868        self
18869    }
18870    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18871    /// while executing the actual API request.
18872    ///
18873    /// ````text
18874    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18875    /// ````
18876    ///
18877    /// Sets the *delegate* property to the given value.
18878    pub fn delegate(
18879        mut self,
18880        new_value: &'a mut dyn common::Delegate,
18881    ) -> ProjectLocationRuntimeReportEventCall<'a, C> {
18882        self._delegate = Some(new_value);
18883        self
18884    }
18885
18886    /// Set any additional parameter of the query string used in the request.
18887    /// It should be used to set parameters which are not yet available through their own
18888    /// setters.
18889    ///
18890    /// Please note that this method must not be used to set any of the known parameters
18891    /// which have their own setter method. If done anyway, the request will fail.
18892    ///
18893    /// # Additional Parameters
18894    ///
18895    /// * *$.xgafv* (query-string) - V1 error format.
18896    /// * *access_token* (query-string) - OAuth access token.
18897    /// * *alt* (query-string) - Data format for response.
18898    /// * *callback* (query-string) - JSONP
18899    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18900    /// * *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.
18901    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18902    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18903    /// * *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.
18904    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18905    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18906    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRuntimeReportEventCall<'a, C>
18907    where
18908        T: AsRef<str>,
18909    {
18910        self._additional_params
18911            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18912        self
18913    }
18914
18915    /// Identifies the authorization scope for the method you are building.
18916    ///
18917    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18918    /// [`Scope::CloudPlatform`].
18919    ///
18920    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18921    /// tokens for more than one scope.
18922    ///
18923    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18924    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18925    /// sufficient, a read-write scope will do as well.
18926    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRuntimeReportEventCall<'a, C>
18927    where
18928        St: AsRef<str>,
18929    {
18930        self._scopes.insert(String::from(scope.as_ref()));
18931        self
18932    }
18933    /// Identifies the authorization scope(s) for the method you are building.
18934    ///
18935    /// See [`Self::add_scope()`] for details.
18936    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRuntimeReportEventCall<'a, C>
18937    where
18938        I: IntoIterator<Item = St>,
18939        St: AsRef<str>,
18940    {
18941        self._scopes
18942            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18943        self
18944    }
18945
18946    /// Removes all scopes, and no default scope will be used either.
18947    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18948    /// for details).
18949    pub fn clear_scopes(mut self) -> ProjectLocationRuntimeReportEventCall<'a, C> {
18950        self._scopes.clear();
18951        self
18952    }
18953}
18954
18955/// Resets a Managed Notebook Runtime.
18956///
18957/// A builder for the *locations.runtimes.reset* method supported by a *project* resource.
18958/// It is not used directly, but through a [`ProjectMethods`] instance.
18959///
18960/// # Example
18961///
18962/// Instantiate a resource method builder
18963///
18964/// ```test_harness,no_run
18965/// # extern crate hyper;
18966/// # extern crate hyper_rustls;
18967/// # extern crate google_notebooks1 as notebooks1;
18968/// use notebooks1::api::ResetRuntimeRequest;
18969/// # async fn dox() {
18970/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18971///
18972/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18973/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18974/// #     secret,
18975/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18976/// # ).build().await.unwrap();
18977///
18978/// # let client = hyper_util::client::legacy::Client::builder(
18979/// #     hyper_util::rt::TokioExecutor::new()
18980/// # )
18981/// # .build(
18982/// #     hyper_rustls::HttpsConnectorBuilder::new()
18983/// #         .with_native_roots()
18984/// #         .unwrap()
18985/// #         .https_or_http()
18986/// #         .enable_http1()
18987/// #         .build()
18988/// # );
18989/// # let mut hub = AIPlatformNotebooks::new(client, auth);
18990/// // As the method needs a request, you would usually fill it with the desired information
18991/// // into the respective structure. Some of the parts shown here might not be applicable !
18992/// // Values shown here are possibly random and not representative !
18993/// let mut req = ResetRuntimeRequest::default();
18994///
18995/// // You can configure optional parameters by calling the respective setters at will, and
18996/// // execute the final call using `doit()`.
18997/// // Values shown here are possibly random and not representative !
18998/// let result = hub.projects().locations_runtimes_reset(req, "name")
18999///              .doit().await;
19000/// # }
19001/// ```
19002pub struct ProjectLocationRuntimeResetCall<'a, C>
19003where
19004    C: 'a,
19005{
19006    hub: &'a AIPlatformNotebooks<C>,
19007    _request: ResetRuntimeRequest,
19008    _name: String,
19009    _delegate: Option<&'a mut dyn common::Delegate>,
19010    _additional_params: HashMap<String, String>,
19011    _scopes: BTreeSet<String>,
19012}
19013
19014impl<'a, C> common::CallBuilder for ProjectLocationRuntimeResetCall<'a, C> {}
19015
19016impl<'a, C> ProjectLocationRuntimeResetCall<'a, C>
19017where
19018    C: common::Connector,
19019{
19020    /// Perform the operation you have build so far.
19021    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
19022        use std::borrow::Cow;
19023        use std::io::{Read, Seek};
19024
19025        use common::{url::Params, ToParts};
19026        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19027
19028        let mut dd = common::DefaultDelegate;
19029        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19030        dlg.begin(common::MethodInfo {
19031            id: "notebooks.projects.locations.runtimes.reset",
19032            http_method: hyper::Method::POST,
19033        });
19034
19035        for &field in ["alt", "name"].iter() {
19036            if self._additional_params.contains_key(field) {
19037                dlg.finished(false);
19038                return Err(common::Error::FieldClash(field));
19039            }
19040        }
19041
19042        let mut params = Params::with_capacity(4 + self._additional_params.len());
19043        params.push("name", self._name);
19044
19045        params.extend(self._additional_params.iter());
19046
19047        params.push("alt", "json");
19048        let mut url = self.hub._base_url.clone() + "v1/{+name}:reset";
19049        if self._scopes.is_empty() {
19050            self._scopes
19051                .insert(Scope::CloudPlatform.as_ref().to_string());
19052        }
19053
19054        #[allow(clippy::single_element_loop)]
19055        for &(find_this, param_name) in [("{+name}", "name")].iter() {
19056            url = params.uri_replacement(url, param_name, find_this, true);
19057        }
19058        {
19059            let to_remove = ["name"];
19060            params.remove_params(&to_remove);
19061        }
19062
19063        let url = params.parse_with_url(&url);
19064
19065        let mut json_mime_type = mime::APPLICATION_JSON;
19066        let mut request_value_reader = {
19067            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19068            common::remove_json_null_values(&mut value);
19069            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19070            serde_json::to_writer(&mut dst, &value).unwrap();
19071            dst
19072        };
19073        let request_size = request_value_reader
19074            .seek(std::io::SeekFrom::End(0))
19075            .unwrap();
19076        request_value_reader
19077            .seek(std::io::SeekFrom::Start(0))
19078            .unwrap();
19079
19080        loop {
19081            let token = match self
19082                .hub
19083                .auth
19084                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19085                .await
19086            {
19087                Ok(token) => token,
19088                Err(e) => match dlg.token(e) {
19089                    Ok(token) => token,
19090                    Err(e) => {
19091                        dlg.finished(false);
19092                        return Err(common::Error::MissingToken(e));
19093                    }
19094                },
19095            };
19096            request_value_reader
19097                .seek(std::io::SeekFrom::Start(0))
19098                .unwrap();
19099            let mut req_result = {
19100                let client = &self.hub.client;
19101                dlg.pre_request();
19102                let mut req_builder = hyper::Request::builder()
19103                    .method(hyper::Method::POST)
19104                    .uri(url.as_str())
19105                    .header(USER_AGENT, self.hub._user_agent.clone());
19106
19107                if let Some(token) = token.as_ref() {
19108                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19109                }
19110
19111                let request = req_builder
19112                    .header(CONTENT_TYPE, json_mime_type.to_string())
19113                    .header(CONTENT_LENGTH, request_size as u64)
19114                    .body(common::to_body(
19115                        request_value_reader.get_ref().clone().into(),
19116                    ));
19117
19118                client.request(request.unwrap()).await
19119            };
19120
19121            match req_result {
19122                Err(err) => {
19123                    if let common::Retry::After(d) = dlg.http_error(&err) {
19124                        sleep(d).await;
19125                        continue;
19126                    }
19127                    dlg.finished(false);
19128                    return Err(common::Error::HttpError(err));
19129                }
19130                Ok(res) => {
19131                    let (mut parts, body) = res.into_parts();
19132                    let mut body = common::Body::new(body);
19133                    if !parts.status.is_success() {
19134                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19135                        let error = serde_json::from_str(&common::to_string(&bytes));
19136                        let response = common::to_response(parts, bytes.into());
19137
19138                        if let common::Retry::After(d) =
19139                            dlg.http_failure(&response, error.as_ref().ok())
19140                        {
19141                            sleep(d).await;
19142                            continue;
19143                        }
19144
19145                        dlg.finished(false);
19146
19147                        return Err(match error {
19148                            Ok(value) => common::Error::BadRequest(value),
19149                            _ => common::Error::Failure(response),
19150                        });
19151                    }
19152                    let response = {
19153                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19154                        let encoded = common::to_string(&bytes);
19155                        match serde_json::from_str(&encoded) {
19156                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19157                            Err(error) => {
19158                                dlg.response_json_decode_error(&encoded, &error);
19159                                return Err(common::Error::JsonDecodeError(
19160                                    encoded.to_string(),
19161                                    error,
19162                                ));
19163                            }
19164                        }
19165                    };
19166
19167                    dlg.finished(true);
19168                    return Ok(response);
19169                }
19170            }
19171        }
19172    }
19173
19174    ///
19175    /// Sets the *request* property to the given value.
19176    ///
19177    /// Even though the property as already been set when instantiating this call,
19178    /// we provide this method for API completeness.
19179    pub fn request(
19180        mut self,
19181        new_value: ResetRuntimeRequest,
19182    ) -> ProjectLocationRuntimeResetCall<'a, C> {
19183        self._request = new_value;
19184        self
19185    }
19186    /// Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
19187    ///
19188    /// Sets the *name* path property to the given value.
19189    ///
19190    /// Even though the property as already been set when instantiating this call,
19191    /// we provide this method for API completeness.
19192    pub fn name(mut self, new_value: &str) -> ProjectLocationRuntimeResetCall<'a, C> {
19193        self._name = new_value.to_string();
19194        self
19195    }
19196    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19197    /// while executing the actual API request.
19198    ///
19199    /// ````text
19200    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19201    /// ````
19202    ///
19203    /// Sets the *delegate* property to the given value.
19204    pub fn delegate(
19205        mut self,
19206        new_value: &'a mut dyn common::Delegate,
19207    ) -> ProjectLocationRuntimeResetCall<'a, C> {
19208        self._delegate = Some(new_value);
19209        self
19210    }
19211
19212    /// Set any additional parameter of the query string used in the request.
19213    /// It should be used to set parameters which are not yet available through their own
19214    /// setters.
19215    ///
19216    /// Please note that this method must not be used to set any of the known parameters
19217    /// which have their own setter method. If done anyway, the request will fail.
19218    ///
19219    /// # Additional Parameters
19220    ///
19221    /// * *$.xgafv* (query-string) - V1 error format.
19222    /// * *access_token* (query-string) - OAuth access token.
19223    /// * *alt* (query-string) - Data format for response.
19224    /// * *callback* (query-string) - JSONP
19225    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19226    /// * *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.
19227    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19228    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19229    /// * *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.
19230    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19231    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19232    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRuntimeResetCall<'a, C>
19233    where
19234        T: AsRef<str>,
19235    {
19236        self._additional_params
19237            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19238        self
19239    }
19240
19241    /// Identifies the authorization scope for the method you are building.
19242    ///
19243    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19244    /// [`Scope::CloudPlatform`].
19245    ///
19246    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19247    /// tokens for more than one scope.
19248    ///
19249    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19250    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19251    /// sufficient, a read-write scope will do as well.
19252    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRuntimeResetCall<'a, C>
19253    where
19254        St: AsRef<str>,
19255    {
19256        self._scopes.insert(String::from(scope.as_ref()));
19257        self
19258    }
19259    /// Identifies the authorization scope(s) for the method you are building.
19260    ///
19261    /// See [`Self::add_scope()`] for details.
19262    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRuntimeResetCall<'a, C>
19263    where
19264        I: IntoIterator<Item = St>,
19265        St: AsRef<str>,
19266    {
19267        self._scopes
19268            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19269        self
19270    }
19271
19272    /// Removes all scopes, and no default scope will be used either.
19273    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19274    /// for details).
19275    pub fn clear_scopes(mut self) -> ProjectLocationRuntimeResetCall<'a, C> {
19276        self._scopes.clear();
19277        self
19278    }
19279}
19280
19281/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
19282///
19283/// A builder for the *locations.runtimes.setIamPolicy* method supported by a *project* resource.
19284/// It is not used directly, but through a [`ProjectMethods`] instance.
19285///
19286/// # Example
19287///
19288/// Instantiate a resource method builder
19289///
19290/// ```test_harness,no_run
19291/// # extern crate hyper;
19292/// # extern crate hyper_rustls;
19293/// # extern crate google_notebooks1 as notebooks1;
19294/// use notebooks1::api::SetIamPolicyRequest;
19295/// # async fn dox() {
19296/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19297///
19298/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19299/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19300/// #     secret,
19301/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19302/// # ).build().await.unwrap();
19303///
19304/// # let client = hyper_util::client::legacy::Client::builder(
19305/// #     hyper_util::rt::TokioExecutor::new()
19306/// # )
19307/// # .build(
19308/// #     hyper_rustls::HttpsConnectorBuilder::new()
19309/// #         .with_native_roots()
19310/// #         .unwrap()
19311/// #         .https_or_http()
19312/// #         .enable_http1()
19313/// #         .build()
19314/// # );
19315/// # let mut hub = AIPlatformNotebooks::new(client, auth);
19316/// // As the method needs a request, you would usually fill it with the desired information
19317/// // into the respective structure. Some of the parts shown here might not be applicable !
19318/// // Values shown here are possibly random and not representative !
19319/// let mut req = SetIamPolicyRequest::default();
19320///
19321/// // You can configure optional parameters by calling the respective setters at will, and
19322/// // execute the final call using `doit()`.
19323/// // Values shown here are possibly random and not representative !
19324/// let result = hub.projects().locations_runtimes_set_iam_policy(req, "resource")
19325///              .doit().await;
19326/// # }
19327/// ```
19328pub struct ProjectLocationRuntimeSetIamPolicyCall<'a, C>
19329where
19330    C: 'a,
19331{
19332    hub: &'a AIPlatformNotebooks<C>,
19333    _request: SetIamPolicyRequest,
19334    _resource: String,
19335    _delegate: Option<&'a mut dyn common::Delegate>,
19336    _additional_params: HashMap<String, String>,
19337    _scopes: BTreeSet<String>,
19338}
19339
19340impl<'a, C> common::CallBuilder for ProjectLocationRuntimeSetIamPolicyCall<'a, C> {}
19341
19342impl<'a, C> ProjectLocationRuntimeSetIamPolicyCall<'a, C>
19343where
19344    C: common::Connector,
19345{
19346    /// Perform the operation you have build so far.
19347    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
19348        use std::borrow::Cow;
19349        use std::io::{Read, Seek};
19350
19351        use common::{url::Params, ToParts};
19352        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19353
19354        let mut dd = common::DefaultDelegate;
19355        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19356        dlg.begin(common::MethodInfo {
19357            id: "notebooks.projects.locations.runtimes.setIamPolicy",
19358            http_method: hyper::Method::POST,
19359        });
19360
19361        for &field in ["alt", "resource"].iter() {
19362            if self._additional_params.contains_key(field) {
19363                dlg.finished(false);
19364                return Err(common::Error::FieldClash(field));
19365            }
19366        }
19367
19368        let mut params = Params::with_capacity(4 + self._additional_params.len());
19369        params.push("resource", self._resource);
19370
19371        params.extend(self._additional_params.iter());
19372
19373        params.push("alt", "json");
19374        let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
19375        if self._scopes.is_empty() {
19376            self._scopes
19377                .insert(Scope::CloudPlatform.as_ref().to_string());
19378        }
19379
19380        #[allow(clippy::single_element_loop)]
19381        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
19382            url = params.uri_replacement(url, param_name, find_this, true);
19383        }
19384        {
19385            let to_remove = ["resource"];
19386            params.remove_params(&to_remove);
19387        }
19388
19389        let url = params.parse_with_url(&url);
19390
19391        let mut json_mime_type = mime::APPLICATION_JSON;
19392        let mut request_value_reader = {
19393            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19394            common::remove_json_null_values(&mut value);
19395            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19396            serde_json::to_writer(&mut dst, &value).unwrap();
19397            dst
19398        };
19399        let request_size = request_value_reader
19400            .seek(std::io::SeekFrom::End(0))
19401            .unwrap();
19402        request_value_reader
19403            .seek(std::io::SeekFrom::Start(0))
19404            .unwrap();
19405
19406        loop {
19407            let token = match self
19408                .hub
19409                .auth
19410                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19411                .await
19412            {
19413                Ok(token) => token,
19414                Err(e) => match dlg.token(e) {
19415                    Ok(token) => token,
19416                    Err(e) => {
19417                        dlg.finished(false);
19418                        return Err(common::Error::MissingToken(e));
19419                    }
19420                },
19421            };
19422            request_value_reader
19423                .seek(std::io::SeekFrom::Start(0))
19424                .unwrap();
19425            let mut req_result = {
19426                let client = &self.hub.client;
19427                dlg.pre_request();
19428                let mut req_builder = hyper::Request::builder()
19429                    .method(hyper::Method::POST)
19430                    .uri(url.as_str())
19431                    .header(USER_AGENT, self.hub._user_agent.clone());
19432
19433                if let Some(token) = token.as_ref() {
19434                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19435                }
19436
19437                let request = req_builder
19438                    .header(CONTENT_TYPE, json_mime_type.to_string())
19439                    .header(CONTENT_LENGTH, request_size as u64)
19440                    .body(common::to_body(
19441                        request_value_reader.get_ref().clone().into(),
19442                    ));
19443
19444                client.request(request.unwrap()).await
19445            };
19446
19447            match req_result {
19448                Err(err) => {
19449                    if let common::Retry::After(d) = dlg.http_error(&err) {
19450                        sleep(d).await;
19451                        continue;
19452                    }
19453                    dlg.finished(false);
19454                    return Err(common::Error::HttpError(err));
19455                }
19456                Ok(res) => {
19457                    let (mut parts, body) = res.into_parts();
19458                    let mut body = common::Body::new(body);
19459                    if !parts.status.is_success() {
19460                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19461                        let error = serde_json::from_str(&common::to_string(&bytes));
19462                        let response = common::to_response(parts, bytes.into());
19463
19464                        if let common::Retry::After(d) =
19465                            dlg.http_failure(&response, error.as_ref().ok())
19466                        {
19467                            sleep(d).await;
19468                            continue;
19469                        }
19470
19471                        dlg.finished(false);
19472
19473                        return Err(match error {
19474                            Ok(value) => common::Error::BadRequest(value),
19475                            _ => common::Error::Failure(response),
19476                        });
19477                    }
19478                    let response = {
19479                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19480                        let encoded = common::to_string(&bytes);
19481                        match serde_json::from_str(&encoded) {
19482                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19483                            Err(error) => {
19484                                dlg.response_json_decode_error(&encoded, &error);
19485                                return Err(common::Error::JsonDecodeError(
19486                                    encoded.to_string(),
19487                                    error,
19488                                ));
19489                            }
19490                        }
19491                    };
19492
19493                    dlg.finished(true);
19494                    return Ok(response);
19495                }
19496            }
19497        }
19498    }
19499
19500    ///
19501    /// Sets the *request* property to the given value.
19502    ///
19503    /// Even though the property as already been set when instantiating this call,
19504    /// we provide this method for API completeness.
19505    pub fn request(
19506        mut self,
19507        new_value: SetIamPolicyRequest,
19508    ) -> ProjectLocationRuntimeSetIamPolicyCall<'a, C> {
19509        self._request = new_value;
19510        self
19511    }
19512    /// 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.
19513    ///
19514    /// Sets the *resource* path property to the given value.
19515    ///
19516    /// Even though the property as already been set when instantiating this call,
19517    /// we provide this method for API completeness.
19518    pub fn resource(mut self, new_value: &str) -> ProjectLocationRuntimeSetIamPolicyCall<'a, C> {
19519        self._resource = new_value.to_string();
19520        self
19521    }
19522    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19523    /// while executing the actual API request.
19524    ///
19525    /// ````text
19526    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19527    /// ````
19528    ///
19529    /// Sets the *delegate* property to the given value.
19530    pub fn delegate(
19531        mut self,
19532        new_value: &'a mut dyn common::Delegate,
19533    ) -> ProjectLocationRuntimeSetIamPolicyCall<'a, C> {
19534        self._delegate = Some(new_value);
19535        self
19536    }
19537
19538    /// Set any additional parameter of the query string used in the request.
19539    /// It should be used to set parameters which are not yet available through their own
19540    /// setters.
19541    ///
19542    /// Please note that this method must not be used to set any of the known parameters
19543    /// which have their own setter method. If done anyway, the request will fail.
19544    ///
19545    /// # Additional Parameters
19546    ///
19547    /// * *$.xgafv* (query-string) - V1 error format.
19548    /// * *access_token* (query-string) - OAuth access token.
19549    /// * *alt* (query-string) - Data format for response.
19550    /// * *callback* (query-string) - JSONP
19551    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19552    /// * *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.
19553    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19554    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19555    /// * *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.
19556    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19557    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19558    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRuntimeSetIamPolicyCall<'a, C>
19559    where
19560        T: AsRef<str>,
19561    {
19562        self._additional_params
19563            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19564        self
19565    }
19566
19567    /// Identifies the authorization scope for the method you are building.
19568    ///
19569    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19570    /// [`Scope::CloudPlatform`].
19571    ///
19572    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19573    /// tokens for more than one scope.
19574    ///
19575    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19576    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19577    /// sufficient, a read-write scope will do as well.
19578    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRuntimeSetIamPolicyCall<'a, C>
19579    where
19580        St: AsRef<str>,
19581    {
19582        self._scopes.insert(String::from(scope.as_ref()));
19583        self
19584    }
19585    /// Identifies the authorization scope(s) for the method you are building.
19586    ///
19587    /// See [`Self::add_scope()`] for details.
19588    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRuntimeSetIamPolicyCall<'a, C>
19589    where
19590        I: IntoIterator<Item = St>,
19591        St: AsRef<str>,
19592    {
19593        self._scopes
19594            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19595        self
19596    }
19597
19598    /// Removes all scopes, and no default scope will be used either.
19599    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19600    /// for details).
19601    pub fn clear_scopes(mut self) -> ProjectLocationRuntimeSetIamPolicyCall<'a, C> {
19602        self._scopes.clear();
19603        self
19604    }
19605}
19606
19607/// 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
19608///
19609/// A builder for the *locations.runtimes.start* method supported by a *project* resource.
19610/// It is not used directly, but through a [`ProjectMethods`] instance.
19611///
19612/// # Example
19613///
19614/// Instantiate a resource method builder
19615///
19616/// ```test_harness,no_run
19617/// # extern crate hyper;
19618/// # extern crate hyper_rustls;
19619/// # extern crate google_notebooks1 as notebooks1;
19620/// use notebooks1::api::StartRuntimeRequest;
19621/// # async fn dox() {
19622/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19623///
19624/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19625/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19626/// #     secret,
19627/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19628/// # ).build().await.unwrap();
19629///
19630/// # let client = hyper_util::client::legacy::Client::builder(
19631/// #     hyper_util::rt::TokioExecutor::new()
19632/// # )
19633/// # .build(
19634/// #     hyper_rustls::HttpsConnectorBuilder::new()
19635/// #         .with_native_roots()
19636/// #         .unwrap()
19637/// #         .https_or_http()
19638/// #         .enable_http1()
19639/// #         .build()
19640/// # );
19641/// # let mut hub = AIPlatformNotebooks::new(client, auth);
19642/// // As the method needs a request, you would usually fill it with the desired information
19643/// // into the respective structure. Some of the parts shown here might not be applicable !
19644/// // Values shown here are possibly random and not representative !
19645/// let mut req = StartRuntimeRequest::default();
19646///
19647/// // You can configure optional parameters by calling the respective setters at will, and
19648/// // execute the final call using `doit()`.
19649/// // Values shown here are possibly random and not representative !
19650/// let result = hub.projects().locations_runtimes_start(req, "name")
19651///              .doit().await;
19652/// # }
19653/// ```
19654pub struct ProjectLocationRuntimeStartCall<'a, C>
19655where
19656    C: 'a,
19657{
19658    hub: &'a AIPlatformNotebooks<C>,
19659    _request: StartRuntimeRequest,
19660    _name: String,
19661    _delegate: Option<&'a mut dyn common::Delegate>,
19662    _additional_params: HashMap<String, String>,
19663    _scopes: BTreeSet<String>,
19664}
19665
19666impl<'a, C> common::CallBuilder for ProjectLocationRuntimeStartCall<'a, C> {}
19667
19668impl<'a, C> ProjectLocationRuntimeStartCall<'a, C>
19669where
19670    C: common::Connector,
19671{
19672    /// Perform the operation you have build so far.
19673    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
19674        use std::borrow::Cow;
19675        use std::io::{Read, Seek};
19676
19677        use common::{url::Params, ToParts};
19678        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19679
19680        let mut dd = common::DefaultDelegate;
19681        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19682        dlg.begin(common::MethodInfo {
19683            id: "notebooks.projects.locations.runtimes.start",
19684            http_method: hyper::Method::POST,
19685        });
19686
19687        for &field in ["alt", "name"].iter() {
19688            if self._additional_params.contains_key(field) {
19689                dlg.finished(false);
19690                return Err(common::Error::FieldClash(field));
19691            }
19692        }
19693
19694        let mut params = Params::with_capacity(4 + self._additional_params.len());
19695        params.push("name", self._name);
19696
19697        params.extend(self._additional_params.iter());
19698
19699        params.push("alt", "json");
19700        let mut url = self.hub._base_url.clone() + "v1/{+name}:start";
19701        if self._scopes.is_empty() {
19702            self._scopes
19703                .insert(Scope::CloudPlatform.as_ref().to_string());
19704        }
19705
19706        #[allow(clippy::single_element_loop)]
19707        for &(find_this, param_name) in [("{+name}", "name")].iter() {
19708            url = params.uri_replacement(url, param_name, find_this, true);
19709        }
19710        {
19711            let to_remove = ["name"];
19712            params.remove_params(&to_remove);
19713        }
19714
19715        let url = params.parse_with_url(&url);
19716
19717        let mut json_mime_type = mime::APPLICATION_JSON;
19718        let mut request_value_reader = {
19719            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19720            common::remove_json_null_values(&mut value);
19721            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19722            serde_json::to_writer(&mut dst, &value).unwrap();
19723            dst
19724        };
19725        let request_size = request_value_reader
19726            .seek(std::io::SeekFrom::End(0))
19727            .unwrap();
19728        request_value_reader
19729            .seek(std::io::SeekFrom::Start(0))
19730            .unwrap();
19731
19732        loop {
19733            let token = match self
19734                .hub
19735                .auth
19736                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19737                .await
19738            {
19739                Ok(token) => token,
19740                Err(e) => match dlg.token(e) {
19741                    Ok(token) => token,
19742                    Err(e) => {
19743                        dlg.finished(false);
19744                        return Err(common::Error::MissingToken(e));
19745                    }
19746                },
19747            };
19748            request_value_reader
19749                .seek(std::io::SeekFrom::Start(0))
19750                .unwrap();
19751            let mut req_result = {
19752                let client = &self.hub.client;
19753                dlg.pre_request();
19754                let mut req_builder = hyper::Request::builder()
19755                    .method(hyper::Method::POST)
19756                    .uri(url.as_str())
19757                    .header(USER_AGENT, self.hub._user_agent.clone());
19758
19759                if let Some(token) = token.as_ref() {
19760                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19761                }
19762
19763                let request = req_builder
19764                    .header(CONTENT_TYPE, json_mime_type.to_string())
19765                    .header(CONTENT_LENGTH, request_size as u64)
19766                    .body(common::to_body(
19767                        request_value_reader.get_ref().clone().into(),
19768                    ));
19769
19770                client.request(request.unwrap()).await
19771            };
19772
19773            match req_result {
19774                Err(err) => {
19775                    if let common::Retry::After(d) = dlg.http_error(&err) {
19776                        sleep(d).await;
19777                        continue;
19778                    }
19779                    dlg.finished(false);
19780                    return Err(common::Error::HttpError(err));
19781                }
19782                Ok(res) => {
19783                    let (mut parts, body) = res.into_parts();
19784                    let mut body = common::Body::new(body);
19785                    if !parts.status.is_success() {
19786                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19787                        let error = serde_json::from_str(&common::to_string(&bytes));
19788                        let response = common::to_response(parts, bytes.into());
19789
19790                        if let common::Retry::After(d) =
19791                            dlg.http_failure(&response, error.as_ref().ok())
19792                        {
19793                            sleep(d).await;
19794                            continue;
19795                        }
19796
19797                        dlg.finished(false);
19798
19799                        return Err(match error {
19800                            Ok(value) => common::Error::BadRequest(value),
19801                            _ => common::Error::Failure(response),
19802                        });
19803                    }
19804                    let response = {
19805                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19806                        let encoded = common::to_string(&bytes);
19807                        match serde_json::from_str(&encoded) {
19808                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19809                            Err(error) => {
19810                                dlg.response_json_decode_error(&encoded, &error);
19811                                return Err(common::Error::JsonDecodeError(
19812                                    encoded.to_string(),
19813                                    error,
19814                                ));
19815                            }
19816                        }
19817                    };
19818
19819                    dlg.finished(true);
19820                    return Ok(response);
19821                }
19822            }
19823        }
19824    }
19825
19826    ///
19827    /// Sets the *request* property to the given value.
19828    ///
19829    /// Even though the property as already been set when instantiating this call,
19830    /// we provide this method for API completeness.
19831    pub fn request(
19832        mut self,
19833        new_value: StartRuntimeRequest,
19834    ) -> ProjectLocationRuntimeStartCall<'a, C> {
19835        self._request = new_value;
19836        self
19837    }
19838    /// Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
19839    ///
19840    /// Sets the *name* path property to the given value.
19841    ///
19842    /// Even though the property as already been set when instantiating this call,
19843    /// we provide this method for API completeness.
19844    pub fn name(mut self, new_value: &str) -> ProjectLocationRuntimeStartCall<'a, C> {
19845        self._name = new_value.to_string();
19846        self
19847    }
19848    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19849    /// while executing the actual API request.
19850    ///
19851    /// ````text
19852    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19853    /// ````
19854    ///
19855    /// Sets the *delegate* property to the given value.
19856    pub fn delegate(
19857        mut self,
19858        new_value: &'a mut dyn common::Delegate,
19859    ) -> ProjectLocationRuntimeStartCall<'a, C> {
19860        self._delegate = Some(new_value);
19861        self
19862    }
19863
19864    /// Set any additional parameter of the query string used in the request.
19865    /// It should be used to set parameters which are not yet available through their own
19866    /// setters.
19867    ///
19868    /// Please note that this method must not be used to set any of the known parameters
19869    /// which have their own setter method. If done anyway, the request will fail.
19870    ///
19871    /// # Additional Parameters
19872    ///
19873    /// * *$.xgafv* (query-string) - V1 error format.
19874    /// * *access_token* (query-string) - OAuth access token.
19875    /// * *alt* (query-string) - Data format for response.
19876    /// * *callback* (query-string) - JSONP
19877    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19878    /// * *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.
19879    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19880    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19881    /// * *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.
19882    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19883    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19884    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRuntimeStartCall<'a, C>
19885    where
19886        T: AsRef<str>,
19887    {
19888        self._additional_params
19889            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19890        self
19891    }
19892
19893    /// Identifies the authorization scope for the method you are building.
19894    ///
19895    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19896    /// [`Scope::CloudPlatform`].
19897    ///
19898    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19899    /// tokens for more than one scope.
19900    ///
19901    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19902    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19903    /// sufficient, a read-write scope will do as well.
19904    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRuntimeStartCall<'a, C>
19905    where
19906        St: AsRef<str>,
19907    {
19908        self._scopes.insert(String::from(scope.as_ref()));
19909        self
19910    }
19911    /// Identifies the authorization scope(s) for the method you are building.
19912    ///
19913    /// See [`Self::add_scope()`] for details.
19914    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRuntimeStartCall<'a, C>
19915    where
19916        I: IntoIterator<Item = St>,
19917        St: AsRef<str>,
19918    {
19919        self._scopes
19920            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19921        self
19922    }
19923
19924    /// Removes all scopes, and no default scope will be used either.
19925    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19926    /// for details).
19927    pub fn clear_scopes(mut self) -> ProjectLocationRuntimeStartCall<'a, C> {
19928        self._scopes.clear();
19929        self
19930    }
19931}
19932
19933/// 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
19934///
19935/// A builder for the *locations.runtimes.stop* method supported by a *project* resource.
19936/// It is not used directly, but through a [`ProjectMethods`] instance.
19937///
19938/// # Example
19939///
19940/// Instantiate a resource method builder
19941///
19942/// ```test_harness,no_run
19943/// # extern crate hyper;
19944/// # extern crate hyper_rustls;
19945/// # extern crate google_notebooks1 as notebooks1;
19946/// use notebooks1::api::StopRuntimeRequest;
19947/// # async fn dox() {
19948/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19949///
19950/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19951/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19952/// #     secret,
19953/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19954/// # ).build().await.unwrap();
19955///
19956/// # let client = hyper_util::client::legacy::Client::builder(
19957/// #     hyper_util::rt::TokioExecutor::new()
19958/// # )
19959/// # .build(
19960/// #     hyper_rustls::HttpsConnectorBuilder::new()
19961/// #         .with_native_roots()
19962/// #         .unwrap()
19963/// #         .https_or_http()
19964/// #         .enable_http1()
19965/// #         .build()
19966/// # );
19967/// # let mut hub = AIPlatformNotebooks::new(client, auth);
19968/// // As the method needs a request, you would usually fill it with the desired information
19969/// // into the respective structure. Some of the parts shown here might not be applicable !
19970/// // Values shown here are possibly random and not representative !
19971/// let mut req = StopRuntimeRequest::default();
19972///
19973/// // You can configure optional parameters by calling the respective setters at will, and
19974/// // execute the final call using `doit()`.
19975/// // Values shown here are possibly random and not representative !
19976/// let result = hub.projects().locations_runtimes_stop(req, "name")
19977///              .doit().await;
19978/// # }
19979/// ```
19980pub struct ProjectLocationRuntimeStopCall<'a, C>
19981where
19982    C: 'a,
19983{
19984    hub: &'a AIPlatformNotebooks<C>,
19985    _request: StopRuntimeRequest,
19986    _name: String,
19987    _delegate: Option<&'a mut dyn common::Delegate>,
19988    _additional_params: HashMap<String, String>,
19989    _scopes: BTreeSet<String>,
19990}
19991
19992impl<'a, C> common::CallBuilder for ProjectLocationRuntimeStopCall<'a, C> {}
19993
19994impl<'a, C> ProjectLocationRuntimeStopCall<'a, C>
19995where
19996    C: common::Connector,
19997{
19998    /// Perform the operation you have build so far.
19999    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
20000        use std::borrow::Cow;
20001        use std::io::{Read, Seek};
20002
20003        use common::{url::Params, ToParts};
20004        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20005
20006        let mut dd = common::DefaultDelegate;
20007        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20008        dlg.begin(common::MethodInfo {
20009            id: "notebooks.projects.locations.runtimes.stop",
20010            http_method: hyper::Method::POST,
20011        });
20012
20013        for &field in ["alt", "name"].iter() {
20014            if self._additional_params.contains_key(field) {
20015                dlg.finished(false);
20016                return Err(common::Error::FieldClash(field));
20017            }
20018        }
20019
20020        let mut params = Params::with_capacity(4 + self._additional_params.len());
20021        params.push("name", self._name);
20022
20023        params.extend(self._additional_params.iter());
20024
20025        params.push("alt", "json");
20026        let mut url = self.hub._base_url.clone() + "v1/{+name}:stop";
20027        if self._scopes.is_empty() {
20028            self._scopes
20029                .insert(Scope::CloudPlatform.as_ref().to_string());
20030        }
20031
20032        #[allow(clippy::single_element_loop)]
20033        for &(find_this, param_name) in [("{+name}", "name")].iter() {
20034            url = params.uri_replacement(url, param_name, find_this, true);
20035        }
20036        {
20037            let to_remove = ["name"];
20038            params.remove_params(&to_remove);
20039        }
20040
20041        let url = params.parse_with_url(&url);
20042
20043        let mut json_mime_type = mime::APPLICATION_JSON;
20044        let mut request_value_reader = {
20045            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20046            common::remove_json_null_values(&mut value);
20047            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20048            serde_json::to_writer(&mut dst, &value).unwrap();
20049            dst
20050        };
20051        let request_size = request_value_reader
20052            .seek(std::io::SeekFrom::End(0))
20053            .unwrap();
20054        request_value_reader
20055            .seek(std::io::SeekFrom::Start(0))
20056            .unwrap();
20057
20058        loop {
20059            let token = match self
20060                .hub
20061                .auth
20062                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20063                .await
20064            {
20065                Ok(token) => token,
20066                Err(e) => match dlg.token(e) {
20067                    Ok(token) => token,
20068                    Err(e) => {
20069                        dlg.finished(false);
20070                        return Err(common::Error::MissingToken(e));
20071                    }
20072                },
20073            };
20074            request_value_reader
20075                .seek(std::io::SeekFrom::Start(0))
20076                .unwrap();
20077            let mut req_result = {
20078                let client = &self.hub.client;
20079                dlg.pre_request();
20080                let mut req_builder = hyper::Request::builder()
20081                    .method(hyper::Method::POST)
20082                    .uri(url.as_str())
20083                    .header(USER_AGENT, self.hub._user_agent.clone());
20084
20085                if let Some(token) = token.as_ref() {
20086                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20087                }
20088
20089                let request = req_builder
20090                    .header(CONTENT_TYPE, json_mime_type.to_string())
20091                    .header(CONTENT_LENGTH, request_size as u64)
20092                    .body(common::to_body(
20093                        request_value_reader.get_ref().clone().into(),
20094                    ));
20095
20096                client.request(request.unwrap()).await
20097            };
20098
20099            match req_result {
20100                Err(err) => {
20101                    if let common::Retry::After(d) = dlg.http_error(&err) {
20102                        sleep(d).await;
20103                        continue;
20104                    }
20105                    dlg.finished(false);
20106                    return Err(common::Error::HttpError(err));
20107                }
20108                Ok(res) => {
20109                    let (mut parts, body) = res.into_parts();
20110                    let mut body = common::Body::new(body);
20111                    if !parts.status.is_success() {
20112                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20113                        let error = serde_json::from_str(&common::to_string(&bytes));
20114                        let response = common::to_response(parts, bytes.into());
20115
20116                        if let common::Retry::After(d) =
20117                            dlg.http_failure(&response, error.as_ref().ok())
20118                        {
20119                            sleep(d).await;
20120                            continue;
20121                        }
20122
20123                        dlg.finished(false);
20124
20125                        return Err(match error {
20126                            Ok(value) => common::Error::BadRequest(value),
20127                            _ => common::Error::Failure(response),
20128                        });
20129                    }
20130                    let response = {
20131                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20132                        let encoded = common::to_string(&bytes);
20133                        match serde_json::from_str(&encoded) {
20134                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20135                            Err(error) => {
20136                                dlg.response_json_decode_error(&encoded, &error);
20137                                return Err(common::Error::JsonDecodeError(
20138                                    encoded.to_string(),
20139                                    error,
20140                                ));
20141                            }
20142                        }
20143                    };
20144
20145                    dlg.finished(true);
20146                    return Ok(response);
20147                }
20148            }
20149        }
20150    }
20151
20152    ///
20153    /// Sets the *request* property to the given value.
20154    ///
20155    /// Even though the property as already been set when instantiating this call,
20156    /// we provide this method for API completeness.
20157    pub fn request(
20158        mut self,
20159        new_value: StopRuntimeRequest,
20160    ) -> ProjectLocationRuntimeStopCall<'a, C> {
20161        self._request = new_value;
20162        self
20163    }
20164    /// Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
20165    ///
20166    /// Sets the *name* path property to the given value.
20167    ///
20168    /// Even though the property as already been set when instantiating this call,
20169    /// we provide this method for API completeness.
20170    pub fn name(mut self, new_value: &str) -> ProjectLocationRuntimeStopCall<'a, C> {
20171        self._name = new_value.to_string();
20172        self
20173    }
20174    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20175    /// while executing the actual API request.
20176    ///
20177    /// ````text
20178    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20179    /// ````
20180    ///
20181    /// Sets the *delegate* property to the given value.
20182    pub fn delegate(
20183        mut self,
20184        new_value: &'a mut dyn common::Delegate,
20185    ) -> ProjectLocationRuntimeStopCall<'a, C> {
20186        self._delegate = Some(new_value);
20187        self
20188    }
20189
20190    /// Set any additional parameter of the query string used in the request.
20191    /// It should be used to set parameters which are not yet available through their own
20192    /// setters.
20193    ///
20194    /// Please note that this method must not be used to set any of the known parameters
20195    /// which have their own setter method. If done anyway, the request will fail.
20196    ///
20197    /// # Additional Parameters
20198    ///
20199    /// * *$.xgafv* (query-string) - V1 error format.
20200    /// * *access_token* (query-string) - OAuth access token.
20201    /// * *alt* (query-string) - Data format for response.
20202    /// * *callback* (query-string) - JSONP
20203    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20204    /// * *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.
20205    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20206    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20207    /// * *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.
20208    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20209    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20210    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRuntimeStopCall<'a, C>
20211    where
20212        T: AsRef<str>,
20213    {
20214        self._additional_params
20215            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20216        self
20217    }
20218
20219    /// Identifies the authorization scope for the method you are building.
20220    ///
20221    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20222    /// [`Scope::CloudPlatform`].
20223    ///
20224    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20225    /// tokens for more than one scope.
20226    ///
20227    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20228    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20229    /// sufficient, a read-write scope will do as well.
20230    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRuntimeStopCall<'a, C>
20231    where
20232        St: AsRef<str>,
20233    {
20234        self._scopes.insert(String::from(scope.as_ref()));
20235        self
20236    }
20237    /// Identifies the authorization scope(s) for the method you are building.
20238    ///
20239    /// See [`Self::add_scope()`] for details.
20240    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRuntimeStopCall<'a, C>
20241    where
20242        I: IntoIterator<Item = St>,
20243        St: AsRef<str>,
20244    {
20245        self._scopes
20246            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20247        self
20248    }
20249
20250    /// Removes all scopes, and no default scope will be used either.
20251    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20252    /// for details).
20253    pub fn clear_scopes(mut self) -> ProjectLocationRuntimeStopCall<'a, C> {
20254        self._scopes.clear();
20255        self
20256    }
20257}
20258
20259/// Switch a Managed Notebook Runtime.
20260///
20261/// A builder for the *locations.runtimes.switch* method supported by a *project* resource.
20262/// It is not used directly, but through a [`ProjectMethods`] instance.
20263///
20264/// # Example
20265///
20266/// Instantiate a resource method builder
20267///
20268/// ```test_harness,no_run
20269/// # extern crate hyper;
20270/// # extern crate hyper_rustls;
20271/// # extern crate google_notebooks1 as notebooks1;
20272/// use notebooks1::api::SwitchRuntimeRequest;
20273/// # async fn dox() {
20274/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20275///
20276/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20277/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
20278/// #     secret,
20279/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20280/// # ).build().await.unwrap();
20281///
20282/// # let client = hyper_util::client::legacy::Client::builder(
20283/// #     hyper_util::rt::TokioExecutor::new()
20284/// # )
20285/// # .build(
20286/// #     hyper_rustls::HttpsConnectorBuilder::new()
20287/// #         .with_native_roots()
20288/// #         .unwrap()
20289/// #         .https_or_http()
20290/// #         .enable_http1()
20291/// #         .build()
20292/// # );
20293/// # let mut hub = AIPlatformNotebooks::new(client, auth);
20294/// // As the method needs a request, you would usually fill it with the desired information
20295/// // into the respective structure. Some of the parts shown here might not be applicable !
20296/// // Values shown here are possibly random and not representative !
20297/// let mut req = SwitchRuntimeRequest::default();
20298///
20299/// // You can configure optional parameters by calling the respective setters at will, and
20300/// // execute the final call using `doit()`.
20301/// // Values shown here are possibly random and not representative !
20302/// let result = hub.projects().locations_runtimes_switch(req, "name")
20303///              .doit().await;
20304/// # }
20305/// ```
20306pub struct ProjectLocationRuntimeSwitchCall<'a, C>
20307where
20308    C: 'a,
20309{
20310    hub: &'a AIPlatformNotebooks<C>,
20311    _request: SwitchRuntimeRequest,
20312    _name: String,
20313    _delegate: Option<&'a mut dyn common::Delegate>,
20314    _additional_params: HashMap<String, String>,
20315    _scopes: BTreeSet<String>,
20316}
20317
20318impl<'a, C> common::CallBuilder for ProjectLocationRuntimeSwitchCall<'a, C> {}
20319
20320impl<'a, C> ProjectLocationRuntimeSwitchCall<'a, C>
20321where
20322    C: common::Connector,
20323{
20324    /// Perform the operation you have build so far.
20325    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
20326        use std::borrow::Cow;
20327        use std::io::{Read, Seek};
20328
20329        use common::{url::Params, ToParts};
20330        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20331
20332        let mut dd = common::DefaultDelegate;
20333        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20334        dlg.begin(common::MethodInfo {
20335            id: "notebooks.projects.locations.runtimes.switch",
20336            http_method: hyper::Method::POST,
20337        });
20338
20339        for &field in ["alt", "name"].iter() {
20340            if self._additional_params.contains_key(field) {
20341                dlg.finished(false);
20342                return Err(common::Error::FieldClash(field));
20343            }
20344        }
20345
20346        let mut params = Params::with_capacity(4 + self._additional_params.len());
20347        params.push("name", self._name);
20348
20349        params.extend(self._additional_params.iter());
20350
20351        params.push("alt", "json");
20352        let mut url = self.hub._base_url.clone() + "v1/{+name}:switch";
20353        if self._scopes.is_empty() {
20354            self._scopes
20355                .insert(Scope::CloudPlatform.as_ref().to_string());
20356        }
20357
20358        #[allow(clippy::single_element_loop)]
20359        for &(find_this, param_name) in [("{+name}", "name")].iter() {
20360            url = params.uri_replacement(url, param_name, find_this, true);
20361        }
20362        {
20363            let to_remove = ["name"];
20364            params.remove_params(&to_remove);
20365        }
20366
20367        let url = params.parse_with_url(&url);
20368
20369        let mut json_mime_type = mime::APPLICATION_JSON;
20370        let mut request_value_reader = {
20371            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20372            common::remove_json_null_values(&mut value);
20373            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20374            serde_json::to_writer(&mut dst, &value).unwrap();
20375            dst
20376        };
20377        let request_size = request_value_reader
20378            .seek(std::io::SeekFrom::End(0))
20379            .unwrap();
20380        request_value_reader
20381            .seek(std::io::SeekFrom::Start(0))
20382            .unwrap();
20383
20384        loop {
20385            let token = match self
20386                .hub
20387                .auth
20388                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20389                .await
20390            {
20391                Ok(token) => token,
20392                Err(e) => match dlg.token(e) {
20393                    Ok(token) => token,
20394                    Err(e) => {
20395                        dlg.finished(false);
20396                        return Err(common::Error::MissingToken(e));
20397                    }
20398                },
20399            };
20400            request_value_reader
20401                .seek(std::io::SeekFrom::Start(0))
20402                .unwrap();
20403            let mut req_result = {
20404                let client = &self.hub.client;
20405                dlg.pre_request();
20406                let mut req_builder = hyper::Request::builder()
20407                    .method(hyper::Method::POST)
20408                    .uri(url.as_str())
20409                    .header(USER_AGENT, self.hub._user_agent.clone());
20410
20411                if let Some(token) = token.as_ref() {
20412                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20413                }
20414
20415                let request = req_builder
20416                    .header(CONTENT_TYPE, json_mime_type.to_string())
20417                    .header(CONTENT_LENGTH, request_size as u64)
20418                    .body(common::to_body(
20419                        request_value_reader.get_ref().clone().into(),
20420                    ));
20421
20422                client.request(request.unwrap()).await
20423            };
20424
20425            match req_result {
20426                Err(err) => {
20427                    if let common::Retry::After(d) = dlg.http_error(&err) {
20428                        sleep(d).await;
20429                        continue;
20430                    }
20431                    dlg.finished(false);
20432                    return Err(common::Error::HttpError(err));
20433                }
20434                Ok(res) => {
20435                    let (mut parts, body) = res.into_parts();
20436                    let mut body = common::Body::new(body);
20437                    if !parts.status.is_success() {
20438                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20439                        let error = serde_json::from_str(&common::to_string(&bytes));
20440                        let response = common::to_response(parts, bytes.into());
20441
20442                        if let common::Retry::After(d) =
20443                            dlg.http_failure(&response, error.as_ref().ok())
20444                        {
20445                            sleep(d).await;
20446                            continue;
20447                        }
20448
20449                        dlg.finished(false);
20450
20451                        return Err(match error {
20452                            Ok(value) => common::Error::BadRequest(value),
20453                            _ => common::Error::Failure(response),
20454                        });
20455                    }
20456                    let response = {
20457                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20458                        let encoded = common::to_string(&bytes);
20459                        match serde_json::from_str(&encoded) {
20460                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20461                            Err(error) => {
20462                                dlg.response_json_decode_error(&encoded, &error);
20463                                return Err(common::Error::JsonDecodeError(
20464                                    encoded.to_string(),
20465                                    error,
20466                                ));
20467                            }
20468                        }
20469                    };
20470
20471                    dlg.finished(true);
20472                    return Ok(response);
20473                }
20474            }
20475        }
20476    }
20477
20478    ///
20479    /// Sets the *request* property to the given value.
20480    ///
20481    /// Even though the property as already been set when instantiating this call,
20482    /// we provide this method for API completeness.
20483    pub fn request(
20484        mut self,
20485        new_value: SwitchRuntimeRequest,
20486    ) -> ProjectLocationRuntimeSwitchCall<'a, C> {
20487        self._request = new_value;
20488        self
20489    }
20490    /// Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
20491    ///
20492    /// Sets the *name* path property to the given value.
20493    ///
20494    /// Even though the property as already been set when instantiating this call,
20495    /// we provide this method for API completeness.
20496    pub fn name(mut self, new_value: &str) -> ProjectLocationRuntimeSwitchCall<'a, C> {
20497        self._name = new_value.to_string();
20498        self
20499    }
20500    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20501    /// while executing the actual API request.
20502    ///
20503    /// ````text
20504    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20505    /// ````
20506    ///
20507    /// Sets the *delegate* property to the given value.
20508    pub fn delegate(
20509        mut self,
20510        new_value: &'a mut dyn common::Delegate,
20511    ) -> ProjectLocationRuntimeSwitchCall<'a, C> {
20512        self._delegate = Some(new_value);
20513        self
20514    }
20515
20516    /// Set any additional parameter of the query string used in the request.
20517    /// It should be used to set parameters which are not yet available through their own
20518    /// setters.
20519    ///
20520    /// Please note that this method must not be used to set any of the known parameters
20521    /// which have their own setter method. If done anyway, the request will fail.
20522    ///
20523    /// # Additional Parameters
20524    ///
20525    /// * *$.xgafv* (query-string) - V1 error format.
20526    /// * *access_token* (query-string) - OAuth access token.
20527    /// * *alt* (query-string) - Data format for response.
20528    /// * *callback* (query-string) - JSONP
20529    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20530    /// * *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.
20531    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20532    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20533    /// * *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.
20534    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20535    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20536    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRuntimeSwitchCall<'a, C>
20537    where
20538        T: AsRef<str>,
20539    {
20540        self._additional_params
20541            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20542        self
20543    }
20544
20545    /// Identifies the authorization scope for the method you are building.
20546    ///
20547    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20548    /// [`Scope::CloudPlatform`].
20549    ///
20550    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20551    /// tokens for more than one scope.
20552    ///
20553    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20554    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20555    /// sufficient, a read-write scope will do as well.
20556    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRuntimeSwitchCall<'a, C>
20557    where
20558        St: AsRef<str>,
20559    {
20560        self._scopes.insert(String::from(scope.as_ref()));
20561        self
20562    }
20563    /// Identifies the authorization scope(s) for the method you are building.
20564    ///
20565    /// See [`Self::add_scope()`] for details.
20566    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRuntimeSwitchCall<'a, C>
20567    where
20568        I: IntoIterator<Item = St>,
20569        St: AsRef<str>,
20570    {
20571        self._scopes
20572            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20573        self
20574    }
20575
20576    /// Removes all scopes, and no default scope will be used either.
20577    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20578    /// for details).
20579    pub fn clear_scopes(mut self) -> ProjectLocationRuntimeSwitchCall<'a, C> {
20580        self._scopes.clear();
20581        self
20582    }
20583}
20584
20585/// 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.
20586///
20587/// A builder for the *locations.runtimes.testIamPermissions* method supported by a *project* resource.
20588/// It is not used directly, but through a [`ProjectMethods`] instance.
20589///
20590/// # Example
20591///
20592/// Instantiate a resource method builder
20593///
20594/// ```test_harness,no_run
20595/// # extern crate hyper;
20596/// # extern crate hyper_rustls;
20597/// # extern crate google_notebooks1 as notebooks1;
20598/// use notebooks1::api::TestIamPermissionsRequest;
20599/// # async fn dox() {
20600/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20601///
20602/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20603/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
20604/// #     secret,
20605/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20606/// # ).build().await.unwrap();
20607///
20608/// # let client = hyper_util::client::legacy::Client::builder(
20609/// #     hyper_util::rt::TokioExecutor::new()
20610/// # )
20611/// # .build(
20612/// #     hyper_rustls::HttpsConnectorBuilder::new()
20613/// #         .with_native_roots()
20614/// #         .unwrap()
20615/// #         .https_or_http()
20616/// #         .enable_http1()
20617/// #         .build()
20618/// # );
20619/// # let mut hub = AIPlatformNotebooks::new(client, auth);
20620/// // As the method needs a request, you would usually fill it with the desired information
20621/// // into the respective structure. Some of the parts shown here might not be applicable !
20622/// // Values shown here are possibly random and not representative !
20623/// let mut req = TestIamPermissionsRequest::default();
20624///
20625/// // You can configure optional parameters by calling the respective setters at will, and
20626/// // execute the final call using `doit()`.
20627/// // Values shown here are possibly random and not representative !
20628/// let result = hub.projects().locations_runtimes_test_iam_permissions(req, "resource")
20629///              .doit().await;
20630/// # }
20631/// ```
20632pub struct ProjectLocationRuntimeTestIamPermissionCall<'a, C>
20633where
20634    C: 'a,
20635{
20636    hub: &'a AIPlatformNotebooks<C>,
20637    _request: TestIamPermissionsRequest,
20638    _resource: String,
20639    _delegate: Option<&'a mut dyn common::Delegate>,
20640    _additional_params: HashMap<String, String>,
20641    _scopes: BTreeSet<String>,
20642}
20643
20644impl<'a, C> common::CallBuilder for ProjectLocationRuntimeTestIamPermissionCall<'a, C> {}
20645
20646impl<'a, C> ProjectLocationRuntimeTestIamPermissionCall<'a, C>
20647where
20648    C: common::Connector,
20649{
20650    /// Perform the operation you have build so far.
20651    pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
20652        use std::borrow::Cow;
20653        use std::io::{Read, Seek};
20654
20655        use common::{url::Params, ToParts};
20656        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20657
20658        let mut dd = common::DefaultDelegate;
20659        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20660        dlg.begin(common::MethodInfo {
20661            id: "notebooks.projects.locations.runtimes.testIamPermissions",
20662            http_method: hyper::Method::POST,
20663        });
20664
20665        for &field in ["alt", "resource"].iter() {
20666            if self._additional_params.contains_key(field) {
20667                dlg.finished(false);
20668                return Err(common::Error::FieldClash(field));
20669            }
20670        }
20671
20672        let mut params = Params::with_capacity(4 + self._additional_params.len());
20673        params.push("resource", self._resource);
20674
20675        params.extend(self._additional_params.iter());
20676
20677        params.push("alt", "json");
20678        let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
20679        if self._scopes.is_empty() {
20680            self._scopes
20681                .insert(Scope::CloudPlatform.as_ref().to_string());
20682        }
20683
20684        #[allow(clippy::single_element_loop)]
20685        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
20686            url = params.uri_replacement(url, param_name, find_this, true);
20687        }
20688        {
20689            let to_remove = ["resource"];
20690            params.remove_params(&to_remove);
20691        }
20692
20693        let url = params.parse_with_url(&url);
20694
20695        let mut json_mime_type = mime::APPLICATION_JSON;
20696        let mut request_value_reader = {
20697            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20698            common::remove_json_null_values(&mut value);
20699            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20700            serde_json::to_writer(&mut dst, &value).unwrap();
20701            dst
20702        };
20703        let request_size = request_value_reader
20704            .seek(std::io::SeekFrom::End(0))
20705            .unwrap();
20706        request_value_reader
20707            .seek(std::io::SeekFrom::Start(0))
20708            .unwrap();
20709
20710        loop {
20711            let token = match self
20712                .hub
20713                .auth
20714                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20715                .await
20716            {
20717                Ok(token) => token,
20718                Err(e) => match dlg.token(e) {
20719                    Ok(token) => token,
20720                    Err(e) => {
20721                        dlg.finished(false);
20722                        return Err(common::Error::MissingToken(e));
20723                    }
20724                },
20725            };
20726            request_value_reader
20727                .seek(std::io::SeekFrom::Start(0))
20728                .unwrap();
20729            let mut req_result = {
20730                let client = &self.hub.client;
20731                dlg.pre_request();
20732                let mut req_builder = hyper::Request::builder()
20733                    .method(hyper::Method::POST)
20734                    .uri(url.as_str())
20735                    .header(USER_AGENT, self.hub._user_agent.clone());
20736
20737                if let Some(token) = token.as_ref() {
20738                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20739                }
20740
20741                let request = req_builder
20742                    .header(CONTENT_TYPE, json_mime_type.to_string())
20743                    .header(CONTENT_LENGTH, request_size as u64)
20744                    .body(common::to_body(
20745                        request_value_reader.get_ref().clone().into(),
20746                    ));
20747
20748                client.request(request.unwrap()).await
20749            };
20750
20751            match req_result {
20752                Err(err) => {
20753                    if let common::Retry::After(d) = dlg.http_error(&err) {
20754                        sleep(d).await;
20755                        continue;
20756                    }
20757                    dlg.finished(false);
20758                    return Err(common::Error::HttpError(err));
20759                }
20760                Ok(res) => {
20761                    let (mut parts, body) = res.into_parts();
20762                    let mut body = common::Body::new(body);
20763                    if !parts.status.is_success() {
20764                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20765                        let error = serde_json::from_str(&common::to_string(&bytes));
20766                        let response = common::to_response(parts, bytes.into());
20767
20768                        if let common::Retry::After(d) =
20769                            dlg.http_failure(&response, error.as_ref().ok())
20770                        {
20771                            sleep(d).await;
20772                            continue;
20773                        }
20774
20775                        dlg.finished(false);
20776
20777                        return Err(match error {
20778                            Ok(value) => common::Error::BadRequest(value),
20779                            _ => common::Error::Failure(response),
20780                        });
20781                    }
20782                    let response = {
20783                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20784                        let encoded = common::to_string(&bytes);
20785                        match serde_json::from_str(&encoded) {
20786                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20787                            Err(error) => {
20788                                dlg.response_json_decode_error(&encoded, &error);
20789                                return Err(common::Error::JsonDecodeError(
20790                                    encoded.to_string(),
20791                                    error,
20792                                ));
20793                            }
20794                        }
20795                    };
20796
20797                    dlg.finished(true);
20798                    return Ok(response);
20799                }
20800            }
20801        }
20802    }
20803
20804    ///
20805    /// Sets the *request* property to the given value.
20806    ///
20807    /// Even though the property as already been set when instantiating this call,
20808    /// we provide this method for API completeness.
20809    pub fn request(
20810        mut self,
20811        new_value: TestIamPermissionsRequest,
20812    ) -> ProjectLocationRuntimeTestIamPermissionCall<'a, C> {
20813        self._request = new_value;
20814        self
20815    }
20816    /// 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.
20817    ///
20818    /// Sets the *resource* path property to the given value.
20819    ///
20820    /// Even though the property as already been set when instantiating this call,
20821    /// we provide this method for API completeness.
20822    pub fn resource(
20823        mut self,
20824        new_value: &str,
20825    ) -> ProjectLocationRuntimeTestIamPermissionCall<'a, C> {
20826        self._resource = new_value.to_string();
20827        self
20828    }
20829    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20830    /// while executing the actual API request.
20831    ///
20832    /// ````text
20833    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20834    /// ````
20835    ///
20836    /// Sets the *delegate* property to the given value.
20837    pub fn delegate(
20838        mut self,
20839        new_value: &'a mut dyn common::Delegate,
20840    ) -> ProjectLocationRuntimeTestIamPermissionCall<'a, C> {
20841        self._delegate = Some(new_value);
20842        self
20843    }
20844
20845    /// Set any additional parameter of the query string used in the request.
20846    /// It should be used to set parameters which are not yet available through their own
20847    /// setters.
20848    ///
20849    /// Please note that this method must not be used to set any of the known parameters
20850    /// which have their own setter method. If done anyway, the request will fail.
20851    ///
20852    /// # Additional Parameters
20853    ///
20854    /// * *$.xgafv* (query-string) - V1 error format.
20855    /// * *access_token* (query-string) - OAuth access token.
20856    /// * *alt* (query-string) - Data format for response.
20857    /// * *callback* (query-string) - JSONP
20858    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20859    /// * *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.
20860    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20861    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20862    /// * *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.
20863    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20864    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20865    pub fn param<T>(
20866        mut self,
20867        name: T,
20868        value: T,
20869    ) -> ProjectLocationRuntimeTestIamPermissionCall<'a, C>
20870    where
20871        T: AsRef<str>,
20872    {
20873        self._additional_params
20874            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20875        self
20876    }
20877
20878    /// Identifies the authorization scope for the method you are building.
20879    ///
20880    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20881    /// [`Scope::CloudPlatform`].
20882    ///
20883    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20884    /// tokens for more than one scope.
20885    ///
20886    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20887    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20888    /// sufficient, a read-write scope will do as well.
20889    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRuntimeTestIamPermissionCall<'a, C>
20890    where
20891        St: AsRef<str>,
20892    {
20893        self._scopes.insert(String::from(scope.as_ref()));
20894        self
20895    }
20896    /// Identifies the authorization scope(s) for the method you are building.
20897    ///
20898    /// See [`Self::add_scope()`] for details.
20899    pub fn add_scopes<I, St>(
20900        mut self,
20901        scopes: I,
20902    ) -> ProjectLocationRuntimeTestIamPermissionCall<'a, C>
20903    where
20904        I: IntoIterator<Item = St>,
20905        St: AsRef<str>,
20906    {
20907        self._scopes
20908            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20909        self
20910    }
20911
20912    /// Removes all scopes, and no default scope will be used either.
20913    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20914    /// for details).
20915    pub fn clear_scopes(mut self) -> ProjectLocationRuntimeTestIamPermissionCall<'a, C> {
20916        self._scopes.clear();
20917        self
20918    }
20919}
20920
20921/// Upgrades a Managed Notebook Runtime to the latest version.
20922///
20923/// A builder for the *locations.runtimes.upgrade* method supported by a *project* resource.
20924/// It is not used directly, but through a [`ProjectMethods`] instance.
20925///
20926/// # Example
20927///
20928/// Instantiate a resource method builder
20929///
20930/// ```test_harness,no_run
20931/// # extern crate hyper;
20932/// # extern crate hyper_rustls;
20933/// # extern crate google_notebooks1 as notebooks1;
20934/// use notebooks1::api::UpgradeRuntimeRequest;
20935/// # async fn dox() {
20936/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20937///
20938/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20939/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
20940/// #     secret,
20941/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20942/// # ).build().await.unwrap();
20943///
20944/// # let client = hyper_util::client::legacy::Client::builder(
20945/// #     hyper_util::rt::TokioExecutor::new()
20946/// # )
20947/// # .build(
20948/// #     hyper_rustls::HttpsConnectorBuilder::new()
20949/// #         .with_native_roots()
20950/// #         .unwrap()
20951/// #         .https_or_http()
20952/// #         .enable_http1()
20953/// #         .build()
20954/// # );
20955/// # let mut hub = AIPlatformNotebooks::new(client, auth);
20956/// // As the method needs a request, you would usually fill it with the desired information
20957/// // into the respective structure. Some of the parts shown here might not be applicable !
20958/// // Values shown here are possibly random and not representative !
20959/// let mut req = UpgradeRuntimeRequest::default();
20960///
20961/// // You can configure optional parameters by calling the respective setters at will, and
20962/// // execute the final call using `doit()`.
20963/// // Values shown here are possibly random and not representative !
20964/// let result = hub.projects().locations_runtimes_upgrade(req, "name")
20965///              .doit().await;
20966/// # }
20967/// ```
20968pub struct ProjectLocationRuntimeUpgradeCall<'a, C>
20969where
20970    C: 'a,
20971{
20972    hub: &'a AIPlatformNotebooks<C>,
20973    _request: UpgradeRuntimeRequest,
20974    _name: String,
20975    _delegate: Option<&'a mut dyn common::Delegate>,
20976    _additional_params: HashMap<String, String>,
20977    _scopes: BTreeSet<String>,
20978}
20979
20980impl<'a, C> common::CallBuilder for ProjectLocationRuntimeUpgradeCall<'a, C> {}
20981
20982impl<'a, C> ProjectLocationRuntimeUpgradeCall<'a, C>
20983where
20984    C: common::Connector,
20985{
20986    /// Perform the operation you have build so far.
20987    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
20988        use std::borrow::Cow;
20989        use std::io::{Read, Seek};
20990
20991        use common::{url::Params, ToParts};
20992        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20993
20994        let mut dd = common::DefaultDelegate;
20995        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20996        dlg.begin(common::MethodInfo {
20997            id: "notebooks.projects.locations.runtimes.upgrade",
20998            http_method: hyper::Method::POST,
20999        });
21000
21001        for &field in ["alt", "name"].iter() {
21002            if self._additional_params.contains_key(field) {
21003                dlg.finished(false);
21004                return Err(common::Error::FieldClash(field));
21005            }
21006        }
21007
21008        let mut params = Params::with_capacity(4 + self._additional_params.len());
21009        params.push("name", self._name);
21010
21011        params.extend(self._additional_params.iter());
21012
21013        params.push("alt", "json");
21014        let mut url = self.hub._base_url.clone() + "v1/{+name}:upgrade";
21015        if self._scopes.is_empty() {
21016            self._scopes
21017                .insert(Scope::CloudPlatform.as_ref().to_string());
21018        }
21019
21020        #[allow(clippy::single_element_loop)]
21021        for &(find_this, param_name) in [("{+name}", "name")].iter() {
21022            url = params.uri_replacement(url, param_name, find_this, true);
21023        }
21024        {
21025            let to_remove = ["name"];
21026            params.remove_params(&to_remove);
21027        }
21028
21029        let url = params.parse_with_url(&url);
21030
21031        let mut json_mime_type = mime::APPLICATION_JSON;
21032        let mut request_value_reader = {
21033            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21034            common::remove_json_null_values(&mut value);
21035            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21036            serde_json::to_writer(&mut dst, &value).unwrap();
21037            dst
21038        };
21039        let request_size = request_value_reader
21040            .seek(std::io::SeekFrom::End(0))
21041            .unwrap();
21042        request_value_reader
21043            .seek(std::io::SeekFrom::Start(0))
21044            .unwrap();
21045
21046        loop {
21047            let token = match self
21048                .hub
21049                .auth
21050                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21051                .await
21052            {
21053                Ok(token) => token,
21054                Err(e) => match dlg.token(e) {
21055                    Ok(token) => token,
21056                    Err(e) => {
21057                        dlg.finished(false);
21058                        return Err(common::Error::MissingToken(e));
21059                    }
21060                },
21061            };
21062            request_value_reader
21063                .seek(std::io::SeekFrom::Start(0))
21064                .unwrap();
21065            let mut req_result = {
21066                let client = &self.hub.client;
21067                dlg.pre_request();
21068                let mut req_builder = hyper::Request::builder()
21069                    .method(hyper::Method::POST)
21070                    .uri(url.as_str())
21071                    .header(USER_AGENT, self.hub._user_agent.clone());
21072
21073                if let Some(token) = token.as_ref() {
21074                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21075                }
21076
21077                let request = req_builder
21078                    .header(CONTENT_TYPE, json_mime_type.to_string())
21079                    .header(CONTENT_LENGTH, request_size as u64)
21080                    .body(common::to_body(
21081                        request_value_reader.get_ref().clone().into(),
21082                    ));
21083
21084                client.request(request.unwrap()).await
21085            };
21086
21087            match req_result {
21088                Err(err) => {
21089                    if let common::Retry::After(d) = dlg.http_error(&err) {
21090                        sleep(d).await;
21091                        continue;
21092                    }
21093                    dlg.finished(false);
21094                    return Err(common::Error::HttpError(err));
21095                }
21096                Ok(res) => {
21097                    let (mut parts, body) = res.into_parts();
21098                    let mut body = common::Body::new(body);
21099                    if !parts.status.is_success() {
21100                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21101                        let error = serde_json::from_str(&common::to_string(&bytes));
21102                        let response = common::to_response(parts, bytes.into());
21103
21104                        if let common::Retry::After(d) =
21105                            dlg.http_failure(&response, error.as_ref().ok())
21106                        {
21107                            sleep(d).await;
21108                            continue;
21109                        }
21110
21111                        dlg.finished(false);
21112
21113                        return Err(match error {
21114                            Ok(value) => common::Error::BadRequest(value),
21115                            _ => common::Error::Failure(response),
21116                        });
21117                    }
21118                    let response = {
21119                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21120                        let encoded = common::to_string(&bytes);
21121                        match serde_json::from_str(&encoded) {
21122                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21123                            Err(error) => {
21124                                dlg.response_json_decode_error(&encoded, &error);
21125                                return Err(common::Error::JsonDecodeError(
21126                                    encoded.to_string(),
21127                                    error,
21128                                ));
21129                            }
21130                        }
21131                    };
21132
21133                    dlg.finished(true);
21134                    return Ok(response);
21135                }
21136            }
21137        }
21138    }
21139
21140    ///
21141    /// Sets the *request* property to the given value.
21142    ///
21143    /// Even though the property as already been set when instantiating this call,
21144    /// we provide this method for API completeness.
21145    pub fn request(
21146        mut self,
21147        new_value: UpgradeRuntimeRequest,
21148    ) -> ProjectLocationRuntimeUpgradeCall<'a, C> {
21149        self._request = new_value;
21150        self
21151    }
21152    /// Required. Format: `projects/{project_id}/locations/{location}/runtimes/{runtime_id}`
21153    ///
21154    /// Sets the *name* path property to the given value.
21155    ///
21156    /// Even though the property as already been set when instantiating this call,
21157    /// we provide this method for API completeness.
21158    pub fn name(mut self, new_value: &str) -> ProjectLocationRuntimeUpgradeCall<'a, C> {
21159        self._name = new_value.to_string();
21160        self
21161    }
21162    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21163    /// while executing the actual API request.
21164    ///
21165    /// ````text
21166    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21167    /// ````
21168    ///
21169    /// Sets the *delegate* property to the given value.
21170    pub fn delegate(
21171        mut self,
21172        new_value: &'a mut dyn common::Delegate,
21173    ) -> ProjectLocationRuntimeUpgradeCall<'a, C> {
21174        self._delegate = Some(new_value);
21175        self
21176    }
21177
21178    /// Set any additional parameter of the query string used in the request.
21179    /// It should be used to set parameters which are not yet available through their own
21180    /// setters.
21181    ///
21182    /// Please note that this method must not be used to set any of the known parameters
21183    /// which have their own setter method. If done anyway, the request will fail.
21184    ///
21185    /// # Additional Parameters
21186    ///
21187    /// * *$.xgafv* (query-string) - V1 error format.
21188    /// * *access_token* (query-string) - OAuth access token.
21189    /// * *alt* (query-string) - Data format for response.
21190    /// * *callback* (query-string) - JSONP
21191    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21192    /// * *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.
21193    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21194    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21195    /// * *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.
21196    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21197    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21198    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationRuntimeUpgradeCall<'a, C>
21199    where
21200        T: AsRef<str>,
21201    {
21202        self._additional_params
21203            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21204        self
21205    }
21206
21207    /// Identifies the authorization scope for the method you are building.
21208    ///
21209    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21210    /// [`Scope::CloudPlatform`].
21211    ///
21212    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21213    /// tokens for more than one scope.
21214    ///
21215    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21216    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21217    /// sufficient, a read-write scope will do as well.
21218    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationRuntimeUpgradeCall<'a, C>
21219    where
21220        St: AsRef<str>,
21221    {
21222        self._scopes.insert(String::from(scope.as_ref()));
21223        self
21224    }
21225    /// Identifies the authorization scope(s) for the method you are building.
21226    ///
21227    /// See [`Self::add_scope()`] for details.
21228    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationRuntimeUpgradeCall<'a, C>
21229    where
21230        I: IntoIterator<Item = St>,
21231        St: AsRef<str>,
21232    {
21233        self._scopes
21234            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21235        self
21236    }
21237
21238    /// Removes all scopes, and no default scope will be used either.
21239    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21240    /// for details).
21241    pub fn clear_scopes(mut self) -> ProjectLocationRuntimeUpgradeCall<'a, C> {
21242        self._scopes.clear();
21243        self
21244    }
21245}
21246
21247/// Creates a new Scheduled Notebook in a given project and location.
21248///
21249/// A builder for the *locations.schedules.create* method supported by a *project* resource.
21250/// It is not used directly, but through a [`ProjectMethods`] instance.
21251///
21252/// # Example
21253///
21254/// Instantiate a resource method builder
21255///
21256/// ```test_harness,no_run
21257/// # extern crate hyper;
21258/// # extern crate hyper_rustls;
21259/// # extern crate google_notebooks1 as notebooks1;
21260/// use notebooks1::api::Schedule;
21261/// # async fn dox() {
21262/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21263///
21264/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21265/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
21266/// #     secret,
21267/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21268/// # ).build().await.unwrap();
21269///
21270/// # let client = hyper_util::client::legacy::Client::builder(
21271/// #     hyper_util::rt::TokioExecutor::new()
21272/// # )
21273/// # .build(
21274/// #     hyper_rustls::HttpsConnectorBuilder::new()
21275/// #         .with_native_roots()
21276/// #         .unwrap()
21277/// #         .https_or_http()
21278/// #         .enable_http1()
21279/// #         .build()
21280/// # );
21281/// # let mut hub = AIPlatformNotebooks::new(client, auth);
21282/// // As the method needs a request, you would usually fill it with the desired information
21283/// // into the respective structure. Some of the parts shown here might not be applicable !
21284/// // Values shown here are possibly random and not representative !
21285/// let mut req = Schedule::default();
21286///
21287/// // You can configure optional parameters by calling the respective setters at will, and
21288/// // execute the final call using `doit()`.
21289/// // Values shown here are possibly random and not representative !
21290/// let result = hub.projects().locations_schedules_create(req, "parent")
21291///              .schedule_id("dolore")
21292///              .doit().await;
21293/// # }
21294/// ```
21295pub struct ProjectLocationScheduleCreateCall<'a, C>
21296where
21297    C: 'a,
21298{
21299    hub: &'a AIPlatformNotebooks<C>,
21300    _request: Schedule,
21301    _parent: String,
21302    _schedule_id: Option<String>,
21303    _delegate: Option<&'a mut dyn common::Delegate>,
21304    _additional_params: HashMap<String, String>,
21305    _scopes: BTreeSet<String>,
21306}
21307
21308impl<'a, C> common::CallBuilder for ProjectLocationScheduleCreateCall<'a, C> {}
21309
21310impl<'a, C> ProjectLocationScheduleCreateCall<'a, C>
21311where
21312    C: common::Connector,
21313{
21314    /// Perform the operation you have build so far.
21315    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
21316        use std::borrow::Cow;
21317        use std::io::{Read, Seek};
21318
21319        use common::{url::Params, ToParts};
21320        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21321
21322        let mut dd = common::DefaultDelegate;
21323        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21324        dlg.begin(common::MethodInfo {
21325            id: "notebooks.projects.locations.schedules.create",
21326            http_method: hyper::Method::POST,
21327        });
21328
21329        for &field in ["alt", "parent", "scheduleId"].iter() {
21330            if self._additional_params.contains_key(field) {
21331                dlg.finished(false);
21332                return Err(common::Error::FieldClash(field));
21333            }
21334        }
21335
21336        let mut params = Params::with_capacity(5 + self._additional_params.len());
21337        params.push("parent", self._parent);
21338        if let Some(value) = self._schedule_id.as_ref() {
21339            params.push("scheduleId", value);
21340        }
21341
21342        params.extend(self._additional_params.iter());
21343
21344        params.push("alt", "json");
21345        let mut url = self.hub._base_url.clone() + "v1/{+parent}/schedules";
21346        if self._scopes.is_empty() {
21347            self._scopes
21348                .insert(Scope::CloudPlatform.as_ref().to_string());
21349        }
21350
21351        #[allow(clippy::single_element_loop)]
21352        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
21353            url = params.uri_replacement(url, param_name, find_this, true);
21354        }
21355        {
21356            let to_remove = ["parent"];
21357            params.remove_params(&to_remove);
21358        }
21359
21360        let url = params.parse_with_url(&url);
21361
21362        let mut json_mime_type = mime::APPLICATION_JSON;
21363        let mut request_value_reader = {
21364            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21365            common::remove_json_null_values(&mut value);
21366            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21367            serde_json::to_writer(&mut dst, &value).unwrap();
21368            dst
21369        };
21370        let request_size = request_value_reader
21371            .seek(std::io::SeekFrom::End(0))
21372            .unwrap();
21373        request_value_reader
21374            .seek(std::io::SeekFrom::Start(0))
21375            .unwrap();
21376
21377        loop {
21378            let token = match self
21379                .hub
21380                .auth
21381                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21382                .await
21383            {
21384                Ok(token) => token,
21385                Err(e) => match dlg.token(e) {
21386                    Ok(token) => token,
21387                    Err(e) => {
21388                        dlg.finished(false);
21389                        return Err(common::Error::MissingToken(e));
21390                    }
21391                },
21392            };
21393            request_value_reader
21394                .seek(std::io::SeekFrom::Start(0))
21395                .unwrap();
21396            let mut req_result = {
21397                let client = &self.hub.client;
21398                dlg.pre_request();
21399                let mut req_builder = hyper::Request::builder()
21400                    .method(hyper::Method::POST)
21401                    .uri(url.as_str())
21402                    .header(USER_AGENT, self.hub._user_agent.clone());
21403
21404                if let Some(token) = token.as_ref() {
21405                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21406                }
21407
21408                let request = req_builder
21409                    .header(CONTENT_TYPE, json_mime_type.to_string())
21410                    .header(CONTENT_LENGTH, request_size as u64)
21411                    .body(common::to_body(
21412                        request_value_reader.get_ref().clone().into(),
21413                    ));
21414
21415                client.request(request.unwrap()).await
21416            };
21417
21418            match req_result {
21419                Err(err) => {
21420                    if let common::Retry::After(d) = dlg.http_error(&err) {
21421                        sleep(d).await;
21422                        continue;
21423                    }
21424                    dlg.finished(false);
21425                    return Err(common::Error::HttpError(err));
21426                }
21427                Ok(res) => {
21428                    let (mut parts, body) = res.into_parts();
21429                    let mut body = common::Body::new(body);
21430                    if !parts.status.is_success() {
21431                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21432                        let error = serde_json::from_str(&common::to_string(&bytes));
21433                        let response = common::to_response(parts, bytes.into());
21434
21435                        if let common::Retry::After(d) =
21436                            dlg.http_failure(&response, error.as_ref().ok())
21437                        {
21438                            sleep(d).await;
21439                            continue;
21440                        }
21441
21442                        dlg.finished(false);
21443
21444                        return Err(match error {
21445                            Ok(value) => common::Error::BadRequest(value),
21446                            _ => common::Error::Failure(response),
21447                        });
21448                    }
21449                    let response = {
21450                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21451                        let encoded = common::to_string(&bytes);
21452                        match serde_json::from_str(&encoded) {
21453                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21454                            Err(error) => {
21455                                dlg.response_json_decode_error(&encoded, &error);
21456                                return Err(common::Error::JsonDecodeError(
21457                                    encoded.to_string(),
21458                                    error,
21459                                ));
21460                            }
21461                        }
21462                    };
21463
21464                    dlg.finished(true);
21465                    return Ok(response);
21466                }
21467            }
21468        }
21469    }
21470
21471    ///
21472    /// Sets the *request* property to the given value.
21473    ///
21474    /// Even though the property as already been set when instantiating this call,
21475    /// we provide this method for API completeness.
21476    pub fn request(mut self, new_value: Schedule) -> ProjectLocationScheduleCreateCall<'a, C> {
21477        self._request = new_value;
21478        self
21479    }
21480    /// Required. Format: `parent=projects/{project_id}/locations/{location}`
21481    ///
21482    /// Sets the *parent* path property to the given value.
21483    ///
21484    /// Even though the property as already been set when instantiating this call,
21485    /// we provide this method for API completeness.
21486    pub fn parent(mut self, new_value: &str) -> ProjectLocationScheduleCreateCall<'a, C> {
21487        self._parent = new_value.to_string();
21488        self
21489    }
21490    /// Required. User-defined unique ID of this schedule.
21491    ///
21492    /// Sets the *schedule id* query property to the given value.
21493    pub fn schedule_id(mut self, new_value: &str) -> ProjectLocationScheduleCreateCall<'a, C> {
21494        self._schedule_id = Some(new_value.to_string());
21495        self
21496    }
21497    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21498    /// while executing the actual API request.
21499    ///
21500    /// ````text
21501    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21502    /// ````
21503    ///
21504    /// Sets the *delegate* property to the given value.
21505    pub fn delegate(
21506        mut self,
21507        new_value: &'a mut dyn common::Delegate,
21508    ) -> ProjectLocationScheduleCreateCall<'a, C> {
21509        self._delegate = Some(new_value);
21510        self
21511    }
21512
21513    /// Set any additional parameter of the query string used in the request.
21514    /// It should be used to set parameters which are not yet available through their own
21515    /// setters.
21516    ///
21517    /// Please note that this method must not be used to set any of the known parameters
21518    /// which have their own setter method. If done anyway, the request will fail.
21519    ///
21520    /// # Additional Parameters
21521    ///
21522    /// * *$.xgafv* (query-string) - V1 error format.
21523    /// * *access_token* (query-string) - OAuth access token.
21524    /// * *alt* (query-string) - Data format for response.
21525    /// * *callback* (query-string) - JSONP
21526    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21527    /// * *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.
21528    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21529    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21530    /// * *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.
21531    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21532    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21533    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationScheduleCreateCall<'a, C>
21534    where
21535        T: AsRef<str>,
21536    {
21537        self._additional_params
21538            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21539        self
21540    }
21541
21542    /// Identifies the authorization scope for the method you are building.
21543    ///
21544    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21545    /// [`Scope::CloudPlatform`].
21546    ///
21547    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21548    /// tokens for more than one scope.
21549    ///
21550    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21551    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21552    /// sufficient, a read-write scope will do as well.
21553    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationScheduleCreateCall<'a, C>
21554    where
21555        St: AsRef<str>,
21556    {
21557        self._scopes.insert(String::from(scope.as_ref()));
21558        self
21559    }
21560    /// Identifies the authorization scope(s) for the method you are building.
21561    ///
21562    /// See [`Self::add_scope()`] for details.
21563    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationScheduleCreateCall<'a, C>
21564    where
21565        I: IntoIterator<Item = St>,
21566        St: AsRef<str>,
21567    {
21568        self._scopes
21569            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21570        self
21571    }
21572
21573    /// Removes all scopes, and no default scope will be used either.
21574    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21575    /// for details).
21576    pub fn clear_scopes(mut self) -> ProjectLocationScheduleCreateCall<'a, C> {
21577        self._scopes.clear();
21578        self
21579    }
21580}
21581
21582/// Deletes schedule and all underlying jobs
21583///
21584/// A builder for the *locations.schedules.delete* method supported by a *project* resource.
21585/// It is not used directly, but through a [`ProjectMethods`] instance.
21586///
21587/// # Example
21588///
21589/// Instantiate a resource method builder
21590///
21591/// ```test_harness,no_run
21592/// # extern crate hyper;
21593/// # extern crate hyper_rustls;
21594/// # extern crate google_notebooks1 as notebooks1;
21595/// # async fn dox() {
21596/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21597///
21598/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21599/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
21600/// #     secret,
21601/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21602/// # ).build().await.unwrap();
21603///
21604/// # let client = hyper_util::client::legacy::Client::builder(
21605/// #     hyper_util::rt::TokioExecutor::new()
21606/// # )
21607/// # .build(
21608/// #     hyper_rustls::HttpsConnectorBuilder::new()
21609/// #         .with_native_roots()
21610/// #         .unwrap()
21611/// #         .https_or_http()
21612/// #         .enable_http1()
21613/// #         .build()
21614/// # );
21615/// # let mut hub = AIPlatformNotebooks::new(client, auth);
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_schedules_delete("name")
21620///              .doit().await;
21621/// # }
21622/// ```
21623pub struct ProjectLocationScheduleDeleteCall<'a, C>
21624where
21625    C: 'a,
21626{
21627    hub: &'a AIPlatformNotebooks<C>,
21628    _name: String,
21629    _delegate: Option<&'a mut dyn common::Delegate>,
21630    _additional_params: HashMap<String, String>,
21631    _scopes: BTreeSet<String>,
21632}
21633
21634impl<'a, C> common::CallBuilder for ProjectLocationScheduleDeleteCall<'a, C> {}
21635
21636impl<'a, C> ProjectLocationScheduleDeleteCall<'a, C>
21637where
21638    C: common::Connector,
21639{
21640    /// Perform the operation you have build so far.
21641    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
21642        use std::borrow::Cow;
21643        use std::io::{Read, Seek};
21644
21645        use common::{url::Params, ToParts};
21646        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21647
21648        let mut dd = common::DefaultDelegate;
21649        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21650        dlg.begin(common::MethodInfo {
21651            id: "notebooks.projects.locations.schedules.delete",
21652            http_method: hyper::Method::DELETE,
21653        });
21654
21655        for &field in ["alt", "name"].iter() {
21656            if self._additional_params.contains_key(field) {
21657                dlg.finished(false);
21658                return Err(common::Error::FieldClash(field));
21659            }
21660        }
21661
21662        let mut params = Params::with_capacity(3 + self._additional_params.len());
21663        params.push("name", self._name);
21664
21665        params.extend(self._additional_params.iter());
21666
21667        params.push("alt", "json");
21668        let mut url = self.hub._base_url.clone() + "v1/{+name}";
21669        if self._scopes.is_empty() {
21670            self._scopes
21671                .insert(Scope::CloudPlatform.as_ref().to_string());
21672        }
21673
21674        #[allow(clippy::single_element_loop)]
21675        for &(find_this, param_name) in [("{+name}", "name")].iter() {
21676            url = params.uri_replacement(url, param_name, find_this, true);
21677        }
21678        {
21679            let to_remove = ["name"];
21680            params.remove_params(&to_remove);
21681        }
21682
21683        let url = params.parse_with_url(&url);
21684
21685        loop {
21686            let token = match self
21687                .hub
21688                .auth
21689                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21690                .await
21691            {
21692                Ok(token) => token,
21693                Err(e) => match dlg.token(e) {
21694                    Ok(token) => token,
21695                    Err(e) => {
21696                        dlg.finished(false);
21697                        return Err(common::Error::MissingToken(e));
21698                    }
21699                },
21700            };
21701            let mut req_result = {
21702                let client = &self.hub.client;
21703                dlg.pre_request();
21704                let mut req_builder = hyper::Request::builder()
21705                    .method(hyper::Method::DELETE)
21706                    .uri(url.as_str())
21707                    .header(USER_AGENT, self.hub._user_agent.clone());
21708
21709                if let Some(token) = token.as_ref() {
21710                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21711                }
21712
21713                let request = req_builder
21714                    .header(CONTENT_LENGTH, 0_u64)
21715                    .body(common::to_body::<String>(None));
21716
21717                client.request(request.unwrap()).await
21718            };
21719
21720            match req_result {
21721                Err(err) => {
21722                    if let common::Retry::After(d) = dlg.http_error(&err) {
21723                        sleep(d).await;
21724                        continue;
21725                    }
21726                    dlg.finished(false);
21727                    return Err(common::Error::HttpError(err));
21728                }
21729                Ok(res) => {
21730                    let (mut parts, body) = res.into_parts();
21731                    let mut body = common::Body::new(body);
21732                    if !parts.status.is_success() {
21733                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21734                        let error = serde_json::from_str(&common::to_string(&bytes));
21735                        let response = common::to_response(parts, bytes.into());
21736
21737                        if let common::Retry::After(d) =
21738                            dlg.http_failure(&response, error.as_ref().ok())
21739                        {
21740                            sleep(d).await;
21741                            continue;
21742                        }
21743
21744                        dlg.finished(false);
21745
21746                        return Err(match error {
21747                            Ok(value) => common::Error::BadRequest(value),
21748                            _ => common::Error::Failure(response),
21749                        });
21750                    }
21751                    let response = {
21752                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21753                        let encoded = common::to_string(&bytes);
21754                        match serde_json::from_str(&encoded) {
21755                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21756                            Err(error) => {
21757                                dlg.response_json_decode_error(&encoded, &error);
21758                                return Err(common::Error::JsonDecodeError(
21759                                    encoded.to_string(),
21760                                    error,
21761                                ));
21762                            }
21763                        }
21764                    };
21765
21766                    dlg.finished(true);
21767                    return Ok(response);
21768                }
21769            }
21770        }
21771    }
21772
21773    /// Required. Format: `projects/{project_id}/locations/{location}/schedules/{schedule_id}`
21774    ///
21775    /// Sets the *name* path property to the given value.
21776    ///
21777    /// Even though the property as already been set when instantiating this call,
21778    /// we provide this method for API completeness.
21779    pub fn name(mut self, new_value: &str) -> ProjectLocationScheduleDeleteCall<'a, C> {
21780        self._name = new_value.to_string();
21781        self
21782    }
21783    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21784    /// while executing the actual API request.
21785    ///
21786    /// ````text
21787    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21788    /// ````
21789    ///
21790    /// Sets the *delegate* property to the given value.
21791    pub fn delegate(
21792        mut self,
21793        new_value: &'a mut dyn common::Delegate,
21794    ) -> ProjectLocationScheduleDeleteCall<'a, C> {
21795        self._delegate = Some(new_value);
21796        self
21797    }
21798
21799    /// Set any additional parameter of the query string used in the request.
21800    /// It should be used to set parameters which are not yet available through their own
21801    /// setters.
21802    ///
21803    /// Please note that this method must not be used to set any of the known parameters
21804    /// which have their own setter method. If done anyway, the request will fail.
21805    ///
21806    /// # Additional Parameters
21807    ///
21808    /// * *$.xgafv* (query-string) - V1 error format.
21809    /// * *access_token* (query-string) - OAuth access token.
21810    /// * *alt* (query-string) - Data format for response.
21811    /// * *callback* (query-string) - JSONP
21812    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21813    /// * *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.
21814    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21815    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21816    /// * *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.
21817    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21818    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21819    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationScheduleDeleteCall<'a, C>
21820    where
21821        T: AsRef<str>,
21822    {
21823        self._additional_params
21824            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21825        self
21826    }
21827
21828    /// Identifies the authorization scope for the method you are building.
21829    ///
21830    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21831    /// [`Scope::CloudPlatform`].
21832    ///
21833    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21834    /// tokens for more than one scope.
21835    ///
21836    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21837    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21838    /// sufficient, a read-write scope will do as well.
21839    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationScheduleDeleteCall<'a, C>
21840    where
21841        St: AsRef<str>,
21842    {
21843        self._scopes.insert(String::from(scope.as_ref()));
21844        self
21845    }
21846    /// Identifies the authorization scope(s) for the method you are building.
21847    ///
21848    /// See [`Self::add_scope()`] for details.
21849    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationScheduleDeleteCall<'a, C>
21850    where
21851        I: IntoIterator<Item = St>,
21852        St: AsRef<str>,
21853    {
21854        self._scopes
21855            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21856        self
21857    }
21858
21859    /// Removes all scopes, and no default scope will be used either.
21860    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21861    /// for details).
21862    pub fn clear_scopes(mut self) -> ProjectLocationScheduleDeleteCall<'a, C> {
21863        self._scopes.clear();
21864        self
21865    }
21866}
21867
21868/// Gets details of schedule
21869///
21870/// A builder for the *locations.schedules.get* method supported by a *project* resource.
21871/// It is not used directly, but through a [`ProjectMethods`] instance.
21872///
21873/// # Example
21874///
21875/// Instantiate a resource method builder
21876///
21877/// ```test_harness,no_run
21878/// # extern crate hyper;
21879/// # extern crate hyper_rustls;
21880/// # extern crate google_notebooks1 as notebooks1;
21881/// # async fn dox() {
21882/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21883///
21884/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21885/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
21886/// #     secret,
21887/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21888/// # ).build().await.unwrap();
21889///
21890/// # let client = hyper_util::client::legacy::Client::builder(
21891/// #     hyper_util::rt::TokioExecutor::new()
21892/// # )
21893/// # .build(
21894/// #     hyper_rustls::HttpsConnectorBuilder::new()
21895/// #         .with_native_roots()
21896/// #         .unwrap()
21897/// #         .https_or_http()
21898/// #         .enable_http1()
21899/// #         .build()
21900/// # );
21901/// # let mut hub = AIPlatformNotebooks::new(client, auth);
21902/// // You can configure optional parameters by calling the respective setters at will, and
21903/// // execute the final call using `doit()`.
21904/// // Values shown here are possibly random and not representative !
21905/// let result = hub.projects().locations_schedules_get("name")
21906///              .doit().await;
21907/// # }
21908/// ```
21909pub struct ProjectLocationScheduleGetCall<'a, C>
21910where
21911    C: 'a,
21912{
21913    hub: &'a AIPlatformNotebooks<C>,
21914    _name: String,
21915    _delegate: Option<&'a mut dyn common::Delegate>,
21916    _additional_params: HashMap<String, String>,
21917    _scopes: BTreeSet<String>,
21918}
21919
21920impl<'a, C> common::CallBuilder for ProjectLocationScheduleGetCall<'a, C> {}
21921
21922impl<'a, C> ProjectLocationScheduleGetCall<'a, C>
21923where
21924    C: common::Connector,
21925{
21926    /// Perform the operation you have build so far.
21927    pub async fn doit(mut self) -> common::Result<(common::Response, Schedule)> {
21928        use std::borrow::Cow;
21929        use std::io::{Read, Seek};
21930
21931        use common::{url::Params, ToParts};
21932        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21933
21934        let mut dd = common::DefaultDelegate;
21935        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21936        dlg.begin(common::MethodInfo {
21937            id: "notebooks.projects.locations.schedules.get",
21938            http_method: hyper::Method::GET,
21939        });
21940
21941        for &field in ["alt", "name"].iter() {
21942            if self._additional_params.contains_key(field) {
21943                dlg.finished(false);
21944                return Err(common::Error::FieldClash(field));
21945            }
21946        }
21947
21948        let mut params = Params::with_capacity(3 + self._additional_params.len());
21949        params.push("name", self._name);
21950
21951        params.extend(self._additional_params.iter());
21952
21953        params.push("alt", "json");
21954        let mut url = self.hub._base_url.clone() + "v1/{+name}";
21955        if self._scopes.is_empty() {
21956            self._scopes
21957                .insert(Scope::CloudPlatform.as_ref().to_string());
21958        }
21959
21960        #[allow(clippy::single_element_loop)]
21961        for &(find_this, param_name) in [("{+name}", "name")].iter() {
21962            url = params.uri_replacement(url, param_name, find_this, true);
21963        }
21964        {
21965            let to_remove = ["name"];
21966            params.remove_params(&to_remove);
21967        }
21968
21969        let url = params.parse_with_url(&url);
21970
21971        loop {
21972            let token = match self
21973                .hub
21974                .auth
21975                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21976                .await
21977            {
21978                Ok(token) => token,
21979                Err(e) => match dlg.token(e) {
21980                    Ok(token) => token,
21981                    Err(e) => {
21982                        dlg.finished(false);
21983                        return Err(common::Error::MissingToken(e));
21984                    }
21985                },
21986            };
21987            let mut req_result = {
21988                let client = &self.hub.client;
21989                dlg.pre_request();
21990                let mut req_builder = hyper::Request::builder()
21991                    .method(hyper::Method::GET)
21992                    .uri(url.as_str())
21993                    .header(USER_AGENT, self.hub._user_agent.clone());
21994
21995                if let Some(token) = token.as_ref() {
21996                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21997                }
21998
21999                let request = req_builder
22000                    .header(CONTENT_LENGTH, 0_u64)
22001                    .body(common::to_body::<String>(None));
22002
22003                client.request(request.unwrap()).await
22004            };
22005
22006            match req_result {
22007                Err(err) => {
22008                    if let common::Retry::After(d) = dlg.http_error(&err) {
22009                        sleep(d).await;
22010                        continue;
22011                    }
22012                    dlg.finished(false);
22013                    return Err(common::Error::HttpError(err));
22014                }
22015                Ok(res) => {
22016                    let (mut parts, body) = res.into_parts();
22017                    let mut body = common::Body::new(body);
22018                    if !parts.status.is_success() {
22019                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22020                        let error = serde_json::from_str(&common::to_string(&bytes));
22021                        let response = common::to_response(parts, bytes.into());
22022
22023                        if let common::Retry::After(d) =
22024                            dlg.http_failure(&response, error.as_ref().ok())
22025                        {
22026                            sleep(d).await;
22027                            continue;
22028                        }
22029
22030                        dlg.finished(false);
22031
22032                        return Err(match error {
22033                            Ok(value) => common::Error::BadRequest(value),
22034                            _ => common::Error::Failure(response),
22035                        });
22036                    }
22037                    let response = {
22038                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22039                        let encoded = common::to_string(&bytes);
22040                        match serde_json::from_str(&encoded) {
22041                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22042                            Err(error) => {
22043                                dlg.response_json_decode_error(&encoded, &error);
22044                                return Err(common::Error::JsonDecodeError(
22045                                    encoded.to_string(),
22046                                    error,
22047                                ));
22048                            }
22049                        }
22050                    };
22051
22052                    dlg.finished(true);
22053                    return Ok(response);
22054                }
22055            }
22056        }
22057    }
22058
22059    /// Required. Format: `projects/{project_id}/locations/{location}/schedules/{schedule_id}`
22060    ///
22061    /// Sets the *name* path property to the given value.
22062    ///
22063    /// Even though the property as already been set when instantiating this call,
22064    /// we provide this method for API completeness.
22065    pub fn name(mut self, new_value: &str) -> ProjectLocationScheduleGetCall<'a, C> {
22066        self._name = new_value.to_string();
22067        self
22068    }
22069    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22070    /// while executing the actual API request.
22071    ///
22072    /// ````text
22073    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22074    /// ````
22075    ///
22076    /// Sets the *delegate* property to the given value.
22077    pub fn delegate(
22078        mut self,
22079        new_value: &'a mut dyn common::Delegate,
22080    ) -> ProjectLocationScheduleGetCall<'a, C> {
22081        self._delegate = Some(new_value);
22082        self
22083    }
22084
22085    /// Set any additional parameter of the query string used in the request.
22086    /// It should be used to set parameters which are not yet available through their own
22087    /// setters.
22088    ///
22089    /// Please note that this method must not be used to set any of the known parameters
22090    /// which have their own setter method. If done anyway, the request will fail.
22091    ///
22092    /// # Additional Parameters
22093    ///
22094    /// * *$.xgafv* (query-string) - V1 error format.
22095    /// * *access_token* (query-string) - OAuth access token.
22096    /// * *alt* (query-string) - Data format for response.
22097    /// * *callback* (query-string) - JSONP
22098    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22099    /// * *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.
22100    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22101    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22102    /// * *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.
22103    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22104    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22105    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationScheduleGetCall<'a, C>
22106    where
22107        T: AsRef<str>,
22108    {
22109        self._additional_params
22110            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22111        self
22112    }
22113
22114    /// Identifies the authorization scope for the method you are building.
22115    ///
22116    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22117    /// [`Scope::CloudPlatform`].
22118    ///
22119    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22120    /// tokens for more than one scope.
22121    ///
22122    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22123    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22124    /// sufficient, a read-write scope will do as well.
22125    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationScheduleGetCall<'a, C>
22126    where
22127        St: AsRef<str>,
22128    {
22129        self._scopes.insert(String::from(scope.as_ref()));
22130        self
22131    }
22132    /// Identifies the authorization scope(s) for the method you are building.
22133    ///
22134    /// See [`Self::add_scope()`] for details.
22135    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationScheduleGetCall<'a, C>
22136    where
22137        I: IntoIterator<Item = St>,
22138        St: AsRef<str>,
22139    {
22140        self._scopes
22141            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22142        self
22143    }
22144
22145    /// Removes all scopes, and no default scope will be used either.
22146    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22147    /// for details).
22148    pub fn clear_scopes(mut self) -> ProjectLocationScheduleGetCall<'a, C> {
22149        self._scopes.clear();
22150        self
22151    }
22152}
22153
22154/// Lists schedules in a given project and location.
22155///
22156/// A builder for the *locations.schedules.list* method supported by a *project* resource.
22157/// It is not used directly, but through a [`ProjectMethods`] instance.
22158///
22159/// # Example
22160///
22161/// Instantiate a resource method builder
22162///
22163/// ```test_harness,no_run
22164/// # extern crate hyper;
22165/// # extern crate hyper_rustls;
22166/// # extern crate google_notebooks1 as notebooks1;
22167/// # async fn dox() {
22168/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22169///
22170/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22171/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
22172/// #     secret,
22173/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22174/// # ).build().await.unwrap();
22175///
22176/// # let client = hyper_util::client::legacy::Client::builder(
22177/// #     hyper_util::rt::TokioExecutor::new()
22178/// # )
22179/// # .build(
22180/// #     hyper_rustls::HttpsConnectorBuilder::new()
22181/// #         .with_native_roots()
22182/// #         .unwrap()
22183/// #         .https_or_http()
22184/// #         .enable_http1()
22185/// #         .build()
22186/// # );
22187/// # let mut hub = AIPlatformNotebooks::new(client, auth);
22188/// // You can configure optional parameters by calling the respective setters at will, and
22189/// // execute the final call using `doit()`.
22190/// // Values shown here are possibly random and not representative !
22191/// let result = hub.projects().locations_schedules_list("parent")
22192///              .page_token("sadipscing")
22193///              .page_size(-6)
22194///              .order_by("invidunt")
22195///              .filter("no")
22196///              .doit().await;
22197/// # }
22198/// ```
22199pub struct ProjectLocationScheduleListCall<'a, C>
22200where
22201    C: 'a,
22202{
22203    hub: &'a AIPlatformNotebooks<C>,
22204    _parent: String,
22205    _page_token: Option<String>,
22206    _page_size: Option<i32>,
22207    _order_by: Option<String>,
22208    _filter: Option<String>,
22209    _delegate: Option<&'a mut dyn common::Delegate>,
22210    _additional_params: HashMap<String, String>,
22211    _scopes: BTreeSet<String>,
22212}
22213
22214impl<'a, C> common::CallBuilder for ProjectLocationScheduleListCall<'a, C> {}
22215
22216impl<'a, C> ProjectLocationScheduleListCall<'a, C>
22217where
22218    C: common::Connector,
22219{
22220    /// Perform the operation you have build so far.
22221    pub async fn doit(mut self) -> common::Result<(common::Response, ListSchedulesResponse)> {
22222        use std::borrow::Cow;
22223        use std::io::{Read, Seek};
22224
22225        use common::{url::Params, ToParts};
22226        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22227
22228        let mut dd = common::DefaultDelegate;
22229        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22230        dlg.begin(common::MethodInfo {
22231            id: "notebooks.projects.locations.schedules.list",
22232            http_method: hyper::Method::GET,
22233        });
22234
22235        for &field in [
22236            "alt",
22237            "parent",
22238            "pageToken",
22239            "pageSize",
22240            "orderBy",
22241            "filter",
22242        ]
22243        .iter()
22244        {
22245            if self._additional_params.contains_key(field) {
22246                dlg.finished(false);
22247                return Err(common::Error::FieldClash(field));
22248            }
22249        }
22250
22251        let mut params = Params::with_capacity(7 + self._additional_params.len());
22252        params.push("parent", self._parent);
22253        if let Some(value) = self._page_token.as_ref() {
22254            params.push("pageToken", value);
22255        }
22256        if let Some(value) = self._page_size.as_ref() {
22257            params.push("pageSize", value.to_string());
22258        }
22259        if let Some(value) = self._order_by.as_ref() {
22260            params.push("orderBy", value);
22261        }
22262        if let Some(value) = self._filter.as_ref() {
22263            params.push("filter", value);
22264        }
22265
22266        params.extend(self._additional_params.iter());
22267
22268        params.push("alt", "json");
22269        let mut url = self.hub._base_url.clone() + "v1/{+parent}/schedules";
22270        if self._scopes.is_empty() {
22271            self._scopes
22272                .insert(Scope::CloudPlatform.as_ref().to_string());
22273        }
22274
22275        #[allow(clippy::single_element_loop)]
22276        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
22277            url = params.uri_replacement(url, param_name, find_this, true);
22278        }
22279        {
22280            let to_remove = ["parent"];
22281            params.remove_params(&to_remove);
22282        }
22283
22284        let url = params.parse_with_url(&url);
22285
22286        loop {
22287            let token = match self
22288                .hub
22289                .auth
22290                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22291                .await
22292            {
22293                Ok(token) => token,
22294                Err(e) => match dlg.token(e) {
22295                    Ok(token) => token,
22296                    Err(e) => {
22297                        dlg.finished(false);
22298                        return Err(common::Error::MissingToken(e));
22299                    }
22300                },
22301            };
22302            let mut req_result = {
22303                let client = &self.hub.client;
22304                dlg.pre_request();
22305                let mut req_builder = hyper::Request::builder()
22306                    .method(hyper::Method::GET)
22307                    .uri(url.as_str())
22308                    .header(USER_AGENT, self.hub._user_agent.clone());
22309
22310                if let Some(token) = token.as_ref() {
22311                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22312                }
22313
22314                let request = req_builder
22315                    .header(CONTENT_LENGTH, 0_u64)
22316                    .body(common::to_body::<String>(None));
22317
22318                client.request(request.unwrap()).await
22319            };
22320
22321            match req_result {
22322                Err(err) => {
22323                    if let common::Retry::After(d) = dlg.http_error(&err) {
22324                        sleep(d).await;
22325                        continue;
22326                    }
22327                    dlg.finished(false);
22328                    return Err(common::Error::HttpError(err));
22329                }
22330                Ok(res) => {
22331                    let (mut parts, body) = res.into_parts();
22332                    let mut body = common::Body::new(body);
22333                    if !parts.status.is_success() {
22334                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22335                        let error = serde_json::from_str(&common::to_string(&bytes));
22336                        let response = common::to_response(parts, bytes.into());
22337
22338                        if let common::Retry::After(d) =
22339                            dlg.http_failure(&response, error.as_ref().ok())
22340                        {
22341                            sleep(d).await;
22342                            continue;
22343                        }
22344
22345                        dlg.finished(false);
22346
22347                        return Err(match error {
22348                            Ok(value) => common::Error::BadRequest(value),
22349                            _ => common::Error::Failure(response),
22350                        });
22351                    }
22352                    let response = {
22353                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22354                        let encoded = common::to_string(&bytes);
22355                        match serde_json::from_str(&encoded) {
22356                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22357                            Err(error) => {
22358                                dlg.response_json_decode_error(&encoded, &error);
22359                                return Err(common::Error::JsonDecodeError(
22360                                    encoded.to_string(),
22361                                    error,
22362                                ));
22363                            }
22364                        }
22365                    };
22366
22367                    dlg.finished(true);
22368                    return Ok(response);
22369                }
22370            }
22371        }
22372    }
22373
22374    /// Required. Format: `parent=projects/{project_id}/locations/{location}`
22375    ///
22376    /// Sets the *parent* path property to the given value.
22377    ///
22378    /// Even though the property as already been set when instantiating this call,
22379    /// we provide this method for API completeness.
22380    pub fn parent(mut self, new_value: &str) -> ProjectLocationScheduleListCall<'a, C> {
22381        self._parent = new_value.to_string();
22382        self
22383    }
22384    /// A previous returned page token that can be used to continue listing from the last result.
22385    ///
22386    /// Sets the *page token* query property to the given value.
22387    pub fn page_token(mut self, new_value: &str) -> ProjectLocationScheduleListCall<'a, C> {
22388        self._page_token = Some(new_value.to_string());
22389        self
22390    }
22391    /// Maximum return size of the list call.
22392    ///
22393    /// Sets the *page size* query property to the given value.
22394    pub fn page_size(mut self, new_value: i32) -> ProjectLocationScheduleListCall<'a, C> {
22395        self._page_size = Some(new_value);
22396        self
22397    }
22398    /// Field to order results by.
22399    ///
22400    /// Sets the *order by* query property to the given value.
22401    pub fn order_by(mut self, new_value: &str) -> ProjectLocationScheduleListCall<'a, C> {
22402        self._order_by = Some(new_value.to_string());
22403        self
22404    }
22405    /// Filter applied to resulting schedules.
22406    ///
22407    /// Sets the *filter* query property to the given value.
22408    pub fn filter(mut self, new_value: &str) -> ProjectLocationScheduleListCall<'a, C> {
22409        self._filter = Some(new_value.to_string());
22410        self
22411    }
22412    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22413    /// while executing the actual API request.
22414    ///
22415    /// ````text
22416    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22417    /// ````
22418    ///
22419    /// Sets the *delegate* property to the given value.
22420    pub fn delegate(
22421        mut self,
22422        new_value: &'a mut dyn common::Delegate,
22423    ) -> ProjectLocationScheduleListCall<'a, C> {
22424        self._delegate = Some(new_value);
22425        self
22426    }
22427
22428    /// Set any additional parameter of the query string used in the request.
22429    /// It should be used to set parameters which are not yet available through their own
22430    /// setters.
22431    ///
22432    /// Please note that this method must not be used to set any of the known parameters
22433    /// which have their own setter method. If done anyway, the request will fail.
22434    ///
22435    /// # Additional Parameters
22436    ///
22437    /// * *$.xgafv* (query-string) - V1 error format.
22438    /// * *access_token* (query-string) - OAuth access token.
22439    /// * *alt* (query-string) - Data format for response.
22440    /// * *callback* (query-string) - JSONP
22441    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22442    /// * *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.
22443    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22444    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22445    /// * *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.
22446    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22447    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22448    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationScheduleListCall<'a, C>
22449    where
22450        T: AsRef<str>,
22451    {
22452        self._additional_params
22453            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22454        self
22455    }
22456
22457    /// Identifies the authorization scope for the method you are building.
22458    ///
22459    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22460    /// [`Scope::CloudPlatform`].
22461    ///
22462    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22463    /// tokens for more than one scope.
22464    ///
22465    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22466    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22467    /// sufficient, a read-write scope will do as well.
22468    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationScheduleListCall<'a, C>
22469    where
22470        St: AsRef<str>,
22471    {
22472        self._scopes.insert(String::from(scope.as_ref()));
22473        self
22474    }
22475    /// Identifies the authorization scope(s) for the method you are building.
22476    ///
22477    /// See [`Self::add_scope()`] for details.
22478    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationScheduleListCall<'a, C>
22479    where
22480        I: IntoIterator<Item = St>,
22481        St: AsRef<str>,
22482    {
22483        self._scopes
22484            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22485        self
22486    }
22487
22488    /// Removes all scopes, and no default scope will be used either.
22489    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22490    /// for details).
22491    pub fn clear_scopes(mut self) -> ProjectLocationScheduleListCall<'a, C> {
22492        self._scopes.clear();
22493        self
22494    }
22495}
22496
22497/// Triggers execution of an existing schedule.
22498///
22499/// A builder for the *locations.schedules.trigger* method supported by a *project* resource.
22500/// It is not used directly, but through a [`ProjectMethods`] instance.
22501///
22502/// # Example
22503///
22504/// Instantiate a resource method builder
22505///
22506/// ```test_harness,no_run
22507/// # extern crate hyper;
22508/// # extern crate hyper_rustls;
22509/// # extern crate google_notebooks1 as notebooks1;
22510/// use notebooks1::api::TriggerScheduleRequest;
22511/// # async fn dox() {
22512/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22513///
22514/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22515/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
22516/// #     secret,
22517/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22518/// # ).build().await.unwrap();
22519///
22520/// # let client = hyper_util::client::legacy::Client::builder(
22521/// #     hyper_util::rt::TokioExecutor::new()
22522/// # )
22523/// # .build(
22524/// #     hyper_rustls::HttpsConnectorBuilder::new()
22525/// #         .with_native_roots()
22526/// #         .unwrap()
22527/// #         .https_or_http()
22528/// #         .enable_http1()
22529/// #         .build()
22530/// # );
22531/// # let mut hub = AIPlatformNotebooks::new(client, auth);
22532/// // As the method needs a request, you would usually fill it with the desired information
22533/// // into the respective structure. Some of the parts shown here might not be applicable !
22534/// // Values shown here are possibly random and not representative !
22535/// let mut req = TriggerScheduleRequest::default();
22536///
22537/// // You can configure optional parameters by calling the respective setters at will, and
22538/// // execute the final call using `doit()`.
22539/// // Values shown here are possibly random and not representative !
22540/// let result = hub.projects().locations_schedules_trigger(req, "name")
22541///              .doit().await;
22542/// # }
22543/// ```
22544pub struct ProjectLocationScheduleTriggerCall<'a, C>
22545where
22546    C: 'a,
22547{
22548    hub: &'a AIPlatformNotebooks<C>,
22549    _request: TriggerScheduleRequest,
22550    _name: String,
22551    _delegate: Option<&'a mut dyn common::Delegate>,
22552    _additional_params: HashMap<String, String>,
22553    _scopes: BTreeSet<String>,
22554}
22555
22556impl<'a, C> common::CallBuilder for ProjectLocationScheduleTriggerCall<'a, C> {}
22557
22558impl<'a, C> ProjectLocationScheduleTriggerCall<'a, C>
22559where
22560    C: common::Connector,
22561{
22562    /// Perform the operation you have build so far.
22563    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
22564        use std::borrow::Cow;
22565        use std::io::{Read, Seek};
22566
22567        use common::{url::Params, ToParts};
22568        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22569
22570        let mut dd = common::DefaultDelegate;
22571        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22572        dlg.begin(common::MethodInfo {
22573            id: "notebooks.projects.locations.schedules.trigger",
22574            http_method: hyper::Method::POST,
22575        });
22576
22577        for &field in ["alt", "name"].iter() {
22578            if self._additional_params.contains_key(field) {
22579                dlg.finished(false);
22580                return Err(common::Error::FieldClash(field));
22581            }
22582        }
22583
22584        let mut params = Params::with_capacity(4 + self._additional_params.len());
22585        params.push("name", self._name);
22586
22587        params.extend(self._additional_params.iter());
22588
22589        params.push("alt", "json");
22590        let mut url = self.hub._base_url.clone() + "v1/{+name}:trigger";
22591        if self._scopes.is_empty() {
22592            self._scopes
22593                .insert(Scope::CloudPlatform.as_ref().to_string());
22594        }
22595
22596        #[allow(clippy::single_element_loop)]
22597        for &(find_this, param_name) in [("{+name}", "name")].iter() {
22598            url = params.uri_replacement(url, param_name, find_this, true);
22599        }
22600        {
22601            let to_remove = ["name"];
22602            params.remove_params(&to_remove);
22603        }
22604
22605        let url = params.parse_with_url(&url);
22606
22607        let mut json_mime_type = mime::APPLICATION_JSON;
22608        let mut request_value_reader = {
22609            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
22610            common::remove_json_null_values(&mut value);
22611            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
22612            serde_json::to_writer(&mut dst, &value).unwrap();
22613            dst
22614        };
22615        let request_size = request_value_reader
22616            .seek(std::io::SeekFrom::End(0))
22617            .unwrap();
22618        request_value_reader
22619            .seek(std::io::SeekFrom::Start(0))
22620            .unwrap();
22621
22622        loop {
22623            let token = match self
22624                .hub
22625                .auth
22626                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22627                .await
22628            {
22629                Ok(token) => token,
22630                Err(e) => match dlg.token(e) {
22631                    Ok(token) => token,
22632                    Err(e) => {
22633                        dlg.finished(false);
22634                        return Err(common::Error::MissingToken(e));
22635                    }
22636                },
22637            };
22638            request_value_reader
22639                .seek(std::io::SeekFrom::Start(0))
22640                .unwrap();
22641            let mut req_result = {
22642                let client = &self.hub.client;
22643                dlg.pre_request();
22644                let mut req_builder = hyper::Request::builder()
22645                    .method(hyper::Method::POST)
22646                    .uri(url.as_str())
22647                    .header(USER_AGENT, self.hub._user_agent.clone());
22648
22649                if let Some(token) = token.as_ref() {
22650                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22651                }
22652
22653                let request = req_builder
22654                    .header(CONTENT_TYPE, json_mime_type.to_string())
22655                    .header(CONTENT_LENGTH, request_size as u64)
22656                    .body(common::to_body(
22657                        request_value_reader.get_ref().clone().into(),
22658                    ));
22659
22660                client.request(request.unwrap()).await
22661            };
22662
22663            match req_result {
22664                Err(err) => {
22665                    if let common::Retry::After(d) = dlg.http_error(&err) {
22666                        sleep(d).await;
22667                        continue;
22668                    }
22669                    dlg.finished(false);
22670                    return Err(common::Error::HttpError(err));
22671                }
22672                Ok(res) => {
22673                    let (mut parts, body) = res.into_parts();
22674                    let mut body = common::Body::new(body);
22675                    if !parts.status.is_success() {
22676                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22677                        let error = serde_json::from_str(&common::to_string(&bytes));
22678                        let response = common::to_response(parts, bytes.into());
22679
22680                        if let common::Retry::After(d) =
22681                            dlg.http_failure(&response, error.as_ref().ok())
22682                        {
22683                            sleep(d).await;
22684                            continue;
22685                        }
22686
22687                        dlg.finished(false);
22688
22689                        return Err(match error {
22690                            Ok(value) => common::Error::BadRequest(value),
22691                            _ => common::Error::Failure(response),
22692                        });
22693                    }
22694                    let response = {
22695                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22696                        let encoded = common::to_string(&bytes);
22697                        match serde_json::from_str(&encoded) {
22698                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22699                            Err(error) => {
22700                                dlg.response_json_decode_error(&encoded, &error);
22701                                return Err(common::Error::JsonDecodeError(
22702                                    encoded.to_string(),
22703                                    error,
22704                                ));
22705                            }
22706                        }
22707                    };
22708
22709                    dlg.finished(true);
22710                    return Ok(response);
22711                }
22712            }
22713        }
22714    }
22715
22716    ///
22717    /// Sets the *request* property to the given value.
22718    ///
22719    /// Even though the property as already been set when instantiating this call,
22720    /// we provide this method for API completeness.
22721    pub fn request(
22722        mut self,
22723        new_value: TriggerScheduleRequest,
22724    ) -> ProjectLocationScheduleTriggerCall<'a, C> {
22725        self._request = new_value;
22726        self
22727    }
22728    /// Required. Format: `parent=projects/{project_id}/locations/{location}/schedules/{schedule_id}`
22729    ///
22730    /// Sets the *name* path property to the given value.
22731    ///
22732    /// Even though the property as already been set when instantiating this call,
22733    /// we provide this method for API completeness.
22734    pub fn name(mut self, new_value: &str) -> ProjectLocationScheduleTriggerCall<'a, C> {
22735        self._name = new_value.to_string();
22736        self
22737    }
22738    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22739    /// while executing the actual API request.
22740    ///
22741    /// ````text
22742    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22743    /// ````
22744    ///
22745    /// Sets the *delegate* property to the given value.
22746    pub fn delegate(
22747        mut self,
22748        new_value: &'a mut dyn common::Delegate,
22749    ) -> ProjectLocationScheduleTriggerCall<'a, C> {
22750        self._delegate = Some(new_value);
22751        self
22752    }
22753
22754    /// Set any additional parameter of the query string used in the request.
22755    /// It should be used to set parameters which are not yet available through their own
22756    /// setters.
22757    ///
22758    /// Please note that this method must not be used to set any of the known parameters
22759    /// which have their own setter method. If done anyway, the request will fail.
22760    ///
22761    /// # Additional Parameters
22762    ///
22763    /// * *$.xgafv* (query-string) - V1 error format.
22764    /// * *access_token* (query-string) - OAuth access token.
22765    /// * *alt* (query-string) - Data format for response.
22766    /// * *callback* (query-string) - JSONP
22767    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22768    /// * *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.
22769    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22770    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22771    /// * *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.
22772    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22773    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22774    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationScheduleTriggerCall<'a, C>
22775    where
22776        T: AsRef<str>,
22777    {
22778        self._additional_params
22779            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22780        self
22781    }
22782
22783    /// Identifies the authorization scope for the method you are building.
22784    ///
22785    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22786    /// [`Scope::CloudPlatform`].
22787    ///
22788    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22789    /// tokens for more than one scope.
22790    ///
22791    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22792    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22793    /// sufficient, a read-write scope will do as well.
22794    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationScheduleTriggerCall<'a, C>
22795    where
22796        St: AsRef<str>,
22797    {
22798        self._scopes.insert(String::from(scope.as_ref()));
22799        self
22800    }
22801    /// Identifies the authorization scope(s) for the method you are building.
22802    ///
22803    /// See [`Self::add_scope()`] for details.
22804    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationScheduleTriggerCall<'a, C>
22805    where
22806        I: IntoIterator<Item = St>,
22807        St: AsRef<str>,
22808    {
22809        self._scopes
22810            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22811        self
22812    }
22813
22814    /// Removes all scopes, and no default scope will be used either.
22815    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22816    /// for details).
22817    pub fn clear_scopes(mut self) -> ProjectLocationScheduleTriggerCall<'a, C> {
22818        self._scopes.clear();
22819        self
22820    }
22821}
22822
22823/// Gets information about a location.
22824///
22825/// A builder for the *locations.get* method supported by a *project* resource.
22826/// It is not used directly, but through a [`ProjectMethods`] instance.
22827///
22828/// # Example
22829///
22830/// Instantiate a resource method builder
22831///
22832/// ```test_harness,no_run
22833/// # extern crate hyper;
22834/// # extern crate hyper_rustls;
22835/// # extern crate google_notebooks1 as notebooks1;
22836/// # async fn dox() {
22837/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22838///
22839/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22840/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
22841/// #     secret,
22842/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22843/// # ).build().await.unwrap();
22844///
22845/// # let client = hyper_util::client::legacy::Client::builder(
22846/// #     hyper_util::rt::TokioExecutor::new()
22847/// # )
22848/// # .build(
22849/// #     hyper_rustls::HttpsConnectorBuilder::new()
22850/// #         .with_native_roots()
22851/// #         .unwrap()
22852/// #         .https_or_http()
22853/// #         .enable_http1()
22854/// #         .build()
22855/// # );
22856/// # let mut hub = AIPlatformNotebooks::new(client, auth);
22857/// // You can configure optional parameters by calling the respective setters at will, and
22858/// // execute the final call using `doit()`.
22859/// // Values shown here are possibly random and not representative !
22860/// let result = hub.projects().locations_get("name")
22861///              .doit().await;
22862/// # }
22863/// ```
22864pub struct ProjectLocationGetCall<'a, C>
22865where
22866    C: 'a,
22867{
22868    hub: &'a AIPlatformNotebooks<C>,
22869    _name: String,
22870    _delegate: Option<&'a mut dyn common::Delegate>,
22871    _additional_params: HashMap<String, String>,
22872    _scopes: BTreeSet<String>,
22873}
22874
22875impl<'a, C> common::CallBuilder for ProjectLocationGetCall<'a, C> {}
22876
22877impl<'a, C> ProjectLocationGetCall<'a, C>
22878where
22879    C: common::Connector,
22880{
22881    /// Perform the operation you have build so far.
22882    pub async fn doit(mut self) -> common::Result<(common::Response, Location)> {
22883        use std::borrow::Cow;
22884        use std::io::{Read, Seek};
22885
22886        use common::{url::Params, ToParts};
22887        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22888
22889        let mut dd = common::DefaultDelegate;
22890        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22891        dlg.begin(common::MethodInfo {
22892            id: "notebooks.projects.locations.get",
22893            http_method: hyper::Method::GET,
22894        });
22895
22896        for &field in ["alt", "name"].iter() {
22897            if self._additional_params.contains_key(field) {
22898                dlg.finished(false);
22899                return Err(common::Error::FieldClash(field));
22900            }
22901        }
22902
22903        let mut params = Params::with_capacity(3 + self._additional_params.len());
22904        params.push("name", self._name);
22905
22906        params.extend(self._additional_params.iter());
22907
22908        params.push("alt", "json");
22909        let mut url = self.hub._base_url.clone() + "v1/{+name}";
22910        if self._scopes.is_empty() {
22911            self._scopes
22912                .insert(Scope::CloudPlatform.as_ref().to_string());
22913        }
22914
22915        #[allow(clippy::single_element_loop)]
22916        for &(find_this, param_name) in [("{+name}", "name")].iter() {
22917            url = params.uri_replacement(url, param_name, find_this, true);
22918        }
22919        {
22920            let to_remove = ["name"];
22921            params.remove_params(&to_remove);
22922        }
22923
22924        let url = params.parse_with_url(&url);
22925
22926        loop {
22927            let token = match self
22928                .hub
22929                .auth
22930                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22931                .await
22932            {
22933                Ok(token) => token,
22934                Err(e) => match dlg.token(e) {
22935                    Ok(token) => token,
22936                    Err(e) => {
22937                        dlg.finished(false);
22938                        return Err(common::Error::MissingToken(e));
22939                    }
22940                },
22941            };
22942            let mut req_result = {
22943                let client = &self.hub.client;
22944                dlg.pre_request();
22945                let mut req_builder = hyper::Request::builder()
22946                    .method(hyper::Method::GET)
22947                    .uri(url.as_str())
22948                    .header(USER_AGENT, self.hub._user_agent.clone());
22949
22950                if let Some(token) = token.as_ref() {
22951                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22952                }
22953
22954                let request = req_builder
22955                    .header(CONTENT_LENGTH, 0_u64)
22956                    .body(common::to_body::<String>(None));
22957
22958                client.request(request.unwrap()).await
22959            };
22960
22961            match req_result {
22962                Err(err) => {
22963                    if let common::Retry::After(d) = dlg.http_error(&err) {
22964                        sleep(d).await;
22965                        continue;
22966                    }
22967                    dlg.finished(false);
22968                    return Err(common::Error::HttpError(err));
22969                }
22970                Ok(res) => {
22971                    let (mut parts, body) = res.into_parts();
22972                    let mut body = common::Body::new(body);
22973                    if !parts.status.is_success() {
22974                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22975                        let error = serde_json::from_str(&common::to_string(&bytes));
22976                        let response = common::to_response(parts, bytes.into());
22977
22978                        if let common::Retry::After(d) =
22979                            dlg.http_failure(&response, error.as_ref().ok())
22980                        {
22981                            sleep(d).await;
22982                            continue;
22983                        }
22984
22985                        dlg.finished(false);
22986
22987                        return Err(match error {
22988                            Ok(value) => common::Error::BadRequest(value),
22989                            _ => common::Error::Failure(response),
22990                        });
22991                    }
22992                    let response = {
22993                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22994                        let encoded = common::to_string(&bytes);
22995                        match serde_json::from_str(&encoded) {
22996                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22997                            Err(error) => {
22998                                dlg.response_json_decode_error(&encoded, &error);
22999                                return Err(common::Error::JsonDecodeError(
23000                                    encoded.to_string(),
23001                                    error,
23002                                ));
23003                            }
23004                        }
23005                    };
23006
23007                    dlg.finished(true);
23008                    return Ok(response);
23009                }
23010            }
23011        }
23012    }
23013
23014    /// Resource name for the location.
23015    ///
23016    /// Sets the *name* path property to the given value.
23017    ///
23018    /// Even though the property as already been set when instantiating this call,
23019    /// we provide this method for API completeness.
23020    pub fn name(mut self, new_value: &str) -> ProjectLocationGetCall<'a, C> {
23021        self._name = new_value.to_string();
23022        self
23023    }
23024    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23025    /// while executing the actual API request.
23026    ///
23027    /// ````text
23028    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
23029    /// ````
23030    ///
23031    /// Sets the *delegate* property to the given value.
23032    pub fn delegate(
23033        mut self,
23034        new_value: &'a mut dyn common::Delegate,
23035    ) -> ProjectLocationGetCall<'a, C> {
23036        self._delegate = Some(new_value);
23037        self
23038    }
23039
23040    /// Set any additional parameter of the query string used in the request.
23041    /// It should be used to set parameters which are not yet available through their own
23042    /// setters.
23043    ///
23044    /// Please note that this method must not be used to set any of the known parameters
23045    /// which have their own setter method. If done anyway, the request will fail.
23046    ///
23047    /// # Additional Parameters
23048    ///
23049    /// * *$.xgafv* (query-string) - V1 error format.
23050    /// * *access_token* (query-string) - OAuth access token.
23051    /// * *alt* (query-string) - Data format for response.
23052    /// * *callback* (query-string) - JSONP
23053    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23054    /// * *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.
23055    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23056    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23057    /// * *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.
23058    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23059    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23060    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCall<'a, C>
23061    where
23062        T: AsRef<str>,
23063    {
23064        self._additional_params
23065            .insert(name.as_ref().to_string(), value.as_ref().to_string());
23066        self
23067    }
23068
23069    /// Identifies the authorization scope for the method you are building.
23070    ///
23071    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23072    /// [`Scope::CloudPlatform`].
23073    ///
23074    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23075    /// tokens for more than one scope.
23076    ///
23077    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23078    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23079    /// sufficient, a read-write scope will do as well.
23080    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCall<'a, C>
23081    where
23082        St: AsRef<str>,
23083    {
23084        self._scopes.insert(String::from(scope.as_ref()));
23085        self
23086    }
23087    /// Identifies the authorization scope(s) for the method you are building.
23088    ///
23089    /// See [`Self::add_scope()`] for details.
23090    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCall<'a, C>
23091    where
23092        I: IntoIterator<Item = St>,
23093        St: AsRef<str>,
23094    {
23095        self._scopes
23096            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23097        self
23098    }
23099
23100    /// Removes all scopes, and no default scope will be used either.
23101    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23102    /// for details).
23103    pub fn clear_scopes(mut self) -> ProjectLocationGetCall<'a, C> {
23104        self._scopes.clear();
23105        self
23106    }
23107}
23108
23109/// Lists information about the supported locations for this service.
23110///
23111/// A builder for the *locations.list* method supported by a *project* resource.
23112/// It is not used directly, but through a [`ProjectMethods`] instance.
23113///
23114/// # Example
23115///
23116/// Instantiate a resource method builder
23117///
23118/// ```test_harness,no_run
23119/// # extern crate hyper;
23120/// # extern crate hyper_rustls;
23121/// # extern crate google_notebooks1 as notebooks1;
23122/// # async fn dox() {
23123/// # use notebooks1::{AIPlatformNotebooks, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23124///
23125/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23126/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
23127/// #     secret,
23128/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23129/// # ).build().await.unwrap();
23130///
23131/// # let client = hyper_util::client::legacy::Client::builder(
23132/// #     hyper_util::rt::TokioExecutor::new()
23133/// # )
23134/// # .build(
23135/// #     hyper_rustls::HttpsConnectorBuilder::new()
23136/// #         .with_native_roots()
23137/// #         .unwrap()
23138/// #         .https_or_http()
23139/// #         .enable_http1()
23140/// #         .build()
23141/// # );
23142/// # let mut hub = AIPlatformNotebooks::new(client, auth);
23143/// // You can configure optional parameters by calling the respective setters at will, and
23144/// // execute the final call using `doit()`.
23145/// // Values shown here are possibly random and not representative !
23146/// let result = hub.projects().locations_list("name")
23147///              .page_token("sit")
23148///              .page_size(-35)
23149///              .filter("tempor")
23150///              .doit().await;
23151/// # }
23152/// ```
23153pub struct ProjectLocationListCall<'a, C>
23154where
23155    C: 'a,
23156{
23157    hub: &'a AIPlatformNotebooks<C>,
23158    _name: String,
23159    _page_token: Option<String>,
23160    _page_size: Option<i32>,
23161    _filter: Option<String>,
23162    _delegate: Option<&'a mut dyn common::Delegate>,
23163    _additional_params: HashMap<String, String>,
23164    _scopes: BTreeSet<String>,
23165}
23166
23167impl<'a, C> common::CallBuilder for ProjectLocationListCall<'a, C> {}
23168
23169impl<'a, C> ProjectLocationListCall<'a, C>
23170where
23171    C: common::Connector,
23172{
23173    /// Perform the operation you have build so far.
23174    pub async fn doit(mut self) -> common::Result<(common::Response, ListLocationsResponse)> {
23175        use std::borrow::Cow;
23176        use std::io::{Read, Seek};
23177
23178        use common::{url::Params, ToParts};
23179        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23180
23181        let mut dd = common::DefaultDelegate;
23182        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23183        dlg.begin(common::MethodInfo {
23184            id: "notebooks.projects.locations.list",
23185            http_method: hyper::Method::GET,
23186        });
23187
23188        for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
23189            if self._additional_params.contains_key(field) {
23190                dlg.finished(false);
23191                return Err(common::Error::FieldClash(field));
23192            }
23193        }
23194
23195        let mut params = Params::with_capacity(6 + self._additional_params.len());
23196        params.push("name", self._name);
23197        if let Some(value) = self._page_token.as_ref() {
23198            params.push("pageToken", value);
23199        }
23200        if let Some(value) = self._page_size.as_ref() {
23201            params.push("pageSize", value.to_string());
23202        }
23203        if let Some(value) = self._filter.as_ref() {
23204            params.push("filter", value);
23205        }
23206
23207        params.extend(self._additional_params.iter());
23208
23209        params.push("alt", "json");
23210        let mut url = self.hub._base_url.clone() + "v1/{+name}/locations";
23211        if self._scopes.is_empty() {
23212            self._scopes
23213                .insert(Scope::CloudPlatform.as_ref().to_string());
23214        }
23215
23216        #[allow(clippy::single_element_loop)]
23217        for &(find_this, param_name) in [("{+name}", "name")].iter() {
23218            url = params.uri_replacement(url, param_name, find_this, true);
23219        }
23220        {
23221            let to_remove = ["name"];
23222            params.remove_params(&to_remove);
23223        }
23224
23225        let url = params.parse_with_url(&url);
23226
23227        loop {
23228            let token = match self
23229                .hub
23230                .auth
23231                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23232                .await
23233            {
23234                Ok(token) => token,
23235                Err(e) => match dlg.token(e) {
23236                    Ok(token) => token,
23237                    Err(e) => {
23238                        dlg.finished(false);
23239                        return Err(common::Error::MissingToken(e));
23240                    }
23241                },
23242            };
23243            let mut req_result = {
23244                let client = &self.hub.client;
23245                dlg.pre_request();
23246                let mut req_builder = hyper::Request::builder()
23247                    .method(hyper::Method::GET)
23248                    .uri(url.as_str())
23249                    .header(USER_AGENT, self.hub._user_agent.clone());
23250
23251                if let Some(token) = token.as_ref() {
23252                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23253                }
23254
23255                let request = req_builder
23256                    .header(CONTENT_LENGTH, 0_u64)
23257                    .body(common::to_body::<String>(None));
23258
23259                client.request(request.unwrap()).await
23260            };
23261
23262            match req_result {
23263                Err(err) => {
23264                    if let common::Retry::After(d) = dlg.http_error(&err) {
23265                        sleep(d).await;
23266                        continue;
23267                    }
23268                    dlg.finished(false);
23269                    return Err(common::Error::HttpError(err));
23270                }
23271                Ok(res) => {
23272                    let (mut parts, body) = res.into_parts();
23273                    let mut body = common::Body::new(body);
23274                    if !parts.status.is_success() {
23275                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23276                        let error = serde_json::from_str(&common::to_string(&bytes));
23277                        let response = common::to_response(parts, bytes.into());
23278
23279                        if let common::Retry::After(d) =
23280                            dlg.http_failure(&response, error.as_ref().ok())
23281                        {
23282                            sleep(d).await;
23283                            continue;
23284                        }
23285
23286                        dlg.finished(false);
23287
23288                        return Err(match error {
23289                            Ok(value) => common::Error::BadRequest(value),
23290                            _ => common::Error::Failure(response),
23291                        });
23292                    }
23293                    let response = {
23294                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23295                        let encoded = common::to_string(&bytes);
23296                        match serde_json::from_str(&encoded) {
23297                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23298                            Err(error) => {
23299                                dlg.response_json_decode_error(&encoded, &error);
23300                                return Err(common::Error::JsonDecodeError(
23301                                    encoded.to_string(),
23302                                    error,
23303                                ));
23304                            }
23305                        }
23306                    };
23307
23308                    dlg.finished(true);
23309                    return Ok(response);
23310                }
23311            }
23312        }
23313    }
23314
23315    /// The resource that owns the locations collection, if applicable.
23316    ///
23317    /// Sets the *name* path property to the given value.
23318    ///
23319    /// Even though the property as already been set when instantiating this call,
23320    /// we provide this method for API completeness.
23321    pub fn name(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
23322        self._name = new_value.to_string();
23323        self
23324    }
23325    /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
23326    ///
23327    /// Sets the *page token* query property to the given value.
23328    pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
23329        self._page_token = Some(new_value.to_string());
23330        self
23331    }
23332    /// The maximum number of results to return. If not set, the service selects a default.
23333    ///
23334    /// Sets the *page size* query property to the given value.
23335    pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C> {
23336        self._page_size = Some(new_value);
23337        self
23338    }
23339    /// 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).
23340    ///
23341    /// Sets the *filter* query property to the given value.
23342    pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
23343        self._filter = Some(new_value.to_string());
23344        self
23345    }
23346    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23347    /// while executing the actual API request.
23348    ///
23349    /// ````text
23350    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
23351    /// ````
23352    ///
23353    /// Sets the *delegate* property to the given value.
23354    pub fn delegate(
23355        mut self,
23356        new_value: &'a mut dyn common::Delegate,
23357    ) -> ProjectLocationListCall<'a, C> {
23358        self._delegate = Some(new_value);
23359        self
23360    }
23361
23362    /// Set any additional parameter of the query string used in the request.
23363    /// It should be used to set parameters which are not yet available through their own
23364    /// setters.
23365    ///
23366    /// Please note that this method must not be used to set any of the known parameters
23367    /// which have their own setter method. If done anyway, the request will fail.
23368    ///
23369    /// # Additional Parameters
23370    ///
23371    /// * *$.xgafv* (query-string) - V1 error format.
23372    /// * *access_token* (query-string) - OAuth access token.
23373    /// * *alt* (query-string) - Data format for response.
23374    /// * *callback* (query-string) - JSONP
23375    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23376    /// * *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.
23377    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23378    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23379    /// * *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.
23380    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23381    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23382    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C>
23383    where
23384        T: AsRef<str>,
23385    {
23386        self._additional_params
23387            .insert(name.as_ref().to_string(), value.as_ref().to_string());
23388        self
23389    }
23390
23391    /// Identifies the authorization scope for the method you are building.
23392    ///
23393    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23394    /// [`Scope::CloudPlatform`].
23395    ///
23396    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23397    /// tokens for more than one scope.
23398    ///
23399    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23400    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23401    /// sufficient, a read-write scope will do as well.
23402    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationListCall<'a, C>
23403    where
23404        St: AsRef<str>,
23405    {
23406        self._scopes.insert(String::from(scope.as_ref()));
23407        self
23408    }
23409    /// Identifies the authorization scope(s) for the method you are building.
23410    ///
23411    /// See [`Self::add_scope()`] for details.
23412    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationListCall<'a, C>
23413    where
23414        I: IntoIterator<Item = St>,
23415        St: AsRef<str>,
23416    {
23417        self._scopes
23418            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23419        self
23420    }
23421
23422    /// Removes all scopes, and no default scope will be used either.
23423    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23424    /// for details).
23425    pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, C> {
23426        self._scopes.clear();
23427        self
23428    }
23429}